@kecan0406/ttheme 1.2.18 → 1.2.19
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 +3 -3
- package/bin/ttheme.js +220 -218
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +9 -7
- package/shell/adapters/_bg.zsh +2 -1
- package/shell/adapters/_osc.zsh +20 -4
- package/shell/adapters/ghostty.zsh +1 -1
- package/shell/adapters/iterm2.zsh +6 -3
- package/shell/adapters/kitty.zsh +1 -1
- package/shell/adapters/konsole.zsh +1 -1
- package/shell/adapters/terminal-app.zsh +1 -1
- package/shell/adapters/warp.zsh +1 -1
- package/shell/adapters/wezterm.zsh +1 -1
- package/shell/preview.zsh +83 -23
- package/shell/ttheme.zsh +31 -13
package/bin/ttheme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as $I}from"node:module";var dI=Object.create;var{getPrototypeOf:hI,defineProperty:Eb,getOwnPropertyNames:mI}=Object;var pI=Object.prototype.hasOwnProperty;function gI(t){return this[t]}var bI,wI,Df=(t,e,n)=>{var r=t!=null&&typeof t==="object";if(r){var i=e?bI??=new WeakMap:wI??=new WeakMap,o=i.get(t);if(o)return o}n=t!=null?dI(hI(t)):{};let s=e||!t||!t.__esModule?Eb(n,"default",{value:t,enumerable:!0}):n;for(let a of mI(t))if(!pI.call(s,a))Eb(s,a,{get:gI.bind(t,a),enumerable:!0});if(r)i.set(t,s);return s};var Mt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Xt=$I(import.meta.url);var sd=Mt((Qj,Xb)=>{var GI=Xt("util"),Vb=Xt("stream"),nn=Xb.exports=function(){Vb.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};GI.inherits(nn,Vb);nn.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};nn.prototype.write=function(t,e){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let n;if(Buffer.isBuffer(t))n=t;else n=Buffer.from(t,e||this._encoding);if(this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};nn.prototype.end=function(t,e){if(t)this.write(t,e);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};nn.prototype.destroySoon=nn.prototype.end;nn.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};nn.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};nn.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];if(e.length>t.length)this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length));else this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e)};nn.prototype._processRead=function(t){this._reads.shift();let e=0,n=0,r=Buffer.alloc(t.length);while(e<t.length){let i=this._buffers[n++],o=Math.min(i.length,t.length-e);if(i.copy(r,e,0,o),e+=o,o!==i.length)this._buffers[--n]=i.slice(o)}if(n>0)this._buffers.splice(0,n);this._buffered-=t.length,t.func.call(this,r)};nn.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else if(this._buffered>=t.length)this._processRead(t);else break}if(this._buffers&&!this.writable)this._end()}catch(t){this.emit("error",t)}}});var ad=Mt((BI)=>{var Ir=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];BI.getImagePasses=function(t,e){let n=[],r=t%8,i=e%8,o=(t-r)/8,s=(e-i)/8;for(let a=0;a<Ir.length;a++){let c=Ir[a],u=o*c.x.length,f=s*c.y.length;for(let l=0;l<c.x.length;l++)if(c.x[l]<r)u++;else break;for(let l=0;l<c.y.length;l++)if(c.y[l]<i)f++;else break;if(u>0&&f>0)n.push({width:u,height:f,index:a})}return n};BI.getInterlaceIterator=function(t){return function(e,n,r){let i=e%Ir[r].x.length,o=(e-i)/Ir[r].x.length*8+Ir[r].x[i],s=n%Ir[r].y.length,a=(n-s)/Ir[r].y.length*8+Ir[r].y[s];return o*4+a*t*4}}});var cd=Mt((e_,Qb)=>{Qb.exports=function(e,n,r){let i=e+n-r,o=Math.abs(i-e),s=Math.abs(i-n),a=Math.abs(i-r);if(o<=s&&o<=a)return e;if(s<=a)return n;return r}});var ud=Mt((n_,ew)=>{var KI=ad(),zI=cd();function tw(t,e,n){let r=t*e;if(n!==8)r=Math.ceil(r/(8/n));return r}var No=ew.exports=function(t,e){let{width:n,height:r,interlace:i,bpp:o,depth:s}=t;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],i){let a=KI.getImagePasses(n,r);for(let c=0;c<a.length;c++)this._images.push({byteWidth:tw(a[c].width,o,s),height:a[c].height,lineIndex:0})}else this._images.push({byteWidth:tw(n,o,s),height:r,lineIndex:0});if(s===8)this._xComparison=o;else if(s===16)this._xComparison=o*2;else this._xComparison=1};No.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};No.prototype._unFilterType1=function(t,e,n){let r=this._xComparison,i=r-1;for(let o=0;o<n;o++){let s=t[1+o],a=o>i?e[o-r]:0;e[o]=s+a}};No.prototype._unFilterType2=function(t,e,n){let r=this._lastLine;for(let i=0;i<n;i++){let o=t[1+i],s=r?r[i]:0;e[i]=o+s}};No.prototype._unFilterType3=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let a=t[1+s],c=o?o[s]:0,u=s>i?e[s-r]:0,f=Math.floor((u+c)/2);e[s]=a+f}};No.prototype._unFilterType4=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let a=t[1+s],c=o?o[s]:0,u=s>i?e[s-r]:0,f=s>i&&o?o[s-r]:0,l=zI(u,c,f);e[s]=a+l}};No.prototype._reverseFilterLine=function(t){let e=t[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(e===0)n=t.slice(1,i+1);else switch(n=Buffer.alloc(i),e){case 1:this._unFilterType1(t,n,i);break;case 2:this._unFilterType2(t,n,i);break;case 3:this._unFilterType3(t,n,i);break;case 4:this._unFilterType4(t,n,i);break;default:throw Error("Unrecognised filter type - "+e)}if(this.write(n),r.lineIndex++,r.lineIndex>=r.height)this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex];else this._lastLine=n;if(r)this.read(r.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var iw=Mt((r_,rw)=>{var qI=Xt("util"),nw=sd(),DI=ud(),JI=rw.exports=function(t){nw.call(this);let e=[],n=this;this._filter=new DI(t,{read:this.read.bind(this),write:function(r){e.push(r)},complete:function(){n.emit("complete",Buffer.concat(e))}}),this._filter.start()};qI.inherits(JI,nw)});var To=Mt((i_,ow)=>{ow.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var dd=Mt((o_,sw)=>{var ld=[];(function(){for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)if(e&1)e=3988292384^e>>>1;else e=e>>>1;ld[t]=e}})();var fd=sw.exports=function(){this._crc=-1};fd.prototype.write=function(t){for(let e=0;e<t.length;e++)this._crc=ld[(this._crc^t[e])&255]^this._crc>>>8;return!0};fd.prototype.crc32=function(){return this._crc^-1};fd.crc32=function(t){let e=-1;for(let n=0;n<t.length;n++)e=ld[(e^t[n])&255]^e>>>8;return e^-1}});var hd=Mt((s_,aw)=>{var Ct=To(),YI=dd(),_t=aw.exports=function(t,e){this._options=t,t.checkCRC=t.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[Ct.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[Ct.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[Ct.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[Ct.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[Ct.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[Ct.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};_t.prototype.start=function(){this.read(Ct.PNG_SIGNATURE.length,this._parseSignature.bind(this))};_t.prototype._parseSignature=function(t){let e=Ct.PNG_SIGNATURE;for(let n=0;n<e.length;n++)if(t[n]!==e[n]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};_t.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r="";for(let o=4;o<8;o++)r+=String.fromCharCode(t[o]);let i=Boolean(t[4]&32);if(!this._hasIHDR&&n!==Ct.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new YI,this._crc.write(Buffer.from(r)),this._chunks[n])return this._chunks[n](e);if(!i){this.error(Error("Unsupported critical chunk type "+r));return}this.read(e+4,this._skipChunk.bind(this))};_t.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};_t.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};_t.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==e){this.error(Error("Crc error - "+e+" - "+n));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};_t.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))};_t.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r=t[8],i=t[9],o=t[10],s=t[11],a=t[12];if(r!==8&&r!==4&&r!==2&&r!==1&&r!==16){this.error(Error("Unsupported bit depth "+r));return}if(!(i in Ct.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(o!==0){this.error(Error("Unsupported compression method"));return}if(s!==0){this.error(Error("Unsupported filter method"));return}if(a!==0&&a!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=i;let c=Ct.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:n,depth:r,interlace:Boolean(a),palette:Boolean(i&Ct.COLORTYPE_PALETTE),color:Boolean(i&Ct.COLORTYPE_COLOR),alpha:Boolean(i&Ct.COLORTYPE_ALPHA),bpp:c,colorType:i}),this._handleChunkEnd()};_t.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))};_t.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let n=0;n<e;n++)this._palette.push([t[n*3],t[n*3+1],t[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};_t.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))};_t.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===Ct.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(t.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}if(this._colorType===Ct.COLORTYPE_GRAYSCALE)this.transColor([t.readUInt16BE(0)]);if(this._colorType===Ct.COLORTYPE_COLOR)this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]);this._handleChunkEnd()};_t.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))};_t.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/Ct.GAMMA_DIVISION),this._handleChunkEnd()};_t.prototype._handleIDAT=function(t){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-t,this._parseIDAT.bind(this,t))};_t.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===Ct.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(e);let n=t-e.length;if(n>0)this._handleIDAT(n);else this._handleChunkEnd()};_t.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))};_t.prototype._parseIEND=function(t){if(this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var md=Mt((eR)=>{var cw=ad(),ZI=[function(){},function(t,e,n,r){if(r===e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=255},function(t,e,n,r){if(r+1>=e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=e[r+1]},function(t,e,n,r){if(r+2>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=255},function(t,e,n,r){if(r+3>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=e[r+3]}],VI=[function(){},function(t,e,n,r){let i=e[0];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=r},function(t,e,n){let r=e[0];t[n]=r,t[n+1]=r,t[n+2]=r,t[n+3]=e[1]},function(t,e,n,r){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=r},function(t,e,n){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3]}];function XI(t,e){let n=[],r=0;function i(){if(r===t.length)throw Error("Ran out of data");let o=t[r];r++;let s,a,c,u,f,l,d,h;switch(e){default:throw Error("unrecognised depth");case 16:d=t[r],r++,n.push((o<<8)+d);break;case 4:d=o&15,h=o>>4,n.push(h,d);break;case 2:f=o&3,l=o>>2&3,d=o>>4&3,h=o>>6&3,n.push(h,d,l,f);break;case 1:s=o&1,a=o>>1&1,c=o>>2&1,u=o>>3&1,f=o>>4&1,l=o>>5&1,d=o>>6&1,h=o>>7&1,n.push(h,d,l,f,u,c,a,s);break}}return{get:function(o){while(n.length<o)i();let s=n.slice(0,o);return n=n.slice(o),s},resetAfterLine:function(){n.length=0},end:function(){if(r!==t.length)throw Error("extra data found")}}}function QI(t,e,n,r,i,o){let{width:s,height:a,index:c}=t;for(let u=0;u<a;u++)for(let f=0;f<s;f++){let l=n(f,u,c);ZI[r](e,i,l,o),o+=r}return o}function tR(t,e,n,r,i,o){let{width:s,height:a,index:c}=t;for(let u=0;u<a;u++){for(let f=0;f<s;f++){let l=i.get(r),d=n(f,u,c);VI[r](e,l,d,o)}i.resetAfterLine()}}eR.dataToBitMap=function(t,e){let{width:n,height:r,depth:i,bpp:o,interlace:s}=e,a;if(i!==8)a=XI(t,i);let c;if(i<=8)c=Buffer.alloc(n*r*4);else c=new Uint16Array(n*r*4);let u=Math.pow(2,i)-1,f=0,l,d;if(s)l=cw.getImagePasses(n,r),d=cw.getInterlaceIterator(n,r);else{let h=0;d=function(){let m=h;return h+=4,m},l=[{width:n,height:r}]}for(let h=0;h<l.length;h++)if(i===8)f=QI(l[h],c,d,o,t,f);else tR(l[h],c,d,o,a,u);if(i===8){if(f!==t.length)throw Error("extra data found")}else a.end();return c}});var pd=Mt((c_,uw)=>{function rR(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let a=0;a<n;a++){let c=i[t[o]];if(!c)throw Error("index "+t[o]+" not in palette");for(let u=0;u<4;u++)e[o+u]=c[u];o+=4}}function iR(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let a=0;a<n;a++){let c=!1;if(i.length===1){if(i[0]===t[o])c=!0}else if(i[0]===t[o]&&i[1]===t[o+1]&&i[2]===t[o+2])c=!0;if(c)for(let u=0;u<4;u++)e[o+u]=0;o+=4}}function oR(t,e,n,r,i){let o=255,s=Math.pow(2,i)-1,a=0;for(let c=0;c<r;c++)for(let u=0;u<n;u++){for(let f=0;f<4;f++)e[a+f]=Math.floor(t[a+f]*o/s+0.5);a+=4}}uw.exports=function(t,e,n=!1){let{depth:r,width:i,height:o,colorType:s,transColor:a,palette:c}=e,u=t;if(s===3)rR(t,u,i,o,c);else{if(a)iR(t,u,i,o,a);if(r!==8&&!n){if(r===16)u=Buffer.alloc(i*o*4);oR(t,u,i,o,r)}}return u}});var dw=Mt((u_,fw)=>{var sR=Xt("util"),gd=Xt("zlib"),lw=sd(),aR=iw(),cR=hd(),uR=md(),lR=pd(),yn=fw.exports=function(t){lw.call(this),this._parser=new cR(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};sR.inherits(yn,lw);yn.prototype._handleError=function(t){if(this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy)this._inflate.destroy();if(this._filter)this._filter.destroy(),this._filter.on("error",function(){});this.errord=!0};yn.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=gd.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let n=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,r=Math.max(n,gd.Z_MIN_CHUNK);this._inflate=gd.createInflate({chunkSize:r});let i=n,o=this.emit.bind(this,"error");this._inflate.on("error",function(a){if(!i)return;o(a)}),this._filter.on("complete",this._complete.bind(this));let s=this._filter.write.bind(this._filter);this._inflate.on("data",function(a){if(!i)return;if(a.length>i)a=a.slice(0,i);i-=a.length,s(a)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)};yn.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new aR(this._bitmapInfo)};yn.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t};yn.prototype._handlePalette=function(t){this._bitmapInfo.palette=t};yn.prototype._simpleTransparency=function(){this._metaData.alpha=!0};yn.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};yn.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};yn.prototype._complete=function(t){if(this.errord)return;let e;try{let n=uR.dataToBitMap(t,this._bitmapInfo);e=lR(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(n){this._handleError(n);return}this.emit("parsed",e)}});var mw=Mt((l_,hw)=>{var Ue=To();hw.exports=function(t,e,n,r){let i=[Ue.COLORTYPE_COLOR_ALPHA,Ue.COLORTYPE_ALPHA].indexOf(r.colorType)!==-1;if(r.colorType===r.inputColorType){let m=function(){let p=new ArrayBuffer(2);return new DataView(p).setInt16(0,256,!0),new Int16Array(p)[0]!==256}();if(r.bitDepth===8||r.bitDepth===16&&m)return t}let o=r.bitDepth!==16?t:new Uint16Array(t.buffer),s=255,a=Ue.COLORTYPE_TO_BPP_MAP[r.inputColorType];if(a===4&&!r.inputHasAlpha)a=3;let c=Ue.COLORTYPE_TO_BPP_MAP[r.colorType];if(r.bitDepth===16)s=65535,c*=2;let u=Buffer.alloc(e*n*c),f=0,l=0,d=r.bgColor||{};if(d.red===void 0)d.red=s;if(d.green===void 0)d.green=s;if(d.blue===void 0)d.blue=s;function h(){let m,p,b,$=s;switch(r.inputColorType){case Ue.COLORTYPE_COLOR_ALPHA:$=o[f+3],m=o[f],p=o[f+1],b=o[f+2];break;case Ue.COLORTYPE_COLOR:m=o[f],p=o[f+1],b=o[f+2];break;case Ue.COLORTYPE_ALPHA:$=o[f+1],m=o[f],p=m,b=m;break;case Ue.COLORTYPE_GRAYSCALE:m=o[f],p=m,b=m;break;default:throw Error("input color type:"+r.inputColorType+" is not supported at present")}if(r.inputHasAlpha){if(!i)$/=s,m=Math.min(Math.max(Math.round((1-$)*d.red+$*m),0),s),p=Math.min(Math.max(Math.round((1-$)*d.green+$*p),0),s),b=Math.min(Math.max(Math.round((1-$)*d.blue+$*b),0),s)}return{red:m,green:p,blue:b,alpha:$}}for(let m=0;m<n;m++)for(let p=0;p<e;p++){let b=h(o,f);switch(r.colorType){case Ue.COLORTYPE_COLOR_ALPHA:case Ue.COLORTYPE_COLOR:if(r.bitDepth===8){if(u[l]=b.red,u[l+1]=b.green,u[l+2]=b.blue,i)u[l+3]=b.alpha}else if(u.writeUInt16BE(b.red,l),u.writeUInt16BE(b.green,l+2),u.writeUInt16BE(b.blue,l+4),i)u.writeUInt16BE(b.alpha,l+6);break;case Ue.COLORTYPE_ALPHA:case Ue.COLORTYPE_GRAYSCALE:{let $=(b.red+b.green+b.blue)/3;if(r.bitDepth===8){if(u[l]=$,i)u[l+1]=b.alpha}else if(u.writeUInt16BE($,l),i)u.writeUInt16BE(b.alpha,l+2);break}default:throw Error("unrecognised color Type "+r.colorType)}f+=a,l+=c}return u}});var bw=Mt((f_,gw)=>{var pw=cd();function fR(t,e,n,r,i){for(let o=0;o<n;o++)r[i+o]=t[e+o]}function dR(t,e,n){let r=0,i=e+n;for(let o=e;o<i;o++)r+=Math.abs(t[o]);return r}function hR(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=t[e+s]-a;r[i+s]=c}}function mR(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=t[e+o]-s;i+=Math.abs(a)}return i}function pR(t,e,n,r,i){for(let o=0;o<n;o++){let s=e>0?t[e+o-n]:0,a=t[e+o]-s;r[i+o]=a}}function gR(t,e,n){let r=0,i=e+n;for(let o=e;o<i;o++){let s=e>0?t[o-n]:0,a=t[o]-s;r+=Math.abs(a)}return r}function bR(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,u=t[e+s]-(a+c>>1);r[i+s]=u}}function wR(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=t[e+o]-(s+a>>1);i+=Math.abs(c)}return i}function $R(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,u=e>0&&s>=o?t[e+s-(n+o)]:0,f=t[e+s]-pw(a,c,u);r[i+s]=f}}function kR(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=e>0&&o>=r?t[e+o-(n+r)]:0,u=t[e+o]-pw(s,a,c);i+=Math.abs(u)}return i}var yR={0:fR,1:hR,2:pR,3:bR,4:$R},vR={0:dR,1:mR,2:gR,3:wR,4:kR};gw.exports=function(t,e,n,r,i){let o;if(!("filterType"in r)||r.filterType===-1)o=[0,1,2,3,4];else if(typeof r.filterType==="number")o=[r.filterType];else throw Error("unrecognised filter types");if(r.bitDepth===16)i*=2;let s=e*i,a=0,c=0,u=Buffer.alloc((s+1)*n),f=o[0];for(let l=0;l<n;l++){if(o.length>1){let d=1/0;for(let h=0;h<o.length;h++){let m=vR[o[h]](t,c,s,i);if(m<d)f=o[h],d=m}}u[a]=f,a++,yR[f](t,c,s,u,a,i),a+=s,c+=s}return u}});var bd=Mt((d_,ww)=>{var Qt=To(),ER=dd(),SR=mw(),MR=bw(),xR=Xt("zlib"),Rr=ww.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=t.deflateLevel!=null?t.deflateLevel:9,t.deflateStrategy=t.deflateStrategy!=null?t.deflateStrategy:3,t.inputHasAlpha=t.inputHasAlpha!=null?t.inputHasAlpha:!0,t.deflateFactory=t.deflateFactory||xR.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType=typeof t.colorType==="number"?t.colorType:Qt.COLORTYPE_COLOR_ALPHA,t.inputColorType=typeof t.inputColorType==="number"?t.inputColorType:Qt.COLORTYPE_COLOR_ALPHA,[Qt.COLORTYPE_GRAYSCALE,Qt.COLORTYPE_COLOR,Qt.COLORTYPE_COLOR_ALPHA,Qt.COLORTYPE_ALPHA].indexOf(t.colorType)===-1)throw Error("option color type:"+t.colorType+" is not supported at present");if([Qt.COLORTYPE_GRAYSCALE,Qt.COLORTYPE_COLOR,Qt.COLORTYPE_COLOR_ALPHA,Qt.COLORTYPE_ALPHA].indexOf(t.inputColorType)===-1)throw Error("option input color type:"+t.inputColorType+" is not supported at present");if(t.bitDepth!==8&&t.bitDepth!==16)throw Error("option bit depth:"+t.bitDepth+" is not supported at present")};Rr.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Rr.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Rr.prototype.filterData=function(t,e,n){let r=SR(t,e,n,this._options),i=Qt.COLORTYPE_TO_BPP_MAP[this._options.colorType];return MR(r,e,n,this._options,i)};Rr.prototype._packChunk=function(t,e){let n=e?e.length:0,r=Buffer.alloc(n+12);if(r.writeUInt32BE(n,0),r.writeUInt32BE(t,4),e)e.copy(r,8);return r.writeInt32BE(ER.crc32(r.slice(4,r.length-4)),r.length-4),r};Rr.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*Qt.GAMMA_DIVISION),0),this._packChunk(Qt.TYPE_gAMA,e)};Rr.prototype.packIHDR=function(t,e){let n=Buffer.alloc(13);return n.writeUInt32BE(t,0),n.writeUInt32BE(e,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(Qt.TYPE_IHDR,n)};Rr.prototype.packIDAT=function(t){return this._packChunk(Qt.TYPE_IDAT,t)};Rr.prototype.packIEND=function(){return this._packChunk(Qt.TYPE_IEND,null)}});var vw=Mt((h_,yw)=>{var OR=Xt("util"),$w=Xt("stream"),IR=To(),RR=bd(),kw=yw.exports=function(t){$w.call(this);let e=t||{};this._packer=new RR(e),this._deflate=this._packer.createDeflate(),this.readable=!0};OR.inherits(kw,$w);kw.prototype.pack=function(t,e,n,r){if(this.emit("data",Buffer.from(IR.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,n)),r)this.emit("data",this._packer.packGAMA(r));let i=this._packer.filterData(t,e,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(o){this.emit("data",this._packer.packIDAT(o))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(i)}});var Iw=Mt((Zs,Ow)=>{var Ew=Xt("assert").ok,Ho=Xt("zlib"),PR=Xt("util"),Sw=Xt("buffer").kMaxLength;function xi(t){if(!(this instanceof xi))return new xi(t);if(t&&t.chunkSize<Ho.Z_MIN_CHUNK)t.chunkSize=Ho.Z_MIN_CHUNK;if(Ho.Inflate.call(this,t),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&t.maxLength!=null)this._maxLength=t.maxLength}function AR(t){return new xi(t)}function Mw(t,e){if(e)process.nextTick(e);if(!t._handle)return;t._handle.close(),t._handle=null}xi.prototype._processChunk=function(t,e,n){if(typeof n==="function")return Ho.Inflate._processChunk.call(this,t,e,n);let r=this,i=t&&t.length,o=this._chunkSize-this._offset,s=this._maxLength,a=0,c=[],u=0,f;this.on("error",function(m){f=m});function l(m,p){if(r._hadError)return;let b=o-p;if(Ew(b>=0,"have should not go down"),b>0){let $=r._buffer.slice(r._offset,r._offset+b);if(r._offset+=b,$.length>s)$=$.slice(0,s);if(c.push($),u+=$.length,s-=$.length,s===0)return!1}if(p===0||r._offset>=r._chunkSize)o=r._chunkSize,r._offset=0,r._buffer=Buffer.allocUnsafe(r._chunkSize);if(p===0)return a+=i-m,i=m,!0;return!1}Ew(this._handle,"zlib binding closed");let d;do d=this._handle.writeSync(e,t,a,i,this._buffer,this._offset,o),d=d||this._writeState;while(!this._hadError&&l(d[0],d[1]));if(this._hadError)throw f;if(u>=Sw)throw Mw(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+Sw.toString(16)+" bytes");let h=Buffer.concat(c,u);return Mw(this),h};PR.inherits(xi,Ho.Inflate);function NR(t,e){if(typeof e==="string")e=Buffer.from(e);if(!(e instanceof Buffer))throw TypeError("Not a string or buffer");let n=t._finishFlushFlag;if(n==null)n=Ho.Z_FINISH;return t._processChunk(e,n)}function xw(t,e){return NR(new xi(e),t)}Ow.exports=Zs=xw;Zs.Inflate=xi;Zs.createInflate=AR;Zs.inflateSync=xw});var wd=Mt((m_,Pw)=>{var Rw=Pw.exports=function(t){this._buffer=t,this._reads=[]};Rw.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})};Rw.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let t=this._reads[0];if(this._buffer.length&&(this._buffer.length>=t.length||t.allowLess)){this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}else break}if(this._reads.length>0)throw Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw Error("unrecognised content at end of stream")}});var Aw=Mt((FR)=>{var TR=wd(),HR=ud();FR.process=function(t,e){let n=[],r=new TR(t);return new HR(e,{read:r.read.bind(r),write:function(o){n.push(o)},complete:function(){}}).start(),r.process(),Buffer.concat(n)}});var Fw=Mt((g_,Hw)=>{var Nw=!0,Tw=Xt("zlib"),CR=Iw();if(!Tw.deflateSync)Nw=!1;var jR=wd(),_R=Aw(),GR=hd(),BR=md(),UR=pd();Hw.exports=function(t,e){if(!Nw)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n;function r(E){n=E}let i;function o(E){i=E}function s(E){i.transColor=E}function a(E){i.palette=E}function c(){i.alpha=!0}let u;function f(E){u=E}let l=[];function d(E){l.push(E)}let h=new jR(t);if(new GR(e,{read:h.read.bind(h),error:r,metadata:o,gamma:f,palette:a,transColor:s,inflateData:d,simpleTransparency:c}).start(),h.process(),n)throw n;let p=Buffer.concat(l);l.length=0;let b;if(i.interlace)b=Tw.inflateSync(p);else{let x=((i.width*i.bpp*i.depth+7>>3)+1)*i.height;b=CR(p,{chunkSize:x,maxLength:x})}if(p=null,!b||!b.length)throw Error("bad png - invalid inflate data response");let $=_R.process(b,i);p=null;let k=BR.dataToBitMap($,i);$=null;let v=UR(k,i,e.skipRescale);return i.data=v,i.gamma=u||0,i}});var _w=Mt((b_,jw)=>{var Lw=!0,Cw=Xt("zlib");if(!Cw.deflateSync)Lw=!1;var WR=To(),KR=bd();jw.exports=function(t,e){if(!Lw)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r=new KR(e||{}),i=[];if(i.push(Buffer.from(WR.PNG_SIGNATURE)),i.push(r.packIHDR(t.width,t.height)),t.gamma)i.push(r.packGAMA(t.gamma));let o=r.filterData(t.data,t.width,t.height),s=Cw.deflateSync(o,r.getDeflateOptions());if(o=null,!s||!s.length)throw Error("bad png - invalid compressed data response");return i.push(r.packIDAT(s)),i.push(r.packIEND()),Buffer.concat(i)}});var Gw=Mt((DR)=>{var zR=Fw(),qR=_w();DR.read=function(t,e){return zR(t,e||{})};DR.write=function(t,e){return qR(t,e)}});var Uw=Mt((tP)=>{var ZR=Xt("util"),Bw=Xt("stream"),VR=dw(),XR=vw(),QR=Gw(),ae=tP.PNG=function(t){if(Bw.call(this),t=t||{},this.width=t.width|0,this.height=t.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new VR(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(e){this.data=e,this.emit("parsed",e)}.bind(this)),this._packer=new XR(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};ZR.inherits(ae,Bw);ae.sync=QR;ae.prototype.pack=function(){if(!this.data||!this.data.length)return this.emit("error","No data provided"),this;return process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this};ae.prototype.parse=function(t,e){if(e){let n,r;n=function(i){this.removeListener("error",r),this.data=i,e(null,this)}.bind(this),r=function(i){this.removeListener("parsed",n),e(i,null)}.bind(this),this.once("parsed",n),this.once("error",r)}return this.end(t),this};ae.prototype.write=function(t){return this._parser.write(t),!0};ae.prototype.end=function(t){this._parser.end(t)};ae.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)};ae.prototype._gamma=function(t){this.gamma=t};ae.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};ae.bitblt=function(t,e,n,r,i,o,s,a){if(n|=0,r|=0,i|=0,o|=0,s|=0,a|=0,n>t.width||r>t.height||n+i>t.width||r+o>t.height)throw Error("bitblt reading outside image");if(s>e.width||a>e.height||s+i>e.width||a+o>e.height)throw Error("bitblt writing outside image");for(let c=0;c<o;c++)t.data.copy(e.data,(a+c)*e.width+s<<2,(r+c)*t.width+n<<2,(r+c)*t.width+n+i<<2)};ae.prototype.bitblt=function(t,e,n,r,i,o,s){return ae.bitblt(this,t,e,n,r,i,o,s),this};ae.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let n=0;n<t.width;n++){let r=t.width*e+n<<2;for(let i=0;i<3;i++){let o=t.data[r+i]/255;o=Math.pow(o,0.45454545454545453/t.gamma),t.data[r+i]=Math.round(o*255)}}t.gamma=0}};ae.prototype.adjustGamma=function(){ae.adjustGamma(this)}});var Hh=Mt((jB,Gk)=>{var Th={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let n="";if(t<0)n+=`\x1B[${-t}D`;else if(t>0)n+=`\x1B[${t}C`;if(e<0)n+=`\x1B[${-e}A`;else if(e>0)n+=`\x1B[${e}B`;return n},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},XN={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},QN={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let n=0;n<t;n++)e+=this.line+(n<t-1?Th.up():"");if(t)e+=Th.left;return e}};Gk.exports={cursor:Th,scroll:XN,erase:QN,beep:"\x07"}});import{spawnSync as Nj}from"node:child_process";import{isMainThread as Tj}from"node:worker_threads";import{parseArgs as Sj}from"node:util";var ft={name:"@kecan0406/ttheme",version:"1.2.18",type:"module",bin:{ttheme:"bin/ttheme.js"},files:["bin","dist/manifest.json","shell","!shell/check.zsh"],description:"Character terminal palettes for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, Warp and Konsole",license:"MIT",author:"kecan0406",repository:{type:"git",url:"git+https://github.com/kecan0406/ttheme.git"},homepage:"https://github.com/kecan0406/ttheme#readme",bugs:"https://github.com/kecan0406/ttheme/issues",keywords:["terminal","theme","ghostty","kitty","alacritty","wezterm","iterm2","konsole"],devDependencies:{"@biomejs/biome":"^2.3.0","@clack/prompts":"^1.7.0","@jsquash/jpeg":"^1.6.0","@material/material-color-utilities":"^0.4.0","@types/bun":"^1.3.0","@types/pngjs":"6.0.5","@xterm/headless":"6.0.0","fast-string-width":"^3.0.2",pngjs:"7.0.0","smol-toml":"^1.9.0",typescript:"^5.8.2",uqr:"^0.1.3"},engines:{bun:">=1.3",node:">=22"}};var Sb=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(e)=>{let n=0;t.lastIndex=0;while(t.test(e))n+=1;return e.length-n}})(),Mb=(t)=>{return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510},xb=(t)=>{return t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141};var yI=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,vI=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ob=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,EI=/\t{1,1000}/y,Ib=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,SI=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,MI=/\p{M}+/gu,xI={limit:1/0,ellipsis:""},Rb=(t,e={},n={})=>{let r=e.limit??1/0,i=e.ellipsis??"",o=e?.ellipsisWidth??(i?Rb(i,xI,n).width:0),s=0,a=n.controlWidth??0,c=n.tabWidth??8,u=n.emojiWidth??2,f=2,l=n.regularWidth??1,d=n.wideWidth??2,h=[[SI,l],[yI,0],[vI,a],[EI,c],[Ib,u],[Ob,d]],m=0,p=0,b=t.length,$=0,k=!1,v=b,E=Math.max(0,r-o),x=0,M=0,R=0,F=0;t:while(!0){if(M>x||p>=b&&p>m){let N=t.slice(x,M)||t.slice(m,p);$=0;for(let j of N.replaceAll(MI,"")){let z=j.codePointAt(0)||0;if(Mb(z))F=2;else if(xb(z))F=d;else F=l;if(R+F>E)v=Math.min(v,Math.max(x,m)+$);if(R+F>r){k=!0;break t}$+=j.length,R+=F}x=M=0}if(p>=b)break t;for(let N=0,j=h.length;N<j;N++){let[z,G]=h[N];if(z.lastIndex=p,z.test(t)){if($=z===Ob?Sb(t.slice(p,z.lastIndex)):z===Ib?1:z.lastIndex-p,F=$*G,R+F>E)v=Math.min(v,p+Math.floor((E-R)/G));if(R+F>r){k=!0;break t}R+=F,x=m,M=p,p=m=z.lastIndex;continue t}}p+=1}return{width:k?E:R,index:k?v:b,truncated:k,ellipsed:k&&r>=o}},Pb=Rb;var OI={limit:1/0,ellipsis:"",ellipsisWidth:0},II=(t,e={})=>{return Pb(t,OI,e).width},_=II;var RI=/^#[0-9a-f]{6}$/;function he(t){return RI.test(t)}function st(t){let e=Number.parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,e&255]}function At(t,e,n){let r=st(t),i=st(e);return`#${r.map((o,s)=>Math.round(o+((i[s]??0)-o)*n).toString(16).padStart(2,"0")).join("")}`}function Et(t){let[e,n,r]=st(t).map((i)=>{let o=i/255;return o<=0.03928?o/12.92:((o+0.055)/1.055)**2.4});return 0.2126*e+0.7152*n+0.0722*r}function $t(t,e){let n=Et(t),r=Et(e);return(Math.max(n,r)+0.05)/(Math.min(n,r)+0.05)}function _c(t,e){return Math.round($t(t,e)*100)/100}function PI(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function xt(t){let[e,n,r]=st(t).map(PI),i=Math.cbrt(0.4122214708*e+0.5363325363*n+0.0514459929*r),o=Math.cbrt(0.2119034982*e+0.6806995451*n+0.1073969566*r),s=Math.cbrt(0.0883024619*e+0.2817188376*n+0.6299787005*r),a=1.9779984951*i-2.428592205*o+0.4505937099*s,c=0.0259040371*i+0.7827717662*o-0.808675766*s;return{l:0.2104542553*i+0.793617785*o-0.0040720468*s,c:Math.hypot(a,c),h:(Math.atan2(c,a)*180/Math.PI+360)%360}}var Ab={dim:["2","22"],bold:["1","22"],under:["4","24"],reverse:["7","27"],accent:["36","39"],pill:["7;1;36","22;27;39"],match:["1;4;36","22;24;39"],ok:["32","39"],warn:["33","39"],error:["31","39"]},AI={stage:0.08,bar:0.14,selection:0.2,tab:0.3,line:0.45},A={gutter:"▌",current:"◆",signature:"✦",closed:"▸",opened:"▾",on:"●",off:"○",ok:"✓",miss:"✗",above:"↑",below:"↓",update:"⇡",auto:"↻",star:"★",link:"⧉",search:"⌕",linked:"⇠",contrast:"◐",swatch:"■",pictures:"▣",sep:"·",cut:"…"},Wn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Se(t){return`\x1B[${t}m`}function gt(t){return Se(Ab[t][0])}function Jf(t){return Se(Ab[t][1])}var me=Se("0"),bt=Se("39"),Nb=Se("49"),se=Se("39;49");function vi(t){return Se(String(t<8?30+t:82+t))}function Tb(t){return Se(String(t<8?40+t:92+t))}function Hb(t,e){return Se(`38;5;${t};48;5;${e}`)}function Gc(t){let e=t.replace("#","");return[e.slice(0,2),e.slice(2,4),e.slice(4,6)].map((n)=>Number.parseInt(n,16)).join(";")}function Kn(t){return Se(`38;2;${Gc(t)}`)}function Yf(t){return Se(`48;2;${Gc(t)}`)}function Fb(t,e){return Se(`48;2;${Gc(t)};38;2;${Gc(e)}`)}function Lb(t,e=bt){return`${t.map((n)=>`${Kn(n)}${A.swatch}`).join(" ")}${e}`}function Ei(t,e,n){return At(t,e,AI[n])}function Zf(t){let e=!1,n=!1,r=!1,i=!1,o=!1,s=!1;for(let c of t.split("\x1B[").slice(1)){let u=/^([0-9;]*)m/.exec(c)?.[1];if(u===void 0)continue;let f=(u||"0").split(";").map(Number);for(let l=0;l<f.length;l++){let d=f[l];if(d===0)e=n=r=i=o=s=!1;else if(d===1||d===2)e=!0;else if(d===22)e=!1;else if(d===3||d===23)n=d===3;else if(d===4||d===24)r=d===4;else if(d===7||d===27)i=d===7;else if(d===38||d===48)o||=d===38,s||=d===48,l+=f[l+1]===5?2:4;else if(d===39)o=!1;else if(d===49)s=!1;else if(d>=30&&d<=37||d>=90&&d<=97)o=!0;else if(d>=40&&d<=47||d>=100&&d<=107)s=!0}}let a=[e&&"22",n&&"23",r&&"24",i&&"27",o&&"39",s&&"49"].filter(Boolean);return a.length>0?Se(a.join(";")):""}function Me(t){let e=(n)=>(r)=>t?`${gt(n)}${r}${Jf(n)}`:r;return{color:t,dim:e("dim"),bold:e("bold"),accent:e("accent"),pill:e("pill"),ok:e("ok"),warn:e("warn"),error:e("error"),fg:(n)=>t?Kn(n):"",bg:(n)=>t?Yf(n):""}}function Bc(t,e){return e?`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`:t}function Vf(t,e){if(t[e]!=="\x1B")return 0;if(t[e+1]==="]"){let r=t.indexOf("\x07",e+2),i=t.indexOf("\x1B\\",e+2),o=r!==-1&&(i===-1||r<i)?r+1:i!==-1?i+2:0;return o?o-e:0}if(t[e+1]!=="[")return 0;let n=e+2;while(n<t.length&&!/[@-~]/.test(t[n]))n++;return n<t.length?n-e+1:0}var Xf=new Intl.Segmenter(void 0,{granularity:"grapheme"});function Uc(t){let e=[],n=0;while(n<t.length){let r=Vf(t,n);if(r>0){e.push({text:t.slice(n,n+r),start:n,end:n+r,width:0,sequence:!0}),n+=r;continue}let i=t.indexOf("\x1B",n+1),o=i===-1?t.length:i;for(let{segment:s,index:a}of Xf.segment(t.slice(n,o)))e.push({text:s,start:n+a,end:n+a+s.length,width:_(s),sequence:!1});n=o}return e}function Qf(t,e){let n="",r=0;for(let i of Uc(t)){if(!i.sequence){if(r+i.width>e)break;r+=i.width}n+=i.text}return{head:n,used:r}}function nt(t,e,n=!0){if(e<=0)return"";let r=_(t);if(r<=e)return n?t+" ".repeat(e-r):t;let{head:i,used:o}=Qf(t,e-1);return`${i}${Zf(i)}…${n?" ".repeat(e-1-o):""}`}function Cb(t,e){let{head:n,used:r}=Qf(t,e);return`${n}${Zf(n)}${" ".repeat(e-r)}`}function It(t,e,n){let r=n-_(e)-1;return r<=0?nt(t,n):`${nt(t,r)} ${e}`}function St(t,e){let n=[],r="";for(let i of t.split(/\s+/).filter(Boolean)){let o=r?`${r} ${i}`:i;if(_(o)<=e){r=o;continue}if(r)n.push(r);while(_(i)>e){let{head:s}=Qf(i,e),a=Math.max(s.lastIndexOf("/")+1,s.lastIndexOf("#")),c=a>0?a:s.length||Uc(i)[0].end;n.push(i.slice(0,c)),i=i.slice(c)}r=i}if(r)n.push(r);return n}import{existsSync as fk,readFileSync as Sh}from"node:fs";import{join as dk}from"node:path";var Mr=7,jb=3,td=0.15,_b=1.6,nd=[1,2,3,4,5,6,9,10,11,12,13,14],Gb=[7,15],xr=[1,2,3,4,5,6],xe={1:{name:"red",center:19,width:25},2:{name:"green",center:132,width:35},3:{name:"yellow",center:88,width:35},4:{name:"blue",center:250,width:60},5:{name:"magenta",center:329,width:40},6:{name:"cyan",center:197,width:60}},Si=0.03,en=25,Io=15,Ro=0.08;function zn(t,e){let n=t.ansi[e];if(n===void 0)throw Error(`${t.name}: missing ANSI ${e}`);return n}function ed(t,e,n){let r=t.background;return e.flatMap((i)=>{let o=zn(t,i);return $t(o,r)<n?[`ANSI ${i} ${o} on ${r} is ${_c(o,r)}:1, needs ${n}:1`]:[]})}function Bb(t,e){return Math.min(...e.map((n)=>$t(zn(t,n),t.background)))}var Ub=[{rule:"foreground",label:"foreground on background",unit:"ratio",min:Mr,measure:({foreground:t,background:e})=>$t(t,e),check:({foreground:t,background:e})=>$t(t,e)<Mr?[`foreground ${t} on ${e} is ${_c(t,e)}:1, needs ${Mr}:1`]:[]},{rule:"accents",label:"weakest accent on background",unit:"ratio",min:jb,measure:(t)=>Bb(t,nd),check:(t)=>ed(t,nd,jb)},{rule:"ansi0-dark",label:"ansi0 luminance",unit:"luminance",max:td,measure:(t)=>Et(zn(t,0)),check:(t)=>{let e=zn(t,0);return Et(e)>td?[`ANSI 0 ${e} has luminance ${Et(e).toFixed(3)}, needs <= ${td}`]:[]}},{rule:"light-ansi",label:"ansi7 and ansi15 on background",unit:"ratio",min:Mr,measure:(t)=>Bb(t,Gb),check:(t)=>ed(t,Gb,Mr)},{rule:"ansi8-visible",label:"ansi8 on background",unit:"ratio",min:_b,measure:(t)=>$t(zn(t,8),t.background),check:(t)=>ed(t,[8],_b)},{rule:"selection",label:"foreground on selection",unit:"ratio",min:Mr,measure:({foreground:t,selectionBackground:e})=>e===void 0?Number.NaN:$t(t,e),check:({foreground:t,selectionBackground:e})=>e!==void 0&&$t(t,e)<Mr?[`foreground ${t} on selection ${e} is ${_c(t,e)}:1, needs ${Mr}:1`]:[]}];function Oe(t,e){let n=Math.abs(t-e)%360;return Math.min(n,360-n)}var wn=(t)=>t>8?t-8:t;function Po(t){let e=t.signatureSlots.filter((n)=>n.startsWith("ansi")).map((n)=>Number(n.slice(4)));return new Set(e.flatMap((n)=>xr.includes(wn(n))?[n,n>8?n-8:n+8]:[n]))}function Ys(t,e){let n=xt(zn(t,e));return n.c<Si?void 0:n}function Or(t){let e=Po(t);return nd.flatMap((n)=>{let r=Ys(t,n),i=xe[wn(n)];if(r===void 0||i===void 0||e.has(n))return[];let o=Oe(r.h,i.center)-i.width;return o>0?[{slot:n,hue:r.h,over:o}]:[]})}function qn(t){let e=new Set(t.signatureSlots);return xr.flatMap((n)=>{let r=Ys(t,n),i=Ys(t,n+8);if(r===void 0||i===void 0||e.has(`ansi${n}`)&&e.has(`ansi${n+8}`))return[];return[{normal:n,gap:Oe(r.h,i.h)}]})}function Dn(t){let e=Po(t);return[0,8].flatMap((n)=>xr.flatMap((r)=>xr.filter((i)=>i>r).flatMap((i)=>{let[o,s]=[n+r,n+i],a=Ys(t,o),c=Ys(t,s);if(a===void 0||c===void 0||e.has(o)&&e.has(s))return[];return Oe(a.h,c.h)<Io&&Math.abs(a.l-c.l)<Ro?[[o,s]]:[]})))}var NI=[{rule:"ansi-role",label:"accent hue outside its ANSI role",unit:"degrees",max:0,measure:(t)=>Math.max(0,...Or(t).map((e)=>e.over)),check:(t)=>Or(t).map(({slot:e,hue:n,over:r})=>{let i=xe[wn(e)];return`ANSI ${e} ${zn(t,e)} has hue ${n.toFixed(0)}°, ${r.toFixed(0)}° outside ${i.name} (${i.center}±${i.width}°)`})},{rule:"bright-follows",label:"widest normal to bright hue gap",unit:"degrees",max:en,measure:(t)=>Math.max(0,...qn(t).map((e)=>e.gap)),check:(t)=>qn(t).filter((e)=>e.gap>en).map(({normal:e,gap:n})=>`ANSI ${e+8} is ${n.toFixed(0)}° from ANSI ${e}, needs <= ${en}°`)},{rule:"distinct",label:"accent pairs that read as one color",unit:"pairs",max:0,measure:(t)=>Dn(t).length,check:(t)=>Dn(t).map(([e,n])=>`ANSI ${e} ${zn(t,e)} and ANSI ${n} ${zn(t,n)} are within ${Io}° hue and ${Ro} lightness`)}],Wc=[...Ub,...NI],rd=Wc.map((t)=>t.rule),Ie=Wc.map(({rule:t,label:e,unit:n,min:r,max:i})=>({rule:t,label:e,unit:n,...r===void 0?{}:{min:r},...i===void 0?{}:{max:i}}));function $n(t){return Wc.map((e)=>Math.round(e.measure(t)*1000)/1000)}function Wb(t,e){return t.filter((n)=>!e.waive.includes(n.rule)).flatMap((n)=>n.check(e).map((r)=>({theme:e.name,rule:n.rule,detail:r})))}function Jn(t){return Wb(Wc,t)}function Kb(t){return Wb(Ub,t)}function zb(t){return t.flatMap(Jn)}import{chmodSync as TI,copyFileSync as HI,existsSync as Ao,mkdirSync as FI,readFileSync as id,realpathSync as LI,renameSync as Db,rmSync as qb,statSync as CI,writeFileSync as Jb}from"node:fs";import{dirname as jI}from"node:path";function Yb(t){return`${t}.ttheme.bak`}var _I=/^(?:#|--) ttheme begin$|path = "ttheme-|^DefaultProfile=ttheme-/m;function od(t){let e=Yb(t);if(Ao(t)&&!Ao(e)&&!_I.test(id(t,"utf8")))HI(t,e)}function L(t,e){let n=Ao(t)?LI(t):t;FI(jI(n),{recursive:!0});let r=`${n}.ttheme-${process.pid}`;if(Jb(r,e),Ao(n))TI(r,CI(n).mode&4095);Db(r,n)}function Mi(t,e,n){if(Jb(t,n),t!==e)Db(t,e)}function kn(t,e){if((Ao(t)?id(t,"utf8"):void 0)===e)return!1;return od(t),L(t,e),!0}function Zb(t,e){let n=Yb(t),r=Ao(n)?id(n,"utf8"):void 0;if(e===""&&r===void 0)return qb(t,{force:!0}),"removed";if(L(t,e),r===void 0||r===e)return qb(n,{force:!0}),"restored";return"kept backup"}import{createHash as s$}from"node:crypto";import{copyFileSync as HA,existsSync as qd,mkdirSync as FA,readdirSync as LA,readFileSync as Ko,renameSync as a$,rmSync as Wo,statSync as CA}from"node:fs";import{basename as c$,isAbsolute as jA,join as Y}from"node:path";import{createHash as sA}from"node:crypto";import{existsSync as aA,readdirSync as cA,readFileSync as uA,rmSync as lA,statSync as fA,utimesSync as dA}from"node:fs";import{join as Bo}from"node:path";import{readdirSync as hP,rmSync as mP,statSync as pP}from"node:fs";import{setDefaultAutoSelectFamilyAttemptTimeout as gP}from"node:net";import{homedir as bP}from"node:os";import{join as ea}from"node:path";import{setTimeout as wP}from"node:timers/promises";var qw=Df(Uw(),1);import{constants as iP,deflateSync as oP,inflateSync as sP}from"node:zlib";import{inflateRawSync as nP}from"node:zlib";var eP=(()=>{var t=import.meta.url;return function(e={}){var n=e,r,i,o=new Promise((g,w)=>{r=g,i=w});let a=globalThis.ServiceWorkerGlobalScope!==void 0&&typeof self<"u"&&globalThis.caches&&globalThis.caches.default!==void 0,c=typeof process==="object"&&process.release&&process.release.name==="node";if(a||c){if(!globalThis.ImageData)globalThis.ImageData=class{constructor(w,y,S){this.data=w,this.width=y,this.height=S}};if(import.meta.url===void 0)import.meta.url="https://localhost";if(typeof self<"u"&&self.location===void 0)self.location={href:""}}var u=Object.assign({},n),f=[],l="./this.program",d=(g,w)=>{throw w},h=typeof window=="object",m=typeof importScripts=="function",p=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",b="";function $(g){if(n.locateFile)return n.locateFile(g,b);return b+g}var k,v,E;if(h||m){if(m)b=self.location.href;else if(typeof document<"u"&&document.currentScript)b=document.currentScript.src;if(t)b=t;if(b.startsWith("blob:"))b="";else b=b.substr(0,b.replace(/[?#].*/,"").lastIndexOf("/")+1);{if(k=(g)=>{var w=new XMLHttpRequest;return w.open("GET",g,!1),w.send(null),w.responseText},m)E=(g)=>{var w=new XMLHttpRequest;return w.open("GET",g,!1),w.responseType="arraybuffer",w.send(null),new Uint8Array(w.response)};v=(g,w,y)=>{var S=new XMLHttpRequest;S.open("GET",g,!0),S.responseType="arraybuffer",S.onload=()=>{if(S.status==200||S.status==0&&S.response){w(S.response);return}y()},S.onerror=y,S.send(null)}}}var x=n.print||console.log.bind(console),M=n.printErr||console.error.bind(console);if(Object.assign(n,u),u=null,n.arguments)f=n.arguments;if(n.thisProgram)l=n.thisProgram;if(n.quit)d=n.quit;var R;if(n.wasmBinary)R=n.wasmBinary;var F,N=!1,j,z,G,et,q,Ot,tt,Sr,pn;function gn(){var g=F.buffer;n.HEAP8=z=new Int8Array(g),n.HEAP16=et=new Int16Array(g),n.HEAPU8=G=new Uint8Array(g),n.HEAPU16=q=new Uint16Array(g),n.HEAP32=Ot=new Int32Array(g),n.HEAPU32=tt=new Uint32Array(g),n.HEAPF32=Sr=new Float32Array(g),n.HEAPF64=pn=new Float64Array(g)}var bn=[],Fc=[],gi=[],Tf=!1;function Hf(){if(n.preRun){if(typeof n.preRun=="function")n.preRun=[n.preRun];while(n.preRun.length)E2(n.preRun.shift())}Cf(bn)}function Ff(){Tf=!0,Cf(Fc)}function v2(){if(n.postRun){if(typeof n.postRun=="function")n.postRun=[n.postRun];while(n.postRun.length)M2(n.postRun.shift())}Cf(gi)}function E2(g){bn.unshift(g)}function S2(g){Fc.unshift(g)}function M2(g){gi.unshift(g)}var bi=0,Lf=null,Ds=null;function x2(g){bi++,n.monitorRunDependencies?.(bi)}function O2(g){if(bi--,n.monitorRunDependencies?.(bi),bi==0){if(Lf!==null)clearInterval(Lf),Lf=null;if(Ds){var w=Ds;Ds=null,w()}}}function rb(g){n.onAbort?.(g),g="Aborted("+g+")",M(g),N=!0,j=1,g+=". Build with -sASSERTIONS for more info.";var w=new WebAssembly.RuntimeError(g);throw i(w),w}var I2="data:application/octet-stream;base64,",ib=(g)=>g.startsWith(I2),wi;if(n.locateFile){if(wi="mozjpeg_dec.wasm",!ib(wi))wi=$(wi)}else wi=new URL("mozjpeg_dec.wasm",import.meta.url).href;function ob(g){if(g==wi&&R)return new Uint8Array(R);if(E)return E(g);throw"both async and sync fetching of the wasm failed"}function R2(g){if(!R&&(h||m)){if(typeof fetch=="function")return fetch(g,{credentials:"same-origin"}).then((w)=>{if(!w.ok)throw`failed to load wasm binary file at '${g}'`;return w.arrayBuffer()}).catch(()=>ob(g))}return Promise.resolve().then(()=>ob(g))}function sb(g,w,y){return R2(g).then((S)=>WebAssembly.instantiate(S,w)).then(y,(S)=>{M(`failed to asynchronously prepare wasm: ${S}`),rb(S)})}function P2(g,w,y,S){if(!g&&typeof WebAssembly.instantiateStreaming=="function"&&!ib(w)&&typeof fetch=="function")return fetch(w,{credentials:"same-origin"}).then((I)=>{var P=WebAssembly.instantiateStreaming(I,y);return P.then(S,function(B){return M(`wasm streaming compile failed: ${B}`),M("falling back to ArrayBuffer instantiation"),sb(w,y,S)})});return sb(w,y,S)}function A2(){var g={a:eI};function w(S,I){return ie=S.exports,F=ie.A,gn(),mb=ie.F,S2(ie.B),O2("wasm-instantiate"),ie}x2("wasm-instantiate");function y(S){w(S.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(g,w)}catch(S){M(`Module.instantiateWasm callback failed with error: ${S}`),i(S)}return P2(R,wi,g,y).catch(i),{}}function N2(g){this.name="ExitStatus",this.message=`Program terminated with exit(${g})`,this.status=g}var Cf=(g)=>{while(g.length>0)g.shift()(n)},T2=n.noExitRuntime||!0;class ab{constructor(g){this.excPtr=g,this.ptr=g-24}set_type(g){tt[this.ptr+4>>2]=g}get_type(){return tt[this.ptr+4>>2]}set_destructor(g){tt[this.ptr+8>>2]=g}get_destructor(){return tt[this.ptr+8>>2]}set_caught(g){g=g?1:0,z[this.ptr+12]=g}get_caught(){return z[this.ptr+12]!=0}set_rethrown(g){g=g?1:0,z[this.ptr+13]=g}get_rethrown(){return z[this.ptr+13]!=0}init(g,w){this.set_adjusted_ptr(0),this.set_type(g),this.set_destructor(w)}set_adjusted_ptr(g){tt[this.ptr+16>>2]=g}get_adjusted_ptr(){return tt[this.ptr+16>>2]}get_exception_ptr(){var g=yb(this.get_type());if(g)return tt[this.excPtr>>2];var w=this.get_adjusted_ptr();if(w!==0)return w;return this.excPtr}}var cb=0,H2=0,F2=(g,w,y)=>{var S=new ab(g);throw S.init(w,y),cb=g,H2++,cb},L2=(g,w,y,S,I)=>{},C2=()=>{var g=Array(256);for(var w=0;w<256;++w)g[w]=String.fromCharCode(w);ub=g},ub,tn=(g)=>{var w="",y=g;while(G[y])w+=ub[G[y++]];return w},So={},$i={},Lc={},lb,Ee=(g)=>{throw new lb(g)},fb,db=(g)=>{throw new fb(g)},j2=(g,w,y)=>{g.forEach(function(H){Lc[H]=w});function S(H){var W=y(H);if(W.length!==g.length)db("Mismatched type converter count");for(var Q=0;Q<g.length;++Q)Gn(g[Q],W[Q])}var I=Array(w.length),P=[],B=0;if(w.forEach((H,W)=>{if($i.hasOwnProperty(H))I[W]=$i[H];else{if(P.push(H),!So.hasOwnProperty(H))So[H]=[];So[H].push(()=>{if(I[W]=$i[H],++B,B===P.length)S(I)})}}),P.length===0)S(I)};function _2(g,w,y={}){var S=w.name;if(!g)Ee(`type "${S}" must have a positive integer typeid pointer`);if($i.hasOwnProperty(g))if(y.ignoreDuplicateRegistrations)return;else Ee(`Cannot register type '${S}' twice`);if($i[g]=w,delete Lc[g],So.hasOwnProperty(g)){var I=So[g];delete So[g],I.forEach((P)=>P())}}function Gn(g,w,y={}){if(!("argPackAdvance"in w))throw TypeError("registerType registeredInstance requires argPackAdvance");return _2(g,w,y)}var ki=8,G2=(g,w,y,S)=>{w=tn(w),Gn(g,{name:w,fromWireType:function(I){return!!I},toWireType:function(I,P){return P?y:S},argPackAdvance:ki,readValueFromPointer:function(I){return this.fromWireType(G[I])},destructorFunction:null})},jf=[],Bn=[],_f=(g)=>{if(g>9&&--Bn[g+1]===0)Bn[g]=void 0,jf.push(g)},B2=()=>Bn.length/2-5-jf.length,U2=()=>{Bn.push(0,1,void 0,1,null,1,!0,1,!1,1),n.count_emval_handles=B2},yi={toValue:(g)=>{if(!g)Ee("Cannot use deleted val. handle = "+g);return Bn[g]},toHandle:(g)=>{switch(g){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let w=jf.pop()||Bn.length;return Bn[w]=g,Bn[w+1]=1,w}}}};function Gf(g){return this.fromWireType(tt[g>>2])}var W2={name:"emscripten::val",fromWireType:(g)=>{var w=yi.toValue(g);return _f(g),w},toWireType:(g,w)=>yi.toHandle(w),argPackAdvance:ki,readValueFromPointer:Gf,destructorFunction:null},K2=(g)=>Gn(g,W2),z2=(g,w)=>{switch(w){case 4:return function(y){return this.fromWireType(Sr[y>>2])};case 8:return function(y){return this.fromWireType(pn[y>>3])};default:throw TypeError(`invalid float width (${w}): ${g}`)}},q2=(g,w,y)=>{w=tn(w),Gn(g,{name:w,fromWireType:(S)=>S,toWireType:(S,I)=>I,argPackAdvance:ki,readValueFromPointer:z2(w,y),destructorFunction:null})},Bf=(g,w)=>Object.defineProperty(w,"name",{value:g}),hb=(g)=>{while(g.length){var w=g.pop(),y=g.pop();y(w)}};function D2(g){for(var w=1;w<g.length;++w)if(g[w]!==null&&g[w].destructorFunction===void 0)return!0;return!1}function J2(g,w,y,S,I,P){var B=w.length;if(B<2)Ee("argTypes array size mismatch! Must at least get return value and 'this' types!");var H=w[1]!==null&&y!==null,W=D2(w),Q=w[0].name!=="void",pt=B-2,Lt=Array(pt),oe=[],Be=[],Mo=function(...zf){if(zf.length!==pt)Ee(`function ${g} called with ${zf.length} arguments, expected ${pt}`);Be.length=0;var qf;if(oe.length=H?2:1,oe[0]=I,H)qf=w[1].toWireType(Be,this),oe[1]=qf;for(var xo=0;xo<pt;++xo)Lt[xo]=w[xo+2].toWireType(Be,zf[xo]),oe.push(Lt[xo]);var cI=S(...oe);function uI(lI){if(W)hb(Be);else for(var Oo=H?1:2;Oo<w.length;Oo++){var fI=Oo===1?qf:Lt[Oo-2];if(w[Oo].destructorFunction!==null)w[Oo].destructorFunction(fI)}if(Q)return w[0].fromWireType(lI)}return uI(cI)};return Bf(g,Mo)}var Y2=(g,w,y)=>{if(g[w].overloadTable===void 0){var S=g[w];g[w]=function(...I){if(!g[w].overloadTable.hasOwnProperty(I.length))Ee(`Function '${y}' called with an invalid number of arguments (${I.length}) - expects one of (${g[w].overloadTable})!`);return g[w].overloadTable[I.length].apply(this,I)},g[w].overloadTable=[],g[w].overloadTable[S.argCount]=S}},Z2=(g,w,y)=>{if(n.hasOwnProperty(g)){if(y===void 0||n[g].overloadTable!==void 0&&n[g].overloadTable[y]!==void 0)Ee(`Cannot register public name '${g}' twice`);if(Y2(n,g,g),n.hasOwnProperty(y))Ee(`Cannot register multiple overloads of a function with the same number of arguments (${y})!`);n[g].overloadTable[y]=w}else if(n[g]=w,y!==void 0)n[g].numArguments=y},V2=(g,w)=>{var y=[];for(var S=0;S<g;S++)y.push(tt[w+S*4>>2]);return y},X2=(g,w,y)=>{if(!n.hasOwnProperty(g))db("Replacing nonexistent public symbol");if(n[g].overloadTable!==void 0&&y!==void 0)n[g].overloadTable[y]=w;else n[g]=w,n[g].argCount=y},Q2=(g,w,y)=>{g=g.replace(/p/g,"i");var S=n["dynCall_"+g];return S(w,...y)},Cc=[],mb,pb=(g)=>{var w=Cc[g];if(!w){if(g>=Cc.length)Cc.length=g+1;Cc[g]=w=mb.get(g)}return w},tO=(g,w,y=[])=>{if(g.includes("j"))return Q2(g,w,y);var S=pb(w)(...y);return S},eO=(g,w)=>(...y)=>tO(g,w,y),nO=(g,w)=>{g=tn(g);function y(){if(g.includes("j"))return eO(g,w);return pb(w)}var S=y();if(typeof S!="function")Ee(`unknown function pointer with signature ${g}: ${w}`);return S},rO=(g,w)=>{var y=Bf(w,function(S){this.name=w,this.message=S;var I=Error(S).stack;if(I!==void 0)this.stack=this.toString()+`
|
|
3
|
-
`+I.replace(/^Error(:[^\n]*)?\n/,"")});return y.prototype=Object.create(g.prototype),y.prototype.constructor=y,y.prototype.toString=function(){if(this.message===void 0)return this.name;else return`${this.name}: ${this.message}`},y},gb,bb=(g)=>{var w=kb(g),y=tn(w);return Un(w),y},iO=(g,w)=>{var y=[],S={};function I(P){if(S[P])return;if($i[P])return;if(Lc[P]){Lc[P].forEach(I);return}y.push(P),S[P]=!0}throw w.forEach(I),new gb(`${g}: `+y.map(bb).join([", "]))},oO=(g)=>{g=g.trim();let w=g.indexOf("(");if(w!==-1)return g.substr(0,w);else return g},sO=(g,w,y,S,I,P,B)=>{var H=V2(w,y);g=tn(g),g=oO(g),I=nO(S,I),Z2(g,function(){iO(`Cannot call ${g} due to unbound types`,H)},w-1),j2([],H,(W)=>{var Q=[W[0],null].concat(W.slice(1));return X2(g,J2(g,Q,null,I,P,B),w-1),[]})},aO=(g,w,y)=>{switch(w){case 1:return y?(S)=>z[S]:(S)=>G[S];case 2:return y?(S)=>et[S>>1]:(S)=>q[S>>1];case 4:return y?(S)=>Ot[S>>2]:(S)=>tt[S>>2];default:throw TypeError(`invalid integer width (${w}): ${g}`)}},cO=(g,w,y,S,I)=>{if(w=tn(w),I===-1)I=4294967295;var P=(pt)=>pt;if(S===0){var B=32-8*y;P=(pt)=>pt<<B>>>B}var H=w.includes("unsigned"),W=(pt,Lt)=>{},Q;if(H)Q=function(pt,Lt){return W(Lt,this.name),Lt>>>0};else Q=function(pt,Lt){return W(Lt,this.name),Lt};Gn(g,{name:w,fromWireType:P,toWireType:Q,argPackAdvance:ki,readValueFromPointer:aO(w,y,S!==0),destructorFunction:null})},uO=(g,w,y)=>{var S=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],I=S[w];function P(B){var H=tt[B>>2],W=tt[B+4>>2];return new I(z.buffer,W,H)}y=tn(y),Gn(g,{name:y,fromWireType:P,argPackAdvance:ki,readValueFromPointer:P},{ignoreDuplicateRegistrations:!0})},lO=(g,w,y,S)=>{if(!(S>0))return 0;var I=y,P=y+S-1;for(var B=0;B<g.length;++B){var H=g.charCodeAt(B);if(H>=55296&&H<=57343){var W=g.charCodeAt(++B);H=65536+((H&1023)<<10)|W&1023}if(H<=127){if(y>=P)break;w[y++]=H}else if(H<=2047){if(y+1>=P)break;w[y++]=192|H>>6,w[y++]=128|H&63}else if(H<=65535){if(y+2>=P)break;w[y++]=224|H>>12,w[y++]=128|H>>6&63,w[y++]=128|H&63}else{if(y+3>=P)break;w[y++]=240|H>>18,w[y++]=128|H>>12&63,w[y++]=128|H>>6&63,w[y++]=128|H&63}}return w[y]=0,y-I},fO=(g,w,y)=>lO(g,G,w,y),dO=(g)=>{var w=0;for(var y=0;y<g.length;++y){var S=g.charCodeAt(y);if(S<=127)w++;else if(S<=2047)w+=2;else if(S>=55296&&S<=57343)w+=4,++y;else w+=3}return w},wb=(g,w,y)=>{var S=w+y,I="";while(!(w>=S)){var P=g[w++];if(!P)return I;if(!(P&128)){I+=String.fromCharCode(P);continue}var B=g[w++]&63;if((P&224)==192){I+=String.fromCharCode((P&31)<<6|B);continue}var H=g[w++]&63;if((P&240)==224)P=(P&15)<<12|B<<6|H;else P=(P&7)<<18|B<<12|H<<6|g[w++]&63;if(P<65536)I+=String.fromCharCode(P);else{var W=P-65536;I+=String.fromCharCode(55296|W>>10,56320|W&1023)}}return I},hO=(g,w)=>g?wb(G,g,w):"",mO=(g,w)=>{w=tn(w);var y=w==="std::string";Gn(g,{name:w,fromWireType(S){var I=tt[S>>2],P=S+4,B;if(y){var H=P;for(var W=0;W<=I;++W){var Q=P+W;if(W==I||G[Q]==0){var pt=Q-H,Lt=hO(H,pt);if(B===void 0)B=Lt;else B+=String.fromCharCode(0),B+=Lt;H=Q+1}}}else{var oe=Array(I);for(var W=0;W<I;++W)oe[W]=String.fromCharCode(G[P+W]);B=oe.join("")}return Un(S),B},toWireType(S,I){if(I instanceof ArrayBuffer)I=new Uint8Array(I);var P,B=typeof I=="string";if(!(B||I instanceof Uint8Array||I instanceof Uint8ClampedArray||I instanceof Int8Array))Ee("Cannot pass non-string to std::string");if(y&&B)P=dO(I);else P=I.length;var H=Kf(4+P+1),W=H+4;if(tt[H>>2]=P,y&&B)fO(I,W,P+1);else if(B)for(var Q=0;Q<P;++Q){var pt=I.charCodeAt(Q);if(pt>255)Un(W),Ee("String has UTF-16 code units that do not fit in 8 bits");G[W+Q]=pt}else for(var Q=0;Q<P;++Q)G[W+Q]=I[Q];if(S!==null)S.push(Un,H);return H},argPackAdvance:ki,readValueFromPointer:Gf,destructorFunction(S){Un(S)}})},pO=(g,w)=>{var y="";for(var S=0;!(S>=w/2);++S){var I=et[g+S*2>>1];if(I==0)break;y+=String.fromCharCode(I)}return y},gO=(g,w,y)=>{if(y??=2147483647,y<2)return 0;y-=2;var S=w,I=y<g.length*2?y/2:g.length;for(var P=0;P<I;++P){var B=g.charCodeAt(P);et[w>>1]=B,w+=2}return et[w>>1]=0,w-S},bO=(g)=>g.length*2,wO=(g,w)=>{var y=0,S="";while(!(y>=w/4)){var I=Ot[g+y*4>>2];if(I==0)break;if(++y,I>=65536){var P=I-65536;S+=String.fromCharCode(55296|P>>10,56320|P&1023)}else S+=String.fromCharCode(I)}return S},$O=(g,w,y)=>{if(y??=2147483647,y<4)return 0;var S=w,I=S+y-4;for(var P=0;P<g.length;++P){var B=g.charCodeAt(P);if(B>=55296&&B<=57343){var H=g.charCodeAt(++P);B=65536+((B&1023)<<10)|H&1023}if(Ot[w>>2]=B,w+=4,w+4>I)break}return Ot[w>>2]=0,w-S},kO=(g)=>{var w=0;for(var y=0;y<g.length;++y){var S=g.charCodeAt(y);if(S>=55296&&S<=57343)++y;w+=4}return w},yO=(g,w,y)=>{y=tn(y);var S,I,P,B;if(w===2)S=pO,I=gO,B=bO,P=(H)=>q[H>>1];else if(w===4)S=wO,I=$O,B=kO,P=(H)=>tt[H>>2];Gn(g,{name:y,fromWireType:(H)=>{var W=tt[H>>2],Q,pt=H+4;for(var Lt=0;Lt<=W;++Lt){var oe=H+4+Lt*w;if(Lt==W||P(oe)==0){var Be=oe-pt,Mo=S(pt,Be);if(Q===void 0)Q=Mo;else Q+=String.fromCharCode(0),Q+=Mo;pt=oe+w}}return Un(H),Q},toWireType:(H,W)=>{if(typeof W!="string")Ee(`Cannot pass non-string to C++ string type ${y}`);var Q=B(W),pt=Kf(4+Q+w);if(tt[pt>>2]=Q/w,I(W,pt+4,Q+w),H!==null)H.push(Un,pt);return pt},argPackAdvance:ki,readValueFromPointer:Gf,destructorFunction(H){Un(H)}})},vO=(g,w)=>{w=tn(w),Gn(g,{isVoid:!0,name:w,argPackAdvance:0,fromWireType:()=>{return},toWireType:(y,S)=>{return}})},EO=(g,w,y)=>G.copyWithin(g,w,w+y),Uf=[],SO=(g,w,y,S)=>{return g=Uf[g],w=yi.toValue(w),g(null,w,y,S)},MO={},xO=(g)=>{var w=MO[g];if(w===void 0)return tn(g);return w},$b=()=>{if(typeof globalThis=="object")return globalThis;function g(w){w.$$$embind_global$$$=w;var y=typeof $$$embind_global$$$=="object"&&w.$$$embind_global$$$==w;if(!y)delete w.$$$embind_global$$$;return y}if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;if(typeof global=="object"&&g(global))$$$embind_global$$$=global;else if(typeof self=="object"&&g(self))$$$embind_global$$$=self;if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;throw Error("unable to get global object.")},OO=(g)=>{if(g===0)return yi.toHandle($b());else return g=xO(g),yi.toHandle($b()[g])},IO=(g)=>{var w=Uf.length;return Uf.push(g),w},RO=(g,w)=>{var y=$i[g];if(y===void 0)Ee(`${w} has unknown type ${bb(g)}`);return y},PO=(g,w)=>{var y=Array(g);for(var S=0;S<g;++S)y[S]=RO(tt[w+S*4>>2],"parameter "+S);return y},AO=Reflect.construct,NO=(g,w,y)=>{var S=[],I=g.toWireType(S,y);if(S.length)tt[w>>2]=yi.toHandle(S);return I},TO=(g,w,y)=>{var S=PO(g,w),I=S.shift();g--;var P=Array(g),B=(W,Q,pt,Lt)=>{var oe=0;for(var Be=0;Be<g;++Be)P[Be]=S[Be].readValueFromPointer(Lt+oe),oe+=S[Be].argPackAdvance;var Mo=y===1?AO(Q,P):Q.apply(W,P);return NO(I,pt,Mo)},H=`methodCaller<(${S.map((W)=>W.name).join(", ")}) => ${I.name}>`;return IO(Bf(H,B))},HO=(g)=>{if(g>9)Bn[g+1]+=1},FO=(g)=>{var w=yi.toValue(g);hb(w),_f(g)},LO=()=>{rb("")},CO=()=>2147483648,jO=(g)=>{var w=F.buffer,y=(g-w.byteLength+65535)/65536;try{return F.grow(y),gn(),1}catch(S){}},_O=(g)=>{var w=G.length;g>>>=0;var y=CO();if(g>y)return!1;var S=(W,Q)=>W+(Q-W%Q)%Q;for(var I=1;I<=4;I*=2){var P=w*(1+0.2/I);P=Math.min(P,g+100663296);var B=Math.min(y,S(Math.max(g,P),65536)),H=jO(B);if(H)return!0}return!1},Wf={},GO=()=>l||"./this.program",Js=()=>{if(!Js.strings){var g=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",w={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:g,_:GO()};for(var y in Wf)if(Wf[y]===void 0)delete w[y];else w[y]=Wf[y];var S=[];for(var y in w)S.push(`${y}=${w[y]}`);Js.strings=S}return Js.strings},BO=(g,w)=>{for(var y=0;y<g.length;++y)z[w++]=g.charCodeAt(y);z[w]=0},UO=(g,w)=>{var y=0;return Js().forEach((S,I)=>{var P=w+y;tt[g+I*4>>2]=P,BO(S,P),y+=S.length+1}),0},WO=(g,w)=>{var y=Js();tt[g>>2]=y.length;var S=0;return y.forEach((I)=>S+=I.length+1),tt[w>>2]=S,0},KO=0,zO=()=>T2||KO>0,qO=(g)=>{if(j=g,!zO())n.onExit?.(g),N=!0;d(g,new N2(g))},DO=(g,w)=>{j=g,qO(g)},JO=DO,YO=(g)=>52,ZO=(g,w)=>w+2097152>>>0<4194305-!!g?(g>>>0)+w*4294967296:NaN;function VO(g,w,y,S,I){var P=ZO(w,y);return 70}var XO=[null,[],[]],QO=(g,w)=>{var y=XO[g];if(w===0||w===10)(g===1?x:M)(wb(y,0)),y.length=0;else y.push(w)},tI=(g,w,y,S)=>{var I=0;for(var P=0;P<y;P++){var B=tt[w>>2],H=tt[w+4>>2];w+=8;for(var W=0;W<H;W++)QO(g,G[B+W]);I+=H}return tt[S>>2]=I,0};C2(),lb=n.BindingError=class extends Error{constructor(w){super(w);this.name="BindingError"}},fb=n.InternalError=class extends Error{constructor(w){super(w);this.name="InternalError"}},U2(),gb=n.UnboundTypeError=rO(Error,"UnboundTypeError");var eI={o:F2,q:L2,m:G2,l:K2,j:q2,f:sO,b:cO,a:uO,e:mO,c:yO,n:vO,v:EO,i:SO,d:_f,k:OO,h:TO,y:HO,g:FO,r:LO,s:_O,t:UO,u:WO,z:JO,w:YO,p:VO,x:tI},ie=A2(),nI=()=>(nI=ie.B)(),kb=(g)=>(kb=ie.C)(g),Kf=(g)=>(Kf=ie.D)(g),Un=(g)=>(Un=ie.E)(g),rI=(g)=>(rI=ie._emscripten_stack_restore)(g),iI=(g)=>(iI=ie._emscripten_stack_alloc)(g),oI=()=>(oI=ie.emscripten_stack_get_current)(),sI=(g)=>(sI=ie.__cxa_increment_exception_refcount)(g),yb=(g)=>(yb=ie.G)(g),aI=n.dynCall_jiji=(g,w,y,S,I)=>(aI=n.dynCall_jiji=ie.H)(g,w,y,S,I),jc;Ds=function g(){if(!jc)vb();if(!jc)Ds=g};function vb(){if(bi>0)return;if(Hf(),bi>0)return;function g(){if(jc)return;if(jc=!0,n.calledRun=!0,N)return;if(Ff(),r(n),n.onRuntimeInitialized)n.onRuntimeInitialized();v2()}if(n.setStatus)n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),g()},1);else g()}if(n.preInit){if(typeof n.preInit=="function")n.preInit=[n.preInit];while(n.preInit.length>0)n.preInit.pop()()}return vb(),o}})(),Ww=eP;function kd(t){if(t[0]!==255||t[1]!==216)return null;let e=2;while(e+9<t.length){if(t[e]!==255){e++;continue}let n=t[e+1];if(n===255){e++;continue}let r=t[e+2]<<8|t[e+3];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204)return{height:t[e+5]<<8|t[e+6],width:t[e+7]<<8|t[e+8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Ip/5sYfQHnoG3lf9Bw==","base64"))),e={noInitialRun:!0,print:()=>{return},printErr:()=>{return},instantiateWasm:(n,r)=>{let i=new WebAssembly.Instance(t,n);return r(i),i.exports}};if(Ww(e),typeof e.decode!=="function")throw Error("the JPEG decoder did not start");return $d=e,e}function Kw(t,e){let n=kd(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);let r=null;try{r=rP().decode(t,!0)}catch{r=null}if(!r)throw Error("not a JPEG image this decoder can read");return{width:r.width,height:r.height,data:new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.length)}}var Fo=[137,80,78,71,13,10,26,10],Dw=13,Jw=3;function Oi(t){return t.length>=Fo.length&&Fo.every((e,n)=>t[n]===e)}var Yw={0:1,2:3,4:2,6:4};function aP(t){if(t.length<33||!Oi(t))return;let e=Buffer.from(t.buffer,t.byteOffset,t.byteLength),n=e.readUInt32BE(16),r=e.readUInt32BE(20),i=e[25];if(e[24]!==8||e[28]!==0||Yw[i]===void 0)return;let o=[];for(let s=8;s+12<=e.length;){let a=e.readUInt32BE(s),c=e.toString("latin1",s+4,s+8);if(c==="IDAT")o.push(e.subarray(s+8,s+8+a));else if(c==="tRNS"||c==="IEND"){if(c==="tRNS"&&i!==4&&i!==6)return;break}s+=12+a}return o.length>0?{width:n,height:r,type:i,idat:o}:void 0}function cP(t,e,n,r){let i=new Uint8Array(e);for(let o=0;o<n;o++){let s=o*(e+1),a=t[s],c=s+1,u=o>0?t:i,f=o>0?c-e-1:0;if(a===1)for(let l=r;l<e;l++)t[c+l]=t[c+l]+t[c+l-r];else if(a===2)for(let l=0;l<e;l++)t[c+l]=t[c+l]+u[f+l];else if(a===3){for(let l=0;l<r;l++)t[c+l]=t[c+l]+(u[f+l]>>1);for(let l=r;l<e;l++)t[c+l]=t[c+l]+(t[c+l-r]+u[f+l]>>1)}else if(a===4){for(let l=0;l<r;l++)t[c+l]=t[c+l]+u[f+l];for(let l=r;l<e;l++){let d=t[c+l-r],h=u[f+l],m=u[f+l-r],p=Math.abs(h-m),b=Math.abs(d-m),$=Math.abs(d+h-2*m);t[c+l]=t[c+l]+(p<=b&&p<=$?d:b<=$?h:m)}}else if(a!==0)throw Error(`bad PNG filter ${a}`)}}function uP(t){let{width:e,height:n,type:r}=t,i=Yw[r],o=e*i,s=sP(Buffer.concat(t.idat),{chunkSize:Math.min(268435456,Math.max(65536,n*(o+1)))});if(s.length<n*(o+1))throw Error("truncated PNG");cP(s,o,n,i);let a=new Uint8Array(e*n*4);for(let c=0;c<n;c++){let u=c*(o+1)+1,f=c*e*4;if(r===6)a.set(s.subarray(u,u+o),f);else if(r===2)for(let l=0,d=u,h=f;l<e;l++,d+=3,h+=4)a[h]=s[d],a[h+1]=s[d+1],a[h+2]=s[d+2],a[h+3]=255;else if(r===0)for(let l=0,d=f;l<e;l++,d+=4){let h=s[u+l];a[d]=h,a[d+1]=h,a[d+2]=h,a[d+3]=255}else for(let l=0,d=u,h=f;l<e;l++,d+=2,h+=4){let m=s[d];a[h]=m,a[h+1]=m,a[h+2]=m,a[h+3]=s[d+1]}}return{width:e,height:n,data:a}}function Gt(t){let e=aP(t);if(e)return uP(e);let n=qw.PNG.sync.read(Buffer.from(t));return{width:n.width,height:n.height,data:new Uint8Array(n.data)}}function Ar(t,e){if(Oi(t)){let n=vn(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);return Gt(t)}if(t[0]===255&&t[1]===216)return Kw(t,e);throw Error("not a PNG or JPEG image")}function Zw(t,e){let{width:n,height:r,at:i}=e,o=Math.max(0,i.x),s=Math.max(0,i.y),a=Math.min(n,i.x+i.w),c=Math.min(r,i.y+i.h);if(a<=o||c<=s)return;let u={x:o,y:s,w:a-o,h:c-s};if(i.w===t.width&&i.h===t.height)return{part:t,box:u,dx:o-i.x,dy:s-i.y};let f={x:(o-i.x)*t.width/i.w,y:(s-i.y)*t.height/i.h,w:u.w*t.width/i.w,h:u.h*t.height/i.h};return{part:Vs(t,f,u.w,u.h),box:u,dx:0,dy:0}}function Vw(t,e){let n=new Uint8Array(e.width*e.height*4),r=Zw(t,e);if(r){let{part:i,box:o,dx:s,dy:a}=r;for(let c=0;c<o.h;c++){let u=((c+a)*i.width+s)*4;n.set(i.data.subarray(u,u+o.w*4),((o.y+c)*e.width+o.x)*4)}}return{width:e.width,height:e.height,data:n}}function Nr(t,e,n,r={width:t.width,height:t.height,at:{x:0,y:0,w:t.width,h:t.height}}){let i=st(e),{width:o,height:s}=r,a=new Uint8Array(o*s*3);for(let h=0;h<o*3;h+=3)a.set(i,h);for(let h=1;h<s;h++)a.copyWithin(h*o*3,0,o*3);let c=Zw(t,r);if(!c)return{width:o,height:s,data:a};let{part:u,box:f,dx:l,dy:d}=c;for(let h=0;h<f.h;h++)for(let m=0;m<f.w;m++){let p=((h+d)*u.width+m+l)*4,b=((f.y+h)*o+f.x+m)*3,$=u.data[p+3]/255*n;for(let k=0;k<3;k++)a[b+k]=Math.round(i[k]*(1-$)+u.data[p+k]*$)}return{width:o,height:s,data:a}}function zw(t,e){for(let n=0;n+e.length<=t.length;n++){let r=!0;for(let i=0;i<e.length&&r;i++)r=t[n+i]===e.charCodeAt(i);if(r)return n}return-1}function vn(t){if(t.length<33||!Oi(t))return null;let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(16),r=e.getUint32(20);if(t[25]===4||t[25]===6)return{width:n,height:r,alpha:!0};let i=zw(t,"IDAT");return{width:n,height:r,alpha:zw(i===-1?t:t.subarray(0,i),"tRNS")!==-1}}function Xw(t,e=Dw){let{width:n,height:r,data:i}=t,o=(f)=>{for(let l=f*n*4+3,d=l+n*4;l<d;l+=4)if(i[l]>=e)return!0;return!1},s=0;while(s<r&&!o(s))s++;if(s===r)return null;let a=r-1;while(!o(a))a--;let c=n,u=-1;for(let f=s;f<=a;f++){let l=f*n*4+3;for(let d=0;d<c;d++)if(i[l+d*4]>=e){c=d;break}for(let d=n-1;d>u;d--)if(i[l+d*4]>=e){u=d;break}}return{x:c,y:s,w:u-c+1,h:a-s+1}}function Yn(t,e={x:0,y:0,w:t.width,h:t.height}){let n=0;for(let r=e.y;r<e.y+e.h;r++)for(let i=e.x;i<e.x+e.w;i++)if((t.data[(r*t.width+i)*4+3]??0)<Dw)n++;return Math.round(n*100/(e.w*e.h))}function Qw(t,e,n){let r=Math.min(e/t.width,n/t.height),i=Math.max(1,Math.round(t.width*r)),o=Math.max(1,Math.round(t.height*r)),s=Vs(t,{x:0,y:0,w:t.width,h:t.height},i,o),a=new Uint8Array(e*n*4),c=Math.floor((e-i)/2),u=Math.floor((n-o)/2);for(let f=0;f<o;f++)a.set(s.data.subarray(f*i*4,(f+1)*i*4),((u+f)*e+c)*4);return{width:e,height:n,data:a}}function lP(t){let e=Math.abs(t);if(e<1)return(7*e*e*e-12*e*e+5.333333333333333)/6;if(e<2)return(-2.3333333333333335*e*e*e+12*e*e-20*e+10.666666666666666)/6;return 0}function yd(t,e,n,r){if(n===r&&Number.isInteger(e)&&e>=0&&e+r<=t)return{first:Int32Array.from({length:r},(f,l)=>e+l),size:1,weights:new Float32Array(r).fill(1)};let i=n/r,o=Math.max(1,i),s=2*o,a=Math.min(t,Math.ceil(2*s)+2),c=new Int32Array(r),u=new Float32Array(r*a);for(let f=0;f<r;f++){let l=e+(f+0.5)*i,d=Math.floor(l-s-0.5),h=Math.max(0,Math.min(t-a,d));c[f]=h;let m=0;for(let p=d;p<=Math.ceil(l+s-0.5);p++){let b=lP((p+0.5-l)/o),$=f*a+Math.min(t-1,Math.max(0,p))-h;u[$]=(u[$]??0)+b,m+=b}for(let p=f*a;p<(f+1)*a;p++)u[p]=(u[p]??0)/m}return{first:c,size:a,weights:u}}function t0(t,e,n,r,i,o,s){let a=yd(t,e.y,e.h,r),c=n*i,u=a.size+1,f=Array.from({length:u},()=>new Float32Array(c)),l=new Int32Array(u).fill(-1),d=new Float32Array(c),h=[],m=[];for(let p=0;p<r;p++){h.length=0,m.length=0;let b=a.first[p];for(let k=0;k<a.size;k++){let v=a.weights[p*a.size+k];if(v===0)continue;let E=b+k,x=E%u,M=f[x];if(l[x]!==E)o(E,M),l[x]=E;h.push(M),m.push(v)}let $=0;while($<h.length){let k=h[$],v=m[$];if(h.length-$>=4){let E=h[$+1],x=h[$+2],M=h[$+3],R=m[$+1],F=m[$+2],N=m[$+3];if($===0)for(let j=0;j<c;j++)d[j]=k[j]*v+E[j]*R+x[j]*F+M[j]*N;else for(let j=0;j<c;j++)d[j]=d[j]+(k[j]*v+E[j]*R+x[j]*F+M[j]*N);$+=4}else{if($===0)for(let E=0;E<c;E++)d[E]=k[E]*v;else for(let E=0;E<c;E++)d[E]=d[E]+k[E]*v;$+=1}}if(h.length===0)d.fill(0);s(p,d)}}function e0(t,e,n,r,i){let o=0,s=n;while(o<s){let c=o+s>>1;if(t[c]+e-1<r)o=c+1;else s=c}let a=o;s=n;while(o<s){let c=o+s>>1;if(t[c]<=i)o=c+1;else s=c}return[a,o]}function Vs(t,e,n,r){let i=yd(t.width,e.x,e.w,n),o=t.data,s=t.width,a=new Float32Array(s*4),c=new Uint8Array(n*r*4);return t0(t.height,e,n,r,4,(u,f)=>{let l=u*s*4,d=s,h=-1;for(let b=0,$=0;b<s*4;b+=4,$++){let k=o[l+b+3];if(k===0){a[b]=0,a[b+1]=0,a[b+2]=0,a[b+3]=0;continue}if($<d)d=$;h=$,a[b]=o[l+b]*k,a[b+1]=o[l+b+1]*k,a[b+2]=o[l+b+2]*k,a[b+3]=k}if(f.fill(0),h<0)return;let[m,p]=e0(i.first,i.size,n,d,h);for(let b=m;b<p;b++){let $=i.first[b]*4,k=b*i.size,v=0,E=0,x=0,M=0;for(let R=0;R<i.size;R++){let F=i.weights[k+R],N=$+R*4;v+=a[N]*F,E+=a[N+1]*F,x+=a[N+2]*F,M+=a[N+3]*F}f[b*4]=v,f[b*4+1]=E,f[b*4+2]=x,f[b*4+3]=M}},(u,f)=>{let l=u*n*4;for(let d=0;d<n;d++){let h=d*4,m=f[h+3];if(m<=0)continue;let p=f[h]/m;c[l+h]=(p<0?0:p>255?255:p)+0.5,p=f[h+1]/m,c[l+h+1]=(p<0?0:p>255?255:p)+0.5,p=f[h+2]/m,c[l+h+2]=(p<0?0:p>255?255:p)+0.5,c[l+h+3]=(m>255?255:m)+0.5}}),{width:n,height:r,data:c}}function n0(t,e,n,r){let i=yd(t.width,e.x,e.w,n),o=t.data,s=t.width,a=new Float32Array(n*r);return t0(t.height,e,n,r,1,(c,u)=>{let f=c*s,l=s,d=-1;for(let p=0;p<s;p++)if(o[f+p]!==0){if(p<l)l=p;d=p}if(u.fill(0),d<0)return;let[h,m]=e0(i.first,i.size,n,l,d);for(let p=h;p<m;p++){let b=f+i.first[p],$=p*i.size,k=0;for(let v=0;v<i.size;v++)k+=o[b+v]*i.weights[$+v];u[p]=k}},(c,u)=>{a.set(u,c*n)}),{width:n,height:r,data:a}}function Xs(t,e){if(e<=0)return t;let n=Math.max(1,Math.ceil(e*3)),r=Array.from({length:2*n+1},(f,l)=>Math.exp(-((l-n)**2)/(2*e*e))),i=r.reduce((f,l)=>f+l,0),{width:o,height:s,data:a}=t,c=new Float32Array(o*s);for(let f=0;f<s;f++){let l=f*o;for(let d=0;d<o;d++){let h=0;for(let m=-n;m<=n;m++)h+=(a[l+Math.min(o-1,Math.max(0,d+m))]??0)*(r[m+n]??0);c[l+d]=h/i}}let u=new Float32Array(o*s);for(let f=0;f<s;f++){let l=f*o;for(let d=-n;d<=n;d++){let h=(r[d+n]??0)/i,m=Math.min(s-1,Math.max(0,f+d))*o;for(let p=0;p<o;p++)u[l+p]=(u[l+p]??0)+(c[m+p]??0)*h}}return{width:o,height:s,data:u}}function Qs(t){let e=new Uint8Array(t.data.length);for(let n=0;n<e.length;n++){let r=t.data[n];e[n]=(r<0?0:r>255?255:r)+0.5}return{width:t.width,height:t.height,data:e}}function Ii(t){let e=new Uint8Array(t.width*t.height);for(let n=0;n<e.length;n++)e[n]=t.data[n*4+3]??0;return{width:t.width,height:t.height,data:e}}var fP=Array.from({length:256},(t,e)=>{let n=e;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function dP(t){let e=4294967295;for(let n of t)e=(fP[(e^n)&255]??0)^e>>>8;return(e^4294967295)>>>0}function Pr(t,e){let n=Buffer.alloc(12+e.length);return n.writeUInt32BE(e.length,0),n.write(t,4,"latin1"),n.set(e,8),n.writeUInt32BE(dP(n.subarray(4,8+e.length)),8+e.length),n}function r0(t,e,n){let r=new Uint8Array(n*(e+1));r.set(t.subarray(0,e),1);for(let i=1;i<n;i++){let o=i*(e+1),s=i*e,a=s-e;r[o]=2;for(let c=0;c<e;c++)r[o+1+c]=t[s+c]-t[a+c]}return r}function i0(t){return oP(t,{level:1,strategy:iP.Z_RLE})}function o0(t,e,n){let r=Buffer.alloc(13);return r.writeUInt32BE(t.width,0),r.writeUInt32BE(t.height,4),r[8]=8,r[9]=e,Buffer.concat([Buffer.from(Fo),Pr("IHDR",r),...n,Pr("IDAT",i0(r0(t.data,t.width,t.height))),Pr("IEND",new Uint8Array)])}function s0(t){let[e,n,r]=st(t),i=new Uint8Array(768);for(let o=0;o<256;o++)i.set([e,n,r],o*3);return Pr("PLTE",i)}function a0(t,e,n,r,i){let o=Buffer.alloc(13);return o.writeUInt32BE(t,0),o.writeUInt32BE(e,4),o[8]=8,o[9]=n,Buffer.concat([Buffer.from(Fo),Pr("IHDR",o),Pr("IDAT",i0(r0(i,t*r,e))),Pr("IEND",new Uint8Array)])}function Tr(t){return a0(t.width,t.height,2,3,t.data)}function We(t){return a0(t.width,t.height,6,4,t.data)}function Ri(t,e){return o0(t,Jw,[s0(e),Pr("tRNS",Uint8Array.from({length:256},(n,r)=>r))])}function vd(t){return o0(t,0,[])}function Kc(t,e){if(!Oi(t)||t[25]!==Jw)return;let n=Buffer.from(t.buffer,t.byteOffset,t.byteLength),r=[Buffer.from(Fo)],i=Fo.length;while(i+8<=n.length){let o=i+12+n.readUInt32BE(i);r.push(n.toString("latin1",i+4,i+8)==="PLTE"?s0(e):n.subarray(i,o)),i=o}return Buffer.concat(r)}var Hr=100,Re=25000000,$P=536870912,Lo=["safe","questionable","explicit"],Pi=["nudity","underwear"],xd=["comic","monochrome","sketch","chibi"],g0=["off","5","10","25","50","100"],b0=["off","720","1080","1440","1800","2560"],w0={nudity:new Set(["nude","naked","topless","bottomless","nipples","naked_towel","undressing"]),underwear:new Set(["underwear","panties","pantsu","bra","lingerie","pantyshot"])},kP={comic:new Set(["comic","4koma"]),monochrome:new Set(["monochrome","greyscale"]),sketch:new Set(["sketch","lineart","line_art"]),chibi:new Set(["chibi"])},yP=/^(?:rating|score|width|height|filetype|dimension):/,ta={safe:"s",questionable:"q",explicit:"e"},$0=8191,vP=20000,EP=5000,c0=3000,u0=8,SP=8,MP=8000,xP=3000,k0=60000,l0=3,OP=3,IP="https://static.zerochan.net",y0="https://s1.zerochan.net",Od=`ttheme/${ft.version} (+${ft.homepage})`,RP=["orig","tile","thumb","cut"],v0=new Map,PP=DP(process.env.TTHEME_FIND_HOSTS),AP=qP(process.env.TTHEME_FIND_CUTOUTS);gP(xP);var NP=["artist","character","copyright"];function f0(t){try{return hP(t)}catch{return[]}}function Co(t){return t.startsWith("//")?`https:${t}`:t}function Lr(t){return(/\.([a-z0-9]+)(?:\?.*)?$/i.exec(t)?.[1]??"").toLowerCase()}function na(t){let e=t.trim();if(!e)return[];let n=JSON.parse(e);if(Array.isArray(n))return n;let r=n.posts;return Array.isArray(r)?r:[]}function TP(t){let e=t.trim(),r=(e?JSON.parse(e):{}).tags??{};return new Map(Object.entries(r).map(([i,o])=>[i,String(o)]))}function Sd(t,e,n){let r=Co(String(t??""));return{file:r,width:Number(e)||0,height:Number(n)||0,ext:Lr(r)}}function Zn(t){return String(t??"").split(/\s+/).filter(Boolean)}function Md(t){let e=typeof t==="number"?new Date(t*1000):typeof t==="string"?new Date(t):void 0;return e&&!Number.isNaN(e.getTime())?e.toISOString().slice(0,10):void 0}function E0(t,e){let n=Co(String(e.preview??""));if(!e.file||!n||!Number(t.id))return[];let r=Number(t.width??t.image_width)||0,i=Number(t.height??t.image_height)||0;return[{id:Number(t.id),width:r,height:i,file:e.file,preview:n,ext:e.ext,owner:String(e.owner??""),score:Number(t.score)||0,rating:String(t.rating??""),md5:String(e.md5??""),source:String(t.source??""),tags:Zn(e.tags),named:e.named,...Md(t.created_at)?{posted:Md(t.created_at)}:{},solo:e.solo,family:Number(t.parent_id)||(t.has_children===!0?Number(t.id):0),smaller:e.versions.filter((o)=>o.file&&o.width>0&&o.height>0&&o.width*o.height<r*i)}]}function HP(t){let e=TP(t);return na(t).flatMap((n)=>{let r=Co(String(n.file_url??"")),i=String(n.tags??""),o=(s)=>Zn(i).filter((a)=>e.get(a)===s);return E0(n,{preview:n.preview_url,file:r,ext:String(n.file_ext||Lr(r)).toLowerCase(),owner:n.author,md5:n.md5,tags:i,named:{artist:o("artist"),character:o("character"),copyright:o("copyright")},solo:void 0,versions:[Sd(n.jpeg_url,n.jpeg_width,n.jpeg_height),Sd(n.sample_url,n.sample_width,n.sample_height)]})})}function FP(t){return na(t).flatMap((e)=>{let n=Co(String(e.file_url??"")),r=String(e.tag_string??""),i=e.media_asset??{};return E0(e,{preview:i.variants?.find((o)=>o.type==="360x360")?.url??e.preview_file_url,file:n,ext:String(e.file_ext||Lr(n)).toLowerCase(),owner:"",md5:e.md5,tags:r,named:{artist:Zn(e.tag_string_artist),character:Zn(e.tag_string_character),copyright:Zn(e.tag_string_copyright)},solo:r.split(/\s+/).includes("solo"),versions:(i.variants??[]).map((o)=>Sd(o.url,o.width,o.height)).filter((o)=>o.ext==="jpg"||o.ext==="png").sort((o,s)=>s.width*s.height-o.width*o.height)})})}function S0(t){return t.toLowerCase().replace(/\s+/g,"_")}function LP(t){return(Array.isArray(t)?t:[]).map((e)=>S0(String(e)))}function CP(t){return String(t??"").replace(/[^0-9a-z]+/gi,".").replace(/^\.+|\.+$/g,"")||"zerochan"}function jP(t){let e=t.trim(),n=e?JSON.parse(e):{};return(Array.isArray(n.items)?n.items:n.id?[n]:[]).flatMap((i)=>{let o=Number(i.id);if(!o)return[];let s=LP(i.tags),a=Co(String(i.full??""));return[{id:o,width:Number(i.width)||0,height:Number(i.height)||0,file:a,ext:Lr(a),preview:`${y0}/${CP(i.tag??i.primary)}.600.${o}.jpg`,owner:"",score:0,rating:s.some((c)=>w0.nudity.has(c))?"q":"g",md5:String(i.md5??i.hash??""),source:String(i.source??""),tags:s,named:{artist:[],character:[],copyright:[]},solo:s.includes("solo"),family:0,smaller:[]}]})}var _P={mangaka:"artist",studio:"artist",character:"character",series:"copyright",game:"copyright"};function d0(t){return t.replace(/&(?:#(\d+)|amp|quot|apos|lt|gt);/g,(e,n)=>n?String.fromCharCode(Number(n)):{"&":"&",""":'"',"'":"'","<":"<",">":">"}[e]??e)}function GP(t){let e={artist:[],character:[],copyright:[]};for(let[,r,i]of t.matchAll(/<li class="([a-z]+)[^"]*"[^>]*\bdata-tag="([^"]*)"/g)){let o=_P[r],s=S0(d0(i));if(o&&!e[o].includes(s))e[o].push(s)}let n=Md(/"datePublished":\s*"([^"]+)"/.exec(t)?.[1]);return{named:e,source:"",owner:d0(/\buploader = \{\s*name: '([^']*)'/.exec(t)?.[1]??""),...n?{posted:n}:{}}}function BP(t){return Number(/Zerochan has ([\d,]+) /.exec(t)?.[1]?.replace(/,/g,"")??0)}function UP(t){return na(t).flatMap((e)=>{let n=String(e.value??"");return n?[{value:n,count:Number(e.post_count)||0}]:[]})}function WP(t){return na(t).flatMap((e)=>{let n=String(e.name??"");return n?[{value:n,count:Number(e.count)||0}]:[]})}function KP(t){return Number(/count="(\d+)"/.exec(t)?.[1]??0)}function zP(t){let n=(t.trim()?JSON.parse(t):{}).counts?.posts;return n===null?Number.NaN:Number(n)||0}function qP(t){let e=new Map;for(let n of(t??"").split(/\s+/).filter(Boolean)){let r=n.indexOf("=");if(r>0)e.set(n.slice(0,r),n.slice(r+1).split(",").filter(Boolean))}return e}function DP(t){let e=new Map;for(let n of(t??"").split(/[\s,]+/).filter(Boolean)){let r=n.indexOf("="),i=n.slice(0,r);try{let o=new URL(n.slice(r+1));if(i&&o.protocol==="https:")e.set(i,o.origin)}catch{}}return e}function zc(t,e,n,r){let i=(t??"").split(/\s+/);if(r!==void 0&&i.includes(r))return[];let o=e.filter((s)=>i.includes(s));return o.length>0?o:[...n]}function Ai(t){return zc(t,Lo,["safe"])}function jo(t){return zc(t,Pi,Pi,"none")}function qc(t){return zc(t,xd,[],"none")}function ra(t){let e=V.map((n)=>n.name);return zc(t,e,e)}function Id(t,e,n){return{score:Number(t)||0,size:Number(e)||0,png:n==="on"}}function ia(t){return[...new Set((t??"").toLowerCase().split(/[\s,]+/).map((e)=>e.replace(/^-+/,"")).filter(Boolean))]}function Rd(t,e,n){return{safe:new Set(t),questionable:new Set(e),explicit:new Set(n)}}function Pd(t){let e=PP.get(t.key),n=AP.get(t.key);return{...t,origin:e??t.origin,moved:e!==void 0&&e!==t.origin,cutouts:n??t.cutouts,vouched:t.vouched&&n===void 0}}function M0(t){return t.length<2?t.join(""):t.map((e)=>`~${e}`).join(" ")}function x0(t){return t>0?[`width:>=${t}`,`height:>=${t}`]:[]}function h0(t){let e=Pd(t),n=(r)=>new URLSearchParams({api_version:"2",include_tags:"1",...r});return{...e,scored:!0,narrow:({score:r,size:i})=>[...r>0?[`score:>=${r}`]:[],...x0(i)],cutouts:M0(e.cutouts),ratings:Rd([ta.safe],[ta.questionable],[ta.explicit]),rate:(r)=>{let[i]=r;if(r.length===1&&i)return`rating:${ta[i]}`;let o=Lo.filter((a)=>!r.includes(a)),[s]=o;return o.length===1&&s?`-rating:${ta[s]}`:""},best:"order:score",tagBudget:Number.POSITIVE_INFINITY,ors:!0,postsUrl:(r,i)=>`${e.origin}/post.json?${n({limit:String(Hr),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/post.xml?${new URLSearchParams({limit:"1",tags:r})}`,postUrl:(r)=>`${e.origin}/post.json?${n({tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/post/show/${r}`,parse:HP,count:KP,uploadedBy:(r)=>`user:${r}`}}function JP(t){let e=Pd(t),n=Rd(["g"],["s","q"],["e"]);return{...e,scored:!0,narrow:({score:r,size:i,png:o})=>[...r>0?[`score:>=${r}`]:[],...x0(i),...o?["filetype:png"]:[]],cutouts:M0(e.cutouts),ratings:n,rate:(r)=>r.length===Lo.length?"":`rating:${r.flatMap((i)=>[...n[i]]).join(",")}`,best:"order:score",tagBudget:2,ors:!0,postsUrl:(r,i)=>`${e.origin}/posts.json?${new URLSearchParams({limit:String(Hr),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/counts/posts.json?${new URLSearchParams({tags:r})}`,postUrl:(r)=>`${e.origin}/posts.json?${new URLSearchParams({limit:"1",tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/posts/${r}`,parse:FP,count:zP,uploadedBy:(r)=>`user:${r}`}}function Ed(t){return t.split(/\s+/).filter((e)=>e&&!/^(?:order|dimension):/.test(e)).map((e)=>e.split("_").map(encodeURIComponent).join("+")).join(",")}function m0(t){let e=t.split(/\s+/),n=e.find((r)=>r.startsWith("dimension:"))?.slice(10);return{s:e.includes("order:fav")?"fav":"id",...n?{d:n}:{}}}function YP(t){let e=Pd(t);return{...e,scored:!1,narrow:({size:n})=>n>=1800?["dimension:huge"]:n>0?["dimension:large"]:[],cutouts:e.cutouts[0]??"",ratings:Rd(["g"],["q"],["e"]),rate:()=>"",best:"order:fav",tagBudget:3,ors:!1,missing:404,postsUrl:(n,r)=>`${e.origin}/${Ed(n)}?${new URLSearchParams({json:"",l:String(Hr),p:String(r+1),...m0(n)})}`,countUrl:(n)=>`${e.origin}/${Ed(n)}?${new URLSearchParams({xml:"",l:"1"})}`,postUrl:(n)=>`${e.origin}/${n}?json=`,pageUrl:(n)=>`${e.origin}/${n}`,parse:jP,count:BP,credits:GP,counts:(n)=>Ed(n).split(",").length===1&&!("d"in m0(n)),guesses:(n)=>(n.tags.includes("transparent_background")?["png","jpg"]:["jpg","png"]).map((r)=>n.preview.replace(y0,IP).replace(/\.600\.(\d+)\.jpg$/,`.full.$1.${r}`))}}function ZP(t){let e=p0(`https://${t}`);return V.find((n)=>p0(n.origin)===e)}function Ad(t){return t.split(/\s+/).filter((e)=>e&&!yP.test(e)).length}function Dc(t,e){let n=t.trim();if(/^\d+$/.test(n))return{site:e,id:Number(n)};let r=/^([\w.]+):(\d+)$/.exec(n);if(r){let a=V.find((c)=>c.key===r[1]||c.name===r[1]);return a&&{site:a,id:Number(r[2])}}let i;try{i=new URL(n)}catch{return}let o=ZP(i.host),s=Number(i.searchParams.get("id")??i.pathname.split("/").filter(Boolean).at(-1));return o&&s>0?{site:o,id:s}:void 0}var V=[JP({key:"danbooru",name:"danbooru",origin:"https://shima.donmai.us",cutouts:["transparent_background"],vouched:!1,ansi:2}),h0({key:"konachan",name:"konachan",origin:"https://konachan.net",cutouts:["transparent","vector"],vouched:!1,ansi:6}),h0({key:"yande",name:"yande.re",origin:"https://yande.re",cutouts:["transparent_png"],vouched:!0,ansi:5}),YP({key:"zerochan",name:"zerochan",origin:"https://www.zerochan.net",cutouts:["transparent_background"],vouched:!1,ansi:3})],ce=V.find((t)=>t.key==="danbooru"),Cr=134217728;function Pe(t,e){let n=V.indexOf(t);return(n===-1?V.length:n)*Cr+e}function p0(t){let e;try{e=new URL(t).hostname}catch{return""}return e.split(".").slice(-2).join(".")}function Ni(t,e,n=e){return e.mirror&&n===e?{site:ce,url:e.mirror.file}:{site:t,url:n.file}}function Jc(t,e){return e.mirror?{site:ce,url:e.mirror.preview}:{site:t,url:e.preview}}function Yc(t,e=Pi){return t.tags.filter((n)=>e.some((r)=>w0[r].has(n)))}function O0(t,e){return t.tags.filter((n)=>e.some((r)=>kP[r].has(n)))}function Zc(t,e,n=["safe"]){return n.some((r)=>t.ratings[r].has(e.rating))}function I0(t,e){return t.rate(["safe"])===""?void 0:Lo.find((n)=>t.ratings[n].has(e.rating))}function En(t){return[t,...t.smaller].find((e)=>e.width*e.height<=Re)}function R0(t){let e=new Map;for(let[n,r]of[...t].sort(([i],[o])=>i<o?-1:1)){if(r==="")continue;e.set(r,[...e.get(r)??[],n])}return e}function jr(){return ea(process.env.XDG_CACHE_HOME??ea(bP(),".cache"),"ttheme")}function rn(t){return ea(jr(),t.key)}function P0(t=$P,e=jr()){let n=[],r=0;for(let i of f0(e))for(let o of RP){let s=ea(e,i,o);for(let a of f0(s)){let c=ea(s,a);try{let{size:u,mtimeMs:f}=pP(c);n.push({path:c,size:u,at:f}),r+=u}catch{}}}n.sort((i,o)=>i.at-o.at);for(let i of n){if(r<=t)return;try{mP(i.path,{force:!0}),r-=i.size}catch{}}}function VP(t,e){if(t!==null&&/^\s*\d+\s*$/.test(t))return Number(t)*1000;let n=t===null?Number.NaN:Date.parse(t);return Number.isNaN(n)?k0:Math.max(0,n-e)}function Vn(t){return v0.get(t.key)??0}function XP(t){for(let e=t;e instanceof Error;e=e.cause)if(e.code==="ECONNRESET")return!0;return!1}function QP(t){return(t.headers.get("server")??"").startsWith("cloudflare")&&t.headers.get("cf-mitigated")==="challenge"}function tA(t,e){let n=new URL(e,t);if(!n.search)n.search=new URL(t).search;return n.href}async function Fr(t,e,n,r={},i=vP){let o=e;for(let s=1,a=0;;s++){let c=Vn(t)-Date.now();if(c>0)await wP(c,void 0,{signal:n});let u;try{u=await fetch(o,{headers:{"User-Agent":Od,Referer:`${t.origin}/`,...r},redirect:"manual",signal:i?AbortSignal.any([n,AbortSignal.timeout(i)]):n})}catch(l){if(s<l0&&!n.aborted&&XP(l))continue;throw l}let f=u.headers.get("location");if(f&&u.status>=300&&u.status<400&&a<OP){await u.body?.cancel(),o=tA(o,f),a++,s--;continue}if(u.status===429&&s<l0){await u.body?.cancel();let l=VP(u.headers.get("retry-after"),Date.now());if(l>k0)throw Error(`${t.name} asks to wait ${Math.ceil(l/1000)}s`);v0.set(t.key,Math.max(Vn(t),Date.now()+l));continue}if(!u.ok)throw await u.body?.cancel(),Object.assign(Error(QP(u)?`${t.name} is behind a Cloudflare challenge`:`${t.name} answered ${u.status}`),{status:u.status});return u}}async function Vc(t,e,n){try{return await(await Fr(t,e,n)).text()}catch(r){if(t.missing!==void 0&&r.status===t.missing)return"";throw r}}async function A0(t,e,n,r){return t.parse(await Vc(t,t.postsUrl(e,n),r))}async function Nd(t,e,n){return t.count(await Vc(t,t.countUrl(e),n))}async function _o(t,e,n){let[r]=t.parse(await Vc(t,t.postUrl(e),n));return r}async function Xc(t,e,n){return t.credits?.(await Vc(t,t.pageUrl(e),n))}var eA=/^https?:\/\/(?:i\.pximg\.net|i\d*\.pixiv\.net|img\d*\.pixiv\.net)\/\S*\/(\d+)(?:_p\d+)?(?:_\w+)?\.\w+(?:[?#]\S*)?$/i,nA=/^https?:\/\/(?:www\.)?pixiv\.net\/member_illust\.php\?\S*\billust_id=(\d+)/i;function oa(t){let e=eA.exec(t)?.[1]??nA.exec(t)?.[1];return e?`https://www.pixiv.net/artworks/${e}`:t}function Qc(t,e){return t.credits!==void 0&&e.named.artist.length===0}function sa(t,e){for(let n of NP){let r=e.named?.[n]??[];if(t.named[n].length===0&&r.length>0)t.named[n]=r}if(t.source||=e.source??"",t.owner||=e.owner??"",!t.posted&&e.posted)t.posted=e.posted}function rA(t){let e=new URLSearchParams({limit:String(2*Hr),only:"md5,tag_string,tag_string_artist,tag_string_character,tag_string_copyright,source,file_url",tags:`md5:${t.join(",")}`});return`${ce.origin}/posts.json?${e}`}function iA(t){return new Map(na(t).flatMap((e)=>{let n=String(e.md5??"");return n?[[n,{tags:Zn(e.tag_string),named:{artist:Zn(e.tag_string_artist),character:Zn(e.tag_string_character),copyright:Zn(e.tag_string_copyright)},source:String(e.source??""),file:Co(String(e.file_url??""))}]]:[]}))}function tu(t,e){for(let n of t){let r=e.get(n.md5);if(!r)continue;if(n.tags=[...new Set([...n.tags,...r.tags])],sa(n,r),n.solo=r.tags.includes("solo"),r.file.includes("/original/")){if(n.mirror={file:r.file,preview:r.file.replace("/original/","/360x360/").replace(/\.[a-z0-9]+$/i,".jpg")},!n.file)n.file=r.file,n.ext=Lr(r.file)}}}async function eu(t,e){let n=new Map;if(Vn(ce)>Date.now())return n;for(let r=0;r<t.length;r+=Hr){let i=await(await Fr(ce,rA(t.slice(r,r+Hr)),e,{},EP)).text();for(let[o,s]of iA(i))n.set(o,s)}return n}async function aa(t,e,n){if(e.file||!t.guesses)return;for(let r of t.guesses(e))try{let i=await Fr(t,r,n,{Range:`bytes=0-${$0}`}),o=vn(new Uint8Array(await i.arrayBuffer()));return e.file=r,e.ext=Lr(r),o}catch(i){if(n.aborted||i.status!==404)throw i}throw Error(`${t.name} keeps no png or jpg of ${e.id}`)}async function N0(t,e){if(Vn(ce)<=Date.now())try{let i=new URLSearchParams({"search[query]":t,"search[type]":"tag_query",limit:String(u0)}),o=`${ce.origin}/autocomplete.json?${i}`;return UP(await(await Fr(ce,o,e,{},c0)).text())}catch(i){if(e.aborted)throw i}let n=V.find((i)=>i.key==="yande"),r=new URLSearchParams({name:t,order:"count",limit:String(u0)});return WP(await(await Fr(n,`${n.origin}/tag.json?${r}`,e,{},c0)).text())}function oA(t){try{return(JSON.parse(t).related_tags??[]).flatMap(({tag:n})=>n?.name?[{value:n.name,count:Number(n.post_count)||0}]:[])}catch{return[]}}async function T0(t,e){if(Vn(ce)>Date.now())return[];let n=new URLSearchParams({"search[query]":t,"search[category]":"character",limit:String(SP)});return oA(await(await Fr(ce,`${ce.origin}/related_tag.json?${n}`,e,{},MP)).text())}function H0(t,e){return e.slice(0,t.ors?t.tagBudget:1)}async function F0(t,e,n){let r=await Fr(t,e,n,{Range:`bytes=0-${$0}`});return vn(new Uint8Array(await r.arrayBuffer()))}async function nu(t,e,n,r){let i=await Fr(t,e,n,{},0),o=Number(i.headers.get("content-length"))||0,s=i.body?.getReader();if(!s)return new Uint8Array(await i.arrayBuffer());let a=[],c=0;for(;;){let{done:l,value:d}=await s.read();if(l)break;a.push(d),c+=d.length,r?.(c,o)}let u=new Uint8Array(c),f=0;for(let l of a)u.set(l,f),f+=l.length;return u}var hA=12,mA=/^[0-9a-f]{40}$/;function Go(){return Bo(jr(),"drawn")}function L0(t){return sA("sha1").update(JSON.stringify(t)).digest("hex")}function C0(t){return aA(Bo(Go(),t))}function j0(t){let e=Bo(Go(),t);try{let n=uA(e),r=n.readUInt32BE(0),i=JSON.parse(n.toString("utf8",4,4+r)),o=n.subarray(4+r,4+r+i.figure),s=n.subarray(4+r+i.figure,4+r+i.figure+i.picture);if(o.length!==i.figure||s.length!==i.picture)return;let a=new Date;return dA(e,a,a),{stem:i.stem,fill:i.fill,...i.peak?{peak:i.peak}:{},figure:o,picture:s}}catch{return}}function Td(t,e){let n=Buffer.from(JSON.stringify({stem:e.stem,fill:e.fill,...e.peak?{peak:e.peak}:{},figure:e.figure.length,picture:e.picture.length})),r=Buffer.alloc(4);r.writeUInt32BE(n.length),L(Bo(Go(),t),Buffer.concat([r,n,e.figure,e.picture])),pA()}function pA(){let t=cA(Go()).filter((e)=>mA.test(e)).flatMap((e)=>{try{return[{name:e,at:fA(Bo(Go(),e)).mtimeMs}]}catch{return[]}}).sort((e,n)=>n.at-e.at);for(let{name:e}of t.slice(hA))lA(Bo(Go(),e),{force:!0})}import{readdirSync as vA,readFileSync as D0}from"node:fs";import{basename as EA,join as J0}from"node:path";/*!
|
|
2
|
+
import{createRequire as xI}from"node:module";var $I=Object.create;var{getPrototypeOf:kI,defineProperty:Ib,getOwnPropertyNames:yI}=Object;var vI=Object.prototype.hasOwnProperty;function SI(t){return this[t]}var EI,MI,td=(t,e,n)=>{var r=t!=null&&typeof t==="object";if(r){var i=e?EI??=new WeakMap:MI??=new WeakMap,o=i.get(t);if(o)return o}n=t!=null?$I(kI(t)):{};let s=e||!t||!t.__esModule?Ib(n,"default",{value:t,enumerable:!0}):n;for(let a of yI(t))if(!vI.call(s,a))Ib(s,a,{get:SI.bind(t,a),enumerable:!0});if(r)i.set(t,s);return s};var Mt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Xt=xI(import.meta.url);var dd=Mt((l_,iw)=>{var JI=Xt("util"),rw=Xt("stream"),rn=iw.exports=function(){rw.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};JI.inherits(rn,rw);rn.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};rn.prototype.write=function(t,e){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let n;if(Buffer.isBuffer(t))n=t;else n=Buffer.from(t,e||this._encoding);if(this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};rn.prototype.end=function(t,e){if(t)this.write(t,e);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};rn.prototype.destroySoon=rn.prototype.end;rn.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};rn.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};rn.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];if(e.length>t.length)this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length));else this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e)};rn.prototype._processRead=function(t){this._reads.shift();let e=0,n=0,r=Buffer.alloc(t.length);while(e<t.length){let i=this._buffers[n++],o=Math.min(i.length,t.length-e);if(i.copy(r,e,0,o),e+=o,o!==i.length)this._buffers[--n]=i.slice(o)}if(n>0)this._buffers.splice(0,n);this._buffered-=t.length,t.func.call(this,r)};rn.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else if(this._buffered>=t.length)this._processRead(t);else break}if(this._buffers&&!this.writable)this._end()}catch(t){this.emit("error",t)}}});var hd=Mt((YI)=>{var Ir=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];YI.getImagePasses=function(t,e){let n=[],r=t%8,i=e%8,o=(t-r)/8,s=(e-i)/8;for(let a=0;a<Ir.length;a++){let c=Ir[a],u=o*c.x.length,f=s*c.y.length;for(let l=0;l<c.x.length;l++)if(c.x[l]<r)u++;else break;for(let l=0;l<c.y.length;l++)if(c.y[l]<i)f++;else break;if(u>0&&f>0)n.push({width:u,height:f,index:a})}return n};YI.getInterlaceIterator=function(t){return function(e,n,r){let i=e%Ir[r].x.length,o=(e-i)/Ir[r].x.length*8+Ir[r].x[i],s=n%Ir[r].y.length,a=(n-s)/Ir[r].y.length*8+Ir[r].y[s];return o*4+a*t*4}}});var md=Mt((d_,ow)=>{ow.exports=function(e,n,r){let i=e+n-r,o=Math.abs(i-e),s=Math.abs(i-n),a=Math.abs(i-r);if(o<=s&&o<=a)return e;if(s<=a)return n;return r}});var pd=Mt((h_,aw)=>{var XI=hd(),QI=md();function sw(t,e,n){let r=t*e;if(n!==8)r=Math.ceil(r/(8/n));return r}var To=aw.exports=function(t,e){let{width:n,height:r,interlace:i,bpp:o,depth:s}=t;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],i){let a=XI.getImagePasses(n,r);for(let c=0;c<a.length;c++)this._images.push({byteWidth:sw(a[c].width,o,s),height:a[c].height,lineIndex:0})}else this._images.push({byteWidth:sw(n,o,s),height:r,lineIndex:0});if(s===8)this._xComparison=o;else if(s===16)this._xComparison=o*2;else this._xComparison=1};To.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};To.prototype._unFilterType1=function(t,e,n){let r=this._xComparison,i=r-1;for(let o=0;o<n;o++){let s=t[1+o],a=o>i?e[o-r]:0;e[o]=s+a}};To.prototype._unFilterType2=function(t,e,n){let r=this._lastLine;for(let i=0;i<n;i++){let o=t[1+i],s=r?r[i]:0;e[i]=o+s}};To.prototype._unFilterType3=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let a=t[1+s],c=o?o[s]:0,u=s>i?e[s-r]:0,f=Math.floor((u+c)/2);e[s]=a+f}};To.prototype._unFilterType4=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let a=t[1+s],c=o?o[s]:0,u=s>i?e[s-r]:0,f=s>i&&o?o[s-r]:0,l=QI(u,c,f);e[s]=a+l}};To.prototype._reverseFilterLine=function(t){let e=t[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(e===0)n=t.slice(1,i+1);else switch(n=Buffer.alloc(i),e){case 1:this._unFilterType1(t,n,i);break;case 2:this._unFilterType2(t,n,i);break;case 3:this._unFilterType3(t,n,i);break;case 4:this._unFilterType4(t,n,i);break;default:throw Error("Unrecognised filter type - "+e)}if(this.write(n),r.lineIndex++,r.lineIndex>=r.height)this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex];else this._lastLine=n;if(r)this.read(r.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var lw=Mt((m_,uw)=>{var tP=Xt("util"),cw=dd(),eP=pd(),nP=uw.exports=function(t){cw.call(this);let e=[],n=this;this._filter=new eP(t,{read:this.read.bind(this),write:function(r){e.push(r)},complete:function(){n.emit("complete",Buffer.concat(e))}}),this._filter.start()};tP.inherits(nP,cw)});var Ho=Mt((p_,fw)=>{fw.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var wd=Mt((g_,dw)=>{var gd=[];(function(){for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)if(e&1)e=3988292384^e>>>1;else e=e>>>1;gd[t]=e}})();var bd=dw.exports=function(){this._crc=-1};bd.prototype.write=function(t){for(let e=0;e<t.length;e++)this._crc=gd[(this._crc^t[e])&255]^this._crc>>>8;return!0};bd.prototype.crc32=function(){return this._crc^-1};bd.crc32=function(t){let e=-1;for(let n=0;n<t.length;n++)e=gd[(e^t[n])&255]^e>>>8;return e^-1}});var $d=Mt((b_,hw)=>{var Lt=Ho(),rP=wd(),_t=hw.exports=function(t,e){this._options=t,t.checkCRC=t.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[Lt.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[Lt.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[Lt.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[Lt.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[Lt.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[Lt.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};_t.prototype.start=function(){this.read(Lt.PNG_SIGNATURE.length,this._parseSignature.bind(this))};_t.prototype._parseSignature=function(t){let e=Lt.PNG_SIGNATURE;for(let n=0;n<e.length;n++)if(t[n]!==e[n]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};_t.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r="";for(let o=4;o<8;o++)r+=String.fromCharCode(t[o]);let i=Boolean(t[4]&32);if(!this._hasIHDR&&n!==Lt.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new rP,this._crc.write(Buffer.from(r)),this._chunks[n])return this._chunks[n](e);if(!i){this.error(Error("Unsupported critical chunk type "+r));return}this.read(e+4,this._skipChunk.bind(this))};_t.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};_t.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};_t.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==e){this.error(Error("Crc error - "+e+" - "+n));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};_t.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))};_t.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r=t[8],i=t[9],o=t[10],s=t[11],a=t[12];if(r!==8&&r!==4&&r!==2&&r!==1&&r!==16){this.error(Error("Unsupported bit depth "+r));return}if(!(i in Lt.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(o!==0){this.error(Error("Unsupported compression method"));return}if(s!==0){this.error(Error("Unsupported filter method"));return}if(a!==0&&a!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=i;let c=Lt.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:n,depth:r,interlace:Boolean(a),palette:Boolean(i&Lt.COLORTYPE_PALETTE),color:Boolean(i&Lt.COLORTYPE_COLOR),alpha:Boolean(i&Lt.COLORTYPE_ALPHA),bpp:c,colorType:i}),this._handleChunkEnd()};_t.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))};_t.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let n=0;n<e;n++)this._palette.push([t[n*3],t[n*3+1],t[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};_t.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))};_t.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===Lt.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(t.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}if(this._colorType===Lt.COLORTYPE_GRAYSCALE)this.transColor([t.readUInt16BE(0)]);if(this._colorType===Lt.COLORTYPE_COLOR)this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]);this._handleChunkEnd()};_t.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))};_t.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/Lt.GAMMA_DIVISION),this._handleChunkEnd()};_t.prototype._handleIDAT=function(t){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-t,this._parseIDAT.bind(this,t))};_t.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===Lt.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(e);let n=t-e.length;if(n>0)this._handleIDAT(n);else this._handleChunkEnd()};_t.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))};_t.prototype._parseIEND=function(t){if(this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var kd=Mt((uP)=>{var mw=hd(),iP=[function(){},function(t,e,n,r){if(r===e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=255},function(t,e,n,r){if(r+1>=e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=e[r+1]},function(t,e,n,r){if(r+2>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=255},function(t,e,n,r){if(r+3>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=e[r+3]}],oP=[function(){},function(t,e,n,r){let i=e[0];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=r},function(t,e,n){let r=e[0];t[n]=r,t[n+1]=r,t[n+2]=r,t[n+3]=e[1]},function(t,e,n,r){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=r},function(t,e,n){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3]}];function sP(t,e){let n=[],r=0;function i(){if(r===t.length)throw Error("Ran out of data");let o=t[r];r++;let s,a,c,u,f,l,d,h;switch(e){default:throw Error("unrecognised depth");case 16:d=t[r],r++,n.push((o<<8)+d);break;case 4:d=o&15,h=o>>4,n.push(h,d);break;case 2:f=o&3,l=o>>2&3,d=o>>4&3,h=o>>6&3,n.push(h,d,l,f);break;case 1:s=o&1,a=o>>1&1,c=o>>2&1,u=o>>3&1,f=o>>4&1,l=o>>5&1,d=o>>6&1,h=o>>7&1,n.push(h,d,l,f,u,c,a,s);break}}return{get:function(o){while(n.length<o)i();let s=n.slice(0,o);return n=n.slice(o),s},resetAfterLine:function(){n.length=0},end:function(){if(r!==t.length)throw Error("extra data found")}}}function aP(t,e,n,r,i,o){let{width:s,height:a,index:c}=t;for(let u=0;u<a;u++)for(let f=0;f<s;f++){let l=n(f,u,c);iP[r](e,i,l,o),o+=r}return o}function cP(t,e,n,r,i,o){let{width:s,height:a,index:c}=t;for(let u=0;u<a;u++){for(let f=0;f<s;f++){let l=i.get(r),d=n(f,u,c);oP[r](e,l,d,o)}i.resetAfterLine()}}uP.dataToBitMap=function(t,e){let{width:n,height:r,depth:i,bpp:o,interlace:s}=e,a;if(i!==8)a=sP(t,i);let c;if(i<=8)c=Buffer.alloc(n*r*4);else c=new Uint16Array(n*r*4);let u=Math.pow(2,i)-1,f=0,l,d;if(s)l=mw.getImagePasses(n,r),d=mw.getInterlaceIterator(n,r);else{let h=0;d=function(){let m=h;return h+=4,m},l=[{width:n,height:r}]}for(let h=0;h<l.length;h++)if(i===8)f=aP(l[h],c,d,o,t,f);else cP(l[h],c,d,o,a,u);if(i===8){if(f!==t.length)throw Error("extra data found")}else a.end();return c}});var yd=Mt(($_,pw)=>{function fP(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let a=0;a<n;a++){let c=i[t[o]];if(!c)throw Error("index "+t[o]+" not in palette");for(let u=0;u<4;u++)e[o+u]=c[u];o+=4}}function dP(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let a=0;a<n;a++){let c=!1;if(i.length===1){if(i[0]===t[o])c=!0}else if(i[0]===t[o]&&i[1]===t[o+1]&&i[2]===t[o+2])c=!0;if(c)for(let u=0;u<4;u++)e[o+u]=0;o+=4}}function hP(t,e,n,r,i){let o=255,s=Math.pow(2,i)-1,a=0;for(let c=0;c<r;c++)for(let u=0;u<n;u++){for(let f=0;f<4;f++)e[a+f]=Math.floor(t[a+f]*o/s+0.5);a+=4}}pw.exports=function(t,e,n=!1){let{depth:r,width:i,height:o,colorType:s,transColor:a,palette:c}=e,u=t;if(s===3)fP(t,u,i,o,c);else{if(a)dP(t,u,i,o,a);if(r!==8&&!n){if(r===16)u=Buffer.alloc(i*o*4);hP(t,u,i,o,r)}}return u}});var ww=Mt((k_,bw)=>{var mP=Xt("util"),vd=Xt("zlib"),gw=dd(),pP=lw(),gP=$d(),bP=kd(),wP=yd(),kn=bw.exports=function(t){gw.call(this),this._parser=new gP(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};mP.inherits(kn,gw);kn.prototype._handleError=function(t){if(this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy)this._inflate.destroy();if(this._filter)this._filter.destroy(),this._filter.on("error",function(){});this.errord=!0};kn.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=vd.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let n=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,r=Math.max(n,vd.Z_MIN_CHUNK);this._inflate=vd.createInflate({chunkSize:r});let i=n,o=this.emit.bind(this,"error");this._inflate.on("error",function(a){if(!i)return;o(a)}),this._filter.on("complete",this._complete.bind(this));let s=this._filter.write.bind(this._filter);this._inflate.on("data",function(a){if(!i)return;if(a.length>i)a=a.slice(0,i);i-=a.length,s(a)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)};kn.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new pP(this._bitmapInfo)};kn.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t};kn.prototype._handlePalette=function(t){this._bitmapInfo.palette=t};kn.prototype._simpleTransparency=function(){this._metaData.alpha=!0};kn.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};kn.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};kn.prototype._complete=function(t){if(this.errord)return;let e;try{let n=bP.dataToBitMap(t,this._bitmapInfo);e=wP(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(n){this._handleError(n);return}this.emit("parsed",e)}});var kw=Mt((y_,$w)=>{var We=Ho();$w.exports=function(t,e,n,r){let i=[We.COLORTYPE_COLOR_ALPHA,We.COLORTYPE_ALPHA].indexOf(r.colorType)!==-1;if(r.colorType===r.inputColorType){let m=function(){let p=new ArrayBuffer(2);return new DataView(p).setInt16(0,256,!0),new Int16Array(p)[0]!==256}();if(r.bitDepth===8||r.bitDepth===16&&m)return t}let o=r.bitDepth!==16?t:new Uint16Array(t.buffer),s=255,a=We.COLORTYPE_TO_BPP_MAP[r.inputColorType];if(a===4&&!r.inputHasAlpha)a=3;let c=We.COLORTYPE_TO_BPP_MAP[r.colorType];if(r.bitDepth===16)s=65535,c*=2;let u=Buffer.alloc(e*n*c),f=0,l=0,d=r.bgColor||{};if(d.red===void 0)d.red=s;if(d.green===void 0)d.green=s;if(d.blue===void 0)d.blue=s;function h(){let m,p,b,$=s;switch(r.inputColorType){case We.COLORTYPE_COLOR_ALPHA:$=o[f+3],m=o[f],p=o[f+1],b=o[f+2];break;case We.COLORTYPE_COLOR:m=o[f],p=o[f+1],b=o[f+2];break;case We.COLORTYPE_ALPHA:$=o[f+1],m=o[f],p=m,b=m;break;case We.COLORTYPE_GRAYSCALE:m=o[f],p=m,b=m;break;default:throw Error("input color type:"+r.inputColorType+" is not supported at present")}if(r.inputHasAlpha){if(!i)$/=s,m=Math.min(Math.max(Math.round((1-$)*d.red+$*m),0),s),p=Math.min(Math.max(Math.round((1-$)*d.green+$*p),0),s),b=Math.min(Math.max(Math.round((1-$)*d.blue+$*b),0),s)}return{red:m,green:p,blue:b,alpha:$}}for(let m=0;m<n;m++)for(let p=0;p<e;p++){let b=h(o,f);switch(r.colorType){case We.COLORTYPE_COLOR_ALPHA:case We.COLORTYPE_COLOR:if(r.bitDepth===8){if(u[l]=b.red,u[l+1]=b.green,u[l+2]=b.blue,i)u[l+3]=b.alpha}else if(u.writeUInt16BE(b.red,l),u.writeUInt16BE(b.green,l+2),u.writeUInt16BE(b.blue,l+4),i)u.writeUInt16BE(b.alpha,l+6);break;case We.COLORTYPE_ALPHA:case We.COLORTYPE_GRAYSCALE:{let $=(b.red+b.green+b.blue)/3;if(r.bitDepth===8){if(u[l]=$,i)u[l+1]=b.alpha}else if(u.writeUInt16BE($,l),i)u.writeUInt16BE(b.alpha,l+2);break}default:throw Error("unrecognised color Type "+r.colorType)}f+=a,l+=c}return u}});var Sw=Mt((v_,vw)=>{var yw=md();function $P(t,e,n,r,i){for(let o=0;o<n;o++)r[i+o]=t[e+o]}function kP(t,e,n){let r=0,i=e+n;for(let o=e;o<i;o++)r+=Math.abs(t[o]);return r}function yP(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=t[e+s]-a;r[i+s]=c}}function vP(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=t[e+o]-s;i+=Math.abs(a)}return i}function SP(t,e,n,r,i){for(let o=0;o<n;o++){let s=e>0?t[e+o-n]:0,a=t[e+o]-s;r[i+o]=a}}function EP(t,e,n){let r=0,i=e+n;for(let o=e;o<i;o++){let s=e>0?t[o-n]:0,a=t[o]-s;r+=Math.abs(a)}return r}function MP(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,u=t[e+s]-(a+c>>1);r[i+s]=u}}function xP(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=t[e+o]-(s+a>>1);i+=Math.abs(c)}return i}function OP(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,u=e>0&&s>=o?t[e+s-(n+o)]:0,f=t[e+s]-yw(a,c,u);r[i+s]=f}}function IP(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=e>0&&o>=r?t[e+o-(n+r)]:0,u=t[e+o]-yw(s,a,c);i+=Math.abs(u)}return i}var PP={0:$P,1:yP,2:SP,3:MP,4:OP},RP={0:kP,1:vP,2:EP,3:xP,4:IP};vw.exports=function(t,e,n,r,i){let o;if(!("filterType"in r)||r.filterType===-1)o=[0,1,2,3,4];else if(typeof r.filterType==="number")o=[r.filterType];else throw Error("unrecognised filter types");if(r.bitDepth===16)i*=2;let s=e*i,a=0,c=0,u=Buffer.alloc((s+1)*n),f=o[0];for(let l=0;l<n;l++){if(o.length>1){let d=1/0;for(let h=0;h<o.length;h++){let m=RP[o[h]](t,c,s,i);if(m<d)f=o[h],d=m}}u[a]=f,a++,PP[f](t,c,s,u,a,i),a+=s,c+=s}return u}});var Sd=Mt((S_,Ew)=>{var Qt=Ho(),NP=wd(),AP=kw(),TP=Sw(),HP=Xt("zlib"),Pr=Ew.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=t.deflateLevel!=null?t.deflateLevel:9,t.deflateStrategy=t.deflateStrategy!=null?t.deflateStrategy:3,t.inputHasAlpha=t.inputHasAlpha!=null?t.inputHasAlpha:!0,t.deflateFactory=t.deflateFactory||HP.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType=typeof t.colorType==="number"?t.colorType:Qt.COLORTYPE_COLOR_ALPHA,t.inputColorType=typeof t.inputColorType==="number"?t.inputColorType:Qt.COLORTYPE_COLOR_ALPHA,[Qt.COLORTYPE_GRAYSCALE,Qt.COLORTYPE_COLOR,Qt.COLORTYPE_COLOR_ALPHA,Qt.COLORTYPE_ALPHA].indexOf(t.colorType)===-1)throw Error("option color type:"+t.colorType+" is not supported at present");if([Qt.COLORTYPE_GRAYSCALE,Qt.COLORTYPE_COLOR,Qt.COLORTYPE_COLOR_ALPHA,Qt.COLORTYPE_ALPHA].indexOf(t.inputColorType)===-1)throw Error("option input color type:"+t.inputColorType+" is not supported at present");if(t.bitDepth!==8&&t.bitDepth!==16)throw Error("option bit depth:"+t.bitDepth+" is not supported at present")};Pr.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Pr.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Pr.prototype.filterData=function(t,e,n){let r=AP(t,e,n,this._options),i=Qt.COLORTYPE_TO_BPP_MAP[this._options.colorType];return TP(r,e,n,this._options,i)};Pr.prototype._packChunk=function(t,e){let n=e?e.length:0,r=Buffer.alloc(n+12);if(r.writeUInt32BE(n,0),r.writeUInt32BE(t,4),e)e.copy(r,8);return r.writeInt32BE(NP.crc32(r.slice(4,r.length-4)),r.length-4),r};Pr.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*Qt.GAMMA_DIVISION),0),this._packChunk(Qt.TYPE_gAMA,e)};Pr.prototype.packIHDR=function(t,e){let n=Buffer.alloc(13);return n.writeUInt32BE(t,0),n.writeUInt32BE(e,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(Qt.TYPE_IHDR,n)};Pr.prototype.packIDAT=function(t){return this._packChunk(Qt.TYPE_IDAT,t)};Pr.prototype.packIEND=function(){return this._packChunk(Qt.TYPE_IEND,null)}});var Iw=Mt((E_,Ow)=>{var FP=Xt("util"),Mw=Xt("stream"),LP=Ho(),CP=Sd(),xw=Ow.exports=function(t){Mw.call(this);let e=t||{};this._packer=new CP(e),this._deflate=this._packer.createDeflate(),this.readable=!0};FP.inherits(xw,Mw);xw.prototype.pack=function(t,e,n,r){if(this.emit("data",Buffer.from(LP.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,n)),r)this.emit("data",this._packer.packGAMA(r));let i=this._packer.filterData(t,e,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(o){this.emit("data",this._packer.packIDAT(o))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(i)}});var Hw=Mt((Qs,Tw)=>{var Pw=Xt("assert").ok,Fo=Xt("zlib"),jP=Xt("util"),Rw=Xt("buffer").kMaxLength;function Oi(t){if(!(this instanceof Oi))return new Oi(t);if(t&&t.chunkSize<Fo.Z_MIN_CHUNK)t.chunkSize=Fo.Z_MIN_CHUNK;if(Fo.Inflate.call(this,t),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&t.maxLength!=null)this._maxLength=t.maxLength}function _P(t){return new Oi(t)}function Nw(t,e){if(e)process.nextTick(e);if(!t._handle)return;t._handle.close(),t._handle=null}Oi.prototype._processChunk=function(t,e,n){if(typeof n==="function")return Fo.Inflate._processChunk.call(this,t,e,n);let r=this,i=t&&t.length,o=this._chunkSize-this._offset,s=this._maxLength,a=0,c=[],u=0,f;this.on("error",function(m){f=m});function l(m,p){if(r._hadError)return;let b=o-p;if(Pw(b>=0,"have should not go down"),b>0){let $=r._buffer.slice(r._offset,r._offset+b);if(r._offset+=b,$.length>s)$=$.slice(0,s);if(c.push($),u+=$.length,s-=$.length,s===0)return!1}if(p===0||r._offset>=r._chunkSize)o=r._chunkSize,r._offset=0,r._buffer=Buffer.allocUnsafe(r._chunkSize);if(p===0)return a+=i-m,i=m,!0;return!1}Pw(this._handle,"zlib binding closed");let d;do d=this._handle.writeSync(e,t,a,i,this._buffer,this._offset,o),d=d||this._writeState;while(!this._hadError&&l(d[0],d[1]));if(this._hadError)throw f;if(u>=Rw)throw Nw(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+Rw.toString(16)+" bytes");let h=Buffer.concat(c,u);return Nw(this),h};jP.inherits(Oi,Fo.Inflate);function GP(t,e){if(typeof e==="string")e=Buffer.from(e);if(!(e instanceof Buffer))throw TypeError("Not a string or buffer");let n=t._finishFlushFlag;if(n==null)n=Fo.Z_FINISH;return t._processChunk(e,n)}function Aw(t,e){return GP(new Oi(e),t)}Tw.exports=Qs=Aw;Qs.Inflate=Oi;Qs.createInflate=_P;Qs.inflateSync=Aw});var Ed=Mt((M_,Lw)=>{var Fw=Lw.exports=function(t){this._buffer=t,this._reads=[]};Fw.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})};Fw.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let t=this._reads[0];if(this._buffer.length&&(this._buffer.length>=t.length||t.allowLess)){this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}else break}if(this._reads.length>0)throw Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw Error("unrecognised content at end of stream")}});var Cw=Mt((WP)=>{var BP=Ed(),UP=pd();WP.process=function(t,e){let n=[],r=new BP(t);return new UP(e,{read:r.read.bind(r),write:function(o){n.push(o)},complete:function(){}}).start(),r.process(),Buffer.concat(n)}});var Bw=Mt((O_,Gw)=>{var jw=!0,_w=Xt("zlib"),zP=Hw();if(!_w.deflateSync)jw=!1;var qP=Ed(),DP=Cw(),JP=$d(),YP=kd(),VP=yd();Gw.exports=function(t,e){if(!jw)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n;function r(S){n=S}let i;function o(S){i=S}function s(S){i.transColor=S}function a(S){i.palette=S}function c(){i.alpha=!0}let u;function f(S){u=S}let l=[];function d(S){l.push(S)}let h=new qP(t);if(new JP(e,{read:h.read.bind(h),error:r,metadata:o,gamma:f,palette:a,transColor:s,inflateData:d,simpleTransparency:c}).start(),h.process(),n)throw n;let p=Buffer.concat(l);l.length=0;let b;if(i.interlace)b=_w.inflateSync(p);else{let x=((i.width*i.bpp*i.depth+7>>3)+1)*i.height;b=zP(p,{chunkSize:x,maxLength:x})}if(p=null,!b||!b.length)throw Error("bad png - invalid inflate data response");let $=DP.process(b,i);p=null;let k=YP.dataToBitMap($,i);$=null;let v=VP(k,i,e.skipRescale);return i.data=v,i.gamma=u||0,i}});var zw=Mt((I_,Kw)=>{var Uw=!0,Ww=Xt("zlib");if(!Ww.deflateSync)Uw=!1;var ZP=Ho(),XP=Sd();Kw.exports=function(t,e){if(!Uw)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r=new XP(e||{}),i=[];if(i.push(Buffer.from(ZP.PNG_SIGNATURE)),i.push(r.packIHDR(t.width,t.height)),t.gamma)i.push(r.packGAMA(t.gamma));let o=r.filterData(t.data,t.width,t.height),s=Ww.deflateSync(o,r.getDeflateOptions());if(o=null,!s||!s.length)throw Error("bad png - invalid compressed data response");return i.push(r.packIDAT(s)),i.push(r.packIEND()),Buffer.concat(i)}});var qw=Mt((eR)=>{var QP=Bw(),tR=zw();eR.read=function(t,e){return QP(t,e||{})};eR.write=function(t,e){return tR(t,e)}});var Jw=Mt((cR)=>{var iR=Xt("util"),Dw=Xt("stream"),oR=ww(),sR=Iw(),aR=qw(),ae=cR.PNG=function(t){if(Dw.call(this),t=t||{},this.width=t.width|0,this.height=t.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new oR(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(e){this.data=e,this.emit("parsed",e)}.bind(this)),this._packer=new sR(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};iR.inherits(ae,Dw);ae.sync=aR;ae.prototype.pack=function(){if(!this.data||!this.data.length)return this.emit("error","No data provided"),this;return process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this};ae.prototype.parse=function(t,e){if(e){let n,r;n=function(i){this.removeListener("error",r),this.data=i,e(null,this)}.bind(this),r=function(i){this.removeListener("parsed",n),e(i,null)}.bind(this),this.once("parsed",n),this.once("error",r)}return this.end(t),this};ae.prototype.write=function(t){return this._parser.write(t),!0};ae.prototype.end=function(t){this._parser.end(t)};ae.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)};ae.prototype._gamma=function(t){this.gamma=t};ae.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};ae.bitblt=function(t,e,n,r,i,o,s,a){if(n|=0,r|=0,i|=0,o|=0,s|=0,a|=0,n>t.width||r>t.height||n+i>t.width||r+o>t.height)throw Error("bitblt reading outside image");if(s>e.width||a>e.height||s+i>e.width||a+o>e.height)throw Error("bitblt writing outside image");for(let c=0;c<o;c++)t.data.copy(e.data,(a+c)*e.width+s<<2,(r+c)*t.width+n<<2,(r+c)*t.width+n+i<<2)};ae.prototype.bitblt=function(t,e,n,r,i,o,s){return ae.bitblt(this,t,e,n,r,i,o,s),this};ae.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let n=0;n<t.width;n++){let r=t.width*e+n<<2;for(let i=0;i<3;i++){let o=t.data[r+i]/255;o=Math.pow(o,0.45454545454545453/t.gamma),t.data[r+i]=Math.round(o*255)}}t.gamma=0}};ae.prototype.adjustGamma=function(){ae.adjustGamma(this)}});var Gh=Mt((YB,qk)=>{var _h={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let n="";if(t<0)n+=`\x1B[${-t}D`;else if(t>0)n+=`\x1B[${t}C`;if(e<0)n+=`\x1B[${-e}A`;else if(e>0)n+=`\x1B[${e}B`;return n},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},sT={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},aT={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let n=0;n<t;n++)e+=this.line+(n<t-1?_h.up():"");if(t)e+=_h.left;return e}};qk.exports={cursor:_h,scroll:sT,erase:aT,beep:"\x07"}});import{spawnSync as Wj}from"node:child_process";import{isMainThread as Kj}from"node:worker_threads";import{parseArgs as Fj}from"node:util";var lt={name:"@kecan0406/ttheme",version:"1.2.19",type:"module",bin:{ttheme:"bin/ttheme.js"},files:["bin","dist/manifest.json","shell","!shell/check.zsh"],description:"Character terminal palettes for Ghostty, iTerm2, kitty, Alacritty, WezTerm, Windows Terminal, Warp, Konsole and Terminal.app",license:"MIT",author:"kecan0406",repository:{type:"git",url:"git+https://github.com/kecan0406/ttheme.git"},homepage:"https://github.com/kecan0406/ttheme#readme",bugs:"https://github.com/kecan0406/ttheme/issues",keywords:["terminal","theme","ghostty","kitty","alacritty","wezterm","iterm2","konsole","warp","windows-terminal"],devDependencies:{"@biomejs/biome":"^2.5.15","@clack/prompts":"^1.8.1","@jsquash/jpeg":"^1.6.0","@material/material-color-utilities":"^0.4.0","@types/bun":"^1.4.2","@types/pngjs":"6.0.5","@xterm/headless":"6.0.0","fast-string-width":"^3.0.2",pngjs:"7.0.0","smol-toml":"^1.9.0",typescript:"^7.0.2",uqr:"^0.1.3"},engines:{bun:">=1.3",node:">=22"}};var Pb=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(e)=>{let n=0;t.lastIndex=0;while(t.test(e))n+=1;return e.length-n}})(),Rb=(t)=>{return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510},Nb=(t)=>{return t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141};var II=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,PI=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ab=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,RI=/\t{1,1000}/y,Tb=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,NI=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,AI=/\p{M}+/gu,TI={limit:1/0,ellipsis:""},Hb=(t,e={},n={})=>{let r=e.limit??1/0,i=e.ellipsis??"",o=e?.ellipsisWidth??(i?Hb(i,TI,n).width:0),s=0,a=n.controlWidth??0,c=n.tabWidth??8,u=n.emojiWidth??2,f=2,l=n.regularWidth??1,d=n.wideWidth??2,h=[[NI,l],[II,0],[PI,a],[RI,c],[Tb,u],[Ab,d]],m=0,p=0,b=t.length,$=0,k=!1,v=b,S=Math.max(0,r-o),x=0,M=0,P=0,L=0;t:while(!0){if(M>x||p>=b&&p>m){let A=t.slice(x,M)||t.slice(m,p);$=0;for(let _ of A.replaceAll(AI,"")){let q=_.codePointAt(0)||0;if(Rb(q))L=2;else if(Nb(q))L=d;else L=l;if(P+L>S)v=Math.min(v,Math.max(x,m)+$);if(P+L>r){k=!0;break t}$+=_.length,P+=L}x=M=0}if(p>=b)break t;for(let A=0,_=h.length;A<_;A++){let[q,B]=h[A];if(q.lastIndex=p,q.test(t)){if($=q===Ab?Pb(t.slice(p,q.lastIndex)):q===Tb?1:q.lastIndex-p,L=$*B,P+L>S)v=Math.min(v,p+Math.floor((S-P)/B));if(P+L>r){k=!0;break t}P+=L,x=m,M=p,p=m=q.lastIndex;continue t}}p+=1}return{width:k?S:P,index:k?v:b,truncated:k,ellipsed:k&&r>=o}},Fb=Hb;var HI={limit:1/0,ellipsis:"",ellipsisWidth:0},FI=(t,e={})=>{return Fb(t,HI,e).width},G=FI;var LI=/^#[0-9a-f]{6}$/;function he(t){return LI.test(t)}function ot(t){let e=Number.parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,e&255]}function Rt(t,e,n){let r=ot(t),i=ot(e);return`#${r.map((o,s)=>Math.round(o+((i[s]??0)-o)*n).toString(16).padStart(2,"0")).join("")}`}function St(t){let[e,n,r]=ot(t).map((i)=>{let o=i/255;return o<=0.03928?o/12.92:((o+0.055)/1.055)**2.4});return 0.2126*e+0.7152*n+0.0722*r}function $t(t,e){let n=St(t),r=St(e);return(Math.max(n,r)+0.05)/(Math.min(n,r)+0.05)}function Wc(t,e){return Math.round($t(t,e)*100)/100}function CI(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function xt(t){let[e,n,r]=ot(t).map(CI),i=Math.cbrt(0.4122214708*e+0.5363325363*n+0.0514459929*r),o=Math.cbrt(0.2119034982*e+0.6806995451*n+0.1073969566*r),s=Math.cbrt(0.0883024619*e+0.2817188376*n+0.6299787005*r),a=1.9779984951*i-2.428592205*o+0.4505937099*s,c=0.0259040371*i+0.7827717662*o-0.808675766*s;return{l:0.2104542553*i+0.793617785*o-0.0040720468*s,c:Math.hypot(a,c),h:(Math.atan2(c,a)*180/Math.PI+360)%360}}var Lb={dim:["2","22"],bold:["1","22"],under:["4","24"],reverse:["7","27"],accent:["36","39"],pill:["7;1;36","22;27;39"],match:["1;4;36","22;24;39"],ok:["32","39"],warn:["33","39"],error:["31","39"]},jI={stage:0.08,bar:0.14,selection:0.2,tab:0.3,line:0.45},N={gutter:"▌",current:"◆",signature:"✦",closed:"▸",opened:"▾",on:"●",off:"○",ok:"✓",miss:"✗",above:"↑",below:"↓",update:"⇡",auto:"↻",star:"★",link:"⧉",search:"⌕",linked:"⇠",contrast:"◐",swatch:"■",pictures:"▣",sep:"·",cut:"…"},Kn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Me(t){return`\x1B[${t}m`}function bt(t){return Me(Lb[t][0])}function ed(t){return Me(Lb[t][1])}var me=Me("0"),wt=Me("39"),Cb=Me("49"),se=Me("39;49");function Si(t){return Me(String(t<8?30+t:82+t))}function jb(t){return Me(String(t<8?40+t:92+t))}function _b(t,e){return Me(`38;5;${t};48;5;${e}`)}function Kc(t){let e=t.replace("#","");return[e.slice(0,2),e.slice(2,4),e.slice(4,6)].map((n)=>Number.parseInt(n,16)).join(";")}function zn(t){return Me(`38;2;${Kc(t)}`)}function nd(t){return Me(`48;2;${Kc(t)}`)}function Gb(t,e){return Me(`48;2;${Kc(t)};38;2;${Kc(e)}`)}function Bb(t,e=wt){return`${t.map((n)=>`${zn(n)}${N.swatch}`).join(" ")}${e}`}function Ei(t,e,n){return Rt(t,e,jI[n])}function rd(t){let e=!1,n=!1,r=!1,i=!1,o=!1,s=!1;for(let c of t.split("\x1B[").slice(1)){let u=/^([0-9;]*)m/.exec(c)?.[1];if(u===void 0)continue;let f=(u||"0").split(";").map(Number);for(let l=0;l<f.length;l++){let d=f[l];if(d===0)e=n=r=i=o=s=!1;else if(d===1||d===2)e=!0;else if(d===22)e=!1;else if(d===3||d===23)n=d===3;else if(d===4||d===24)r=d===4;else if(d===7||d===27)i=d===7;else if(d===38||d===48)o||=d===38,s||=d===48,l+=f[l+1]===5?2:4;else if(d===39)o=!1;else if(d===49)s=!1;else if(d>=30&&d<=37||d>=90&&d<=97)o=!0;else if(d>=40&&d<=47||d>=100&&d<=107)s=!0}}let a=[e&&"22",n&&"23",r&&"24",i&&"27",o&&"39",s&&"49"].filter(Boolean);return a.length>0?Me(a.join(";")):""}function xe(t){let e=(n)=>(r)=>t?`${bt(n)}${r}${ed(n)}`:r;return{color:t,dim:e("dim"),bold:e("bold"),accent:e("accent"),pill:e("pill"),ok:e("ok"),warn:e("warn"),error:e("error"),fg:(n)=>t?zn(n):"",bg:(n)=>t?nd(n):""}}function zc(t,e){return e&&!/\p{Cc}/u.test(e)?`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`:t}function id(t,e){if(t[e]!=="\x1B")return 0;if(t[e+1]==="]"){let r=t.indexOf("\x07",e+2),i=t.indexOf("\x1B\\",e+2),o=r!==-1&&(i===-1||r<i)?r+1:i!==-1?i+2:0;return o?o-e:0}if(t[e+1]!=="[")return 0;let n=e+2;while(n<t.length&&!/[@-~]/.test(t[n]))n++;return n<t.length?n-e+1:0}var Ub;function od(t){return Ub??=new Intl.Segmenter(void 0,{granularity:"grapheme"}),Ub.segment(t)}function qc(t){let e=[],n=0;while(n<t.length){let r=id(t,n);if(r>0){e.push({text:t.slice(n,n+r),start:n,end:n+r,width:0,sequence:!0}),n+=r;continue}let i=t.indexOf("\x1B",n+1),o=i===-1?t.length:i;for(let{segment:s,index:a}of od(t.slice(n,o)))e.push({text:s,start:n+a,end:n+a+s.length,width:G(s),sequence:!1});n=o}return e}function _I(t){let e=t.slice(3,-1);return t.startsWith("\x1B[?")&&t.endsWith("y")&&/^\d{1,4}$/.test(e)?e:void 0}function sd(t,e){let n="",r=0,i=0;for(let o of qc(t)){if(!o.sequence){if(r+o.width>e)break;r+=o.width}else{let s=_I(o.text);if(s!==void 0)i=s==="0"?Math.max(0,i-1):i+1}n+=o.text}return{head:n,used:r,ends:"\x1B[?0y".repeat(i)}}function tt(t,e,n=!0){if(e<=0)return"";let r=G(t);if(r<=e)return n?t+" ".repeat(e-r):t;let{head:i,used:o,ends:s}=sd(t,e-1);return`${i}${rd(i)}…${s}${n?" ".repeat(e-1-o):""}`}function Wb(t,e){let{head:n,used:r,ends:i}=sd(t,e);return`${n}${rd(n)}${i}${" ".repeat(e-r)}`}function Ot(t,e,n){let r=n-G(e)-1;return r<=0?tt(t,n):`${tt(t,r)} ${e}`}function Et(t,e){let n=[],r="";for(let i of t.split(/\s+/).filter(Boolean)){let o=r?`${r} ${i}`:i;if(G(o)<=e){r=o;continue}if(r)n.push(r);while(G(i)>e){let{head:s}=sd(i,e),a=Math.max(s.lastIndexOf("/")+1,s.lastIndexOf("#")),c=a>0?a:s.length||qc(i)[0].end;n.push(i.slice(0,c)),i=i.slice(c)}r=i}if(r)n.push(r);return n}import{existsSync as bk,readFileSync as Rh}from"node:fs";import{join as wk}from"node:path";var Er=7,Kb=3,ad=0.15,zb=1.6,ud=[1,2,3,4,5,6,9,10,11,12,13,14],qb=[7,15],Mr=[1,2,3,4,5,6],Oe={1:{name:"red",center:19,width:25},2:{name:"green",center:132,width:35},3:{name:"yellow",center:88,width:35},4:{name:"blue",center:250,width:60},5:{name:"magenta",center:329,width:40},6:{name:"cyan",center:197,width:60}},Mi=0.03,nn=25,Ro=15,No=0.08;function qn(t,e){let n=t.ansi[e];if(n===void 0)throw Error(`${t.name}: missing ANSI ${e}`);return n}function cd(t,e,n){let r=t.background;return e.flatMap((i)=>{let o=qn(t,i);return $t(o,r)<n?[`ANSI ${i} ${o} on ${r} is ${Wc(o,r)}:1, needs ${n}:1`]:[]})}function Db(t,e){return Math.min(...e.map((n)=>$t(qn(t,n),t.background)))}var Jb=[{rule:"foreground",label:"foreground on background",unit:"ratio",min:Er,measure:({foreground:t,background:e})=>$t(t,e),check:({foreground:t,background:e})=>$t(t,e)<Er?[`foreground ${t} on ${e} is ${Wc(t,e)}:1, needs ${Er}:1`]:[]},{rule:"accents",label:"weakest accent on background",unit:"ratio",min:Kb,measure:(t)=>Db(t,ud),check:(t)=>cd(t,ud,Kb)},{rule:"ansi0-dark",label:"ansi0 luminance",unit:"luminance",max:ad,measure:(t)=>St(qn(t,0)),check:(t)=>{let e=qn(t,0);return St(e)>ad?[`ANSI 0 ${e} has luminance ${St(e).toFixed(3)}, needs <= ${ad}`]:[]}},{rule:"light-ansi",label:"ansi7 and ansi15 on background",unit:"ratio",min:Er,measure:(t)=>Db(t,qb),check:(t)=>cd(t,qb,Er)},{rule:"ansi8-visible",label:"ansi8 on background",unit:"ratio",min:zb,measure:(t)=>$t(qn(t,8),t.background),check:(t)=>cd(t,[8],zb)},{rule:"selection",label:"foreground on selection",unit:"ratio",min:Er,measure:({foreground:t,selectionBackground:e})=>e===void 0?Number.NaN:$t(t,e),check:({foreground:t,selectionBackground:e})=>e!==void 0&&$t(t,e)<Er?[`foreground ${t} on selection ${e} is ${Wc(t,e)}:1, needs ${Er}:1`]:[]}];function Ie(t,e){let n=Math.abs(t-e)%360;return Math.min(n,360-n)}var bn=(t)=>t>8?t-8:t;function Ao(t){let e=t.signatureSlots.filter((n)=>n.startsWith("ansi")).map((n)=>Number(n.slice(4)));return new Set(e.flatMap((n)=>Mr.includes(bn(n))?[n,n>8?n-8:n+8]:[n]))}function Vs(t,e){let n=xt(qn(t,e));return n.c<Mi?void 0:n}function xr(t){let e=Ao(t);return ud.flatMap((n)=>{let r=Vs(t,n),i=Oe[bn(n)];if(r===void 0||i===void 0||e.has(n))return[];let o=Ie(r.h,i.center)-i.width;return o>0?[{slot:n,hue:r.h,over:o}]:[]})}function Dn(t){let e=new Set(t.signatureSlots);return Mr.flatMap((n)=>{let r=Vs(t,n),i=Vs(t,n+8);if(r===void 0||i===void 0||e.has(`ansi${n}`)&&e.has(`ansi${n+8}`))return[];return[{normal:n,gap:Ie(r.h,i.h)}]})}function Jn(t){let e=Ao(t);return[0,8].flatMap((n)=>Mr.flatMap((r)=>Mr.filter((i)=>i>r).flatMap((i)=>{let[o,s]=[n+r,n+i],a=Vs(t,o),c=Vs(t,s);if(a===void 0||c===void 0||e.has(o)&&e.has(s))return[];return Ie(a.h,c.h)<Ro&&Math.abs(a.l-c.l)<No?[[o,s]]:[]})))}var GI=[{rule:"ansi-role",label:"accent hue outside its ANSI role",unit:"degrees",max:0,measure:(t)=>Math.max(0,...xr(t).map((e)=>e.over)),check:(t)=>xr(t).map(({slot:e,hue:n,over:r})=>{let i=Oe[bn(e)];return`ANSI ${e} ${qn(t,e)} has hue ${n.toFixed(0)}°, ${r.toFixed(0)}° outside ${i.name} (${i.center}±${i.width}°)`})},{rule:"bright-follows",label:"widest normal to bright hue gap",unit:"degrees",max:nn,measure:(t)=>Math.max(0,...Dn(t).map((e)=>e.gap)),check:(t)=>Dn(t).filter((e)=>e.gap>nn).map(({normal:e,gap:n})=>`ANSI ${e+8} is ${n.toFixed(0)}° from ANSI ${e}, needs <= ${nn}°`)},{rule:"distinct",label:"accent pairs that read as one color",unit:"pairs",max:0,measure:(t)=>Jn(t).length,check:(t)=>Jn(t).map(([e,n])=>`ANSI ${e} ${qn(t,e)} and ANSI ${n} ${qn(t,n)} are within ${Ro}° hue and ${No} lightness`)}],Dc=[...Jb,...GI],ld=Dc.map((t)=>t.rule),Pe=Dc.map(({rule:t,label:e,unit:n,min:r,max:i})=>({rule:t,label:e,unit:n,...r===void 0?{}:{min:r},...i===void 0?{}:{max:i}}));function wn(t){return Dc.map((e)=>Math.round(e.measure(t)*1000)/1000)}function Yb(t,e){return t.filter((n)=>!e.waive.includes(n.rule)).flatMap((n)=>n.check(e).map((r)=>({theme:e.name,rule:n.rule,detail:r})))}function Yn(t){return Yb(Dc,t)}function Vb(t){return Yb(Jb,t)}function Zb(t){return t.flatMap(Yn)}import{chmodSync as BI,copyFileSync as UI,existsSync as Or,mkdirSync as WI,readFileSync as Zs,realpathSync as KI,renameSync as Qb,rmSync as Xb,statSync as zI,writeFileSync as tw}from"node:fs";import{dirname as qI}from"node:path";function Xs(t){return`${t}.ttheme.bak`}var DI=/^(?:#|--) ttheme begin$|path = "ttheme-|^DefaultProfile=ttheme-/m;function fd(t){let e=Xs(t);if(Or(t)&&!Or(e)&&!DI.test(Zs(t,"utf8")))UI(t,e)}function C(t,e){let n=Or(t)?KI(t):t;WI(qI(n),{recursive:!0});let r=`${n}.ttheme-${process.pid}`;if(tw(r,e),Or(n))BI(r,zI(n).mode&4095);Qb(r,n)}function xi(t,e,n){if(tw(t,n),t!==e)Qb(t,e)}function $n(t,e){if((Or(t)?Zs(t,"utf8"):void 0)===e)return!1;return fd(t),C(t,e),!0}function ew(t,e){return t.replace(/\n*$/,"")===e.replace(/\n*$/,"")}function nw(t,e){let n=Xs(t),r=Or(n)?Zs(n,"utf8"):void 0;if(e===""&&r===void 0)return Xb(t,{force:!0}),"removed";let i=r!==void 0&&ew(r,e);if(C(t,i?r:e),r===void 0||i)return Xb(n,{force:!0}),"restored";return"kept backup"}function Jc(t){let e=Xs(t);return Or(t)&&Or(e)&&ew(Zs(t,"utf8"),Zs(e,"utf8"))?[e]:[]}import{createHash as d$}from"node:crypto";import{copyFileSync as UN,existsSync as Xd,mkdirSync as WN,readdirSync as KN,readFileSync as zo,renameSync as h$,rmSync as Ko,statSync as zN}from"node:fs";import{basename as m$,isAbsolute as qN,join as Y}from"node:path";import{createHash as mN}from"node:crypto";import{existsSync as pN,readdirSync as gN,readFileSync as bN,rmSync as wN,statSync as $N,utimesSync as kN}from"node:fs";import{join as Uo}from"node:path";import{readdirSync as yR,rmSync as vR,statSync as SR}from"node:fs";import{setDefaultAutoSelectFamilyAttemptTimeout as ER}from"node:net";import{homedir as MR}from"node:os";import{join as ia}from"node:path";import{setTimeout as xR}from"node:timers/promises";var Xw=td(Jw(),1);import{constants as dR,deflateSync as hR,inflateSync as mR}from"node:zlib";import{inflateRawSync as lR}from"node:zlib";var uR=(()=>{var t=import.meta.url;return function(e={}){var n=e,r,i,o=new Promise((g,w)=>{r=g,i=w});let a=globalThis.ServiceWorkerGlobalScope!==void 0&&typeof self<"u"&&globalThis.caches&&globalThis.caches.default!==void 0,c=typeof process==="object"&&process.release&&process.release.name==="node";if(a||c){if(!globalThis.ImageData)globalThis.ImageData=class{constructor(w,y,E){this.data=w,this.width=y,this.height=E}};if(import.meta.url===void 0)import.meta.url="https://localhost";if(typeof self<"u"&&self.location===void 0)self.location={href:""}}var u=Object.assign({},n),f=[],l="./this.program",d=(g,w)=>{throw w},h=typeof window=="object",m=typeof importScripts=="function",p=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",b="";function $(g){if(n.locateFile)return n.locateFile(g,b);return b+g}var k,v,S;if(h||m){if(m)b=self.location.href;else if(typeof document<"u"&&document.currentScript)b=document.currentScript.src;if(t)b=t;if(b.startsWith("blob:"))b="";else b=b.substr(0,b.replace(/[?#].*/,"").lastIndexOf("/")+1);{if(k=(g)=>{var w=new XMLHttpRequest;return w.open("GET",g,!1),w.send(null),w.responseText},m)S=(g)=>{var w=new XMLHttpRequest;return w.open("GET",g,!1),w.responseType="arraybuffer",w.send(null),new Uint8Array(w.response)};v=(g,w,y)=>{var E=new XMLHttpRequest;E.open("GET",g,!0),E.responseType="arraybuffer",E.onload=()=>{if(E.status==200||E.status==0&&E.response){w(E.response);return}y()},E.onerror=y,E.send(null)}}}var x=n.print||console.log.bind(console),M=n.printErr||console.error.bind(console);if(Object.assign(n,u),u=null,n.arguments)f=n.arguments;if(n.thisProgram)l=n.thisProgram;if(n.quit)d=n.quit;var P;if(n.wasmBinary)P=n.wasmBinary;var L,A=!1,_,q,B,F,pt,Zt,it,Sr,Be;function gn(){var g=L.buffer;n.HEAP8=q=new Int8Array(g),n.HEAP16=F=new Int16Array(g),n.HEAPU8=B=new Uint8Array(g),n.HEAPU16=pt=new Uint16Array(g),n.HEAP32=Zt=new Int32Array(g),n.HEAPU32=it=new Uint32Array(g),n.HEAPF32=Sr=new Float32Array(g),n.HEAPF64=Be=new Float64Array(g)}var Mo=[],_c=[],bi=[],Gf=!1;function Bf(){if(n.preRun){if(typeof n.preRun=="function")n.preRun=[n.preRun];while(n.preRun.length)R2(n.preRun.shift())}Kf(Mo)}function Uf(){Gf=!0,Kf(_c)}function P2(){if(n.postRun){if(typeof n.postRun=="function")n.postRun=[n.postRun];while(n.postRun.length)A2(n.postRun.shift())}Kf(bi)}function R2(g){Mo.unshift(g)}function N2(g){_c.unshift(g)}function A2(g){bi.unshift(g)}var wi=0,Wf=null,Js=null;function T2(g){wi++,n.monitorRunDependencies?.(wi)}function H2(g){if(wi--,n.monitorRunDependencies?.(wi),wi==0){if(Wf!==null)clearInterval(Wf),Wf=null;if(Js){var w=Js;Js=null,w()}}}function cb(g){n.onAbort?.(g),g="Aborted("+g+")",M(g),A=!0,_=1,g+=". Build with -sASSERTIONS for more info.";var w=new WebAssembly.RuntimeError(g);throw i(w),w}var F2="data:application/octet-stream;base64,",ub=(g)=>g.startsWith(F2),$i;if(n.locateFile){if($i="mozjpeg_dec.wasm",!ub($i))$i=$($i)}else $i=new URL("mozjpeg_dec.wasm",import.meta.url).href;function lb(g){if(g==$i&&P)return new Uint8Array(P);if(S)return S(g);throw"both async and sync fetching of the wasm failed"}function L2(g){if(!P&&(h||m)){if(typeof fetch=="function")return fetch(g,{credentials:"same-origin"}).then((w)=>{if(!w.ok)throw`failed to load wasm binary file at '${g}'`;return w.arrayBuffer()}).catch(()=>lb(g))}return Promise.resolve().then(()=>lb(g))}function fb(g,w,y){return L2(g).then((E)=>WebAssembly.instantiate(E,w)).then(y,(E)=>{M(`failed to asynchronously prepare wasm: ${E}`),cb(E)})}function C2(g,w,y,E){if(!g&&typeof WebAssembly.instantiateStreaming=="function"&&!ub(w)&&typeof fetch=="function")return fetch(w,{credentials:"same-origin"}).then((I)=>{var R=WebAssembly.instantiateStreaming(I,y);return R.then(E,function(U){return M(`wasm streaming compile failed: ${U}`),M("falling back to ArrayBuffer instantiation"),fb(w,y,E)})});return fb(w,y,E)}function j2(){var g={a:cI};function w(E,I){return ie=E.exports,L=ie.A,gn(),$b=ie.F,N2(ie.B),H2("wasm-instantiate"),ie}T2("wasm-instantiate");function y(E){w(E.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(g,w)}catch(E){M(`Module.instantiateWasm callback failed with error: ${E}`),i(E)}return C2(P,$i,g,y).catch(i),{}}function _2(g){this.name="ExitStatus",this.message=`Program terminated with exit(${g})`,this.status=g}var Kf=(g)=>{while(g.length>0)g.shift()(n)},G2=n.noExitRuntime||!0;class db{constructor(g){this.excPtr=g,this.ptr=g-24}set_type(g){it[this.ptr+4>>2]=g}get_type(){return it[this.ptr+4>>2]}set_destructor(g){it[this.ptr+8>>2]=g}get_destructor(){return it[this.ptr+8>>2]}set_caught(g){g=g?1:0,q[this.ptr+12]=g}get_caught(){return q[this.ptr+12]!=0}set_rethrown(g){g=g?1:0,q[this.ptr+13]=g}get_rethrown(){return q[this.ptr+13]!=0}init(g,w){this.set_adjusted_ptr(0),this.set_type(g),this.set_destructor(w)}set_adjusted_ptr(g){it[this.ptr+16>>2]=g}get_adjusted_ptr(){return it[this.ptr+16>>2]}get_exception_ptr(){var g=xb(this.get_type());if(g)return it[this.excPtr>>2];var w=this.get_adjusted_ptr();if(w!==0)return w;return this.excPtr}}var hb=0,B2=0,U2=(g,w,y)=>{var E=new db(g);throw E.init(w,y),hb=g,B2++,hb},W2=(g,w,y,E,I)=>{},K2=()=>{var g=Array(256);for(var w=0;w<256;++w)g[w]=String.fromCharCode(w);mb=g},mb,en=(g)=>{var w="",y=g;while(B[y])w+=mb[B[y++]];return w},xo={},ki={},Gc={},pb,Ee=(g)=>{throw new pb(g)},gb,bb=(g)=>{throw new gb(g)},z2=(g,w,y)=>{g.forEach(function(H){Gc[H]=w});function E(H){var K=y(H);if(K.length!==g.length)bb("Mismatched type converter count");for(var Q=0;Q<g.length;++Q)Bn(g[Q],K[Q])}var I=Array(w.length),R=[],U=0;if(w.forEach((H,K)=>{if(ki.hasOwnProperty(H))I[K]=ki[H];else{if(R.push(H),!xo.hasOwnProperty(H))xo[H]=[];xo[H].push(()=>{if(I[K]=ki[H],++U,U===R.length)E(I)})}}),R.length===0)E(I)};function q2(g,w,y={}){var E=w.name;if(!g)Ee(`type "${E}" must have a positive integer typeid pointer`);if(ki.hasOwnProperty(g))if(y.ignoreDuplicateRegistrations)return;else Ee(`Cannot register type '${E}' twice`);if(ki[g]=w,delete Gc[g],xo.hasOwnProperty(g)){var I=xo[g];delete xo[g],I.forEach((R)=>R())}}function Bn(g,w,y={}){if(!("argPackAdvance"in w))throw TypeError("registerType registeredInstance requires argPackAdvance");return q2(g,w,y)}var yi=8,D2=(g,w,y,E)=>{w=en(w),Bn(g,{name:w,fromWireType:function(I){return!!I},toWireType:function(I,R){return R?y:E},argPackAdvance:yi,readValueFromPointer:function(I){return this.fromWireType(B[I])},destructorFunction:null})},zf=[],Un=[],qf=(g)=>{if(g>9&&--Un[g+1]===0)Un[g]=void 0,zf.push(g)},J2=()=>Un.length/2-5-zf.length,Y2=()=>{Un.push(0,1,void 0,1,null,1,!0,1,!1,1),n.count_emval_handles=J2},vi={toValue:(g)=>{if(!g)Ee("Cannot use deleted val. handle = "+g);return Un[g]},toHandle:(g)=>{switch(g){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let w=zf.pop()||Un.length;return Un[w]=g,Un[w+1]=1,w}}}};function Df(g){return this.fromWireType(it[g>>2])}var V2={name:"emscripten::val",fromWireType:(g)=>{var w=vi.toValue(g);return qf(g),w},toWireType:(g,w)=>vi.toHandle(w),argPackAdvance:yi,readValueFromPointer:Df,destructorFunction:null},Z2=(g)=>Bn(g,V2),X2=(g,w)=>{switch(w){case 4:return function(y){return this.fromWireType(Sr[y>>2])};case 8:return function(y){return this.fromWireType(Be[y>>3])};default:throw TypeError(`invalid float width (${w}): ${g}`)}},Q2=(g,w,y)=>{w=en(w),Bn(g,{name:w,fromWireType:(E)=>E,toWireType:(E,I)=>I,argPackAdvance:yi,readValueFromPointer:X2(w,y),destructorFunction:null})},Jf=(g,w)=>Object.defineProperty(w,"name",{value:g}),wb=(g)=>{while(g.length){var w=g.pop(),y=g.pop();y(w)}};function tO(g){for(var w=1;w<g.length;++w)if(g[w]!==null&&g[w].destructorFunction===void 0)return!0;return!1}function eO(g,w,y,E,I,R){var U=w.length;if(U<2)Ee("argTypes array size mismatch! Must at least get return value and 'this' types!");var H=w[1]!==null&&y!==null,K=tO(w),Q=w[0].name!=="void",gt=U-2,Ft=Array(gt),oe=[],Ue=[],Oo=function(...Xf){if(Xf.length!==gt)Ee(`function ${g} called with ${Xf.length} arguments, expected ${gt}`);Ue.length=0;var Qf;if(oe.length=H?2:1,oe[0]=I,H)Qf=w[1].toWireType(Ue,this),oe[1]=Qf;for(var Io=0;Io<gt;++Io)Ft[Io]=w[Io+2].toWireType(Ue,Xf[Io]),oe.push(Ft[Io]);var pI=E(...oe);function gI(bI){if(K)wb(Ue);else for(var Po=H?1:2;Po<w.length;Po++){var wI=Po===1?Qf:Ft[Po-2];if(w[Po].destructorFunction!==null)w[Po].destructorFunction(wI)}if(Q)return w[0].fromWireType(bI)}return gI(pI)};return Jf(g,Oo)}var nO=(g,w,y)=>{if(g[w].overloadTable===void 0){var E=g[w];g[w]=function(...I){if(!g[w].overloadTable.hasOwnProperty(I.length))Ee(`Function '${y}' called with an invalid number of arguments (${I.length}) - expects one of (${g[w].overloadTable})!`);return g[w].overloadTable[I.length].apply(this,I)},g[w].overloadTable=[],g[w].overloadTable[E.argCount]=E}},rO=(g,w,y)=>{if(n.hasOwnProperty(g)){if(y===void 0||n[g].overloadTable!==void 0&&n[g].overloadTable[y]!==void 0)Ee(`Cannot register public name '${g}' twice`);if(nO(n,g,g),n.hasOwnProperty(y))Ee(`Cannot register multiple overloads of a function with the same number of arguments (${y})!`);n[g].overloadTable[y]=w}else if(n[g]=w,y!==void 0)n[g].numArguments=y},iO=(g,w)=>{var y=[];for(var E=0;E<g;E++)y.push(it[w+E*4>>2]);return y},oO=(g,w,y)=>{if(!n.hasOwnProperty(g))bb("Replacing nonexistent public symbol");if(n[g].overloadTable!==void 0&&y!==void 0)n[g].overloadTable[y]=w;else n[g]=w,n[g].argCount=y},sO=(g,w,y)=>{g=g.replace(/p/g,"i");var E=n["dynCall_"+g];return E(w,...y)},Bc=[],$b,kb=(g)=>{var w=Bc[g];if(!w){if(g>=Bc.length)Bc.length=g+1;Bc[g]=w=$b.get(g)}return w},aO=(g,w,y=[])=>{if(g.includes("j"))return sO(g,w,y);var E=kb(w)(...y);return E},cO=(g,w)=>(...y)=>aO(g,w,y),uO=(g,w)=>{g=en(g);function y(){if(g.includes("j"))return cO(g,w);return kb(w)}var E=y();if(typeof E!="function")Ee(`unknown function pointer with signature ${g}: ${w}`);return E},lO=(g,w)=>{var y=Jf(w,function(E){this.name=w,this.message=E;var I=Error(E).stack;if(I!==void 0)this.stack=this.toString()+`
|
|
3
|
+
`+I.replace(/^Error(:[^\n]*)?\n/,"")});return y.prototype=Object.create(g.prototype),y.prototype.constructor=y,y.prototype.toString=function(){if(this.message===void 0)return this.name;else return`${this.name}: ${this.message}`},y},yb,vb=(g)=>{var w=Mb(g),y=en(w);return Wn(w),y},fO=(g,w)=>{var y=[],E={};function I(R){if(E[R])return;if(ki[R])return;if(Gc[R]){Gc[R].forEach(I);return}y.push(R),E[R]=!0}throw w.forEach(I),new yb(`${g}: `+y.map(vb).join([", "]))},dO=(g)=>{g=g.trim();let w=g.indexOf("(");if(w!==-1)return g.substr(0,w);else return g},hO=(g,w,y,E,I,R,U)=>{var H=iO(w,y);g=en(g),g=dO(g),I=uO(E,I),rO(g,function(){fO(`Cannot call ${g} due to unbound types`,H)},w-1),z2([],H,(K)=>{var Q=[K[0],null].concat(K.slice(1));return oO(g,eO(g,Q,null,I,R,U),w-1),[]})},mO=(g,w,y)=>{switch(w){case 1:return y?(E)=>q[E]:(E)=>B[E];case 2:return y?(E)=>F[E>>1]:(E)=>pt[E>>1];case 4:return y?(E)=>Zt[E>>2]:(E)=>it[E>>2];default:throw TypeError(`invalid integer width (${w}): ${g}`)}},pO=(g,w,y,E,I)=>{if(w=en(w),I===-1)I=4294967295;var R=(gt)=>gt;if(E===0){var U=32-8*y;R=(gt)=>gt<<U>>>U}var H=w.includes("unsigned"),K=(gt,Ft)=>{},Q;if(H)Q=function(gt,Ft){return K(Ft,this.name),Ft>>>0};else Q=function(gt,Ft){return K(Ft,this.name),Ft};Bn(g,{name:w,fromWireType:R,toWireType:Q,argPackAdvance:yi,readValueFromPointer:mO(w,y,E!==0),destructorFunction:null})},gO=(g,w,y)=>{var E=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],I=E[w];function R(U){var H=it[U>>2],K=it[U+4>>2];return new I(q.buffer,K,H)}y=en(y),Bn(g,{name:y,fromWireType:R,argPackAdvance:yi,readValueFromPointer:R},{ignoreDuplicateRegistrations:!0})},bO=(g,w,y,E)=>{if(!(E>0))return 0;var I=y,R=y+E-1;for(var U=0;U<g.length;++U){var H=g.charCodeAt(U);if(H>=55296&&H<=57343){var K=g.charCodeAt(++U);H=65536+((H&1023)<<10)|K&1023}if(H<=127){if(y>=R)break;w[y++]=H}else if(H<=2047){if(y+1>=R)break;w[y++]=192|H>>6,w[y++]=128|H&63}else if(H<=65535){if(y+2>=R)break;w[y++]=224|H>>12,w[y++]=128|H>>6&63,w[y++]=128|H&63}else{if(y+3>=R)break;w[y++]=240|H>>18,w[y++]=128|H>>12&63,w[y++]=128|H>>6&63,w[y++]=128|H&63}}return w[y]=0,y-I},wO=(g,w,y)=>bO(g,B,w,y),$O=(g)=>{var w=0;for(var y=0;y<g.length;++y){var E=g.charCodeAt(y);if(E<=127)w++;else if(E<=2047)w+=2;else if(E>=55296&&E<=57343)w+=4,++y;else w+=3}return w},Sb=(g,w,y)=>{var E=w+y,I="";while(!(w>=E)){var R=g[w++];if(!R)return I;if(!(R&128)){I+=String.fromCharCode(R);continue}var U=g[w++]&63;if((R&224)==192){I+=String.fromCharCode((R&31)<<6|U);continue}var H=g[w++]&63;if((R&240)==224)R=(R&15)<<12|U<<6|H;else R=(R&7)<<18|U<<12|H<<6|g[w++]&63;if(R<65536)I+=String.fromCharCode(R);else{var K=R-65536;I+=String.fromCharCode(55296|K>>10,56320|K&1023)}}return I},kO=(g,w)=>g?Sb(B,g,w):"",yO=(g,w)=>{w=en(w);var y=w==="std::string";Bn(g,{name:w,fromWireType(E){var I=it[E>>2],R=E+4,U;if(y){var H=R;for(var K=0;K<=I;++K){var Q=R+K;if(K==I||B[Q]==0){var gt=Q-H,Ft=kO(H,gt);if(U===void 0)U=Ft;else U+=String.fromCharCode(0),U+=Ft;H=Q+1}}}else{var oe=Array(I);for(var K=0;K<I;++K)oe[K]=String.fromCharCode(B[R+K]);U=oe.join("")}return Wn(E),U},toWireType(E,I){if(I instanceof ArrayBuffer)I=new Uint8Array(I);var R,U=typeof I=="string";if(!(U||I instanceof Uint8Array||I instanceof Uint8ClampedArray||I instanceof Int8Array))Ee("Cannot pass non-string to std::string");if(y&&U)R=$O(I);else R=I.length;var H=Zf(4+R+1),K=H+4;if(it[H>>2]=R,y&&U)wO(I,K,R+1);else if(U)for(var Q=0;Q<R;++Q){var gt=I.charCodeAt(Q);if(gt>255)Wn(K),Ee("String has UTF-16 code units that do not fit in 8 bits");B[K+Q]=gt}else for(var Q=0;Q<R;++Q)B[K+Q]=I[Q];if(E!==null)E.push(Wn,H);return H},argPackAdvance:yi,readValueFromPointer:Df,destructorFunction(E){Wn(E)}})},vO=(g,w)=>{var y="";for(var E=0;!(E>=w/2);++E){var I=F[g+E*2>>1];if(I==0)break;y+=String.fromCharCode(I)}return y},SO=(g,w,y)=>{if(y??=2147483647,y<2)return 0;y-=2;var E=w,I=y<g.length*2?y/2:g.length;for(var R=0;R<I;++R){var U=g.charCodeAt(R);F[w>>1]=U,w+=2}return F[w>>1]=0,w-E},EO=(g)=>g.length*2,MO=(g,w)=>{var y=0,E="";while(!(y>=w/4)){var I=Zt[g+y*4>>2];if(I==0)break;if(++y,I>=65536){var R=I-65536;E+=String.fromCharCode(55296|R>>10,56320|R&1023)}else E+=String.fromCharCode(I)}return E},xO=(g,w,y)=>{if(y??=2147483647,y<4)return 0;var E=w,I=E+y-4;for(var R=0;R<g.length;++R){var U=g.charCodeAt(R);if(U>=55296&&U<=57343){var H=g.charCodeAt(++R);U=65536+((U&1023)<<10)|H&1023}if(Zt[w>>2]=U,w+=4,w+4>I)break}return Zt[w>>2]=0,w-E},OO=(g)=>{var w=0;for(var y=0;y<g.length;++y){var E=g.charCodeAt(y);if(E>=55296&&E<=57343)++y;w+=4}return w},IO=(g,w,y)=>{y=en(y);var E,I,R,U;if(w===2)E=vO,I=SO,U=EO,R=(H)=>pt[H>>1];else if(w===4)E=MO,I=xO,U=OO,R=(H)=>it[H>>2];Bn(g,{name:y,fromWireType:(H)=>{var K=it[H>>2],Q,gt=H+4;for(var Ft=0;Ft<=K;++Ft){var oe=H+4+Ft*w;if(Ft==K||R(oe)==0){var Ue=oe-gt,Oo=E(gt,Ue);if(Q===void 0)Q=Oo;else Q+=String.fromCharCode(0),Q+=Oo;gt=oe+w}}return Wn(H),Q},toWireType:(H,K)=>{if(typeof K!="string")Ee(`Cannot pass non-string to C++ string type ${y}`);var Q=U(K),gt=Zf(4+Q+w);if(it[gt>>2]=Q/w,I(K,gt+4,Q+w),H!==null)H.push(Wn,gt);return gt},argPackAdvance:yi,readValueFromPointer:Df,destructorFunction(H){Wn(H)}})},PO=(g,w)=>{w=en(w),Bn(g,{isVoid:!0,name:w,argPackAdvance:0,fromWireType:()=>{return},toWireType:(y,E)=>{return}})},RO=(g,w,y)=>B.copyWithin(g,w,w+y),Yf=[],NO=(g,w,y,E)=>{return g=Yf[g],w=vi.toValue(w),g(null,w,y,E)},AO={},TO=(g)=>{var w=AO[g];if(w===void 0)return en(g);return w},Eb=()=>{if(typeof globalThis=="object")return globalThis;function g(w){w.$$$embind_global$$$=w;var y=typeof $$$embind_global$$$=="object"&&w.$$$embind_global$$$==w;if(!y)delete w.$$$embind_global$$$;return y}if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;if(typeof global=="object"&&g(global))$$$embind_global$$$=global;else if(typeof self=="object"&&g(self))$$$embind_global$$$=self;if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;throw Error("unable to get global object.")},HO=(g)=>{if(g===0)return vi.toHandle(Eb());else return g=TO(g),vi.toHandle(Eb()[g])},FO=(g)=>{var w=Yf.length;return Yf.push(g),w},LO=(g,w)=>{var y=ki[g];if(y===void 0)Ee(`${w} has unknown type ${vb(g)}`);return y},CO=(g,w)=>{var y=Array(g);for(var E=0;E<g;++E)y[E]=LO(it[w+E*4>>2],"parameter "+E);return y},jO=Reflect.construct,_O=(g,w,y)=>{var E=[],I=g.toWireType(E,y);if(E.length)it[w>>2]=vi.toHandle(E);return I},GO=(g,w,y)=>{var E=CO(g,w),I=E.shift();g--;var R=Array(g),U=(K,Q,gt,Ft)=>{var oe=0;for(var Ue=0;Ue<g;++Ue)R[Ue]=E[Ue].readValueFromPointer(Ft+oe),oe+=E[Ue].argPackAdvance;var Oo=y===1?jO(Q,R):Q.apply(K,R);return _O(I,gt,Oo)},H=`methodCaller<(${E.map((K)=>K.name).join(", ")}) => ${I.name}>`;return FO(Jf(H,U))},BO=(g)=>{if(g>9)Un[g+1]+=1},UO=(g)=>{var w=vi.toValue(g);wb(w),qf(g)},WO=()=>{cb("")},KO=()=>2147483648,zO=(g)=>{var w=L.buffer,y=(g-w.byteLength+65535)/65536;try{return L.grow(y),gn(),1}catch(E){}},qO=(g)=>{var w=B.length;g>>>=0;var y=KO();if(g>y)return!1;var E=(K,Q)=>K+(Q-K%Q)%Q;for(var I=1;I<=4;I*=2){var R=w*(1+0.2/I);R=Math.min(R,g+100663296);var U=Math.min(y,E(Math.max(g,R),65536)),H=zO(U);if(H)return!0}return!1},Vf={},DO=()=>l||"./this.program",Ys=()=>{if(!Ys.strings){var g=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",w={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:g,_:DO()};for(var y in Vf)if(Vf[y]===void 0)delete w[y];else w[y]=Vf[y];var E=[];for(var y in w)E.push(`${y}=${w[y]}`);Ys.strings=E}return Ys.strings},JO=(g,w)=>{for(var y=0;y<g.length;++y)q[w++]=g.charCodeAt(y);q[w]=0},YO=(g,w)=>{var y=0;return Ys().forEach((E,I)=>{var R=w+y;it[g+I*4>>2]=R,JO(E,R),y+=E.length+1}),0},VO=(g,w)=>{var y=Ys();it[g>>2]=y.length;var E=0;return y.forEach((I)=>E+=I.length+1),it[w>>2]=E,0},ZO=0,XO=()=>G2||ZO>0,QO=(g)=>{if(_=g,!XO())n.onExit?.(g),A=!0;d(g,new _2(g))},tI=(g,w)=>{_=g,QO(g)},eI=tI,nI=(g)=>52,rI=(g,w)=>w+2097152>>>0<4194305-!!g?(g>>>0)+w*4294967296:NaN;function iI(g,w,y,E,I){var R=rI(w,y);return 70}var oI=[null,[],[]],sI=(g,w)=>{var y=oI[g];if(w===0||w===10)(g===1?x:M)(Sb(y,0)),y.length=0;else y.push(w)},aI=(g,w,y,E)=>{var I=0;for(var R=0;R<y;R++){var U=it[w>>2],H=it[w+4>>2];w+=8;for(var K=0;K<H;K++)sI(g,B[U+K]);I+=H}return it[E>>2]=I,0};K2(),pb=n.BindingError=class extends Error{constructor(w){super(w);this.name="BindingError"}},gb=n.InternalError=class extends Error{constructor(w){super(w);this.name="InternalError"}},Y2(),yb=n.UnboundTypeError=lO(Error,"UnboundTypeError");var cI={o:U2,q:W2,m:D2,l:Z2,j:Q2,f:hO,b:pO,a:gO,e:yO,c:IO,n:PO,v:RO,i:NO,d:qf,k:HO,h:GO,y:BO,g:UO,r:WO,s:qO,t:YO,u:VO,z:eI,w:nI,p:iI,x:aI},ie=j2(),uI=()=>(uI=ie.B)(),Mb=(g)=>(Mb=ie.C)(g),Zf=(g)=>(Zf=ie.D)(g),Wn=(g)=>(Wn=ie.E)(g),lI=(g)=>(lI=ie._emscripten_stack_restore)(g),fI=(g)=>(fI=ie._emscripten_stack_alloc)(g),dI=()=>(dI=ie.emscripten_stack_get_current)(),hI=(g)=>(hI=ie.__cxa_increment_exception_refcount)(g),xb=(g)=>(xb=ie.G)(g),mI=n.dynCall_jiji=(g,w,y,E,I)=>(mI=n.dynCall_jiji=ie.H)(g,w,y,E,I),Uc;Js=function g(){if(!Uc)Ob();if(!Uc)Js=g};function Ob(){if(wi>0)return;if(Bf(),wi>0)return;function g(){if(Uc)return;if(Uc=!0,n.calledRun=!0,A)return;if(Uf(),r(n),n.onRuntimeInitialized)n.onRuntimeInitialized();P2()}if(n.setStatus)n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),g()},1);else g()}if(n.preInit){if(typeof n.preInit=="function")n.preInit=[n.preInit];while(n.preInit.length>0)n.preInit.pop()()}return Ob(),o}})(),Yw=uR;function xd(t){if(t[0]!==255||t[1]!==216)return null;let e=2;while(e+9<t.length){if(t[e]!==255){e++;continue}let n=t[e+1];if(n===255){e++;continue}let r=t[e+2]<<8|t[e+3];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204)return{height:t[e+5]<<8|t[e+6],width:t[e+7]<<8|t[e+8]};e+=2+r}return null}var Md;function fR(){if(Md)return Md;let t=new WebAssembly.Module(lR(Buffer.from("7L0NnFzHVSd6q+5H3+7bPdMjjeyRZmTf7ohFITZWgpFN4mBdEX3Y8leI15jfy+6a3UC8Mwp4ZEWYRdaMY9kICESA2TWsCXrBb+2wNugtejwvmBcFDBFgFgXMRkkMEYtJzBLA720A78PY+/+fU3X73u4eSVYMC1mUePre+rqnTp06derUqXOCb7rzPSYIAvN/m9nbzFKA/8zSbeHSEn/sEhLiJf4Lbov0x0pOY2nJJWu2q+NK4S1gzgH8C25LfFH3gNwIWUgIlw4smQOuzn40vZ/to0rEmihnmIxsNsM6BwS+A/wWHkMpZH/MrDPfZL4paOLvPw8i/P0X8vwu9OqbzDcHIf5+S9DA33dLyu2Bxd9/GUzh77yUXAgM/u6W3PcEMf5+q9T6Nsm9I0jxd1Fa2BNk+HunlN8bJPj7Xvm7T0p+u6TfFbTw9zuktX8VBOFvm48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MkB446onyn6uLP/v3Z14+sr3++PHzzyDGIA13DI0ex0x76GqfWrW6Xl1+80Glnns9OFtPvHvh9iC5x946fvyTDx4/jgG8a1dqbCzZn93XCbnIrtJgdngXqZnsggpVgei8WolZ/BpwBO2LeMC74JfjPYc9Om8Egj8C+HvOnAR+hERoE+GPTQp/DuALvEPojkHws8GNxM6StrgOz4/heTXcx2ntBvcJVZXWYsx3A9hESPL2Za46vfRZkv8+xNuG94Nw/fr9LriUfr8XblC/PwCX1O+PwJX0+9NwZf3+LFxWv78EN6Tf34TL6fcAiOSwfo/jfUy/z8f7Af3ehvcB/b60Xfqa3le1V9cT76XsZN3C9dxEEy7q2Vc+p7LHrH/3I+wjeF4L98eKYDo7c4Xd4A9k+5zi3wWY9y8S+GMa/roK/GLZgNURdJ5Pt0va9KO8qa/+xNVX18P9KdwNcDdyOuc4BVea0Ziv8yy3S/xPVsX/FNxNcJ/W8Jfr/KisN+N5CxxGgroV7jNwf6YS1/xYmZHxJbIACoKO4tt3uUrcj2f0CvhdCXfXEhx7owAsIp/5sYfQHnoG3lf9Bw==","base64"))),e={noInitialRun:!0,print:()=>{return},printErr:()=>{return},instantiateWasm:(n,r)=>{let i=new WebAssembly.Instance(t,n);return r(i),i.exports}};if(Yw(e),typeof e.decode!=="function")throw Error("the JPEG decoder did not start");return Md=e,e}function Vw(t,e){let n=xd(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);let r=null;try{r=fR().decode(t,!0)}catch{r=null}if(!r)throw Error("not a JPEG image this decoder can read");return{width:r.width,height:r.height,data:new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.length)}}var Lo=[137,80,78,71,13,10,26,10],Qw=13,t0=3;function Ii(t){return t.length>=Lo.length&&Lo.every((e,n)=>t[n]===e)}var e0={0:1,2:3,4:2,6:4};function pR(t){if(t.length<33||!Ii(t))return;let e=Buffer.from(t.buffer,t.byteOffset,t.byteLength),n=e.readUInt32BE(16),r=e.readUInt32BE(20),i=e[25];if(e[24]!==8||e[28]!==0||e0[i]===void 0)return;let o=[];for(let s=8;s+12<=e.length;){let a=e.readUInt32BE(s),c=e.toString("latin1",s+4,s+8);if(c==="IDAT")o.push(e.subarray(s+8,s+8+a));else if(c==="tRNS"||c==="IEND"){if(c==="tRNS"&&i!==4&&i!==6)return;break}s+=12+a}return o.length>0?{width:n,height:r,type:i,idat:o}:void 0}function gR(t,e,n,r){let i=new Uint8Array(e);for(let o=0;o<n;o++){let s=o*(e+1),a=t[s],c=s+1,u=o>0?t:i,f=o>0?c-e-1:0;if(a===1)for(let l=r;l<e;l++)t[c+l]=t[c+l]+t[c+l-r];else if(a===2)for(let l=0;l<e;l++)t[c+l]=t[c+l]+u[f+l];else if(a===3){for(let l=0;l<r;l++)t[c+l]=t[c+l]+(u[f+l]>>1);for(let l=r;l<e;l++)t[c+l]=t[c+l]+(t[c+l-r]+u[f+l]>>1)}else if(a===4){for(let l=0;l<r;l++)t[c+l]=t[c+l]+u[f+l];for(let l=r;l<e;l++){let d=t[c+l-r],h=u[f+l],m=u[f+l-r],p=Math.abs(h-m),b=Math.abs(d-m),$=Math.abs(d+h-2*m);t[c+l]=t[c+l]+(p<=b&&p<=$?d:b<=$?h:m)}}else if(a!==0)throw Error(`bad PNG filter ${a}`)}}function bR(t){let{width:e,height:n,type:r}=t,i=e0[r],o=e*i,s=mR(Buffer.concat(t.idat),{chunkSize:Math.min(268435456,Math.max(65536,n*(o+1)))});if(s.length<n*(o+1))throw Error("truncated PNG");gR(s,o,n,i);let a=new Uint8Array(e*n*4);for(let c=0;c<n;c++){let u=c*(o+1)+1,f=c*e*4;if(r===6)a.set(s.subarray(u,u+o),f);else if(r===2)for(let l=0,d=u,h=f;l<e;l++,d+=3,h+=4)a[h]=s[d],a[h+1]=s[d+1],a[h+2]=s[d+2],a[h+3]=255;else if(r===0)for(let l=0,d=f;l<e;l++,d+=4){let h=s[u+l];a[d]=h,a[d+1]=h,a[d+2]=h,a[d+3]=255}else for(let l=0,d=u,h=f;l<e;l++,d+=2,h+=4){let m=s[d];a[h]=m,a[h+1]=m,a[h+2]=m,a[h+3]=s[d+1]}}return{width:e,height:n,data:a}}function Gt(t){let e=pR(t);if(e)return bR(e);let n=Xw.PNG.sync.read(Buffer.from(t));return{width:n.width,height:n.height,data:new Uint8Array(n.data)}}function Nr(t,e){if(Ii(t)){let n=yn(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);return Gt(t)}if(t[0]===255&&t[1]===216)return Vw(t,e);throw Error("not a PNG or JPEG image")}function n0(t,e){let{width:n,height:r,at:i}=e,o=Math.max(0,i.x),s=Math.max(0,i.y),a=Math.min(n,i.x+i.w),c=Math.min(r,i.y+i.h);if(a<=o||c<=s)return;let u={x:o,y:s,w:a-o,h:c-s};if(i.w===t.width&&i.h===t.height)return{part:t,box:u,dx:o-i.x,dy:s-i.y};let f={x:(o-i.x)*t.width/i.w,y:(s-i.y)*t.height/i.h,w:u.w*t.width/i.w,h:u.h*t.height/i.h};return{part:ta(t,f,u.w,u.h),box:u,dx:0,dy:0}}function r0(t,e){let n=new Uint8Array(e.width*e.height*4),r=n0(t,e);if(r){let{part:i,box:o,dx:s,dy:a}=r;for(let c=0;c<o.h;c++){let u=((c+a)*i.width+s)*4;n.set(i.data.subarray(u,u+o.w*4),((o.y+c)*e.width+o.x)*4)}}return{width:e.width,height:e.height,data:n}}function Ar(t,e,n,r={width:t.width,height:t.height,at:{x:0,y:0,w:t.width,h:t.height}}){let i=ot(e),{width:o,height:s}=r,a=new Uint8Array(o*s*3);for(let h=0;h<o*3;h+=3)a.set(i,h);for(let h=1;h<s;h++)a.copyWithin(h*o*3,0,o*3);let c=n0(t,r);if(!c)return{width:o,height:s,data:a};let{part:u,box:f,dx:l,dy:d}=c;for(let h=0;h<f.h;h++)for(let m=0;m<f.w;m++){let p=((h+d)*u.width+m+l)*4,b=((f.y+h)*o+f.x+m)*3,$=u.data[p+3]/255*n;for(let k=0;k<3;k++)a[b+k]=Math.round(i[k]*(1-$)+u.data[p+k]*$)}return{width:o,height:s,data:a}}function Zw(t,e){for(let n=0;n+e.length<=t.length;n++){let r=!0;for(let i=0;i<e.length&&r;i++)r=t[n+i]===e.charCodeAt(i);if(r)return n}return-1}function yn(t){if(t.length<33||!Ii(t))return null;let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(16),r=e.getUint32(20);if(t[25]===4||t[25]===6)return{width:n,height:r,alpha:!0};let i=Zw(t,"IDAT");return{width:n,height:r,alpha:Zw(i===-1?t:t.subarray(0,i),"tRNS")!==-1}}function i0(t,e=Qw){let{width:n,height:r,data:i}=t,o=(f)=>{for(let l=f*n*4+3,d=l+n*4;l<d;l+=4)if(i[l]>=e)return!0;return!1},s=0;while(s<r&&!o(s))s++;if(s===r)return null;let a=r-1;while(!o(a))a--;let c=n,u=-1;for(let f=s;f<=a;f++){let l=f*n*4+3;for(let d=0;d<c;d++)if(i[l+d*4]>=e){c=d;break}for(let d=n-1;d>u;d--)if(i[l+d*4]>=e){u=d;break}}return{x:c,y:s,w:u-c+1,h:a-s+1}}function Vn(t,e={x:0,y:0,w:t.width,h:t.height}){let n=0;for(let r=e.y;r<e.y+e.h;r++)for(let i=e.x;i<e.x+e.w;i++)if((t.data[(r*t.width+i)*4+3]??0)<Qw)n++;return Math.round(n*100/(e.w*e.h))}function o0(t,e,n){let r=Math.min(e/t.width,n/t.height),i=Math.max(1,Math.round(t.width*r)),o=Math.max(1,Math.round(t.height*r)),s=ta(t,{x:0,y:0,w:t.width,h:t.height},i,o),a=new Uint8Array(e*n*4),c=Math.floor((e-i)/2),u=Math.floor((n-o)/2);for(let f=0;f<o;f++)a.set(s.data.subarray(f*i*4,(f+1)*i*4),((u+f)*e+c)*4);return{width:e,height:n,data:a}}function wR(t){let e=Math.abs(t);if(e<1)return(7*e*e*e-12*e*e+5.333333333333333)/6;if(e<2)return(-2.3333333333333335*e*e*e+12*e*e-20*e+10.666666666666666)/6;return 0}function Od(t,e,n,r){if(n===r&&Number.isInteger(e)&&e>=0&&e+r<=t)return{first:Int32Array.from({length:r},(f,l)=>e+l),size:1,weights:new Float32Array(r).fill(1)};let i=n/r,o=Math.max(1,i),s=2*o,a=Math.min(t,Math.ceil(2*s)+2),c=new Int32Array(r),u=new Float32Array(r*a);for(let f=0;f<r;f++){let l=e+(f+0.5)*i,d=Math.floor(l-s-0.5),h=Math.max(0,Math.min(t-a,d));c[f]=h;let m=0;for(let p=d;p<=Math.ceil(l+s-0.5);p++){let b=wR((p+0.5-l)/o),$=f*a+Math.min(t-1,Math.max(0,p))-h;u[$]=(u[$]??0)+b,m+=b}for(let p=f*a;p<(f+1)*a;p++)u[p]=(u[p]??0)/m}return{first:c,size:a,weights:u}}function s0(t,e,n,r,i,o,s){let a=Od(t,e.y,e.h,r),c=n*i,u=a.size+1,f=Array.from({length:u},()=>new Float32Array(c)),l=new Int32Array(u).fill(-1),d=new Float32Array(c),h=[],m=[];for(let p=0;p<r;p++){h.length=0,m.length=0;let b=a.first[p];for(let k=0;k<a.size;k++){let v=a.weights[p*a.size+k];if(v===0)continue;let S=b+k,x=S%u,M=f[x];if(l[x]!==S)o(S,M),l[x]=S;h.push(M),m.push(v)}let $=0;while($<h.length){let k=h[$],v=m[$];if(h.length-$>=4){let S=h[$+1],x=h[$+2],M=h[$+3],P=m[$+1],L=m[$+2],A=m[$+3];if($===0)for(let _=0;_<c;_++)d[_]=k[_]*v+S[_]*P+x[_]*L+M[_]*A;else for(let _=0;_<c;_++)d[_]=d[_]+(k[_]*v+S[_]*P+x[_]*L+M[_]*A);$+=4}else{if($===0)for(let S=0;S<c;S++)d[S]=k[S]*v;else for(let S=0;S<c;S++)d[S]=d[S]+k[S]*v;$+=1}}if(h.length===0)d.fill(0);s(p,d)}}function a0(t,e,n,r,i){let o=0,s=n;while(o<s){let c=o+s>>1;if(t[c]+e-1<r)o=c+1;else s=c}let a=o;s=n;while(o<s){let c=o+s>>1;if(t[c]<=i)o=c+1;else s=c}return[a,o]}function ta(t,e,n,r){let i=Od(t.width,e.x,e.w,n),o=t.data,s=t.width,a=new Float32Array(s*4),c=new Uint8Array(n*r*4);return s0(t.height,e,n,r,4,(u,f)=>{let l=u*s*4,d=s,h=-1;for(let b=0,$=0;b<s*4;b+=4,$++){let k=o[l+b+3];if(k===0){a[b]=0,a[b+1]=0,a[b+2]=0,a[b+3]=0;continue}if($<d)d=$;h=$,a[b]=o[l+b]*k,a[b+1]=o[l+b+1]*k,a[b+2]=o[l+b+2]*k,a[b+3]=k}if(f.fill(0),h<0)return;let[m,p]=a0(i.first,i.size,n,d,h);for(let b=m;b<p;b++){let $=i.first[b]*4,k=b*i.size,v=0,S=0,x=0,M=0;for(let P=0;P<i.size;P++){let L=i.weights[k+P],A=$+P*4;v+=a[A]*L,S+=a[A+1]*L,x+=a[A+2]*L,M+=a[A+3]*L}f[b*4]=v,f[b*4+1]=S,f[b*4+2]=x,f[b*4+3]=M}},(u,f)=>{let l=u*n*4;for(let d=0;d<n;d++){let h=d*4,m=f[h+3];if(m<=0)continue;let p=f[h]/m;c[l+h]=(p<0?0:p>255?255:p)+0.5,p=f[h+1]/m,c[l+h+1]=(p<0?0:p>255?255:p)+0.5,p=f[h+2]/m,c[l+h+2]=(p<0?0:p>255?255:p)+0.5,c[l+h+3]=(m>255?255:m)+0.5}}),{width:n,height:r,data:c}}function c0(t,e,n,r){let i=Od(t.width,e.x,e.w,n),o=t.data,s=t.width,a=new Float32Array(n*r);return s0(t.height,e,n,r,1,(c,u)=>{let f=c*s,l=s,d=-1;for(let p=0;p<s;p++)if(o[f+p]!==0){if(p<l)l=p;d=p}if(u.fill(0),d<0)return;let[h,m]=a0(i.first,i.size,n,l,d);for(let p=h;p<m;p++){let b=f+i.first[p],$=p*i.size,k=0;for(let v=0;v<i.size;v++)k+=o[b+v]*i.weights[$+v];u[p]=k}},(c,u)=>{a.set(u,c*n)}),{width:n,height:r,data:a}}function ea(t,e){if(e<=0)return t;let n=Math.max(1,Math.ceil(e*3)),r=Array.from({length:2*n+1},(f,l)=>Math.exp(-((l-n)**2)/(2*e*e))),i=r.reduce((f,l)=>f+l,0),{width:o,height:s,data:a}=t,c=new Float32Array(o*s);for(let f=0;f<s;f++){let l=f*o;for(let d=0;d<o;d++){let h=0;for(let m=-n;m<=n;m++)h+=(a[l+Math.min(o-1,Math.max(0,d+m))]??0)*(r[m+n]??0);c[l+d]=h/i}}let u=new Float32Array(o*s);for(let f=0;f<s;f++){let l=f*o;for(let d=-n;d<=n;d++){let h=(r[d+n]??0)/i,m=Math.min(s-1,Math.max(0,f+d))*o;for(let p=0;p<o;p++)u[l+p]=(u[l+p]??0)+(c[m+p]??0)*h}}return{width:o,height:s,data:u}}function na(t){let e=new Uint8Array(t.data.length);for(let n=0;n<e.length;n++){let r=t.data[n];e[n]=(r<0?0:r>255?255:r)+0.5}return{width:t.width,height:t.height,data:e}}function Pi(t){let e=new Uint8Array(t.width*t.height);for(let n=0;n<e.length;n++)e[n]=t.data[n*4+3]??0;return{width:t.width,height:t.height,data:e}}var $R=Array.from({length:256},(t,e)=>{let n=e;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function kR(t){let e=4294967295;for(let n of t)e=($R[(e^n)&255]??0)^e>>>8;return(e^4294967295)>>>0}function Rr(t,e){let n=Buffer.alloc(12+e.length);return n.writeUInt32BE(e.length,0),n.write(t,4,"latin1"),n.set(e,8),n.writeUInt32BE(kR(n.subarray(4,8+e.length)),8+e.length),n}function u0(t,e,n){let r=new Uint8Array(n*(e+1));r.set(t.subarray(0,e),1);for(let i=1;i<n;i++){let o=i*(e+1),s=i*e,a=s-e;r[o]=2;for(let c=0;c<e;c++)r[o+1+c]=t[s+c]-t[a+c]}return r}function l0(t){return hR(t,{level:1,strategy:dR.Z_RLE})}function f0(t,e,n){let r=Buffer.alloc(13);return r.writeUInt32BE(t.width,0),r.writeUInt32BE(t.height,4),r[8]=8,r[9]=e,Buffer.concat([Buffer.from(Lo),Rr("IHDR",r),...n,Rr("IDAT",l0(u0(t.data,t.width,t.height))),Rr("IEND",new Uint8Array)])}function d0(t){let[e,n,r]=ot(t),i=new Uint8Array(768);for(let o=0;o<256;o++)i.set([e,n,r],o*3);return Rr("PLTE",i)}function h0(t,e,n,r,i){let o=Buffer.alloc(13);return o.writeUInt32BE(t,0),o.writeUInt32BE(e,4),o[8]=8,o[9]=n,Buffer.concat([Buffer.from(Lo),Rr("IHDR",o),Rr("IDAT",l0(u0(i,t*r,e))),Rr("IEND",new Uint8Array)])}function Tr(t){return h0(t.width,t.height,2,3,t.data)}function Ke(t){return h0(t.width,t.height,6,4,t.data)}function Ri(t,e){return f0(t,t0,[d0(e),Rr("tRNS",Uint8Array.from({length:256},(n,r)=>r))])}function Id(t){return f0(t,0,[])}function Yc(t,e){if(!Ii(t)||t[25]!==t0)return;let n=Buffer.from(t.buffer,t.byteOffset,t.byteLength),r=[Buffer.from(Lo)],i=Lo.length;while(i+8<=n.length){let o=i+12+n.readUInt32BE(i);r.push(n.toString("latin1",i+4,i+8)==="PLTE"?d0(e):n.subarray(i,o)),i=o}return Buffer.concat(r)}var Hr=100,Re=25000000,OR=536870912,Co=["safe","questionable","explicit"],Ni=["nudity","underwear"],Ad=["comic","monochrome","sketch","chibi"],v0=["off","5","10","25","50","100"],S0=["off","720","1080","1440","1800","2560"],E0={nudity:new Set(["nude","naked","topless","bottomless","nipples","naked_towel","undressing"]),underwear:new Set(["underwear","panties","pantsu","bra","lingerie","pantyshot"])},IR={comic:new Set(["comic","4koma"]),monochrome:new Set(["monochrome","greyscale"]),sketch:new Set(["sketch","lineart","line_art"]),chibi:new Set(["chibi"])},PR=/^(?:rating|score|width|height|filetype|dimension):/,ra={safe:"s",questionable:"q",explicit:"e"},M0=8191,RR=20000,NR=5000,m0=3000,p0=8,AR=8,TR=8000,HR=3000,x0=60000,g0=3,FR=3,LR="https://static.zerochan.net",O0="https://s1.zerochan.net",Td=`ttheme/${lt.version} (+${lt.homepage})`,CR=["orig","tile","thumb","cut"],I0=new Map,jR=eN(process.env.TTHEME_FIND_HOSTS),_R=tN(process.env.TTHEME_FIND_CUTOUTS);ER(HR);var GR=["artist","character","copyright"];function b0(t){try{return yR(t)}catch{return[]}}function jo(t){return t.startsWith("//")?`https:${t}`:t}function Lr(t){return(/\.([a-z0-9]+)(?:\?.*)?$/i.exec(t)?.[1]??"").toLowerCase()}function oa(t){let e=t.trim();if(!e)return[];let n=JSON.parse(e);if(Array.isArray(n))return n;let r=n.posts;return Array.isArray(r)?r:[]}function BR(t){let e=t.trim(),r=(e?JSON.parse(e):{}).tags??{};return new Map(Object.entries(r).map(([i,o])=>[i,String(o)]))}function Rd(t,e,n){let r=jo(String(t??""));return{file:r,width:Number(e)||0,height:Number(n)||0,ext:Lr(r)}}function Zn(t){return String(t??"").split(/\s+/).filter(Boolean)}function Nd(t){let e=typeof t==="number"?new Date(t*1000):typeof t==="string"?new Date(t):void 0;return e&&!Number.isNaN(e.getTime())?e.toISOString().slice(0,10):void 0}function P0(t,e){let n=jo(String(e.preview??""));if(!e.file||!n||!Number(t.id))return[];let r=Number(t.width??t.image_width)||0,i=Number(t.height??t.image_height)||0;return[{id:Number(t.id),width:r,height:i,file:e.file,preview:n,ext:e.ext,owner:String(e.owner??""),score:Number(t.score)||0,rating:String(t.rating??""),md5:String(e.md5??""),source:String(t.source??""),tags:Zn(e.tags),named:e.named,...Nd(t.created_at)?{posted:Nd(t.created_at)}:{},solo:e.solo,family:Number(t.parent_id)||(t.has_children===!0?Number(t.id):0),smaller:e.versions.filter((o)=>o.file&&o.width>0&&o.height>0&&o.width*o.height<r*i)}]}function UR(t){let e=BR(t);return oa(t).flatMap((n)=>{let r=jo(String(n.file_url??"")),i=String(n.tags??""),o=(s)=>Zn(i).filter((a)=>e.get(a)===s);return P0(n,{preview:n.preview_url,file:r,ext:String(n.file_ext||Lr(r)).toLowerCase(),owner:n.author,md5:n.md5,tags:i,named:{artist:o("artist"),character:o("character"),copyright:o("copyright")},solo:void 0,versions:[Rd(n.jpeg_url,n.jpeg_width,n.jpeg_height),Rd(n.sample_url,n.sample_width,n.sample_height)]})})}function WR(t){return oa(t).flatMap((e)=>{let n=jo(String(e.file_url??"")),r=String(e.tag_string??""),i=e.media_asset??{};return P0(e,{preview:i.variants?.find((o)=>o.type==="360x360")?.url??e.preview_file_url,file:n,ext:String(e.file_ext||Lr(n)).toLowerCase(),owner:"",md5:e.md5,tags:r,named:{artist:Zn(e.tag_string_artist),character:Zn(e.tag_string_character),copyright:Zn(e.tag_string_copyright)},solo:r.split(/\s+/).includes("solo"),versions:(i.variants??[]).map((o)=>Rd(o.url,o.width,o.height)).filter((o)=>o.ext==="jpg"||o.ext==="png").sort((o,s)=>s.width*s.height-o.width*o.height)})})}function R0(t){return t.toLowerCase().replace(/\s+/g,"_")}function KR(t){return(Array.isArray(t)?t:[]).map((e)=>R0(String(e)))}function zR(t){return String(t??"").replace(/[^0-9a-z]+/gi,".").replace(/^\.+|\.+$/g,"")||"zerochan"}function qR(t){let e=t.trim(),n=e?JSON.parse(e):{};return(Array.isArray(n.items)?n.items:n.id?[n]:[]).flatMap((i)=>{let o=Number(i.id);if(!o)return[];let s=KR(i.tags),a=jo(String(i.full??""));return[{id:o,width:Number(i.width)||0,height:Number(i.height)||0,file:a,ext:Lr(a),preview:`${O0}/${zR(i.tag??i.primary)}.600.${o}.jpg`,owner:"",score:0,rating:s.some((c)=>E0.nudity.has(c))?"q":"g",md5:String(i.md5??i.hash??""),source:String(i.source??""),tags:s,named:{artist:[],character:[],copyright:[]},solo:s.includes("solo"),family:0,smaller:[]}]})}var DR={mangaka:"artist",studio:"artist",character:"character",series:"copyright",game:"copyright"};function w0(t){return t.replace(/&(?:#(\d+)|amp|quot|apos|lt|gt);/g,(e,n)=>n?String.fromCharCode(Number(n)):{"&":"&",""":'"',"'":"'","<":"<",">":">"}[e]??e)}function JR(t){let e={artist:[],character:[],copyright:[]};for(let[,r,i]of t.matchAll(/<li class="([a-z]+)[^"]*"[^>]*\bdata-tag="([^"]*)"/g)){let o=DR[r],s=R0(w0(i));if(o&&!e[o].includes(s))e[o].push(s)}let n=Nd(/"datePublished":\s*"([^"]+)"/.exec(t)?.[1]);return{named:e,source:"",owner:w0(/\buploader = \{\s*name: '([^']*)'/.exec(t)?.[1]??""),...n?{posted:n}:{}}}function YR(t){return Number(/Zerochan has ([\d,]+) /.exec(t)?.[1]?.replace(/,/g,"")??0)}function VR(t){return oa(t).flatMap((e)=>{let n=String(e.value??"");return n?[{value:n,count:Number(e.post_count)||0}]:[]})}function ZR(t){return oa(t).flatMap((e)=>{let n=String(e.name??"");return n?[{value:n,count:Number(e.count)||0}]:[]})}function XR(t){return Number(/count="(\d+)"/.exec(t)?.[1]??0)}function QR(t){let n=(t.trim()?JSON.parse(t):{}).counts?.posts;return n===null?Number.NaN:Number(n)||0}function tN(t){let e=new Map;for(let n of(t??"").split(/\s+/).filter(Boolean)){let r=n.indexOf("=");if(r>0)e.set(n.slice(0,r),n.slice(r+1).split(",").filter(Boolean))}return e}function eN(t){let e=new Map;for(let n of(t??"").split(/[\s,]+/).filter(Boolean)){let r=n.indexOf("="),i=n.slice(0,r);try{let o=new URL(n.slice(r+1));if(i&&o.protocol==="https:")e.set(i,o.origin)}catch{}}return e}function Vc(t,e,n,r){let i=(t??"").split(/\s+/);if(r!==void 0&&i.includes(r))return[];let o=e.filter((s)=>i.includes(s));return o.length>0?o:[...n]}function Ai(t){return Vc(t,Co,["safe"])}function _o(t){return Vc(t,Ni,Ni,"none")}function Zc(t){return Vc(t,Ad,[],"none")}function sa(t){let e=Z.map((n)=>n.name);return Vc(t,e,e)}function Hd(t,e,n){return{score:Number(t)||0,size:Number(e)||0,png:n==="on"}}function aa(t){return[...new Set((t??"").toLowerCase().split(/[\s,]+/).map((e)=>e.replace(/^-+/,"")).filter(Boolean))]}function Fd(t,e,n){return{safe:new Set(t),questionable:new Set(e),explicit:new Set(n)}}function Ld(t){let e=jR.get(t.key),n=_R.get(t.key);return{...t,origin:e??t.origin,moved:e!==void 0&&e!==t.origin,cutouts:n??t.cutouts,vouched:t.vouched&&n===void 0}}function N0(t){return t.length<2?t.join(""):t.map((e)=>`~${e}`).join(" ")}function A0(t){return t>0?[`width:>=${t}`,`height:>=${t}`]:[]}function $0(t){let e=Ld(t),n=(r)=>new URLSearchParams({api_version:"2",include_tags:"1",...r});return{...e,scored:!0,narrow:({score:r,size:i})=>[...r>0?[`score:>=${r}`]:[],...A0(i)],cutouts:N0(e.cutouts),ratings:Fd([ra.safe],[ra.questionable],[ra.explicit]),rate:(r)=>{let[i]=r;if(r.length===1&&i)return`rating:${ra[i]}`;let o=Co.filter((a)=>!r.includes(a)),[s]=o;return o.length===1&&s?`-rating:${ra[s]}`:""},best:"order:score",tagBudget:Number.POSITIVE_INFINITY,ors:!0,postsUrl:(r,i)=>`${e.origin}/post.json?${n({limit:String(Hr),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/post.xml?${new URLSearchParams({limit:"1",tags:r})}`,postUrl:(r)=>`${e.origin}/post.json?${n({tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/post/show/${r}`,parse:UR,count:XR,uploadedBy:(r)=>`user:${r}`}}function nN(t){let e=Ld(t),n=Fd(["g"],["s","q"],["e"]);return{...e,scored:!0,narrow:({score:r,size:i,png:o})=>[...r>0?[`score:>=${r}`]:[],...A0(i),...o?["filetype:png"]:[]],cutouts:N0(e.cutouts),ratings:n,rate:(r)=>r.length===Co.length?"":`rating:${r.flatMap((i)=>[...n[i]]).join(",")}`,best:"order:score",tagBudget:2,ors:!0,postsUrl:(r,i)=>`${e.origin}/posts.json?${new URLSearchParams({limit:String(Hr),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/counts/posts.json?${new URLSearchParams({tags:r})}`,postUrl:(r)=>`${e.origin}/posts.json?${new URLSearchParams({limit:"1",tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/posts/${r}`,parse:WR,count:QR,uploadedBy:(r)=>`user:${r}`}}function Pd(t){return t.split(/\s+/).filter((e)=>e&&!/^(?:order|dimension):/.test(e)).map((e)=>e.split("_").map(encodeURIComponent).join("+")).join(",")}function k0(t){let e=t.split(/\s+/),n=e.find((r)=>r.startsWith("dimension:"))?.slice(10);return{s:e.includes("order:fav")?"fav":"id",...n?{d:n}:{}}}function rN(t){let e=Ld(t);return{...e,scored:!1,narrow:({size:n})=>n>=1800?["dimension:huge"]:n>0?["dimension:large"]:[],cutouts:e.cutouts[0]??"",ratings:Fd(["g"],["q"],["e"]),rate:()=>"",best:"order:fav",tagBudget:3,ors:!1,missing:404,postsUrl:(n,r)=>`${e.origin}/${Pd(n)}?${new URLSearchParams({json:"",l:String(Hr),p:String(r+1),...k0(n)})}`,countUrl:(n)=>`${e.origin}/${Pd(n)}?${new URLSearchParams({xml:"",l:"1"})}`,postUrl:(n)=>`${e.origin}/${n}?json=`,pageUrl:(n)=>`${e.origin}/${n}`,parse:qR,count:YR,credits:JR,counts:(n)=>Pd(n).split(",").length===1&&!("d"in k0(n)),guesses:(n)=>(n.tags.includes("transparent_background")?["png","jpg"]:["jpg","png"]).map((r)=>n.preview.replace(O0,LR).replace(/\.600\.(\d+)\.jpg$/,`.full.$1.${r}`))}}function iN(t){let e=y0(`https://${t}`);return Z.find((n)=>y0(n.origin)===e)}function Cd(t){return t.split(/\s+/).filter((e)=>e&&!PR.test(e)).length}function Xc(t,e){let n=t.trim();if(/^\d+$/.test(n))return{site:e,id:Number(n)};let r=/^([\w.]+):(\d+)$/.exec(n);if(r){let a=Z.find((c)=>c.key===r[1]||c.name===r[1]);return a&&{site:a,id:Number(r[2])}}let i;try{i=new URL(n)}catch{return}let o=iN(i.host),s=Number(i.searchParams.get("id")??i.pathname.split("/").filter(Boolean).at(-1));return o&&s>0?{site:o,id:s}:void 0}var Z=[nN({key:"danbooru",name:"danbooru",origin:"https://shima.donmai.us",cutouts:["transparent_background"],vouched:!1,ansi:2}),$0({key:"konachan",name:"konachan",origin:"https://konachan.net",cutouts:["transparent","vector"],vouched:!1,ansi:6}),$0({key:"yande",name:"yande.re",origin:"https://yande.re",cutouts:["transparent_png"],vouched:!0,ansi:5}),rN({key:"zerochan",name:"zerochan",origin:"https://www.zerochan.net",cutouts:["transparent_background"],vouched:!1,ansi:3})],ce=Z.find((t)=>t.key==="danbooru"),Cr=134217728;function Ne(t,e){let n=Z.indexOf(t);return(n===-1?Z.length:n)*Cr+e}function y0(t){let e;try{e=new URL(t).hostname}catch{return""}return e.split(".").slice(-2).join(".")}function Ti(t,e,n=e){return e.mirror&&n===e?{site:ce,url:e.mirror.file}:{site:t,url:n.file}}function Qc(t,e){return e.mirror?{site:ce,url:e.mirror.preview}:{site:t,url:e.preview}}function tu(t,e=Ni){return t.tags.filter((n)=>e.some((r)=>E0[r].has(n)))}function T0(t,e){return t.tags.filter((n)=>e.some((r)=>IR[r].has(n)))}function eu(t,e,n=["safe"]){return n.some((r)=>t.ratings[r].has(e.rating))}function H0(t,e){return t.rate(["safe"])===""?void 0:Co.find((n)=>t.ratings[n].has(e.rating))}function vn(t){return[t,...t.smaller].find((e)=>e.width*e.height<=Re)}function F0(t){let e=new Map;for(let[n,r]of[...t].sort(([i],[o])=>i<o?-1:1)){if(r==="")continue;e.set(r,[...e.get(r)??[],n])}return e}function jr(){return ia(process.env.XDG_CACHE_HOME??ia(MR(),".cache"),"ttheme")}function on(t){return ia(jr(),t.key)}function L0(t=OR,e=jr()){let n=[],r=0;for(let i of b0(e))for(let o of CR){let s=ia(e,i,o);for(let a of b0(s)){let c=ia(s,a);try{let{size:u,mtimeMs:f}=SR(c);n.push({path:c,size:u,at:f}),r+=u}catch{}}}n.sort((i,o)=>i.at-o.at);for(let i of n){if(r<=t)return;try{vR(i.path,{force:!0}),r-=i.size}catch{}}}function oN(t,e){if(t!==null&&/^\s*\d+\s*$/.test(t))return Number(t)*1000;let n=t===null?Number.NaN:Date.parse(t);return Number.isNaN(n)?x0:Math.max(0,n-e)}function Xn(t){return I0.get(t.key)??0}function sN(t){for(let e=t;e instanceof Error;e=e.cause)if(e.code==="ECONNRESET")return!0;return!1}function aN(t){return(t.headers.get("server")??"").startsWith("cloudflare")&&t.headers.get("cf-mitigated")==="challenge"}function cN(t,e){let n=new URL(e,t);if(!n.search)n.search=new URL(t).search;return n.href}async function Fr(t,e,n,r={},i=RR){let o=e;for(let s=1,a=0;;s++){let c=Xn(t)-Date.now();if(c>0)await xR(c,void 0,{signal:n});let u;try{u=await fetch(o,{headers:{"User-Agent":Td,Referer:`${t.origin}/`,...r},redirect:"manual",signal:i?AbortSignal.any([n,AbortSignal.timeout(i)]):n})}catch(l){if(s<g0&&!n.aborted&&sN(l))continue;throw l}let f=u.headers.get("location");if(f&&u.status>=300&&u.status<400&&a<FR){await u.body?.cancel(),o=cN(o,f),a++,s--;continue}if(u.status===429&&s<g0){await u.body?.cancel();let l=oN(u.headers.get("retry-after"),Date.now());if(l>x0)throw Error(`${t.name} asks to wait ${Math.ceil(l/1000)}s`);I0.set(t.key,Math.max(Xn(t),Date.now()+l));continue}if(!u.ok)throw await u.body?.cancel(),Object.assign(Error(aN(u)?`${t.name} is behind a Cloudflare challenge`:`${t.name} answered ${u.status}`),{status:u.status});return u}}async function nu(t,e,n){try{return await(await Fr(t,e,n)).text()}catch(r){if(t.missing!==void 0&&r.status===t.missing)return"";throw r}}async function C0(t,e,n,r){return t.parse(await nu(t,t.postsUrl(e,n),r))}async function jd(t,e,n){return t.count(await nu(t,t.countUrl(e),n))}async function Go(t,e,n){let[r]=t.parse(await nu(t,t.postUrl(e),n));return r}async function ru(t,e,n){return t.credits?.(await nu(t,t.pageUrl(e),n))}var uN=/^https?:\/\/(?:i\.pximg\.net|i\d*\.pixiv\.net|img\d*\.pixiv\.net)\/\S*\/(\d+)(?:_p\d+)?(?:_\w+)?\.\w+(?:[?#]\S*)?$/i,lN=/^https?:\/\/(?:www\.)?pixiv\.net\/member_illust\.php\?\S*\billust_id=(\d+)/i;function ca(t){let e=uN.exec(t)?.[1]??lN.exec(t)?.[1];return e?`https://www.pixiv.net/artworks/${e}`:t}function iu(t,e){return t.credits!==void 0&&e.named.artist.length===0}function ua(t,e){for(let n of GR){let r=e.named?.[n]??[];if(t.named[n].length===0&&r.length>0)t.named[n]=r}if(t.source||=e.source??"",t.owner||=e.owner??"",!t.posted&&e.posted)t.posted=e.posted}function fN(t){let e=new URLSearchParams({limit:String(2*Hr),only:"md5,tag_string,tag_string_artist,tag_string_character,tag_string_copyright,source,file_url",tags:`md5:${t.join(",")}`});return`${ce.origin}/posts.json?${e}`}function dN(t){return new Map(oa(t).flatMap((e)=>{let n=String(e.md5??"");return n?[[n,{tags:Zn(e.tag_string),named:{artist:Zn(e.tag_string_artist),character:Zn(e.tag_string_character),copyright:Zn(e.tag_string_copyright)},source:String(e.source??""),file:jo(String(e.file_url??""))}]]:[]}))}function ou(t,e){for(let n of t){let r=e.get(n.md5);if(!r)continue;if(n.tags=[...new Set([...n.tags,...r.tags])],ua(n,r),n.solo=r.tags.includes("solo"),r.file.includes("/original/")){if(n.mirror={file:r.file,preview:r.file.replace("/original/","/360x360/").replace(/\.[a-z0-9]+$/i,".jpg")},!n.file)n.file=r.file,n.ext=Lr(r.file)}}}async function su(t,e){let n=new Map;if(Xn(ce)>Date.now())return n;for(let r=0;r<t.length;r+=Hr){let i=await(await Fr(ce,fN(t.slice(r,r+Hr)),e,{},NR)).text();for(let[o,s]of dN(i))n.set(o,s)}return n}async function la(t,e,n){if(e.file||!t.guesses)return;for(let r of t.guesses(e))try{let i=await Fr(t,r,n,{Range:`bytes=0-${M0}`}),o=yn(new Uint8Array(await i.arrayBuffer()));return e.file=r,e.ext=Lr(r),o}catch(i){if(n.aborted||i.status!==404)throw i}throw Error(`${t.name} keeps no png or jpg of ${e.id}`)}async function j0(t,e){if(Xn(ce)<=Date.now())try{let i=new URLSearchParams({"search[query]":t,"search[type]":"tag_query",limit:String(p0)}),o=`${ce.origin}/autocomplete.json?${i}`;return VR(await(await Fr(ce,o,e,{},m0)).text())}catch(i){if(e.aborted)throw i}let n=Z.find((i)=>i.key==="yande"),r=new URLSearchParams({name:t,order:"count",limit:String(p0)});return ZR(await(await Fr(n,`${n.origin}/tag.json?${r}`,e,{},m0)).text())}function hN(t){try{return(JSON.parse(t).related_tags??[]).flatMap(({tag:n})=>n?.name?[{value:n.name,count:Number(n.post_count)||0}]:[])}catch{return[]}}async function _0(t,e){if(Xn(ce)>Date.now())return[];let n=new URLSearchParams({"search[query]":t,"search[category]":"character",limit:String(AR)});return hN(await(await Fr(ce,`${ce.origin}/related_tag.json?${n}`,e,{},TR)).text())}function G0(t,e){return e.slice(0,t.ors?t.tagBudget:1)}async function B0(t,e,n){let r=await Fr(t,e,n,{Range:`bytes=0-${M0}`});return yn(new Uint8Array(await r.arrayBuffer()))}async function au(t,e,n,r){let i=await Fr(t,e,n,{},0),o=Number(i.headers.get("content-length"))||0,s=i.body?.getReader();if(!s)return new Uint8Array(await i.arrayBuffer());let a=[],c=0;for(;;){let{done:l,value:d}=await s.read();if(l)break;a.push(d),c+=d.length,r?.(c,o)}let u=new Uint8Array(c),f=0;for(let l of a)u.set(l,f),f+=l.length;return u}var yN=12,vN=/^[0-9a-f]{40}$/;function Bo(){return Uo(jr(),"drawn")}function U0(t){return mN("sha1").update(JSON.stringify(t)).digest("hex")}function W0(t){return pN(Uo(Bo(),t))}function K0(t){let e=Uo(Bo(),t);try{let n=bN(e),r=n.readUInt32BE(0),i=JSON.parse(n.toString("utf8",4,4+r)),o=n.subarray(4+r,4+r+i.figure),s=n.subarray(4+r+i.figure,4+r+i.figure+i.picture);if(o.length!==i.figure||s.length!==i.picture)return;let a=new Date;return kN(e,a,a),{stem:i.stem,fill:i.fill,...i.peak?{peak:i.peak}:{},figure:o,picture:s}}catch{return}}function _d(t,e){let n=Buffer.from(JSON.stringify({stem:e.stem,fill:e.fill,...e.peak?{peak:e.peak}:{},figure:e.figure.length,picture:e.picture.length})),r=Buffer.alloc(4);r.writeUInt32BE(n.length),C(Uo(Bo(),t),Buffer.concat([r,n,e.figure,e.picture])),SN()}function SN(){let t=gN(Bo()).filter((e)=>vN.test(e)).flatMap((e)=>{try{return[{name:e,at:$N(Uo(Bo(),e)).mtimeMs}]}catch{return[]}}).sort((e,n)=>n.at-e.at);for(let{name:e}of t.slice(yN))wN(Uo(Bo(),e),{force:!0})}import{readdirSync as RN,readFileSync as Q0}from"node:fs";import{basename as NN,join as t$}from"node:path";/*!
|
|
4
4
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
6
|
*
|
|
@@ -26,9 +26,9 @@ import{createRequire as $I}from"node:module";var dI=Object.create;var{getPrototy
|
|
|
26
26
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
27
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
28
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
-
*/function
|
|
29
|
+
*/function EN(t,e){let n=t.slice(0,e).split(/\r?\n/);return[n.length,n.pop().length+1]}function MN(t,e,n){let r=t.split(/\r?\n/),i="",o=(Math.log10(e+1)|0)+1;for(let s=e-1;s<=e+1;s++){let a=r[s-1];if(!a)continue;if(i+=s.toString().padEnd(o," "),i+=": ",i+=a,i+=`
|
|
30
30
|
`,s===e)i+=" ".repeat(o+n+2),i+=`^
|
|
31
|
-
`}return i}class D extends Error{line;column;codeblock;constructor(t,e){let[n,r]=
|
|
31
|
+
`}return i}class D extends Error{line;column;codeblock;constructor(t,e){let[n,r]=EN(e.toml,e.ptr),i=MN(e.toml,n,r);super(`Invalid TOML document: ${t}
|
|
32
32
|
|
|
33
33
|
${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(t,{toml:e.s,ptr:n??e.p})}}/*!
|
|
34
34
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -56,7 +56,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
56
56
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
57
57
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
58
58
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
59
|
-
*/function
|
|
59
|
+
*/function cu(t){let e=t.p,n=t.s.charCodeAt(t.p++),r=n,i=n===39,o=n===t.s.charCodeAt(t.p)&&n===t.s.charCodeAt(t.p+1);if(o){if((n=t.s.charCodeAt(t.p+=2))===10)t.p++;else if(n===13&&t.s.charCodeAt(t.p+1)===10)t.p+=2}let s="",a=t.p,c=0;for(;t.p<t.s.length;t.p++)if(n=t.s.charCodeAt(t.p),o&&(n===10||n===13&&t.s.charCodeAt(t.p+1)===10))c=c&&3;else if(n<32&&n!==9||n===127)D.x("control characters are not allowed in strings",t);else if((!c||c===3)&&n===r&&(!o||t.s.charCodeAt(t.p+1)===r&&t.s.charCodeAt(t.p+2)===r)){if(o){if(t.s.charCodeAt(t.p+3)===r)t.p++;if(t.s.charCodeAt(t.p+3)===r)t.p++}if(!c){let u=t.s.slice(a,t.p);s=s?s+u:u}return t.p+=o?3:1,s}else if(!c){if(!i&&n===92)s+=t.s.slice(a,a=t.p),c=1}else if(c===1)if(n===120||n===117||n===85){let u=t.p++-1,f=0,l=n===120?2:n===117?4:8;for(let d=0;d<l;d++,t.p++){let h=t.s.charCodeAt(t.p),m=h>=48&&h<=57?h-48:h>=65&&h<=70?h-65+10:h>=97&&h<=102?h-97+10:-1;if(m<0)D.x("invalid non-hex character in unicode escape",t);f=f<<4|m}if(f<0||f>1114111||f>=55296&&f<=57343)D.x("invalid unicode escape",t,u);s+=String.fromCodePoint(f),a=t.p--,c=0}else if(o&&(n===32||n===9))c=2;else{if(n===98)s+="\b";else if(n===116)s+="\t";else if(n===110)s+=`
|
|
60
60
|
`;else if(n===102)s+="\f";else if(n===114)s+="\r";else if(n===101)s+="\x1B";else if(n===34)s+='"';else if(n===92)s+="\\";else D.x("unrecognised escape sequence",t);a=t.p+1,c=0}else if(n!==32&&n!==9){if(c===2)D.x("invalid escape: only line-ending whitespace may be escaped",t,a);c=!i&&n===92?1:0,a=t.p}D.x("unfinished string",t,e)}/*!
|
|
61
61
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
62
62
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -83,7 +83,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
83
83
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
84
84
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
85
85
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
86
|
-
*/var
|
|
86
|
+
*/var xN=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class _r extends Date{#e=!1;#r=!1;#t=null;constructor(t,e,n){let r=!0,i=!0,o="Z",s;if(typeof t==="string")if(e)t:{if(e<3){if(+t.slice(11,13)>23){t="";break t}if(e===2)o=null,t+="Z";else if((s=t.charCodeAt(t.length-1))!==90&&s!==122)o=t.slice(t.length-6);if(n)t=t.slice(0,10)+"T"+t.slice(11)}else if(e===4)t=+t.slice(0,2)>23?"":`0000-01-01T${t}Z`;r=e!==4,i=e!==3}else{let a=t.match(xN);if(a){if(!a[1])r=!1,t=`0000-01-01T${t}`;if(i=!!a[2],i&&t[10]===" "&&(t=t.replace(" ","T")),a[2]&&+a[2]>23)t="";else if(o=a[3]||null,!o&&i)t+="Z"}else t=""}super(t);if(!isNaN(this.getTime()))this.#e=r,this.#r=i,this.#t=o}isDateTime(){return this.#e&&this.#r}isLocal(){return!this.#e||!this.#r||!this.#t}isDate(){return this.#e&&!this.#r}isTime(){return this.#r&&!this.#e}isValid(){return this.#e||this.#r}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#t===null)return t.slice(0,-1);if(this.#t==="Z"||this.#t==="z")return t;let e=+this.#t.slice(1,3)*60+ +this.#t.slice(4,6);return e=this.#t[0]==="-"?e:-e,new Date(this.getTime()-e*60000).toISOString().slice(0,-1)+this.#t}static wrapAsOffsetDateTime(t,e="Z"){let n=new _r(t);return n.#t=e,n}static wrapAsLocalDateTime(t){let e=new _r(t);return e.#t=null,e}static wrapAsLocalDate(t){let e=new _r(t);return e.#r=!1,e.#t=null,e}static wrapAsLocalTime(t){let e=new _r(t);return e.#e=!1,e.#t=null,e}}/*!
|
|
87
87
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
88
88
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
89
89
|
*
|
|
@@ -109,7 +109,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
109
109
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
110
110
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
111
111
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
112
|
-
*/function Ae(t,e=10){return e===16?t>47&&t<58||t>64&&t<71||t>96&&t<103:t>47&&t<48+e}function
|
|
112
|
+
*/function Ae(t,e=10){return e===16?t>47&&t<58||t>64&&t<71||t>96&&t<103:t>47&&t<48+e}function Bd(t,e){return t===32||t===9||t===10||t===13||e&&(t===e||t===44)||t===35}function da(t,e){let n=t.p,r=t.s.charCodeAt(t.p);if(r===91||r===123){t.d--||D.x("document contains excessively nested structures. aborting.",t);let i=r===91?D0(t):q0(t);return t.d++,i}if(r===34||r===39)return cu(t);if(r===116){if(t.s.charCodeAt(++t.p)!==114||t.s.charCodeAt(++t.p)!==117||t.s.charCodeAt(++t.p)!==101)D.x("invalid value",t,n);return t.p++,!0}if(r===102){if(t.s.charCodeAt(++t.p)!==97||t.s.charCodeAt(++t.p)!==108||t.s.charCodeAt(++t.p)!==115||t.s.charCodeAt(++t.p)!==101)D.x("invalid value",t,n);return t.p++,!1}if(r===43||r===45)return uu(t,t.p,t.s.charCodeAt(++t.p),44-r,e);if(t.s.charCodeAt(t.p+4)===45&&t.s.charCodeAt(t.p+7)===45)return ON(t,r,e);if(t.s.charCodeAt(t.p+2)===58)return IN(t,r,e);return uu(t,t.p,r,0,e)}function uu(t,e,n,r,i){let o=n,s=0,a=!1;if(o===105){if(t.s.charCodeAt(++t.p)!==110||t.s.charCodeAt(++t.p)!==102)D.x("invalid value",t,e);return t.p++,(r||1)/0}if(o===110){if(t.s.charCodeAt(++t.p)!==97||t.s.charCodeAt(++t.p)!==110)D.x("invalid value",t,e);return t.p++,NaN}if(o===48){if(++t.p>=t.s.length||Bd(o=t.s.charCodeAt(t.p),i))return t.bi===!0?0n:0;if(!r){if(o===120)return Gd(t,e,16,i);else if(o===98)return Gd(t,e,2,i);else if(o===111)return Gd(t,e,8,i)}if(o===46)s=2;else if(o===101||o===69)s=4;else D.x("illegal leading zero",t,e)}else if(!Ae(o))D.x("invalid value",t,e);while(++t.p<t.s.length&&(o=t.s.charCodeAt(t.p),!Bd(o,i))){if(!s)s=1;if(o===95){if(!(s&1))D.x("illegal underscore",t);s+=11,a=!0}else if(s===1&&o===46)s=2;else if((s===1||s===3)&&(o===101||o===69))s=4;else if(s===4&&(o===43||o===45));else if(!Ae(o))D.x("illegal character in numeric literal",t);else if(s>9)s-=11;else if(!(s&1))s++}if(!s){let u=(n-48)*(r||1);return t.bi===!0?BigInt(u):u}if(!(s&1))D.x("unfinished numeric value",t,e);let c=t.s.slice(e,t.p);if(a)c=c.replaceAll("_","");return s>1?parseFloat(c):z0(t,c,10,e)}function Gd(t,e,n,r){let i,o=1;while(++t.p<t.s.length&&(i=t.s.charCodeAt(t.p),!Bd(i,r)))if(i===95){if(o&1)D.x("illegal underscore",t);o=3}else if(!Ae(i,n))D.x("illegal character in numeric literal",t);else if(o&1)o--;if(o&1)D.x("unfinished numeric value",t);let s=t.s.slice(e+2,t.p);if(o)s=s.replaceAll("_","");return z0(t,s,n,e)}function z0(t,e,n,r){if(t.bi!==!0)t:{let i=parseInt(e,n);if(!Number.isSafeInteger(i)){if(t.bi)break t;D.x("integer value cannot be represented losslessly",t,r)}return i}return n===10?BigInt(e):BigInt((n===2?"0b":n===8?"0o":"0x")+e)}function ON(t,e,n){let r=t.p++,i;if(!Ae(e)||!Ae(t.s.charCodeAt(t.p++))||!Ae(t.s.charCodeAt(t.p++))||!Ae(t.s.charCodeAt(t.p++)))return uu(t,t.p=r,e,0,n);if(t.p+=5,!Ae(t.s.charCodeAt(t.p++)))D.x("invalid date-time: date part is malformed",t,r);if(t.p>=t.s.length||((e=t.s.charCodeAt(t.p))!==32||(i=!0,!Ae(t.s.charCodeAt(t.p+1))))&&e!==84&&e!==116){let s=t.s.slice(r,t.p);return fa(t,s,3,!1,r)}if(t.s.charCodeAt(t.p+=3)!==58)D.x("invalid date-time: time part is malformed",t,r);if(t.s.charCodeAt(t.p+=3)===58)t.p+=3;if(t.s.charCodeAt(t.p)===46)while(Ae(t.s.charCodeAt(++t.p)));if(e=t.s.charCodeAt(t.p)){if(e===90||e===122){let s=t.s.slice(r,++t.p);return fa(t,s,1,i,r,"[+00:00]")}if(e===43||e===45){let s=t.s.slice(r,t.p+=6);return fa(t,s,1,i,r,!t.ld&&"["+t.s.slice(t.p-6,t.p)+"]")}}let o=t.s.slice(r,t.p);return fa(t,o,2,i,r)}function IN(t,e,n){let r=t.p;if(!Ae(e)||!Ae(t.s.charCodeAt(++t.p)))return uu(t,--t.p,e,0,n);if(t.s.charCodeAt(t.p+=4)===58)t.p+=3;if(t.s.charCodeAt(t.p)===46)while(Ae(t.s.charCodeAt(++t.p)));let i=t.s.slice(r,t.p);return fa(t,i,4,!1,r)}function fa(t,e,n,r,i,o){if(t.ld){let s=new _r(e,n,r);if(!s.isValid())D.x("invalid date",t,i);return s}try{if(o)e+=o;switch(n){case 1:return Temporal.ZonedDateTime.from(e);case 2:return Temporal.PlainDateTime.from(e);case 3:return Temporal.PlainDate.from(e);case 4:return Temporal.PlainTime.from(e)}}catch(s){D.x(s instanceof Error?s.message:""+s,t,i)}}/*!
|
|
113
113
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
114
114
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
115
115
|
*
|
|
@@ -135,7 +135,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
135
135
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
136
136
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
137
137
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
138
|
-
*/function
|
|
138
|
+
*/function PN(t){for(;t.p<t.s.length;t.p++){let e=t.s.charCodeAt(t.p);if(e===10)break;if(e===13&&t.s.charCodeAt(t.p+1)===10){t.p++;break}if(e<32&&e!==9||e===127)D.x("control characters are not allowed in comments",t)}}function sn(t,e,n){let r;while(t.p<t.s.length){while(t.p<t.s.length&&((r=t.s.charCodeAt(t.p))===32||r===9||!e&&(r===10||r===13&&t.s.charCodeAt(t.p+1)===10)))t.p++;if(n||r!==35)break;PN(t)}}/*!
|
|
139
139
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
140
140
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
141
141
|
*
|
|
@@ -161,7 +161,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
161
161
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
162
162
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
163
163
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
164
|
-
*/function
|
|
164
|
+
*/function lu(t,e=61){let n,r=0,i=[],o,s=t.s.charCodeAt(n=t.p);do if(s===e){if(!r)D.x("unexpected end of key",t);if(r===1)i.push(t.s.slice(o,t.p));return t.p++,i}else if(s===46){if(!r)D.x("illegal empty bare key",t);if(r===1)i.push(t.s.slice(o,t.p));r=0}else if(!r&&(s===34||s===39)){if(s===t.s.charCodeAt(t.p+1)&&s===t.s.charCodeAt(t.p+2))D.x("illegal quoted key: multiline strings are not allowed",t);i.push(cu(t)),r=2,t.p--}else if(s===32||s===9){if(r===1)i.push(t.s.slice(o,t.p)),r=2}else if(r===2||s<48&&s!==45||s>57&&s<65||s>90&&s<97&&s!==95||s>122)D.x("illegal character in key",t);else if(!r)r=1,o=t.p;while(s=t.s.charCodeAt(++t.p));D.x("incomplete key-value: cannot find end of key",t,n)}function q0(t){let e=t.p++,n=Object.create(null),r=new Set,i;while(t.p<t.s.length){if(sn(t),(i=t.s.charCodeAt(t.p))===125)return t.p++,n;let o,s=n,a=!1,c=t.p,u=lu(t);for(let l=0;l<u.length;l++){if(l)s=a?s[o]:s[o]=Object.create(null);if(o=u[l],(a=Object.hasOwn(s,o))&&(typeof s[o]!=="object"||r.has(s[o])))D.x("trying to redefine an already defined value",t,c);let d=o==="__proto__";if(t.uk&&(d||o==="constructor")){s=t.uk!==1&&D.x("document contains an unsafe property",t,c);break}if(!a&&d)Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(a)D.x("trying to redefine an already defined value",t,c);sn(t,!0,!0);let f=da(t,125);if(s&&typeof(s[o]=f)==="object")r.add(f);if(sn(t),(i=t.s.charCodeAt(t.p++))===125)return n;if(i!==44)D.x("expected comma or end of structure",t,t.p-1)}D.x("unfinished table",t,e)}function D0(t){let e=t.p++,n=[],r;while(t.p<t.s.length){if(sn(t),(r=t.s.charCodeAt(t.p))===93)return t.p++,n;if(n.push(da(t,93)),sn(t),(r=t.s.charCodeAt(t.p++))===93)return n;if(r!==44)D.x("expected comma or end of structure",t,t.p-1)}D.x("unfinished array",t,e)}/*!
|
|
165
165
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
166
166
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
167
167
|
*
|
|
@@ -187,7 +187,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
187
187
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
188
188
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
189
189
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
190
|
-
*/function
|
|
190
|
+
*/function J0(t,e,n,r,i){let o=n,s=r,a,c=!1,u;for(let f=0;f<e.length;f++){if(f){if(o=c?o[a]:o[a]=Object.create(null),s=(u=s[a]).c,i===0&&(u.t===1||u.t===2))return null;if(u.t===2){let l=o.length-1;o=o[l],s=s[l].c}}if(a=e[f],(c=Object.hasOwn(o,a))&&s[a]?.t===0&&s[a]?.d)return null;if(!c){let l=a==="__proto__";if(t.uk&&(l||a==="constructor"))return!1;if(l)Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(s,a,{enumerable:!0,configurable:!0,writable:!0});s[a]={t:f<e.length-1&&i===2?3:i,d:!1,i:0,c:Object.create(null)}}}if(u=s[a],u.t!==i&&!(i===1&&u.t===3))return null;if(i===2){if(!u.d)u.d=!0,o[a]=[];o[a].push(o=Object.create(null)),u.c[u.i++]=u={t:1,d:!1,i:0,c:Object.create(null)}}if(u.d)return null;if(u.d=!0,i===1)o=c?o[a]:o[a]=Object.create(null);else if(i===0&&c)return null;return[a,o,u.c]}function Y0(t,e,n){if(e===null||t.uk===2)D.x(e===null?"trying to redefine an already defined table or value":"document contains an unsafe property",t,n)}function Hi(t,e={}){let n={s:t,p:0,d:e.maxDepth??1000,bi:e.integersAsBigInt??!1,ld:e.useLegacyDate??!0,uk:e.unsafeKeyBehaviour==="throw"?2:e.unsafeKeyBehaviour==="drop"?1:0},r=Object.create(null),i=Object.create(null),o,s=!1,a=r,c=i;if(t.charCodeAt(0)===65279)n.p++;sn(n);while(n.p<t.length){if(t.charCodeAt(n.p)===91){let u=t.charCodeAt(++n.p)===91;o=n.p+=+u,s=!1;let f=lu(n,93);if(u){if(t.charCodeAt(n.p)!==93)D.x("expected end of table array declaration",n);n.p++}let l=J0(n,f,r,i,u?2:1);if(!l)Y0(n,l,o),s=!0;else c=l[2],a=l[1]}else{o=n.p;let u=lu(n),f=J0(n,u,a,c,0);if(!f&&!s)Y0(n,f,o);sn(n,!0,!0);let l=da(n,void 0);if(f&&!s)f[1][f[0]]=l}if(sn(n,!0),n.p<t.length&&(o=t.charCodeAt(n.p))!==10&&(o!==13||t.charCodeAt(n.p+1)!==10))D.x("each key-value declaration must be followed by an end-of-line",n);sn(n)}return r}/*!
|
|
191
191
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
192
192
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
193
193
|
*
|
|
@@ -213,7 +213,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
213
213
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
214
214
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
215
215
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
216
|
-
*/var
|
|
216
|
+
*/var yG=!!"".isWellFormed;/*!
|
|
217
217
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
218
218
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
219
219
|
*
|
|
@@ -239,175 +239,177 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new D(
|
|
|
239
239
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
240
240
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
241
241
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
242
|
-
*/var qt=["top-left","top-center","top-right","center-left","center","center-right","bottom-left","bottom-center","bottom-right"],
|
|
243
|
-
`)[0]}`)}}function NA(t){let n=jd(Sn,D0(J0(t,Sn),"utf8")).group;if(!Array.isArray(n)||n.length===0)it(Sn,"needs at least one [[group]] table");return n.map((r)=>{let i=Uo(r);return{name:fa(Sn,"group.name",i.name),native:i.native===void 0?void 0:fa(Sn,"group.native",i.native),lead:da(Sn,"group.lead",i.lead)}})}function TA(t,e){if(!Array.isArray(e)||e.length===0)it(t,'meta.native_names must be a list of names, like ["後藤ひとり"]');return e.map((n,r)=>{let i=fa(t,`meta.native_names[${r}]`,n);if(i.includes("|"))it(t,`meta.native_names[${r}] ${JSON.stringify(i)} contains |`);return i})}var Cd={"":["$schema","meta","colors","contrast","ghostty","picture"],meta:["name","base","group","ansi_source","booru","booru_sites","native_names","signature","order","role"],colors:["background","foreground","cursor","selection_background","ansi"],contrast:["waive","reason"],ghostty:["icon_ghost","icon_screen"],picture:["site","id","size","position","opacity"]};function Z0(t,e){let n=jd(t,e),r=(i,o,s=[])=>o&&typeof o==="object"&&!Array.isArray(o)?Object.keys(o).filter((a)=>!s.includes(a)).map((a)=>i?`${i}.${a}`:a):[];return[...r("",n,Cd[""]),...["meta","colors","contrast","ghostty"].flatMap((i)=>r(i,n[i],Cd[i])),...(Array.isArray(n.picture)?n.picture:[]).flatMap((i,o)=>r(`picture[${o}]`,i,Cd.picture))]}function _d(t,e,n){let r=jd(t,e),i=Uo(r.meta),o=Uo(r.colors),s=Uo(r.contrast),a=o.ansi;if(!Array.isArray(a)||a.length!==16)it(t,`colors.ansi must hold exactly 16 colors, got ${Array.isArray(a)?a.length:typeof a}`);let c=q0(t,"meta.name",i.name);if(c!==n.name)it(t,`meta.name "${c}" does not match its file — it lives at ${n.name}`);let u=n.open===!0;for(let j of["order","role"])if(u&&i[j]!==void 0)it(t,`meta.${j} is for the official palettes — a market palette follows its base`);let f=i.role;if(f!==void 0&&f!=="default")it(t,`meta.role must be "default", got ${JSON.stringify(f)}`);let l=i.base===void 0?void 0:q0(t,"meta.base",i.base);if(l!==void 0&&!u)it(t,"meta.base is for market palettes");let d=l===void 0?void 0:n.bases?.get(l),h=u&&i.group===void 0?d?.group??la:fa(t,"meta.group",i.group),m=n.groups.get(h);if(!m&&!(u&&(h===la||n.open)))it(t,`meta.group "${h}" has no [[group]] table in ${Sn}`);let p=Hi(t,"colors.background",o.background),b=Hi(t,"colors.foreground",o.foreground),$=Hi(t,"colors.cursor",o.cursor),k=Hi(t,"colors.selection_background",o.selection_background),v=a.map((j,z)=>Hi(t,`colors.ansi[${z}]`,j)),E=RA(t,i.signature,{background:p,foreground:b,cursor:$,selection:k,ansi:v}),x=i.booru===void 0?void 0:da(t,"meta.booru",i.booru);if(x!==void 0&&/[\s\p{Cc}]/u.test(x))it(t,`meta.booru must be a single booru tag, got ${JSON.stringify(x)}`);let M=PA(t,i.booru_sites,x,n.foreign===!0),R=i.native_names===void 0?void 0:TA(t,i.native_names),F=Array.isArray(s.waive)?s.waive.map(String):[];if(F.length>0&&typeof s.reason!=="string")it(t,"contrast.waive needs a contrast.reason explaining why");let N=AA(t,r.picture,n.foreign===!0);return{name:c,...l?{base:l}:{},group:h,native:m?.native,...R?{nativeNames:R}:{},lead:!u&&m?.lead===c,order:u?d?.order??SA:Number(i.order),role:f,ansiSource:u&&i.ansi_source===void 0?l??"original":fa(t,"meta.ansi_source",i.ansi_source),...x?{booru:x}:{},...M?{booruSites:M}:{},background:p,foreground:b,cursor:$,selectionBackground:k,ansi:v,signature:E.colors,signatureSlots:E.names,ghostty:OA(t,r.ghostty,{background:p,cursor:$,selectionBackground:k}),waive:F,waiveReason:typeof s.reason==="string"?s.reason:void 0,...N?{pictures:N}:{}}}function V0(t){let e=NA(t),n=new Map(e.map((o)=>[o.name,o]));if(n.size!==e.length)it(Sn,"group.name must be unique");let r=vA(t).filter((o)=>o.endsWith(".toml")&&!o.startsWith("_")).map((o)=>_d(o,D0(J0(t,o),"utf8"),{name:EA(o,".toml"),groups:n})).sort((o,s)=>o.order-s.order);if(new Set(r.map((o)=>o.order)).size!==r.length)throw Error("themes: meta.order must be unique across all themes");for(let o of e){let s=r.filter((a)=>a.group===o.name);if(s.length===0)it(Sn,`group "${o.name}" has no themes`);if(!s.some((a)=>a.name===o.lead))it(Sn,`group "${o.name}" lead "${o.lead}" is not one of its themes`)}return r}function X0(t){return t.filter((e)=>e.role===void 0)}function Fi(t){let e=(r,i)=>r<i?-1:r>i?1:0,n=(r)=>ut(r.name)?r.name:r.base??r.name;return[...t].sort((r,i)=>Number(ut(r.name)!==void 0)-Number(ut(i.name)!==void 0)||e(r.group.toLowerCase(),i.group.toLowerCase())||Number(r.catalog===void 0)-Number(i.catalog===void 0)||e((r.catalog??"").toLowerCase(),(i.catalog??"").toLowerCase())||e(n(r),n(i))||Number(r.base!==void 0)-Number(i.base!==void 0)||e(r.name,i.name))}var ma={width:2560,height:1550},_A=1,GA=2560,BA=0.1,u$=0.99,UA=2,Li={tall:1.15,reach:0.4,widest:0.95,headroom:0.04,margin:0.03,stands:12},WA=Et(At("#19161e","#9b86c8",0.2)),KA="shelf",au="originals",zA="images.json",Bd=1;function qA(t,e){if(e==="background"||e==="foreground"||e==="cursor")return t[e];if(e==="selection"&&t.selection)return t.selection;let n=/^ansi(\d|1[0-5])$/.exec(e),r=n?t.ansi[Number(n[1])]:void 0;if(!r)throw Error(`${t.name} has no slot ${e}`);return r}function Q0(t){if(t(1))return 1;let e=0,n=1;for(let r=0;r<40;r++){let i=(e+n)/2;if(t(i))e=i;else n=i}return e}function l$(t,e){let n=(s)=>Kb({name:t.name,background:At(t.background,e,s),foreground:t.foreground,ansi:t.ansi,waive:t.waived??[]}).map((a)=>a.rule),r=new Set(n(0)),i=Q0((s)=>n(s).every((a)=>r.has(a))),o=Q0((s)=>Et(At(t.background,e,s))<=WA);return{cap:i,matched:o,opacity:Math.floor(Math.min(i,o)*100)/100}}function t$(t,e){let n=qA(t,e),{cap:r,matched:i,opacity:o}=l$(t,n),s=st(t.background),a=Math.hypot(...st(n).map((c,u)=>(c-(s[u]??0))*o));return{slot:e,color:n,cap:r,matched:i,opacity:o,reach:a}}function f$(t,e){return l$(t,e).opacity}function Mn(t,e){let n=t$(t,"cursor");if(n.opacity>=BA)return n;return e.filter((r)=>r!=="cursor"&&r!=="background").map((r)=>t$(t,r)).reduce((r,i)=>i.reach>r.reach?i:r,n)}function DA(t){return Xw(t)??{x:0,y:0,w:t.width,h:t.height}}function Dd(t,e){if(t<=0||e<=0)return ma;let n=Math.min(1,ma.width/Math.max(t,e));return{width:Math.round(t*n),height:Math.round(e*n)}}function d$(t,e,n,r){if(r<Li.stands){let c=t.w*n>t.h*e?{x:t.x+(t.w-t.h*e/n)/2,y:t.y,w:t.h*e/n,h:t.h}:{x:t.x,y:t.y,w:t.w,h:t.w*n/e};return{crop:c,at:{x:0,y:0,w:e,h:n},focus:(c.y-t.y+c.h/2)/t.h}}let i=Math.max(Li.tall*n,Li.reach*e*t.h/t.w),o=i*t.w/t.h;if(o>Li.widest*e)o=Li.widest*e,i=o*t.h/t.w;let s=Li.headroom*n,a=Math.min(1,(n-s)/i);return{crop:{x:t.x,y:t.y,w:t.w,h:t.h*a},at:{x:e*(1-Li.margin)-o,y:s,w:o,h:i*a},focus:Math.min(1,(n/2-s)/i)}}function JA(t,e){return 0.299*(t[e]??0)+0.587*(t[e+1]??0)+0.114*(t[e+2]??0)}function YA(t,e){let n=new Uint32Array(256),r=Math.max(1,Math.floor(e.w*e.h/400000)),i=0;for(let s=0;s<e.w*e.h;s+=r){let a=((e.y+Math.floor(s/e.w))*t.width+e.x+s%e.w)*4;if((t.data[a+3]??0)>=128){let c=Math.round(JA(t.data,a));n[c]=(n[c]??0)+1,i++}}let o=0;for(let s=0;s<256&&i>0;s++)if(o+=n[s]??0,o>=i*u$)return Math.min(UA,Math.max(1,255/Math.max(1,s)));return 1}var Gd=Float64Array.from({length:256},(t,e)=>{let n=e/255;return n<=0.04045?n/12.92:((n+0.055)/1.055)**2.4});function ZA(t,e,n){return`#${[t,e,n].map((r)=>Math.round(r).toString(16).padStart(2,"0")).join("")}`}function VA(t,e){let n=new Uint32Array(256),r=new Float64Array(768),i=Math.max(1,Math.floor(e.w*e.h/400000)),o=0;for(let a=0;a<e.w*e.h;a+=i){let c=((e.y+Math.floor(a/e.w))*t.width+e.x+a%e.w)*4;if((t.data[c+3]??0)>=128){let u=t.data[c]??0,f=t.data[c+1]??0,l=t.data[c+2]??0,d=Math.round(255*Math.sqrt(0.2126*(Gd[u]??0)+0.7152*(Gd[f]??0)+0.0722*(Gd[l]??0)));n[d]=(n[d]??0)+1,r[d*3]=(r[d*3]??0)+u,r[d*3+1]=(r[d*3+1]??0)+f,r[d*3+2]=(r[d*3+2]??0)+l,o++}}let s=0;for(let a=0;a<256&&o>0;a++)if(s+=n[a]??0,s>=o*u$){let c=Math.max(1,n[a]??1);return ZA((r[a*3]??0)/c,(r[a*3+1]??0)/c,(r[a*3+2]??0)/c)}return"#ffffff"}function XA(t,e){let n=t.data,r=new Uint8Array(t.width*t.height);for(let i=0,o=0;i<r.length;i++,o+=4){let s=n[o+3];if(s===0)continue;let a=(0.299*n[o]+0.587*n[o+1]+0.114*n[o+2])*e;r[i]=(a>255?255:a)*s/255+0.5}return{width:t.width,height:t.height,data:r}}function h$(t,e,n){let r=Math.max(0,Math.round(t.at.x)),i=Math.max(0,Math.round(t.at.y)),o=Math.min(e,Math.round(t.at.x+t.at.w)),s=Math.min(n,Math.round(t.at.y+t.at.h));if(o<=r||s<=i)return;let a=t.crop.w/t.at.w,c=t.crop.h/t.at.h;return{x0:r,y0:i,x1:o,y1:s,box:{x:t.crop.x+(r-t.at.x)*a,y:t.crop.y+(i-t.at.y)*c,w:(o-r)*a,h:(s-i)*c}}}function su(t,e,n,r){let i=new Float32Array(n*r),o=h$(e,n,r);if(o){let s=n0(t,o.box,o.x1-o.x0,o.y1-o.y0);for(let a=o.y0;a<o.y1;a++)i.set(s.data.subarray((a-o.y0)*(o.x1-o.x0),(a-o.y0+1)*(o.x1-o.x0)),a*n+o.x0)}return{width:n,height:r,data:i}}function Jd(t,e,n,r){let i=new Uint8Array(n*r*4),o=h$(e,n,r);if(o){let s=o.x1-o.x0,a=Vs(t,o.box,s,o.y1-o.y0);for(let c=o.y0;c<o.y1;c++)i.set(a.data.subarray((c-o.y0)*s*4,(c-o.y0+1)*s*4),(c*n+o.x0)*4)}return{width:n,height:r,data:i}}function Ud(t,e){if(e<=0)return t;let{width:n,height:r}=t,i=[0,1,2,3].map(()=>({width:n,height:r,data:new Float32Array(n*r)}));for(let a=0;a<n*r;a++){let c=t.data[a*4+3]??0;for(let u=0;u<3;u++)i[u].data[a]=(t.data[a*4+u]??0)*c/255;i[3].data[a]=c}let o=i.map((a)=>Xs(a,e).data),s=new Uint8Array(n*r*4);for(let a=0;a<n*r;a++){let c=o[3]?.[a]??0;if(c<=0)continue;for(let u=0;u<3;u++)s[a*4+u]=Math.min(255,Math.max(0,Math.round((o[u]?.[a]??0)*255/c)));s[a*4+3]=Math.min(255,Math.round(c))}return{width:n,height:r,data:s}}function Yd(t){let e=DA(t),n,r;return{box:e,clear:Yn(t,e),get ink(){return n??=XA(t,YA(t,e)),n},image:t,get peak(){return r??=VA(t,e),r}}}function m$(t,e,n,r,i){let o=Yd(t),{box:s,clear:a,ink:c}=o,u=d$(s,e,n,a),f=Math.min(1,GA/Math.max(s.w,s.h)),l={x:0,y:0,w:Math.round(s.w*f),h:Math.round(s.h*f)},d=r*l.w*u.crop.w/(s.w*u.at.w);if(i==="original")return{coloring:i,figure:Ud(Vs(t,s,l.w,l.h),d),fill:Ud(Jd(t,u,e,n),r),focus:u.focus,peak:o.peak};let h=su(c,{crop:s,at:l,focus:u.focus},l.w,l.h),m=su(c,u,e,n);return{coloring:i,figure:Qs(Xs(h,d)),fill:Qs(Xs(m,r)),focus:u.focus}}function QA(t,e,n,r){let i=st(e),o=st(n),s=new Uint8Array(t.width*t.height*4);for(let a=0;a<t.data.length;a++){let c=(t.data[a]??0)/255*r;for(let u=0;u<3;u++)s[a*4+u]=Math.round((i[u]??0)+((o[u]??0)-(i[u]??0))*c);s[a*4+3]=255}return{width:t.width,height:t.height,data:s}}function tN(t,e,n){let r=st(e),i=new Uint8Array(t.width*t.height*4);for(let o=0;o<t.width*t.height;o++){let s=(t.data[o*4+3]??0)/255*n;for(let a=0;a<3;a++)i[o*4+a]=Math.round((r[a]??0)+((t.data[o*4+a]??0)-(r[a]??0))*s);i[o*4+3]=255}return{width:t.width,height:t.height,data:i}}function p$(t,e,n,r,i,o,s,a="tone"){let{box:c,clear:u,ink:f}=t,l=d$(c,r,i,u),d=Math.round(100*l.at.w/l.crop.w/Math.min(r/c.w,i/c.h)),h=s?.size??"fill",m=h==="fill"?l:{crop:c,at:Jo(c.w,c.h,r,i,h,s?.at??5,!1,h>100?Math.round(l.focus*100):-1),focus:l.focus},p=a==="original"?f$(e,t.peak):n.opacity,b=s?.opacity??p;return{image:a==="original"?tN(Ud(Jd(t.image,m,r,i),o),e.background,b):QA(Qs(Xs(su(f,m,r,i),o)),e.background,n.color,b),fill:d,opacity:p}}function X(t){return Y(t,"ttheme","backgrounds")}function Wd(t){return Y(t,zA)}function Ci(t){try{return Ko(t,"utf8")}catch{return}}function Gr(t){try{return LA(t)}catch{return[]}}function Nt(t){let e=Ci(Wd(t));if(e===void 0)return eN(t);let n=JSON.parse(e);if(n.version!==Bd)throw Error(`${Wd(t)} is version ${n.version} — this ttheme reads version ${Bd}`);return n}function Ke(t){return t.coloring??"tone"}function Zd(t){return{name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,...t.selection?{selection:t.selection}:{},ansi:t.ansi,...t.waived?{waived:t.waived}:{}}}function zo(t){return{hue:{color:t.backdrop.color,opacity:t.backdrop.opacity},colors:Zd(t)}}function qo(t){return t.tone===void 0&&Ke(t)==="tone"}function e$(t){return(t.artist??[]).map((e)=>e.replace(/[\s,]+/g,"_")).join(",")}function g$(t,e){let n=e.pictures.findIndex((i)=>i.key===e.active),r=e.pictures[n];return[...r.artist?.length?[`# by ${e$(r)}`]:[],...r.from?[`# from ${r.from}`]:[],`# image ${r.key} ${n+1}/${e.pictures.length}`,...e.pictures.map((i)=>[`# picture ${i.key} ${i.stem} ${i.fill} ${i.opacity} ${i.artist?.length?e$(i):"-"}`,...i.from?[i.from]:[]].join(" ")),...e.pictures.filter((i)=>Ke(i)==="original").map((i)=>`# colors ${i.key} original`),`background-image = ${Y(t,r.fill)}`,"background-image-fit = cover","background-image-position = top-right",`background-image-opacity = ${r.opacity}`,`config-file = ?${r.stem}.tune.conf`,`config-file = ?${r.stem}.off.conf`,""].join(`
|
|
244
|
-
`)}function
|
|
245
|
-
`);for(let r of n){let i=e.palettes[r],o=Y(t,`${ue(r)}.conf`);if(i)
|
|
246
|
-
`)){let l=/^([a-z-]+)\s*=\s*(.*?)\s*$/.exec(f);if(l?.[1]==="config-file"&&c<4)i(
|
|
247
|
-
`)),h}function E$(t){let e=new Map;for(let[n,r]of Object.entries(Nt(X(t)).palettes)){let[,i,o]=/^([a-z.]+)_(\d+)$/.exec(r.active)??[];if(i&&o)e.set(n,{site:i,id:Number(o)})}return e}function S$(t){try{let e=vn(new Uint8Array(Ko(t)));return e?{width:e.width,height:e.height}:void 0}catch{return}}function M$(t,e,n,r,i,o,s){let a=[n.original,n.cut].map((c)=>{if(!c)return"";try{let{size:u,mtimeMs:f}=CA(Y(t,c));return`${c}:${u}:${f}`}catch{return}});if(!n.original||a.includes(void 0))return;return L0([_A,ue(e),n.key,...a,r.width,r.height,i,o,o==="tone"?s:""])}function nN(t,e,n){if(!n.window||n.blur===void 0)return;let r=M$(t,e,n,n.window,n.blur,Ke(n),n.tone??"");if(!r||C0(r))return;try{Td(r,{stem:n.stem,fill:n.fill,...n.peak?{peak:n.peak}:{},figure:Ko(Y(t,`${n.stem}.png`)),picture:Ko(Y(t,n.fill))})}catch{}}function x$(t,e,n,r,i,o,s,a,c){let u=c?void 0:M$(t,e,n,r,s,a,o.hue.color),f=u?j0(u):void 0;if(f)return{made:{stem:f.stem,fill:f.fill,files:[[`${f.stem}.png`,f.figure],[f.fill,f.picture]]},peak:f.peak,image:void 0};let l=i();if(!l)return null;let d=m$(l,r.width,r.height,s,a),h=y$(e,n.key,d,o.hue.color),m=d.coloring==="original"?d.peak:void 0;if(u)Td(u,{stem:h.stem,fill:h.fill,...m?{peak:m}:{},figure:h.files[0]?.[1],picture:h.files[1]?.[1]});return{made:h,peak:m,image:l}}function ga(t,e,n,r,i,o,s,a,c,u=Ke(n)){let f=X(t),l=n.window??S$(Y(f,n.fill))??ma,d=x$(f,e,n,l,r,i,o,u,c);if(!d)return null;let{made:h,peak:m,image:p}=d,b={...n,stem:h.stem,fill:h.fill,...v$(i.colors,i.hue,u,m),blur:o,window:l,...c?{cut:`${Kd(e,n.key)}.cut.png`}:{}};if(u==="original")delete b.tone;else delete b.peak;if(c&&p)L(Y(f,`${Kd(e,n.key)}.cut.png`),vd(Ii(p)));if(h.stem===n.stem)return b;if(Ke(n)!==u)nN(f,e,n);Xd(f,h.files);let $=Qd(f,n);pa(f,b,Ke(n)===u?$:{...$,opacity:void 0},s,a);let k=Y(f,`${n.stem}.off.conf`);if(qd(k))HA(k,Y(f,`${b.stem}.off.conf`));return b}function O$(t,e,n,r,i,o,s){let a=X(t),c=n.window??S$(Y(a,n.fill))??ma;return x$(a,e,n,c,r,i,o,s,!1)!==null}function th(t,e){let n=X(t),r=Nt(n),i=new Set,o=[];for(let{name:s,picture:a}of e){let c=r.palettes[s],u=c?.pictures.findIndex((l)=>l.key===a.key)??-1,f=c?.pictures[u];if(!c||!f)continue;if(c.pictures[u]=a,i.add(s),f.stem!==a.stem)o.push(f.stem)}if(i.size===0)return;ji(n,r,[...i]);for(let s of o)Vd(n,s)}function rN(t,e,n,r){let i=$$(t,n.stem).filter((a)=>a.endsWith(".png")).map((a)=>{let c=new Uint8Array(Ko(Y(t,a)));return[a,Kc(c,r.color)??Ri(Ii(Gt(c)),r.color)]}),o=(a)=>i.find(([c])=>c===a)?.[1]??new Uint8Array,s=`${ue(e)}.${s$("sha1").update(n.key).update(o(`${n.stem}.png`)).update(o(n.fill)).digest("hex").slice(0,8)}`;Xd(t,i.map(([a,c])=>[s+a.slice(n.stem.length),c]));for(let a of["tune","off"]){let c=Ci(Y(t,`${n.stem}.${a}.conf`));if(c!==void 0)L(Y(t,`${s}.${a}.conf`),c.split(n.stem).join(s))}return{...n,stem:s,fill:s+n.fill.slice(n.stem.length),tone:r.color}}function o$(t,e){return Ke(t)!=="original"&&t.tone!==void 0&&t.tone!==e.hue.color}function I$(t,e){let n=X(t),r=Nt(n),i=[],o=[];for(let[s,a]of Object.entries(r.palettes)){let c=e.get(s);if(!c||!a.pictures.some((u)=>o$(u,c)))continue;a.pictures=a.pictures.map((u)=>{if(!o$(u,c))return u;let f=rN(n,s,u,c.hue);if(f.stem!==u.stem)o.push(u.stem);return f}),i.push(s)}if(i.length>0){ji(n,r,i);for(let s of o)Vd(n,s)}return i}var iN=1;function sn(t){let{slot:e,color:n,opacity:r}=Mn({name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,ansi:t.ansi,waived:t.waive},t.signatureSlots);return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},...t.lead?{lead:!0}:{},order:t.order,ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},...t.role==="default"?{default:!0}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,signature:t.signature,signatureSlots:t.signatureSlots,ansi:t.ansi,gate:$n(t),...t.waive.length>0?{waived:t.waive}:{},backdrop:{slot:e,color:n,opacity:r},...t.pictures?{pictures:t.pictures}:{}}}function He(t){return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},lead:t.lead===!0,order:t.order,...t.default?{role:"default"}:{},ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selectionBackground:t.selection,ansi:t.ansi,signature:t.signature,signatureSlots:t.signatureSlots,ghostty:{iconGhost:t.cursor,iconScreen:[t.cursor,t.selection,t.background]},waive:t.waived??[],...t.pictures?{pictures:t.pictures}:{}}}var oN=6,sN=["ansi1","ansi2","ansi4","ansi3","ansi5","ansi6"];function lu(t){let e=(o)=>o.startsWith("ansi")?t.ansi[Number(o.slice(4))]:o==="foreground"?t.foreground:o==="cursor"?t.cursor:o==="selection"?t.selection:void 0,n=(o)=>o.startsWith("ansi")?`ansi${Number(o.slice(4))%8}`:o,r=new Set,i=[];for(let o of["foreground",...t.signatureSlots,...sN]){let s=e(o);if(i.length===oN||!s||r.has(n(o))||i.includes(s))continue;r.add(n(o)),i.push(s)}return i}function Tt(t){return t.filter((e)=>e.default!==!0)}function fu(){return{schema:iN,version:ft.version,gate:Ie,palettes:[]}}import{existsSync as aN,readFileSync as hu,statSync as R$}from"node:fs";import{homedir as Xo}from"node:os";import{join as Zo}from"node:path";var cN=["core","kowiki","unlicensed"],uN=["ko","ja","en","zh","other"],N$=["keys","keyAt","ownAt","owners","cards","cardAt","ranks","tags","tagAt","tagCard"],T$="TTNI";function Br(t=Xo()){return Zo(process.env.XDG_CACHE_HOME??Zo(t,".cache"),"ttheme","aninames")}var lN=/[ァ-ヶ]/g,fN=/[\s\p{P}\p{S}]+/gu;function Vo(t){return t.normalize("NFKC").toLowerCase().replace(lN,(e)=>String.fromCharCode(e.charCodeAt(0)-96)).replace(fN,"")}function _i(t,e){let n=Vo(e);if(n===""){let r=e.toLowerCase();return t.some((i)=>i.toLowerCase().includes(r))}return t.some((r)=>Vo(r).includes(n))}function ih(t){return t.length>=2||/[\p{Script=Han}\p{Script=Hangul}\p{Script=Hiragana}]/u.test(t)}function H$(t){let e=Br(t);return cN.map((n)=>Zo(e,`ttheme-${n}.json`)).filter((n)=>aN(n))}var dN=6;function F$(t){return[`format ${dN}`,...t.map((e)=>`${e}:${R$(e).size}:${R$(e).mtimeMs}`)].join("|")}function hN(t){try{return JSON.parse(hu(t,"utf8"))}catch{return{}}}function mN(t){let e=new Map;for(let i of t)for(let[o,s]of Object.entries(hN(i))){let a=e.get(o)??{tags:new Set,names:[],japanese:[],generated:[],rank:0,weight:0,posts:0};a.posts=Math.max(a.posts,s.posts??0),a.generated.push(...s.generated??[]),a.japanese.push(...s.names?.ja??[]),a.tag??=s.tag;for(let c of s.danbooru??[])a.tags.add(c);for(let c of uN)a.names.push(...s.names?.[c]??[]);if(s.rank!==void 0){let c=s.weight??1;a.rank=(a.rank*a.weight+s.rank*c)/(a.weight+c),a.weight+=c}e.set(o,a)}let n=[],r=Math.log1p([...e.values()].reduce((i,o)=>Math.max(i,o.posts),1));for(let i of e.values()){if(i.tags.size===0)continue;let o=[...i.tags];n.push({tag:i.tag&&i.tags.has(i.tag)?i.tag:o[0],tags:o,names:[...new Set(i.names)],japanese:[...new Set(i.japanese)],generated:[...new Set(i.generated)],rank:i.posts>0?Math.log1p(i.posts)/r:i.rank})}return n}function ba(t,e){let n=new t(e.length);return n.set(e),n}function eh(t){let e=[0];for(let n of t)e.push(e.at(-1)+n.length);return{bytes:Buffer.concat(t),at:ba(Uint32Array,e)}}function pN(t,e){let n=mN(t),r=new Map,i=(v,E,x)=>{let M=r.get(v),R=E*4+x;if(!M)r.set(v,[R]);else if(M.at(-1)>>>2!==E)M.push(R);else if(M.at(-1)<R)M[M.length-1]=R};n.forEach((v,E)=>{let x=[...v.names,...v.tags.map((M)=>M.replaceAll("_"," "))];for(let[M,R]of[[x,1],[v.generated,0]])for(let F of M){let N=Vo(F);if(N&&ih(N))i(N,E,2|R);let j=F.split(/[\s・·_]+/);if(j.length<2)continue;for(let z of j){let G=Vo(z);if(G&&ih(G))i(G,E,R)}}});let o=[...r.keys()].sort(),s=[0],a=[];for(let v of o){for(let E of r.get(v)??[])a.push(E);s.push(a.length)}let c=n.flatMap((v,E)=>v.tags.map((x)=>[x,E])).sort(([v],[E])=>v<E?-1:v>E?1:0),u=eh(o.map((v)=>Buffer.from(v))),f=eh(n.map((v)=>Buffer.from(JSON.stringify([v.tag,v.tags,v.names,v.japanese,v.generated])))),l=eh(c.map(([v])=>Buffer.from(v))),d={keys:u.bytes,keyAt:u.at,ownAt:ba(Uint32Array,s),owners:ba(Uint32Array,a),cards:f.bytes,cardAt:f.at,ranks:ba(Float32Array,n.map((v)=>v.rank)),tags:l.bytes,tagAt:l.at,tagCard:ba(Uint32Array,c.map(([,v])=>v))},h=N$.map((v)=>{let E=d[v];return Buffer.from(E.buffer,E.byteOffset,E.byteLength)}),m=0,p=h.map((v)=>{let E=[m,v.length];return m+=Math.ceil(v.length/4)*4,E}),b=Buffer.from(JSON.stringify({stamp:e,sections:p})),$=Math.ceil((8+b.length)/4)*4,k=Buffer.alloc($+m);k.write(T$,0,"latin1"),k.writeUInt32LE(b.length,4),b.copy(k,8);for(let[v,E]of h.entries())E.copy(k,$+(p[v]?.[0]??0));return k}function P$(t,e,n,r){let i=e.byteOffset+n;if(i%4===0)return new t(e.buffer,i,r/4);return new t(e.buffer.slice(i,i+r),0,r/4)}function A$(t,e){if(t.toString("latin1",0,4)!==T$)return;let n=t.readUInt32LE(4),r=JSON.parse(t.toString("utf8",8,8+n));if(r.stamp!==e)return;let i=Math.ceil((8+n)/4)*4,o=(c)=>{let[u,f]=r.sections[N$.indexOf(c)];return[i+u,f]},s=(c)=>{let[u,f]=o(c);return t.subarray(u,u+f)},a=(c)=>P$(Uint32Array,t,...o(c));return{keys:s("keys"),keyAt:a("keyAt"),ownAt:a("ownAt"),owners:a("owners"),cards:s("cards"),cardAt:a("cardAt"),ranks:P$(Float32Array,t,...o("ranks")),tags:s("tags"),tagAt:a("tagAt"),tagCard:a("tagCard")}}var nh;function oh(t){try{let e=H$(t);if(e.length===0)return;let n=F$(e);if(nh?.stamp===n)return nh.index;let r=Zo(Br(t),"index.bin"),i;try{i=A$(hu(r),n)}catch{}if(!i){let o=pN(e,n);try{L(r,o)}catch{}i=A$(o,n)}if(i)nh={stamp:n,index:i};return i}catch{return}}function L$(t,e){let[n,r,i,o,s]=JSON.parse(t.cards.toString("utf8",t.cardAt[e],t.cardAt[e+1]));return{tag:n,tags:r,names:i,japanese:o,generated:s,rank:t.ranks[e]??0}}function C$(t,e,n,r){let i=0,o=n;while(i<o){let s=i+o>>1;if(t.toString("utf8",e[s],e[s+1])<r)i=s+1;else o=s}return i}function j$(t,e){let n=Buffer.from(e),r=t.tagCard.length,i=C$(t.tags,t.tagAt,r,e);if(i>=r||t.tags.compare(n,0,n.length,t.tagAt[i],t.tagAt[i+1])!==0)return;return t.tagCard[i]}var rh=/\s*[((][^()()]*[))]$/u,du={ko:4,en:4,ja:5,zh:3};function gN(t){if(!t)return[];let e=/\p{Script=Hangul}/u,n=/^[\p{Script=Latin}\p{N}\s.'’-]+$/u,r=new Set([...t.names,...t.generated].filter((l)=>!rh.test(l))),i=(l)=>!rh.test(l)||!r.has(l.replace(rh,"")),o=t.names.filter(i),s=o.filter((l)=>e.test(l)),a=[...s,...t.generated.slice(0,s.length>0?0:2)],c=o.filter((l)=>n.test(l)),u=t.japanese.filter(i),f=o.filter((l)=>!e.test(l)&&!n.test(l)&&!u.includes(l));return[...new Set([...a.slice(0,du.ko),...c.slice(0,du.en),...u.slice(0,du.ja),...f.slice(0,du.zh)])]}var Yo;function mu(t,e=Xo()){if(!t)return[];if(!Yo)try{Yo=JSON.parse(hu(Zo(Br(e),"aliases.json"),"utf8")).tags}catch{Yo={}}return Yo[t]??[]}function sh(t,e=Xo()){try{return bN(t,e)}catch{return new Map}}function bN(t,e){let n=new Map,r=H$(e);if(r.length===0||t.length===0)return n;let i=F$(r),o=Zo(Br(e),"aliases.json"),s;try{s=JSON.parse(hu(o,"utf8"))}catch{}if(s?.stamp===i&&t.every((f)=>(f in s.tags))){Yo=s.tags;for(let f of t)n.set(f,s.tags[f]??[]);return n}let a=oh(e);if(!a)return n;let c=new Set([...t,...s?.stamp===i?Object.keys(s.tags):[]]),u={};for(let f of c){let l=j$(a,f);u[f]=l===void 0?[]:gN(L$(a,l))}try{L(o,`${JSON.stringify({stamp:i,tags:u})}
|
|
248
|
-
`)}catch{}
|
|
242
|
+
*/var qt=["top-left","top-center","top-right","center-left","center","center-right","bottom-left","bottom-center","bottom-right"],ha="Original",AN=1e6,Sn="_groups.toml",V0=3,Z0=8,Ud="[a-z0-9]+(?:-[a-z0-9]+)*",TN=new RegExp(`^(?:(${Ud})@(${Ud})/)?(${Ud})$`),e$=["background","foreground","cursor","selection"];function nt(t,e){throw Error(`${t}: ${e}`)}function Fi(t,e,n){if(typeof n!=="string"||!he(n))nt(t,`${e} must be "#rrggbb" (lowercase), got ${JSON.stringify(n)}`);return n}function pa(t,e,n){if(typeof n!=="string"||n.length===0)nt(t,`${e} must be a non-empty string`);return n}function ue(t){return t.replace("@","--").replace("/","--")}function j(t){return`ttheme-${ue(t)}`}function ut(t){let e=t.indexOf("/");return e<0?void 0:t.slice(0,e)}function pe(t){return t.slice(t.indexOf("/")+1)}function Te(t){let e=TN.exec(t);if(!e)return"takes lowercase letters, digits and single hyphens, as <palette> or <owner>@<market>/<palette>";if((e[1]?.length??0)>39)return"has an owner longer than a GitHub handle can be";return(e[2]?.length??0)>40||(e[3]?.length??0)>40?"is longer than 40 characters":void 0}function ga(t){if(/[\p{Cc}"$`\\]/u.test(t))return"holds a control character, a quote, $, ` or \\";return t.length>80?"is longer than 80 characters":void 0}function ma(t,e,n){let r=pa(t,e,n),i=ga(r);if(i)nt(t,`${e} ${JSON.stringify(r)} ${i}`);return r}function X0(t,e,n){let r=pa(t,e,n),i=Te(r);if(i)nt(t,`${e} "${r}" ${i}`);return r}function Wo(t){return t&&typeof t==="object"?t:{}}function HN(t,e,n){if(e===void 0)return[n.cursor,n.selectionBackground,n.background];let r=Array.isArray(e)?e:[e];if(r.length===0)nt(t,"ghostty.icon_screen must not be empty");return r.map((i,o)=>Fi(t,`ghostty.icon_screen[${o}]`,i))}function FN(t,e,n){let r=Wo(e);return{iconGhost:r.icon_ghost===void 0?n.cursor:Fi(t,"ghostty.icon_ghost",r.icon_ghost),iconScreen:HN(t,r.icon_screen,n)}}function LN(t){return new Map([...e$.map((e)=>[e,t[e]]),...t.ansi.map((e,n)=>[`ansi${n}`,e])])}function CN(t,e,n){if(!Array.isArray(e)||e.length!==V0)nt(t,`meta.signature must name exactly ${V0} palette slots`);let r=LN(n),i=[],o=[];for(let[s,a]of e.entries()){let c=`meta.signature[${s}]`,u=pa(t,c,a),f=r.get(u);if(f===void 0)nt(t,`${c} ${JSON.stringify(a)} is not a palette slot — use ${e$.join(", ")} or ansi0-ansi15`);i.push(u),o.push(f)}if(new Set(o).size!==o.length)nt(t,"meta.signature slots must resolve to three different colors");return{names:i,colors:o}}function jN(t,e,n,r=!1){if(e===void 0)return;if(!n)nt(t,"meta.booru_sites renames meta.booru per site, so it needs meta.booru");if(!e||typeof e!=="object"||Array.isArray(e))nt(t,'meta.booru_sites must be a table of site = "tag" or site = ["tag", ...]');let i={};for(let[o,s]of Object.entries(e)){let a=Z.find((u)=>u.key===o);if(!a){if(r)continue;nt(t,`meta.booru_sites.${o} is not a find site — use ${Z.map((u)=>u.key).join(", ")}`)}let c=typeof s==="string"?[s]:Array.isArray(s)?s:void 0;if(!c||c.some((u)=>typeof u!=="string"||u===""||/\s/.test(u)))nt(t,`meta.booru_sites.${o} must be one tag or a list of tags, got ${JSON.stringify(s)}`);if(c.length>1&&!a.ors)nt(t,`meta.booru_sites.${o} takes one tag — ${a.name} does not OR tags`);if(c.length>a.tagBudget)nt(t,`meta.booru_sites.${o} takes ${a.tagBudget} tags at most — ${a.name} searches that many at a time`);i[o]=c}return i}function _N(t,e,n){if(e===void 0)return;if(!Array.isArray(e)||e.length===0||e.length>Z0)nt(t,`[[picture]] holds 1 to ${Z0} pictures`);let r=e.flatMap((i,o)=>{let s=Wo(i),a=`picture[${o}]`,c=Z.find((h)=>h.key===s.site);if(!c){if(n)return[];nt(t,`${a}.site must be one of ${Z.map((h)=>h.key).join(", ")}`)}if(typeof s.id!=="number"||!Number.isSafeInteger(s.id)||s.id<=0)nt(t,`${a}.id must be the post's number on ${c.name}`);let{size:u,position:f,opacity:l}=s;if(u!==void 0&&u!=="fill"&&!(Number.isInteger(u)&&Number(u)>=20&&Number(u)<=999))nt(t,`${a}.size must be "fill" or a percentage from 20 to 999`);let d=f===void 0||qt.includes(f);if(!d&&!n)nt(t,`${a}.position must be one of ${qt.join(", ")}`);if(l!==void 0&&!(typeof l==="number"&&l>=0&&l<=1))nt(t,`${a}.opacity must be a number from 0 to 1`);return[{site:c.key,id:s.id,...u!==void 0?{size:u}:{},...f!==void 0&&d?{position:f}:{},...l!==void 0?{opacity:l}:{}}]});return r.length>0?r:void 0}function Kd(t,e){try{return Hi(e)}catch(n){nt(t,`is not valid TOML — ${(n instanceof Error?n.message:String(n)).split(`
|
|
243
|
+
`)[0]}`)}}function GN(t){let n=Kd(Sn,Q0(t$(t,Sn),"utf8")).group;if(!Array.isArray(n)||n.length===0)nt(Sn,"needs at least one [[group]] table");return n.map((r)=>{let i=Wo(r);return{name:ma(Sn,"group.name",i.name),native:i.native===void 0?void 0:ma(Sn,"group.native",i.native),lead:pa(Sn,"group.lead",i.lead)}})}function BN(t,e){if(!Array.isArray(e)||e.length===0)nt(t,'meta.native_names must be a list of names, like ["後藤ひとり"]');return e.map((n,r)=>{let i=ma(t,`meta.native_names[${r}]`,n);if(i.includes("|"))nt(t,`meta.native_names[${r}] ${JSON.stringify(i)} contains |`);return i})}var Wd={"":["$schema","meta","colors","contrast","ghostty","picture"],meta:["name","base","group","ansi_source","booru","booru_sites","native_names","signature","order","role"],colors:["background","foreground","cursor","selection_background","ansi"],contrast:["waive","reason"],ghostty:["icon_ghost","icon_screen"],picture:["site","id","size","position","opacity"]};function n$(t,e){let n=Kd(t,e),r=(i,o,s=[])=>o&&typeof o==="object"&&!Array.isArray(o)?Object.keys(o).filter((a)=>!s.includes(a)).map((a)=>i?`${i}.${a}`:a):[];return[...r("",n,Wd[""]),...["meta","colors","contrast","ghostty"].flatMap((i)=>r(i,n[i],Wd[i])),...(Array.isArray(n.picture)?n.picture:[]).flatMap((i,o)=>r(`picture[${o}]`,i,Wd.picture))]}function zd(t,e,n){let r=Kd(t,e),i=Wo(r.meta),o=Wo(r.colors),s=Wo(r.contrast),a=o.ansi;if(!Array.isArray(a)||a.length!==16)nt(t,`colors.ansi must hold exactly 16 colors, got ${Array.isArray(a)?a.length:typeof a}`);let c=X0(t,"meta.name",i.name);if(c!==n.name)nt(t,`meta.name "${c}" does not match its file — it lives at ${n.name}`);let u=n.open===!0;for(let _ of["order","role"])if(u&&i[_]!==void 0)nt(t,`meta.${_} is for the official palettes — a market palette follows its base`);let f=i.role;if(f!==void 0&&f!=="default")nt(t,`meta.role must be "default", got ${JSON.stringify(f)}`);let l=i.base===void 0?void 0:X0(t,"meta.base",i.base);if(l!==void 0&&!u)nt(t,"meta.base is for market palettes");let d=l===void 0?void 0:n.bases?.get(l),h=u&&i.group===void 0?d?.group??ha:ma(t,"meta.group",i.group),m=n.groups.get(h);if(!m&&!(u&&(h===ha||n.open)))nt(t,`meta.group "${h}" has no [[group]] table in ${Sn}`);let p=Fi(t,"colors.background",o.background),b=Fi(t,"colors.foreground",o.foreground),$=Fi(t,"colors.cursor",o.cursor),k=Fi(t,"colors.selection_background",o.selection_background),v=a.map((_,q)=>Fi(t,`colors.ansi[${q}]`,_)),S=CN(t,i.signature,{background:p,foreground:b,cursor:$,selection:k,ansi:v}),x=i.booru===void 0?void 0:pa(t,"meta.booru",i.booru);if(x!==void 0&&/[\s\p{Cc}]/u.test(x))nt(t,`meta.booru must be a single booru tag, got ${JSON.stringify(x)}`);let M=jN(t,i.booru_sites,x,n.foreign===!0),P=i.native_names===void 0?void 0:BN(t,i.native_names),L=Array.isArray(s.waive)?s.waive.map(String):[];if(L.length>0&&typeof s.reason!=="string")nt(t,"contrast.waive needs a contrast.reason explaining why");let A=_N(t,r.picture,n.foreign===!0);return{name:c,...l?{base:l}:{},group:h,native:m?.native,...P?{nativeNames:P}:{},lead:!u&&m?.lead===c,order:u?d?.order??AN:Number(i.order),role:f,ansiSource:u&&i.ansi_source===void 0?l??"original":ma(t,"meta.ansi_source",i.ansi_source),...x?{booru:x}:{},...M?{booruSites:M}:{},background:p,foreground:b,cursor:$,selectionBackground:k,ansi:v,signature:S.colors,signatureSlots:S.names,ghostty:FN(t,r.ghostty,{background:p,cursor:$,selectionBackground:k}),waive:L,waiveReason:typeof s.reason==="string"?s.reason:void 0,...A?{pictures:A}:{}}}function r$(t){let e=GN(t),n=new Map(e.map((o)=>[o.name,o]));if(n.size!==e.length)nt(Sn,"group.name must be unique");let r=RN(t).filter((o)=>o.endsWith(".toml")&&!o.startsWith("_")).map((o)=>zd(o,Q0(t$(t,o),"utf8"),{name:NN(o,".toml"),groups:n})).sort((o,s)=>o.order-s.order);if(new Set(r.map((o)=>o.order)).size!==r.length)throw Error("themes: meta.order must be unique across all themes");for(let o of e){let s=r.filter((a)=>a.group===o.name);if(s.length===0)nt(Sn,`group "${o.name}" has no themes`);if(!s.some((a)=>a.name===o.lead))nt(Sn,`group "${o.name}" lead "${o.lead}" is not one of its themes`)}return r}function i$(t){return t.filter((e)=>e.role===void 0)}function Li(t){let e=(r,i)=>r<i?-1:r>i?1:0,n=(r)=>ut(r.name)?r.name:r.base??r.name;return[...t].sort((r,i)=>Number(ut(r.name)!==void 0)-Number(ut(i.name)!==void 0)||e(r.group.toLowerCase(),i.group.toLowerCase())||Number(r.catalog===void 0)-Number(i.catalog===void 0)||e((r.catalog??"").toLowerCase(),(i.catalog??"").toLowerCase())||e(n(r),n(i))||Number(r.base!==void 0)-Number(i.base!==void 0)||e(r.name,i.name))}var ba={width:2560,height:1550},DN=1,JN=2560,YN=0.1,p$=0.99,VN=2,Ci={tall:1.15,reach:0.4,widest:0.95,headroom:0.04,margin:0.03,stands:12},ZN=St(Rt("#19161e","#9b86c8",0.2)),XN="shelf",du="originals",QN="images.json",Dd=1;function tA(t,e){if(e==="background"||e==="foreground"||e==="cursor")return t[e];if(e==="selection"&&t.selection)return t.selection;let n=/^ansi(\d|1[0-5])$/.exec(e),r=n?t.ansi[Number(n[1])]:void 0;if(!r)throw Error(`${t.name} has no slot ${e}`);return r}function o$(t){if(t(1))return 1;let e=0,n=1;for(let r=0;r<40;r++){let i=(e+n)/2;if(t(i))e=i;else n=i}return e}function g$(t,e){let n=(s)=>Vb({name:t.name,background:Rt(t.background,e,s),foreground:t.foreground,ansi:t.ansi,waive:t.waived??[]}).map((a)=>a.rule),r=new Set(n(0)),i=o$((s)=>n(s).every((a)=>r.has(a))),o=o$((s)=>St(Rt(t.background,e,s))<=ZN);return{cap:i,matched:o,opacity:Math.floor(Math.min(i,o)*100)/100}}function s$(t,e){let n=tA(t,e),{cap:r,matched:i,opacity:o}=g$(t,n),s=ot(t.background),a=Math.hypot(...ot(n).map((c,u)=>(c-(s[u]??0))*o));return{slot:e,color:n,cap:r,matched:i,opacity:o,reach:a}}function b$(t,e){return g$(t,e).opacity}function En(t,e){let n=s$(t,"cursor");if(n.opacity>=YN)return n;return e.filter((r)=>r!=="cursor"&&r!=="background").map((r)=>s$(t,r)).reduce((r,i)=>i.reach>r.reach?i:r,n)}function eA(t){return i0(t)??{x:0,y:0,w:t.width,h:t.height}}function Qd(t,e){if(t<=0||e<=0)return ba;let n=Math.min(1,ba.width/Math.max(t,e));return{width:Math.round(t*n),height:Math.round(e*n)}}function w$(t,e,n,r){if(r<Ci.stands){let c=t.w*n>t.h*e?{x:t.x+(t.w-t.h*e/n)/2,y:t.y,w:t.h*e/n,h:t.h}:{x:t.x,y:t.y,w:t.w,h:t.w*n/e};return{crop:c,at:{x:0,y:0,w:e,h:n},focus:(c.y-t.y+c.h/2)/t.h}}let i=Math.max(Ci.tall*n,Ci.reach*e*t.h/t.w),o=i*t.w/t.h;if(o>Ci.widest*e)o=Ci.widest*e,i=o*t.h/t.w;let s=Ci.headroom*n,a=Math.min(1,(n-s)/i);return{crop:{x:t.x,y:t.y,w:t.w,h:t.h*a},at:{x:e*(1-Ci.margin)-o,y:s,w:o,h:i*a},focus:Math.min(1,(n/2-s)/i)}}function nA(t,e){return 0.299*(t[e]??0)+0.587*(t[e+1]??0)+0.114*(t[e+2]??0)}function rA(t,e){let n=new Uint32Array(256),r=Math.max(1,Math.floor(e.w*e.h/400000)),i=0;for(let s=0;s<e.w*e.h;s+=r){let a=((e.y+Math.floor(s/e.w))*t.width+e.x+s%e.w)*4;if((t.data[a+3]??0)>=128){let c=Math.round(nA(t.data,a));n[c]=(n[c]??0)+1,i++}}let o=0;for(let s=0;s<256&&i>0;s++)if(o+=n[s]??0,o>=i*p$)return Math.min(VN,Math.max(1,255/Math.max(1,s)));return 1}var qd=Float64Array.from({length:256},(t,e)=>{let n=e/255;return n<=0.04045?n/12.92:((n+0.055)/1.055)**2.4});function iA(t,e,n){return`#${[t,e,n].map((r)=>Math.round(r).toString(16).padStart(2,"0")).join("")}`}function oA(t,e){let n=new Uint32Array(256),r=new Float64Array(768),i=Math.max(1,Math.floor(e.w*e.h/400000)),o=0;for(let a=0;a<e.w*e.h;a+=i){let c=((e.y+Math.floor(a/e.w))*t.width+e.x+a%e.w)*4;if((t.data[c+3]??0)>=128){let u=t.data[c]??0,f=t.data[c+1]??0,l=t.data[c+2]??0,d=Math.round(255*Math.sqrt(0.2126*(qd[u]??0)+0.7152*(qd[f]??0)+0.0722*(qd[l]??0)));n[d]=(n[d]??0)+1,r[d*3]=(r[d*3]??0)+u,r[d*3+1]=(r[d*3+1]??0)+f,r[d*3+2]=(r[d*3+2]??0)+l,o++}}let s=0;for(let a=0;a<256&&o>0;a++)if(s+=n[a]??0,s>=o*p$){let c=Math.max(1,n[a]??1);return iA((r[a*3]??0)/c,(r[a*3+1]??0)/c,(r[a*3+2]??0)/c)}return"#ffffff"}function sA(t,e){let n=t.data,r=new Uint8Array(t.width*t.height);for(let i=0,o=0;i<r.length;i++,o+=4){let s=n[o+3];if(s===0)continue;let a=(0.299*n[o]+0.587*n[o+1]+0.114*n[o+2])*e;r[i]=(a>255?255:a)*s/255+0.5}return{width:t.width,height:t.height,data:r}}function $$(t,e,n){let r=Math.max(0,Math.round(t.at.x)),i=Math.max(0,Math.round(t.at.y)),o=Math.min(e,Math.round(t.at.x+t.at.w)),s=Math.min(n,Math.round(t.at.y+t.at.h));if(o<=r||s<=i)return;let a=t.crop.w/t.at.w,c=t.crop.h/t.at.h;return{x0:r,y0:i,x1:o,y1:s,box:{x:t.crop.x+(r-t.at.x)*a,y:t.crop.y+(i-t.at.y)*c,w:(o-r)*a,h:(s-i)*c}}}function fu(t,e,n,r){let i=new Float32Array(n*r),o=$$(e,n,r);if(o){let s=c0(t,o.box,o.x1-o.x0,o.y1-o.y0);for(let a=o.y0;a<o.y1;a++)i.set(s.data.subarray((a-o.y0)*(o.x1-o.x0),(a-o.y0+1)*(o.x1-o.x0)),a*n+o.x0)}return{width:n,height:r,data:i}}function th(t,e,n,r){let i=new Uint8Array(n*r*4),o=$$(e,n,r);if(o){let s=o.x1-o.x0,a=ta(t,o.box,s,o.y1-o.y0);for(let c=o.y0;c<o.y1;c++)i.set(a.data.subarray((c-o.y0)*s*4,(c-o.y0+1)*s*4),(c*n+o.x0)*4)}return{width:n,height:r,data:i}}function Jd(t,e){if(e<=0)return t;let{width:n,height:r}=t,i=[0,1,2,3].map(()=>({width:n,height:r,data:new Float32Array(n*r)}));for(let a=0;a<n*r;a++){let c=t.data[a*4+3]??0;for(let u=0;u<3;u++)i[u].data[a]=(t.data[a*4+u]??0)*c/255;i[3].data[a]=c}let o=i.map((a)=>ea(a,e).data),s=new Uint8Array(n*r*4);for(let a=0;a<n*r;a++){let c=o[3]?.[a]??0;if(c<=0)continue;for(let u=0;u<3;u++)s[a*4+u]=Math.min(255,Math.max(0,Math.round((o[u]?.[a]??0)*255/c)));s[a*4+3]=Math.min(255,Math.round(c))}return{width:n,height:r,data:s}}function eh(t){let e=eA(t),n,r;return{box:e,clear:Vn(t,e),get ink(){return n??=sA(t,rA(t,e)),n},image:t,get peak(){return r??=oA(t,e),r}}}function k$(t,e,n,r,i){let o=eh(t),{box:s,clear:a,ink:c}=o,u=w$(s,e,n,a),f=Math.min(1,JN/Math.max(s.w,s.h)),l={x:0,y:0,w:Math.round(s.w*f),h:Math.round(s.h*f)},d=r*l.w*u.crop.w/(s.w*u.at.w);if(i==="original")return{coloring:i,figure:Jd(ta(t,s,l.w,l.h),d),fill:Jd(th(t,u,e,n),r),focus:u.focus,peak:o.peak};let h=fu(c,{crop:s,at:l,focus:u.focus},l.w,l.h),m=fu(c,u,e,n);return{coloring:i,figure:na(ea(h,d)),fill:na(ea(m,r)),focus:u.focus}}function aA(t,e,n,r){let i=ot(e),o=ot(n),s=new Uint8Array(t.width*t.height*4);for(let a=0;a<t.data.length;a++){let c=(t.data[a]??0)/255*r;for(let u=0;u<3;u++)s[a*4+u]=Math.round((i[u]??0)+((o[u]??0)-(i[u]??0))*c);s[a*4+3]=255}return{width:t.width,height:t.height,data:s}}function cA(t,e,n){let r=ot(e),i=new Uint8Array(t.width*t.height*4);for(let o=0;o<t.width*t.height;o++){let s=(t.data[o*4+3]??0)/255*n;for(let a=0;a<3;a++)i[o*4+a]=Math.round((r[a]??0)+((t.data[o*4+a]??0)-(r[a]??0))*s);i[o*4+3]=255}return{width:t.width,height:t.height,data:i}}function y$(t,e,n,r,i,o,s,a="tone"){let{box:c,clear:u,ink:f}=t,l=w$(c,r,i,u),d=Math.round(100*l.at.w/l.crop.w/Math.min(r/c.w,i/c.h)),h=s?.size??"fill",m=h==="fill"?l:{crop:c,at:Yo(c.w,c.h,r,i,h,s?.at??5,!1,h>100?Math.round(l.focus*100):-1),focus:l.focus},p=a==="original"?b$(e,t.peak):n.opacity,b=s?.opacity??p;return{image:a==="original"?cA(Jd(th(t.image,m,r,i),o),e.background,b):aA(na(ea(fu(f,m,r,i),o)),e.background,n.color,b),fill:d,opacity:p}}function X(t){return Y(t,"ttheme","backgrounds")}function Yd(t){return Y(t,QN)}function ji(t){try{return zo(t,"utf8")}catch{return}}function Gr(t){try{return KN(t)}catch{return[]}}function Nt(t){let e=ji(Yd(t));if(e===void 0)return uA(t);let n=JSON.parse(e);if(n.version!==Dd)throw Error(`${Yd(t)} is version ${n.version} — this ttheme reads version ${Dd}`);return n}function ze(t){return t.coloring??"tone"}function nh(t){return{name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,...t.selection?{selection:t.selection}:{},ansi:t.ansi,...t.waived?{waived:t.waived}:{}}}function qo(t){return{hue:{color:t.backdrop.color,opacity:t.backdrop.opacity},colors:nh(t)}}function Do(t){return t.tone===void 0&&ze(t)==="tone"}function a$(t){return(t.artist??[]).map((e)=>e.replace(/[\s,\p{Cc}]+/gu,"_")).join(",")}function v$(t,e){let n=e.pictures.findIndex((i)=>i.key===e.active),r=e.pictures[n];return[...r.artist?.length?[`# by ${a$(r)}`]:[],...r.from?[`# from ${r.from}`]:[],`# image ${r.key} ${n+1}/${e.pictures.length}`,...e.pictures.map((i)=>[`# picture ${i.key} ${i.stem} ${i.fill} ${i.opacity} ${i.artist?.length?a$(i):"-"}`,...i.from?[i.from]:[]].join(" ")),...e.pictures.filter((i)=>ze(i)==="original").map((i)=>`# colors ${i.key} original`),`background-image = ${Y(t,r.fill)}`,"background-image-fit = cover","background-image-position = top-right",`background-image-opacity = ${r.opacity}`,`config-file = ?${r.stem}.tune.conf`,`config-file = ?${r.stem}.off.conf`,""].join(`
|
|
244
|
+
`)}function S$(t){let e=X(t);for(let[n,r]of Object.entries(Nt(e).palettes)){let i=Y(e,`${ue(n)}.conf`),o=v$(e,r);if(ji(i)!==o)C(i,o)}}function _i(t,e,n){C(Yd(t),`${JSON.stringify(e,null,2)}
|
|
245
|
+
`);for(let r of n){let i=e.palettes[r],o=Y(t,`${ue(r)}.conf`);if(i)C(o,v$(t,i));else Ko(o,{force:!0})}}function E$(t,e){let n=X(t),r=Nt(n),i=[];for(let[o,s]of e){let a=r.palettes[o];if(a&&!r.palettes[s])r.palettes[s]=a,delete r.palettes[o],i.push(o,s)}if(i.length>0)_i(n,r,i)}function M$(t,e){return Gr(t).filter((n)=>n.startsWith(`${e}.`)||n.startsWith(`${e}@`))}function rh(t,e){for(let n of M$(t,e))Ko(Y(t,n),{force:!0})}function x$(t,e){rh(t,e.stem);for(let n of[e.original,e.cut])if(n)Ko(Y(t,n),{force:!0})}function c$(t,e,n,r){let i=m$(/^background-image\s*=\s*(.*?)\s*$/m.exec(e??"")?.[1]??"");if(!i.startsWith(`${t}.`)||!/^\.[0-9a-f]{8}@fill-\d+\.png$/.test(i.slice(t.length)))return;let o=i.slice(0,i.indexOf("@")),s=r??/^# image (\S+)$/m.exec(e??"")?.[1]??`picture_${o.slice(t.length+1)}`,a=/^# from (.+)$/m.exec(e??"")?.[1],c=Number(/^background-image-opacity\s*=\s*(\S+)/m.exec(e??"")?.[1]??1),u=n.find((f)=>f.startsWith(`${t}-${s}.`));return{key:s,stem:o,fill:i,opacity:Number.isFinite(c)?c:1,...a?{from:a}:{},...u?{original:Y(du,u)}:{}}}function u$(t,e){if(Xd(t))h$(t,e)}function uA(t){let e={version:Dd,palettes:{}};if(!Xd(t))return e;let n=Gr(Y(t,du)),r=Gr(t).filter((o)=>o.endsWith(".conf")&&o!=="shown.conf"&&!/\.(tune|off)\.conf$/.test(o)).map((o)=>o.slice(0,-5)),i=Y(t,XN);for(let o of new Set([...r,...Gr(i)])){let s=[],a=c$(o,ji(Y(t,`${o}.conf`)),n);if(a)u$(Y(t,`${o}.tune.conf`),Y(t,`${a.stem}.tune.conf`)),u$(Y(t,`${o}.off.conf`),Y(t,`${a.stem}.off.conf`)),s.push(a);for(let c of Gr(Y(i,o))){let u=Y(i,o,c),f=c$(o,ji(Y(u,".conf")),n,c);if(!f)continue;for(let l of Gr(u)){let d=l===".tune.conf"||l===".off.conf"?`${f.stem}${l}`:`${o}${l}`;if(l!==".conf")h$(Y(u,l),Y(t,d))}Ko(u,{recursive:!0}),s.push(f)}if(Gr(Y(i,o)).length===0)Ko(Y(i,o),{recursive:!0,force:!0});if(s.length>0)s.sort((c,u)=>c.key<u.key?-1:c.key>u.key?1:0),e.palettes[o]={active:(a??s[0]).key,pictures:s}}if(Gr(i).length===0)Ko(i,{recursive:!0,force:!0});return _i(t,e,Object.keys(e.palettes)),e}function l$(t,e,n){return e.startsWith("~/")?Y(n,e.slice(2)):qN(e)?e:Y(t,e)}function He(t,e,n){let r=new Map,i=(a,c)=>{let u=ji(a);if(u===void 0)return!1;for(let f of u.split(`
|
|
246
|
+
`)){let l=/^([a-z-]+)\s*=\s*(.*?)\s*$/.exec(f);if(l?.[1]==="config-file"&&c<4)i(l$(t,l[2].replace(/^\?/,""),n),c+1);else if(l&&/^background-image(?:-fit|-opacity|-position)?$/.test(l[1]))r.set(l[1],l[2])}return!0};if(!i(Y(t,`${ue(e)}.conf`),0))return;let o=r.get("background-image")??"";if(o==="")return;let s=Number(r.get("background-image-opacity")??1);return{image:l$(t,o,n),opacity:Number.isFinite(s)?s:1,cover:r.get("background-image-fit")==="cover",position:r.get("background-image-position")??"center"}}function le(t){return`${t.site}_${t.id}`}function hu(t,e,n){let r=X(t),i=Nt(r),o=i.palettes[e];if(!o)throw Error(`${e} has no image`);let s=o.pictures.findIndex((u)=>u.key===(n??o.active));if(s===-1)throw Error(`${e} has no picture ${n}`);let[a]=o.pictures.splice(s,1);x$(r,a);let c=o.pictures[s%Math.max(o.pictures.length,1)];if(!c)delete i.palettes[e];else if(a.key===o.active)o.active=c.key;return _i(r,i,[e]),{key:a.key,left:o.pictures.length}}function O$(t,e,n,r){let i=n.coloring==="original"?Ke(n.figure):Ri(n.figure,r),o=n.coloring==="original"?Ke(n.fill):Ri(n.fill,r),s=`${ue(t)}.${d$("sha1").update(e).update(i).update(o).digest("hex").slice(0,8)}`,a=`${s}@fill-${Math.round(n.focus*100)}.png`;return{stem:s,fill:a,files:[[`${s}.png`,i],[a,o]]}}function I$(t,e,n,r){return n==="original"&&r?{coloring:"original",opacity:b$(t,r),peak:r}:{coloring:"tone",opacity:e.opacity,tone:e.color}}function Vd(t,e){return Y(du,`${ue(t)}-${e}`)}function ih(t,e){return e.map(([n,r])=>{let i=Y(t,n);return C(i,r),i})}function mu(t,e,n,r,i,o,s,a="tone"){let c=X(t),u=e.name,f=le(i),l=Nt(c),d=l.palettes[u]??{active:f,pictures:[]},h=Qd(o.width,o.height),m=k$(r,h.width,h.height,s,a),p=O$(u,f,m,n.color),b=Vd(u,f),$={key:f,stem:p.stem,fill:p.fill,...I$(e,n,m.coloring,m.coloring==="original"?m.peak:void 0),blur:s,window:h,...i.from?{from:i.from}:{},...i.artist?.length?{artist:i.artist}:{},...i.source?{source:i.source}:{},original:`${b}.${i.ext}`,...i.cut?{cut:`${b}.cut.png`}:{}},k=d.pictures.find((S)=>S.key===f);if(k)x$(c,k);WN(Y(c,du),{recursive:!0});let v=ih(c,[...p.files,[$.original,i.bytes],...$.cut?[[$.cut,Id(Pi(r))]]:[]]);return d.pictures=k?d.pictures.map((S)=>S===k?$:S):[...d.pictures,$],d.active=f,l.palettes[u]=d,_i(c,l,[u]),[...v,Y(c,`${ue(u)}.conf`)]}function Jo(t,e,n){let r=X(t),i=Nt(r),o=i.palettes[e],s=o?o.pictures.findIndex((a)=>a.key===n):-1;if(!o||s===-1)throw Error(`${e} has no picture ${n}`);if(o.active!==n)o.active=n,_i(r,i,[e]);return{at:s+1,of:o.pictures.length}}function ge(t,e){let n=Nt(X(t)).palettes[e];if(!n)return[];return[...n.pictures.filter((i)=>i.key===n.active),...n.pictures.filter((i)=>i.key!==n.active)]}var Zd="top-right";function Yo(t,e,n,r,i,o,s,a=-1){let c=Math.trunc,u=(o-1)%3,f=c((o-1)/3),l=n*e>=r*t!==!s,d=l?c(i*n/100):c(i*r*t/(100*e)),h=l?c(i*n*e/(100*t)):c(i*r/100),m=c(u*(n-d)/2),p=c(f*(r-h)/2);if(a>=0){if(d>n)m=c((n-d)/2);if(h>r)p=Math.max(r-h,Math.min(0,c(r/2)-c(a*h/100)))}return{x:m,y:p,w:d,h}}function oh(t,e){let n=ji(Y(t,`${e.stem}.tune.conf`));if(n===void 0)return{};let r=(u)=>new RegExp(`^${u}\\s*=\\s*(.*?)\\s*$`,"m").exec(n)?.[1]??"",i=m$(r("background-image")),o=/@(\d+)-/.exec(i)?.[1],s=/@fill-\d+\.png$/.test(i)?"fill":o?Number(o):r("background-image-fit")==="cover"?"fill":100,a=r("background-image-position").replace("center-center","center")||"center",c=Number(r("background-image-opacity")||1);return{...s!=="fill"?{size:s}:{},...a!==Zd?{position:a}:{},...Number.isFinite(c)&&c!==e.opacity?{opacity:c}:{}}}function wa(t,e,n,r,i){let o=n.size??"fill",s=n.position??Zd,a=n.opacity??e.opacity;if(o==="fill"&&s===Zd&&a===e.opacity)return;let c=qt.indexOf(s)+1,u=Y(t,`${e.stem}.png`),f=Y(t,e.fill),l=!0,d=typeof o==="number"&&(o>100||!r&&s!=="center");if(o===100&&!d)f=u,l=!1;else if(typeof o==="number"){if(Do(e))throw Error(`${e.stem} was drawn before pictures kept their tone — init draws it again`);let m=Gt(new Uint8Array(zo(u))),{width:p,height:b}=d?ba:m,$=d?Number(/@fill-(\d+)\.png$/.exec(e.fill)?.[1]??50):-1,k=Yo(m.width,m.height,p,b,o,c,!1,$);f=Y(t,`${e.stem}@${o}-${s}${d?`-${p}x${b}`:""}.png`);let S={crop:{x:0,y:0,w:m.width,h:m.height},at:k,focus:$};C(f,e.tone?Ri(na(fu(Pi(m),S,p,b)),e.tone):Ke(th(m,S,p,b))),l=d}let h=Y(t,`${e.stem}.tune.conf`);return C(h,[`background-image = ${f.startsWith(`${i}/`)?`~${f.slice(i.length)}`:f}`,`background-image-fit = ${l?"cover":"contain"}`,`background-image-position = ${s}`,`background-image-opacity = ${a}`,""].join(`
|
|
247
|
+
`)),h}function P$(t){let e=new Map;for(let[n,r]of Object.entries(Nt(X(t)).palettes)){let[,i,o]=/^([a-z.]+)_(\d+)$/.exec(r.active)??[];if(i&&o)e.set(n,{site:i,id:Number(o)})}return e}function R$(t){try{let e=yn(new Uint8Array(zo(t)));return e?{width:e.width,height:e.height}:void 0}catch{return}}function N$(t,e,n,r,i,o,s){let a=[n.original,n.cut].map((c)=>{if(!c)return"";try{let{size:u,mtimeMs:f}=zN(Y(t,c));return`${c}:${u}:${f}`}catch{return}});if(!n.original||a.includes(void 0))return;return U0([DN,ue(e),n.key,...a,r.width,r.height,i,o,o==="tone"?s:""])}function lA(t,e,n){if(!n.window||n.blur===void 0)return;let r=N$(t,e,n,n.window,n.blur,ze(n),n.tone??"");if(!r||W0(r))return;try{_d(r,{stem:n.stem,fill:n.fill,...n.peak?{peak:n.peak}:{},figure:zo(Y(t,`${n.stem}.png`)),picture:zo(Y(t,n.fill))})}catch{}}function A$(t,e,n,r,i,o,s,a,c){let u=c?void 0:N$(t,e,n,r,s,a,o.hue.color),f=u?K0(u):void 0;if(f)return{made:{stem:f.stem,fill:f.fill,files:[[`${f.stem}.png`,f.figure],[f.fill,f.picture]]},peak:f.peak,image:void 0};let l=i();if(!l)return null;let d=k$(l,r.width,r.height,s,a),h=O$(e,n.key,d,o.hue.color),m=d.coloring==="original"?d.peak:void 0;if(u)_d(u,{stem:h.stem,fill:h.fill,...m?{peak:m}:{},figure:h.files[0]?.[1],picture:h.files[1]?.[1]});return{made:h,peak:m,image:l}}function $a(t,e,n,r,i,o,s,a,c,u=ze(n)){let f=X(t),l=n.window??R$(Y(f,n.fill))??ba,d=A$(f,e,n,l,r,i,o,u,c);if(!d)return null;let{made:h,peak:m,image:p}=d,b={...n,stem:h.stem,fill:h.fill,...I$(i.colors,i.hue,u,m),blur:o,window:l,...c?{cut:`${Vd(e,n.key)}.cut.png`}:{}};if(u==="original")delete b.tone;else delete b.peak;if(c&&p)C(Y(f,`${Vd(e,n.key)}.cut.png`),Id(Pi(p)));if(h.stem===n.stem)return b;if(ze(n)!==u)lA(f,e,n);ih(f,h.files);let $=oh(f,n);wa(f,b,ze(n)===u?$:{...$,opacity:void 0},s,a);let k=Y(f,`${n.stem}.off.conf`);if(Xd(k))UN(k,Y(f,`${b.stem}.off.conf`));return b}function T$(t,e,n,r,i,o,s){let a=X(t),c=n.window??R$(Y(a,n.fill))??ba;return A$(a,e,n,c,r,i,o,s,!1)!==null}function sh(t,e){let n=X(t),r=Nt(n),i=new Set,o=[];for(let{name:s,picture:a}of e){let c=r.palettes[s],u=c?.pictures.findIndex((l)=>l.key===a.key)??-1,f=c?.pictures[u];if(!c||!f)continue;if(c.pictures[u]=a,i.add(s),f.stem!==a.stem)o.push(f.stem)}if(i.size===0)return;_i(n,r,[...i]);for(let s of o)rh(n,s)}function fA(t,e,n,r){let i=M$(t,n.stem).filter((a)=>a.endsWith(".png")).map((a)=>{let c=new Uint8Array(zo(Y(t,a)));return[a,Yc(c,r.color)??Ri(Pi(Gt(c)),r.color)]}),o=(a)=>i.find(([c])=>c===a)?.[1]??new Uint8Array,s=`${ue(e)}.${d$("sha1").update(n.key).update(o(`${n.stem}.png`)).update(o(n.fill)).digest("hex").slice(0,8)}`;ih(t,i.map(([a,c])=>[s+a.slice(n.stem.length),c]));for(let a of["tune","off"]){let c=ji(Y(t,`${n.stem}.${a}.conf`));if(c!==void 0)C(Y(t,`${s}.${a}.conf`),c.split(n.stem).join(s))}return{...n,stem:s,fill:s+n.fill.slice(n.stem.length),tone:r.color}}function f$(t,e){return ze(t)!=="original"&&t.tone!==void 0&&t.tone!==e.hue.color}function H$(t,e){let n=X(t),r=Nt(n),i=[],o=[];for(let[s,a]of Object.entries(r.palettes)){let c=e.get(s);if(!c||!a.pictures.some((u)=>f$(u,c)))continue;a.pictures=a.pictures.map((u)=>{if(!f$(u,c))return u;let f=fA(n,s,u,c.hue);if(f.stem!==u.stem)o.push(u.stem);return f}),i.push(s)}if(i.length>0){_i(n,r,i);for(let s of o)rh(n,s)}return i}var dA=1;function an(t){let{slot:e,color:n,opacity:r}=En({name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,ansi:t.ansi,waived:t.waive},t.signatureSlots);return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},...t.lead?{lead:!0}:{},order:t.order,ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},...t.role==="default"?{default:!0}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,signature:t.signature,signatureSlots:t.signatureSlots,ansi:t.ansi,gate:wn(t),...t.waive.length>0?{waived:t.waive}:{},backdrop:{slot:e,color:n,opacity:r},...t.pictures?{pictures:t.pictures}:{}}}function Fe(t){return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},lead:t.lead===!0,order:t.order,...t.default?{role:"default"}:{},ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selectionBackground:t.selection,ansi:t.ansi,signature:t.signature,signatureSlots:t.signatureSlots,ghostty:{iconGhost:t.cursor,iconScreen:[t.cursor,t.selection,t.background]},waive:t.waived??[],...t.pictures?{pictures:t.pictures}:{}}}var hA=6,mA=["ansi1","ansi2","ansi4","ansi3","ansi5","ansi6"];function pu(t){let e=(o)=>o.startsWith("ansi")?t.ansi[Number(o.slice(4))]:o==="foreground"?t.foreground:o==="cursor"?t.cursor:o==="selection"?t.selection:void 0,n=(o)=>o.startsWith("ansi")?`ansi${Number(o.slice(4))%8}`:o,r=new Set,i=[];for(let o of["foreground",...t.signatureSlots,...mA]){let s=e(o);if(i.length===hA||!s||r.has(n(o))||i.includes(s))continue;r.add(n(o)),i.push(s)}return i}function At(t){return t.filter((e)=>e.default!==!0)}function gu(){return{schema:dA,version:lt.version,gate:Pe,palettes:[]}}import{existsSync as pA,readFileSync as wu,statSync as F$}from"node:fs";import{homedir as Qo}from"node:os";import{join as Zo}from"node:path";var gA=["core","kowiki","unlicensed"],bA=["ko","ja","en","zh","other"],j$=["keys","keyAt","ownAt","owners","cards","cardAt","ranks","tags","tagAt","tagCard"],_$="TTNI";function Br(t=Qo()){return Zo(process.env.XDG_CACHE_HOME??Zo(t,".cache"),"ttheme","aninames")}var wA=/[ァ-ヶ]/g,$A=/[\s\p{P}\p{S}]+/gu;function Xo(t){return t.normalize("NFKC").toLowerCase().replace(wA,(e)=>String.fromCharCode(e.charCodeAt(0)-96)).replace($A,"")}function Gi(t,e){let n=Xo(e);if(n===""){let r=e.toLowerCase();return t.some((i)=>i.toLowerCase().includes(r))}return t.some((r)=>Xo(r).includes(n))}function lh(t){return t.length>=2||/[\p{Script=Han}\p{Script=Hangul}\p{Script=Hiragana}]/u.test(t)}function G$(t){let e=Br(t);return gA.map((n)=>Zo(e,`ttheme-${n}.json`)).filter((n)=>pA(n))}var kA=6;function B$(t){return[`format ${kA}`,...t.map((e)=>`${e}:${F$(e).size}:${F$(e).mtimeMs}`)].join("|")}function yA(t){try{return JSON.parse(wu(t,"utf8"))}catch{return{}}}function vA(t){let e=new Map;for(let i of t)for(let[o,s]of Object.entries(yA(i))){let a=e.get(o)??{tags:new Set,names:[],japanese:[],generated:[],rank:0,weight:0,posts:0};a.posts=Math.max(a.posts,s.posts??0),a.generated.push(...s.generated??[]),a.japanese.push(...s.names?.ja??[]),a.tag??=s.tag;for(let c of s.danbooru??[])a.tags.add(c);for(let c of bA)a.names.push(...s.names?.[c]??[]);if(s.rank!==void 0){let c=s.weight??1;a.rank=(a.rank*a.weight+s.rank*c)/(a.weight+c),a.weight+=c}e.set(o,a)}let n=[],r=Math.log1p([...e.values()].reduce((i,o)=>Math.max(i,o.posts),1));for(let i of e.values()){if(i.tags.size===0)continue;let o=[...i.tags];n.push({tag:i.tag&&i.tags.has(i.tag)?i.tag:o[0],tags:o,names:[...new Set(i.names)],japanese:[...new Set(i.japanese)],generated:[...new Set(i.generated)],rank:i.posts>0?Math.log1p(i.posts)/r:i.rank})}return n}function ka(t,e){let n=new t(e.length);return n.set(e),n}function ah(t){let e=[0];for(let n of t)e.push(e.at(-1)+n.length);return{bytes:Buffer.concat(t),at:ka(Uint32Array,e)}}function SA(t,e){let n=vA(t),r=new Map,i=(v,S,x)=>{let M=r.get(v),P=S*4+x;if(!M)r.set(v,[P]);else if(M.at(-1)>>>2!==S)M.push(P);else if(M.at(-1)<P)M[M.length-1]=P};n.forEach((v,S)=>{let x=[...v.names,...v.tags.map((M)=>M.replaceAll("_"," "))];for(let[M,P]of[[x,1],[v.generated,0]])for(let L of M){let A=Xo(L);if(A&&lh(A))i(A,S,2|P);let _=L.split(/[\s・·_]+/);if(_.length<2)continue;for(let q of _){let B=Xo(q);if(B&&lh(B))i(B,S,P)}}});let o=[...r.keys()].sort(),s=[0],a=[];for(let v of o){for(let S of r.get(v)??[])a.push(S);s.push(a.length)}let c=n.flatMap((v,S)=>v.tags.map((x)=>[x,S])).sort(([v],[S])=>v<S?-1:v>S?1:0),u=ah(o.map((v)=>Buffer.from(v))),f=ah(n.map((v)=>Buffer.from(JSON.stringify([v.tag,v.tags,v.names,v.japanese,v.generated])))),l=ah(c.map(([v])=>Buffer.from(v))),d={keys:u.bytes,keyAt:u.at,ownAt:ka(Uint32Array,s),owners:ka(Uint32Array,a),cards:f.bytes,cardAt:f.at,ranks:ka(Float32Array,n.map((v)=>v.rank)),tags:l.bytes,tagAt:l.at,tagCard:ka(Uint32Array,c.map(([,v])=>v))},h=j$.map((v)=>{let S=d[v];return Buffer.from(S.buffer,S.byteOffset,S.byteLength)}),m=0,p=h.map((v)=>{let S=[m,v.length];return m+=Math.ceil(v.length/4)*4,S}),b=Buffer.from(JSON.stringify({stamp:e,sections:p})),$=Math.ceil((8+b.length)/4)*4,k=Buffer.alloc($+m);k.write(_$,0,"latin1"),k.writeUInt32LE(b.length,4),b.copy(k,8);for(let[v,S]of h.entries())S.copy(k,$+(p[v]?.[0]??0));return k}function L$(t,e,n,r){let i=e.byteOffset+n;if(i%4===0)return new t(e.buffer,i,r/4);return new t(e.buffer.slice(i,i+r),0,r/4)}function C$(t,e){if(t.toString("latin1",0,4)!==_$)return;let n=t.readUInt32LE(4),r=JSON.parse(t.toString("utf8",8,8+n));if(r.stamp!==e)return;let i=Math.ceil((8+n)/4)*4,o=(c)=>{let[u,f]=r.sections[j$.indexOf(c)];return[i+u,f]},s=(c)=>{let[u,f]=o(c);return t.subarray(u,u+f)},a=(c)=>L$(Uint32Array,t,...o(c));return{keys:s("keys"),keyAt:a("keyAt"),ownAt:a("ownAt"),owners:a("owners"),cards:s("cards"),cardAt:a("cardAt"),ranks:L$(Float32Array,t,...o("ranks")),tags:s("tags"),tagAt:a("tagAt"),tagCard:a("tagCard")}}var ch;function fh(t){try{let e=G$(t);if(e.length===0)return;let n=B$(e);if(ch?.stamp===n)return ch.index;let r=Zo(Br(t),"index.bin"),i;try{i=C$(wu(r),n)}catch{}if(!i){let o=SA(e,n);try{C(r,o)}catch{}i=C$(o,n)}if(i)ch={stamp:n,index:i};return i}catch{return}}function U$(t,e){let[n,r,i,o,s]=JSON.parse(t.cards.toString("utf8",t.cardAt[e],t.cardAt[e+1]));return{tag:n,tags:r,names:i,japanese:o,generated:s,rank:t.ranks[e]??0}}function W$(t,e,n,r){let i=0,o=n;while(i<o){let s=i+o>>1;if(t.toString("utf8",e[s],e[s+1])<r)i=s+1;else o=s}return i}function K$(t,e){let n=Buffer.from(e),r=t.tagCard.length,i=W$(t.tags,t.tagAt,r,e);if(i>=r||t.tags.compare(n,0,n.length,t.tagAt[i],t.tagAt[i+1])!==0)return;return t.tagCard[i]}var uh=/\s*[((][^()()]*[))]$/u,bu={ko:4,en:4,ja:5,zh:3};function EA(t){if(!t)return[];let e=/\p{Script=Hangul}/u,n=/^[\p{Script=Latin}\p{N}\s.'’-]+$/u,r=new Set([...t.names,...t.generated].filter((l)=>!uh.test(l))),i=(l)=>!uh.test(l)||!r.has(l.replace(uh,"")),o=t.names.filter(i),s=o.filter((l)=>e.test(l)),a=[...s,...t.generated.slice(0,s.length>0?0:2)],c=o.filter((l)=>n.test(l)),u=t.japanese.filter(i),f=o.filter((l)=>!e.test(l)&&!n.test(l)&&!u.includes(l));return[...new Set([...a.slice(0,bu.ko),...c.slice(0,bu.en),...u.slice(0,bu.ja),...f.slice(0,bu.zh)])]}var Vo;function $u(t,e=Qo()){if(!t)return[];if(!Vo)try{Vo=JSON.parse(wu(Zo(Br(e),"aliases.json"),"utf8")).tags}catch{Vo={}}return Vo[t]??[]}function dh(t,e=Qo()){try{return MA(t,e)}catch{return new Map}}function MA(t,e){let n=new Map,r=G$(e);if(r.length===0||t.length===0)return n;let i=B$(r),o=Zo(Br(e),"aliases.json"),s;try{s=JSON.parse(wu(o,"utf8"))}catch{}if(s?.stamp===i&&t.every((f)=>(f in s.tags))){Vo=s.tags;for(let f of t)n.set(f,s.tags[f]??[]);return n}let a=fh(e);if(!a)return n;let c=new Set([...t,...s?.stamp===i?Object.keys(s.tags):[]]),u={};for(let f of c){let l=K$(a,f);u[f]=l===void 0?[]:EA(U$(a,l))}try{C(o,`${JSON.stringify({stamp:i,tags:u})}
|
|
248
|
+
`)}catch{}Vo=u;for(let f of t)n.set(f,u[f]??[]);return n}function Bi(t,e=Qo()){dh(t.flatMap((n)=>n.booru?[n.booru]:[]),e)}var xA=0.25,OA=0.1;function z$(t,e,n=new Set,r=Qo()){let i=Xo(t);if(!i||!lh(i))return[];let o=fh(r);if(!o)return[];let s=Buffer.from(i),a=o.ownAt.length-1,c=new Set([...n].flatMap((f)=>K$(o,f)??[])),u=new Map;for(let f=W$(o.keys,o.keyAt,a,i);f<a;f++){let l=o.keyAt[f],d=o.keyAt[f+1]-l;if(d<s.length||o.keys.compare(s,0,s.length,l,l+s.length)!==0)break;let h=d===s.length;for(let m=o.ownAt[f];m<o.ownAt[f+1];m++){let p=o.owners[m],b=p>>>2,$=h?Math.max(0,(p&2?2:1)-(p&1?0:1)):0,k=(o.ranks[b]??0)+xA*$+(c.has(b)?OA:0);if((u.get(b)?.score??-1)<k)u.set(b,{score:k,key:f})}}return[...u].sort(([,f],[,l])=>l.score-f.score).slice(0,e).map(([f,{key:l}])=>{let d=U$(o,f),h=o.keys.toString("utf8",o.keyAt[l],o.keyAt[l+1]);return{tag:d.tags.find((m)=>n.has(m))??d.tag,name:[...d.names,...d.generated].find((m)=>Xo(m).includes(h))??d.tag.replaceAll("_"," ")}})}function ku(t=Qo()){fh(t)}import{createHash as CA}from"node:crypto";import{existsSync as jA,readdirSync as ek,readFileSync as _A}from"node:fs";import{basename as nk,join as Su}from"node:path";import{existsSync as IA,readFileSync as q$}from"node:fs";import{homedir as D$}from"node:os";import{isAbsolute as J$,join as Ui,resolve as PA}from"node:path";var V="official",Bt="ttheme-market.toml",RA="https://www.schemastore.org/ttheme-market.json",Y$="https://www.schemastore.org/ttheme-palette.json",V$=["$schema","name","description","owner","renames","force_remove_deleted_palettes","metadata"],Z$=["name","email","url"],ts="ttheme-market",NA=/^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}$/i,AA=/^[\w.-]{1,100}$/,TA=/^\w[\w.+/-]{0,199}$/;function Qn(t){return Ui(t,"ttheme","installed.json")}function Dt(t){return t??[V]}function es(t){try{let{markets:e}=JSON.parse(q$(Qn(t),"utf8"));return Dt(Array.isArray(e)?e.filter((n)=>typeof n==="string"):void 0)}catch{return[V]}}function Tt(t){return J$(t)}function kt(t){return t!==V&&!Tt(t)}function Ur(t){let e=t.indexOf("#");return kt(t)&&e>=0?t.slice(0,e):t}function ya(t){let e=t.indexOf("#");return kt(t)&&e>=0?t.slice(e+1):void 0}function ns(t,e){return Ur(t)===Ur(e)}function Wr(t,e){return kt(t)&&(e?.[t]??!1)}function HA(t){return!TA.test(t)||t.includes("..")||t.includes("//")||/(?:[./]|\.lock)$/.test(t)}function Kr(t,e=process.cwd()){if(t===V)return V;if(t==="~"||t.startsWith("~/"))return Ui(D$(),t.slice(1));if(t.startsWith(".")||J$(t))return PA(e,t);let[n="",r,...i]=t.split("#"),[o,s,...a]=n.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("/");if(!o||!NA.test(o)||!s||!AA.test(s)||a.length>0||i.length>0||r!==void 0&&HA(r))throw Error(`${t} is not a market — give a repository (alice/ttheme-dust, #v1 pins a tag or branch) or a path (./my-market)`);return`${o.toLowerCase()}/${s}${r===void 0?"":`#${r}`}`}function X$(t){let e=ya(t)?.split("/").map(encodeURIComponent).join("/")??"HEAD";return`https://codeload.github.com/${Ur(t)}/tar.gz/${e}`}function Q$(t){return t.slice(0,t.indexOf("/"))}function ph(t){return Ui(t,"ttheme","markets")}function tr(t,e){return Ui(ph(t),`${Ur(e).replace("/","--")}.json`)}function yu(t){return Ui(t,"ttheme","market")}function gh(t,e){return Ui(yu(t),e)}function FA(t,e){if(typeof t!=="string"||typeof e!=="string")return'needs a "name" and an [owner] table whose name is the GitHub handle';return Te(`${t}@${e}/x`)}function be({owner:t,name:e}){return`${t}@${e}`}function tk({owner:t,name:e}){return`"$schema" = ${JSON.stringify(RA)}
|
|
249
249
|
name = ${JSON.stringify(e)}
|
|
250
250
|
|
|
251
251
|
[owner]
|
|
252
252
|
name = ${JSON.stringify(t)}
|
|
253
|
-
`}function
|
|
254
|
-
`)[0]}`)}let r=
|
|
255
|
-
`);return[]}})}function
|
|
256
|
-
`):()=>{}}function
|
|
253
|
+
`}function mh(t,e,n,r){if(typeof n!=="string"||n===""||/\p{Cc}/u.test(n)||n.length>200)throw Error(`${t}: ${e} must be ${r}`);return n}function hh(t,e,n){return n===void 0?void 0:mh(t,e,n,"one line of text, 200 characters at most")}function LA(t,e){if(e===void 0)return{};if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`${t}: [renames] maps an old palette name to its new name, or to false once it is gone`);let n={};for(let[r,i]of Object.entries(e)){if(Te(r)||i!==!1&&(typeof i!=="string"||Te(i)))throw Error(`${t}: renames.${r} must map a palette name to a palette name, or to false`);n[r]=i}return n}function bh(t,e){let n;try{n=Hi(t)}catch(d){throw Error(`${e} is not valid TOML — ${d.message.split(`
|
|
254
|
+
`)[0]}`)}let r=mh(e,"name",n.name,"the market name"),i=n.owner;if(!i||typeof i!=="object"||Array.isArray(i))throw Error(`${e}: owner is a table — [owner] with name = "<GitHub handle>"`);let o=i,s={name:mh(e,"owner.name",o.name,"the GitHub handle")},a=hh(e,"owner.email",o.email),c=hh(e,"owner.url",o.url),u=hh(e,"description",n.description),f=n.force_remove_deleted_palettes;if(f!==void 0&&typeof f!=="boolean")throw Error(`${e}: force_remove_deleted_palettes must be true or false`);let l=FA(s.name,r);if(l)throw Error(`${e} ${l}`);return{owner:s.name,name:r,about:{...s,...a?{email:a}:{},...c?{url:c}:{}},...u?{description:u}:{},renames:LA(e,n.renames),forceRemove:f===!0}}function cn(t){let e=Ui(t,Bt);if(!IA(e))throw Error(`${t} has no ${Bt} — \`ttheme market init ${t}\` makes one`);return bh(q$(e,"utf8"),e)}function rt(t){if(t===V)return"the ttheme catalog";if(!Tt(t))return`github.com/${t}`;let e=D$();return t===e||t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t}var va="tt2:",kh="https://ttheme.vercel.app/p/",vu=4,rk=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)];function Wi(t,e=!0){return es(t).filter(Tt).flatMap((n)=>{try{let r=cn(n);return[{dir:n,...r,id:be(r)}]}catch(r){if(e)process.stderr.write(`ttheme: skipping the market at ${n} — ${r.message}
|
|
255
|
+
`);return[]}})}function Eu(t){return Su(t,"palettes")}function wh(t,e){return t<e?-1:t>e?1:0}function yh(t,e){let n=[],r=[];for(let i of t){let[o,s,a,...c]=i.split("/");if(o!=="palettes"||!s||s.startsWith(".")||c.length>0)continue;if(a===void 0){if(s.endsWith(".toml"))r.push({file:{path:e(i),slug:nk(s,".toml")},name:s})}else if(a.endsWith(".toml"))n.push({file:{path:e(i),slug:nk(a,".toml"),catalog:s},name:a})}return n.sort((i,o)=>wh(i.file.catalog??"",o.file.catalog??"")||wh(i.name,o.name)),r.sort((i,o)=>wh(i.name,o.name)),[...n,...r].map(({file:i})=>i)}function rs(t){let e=Eu(t);if(!jA(e))return[];let n=ek(e,{withFileTypes:!0}).flatMap((r)=>r.isDirectory()?ek(Su(e,r.name)).map((i)=>`palettes/${r.name}/${i}`):[`palettes/${r.name}`]);return yh(n,(r)=>Su(t,r))}function GA(t,e){let n=e.get(t.slug);if(n)return`${t.slug} is also ${n.catalog?`in ${n.catalog}`:"outside a catalog"} — a palette name is used once in a market`;let r=t.catalog===void 0?void 0:ga(t.catalog);return r?`the catalog folder ${JSON.stringify(t.catalog)} ${r}`:void 0}function vh(t,e){let n=ut(e);if(!n)throw Error(`${e} is an official palette — yours are named <you>@<market>/<palette>`);let r=Wi(t,!1).find((o)=>o.id===n);if(!r)throw Error(`${n} is not a local market — \`ttheme market add <dir>\` adds the folder that holds it`);let i=pe(e);return rs(r.dir).find((o)=>o.slug===i)?.path??Su(Eu(r.dir),`${i}.toml`)}function BA(t,e,n=!1){let r=new Map;for(let o of e)if(o.group!==ha&&!r.has(o.group)){let s=e.find((a)=>a.group===o.group&&a.lead)?.name??"";r.set(o.group,{name:o.group,...o.native?{native:o.native}:{},lead:s})}let i=new Map(e.filter((o)=>!o.default&&!ut(o.name)).map((o)=>[o.name,{group:o.group,order:o.order}]));return{name:t,groups:r,bases:i,open:!0,...n?{foreign:!0}:{}}}function Mn(t,e,n,r=!1){let i=pe(t),{native:o,...s}=zd(`${i}.toml`,e,BA(i,n,r)),a=ut(t);return{...s,name:t,...a?{group:a,lead:!1}:{}}}function fe(t){return t?(e,n)=>process.stderr.write(`ttheme: skipping ${e} — ${n}
|
|
256
|
+
`):()=>{}}function Sh(t,e,n,r,i,o=!1){let s=new Map;return t.flatMap((a)=>{try{let c=GA(a,s);if(c)throw Error(c);s.set(a.slug,a);let u=an(Mn(`${n}/${a.slug}`,e(a),r,o));return[a.catalog?{...u,catalog:a.catalog}:u]}catch(c){return i(a.path,c.message),[]}})}function xn(t,e,n,r=fe(!0)){return Sh(rs(t),(i)=>_A(i.path,"utf8"),e,n,r)}function Mu(t,e,n=!0){return Wi(t,n).flatMap(({dir:r,id:i})=>xn(r,i,e,fe(n)))}function Eh(t,e=t.name,n){return{name:e,...t.base?{base:t.base}:{},...t.group!==ha?{group:t.group}:{},ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},signature:t.signatureSlots,background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selection,ansi:t.ansi,...t.waived&&t.waived.length>0?{waive:t.waived,reason:n??"kept from the palette"}:{},...t.pictures?{pictures:t.pictures}:{}}}var It=(t)=>JSON.stringify(t);function ik(t){return["[[picture]]",`site = ${It(t.site)}`,`id = ${t.id}`,...t.size===void 0?[]:[`size = ${typeof t.size==="number"?t.size:It(t.size)}`],...t.position===void 0?[]:[`position = ${It(t.position)}`],...t.opacity===void 0?[]:[`opacity = ${t.opacity}`]]}function ok(t,e){return e.length===0?t:`${t.replace(/\n*$/,`
|
|
257
257
|
`)}${e.map((n)=>`
|
|
258
|
-
${
|
|
258
|
+
${ik(n).join(`
|
|
259
259
|
`)}
|
|
260
|
-
`).join("")}`}function
|
|
260
|
+
`).join("")}`}function Mh(t){let e=[`"$schema" = ${It(Y$)}`,"","[meta]",`name = ${It(pe(t.name))}`,...t.base?[`base = ${It(t.base)}`]:[],...t.group?[`group = ${It(t.group)}`]:[],...t.ansiSource?[`ansi_source = ${It(t.ansiSource)}`]:[],...t.booru?[`booru = ${It(t.booru)}`]:[],`signature = [${t.signature.map(It).join(", ")}]`,...t.booruSites?["","[meta.booru_sites]",...Object.entries(t.booruSites).map(([n,r])=>`${n} = [${r.map(It).join(", ")}]`)]:[],"","[colors]",`background = ${It(t.background)}`,`foreground = ${It(t.foreground)}`,`cursor = ${It(t.cursor)}`,`selection_background = ${It(t.selection)}`,"ansi = [",...t.ansi.slice(0,8).map((n)=>` ${It(n)},`),"",...t.ansi.slice(8).map((n)=>` ${It(n)},`),"]"];if(t.waive&&t.waive.length>0)e.push("","[contrast]",`waive = [${t.waive.map(It).join(", ")}]`,`reason = ${It(t.reason??"")}`);for(let n of t.pictures??[])e.push("",...ik(n));return`${e.join(`
|
|
261
261
|
`)}
|
|
262
|
-
`}class
|
|
263
|
-
`)}function
|
|
264
|
-
`)}function
|
|
265
|
-
`);return[]}}function zr(t){let e;try{e=JSON.parse(t)}catch{throw Error("catalog is not valid JSON")}let n=e;if(typeof n?.version!=="string"||!Array.isArray(n.palettes))throw Error("catalog has no version or palettes");for(let r of n.palettes){let i=
|
|
266
|
-
`)}function qr(t){try{let{palettes:e}=JSON.parse(
|
|
267
|
-
`),f=!1;for(let l=0;l<u.length;l++){let d=u[l];if(r+=d,!f){if(f=d>="\uD800"&&d<="\uDBFF",f)continue}else f=!1;if(d===
|
|
268
|
-
`){if(o)r+=
|
|
269
|
-
`){if(i&&
|
|
270
|
-
`)}var
|
|
271
|
-
`),o=0,s=t;for(let c of i){if(s<=c.length)break;s-=c.length+1,o++}for(o=Math.max(0,Math.min(i.length-1,o+n)),s=Math.min(s,i[o].length)+e;s<0&&o>0;)o--,s+=i[o].length+1;for(;s>i[o].length&&o<i.length-1;)s-=i[o].length+1,o++;s=Math.max(0,Math.min(i[o].length,s));let a=0;for(let c=0;c<o;c++)a+=i[c].length+1;return a+s}var
|
|
262
|
+
`}class sk{bytes=[];u8(t){this.bytes.push(t&255)}u16(t){this.u8(t>>8),this.u8(t)}u32(t){this.u16(Math.floor(t/65536)),this.u16(t%65536)}str(t=""){let e=new TextEncoder().encode(t);if(e.length>255)throw Error(`"${t}" is too long to share`);this.u8(e.length),this.bytes.push(...e)}color(t){let e=Number.parseInt(t.slice(1),16);this.u8(e>>16),this.u8(e>>8),this.u8(e)}done(){let t=Buffer.from(this.bytes);return Buffer.concat([t,ck(t)]).toString("base64url")}}class ak{at=0;bytes;constructor(t){this.bytes=t}u8(){let t=this.bytes[this.at++];if(t===void 0)throw Error("the share code is cut short");return t}u16(){return this.u8()*256+this.u8()}u32(){return this.u16()*65536+this.u16()}str(){let t=this.u8(),e=this.bytes.subarray(this.at,this.at+t);if(e.length!==t)throw Error("the share code is cut short");this.at+=t;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{throw Error("the share code holds text it cannot read — was it copied whole?")}}color(){return`#${[this.u8(),this.u8(),this.u8()].map((t)=>t.toString(16).padStart(2,"0")).join("")}`}end(){if(this.at!==this.bytes.length)throw Error("the share code has bytes left over")}}function ck(t){return CA("sha256").update(t).digest().subarray(0,vu)}function $h(t){return/^tt\d+:/.test(t)}function uk(t){return`${kh}${t}`}function is(t){let e=t.trim();if(!/^https?:\/\//i.test(e))return $h(e)?e:void 0;let r=(URL.canParse(e)?/^\/p\/([^/]+)\/?$/.exec(new URL(e).pathname)?.[1]:void 0)?.replace(/%3a/gi,":");return r&&$h(r)?r:void 0}function lk(t,e){let n=Oh(t);return an(Mn(n.name,Mh(n),e,!0))}function xh(t){let e=new sk;e.str(t.name);for(let r of[t.background,t.foreground,t.cursor,t.selection,...t.ansi])e.color(r);for(let r of t.signature)e.u8(rk.indexOf(r));e.str(t.base),e.str(t.group),e.str(t.ansiSource),e.str(t.booru),e.u16((t.waive??[]).reduce((r,i)=>r|1<<ld.indexOf(i),0)),e.str(t.waive&&t.waive.length>0?t.reason:"");let n=t.pictures??[];if(n.length>255)throw Error(`a share code carries at most 255 pictures, and ${t.name} holds ${n.length}`);e.u8(n.length);for(let r of n)e.u8(Z.findIndex((i)=>i.key===r.site)),e.u32(r.id),e.u16(r.size===void 0?0:r.size==="fill"?1:r.size),e.u8(r.position===void 0?0:qt.indexOf(r.position)+1),e.u16(r.opacity===void 0?0:Math.round(r.opacity*1000)+1);return`${va}${e.done()}`}function Oh(t){if(!t.startsWith(va))throw Error($h(t)?`this ttheme reads ${va} share codes, not ${t.slice(0,t.indexOf(":")+1)}`:`a share code starts with ${va}`);let e=t.slice(va.length);if(!/^[A-Za-z0-9_-]+$/.test(e))throw Error("the share code holds characters it never uses — was it copied whole?");let n=Buffer.from(e,"base64url");if(n.length<=vu)throw Error("the share code is cut short");let r=n.subarray(0,-vu);if(!ck(r).equals(n.subarray(-vu)))throw Error("the share code does not add up — was it copied whole?");let i=new ak(new Uint8Array(r)),o=i.str(),[s,a,c,u,...f]=Array.from({length:20},()=>i.color()),l=[i.u8(),i.u8(),i.u8()].map((S)=>rk[S]??`slot${S}`),d=i.str(),h=i.str(),m=i.str(),p=i.str(),b=i.u16(),$=i.str(),k=ld.filter((S,x)=>b&1<<x),v=Array.from({length:i.u8()},()=>{let S=Z[i.u8()]?.key??"unknown",x=i.u32(),M=i.u16(),P=i.u8(),L=i.u16();return{site:S,id:x,...M===1?{size:"fill"}:M>1?{size:M}:{},...P>0?{position:qt[P-1]??"unknown"}:{},...L>0?{opacity:(L-1)/1000}:{}}});if(i.end(),![s,a,c,u,...f].every(he))throw Error("the share code holds a color that is not one");return{name:o,...d?{base:d}:{},...h?{group:h}:{},...m?{ansiSource:m}:{},...p?{booru:p}:{},signature:l,background:s,foreground:a,cursor:c,selection:u,ansi:f,...k.length>0?{waive:k,reason:$}:{},...v.length>0?{pictures:v}:{}}}function os(t){return{background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,ansi:t.ansi}}function Ih(t,e){let n=t.indexOf("ansi = ["),r=t.indexOf("]",n);if(n<0||r<0)throw Error("no ansi = [...] list to rewrite");let i=0,o=t.slice(n,r).replace(/"#[0-9a-fA-F]{6}"/g,()=>It(e.ansi[i++]));return[["background",e.background],["foreground",e.foreground],["cursor",e.cursor],["selection_background",e.selection]].reduce((a,[c,u])=>a.replace(new RegExp(`^(${c}\\s*=\\s*)"#[0-9a-fA-F]{6}"`,"m"),(f,l)=>`${l}${It(u)}`),t.slice(0,n)+o+t.slice(r))}function fk(t,e){return t.replace(/^(signature\s*=\s*)\[[^\]]*\]/m,(n,r)=>`${r}[${e.map(It).join(", ")}]`)}function Sa(t){let e=wn(Fe(t)),n=new Set(t.waived??[]),r=Math.max(...Pe.map((i)=>i.label.length));return Pe.map((i,o)=>{let s=e[o],a=n.has(i.rule)||Number.isNaN(s)||(i.min===void 0||s>=i.min)&&(i.max===void 0||s<=i.max),c=i.min!==void 0?`≥ ${i.min}`:i.max!==void 0?`≤ ${i.max}`:"",u=Number.isNaN(s)?"—":Number.isInteger(s)?String(s):s.toFixed(2);return` ${a?"✓":"✗"} ${i.label.padEnd(r)} ${u.padStart(6)} ${c}${n.has(i.rule)?" waived":""}`})}import{existsSync as UA,readFileSync as WA,rmSync as KA}from"node:fs";import{join as zA}from"node:path";var Ma=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)],qA=1;function dk(t){return zA(t,"ttheme","tone.json")}function hk(t){return Ma.includes(t)}function Ut(t){let e=dk(t);if(!UA(e))return{};let n;try{n=JSON.parse(WA(e,"utf8"))}catch{return{}}let r=n?.palettes;if(typeof r!=="object"||r===null)return{};let i={};for(let[o,s]of Object.entries(r)){if(typeof s!=="object"||s===null)continue;let a={};for(let[c,u]of Object.entries(s))if(hk(c)&&typeof u==="string"&&he(u.toLowerCase()))a[c]=u.toLowerCase();if(Object.keys(a).length>0)i[o]=a}return i}function xa(t,e){let n=dk(t),r=Object.fromEntries(Object.entries(e).filter(([,i])=>Object.keys(i).length>0));if(Object.keys(r).length===0){KA(n,{force:!0});return}C(n,`${JSON.stringify({version:qA,palettes:r},null,2)}
|
|
263
|
+
`)}function Ea(t,e){if(e==="background"||e==="foreground"||e==="cursor"||e==="selection")return t[e];return t.ansi[Number(e.slice(4))]}function mk(t){return Ma.map((e)=>Ea(t,e))}function Ph(t,e){let n={};return Ma.forEach((r,i)=>{let o=e[i].toLowerCase();if(o!==Ea(t,r).toLowerCase())n[r]=o}),n}function Oa(t,e){if(!e)return t;let n=(u)=>e[u]===void 0||e[u]===Ea(t,u).toLowerCase();if(Ma.every(n))return t;let r=(u)=>e[u]??Ea(t,u),i={background:r("background"),foreground:r("foreground"),cursor:r("cursor"),selection:r("selection"),ansi:Ma.slice(4).map(r)},o=t.signatureSlots.map((u)=>hk(u)?r(u):Ea(i,u)),s={...t,...i,signature:o},a=Fe(s),c=En({name:s.name,background:i.background,foreground:i.foreground,cursor:i.cursor,selection:i.selection,ansi:i.ansi,waived:a.waive},s.signatureSlots);return{...s,gate:wn(a),backdrop:c}}function xu(t,e){return Object.keys(e).length===0?t:t.map((n)=>Oa(n,e[n.name]))}function Ou(t,e,n){let r={...t};if(Object.keys(n).length===0)delete r[e];else r[e]=n;return r}function pk(t,e,n){let r=Ut(t);if(!Object.keys(r).some((o)=>e.has(o)||n.includes(o)))return;xa(t,Object.fromEntries(Object.entries(r).filter(([o])=>!n.includes(o)).map(([o,s])=>[e.get(o)??o,s])))}var $k=20000;function er(t){return wk(t,"ttheme","catalog.json")}function kk(t,e){C(er(t),`${JSON.stringify(e,null,2)}
|
|
264
|
+
`)}function at(t,e=!0,n){let r=es(t),i=er(t),o=gu();if(r.includes(V))if(n)o=n;else{if(!bk(i))throw Error(`no catalog at ${i} — run \`ttheme init\` first`);o=zr(Rh(i,"utf8"))}let s=r.filter(kt).flatMap((a)=>JA(t,a,o.palettes,e));return{...o,palettes:[...o.palettes,...s]}}function DA(t){let e;try{e=JSON.parse(t)}catch{throw Error("is not valid JSON")}let n=e?.files;if(!n||typeof n!=="object"||Object.values(n).some((r)=>typeof r!=="string"))throw Error("is not a copy of a market this ttheme fetched — `ttheme update` fetches it again");return{...typeof e?.etag==="string"?{etag:e.etag}:{},files:n}}function nr(t,e){return DA(Rh(tr(t,e),"utf8"))}function yk(t,e){return be({owner:Q$(t),name:e.name})}function vk(t,e){let n=e.files[Bt];if(n===void 0)throw Error(`${rt(t)} has no ${Bt} — \`ttheme market init\` makes one`);return bh(n,Bt)}function Iu(t,e){return yk(t,vk(t,e))}function Ki(t,e,n,r){let i=vk(t,e),o=yk(t,i),s=rt(t),a=new Map(Object.entries(e.files).map(([u,f])=>[`${s}/${u}`,f])),c=yh(Object.keys(e.files),(u)=>`${s}/${u}`);return{id:o,info:i,entries:Sh(c,(u)=>a.get(u.path)??"",o,n,r,!0)}}function JA(t,e,n,r){let i=tr(t,e);if(!bk(i))return[];try{return Ki(e,nr(t,e),n,fe(!1)).entries}catch(o){if(r)process.stderr.write(`ttheme: skipping ${i} — ${o.message}
|
|
265
|
+
`);return[]}}function zr(t){let e;try{e=JSON.parse(t)}catch{throw Error("catalog is not valid JSON")}let n=e;if(typeof n?.version!=="string"||!Array.isArray(n.palettes))throw Error("catalog has no version or palettes");for(let r of n.palettes){let i=Sk(r);if(i)throw Error(`catalog entry ${JSON.stringify(r?.name)} ${i}`)}return n}function Sk(t){if(typeof t?.name!=="string"||!Array.isArray(t.ansi)||t.ansi.length!==16)return"is missing name or its 16 ANSI colors";let e=Te(t.name)??(t.base===void 0?void 0:Te(t.base));if(e)return e;if(![t.background,t.foreground,t.cursor,t.selection,...t.ansi].every((n)=>typeof n==="string"&&he(n)))return'holds a color that is not "#rrggbb"';for(let n of[t.group,t.native??"-",t.catalog??"-",t.ansiSource]){let r=typeof n==="string"?ga(n):"has a field that is not text";if(r)return r}return}function Ek(t){return wk(t,"ttheme","kept.json")}function ss(t,e){C(Ek(t),`${JSON.stringify({palettes:e},null,2)}
|
|
266
|
+
`)}function qr(t){try{let{palettes:e}=JSON.parse(Rh(Ek(t),"utf8"));return Array.isArray(e)?e.filter((n)=>Sk(n)===void 0):[]}catch{return[]}}function gk(t){return JSON.stringify([t.background,t.foreground,t.cursor,t.selection,t.ansi,t.pictures??[]])}function as(t,e){let n=new Map(qr(t).map((r)=>[r.name,r]));return e.palettes.filter((r)=>{let i=n.get(r.name);return ut(r.name)!==void 0&&i!==void 0&&gk(i)!==gk(r)})}function rr(t,e,n=!0){let r=qr(t),i=new Map(r.filter((a)=>ut(a.name)!==void 0).map((a)=>[a.name,a])),o=[...e.palettes.map((a)=>i.get(a.name)??a),...Mu(t,e.palettes,n)],s=new Set(o.map((a)=>a.name));return{...e,palettes:[...o,...r.filter((a)=>!s.has(a.name))]}}function Wt(t,e,n=!0){let r=rr(t,e,n);return{...r,palettes:xu(r.palettes,Ut(t))}}function we(t){return Wt(t,at(t))}class Pu extends Error{}class Ru extends Error{}async function Nh(t,e=$k,n,r={}){let i;try{let o=AbortSignal.timeout(e);i=await fetch(t,{headers:r,signal:n?AbortSignal.any([o,n]):o})}catch(o){throw Error(`cannot reach ${t} — ${o instanceof Error?o.message:String(o)}`)}if(i.status===404)throw new Pu(`nothing at ${t}`);if(i.status===403||i.status===429)throw new Ru(`${new URL(t).host} is turning requests away for now (${i.status}) — try again in a minute`);if(!i.ok&&i.status!==304)throw Error(`${t} answered ${i.status}`);return i}async function Mk(t,e,n=$k,r){return e(await(await Nh(t,n,r)).text())}function Ia(t){let e=new Set(t.waived??[]),n=t.gate??wn(Fe(t));return Pe.flatMap((r,i)=>{let o=n[i];if(e.has(r.rule)||typeof o!=="number"||Number.isNaN(o))return[];if(r.min!==void 0&&o<r.min)return[`${r.label} ${o} < ${r.min}`];if(r.max!==void 0&&o>r.max)return[`${r.label} ${o} > ${r.max}`];return[]})}function On(t,e){let n=t.find((r)=>r.name===e);if(!n)throw Error(`no palette named ${e} in the catalog — ${Ah(t,[e])}`);return n}function Ah(t,e){let n=e.map((s)=>s.toLowerCase()),r=t.filter((s)=>n.some((a)=>s.name.includes(a))),i=t.filter((s)=>!r.includes(s)&&n.some((a)=>s.group.toLowerCase().includes(a))),o=[...r,...i].map((s)=>s.name).slice(0,3);return o.length>0?`did you mean: ${o.join(", ")}?`:"`ttheme list` shows what is there"}function xk(t,e){return t.filter((n)=>Gi([n.name,n.group,n.native??"",n.ansiSource,...n.nativeNames??[],...$u(n.booru)],e))}function Ok(t,e,n){let r=n.toLowerCase(),i=(o)=>o.name===e.name?0:o.group===e.group?1:2;return t.filter((o)=>o.booru?.toLowerCase().includes(r)).map((o,s)=>({p:o,at:s})).sort((o,s)=>i(o.p)-i(s.p)||o.at-s.at).map(({p:o})=>o)}function Ik(t,e){return t.booruSites?.[e]??(t.booru?[t.booru]:[])}var YA=9999,cs;function qe(t,e){if(!cs||e===""||cs.length>=YA)return e;return`\x1B[?${cs.push(t)}y${e}\x1B[?0y`}function Rk(t){let e=cs,n=[];cs=n;try{return{drawn:t(),targets:n}}finally{cs=e}}function Nk(t){let e=t.slice(3,-1);return t.startsWith("\x1B[?")&&t.endsWith("y")&&/^\d{1,4}$/.test(e)?Number(e):void 0}function VA(t){let e=t.slice(2,-1);return t.startsWith("\x1B[")&&t.endsWith("G")&&/^\d*$/.test(e)?Math.max(1,Number(e||1))-1:void 0}function ZA(t,e,n){if(!t.includes("\x1B[?"))return{text:t,zones:[]};let r=[],i=[],o="",s=0,a="",c=()=>{let f=i.pop();if(f&&s>f.col)r.push({row:e,col:f.col,width:s-f.col,height:1,target:f.target})},u=0;while(u<t.length){let f=t.indexOf("\x1B",u);if(f!==u){let m=f===-1?t.length:f;a+=t.slice(u,m),o+=t.slice(u,m),u=m;continue}let l=t.slice(u,u+(id(t,u)||1));u+=l.length;let d=Nk(l),h=d===void 0?VA(l):void 0;if(d===void 0&&h===void 0){o+=l;continue}if(s+=G(a),a="",h!==void 0)s=h,o+=l;else if(d===0)c();else if(d!==void 0)i.push({target:n[d-1],col:s})}s+=G(a);while(i.length>0)c();return{text:o,zones:r}}function Ak(t,e,n){let r=[],i=[],o="",s=(b)=>{let $=Nk(b);if($===0)r.pop();else if($!==void 0)r.push(b);else if(b.startsWith("\x1B]8;"))o=b.slice(b.indexOf(";",4)+1).replace("\x07","").replace("\x1B\\","")===""?"":b;else if(b.startsWith("\x1B[")&&b.endsWith("m"))i.push(b)},a=t.includes("\x1B")||n.includes("\x1B")?me:"",c=qc(t),u="",f=0,l=0;while(l<c.length&&f<e){let b=c[l];if(b.sequence)s(b.text);else if(f+b.width>e)break;else f+=b.width;u+=b.text,l++}u+=" ".repeat(e-Math.min(e,f));let d=`${"\x1B[?0y".repeat(r.length)}${o?"\x1B]8;;\x1B\\":""}${a}`,h=e+G(n);while(l<c.length&&f<h){let b=c[l];if(b.sequence)s(b.text);else f+=b.width;l++}let m=l<c.length?t.slice(c[l].start):"";if(m===""&&f<=h)return`${u}${d}${n}${a}`;let p=`${i.join("")}${o}${r.join("")}${" ".repeat(Math.max(0,f-h))}`;return`${u}${d}${n}${a}${p}${m}`}function Tk(t,e){let n=[];return{lines:t.map((i,o)=>{let s=ZA(i,o,e);return n.push(...s.zones),s.text}),zones:n}}function Pk(t,e,n,r=0.5,i=0.5){let o=n-t.col,s=e-t.row;return{target:t.target,x:o,y:s,exact:{x:o+r,y:s+i},width:t.width,height:t.height,inside:o>=0&&o<t.width&&s>=0&&s<t.height}}function XA(t,e,n){let r;for(let i of t)if(e>=i.row&&e<i.row+i.height&&n>=i.col&&n<i.col+i.width&&(!r||i.width*i.height<=r.width*r.height))r=i;return r}var QA={space:" ",enter:"enter",esc:"esc",tab:"tab",bksp:"backspace",del:"delete","←":"left","→":"right"};function Th(t){let e=/^(ctrl|alt)\+([a-z])$/.exec(t);if(e)return`${e[1]}-${e[2]}`;return QA[t]??([...t].length===1&&t!==" "?t:void 0)}function Ct(t,e){let n=Th(t);return n?qe({kind:"key",key:n},e):e}class Hh{zones=[];held;point(t){if(t.action==="drag"||t.action==="release"){let n=this.held;if(t.action==="release")this.held=void 0;return n&&Pk(n,t.row,t.col,t.fx,t.fy)}let e=XA(this.zones,t.row,t.col);if(t.action==="press")this.held=t.button==="left"?e:void 0;return e&&Pk(e,t.row,t.col,t.fx,t.fy)}drop(){this.held=void 0}}function Hk(t,e,n,r=(i)=>i){if(!t.color)return r(n?`[${e}]`:` ${e} `);return n?t.pill(r(` ${e} `)):t.dim(r(` ${e} `))}function De(t,e){return t.color?t.pill(` ${e} `):`[${e}]`}function Fk(t,e,n){return Ct(e.split(" ")[0]??"",`${t.bold(e)} ${t.dim(n)}`)}function Nu(t,e){return e===void 0?t.dim(N.sep):e?t.dim(N.ok):t.bold(N.miss)}var tT={top:"╭╮",mid:"├┤",bottom:"╰╯"};function Jt(t,e,n=[]){let[r,i]=[...tT[e]],o=[...`${r}${"─".repeat(Math.max(0,t-2))}${i}`];for(let[s,a]of n)[...a].forEach((c,u)=>{if(s+u>0&&s+u<t-1)o[s+u]=c});return o.join("")}function Je(t,e,n){return`${t.dim("│")}${tt(e,n-2)}${t.dim("│")}`}var ir=[{name:"preview",title:"Preview"},{name:"browse",title:"Browse"}],Au=10,Tu=20;function Lk(t){return ir.find((e)=>e.name===t.TTHEME_HUB)?.name}function Ck(t,e){let n=ir.findIndex((r)=>r.name===t);return Tu+(n+e+ir.length)%ir.length+1}function jk(t){return Tu+ir.findIndex((e)=>e.name===t)+1}function Fh(t,e){let n=xe(e);return` ${ir.map(({name:i,title:o})=>{let s={kind:"hub",tab:i};return Hk(n,o,i===t,(a)=>qe(s,a))}).join(" ")} ${n.dim("tab next")}`}import{execFileSync as tL}from"node:child_process";import{existsSync as El,mkdirSync as eL,readdirSync as nL,readFileSync as Ml,rmSync as rL}from"node:fs";import{basename as Rv,join as Ya,relative as Ov}from"node:path";import{styleText as ju}from"node:util";import{stdout as Yk,stdin as cT}from"node:process";import uT from"node:readline";var Hu="\x1B",Wk="",eT=39,Ch="\x07",Kk="[",nT="]",zk="m",jh=`${nT}8;;`,_k=new RegExp(`(?:\\${Kk}(?<code>\\d+)m|\\${jh}(?<uri>.*)${Ch})`,"y"),Gk=(t)=>{if(t>=30&&t<=37)return 39;if(t>=90&&t<=97)return 39;if(t>=40&&t<=47)return 49;if(t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0;return},Bk=(t)=>`${Hu}${Kk}${t}${zk}`,Uk=(t)=>`${Hu}${jh}${t}${Ch}`,Lh=(t,e,n)=>{let r=e[Symbol.iterator](),i=!1,o=!1,s=t.at(-1),a=s===void 0?0:G(s),c=r.next(),u=r.next(),f=0;while(!c.done){let l=c.value,d=G(l);if(a+d<=n)t[t.length-1]+=l;else t.push(l),a=0;if(l===Hu||l===Wk)i=!0,o=e.startsWith(jh,f+1);if(i){if(o){if(l===Ch)i=!1,o=!1}else if(l===zk)i=!1}else if(a+=d,a===n&&!u.done)t.push(""),a=0;c=u,u=r.next(),f+=l.length}if(s=t.at(-1),!a&&s!==void 0&&s.length&&t.length>1)t[t.length-2]+=t.pop()},rT=(t)=>{let e=t.split(" "),n=e.length;while(n){if(G(e[n-1]))break;n--}if(n===e.length)return t;return e.slice(0,n).join(" ")+e.slice(n).join("")},iT=(t,e,n={})=>{if(n.trim!==!1&&t.trim()==="")return"";let r="",i,o,s=t.split(" "),a=[""],c=0;for(let l=0;l<s.length;l++){let d=s[l];if(n.trim!==!1){let m=a.at(-1)??"",p=m.trimStart();if(m.length!==p.length)a[a.length-1]=p,c=G(p)}if(l!==0){if(c>=e&&(n.wordWrap===!1||n.trim===!1))a.push(""),c=0;if(c||n.trim===!1)a[a.length-1]+=" ",c++}let h=G(d);if(n.hard&&h>e){let m=e-c,p=1+Math.floor((h-m-1)/e);if(Math.floor((h-1)/e)<p)a.push("");Lh(a,d,e),c=G(a.at(-1)??"");continue}if(c+h>e&&c&&h){if(n.wordWrap===!1&&c<e){Lh(a,d,e),c=G(a.at(-1)??"");continue}a.push(""),c=0}if(c+h>e&&n.wordWrap===!1){Lh(a,d,e),c=G(a.at(-1)??"");continue}a[a.length-1]+=d,c+=h}if(n.trim!==!1)a=a.map((l)=>rT(l));let u=a.join(`
|
|
267
|
+
`),f=!1;for(let l=0;l<u.length;l++){let d=u[l];if(r+=d,!f){if(f=d>="\uD800"&&d<="\uDBFF",f)continue}else f=!1;if(d===Hu||d===Wk){_k.lastIndex=l+1;let m=_k.exec(u)?.groups;if(m?.code!==void 0){let p=Number.parseFloat(m.code);i=p===eT?void 0:p}else if(m?.uri!==void 0)o=m.uri.length===0?void 0:m.uri}if(u[l+1]===`
|
|
268
|
+
`){if(o)r+=Uk("");let h=i?Gk(i):void 0;if(i&&h)r+=Bk(h)}else if(d===`
|
|
269
|
+
`){if(i&&Gk(i))r+=Bk(i);if(o)r+=Uk(o)}}return r},oT=/\r?\n/;function Dr(t,e,n){return String(t).normalize().split(oT).map((r)=>iT(r,e,n)).join(`
|
|
270
|
+
`)}var Le=td(Gh(),1);function or(t,e,n){if(!n.some((s)=>!s.disabled))return t;let r=t+e,i=Math.max(n.length-1,0),o=r<0?i:r>i?0:r;return n[o]?.disabled?or(o,e<0?-1:1,n):o}function Fu(t,e,n,r){let i=r.split(`
|
|
271
|
+
`),o=0,s=t;for(let c of i){if(s<=c.length)break;s-=c.length+1,o++}for(o=Math.max(0,Math.min(i.length-1,o+n)),s=Math.min(s,i[o].length)+e;s<0&&o>0;)o--,s+=i[o].length+1;for(;s>i[o].length&&o<i.length-1;)s-=i[o].length+1,o++;s=Math.max(0,Math.min(i[o].length,s));let a=0;for(let c=0;c<o;c++)a+=i[c].length+1;return a+s}var lT=["up","down","left","right","space","enter","cancel"],fT=["January","February","March","April","May","June","July","August","September","October","November","December"],jt={actions:new Set(lT),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,accessible:void 0,date:{monthNames:[...fT],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(t,e)=>`There are only ${t} days in ${e}`,afterMin:(t)=>`Date must be on or after ${t.toISOString().slice(0,10)}`,beforeMax:(t)=>`Date must be on or before ${t.toISOString().slice(0,10)}`}}};function dT(t){if(t!==void 0)return t;if(jt.accessible!==void 0)return jt.accessible;let e=process.env.ACCESSIBLE;return e!==void 0&&e!==""&&e!=="0"&&e!=="false"}function Vk(t,e){if(typeof t=="string")return jt.aliases.get(t)===e;for(let n of t)if(n!==void 0&&Vk(n,e))return!0;return!1}function hT(t,e){if(t===e)return;let n=t.split(`
|
|
272
272
|
`),r=e.split(`
|
|
273
|
-
`),i=Math.max(n.length,r.length),o=[];for(let s=0;s<i;s++)n[s]!==r[s]&&o.push(s);return{lines:o,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}var
|
|
273
|
+
`),i=Math.max(n.length,r.length),o=[];for(let s=0;s<i;s++)n[s]!==r[s]&&o.push(s);return{lines:o,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}var tU=globalThis.process.platform.startsWith("win"),_u=Symbol("clack:cancel");function te(t){return t===_u}function Lu(t,e){let n=t;n.isTTY&&n.setRawMode(e)}var Gu=(t)=>("columns"in t)&&typeof t.columns=="number"?t.columns:80,Wh=(t)=>("rows"in t)&&typeof t.rows=="number"?t.rows:20;function Jr(t,e,n,r=n,i=n,o){let s=Gu(t??Yk);return Dr(e,s-n.length,{hard:!0,trim:!1}).split(`
|
|
274
274
|
`).map((a,c,u)=>{let f=o?o(a,c):a;return c===0?`${r}${f}`:c===u.length-1?`${i}${f}`:`${n}${f}`}).join(`
|
|
275
|
-
`)}function
|
|
276
|
-
`),
|
|
277
|
-
`).length-1;this.output.write(
|
|
278
|
-
`);this.output.write(s[o]),this._prevFrame=t,this.output.write(
|
|
275
|
+
`)}function Zk(t,e){if("~standard"in t){let n=t["~standard"].validate(e);return n instanceof Promise?n.then((r)=>r.issues?.at(0)?.message):n.issues?.at(0)?.message}return t(e)}class sr{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";get accessible(){return dT(this.opts.accessible)}constructor(t,e=!0){let{input:n=cT,output:r=Yk,render:i,signal:o,...s}=t;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=e,this._abortSignal=o,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(t,e){let n=this._subscribers.get(t)??[];n.push(e),this._subscribers.set(t,n)}on(t,e){this.setSubscriber(t,{cb:e})}once(t,e){this.setSubscriber(t,{cb:e,once:!0})}emit(t,...e){let n=this._subscribers.get(t)??[],r=[];for(let i of n)i.cb(...e),i.once&&r.push(()=>n.splice(n.indexOf(i),1));for(let i of r)i()}prompt(){return new Promise((t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(_u);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=uT.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Lu(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Le.cursor.show),this.output.off("resize",this.render),Lu(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Le.cursor.show),this.output.off("resize",this.render),Lu(this.input,!1),t(_u)})})}_isActionKey(t,e){return t==="\t"}_shouldSubmit(t,e){return!0}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,e){this.userInput=t??"",this.emit("userInput",this.userInput),e&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}async onKeypress(t,e){if(this.state!=="validating"){if(this._track&&e.name!=="return"&&(e.name&&this._isActionKey(t,e)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),e?.name&&(!this._track&&jt.aliases.has(e.name)&&this.emit("cursor",jt.aliases.get(e.name)),jt.actions.has(e.name)&&this.emit("cursor",e.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t,e),e?.name==="return"&&this._shouldSubmit(t,e)){if(this.opts.validate){let n=Zk(this.opts.validate,this.value),r;n instanceof Promise?(this.state="validating",this.render(),r=await n):r=n,r&&(this.error=r instanceof Error?r.message:r,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Vk([t,e?.name,e?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
276
|
+
`),Lu(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=Dr(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
277
|
+
`).length-1;this.output.write(Le.cursor.move(-999,t*-1))}render(){let t=Dr(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(Le.cursor.hide);else{let e=hT(this._prevFrame,t),n=Wh(this.output);if(this.restoreCursor(),e){let r=Math.max(0,e.numLinesAfter-n),i=Math.max(0,e.numLinesBefore-n),o=e.lines.find((s)=>s>=r);if(o===void 0){this._prevFrame=t;return}if(e.lines.length===1){this.output.write(Le.cursor.move(0,o-i)),this.output.write(Le.erase.lines(1));let s=t.split(`
|
|
278
|
+
`);this.output.write(s[o]),this._prevFrame=t,this.output.write(Le.cursor.move(0,s.length-o-1));return}else if(e.lines.length>1){if(r<i)o=r;else{let a=o-i;a>0&&this.output.write(Le.cursor.move(0,a))}this.output.write(Le.erase.down());let s=t.split(`
|
|
279
279
|
`).slice(o);this.output.write(s.join(`
|
|
280
|
-
`)),this._prevFrame=t;return}}this.output.write(Fe.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function oT(t,e){if(t===void 0||e.length===0)return 0;let n=e.findIndex((r)=>r.value===t);return n!==-1?n:0}function sT(t,e){return(e.label??String(e.value)).toLowerCase().includes(t.toLowerCase())}function aT(t,e){if(e)return t?e:e[0]}var cT=class extends or{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#n="";#t;#o;#a;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return Tu(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let e=this.userInput.slice(0,this.cursor),n=this.userInput.slice(this.cursor,this.cursor+1),r=this.userInput.slice(this.cursor+1);return`${e}${Tu("inverse",n)}${r}`}get options(){return typeof this.#o=="function"?this.#o():this.#o}constructor(e){super(e),this.#o=e.options,this.#a=e.placeholder;let n=this.options;this.filteredOptions=[...n],this.multiple=e.multiple===!0,this.#t=typeof e.options=="function"?e.filter:e.filter??sT;let r;if(e.initialValue&&Array.isArray(e.initialValue)?this.multiple?r=e.initialValue:r=e.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(r=[this.options[0]?.value]),r)for(let i of r){let o=n.findIndex((s)=>s.value===i);o!==-1&&(this.toggleSelected(i),this.#e=o)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(i,o)=>this.#r(i,o)),this.on("userInput",(i)=>this.#i(i))}_isActionKey(e,n){return e==="\t"||this.multiple&&this.isNavigating&&n.name==="space"&&e!==void 0&&e!==""}#r(e,n){let r=n.name==="up",i=n.name==="down",o=n.name==="return",s=this.userInput===""||this.userInput==="\t",a=this.#a,c=this.options,u=a!==void 0&&a!==""&&c.some((f)=>!f.disabled&&(this.#t?this.#t(a,f):!0));if(n.name==="tab"&&s&&u){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}r||i?(this.#e=ir(this.#e,r?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):o?this.value=aT(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(n.name==="tab"||this.isNavigating&&n.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(e){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(e)?this.selectedValues=this.selectedValues.filter((n)=>n!==e):this.selectedValues=[...this.selectedValues,e]:this.selectedValues=[e])}#i(e){if(e!==this.#n){this.#n=e;let n=this.options;e&&this.#t?this.filteredOptions=n.filter((o)=>this.#t?.(e,o)):this.filteredOptions=[...n];let r=oT(this.focusedValue,this.filteredOptions);this.#e=ir(r,0,this.filteredOptions);let i=this.filteredOptions[this.#e];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class _h extends or{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(e)=>{this.output.write(Fe.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var uT={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function Bk(t){return[...t].map((e)=>uT[e])}function lT(t){let e=new Intl.DateTimeFormat(t,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),n=[],r="/";for(let i of e)i.type==="literal"?r=i.value.trim()||i.value:(i.type==="year"||i.type==="month"||i.type==="day")&&n.push({type:i.type,len:i.type==="year"?4:2});return{segments:n,separator:r}}function Fh(t){return Number.parseInt((t||"0").replace(/_/g,"0"),10)||0}function Nu(t){return{year:Fh(t.year),month:Fh(t.month),day:Fh(t.day)}}function Ch(t,e){return new Date(t||2001,e||1,0).getDate()}function qk(t){let{year:e,month:n,day:r}=Nu(t);if(!e||e<0||e>9999||!n||n<1||n>12||!r||r<1)return;let i=new Date(Date.UTC(e,n-1,r));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==n-1||i.getUTCDate()!==r))return{year:e,month:n,day:r}}function Uk(t){let e=qk(t);return e?new Date(Date.UTC(e.year,e.month-1,e.day)):void 0}function fT(t,e,n,r){let i=n?{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()}:null,o=r?{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}:null;return t==="year"?{min:i?.year??1,max:o?.year??9999}:t==="month"?{min:i&&e.year===i.year?i.month:1,max:o&&e.year===o.year?o.month:12}:{min:i&&e.year===i.year&&e.month===i.month?i.day:1,max:o&&e.year===o.year&&e.month===o.month?o.day:Ch(e.year,e.month)}}class Dk extends or{#e;#n;#t;#o;#a;#r={segmentIndex:0,positionInSegment:0};#i=!0;#s=null;inlineError="";get segmentCursor(){return{...this.#r}}get segmentValues(){return{...this.#t}}get segments(){return this.#e}get separator(){return this.#n}get formattedValue(){return this.#f(this.#t)}#f(t){return this.#e.map((e)=>t[e.type]).join(this.#n)}#c(){this._setUserInput(this.#f(this.#t)),this._setValue(Uk(this.#t)??void 0)}constructor(t){let e=t.format?{segments:Bk(t.format),separator:t.separator??"/"}:lT(t.locale),n=t.separator??e.separator,r=t.format?Bk(t.format):e.segments,i=t.initialValue??t.defaultValue,o=i?{year:String(i.getUTCFullYear()).padStart(4,"0"),month:String(i.getUTCMonth()+1).padStart(2,"0"),day:String(i.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},s=r.map((a)=>o[a.type]).join(n);super({...t,initialUserInput:s},!1),this.#e=r,this.#n=n,this.#t=o,this.#o=t.minDate,this.#a=t.maxDate,this.#c(),this.on("cursor",(a)=>this.#m(a)),this.on("key",(a,c)=>this.#p(a,c)),this.on("finalize",()=>this.#g(t))}#u(){let t=Math.max(0,Math.min(this.#r.segmentIndex,this.#e.length-1)),e=this.#e[t];if(e)return this.#r.positionInSegment=Math.max(0,Math.min(this.#r.positionInSegment,e.len-1)),{segment:e,index:t}}#l(t){this.inlineError="",this.#s=null;let e=this.#u();e&&(this.#r.segmentIndex=Math.max(0,Math.min(this.#e.length-1,e.index+t)),this.#r.positionInSegment=0,this.#i=!0)}#d(t){let e=this.#u();if(!e)return;let{segment:n}=e,r=this.#t[n.type],i=!r||r.replace(/_/g,"")==="",o=Number.parseInt((r||"0").replace(/_/g,"0"),10)||0,s=fT(n.type,Nu(this.#t),this.#o,this.#a),a;i?a=t===1?s.min:s.max:a=Math.max(Math.min(s.max,o+t),s.min),this.#t={...this.#t,[n.type]:a.toString().padStart(n.len,"0")},this.#i=!0,this.#s=null,this.#c()}#m(t){if(t)switch(t){case"right":return this.#l(1);case"left":return this.#l(-1);case"up":return this.#d(1);case"down":return this.#d(-1)}}#p(t,e){if(e?.name==="backspace"||e?.sequence===""||e?.sequence==="\b"||t===""||t==="\b"){this.inlineError="";let n=this.#u();if(!n)return;if(!this.#t[n.segment.type].replace(/_/g,"")){this.#l(-1);return}this.#t[n.segment.type]="_".repeat(n.segment.len),this.#i=!0,this.#r.positionInSegment=0,this.#c();return}if(e?.name==="tab"){this.inlineError="";let n=this.#u();if(!n)return;let r=e.shift?-1:1,i=n.index+r;i>=0&&i<this.#e.length&&(this.#r.segmentIndex=i,this.#r.positionInSegment=0,this.#i=!0);return}if(t&&/^[0-9]$/.test(t)){let n=this.#u();if(!n)return;let{segment:r}=n,i=!this.#t[r.type].replace(/_/g,"");if(this.#i&&this.#s!==null&&!i){let d=this.#s+t,h={...this.#t,[r.type]:d},m=this.#h(h,r);if(m){this.inlineError=m,this.#s=null,this.#i=!1;return}this.inlineError="",this.#t[r.type]=d,this.#s=null,this.#i=!1,this.#c(),n.index<this.#e.length-1&&(this.#r.segmentIndex=n.index+1,this.#r.positionInSegment=0,this.#i=!0);return}this.#i&&!i&&(this.#t[r.type]="_".repeat(r.len),this.#r.positionInSegment=0),this.#i=!1,this.#s=null;let o=this.#t[r.type],s=o.indexOf("_"),a=s>=0?s:Math.min(this.#r.positionInSegment,r.len-1);if(a<0||a>=r.len)return;let c=o.slice(0,a)+t+o.slice(a+1),u=!1;if(a===0&&o==="__"&&(r.type==="month"||r.type==="day")){let d=Number.parseInt(t,10);c=`0${t}`,u=d<=(r.type==="month"?1:2)}if(r.type==="year"&&(c=(o.replace(/_/g,"")+t).padStart(r.len,"_")),!c.includes("_")){let d={...this.#t,[r.type]:c},h=this.#h(d,r);if(h){this.inlineError=h;return}}this.inlineError="",this.#t[r.type]=c;let f=c.includes("_")?void 0:qk(this.#t);if(f){let{year:d,month:h}=f,m=Ch(d,h);this.#t={year:String(Math.max(0,Math.min(9999,d))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,h))).padStart(2,"0"),day:String(Math.max(1,Math.min(m,f.day))).padStart(2,"0")}}this.#c();let l=c.indexOf("_");u?(this.#i=!0,this.#s=t):l>=0?this.#r.positionInSegment=l:s>=0&&n.index<this.#e.length-1?(this.#r.segmentIndex=n.index+1,this.#r.positionInSegment=0,this.#i=!0):this.#r.positionInSegment=Math.min(a+1,r.len-1)}}#h(t,e){let{month:n,day:r}=Nu(t);if(e.type==="month"&&(n<0||n>12))return Yt.date.messages.invalidMonth;if(e.type==="day"&&(r<0||r>31))return Yt.date.messages.invalidDay(31,"any month")}#g(t){let{year:e,month:n,day:r}=Nu(this.#t);if(e&&n&&r){let i=Ch(e,n);this.#t={...this.#t,day:String(Math.min(r,i)).padStart(2,"0")}}this.value=Uk(this.#t)??t.defaultValue??void 0}}var dT=class extends or{options;cursor=0;#e;getGroupItems(e){return this.options.filter((n)=>n.group===e)}isGroupSelected(e){let n=this.getGroupItems(e),r=this.value;return r===void 0?!1:n.every((i)=>r.includes(i.value))}toggleValue(){let e=this.options[this.cursor];if(e!==void 0)if(this.value===void 0&&(this.value=[]),e.group===!0){let n=e.value,r=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((i)=>r.findIndex((o)=>o.value===i)===-1):this.value=[...this.value,...r.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(e.value);this.value=n?this.value.filter((r)=>r!==e.value):[...this.value,e.value]}}constructor(e){super(e,!1);let{options:n}=e;this.#e=e.selectableGroups!==!1,this.options=Object.entries(n).flatMap(([r,i])=>[{value:r,group:!0,label:r},...i.map((o)=>({...o,group:r}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:r})=>r===e.cursorAt),this.#e?0:1),this.on("cursor",(r)=>{switch(r){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},hT=new Set(["up","down","left","right"]);class Jk extends or{#e=!1;#n;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${t}█`;let e=t.slice(0,this.cursor),n=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return n===`
|
|
280
|
+
`)),this._prevFrame=t;return}}this.output.write(Le.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function mT(t,e){if(t===void 0||e.length===0)return 0;let n=e.findIndex((r)=>r.value===t);return n!==-1?n:0}function pT(t,e){return(e.label??String(e.value)).toLowerCase().includes(t.toLowerCase())}function gT(t,e){if(e)return t?e:e[0]}var bT=class extends sr{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#r="";#t;#s;#a;#n;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return ju(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let e=this.userInput.slice(0,this.cursor),n=this.userInput.slice(this.cursor,this.cursor+1),r=this.userInput.slice(this.cursor+1);return`${e}${ju("inverse",n)}${r}`}get options(){return typeof this.#s=="function"?this.#s():this.#s}constructor(e){super(e),this.#s=e.options,this.#a=e.placeholder,this.#n=e.completeOnTab===!0;let n=this.options;this.filteredOptions=[...n],this.multiple=e.multiple===!0,this.#t=typeof e.options=="function"?e.filter:e.filter??pT;let r;if(e.initialValue&&Array.isArray(e.initialValue)?this.multiple?r=e.initialValue:r=e.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(r=[this.options[0]?.value]),r)for(let i of r){let o=n.findIndex((s)=>s.value===i);o!==-1&&(this.toggleSelected(i),this.#e=o)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(i,o)=>this.#i(i,o)),this.on("userInput",(i)=>this.#o(i))}_isActionKey(e,n){return e==="\t"||this.multiple&&this.isNavigating&&n.name==="space"&&e!==void 0&&e!==""}#i(e,n){let r=n.name==="up",i=n.name==="down",o=n.name==="return",s=this.userInput===""||this.userInput==="\t",a=this.#a,c=this.options,u=a!==void 0&&a!==""&&c.some((f)=>!f.disabled&&(this.#t?this.#t(a,f):!0));if(n.name==="tab"&&s&&u){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}if(n.name==="tab"&&this.#n&&!this.multiple&&this.focusedValue!==void 0){let f=String(this.focusedValue);this._clearUserInput(),this._setUserInput(f,!0),this.isNavigating=!1;return}r||i?(this.#e=or(this.#e,r?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):o?this.value=gT(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(n.name==="tab"||this.isNavigating&&n.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(e){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(e)?this.selectedValues=this.selectedValues.filter((n)=>n!==e):this.selectedValues=[...this.selectedValues,e]:this.selectedValues=[e])}#o(e){if(e!==this.#r){this.#r=e;let n=this.options;e&&this.#t?this.filteredOptions=n.filter((o)=>this.#t?.(e,o)):this.filteredOptions=[...n];let r=mT(this.focusedValue,this.filteredOptions);this.#e=or(r,0,this.filteredOptions);let i=this.filteredOptions[this.#e];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class Kh extends sr{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(e)=>{this.output.write(Le.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var wT={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function Dk(t){return[...t].map((e)=>wT[e])}function $T(t){let e=new Intl.DateTimeFormat(t,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),n=[],r="/";for(let i of e)i.type==="literal"?r=i.value.trim()||i.value:(i.type==="year"||i.type==="month"||i.type==="day")&&n.push({type:i.type,len:i.type==="year"?4:2});return{segments:n,separator:r}}function Bh(t){return Number.parseInt((t||"0").replace(/_/g,"0"),10)||0}function Cu(t){return{year:Bh(t.year),month:Bh(t.month),day:Bh(t.day)}}function Uh(t,e){return new Date(t||2001,e||1,0).getDate()}function Xk(t){let{year:e,month:n,day:r}=Cu(t);if(!e||e<0||e>9999||!n||n<1||n>12||!r||r<1)return;let i=new Date(Date.UTC(e,n-1,r));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==n-1||i.getUTCDate()!==r))return{year:e,month:n,day:r}}function Jk(t){let e=Xk(t);return e?new Date(Date.UTC(e.year,e.month-1,e.day)):void 0}function kT(t,e,n,r){let i=n?{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()}:null,o=r?{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}:null;return t==="year"?{min:i?.year??1,max:o?.year??9999}:t==="month"?{min:i&&e.year===i.year?i.month:1,max:o&&e.year===o.year?o.month:12}:{min:i&&e.year===i.year&&e.month===i.month?i.day:1,max:o&&e.year===o.year&&e.month===o.month?o.day:Uh(e.year,e.month)}}class Qk extends sr{#e;#r;#t;#s;#a;#n={segmentIndex:0,positionInSegment:0};#i=!0;#o=null;inlineError="";get segmentCursor(){return{...this.#n}}get segmentValues(){return{...this.#t}}get segments(){return this.#e}get separator(){return this.#r}get formattedValue(){return this.#f(this.#t)}#f(t){return this.#e.map((e)=>t[e.type]).join(this.#r)}#c(){this._setUserInput(this.#f(this.#t)),this._setValue(Jk(this.#t)??void 0)}constructor(t){let e=t.format?{segments:Dk(t.format),separator:t.separator??"/"}:$T(t.locale),n=t.separator??e.separator,r=t.format?Dk(t.format):e.segments,i=t.initialValue??t.defaultValue,o=i?{year:String(i.getUTCFullYear()).padStart(4,"0"),month:String(i.getUTCMonth()+1).padStart(2,"0"),day:String(i.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},s=r.map((a)=>o[a.type]).join(n);super({...t,initialUserInput:s},!1),this.#e=r,this.#r=n,this.#t=o,this.#s=t.minDate,this.#a=t.maxDate,this.#c(),this.on("cursor",(a)=>this.#m(a)),this.on("key",(a,c)=>this.#p(a,c)),this.on("finalize",()=>this.#g(t))}#u(){let t=Math.max(0,Math.min(this.#n.segmentIndex,this.#e.length-1)),e=this.#e[t];if(e)return this.#n.positionInSegment=Math.max(0,Math.min(this.#n.positionInSegment,e.len-1)),{segment:e,index:t}}#l(t){this.inlineError="",this.#o=null;let e=this.#u();e&&(this.#n.segmentIndex=Math.max(0,Math.min(this.#e.length-1,e.index+t)),this.#n.positionInSegment=0,this.#i=!0)}#d(t){let e=this.#u();if(!e)return;let{segment:n}=e,r=this.#t[n.type],i=!r||r.replace(/_/g,"")==="",o=Number.parseInt((r||"0").replace(/_/g,"0"),10)||0,s=kT(n.type,Cu(this.#t),this.#s,this.#a),a;i?a=t===1?s.min:s.max:a=Math.max(Math.min(s.max,o+t),s.min),this.#t={...this.#t,[n.type]:a.toString().padStart(n.len,"0")},this.#i=!0,this.#o=null,this.#c()}#m(t){if(t)switch(t){case"right":return this.#l(1);case"left":return this.#l(-1);case"up":return this.#d(1);case"down":return this.#d(-1)}}#p(t,e){if(e?.name==="backspace"||e?.sequence===""||e?.sequence==="\b"||t===""||t==="\b"){this.inlineError="";let n=this.#u();if(!n)return;if(!this.#t[n.segment.type].replace(/_/g,"")){this.#l(-1);return}this.#t[n.segment.type]="_".repeat(n.segment.len),this.#i=!0,this.#n.positionInSegment=0,this.#c();return}if(e?.name==="tab"){this.inlineError="";let n=this.#u();if(!n)return;let r=e.shift?-1:1,i=n.index+r;i>=0&&i<this.#e.length&&(this.#n.segmentIndex=i,this.#n.positionInSegment=0,this.#i=!0);return}if(t&&/^[0-9]$/.test(t)){let n=this.#u();if(!n)return;let{segment:r}=n,i=!this.#t[r.type].replace(/_/g,"");if(this.#i&&this.#o!==null&&!i){let d=this.#o+t,h={...this.#t,[r.type]:d},m=this.#h(h,r);if(m){this.inlineError=m,this.#o=null,this.#i=!1;return}this.inlineError="",this.#t[r.type]=d,this.#o=null,this.#i=!1,this.#c(),n.index<this.#e.length-1&&(this.#n.segmentIndex=n.index+1,this.#n.positionInSegment=0,this.#i=!0);return}this.#i&&!i&&(this.#t[r.type]="_".repeat(r.len),this.#n.positionInSegment=0),this.#i=!1,this.#o=null;let o=this.#t[r.type],s=o.indexOf("_"),a=s>=0?s:Math.min(this.#n.positionInSegment,r.len-1);if(a<0||a>=r.len)return;let c=o.slice(0,a)+t+o.slice(a+1),u=!1;if(a===0&&o==="__"&&(r.type==="month"||r.type==="day")){let d=Number.parseInt(t,10);c=`0${t}`,u=d<=(r.type==="month"?1:2)}if(r.type==="year"&&(c=(o.replace(/_/g,"")+t).padStart(r.len,"_")),!c.includes("_")){let d={...this.#t,[r.type]:c},h=this.#h(d,r);if(h){this.inlineError=h;return}}this.inlineError="",this.#t[r.type]=c;let f=c.includes("_")?void 0:Xk(this.#t);if(f){let{year:d,month:h}=f,m=Uh(d,h);this.#t={year:String(Math.max(0,Math.min(9999,d))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,h))).padStart(2,"0"),day:String(Math.max(1,Math.min(m,f.day))).padStart(2,"0")}}this.#c();let l=c.indexOf("_");u?(this.#i=!0,this.#o=t):l>=0?this.#n.positionInSegment=l:s>=0&&n.index<this.#e.length-1?(this.#n.segmentIndex=n.index+1,this.#n.positionInSegment=0,this.#i=!0):this.#n.positionInSegment=Math.min(a+1,r.len-1)}}#h(t,e){let{month:n,day:r}=Cu(t);if(e.type==="month"&&(n<0||n>12))return jt.date.messages.invalidMonth;if(e.type==="day"&&(r<0||r>31))return jt.date.messages.invalidDay(31,"any month")}#g(t){let{year:e,month:n,day:r}=Cu(this.#t);if(e&&n&&r){let i=Uh(e,n);this.#t={...this.#t,day:String(Math.min(r,i)).padStart(2,"0")}}this.value=Jk(this.#t)??t.defaultValue??void 0}}var yT=class extends sr{options;cursor=0;#e;getGroupItems(e){return this.options.filter((n)=>n.group===e)}isGroupSelected(e){let n=this.getGroupItems(e),r=this.value;return r===void 0?!1:n.every((i)=>r.includes(i.value))}toggleValue(){let e=this.options[this.cursor];if(e!==void 0)if(this.value===void 0&&(this.value=[]),e.group===!0){let n=e.value,r=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((i)=>r.findIndex((o)=>o.value===i)===-1):this.value=[...this.value,...r.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(e.value);this.value=n?this.value.filter((r)=>r!==e.value):[...this.value,e.value]}}constructor(e){super(e,!1);let{options:n}=e;this.#e=e.selectableGroups!==!1,this.options=Object.entries(n).flatMap(([r,i])=>[{value:r,group:!0,label:r},...i.map((o)=>({...o,group:r}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:r})=>r===e.cursorAt),this.#e?0:1),this.on("cursor",(r)=>{switch(r){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},vT=new Set(["up","down","left","right"]);class ty extends sr{#e=!1;#r;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${t}█`;let e=t.slice(0,this.cursor),n=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return n===`
|
|
281
281
|
`?`${e}█
|
|
282
|
-
${r}`:`${e}${
|
|
282
|
+
${r}`:`${e}${ju("inverse",n)}${r}`}get cursor(){return this._cursor}#t(t){if(this.userInput.length===0){this._setUserInput(t);return}this._setUserInput(this.userInput.slice(0,this.cursor)+t+this.userInput.slice(this.cursor))}#s(t){let e=this.value??"";switch(t){case"up":this._cursor=Fu(this._cursor,0,-1,e);return;case"down":this._cursor=Fu(this._cursor,0,1,e);return;case"left":this._cursor=Fu(this._cursor,-1,0,e);return;case"right":this._cursor=Fu(this._cursor,1,0,e);return}}_shouldSubmit(t,e){if(this.#r)return this.focused==="submit"?!0:(this.#t(`
|
|
283
283
|
`),this._cursor++,!1);let n=this.#e;return this.#e=!0,n&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===`
|
|
284
284
|
`&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#t(`
|
|
285
|
-
`),this._cursor++,!1)}constructor(t){let e=t.initialUserInput??t.initialValue;super({...t,initialUserInput:e},!1),e!==void 0&&(this._cursor=e.length),this.#
|
|
286
|
-
`);b.push(
|
|
285
|
+
`),this._cursor++,!1)}constructor(t){let e=t.initialUserInput??t.initialValue;super({...t,initialUserInput:e},!1),e!==void 0&&(this._cursor=e.length),this.#r=t.showSubmit??!1,this.on("key",(n,r)=>{if(r?.name&&vT.has(r.name)){this.#e=!1,this.#s(r.name);return}if(n==="\t"&&this.#r){this.focused=this.focused==="editor"?"submit":"editor";return}if(r?.name!=="return"){if(this.#e=!1,r?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(r?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}n&&(this.#r&&this.focused==="submit"&&(this.focused="editor"),this.#t(n??""),this._cursor++)}}),this.on("userInput",(n)=>{this._setValue(n)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}class zh extends sr{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter((t)=>t.disabled!==!0)}toggleAll(){let t=this._enabledOptions,e=this.value!==void 0&&this.value.length===t.length;this.value=e?[]:t.map((n)=>n.value)}toggleInvert(){let t=this.value;if(!t)return;let e=this._enabledOptions.filter((n)=>!t.includes(n.value));this.value=e.map((n)=>n.value)}toggleValue(){this.value===void 0&&(this.value=[]);let t=this.value.includes(this._value);this.value=t?this.value.filter((e)=>e!==this._value):[...this.value,this._value]}constructor(t){super(t,!1),this.options=t.options,this.value=[...t.initialValues??[]];let e=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0);this.cursor=this.options[e]?.disabled?or(e,1,this.options):e,this.on("key",(n,r)=>{r.name==="a"&&this.toggleAll(),r.name==="i"&&this.toggleInvert()}),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=or(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=or(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}var ey=class extends sr{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let n=this.options.findIndex(({value:i})=>i===e.initialValue),r=n===-1?0:n;this.cursor=this.options[r]?.disabled?or(r,1,this.options):r,this.changeValue(),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=or(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=or(this.cursor,1,this.options);break}this.changeValue()})}};class qh extends sr{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}█`;let e=t.slice(0,this.cursor),n=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return`${e}${ju("inverse",n)}${r}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",(e)=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}import{styleText as O,stripVTControlCharacters as cU}from"node:util";import Ye from"node:process";var ay=td(Gh(),1);function ST(){if(Ye.platform!=="win32")return Ye.env.TERM!=="linux";return Boolean(Ye.env.CI)||Boolean(Ye.env.WT_SESSION)||Boolean(Ye.env.TERMINUS_SUBLIME)||Ye.env.ConEmuTask==="{cmd::Cmder}"||Ye.env.TERM_PROGRAM==="Terminus-Sublime"||Ye.env.TERM_PROGRAM==="vscode"||Ye.env.TERM==="xterm-256color"||Ye.env.TERM==="alacritty"||Ye.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ET=ST();var ht=(t,e)=>ET?t:e,ny=ht("◆","*"),MT=ht("■","x"),xT=ht("▲","x"),Yh=ht("◇","o"),OT=ht("┌","T"),et=ht("│","|"),In=ht("└","—"),dU=ht("┐","T"),hU=ht("┘","—"),Dh=ht("●",">"),Uu=ht("○"," "),IT=ht("◻","[•]"),ry=ht("◼","[+]"),iy=ht("◻","[ ]"),mU=ht("▪","•"),oy=ht("─","-"),PT=ht("╮","+"),RT=ht("├","+"),NT=ht("╯","+"),AT=ht("╰","+"),pU=ht("╭","+"),TT=ht("●","•"),HT=ht("◆","*"),FT=ht("▲","!"),LT=ht("■","x"),Wu=(t)=>{switch(t){case"initial":case"active":return O("cyan",ny);case"cancel":return O("red",MT);case"error":return O("yellow",xT);case"submit":return O("green",Yh);case"validating":return O("dim",ny)}},cy=(t)=>{switch(t){case"initial":case"active":return O("cyan",et);case"cancel":return O("red",et);case"error":return O("yellow",et);case"submit":return O("green",et)}};function uy(t,e){let n=[`${e?`${O("cyan",et)} `:""}${t.join(" • ")}`];return e&&n.push(O("cyan",In)),n}var sy=(t,e,n,r,i,o=!1)=>{let s=e,a=0;if(o)for(let c=r-1;c>=n;c--){let u=t[c];if(u&&(s-=u.length),a++,s<=i)break}else for(let c=n;c<r;c++){let u=t[c];if(u&&(s-=u.length),a++,s<=i)break}return{lineCount:s,removals:a}},Jh=({cursor:t,options:e,style:n,output:r=process.stdout,maxItems:i=Number.POSITIVE_INFINITY,columnPadding:o=0,rowPadding:s=4})=>{let a=Gu(r)-o,c=Wh(r),u=O("dim","..."),f=Math.max(c-s,0),l=Math.max(Math.min(i,f),5),d=0;t>=l-3&&(d=Math.max(Math.min(t-l+3,e.length-l),0));let h=l<e.length&&d>0,m=l<e.length&&d+l<e.length,p=Math.min(d+l,e.length),b=[],$=0;h&&$++,m&&$++;let k=d+(h?1:0),v=p-(m?1:0);for(let x=k;x<v;x++){let M=e[x],P=M?n(M,x===t):"",L=Dr(P,a,{hard:!0,trim:!1}).split(`
|
|
286
|
+
`);b.push(L),$+=L.length}if($>f){let x=0,M=0,P=$,L=t-k,A=f,_=()=>sy(b,P,0,L,A),q=()=>sy(b,P,L+1,b.length,A,!0);h?({lineCount:P,removals:x}=_(),P>A&&(m||(A-=1),{lineCount:P,removals:M}=q())):(m||(A-=1),{lineCount:P,removals:M}=q(),P>A&&(A-=1,{lineCount:P,removals:x}=_())),x>0&&(h=!0,b.splice(0,x)),M>0&&(m=!0,b.splice(b.length-M,M))}let S=[];h&&S.push(u);for(let x of b)for(let M of x)S.push(M);return m&&S.push(u),S};var Ce=(t)=>{let e=t.active??"Yes",n=t.inactive??"No";return new Kh({active:e,inactive:n,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue??!0,render(){let r=t.withGuide??jt.withGuide,i=`${Wu(this.state)} `,o=r?`${O("gray",et)} `:"",s=Jr(t.output,t.message,o,i),a=`${r?`${O("gray",et)}
|
|
287
287
|
`:""}${s}
|
|
288
|
-
`,c=this.value?e:n;switch(this.state){case"submit":{let u=r?`${O("gray",
|
|
289
|
-
${O("gray",
|
|
290
|
-
${O("cyan",
|
|
291
|
-
`:` ${O("dim","/")} `}${this.value?`${O("dim",
|
|
288
|
+
`,c=this.value?e:n;switch(this.state){case"submit":{let u=r?`${O("gray",et)} `:"";return`${a}${u}${O("dim",c)}`}case"cancel":{let u=r?`${O("gray",et)} `:"";return`${a}${u}${O(["strikethrough","dim"],c)}${r?`
|
|
289
|
+
${O("gray",et)}`:""}`}default:{let u=r?`${O("cyan",et)} `:"",f=r?O("cyan",In):"";return`${a}${u}${this.value?`${O("green",Dh)} ${e}`:`${O("dim",Uu)} ${O("dim",e)}`}${t.vertical?r?`
|
|
290
|
+
${O("cyan",et)} `:`
|
|
291
|
+
`:` ${O("dim","/")} `}${this.value?`${O("dim",Uu)} ${O("dim",n)}`:`${O("green",Dh)} ${n}`}
|
|
292
292
|
${f}
|
|
293
|
-
`}}}}).prompt()};var
|
|
293
|
+
`}}}}).prompt()};var CT=[`${O("dim","↑/↓")} to navigate`,`${O("dim","Space:")} select`,`${O("dim","Enter:")} confirm`],Pa=(t,e)=>t.split(`
|
|
294
294
|
`).map((n)=>e(n)).join(`
|
|
295
|
-
`),
|
|
296
|
-
${O("reset",O("dim",`Press ${O(["gray","bgWhite","inverse"]," space ")} to select, ${O("gray",O("bgWhite",O("inverse"," enter ")))} to submit`))}`},render(){let i=t.withGuide??
|
|
295
|
+
`),ly=(t)=>{let e=(i,o)=>{let s=i.label??String(i.value);return o==="disabled"?`${O("gray",iy)} ${Pa(s,(a)=>O(["strikethrough","gray"],a))}${i.hint?` ${O("dim",`(${i.hint??"disabled"})`)}`:""}`:o==="active"?`${O("cyan",IT)} ${s}${i.hint?` ${O("dim",`(${i.hint})`)}`:""}`:o==="selected"?`${O("green",ry)} ${Pa(s,(a)=>O("dim",a))}${i.hint?` ${O("dim",`(${i.hint})`)}`:""}`:o==="cancelled"?`${Pa(s,(a)=>O(["strikethrough","dim"],a))}`:o==="active-selected"?`${O("green",ry)} ${s}${i.hint?` ${O("dim",`(${i.hint})`)}`:""}`:o==="submitted"?`${Pa(s,(a)=>O("dim",a))}`:`${O("dim",iy)} ${Pa(s,(a)=>O("dim",a))}`},n=t.required??!0,r=t.showInstructions??!0;return new zh({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:n,cursorAt:t.cursorAt,validate(i){if(n&&(i===void 0||i.length===0))return`Please select at least one option.
|
|
296
|
+
${O("reset",O("dim",`Press ${O(["gray","bgWhite","inverse"]," space ")} to select, ${O("gray",O("bgWhite",O("inverse"," enter ")))} to submit`))}`},render(){let i=t.withGuide??jt.withGuide,o=Jr(t.output,t.message,i?`${cy(this.state)} `:"",`${Wu(this.state)} `),s=`${i?`${O("gray",et)}
|
|
297
297
|
`:""}${o}
|
|
298
|
-
`,a=this.value??[],c=(u,f)=>{if(u.disabled)return e(u,"disabled");let l=a.includes(u.value);return f&&l?e(u,"active-selected"):l?e(u,"selected"):e(u,f?"active":"inactive")};switch(this.state){case"submit":{let u=this.options.filter(({value:l})=>a.includes(l)).map((l)=>e(l,"submitted")).join(O("dim",", "))||O("dim","none"),f=Jr(t.output,u,i?`${O("gray",
|
|
299
|
-
${O("gray",
|
|
300
|
-
`).map((h,m)=>m===0?`${i?`${O("yellow",
|
|
298
|
+
`,a=this.value??[],c=(u,f)=>{if(u.disabled)return e(u,"disabled");let l=a.includes(u.value);return f&&l?e(u,"active-selected"):l?e(u,"selected"):e(u,f?"active":"inactive")};switch(this.state){case"submit":{let u=this.options.filter(({value:l})=>a.includes(l)).map((l)=>e(l,"submitted")).join(O("dim",", "))||O("dim","none"),f=Jr(t.output,u,i?`${O("gray",et)} `:"");return`${s}${f}`}case"cancel":{let u=this.options.filter(({value:l})=>a.includes(l)).map((l)=>e(l,"cancelled")).join(O("dim",", "));if(u.trim()==="")return`${s}${O("gray",et)}`;let f=Jr(t.output,u,i?`${O("gray",et)} `:"");return`${s}${f}${i?`
|
|
299
|
+
${O("gray",et)}`:""}`}case"error":{let u=i?`${O("yellow",et)} `:"",f=this.error.split(`
|
|
300
|
+
`).map((h,m)=>m===0?`${i?`${O("yellow",In)} `:""}${O("yellow",h)}`:` ${h}`).join(`
|
|
301
301
|
`),l=s.split(`
|
|
302
302
|
`).length,d=f.split(`
|
|
303
|
-
`).length+1;return`${s}${u}${
|
|
303
|
+
`).length+1;return`${s}${u}${Jh({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:u.length,rowPadding:l+d,style:c}).join(`
|
|
304
304
|
${u}`)}
|
|
305
305
|
${f}
|
|
306
|
-
`}default:{let u=i?`${O("cyan",
|
|
307
|
-
`).length,l=r?
|
|
308
|
-
`),h=l.length+1;return`${s}${u}${
|
|
306
|
+
`}default:{let u=i?`${O("cyan",et)} `:"",f=s.split(`
|
|
307
|
+
`).length,l=r?uy(CT,i):i?[O("cyan",In)]:[],d=l.join(`
|
|
308
|
+
`),h=l.length+1;return`${s}${u}${Jh({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:u.length,rowPadding:f+h,style:c}).join(`
|
|
309
309
|
${u}`)}
|
|
310
310
|
${d}
|
|
311
|
-
`}}}}).prompt()};var Yr={message:(t=[],{symbol:e=O("gray",
|
|
311
|
+
`}}}}).prompt()};var Yr={message:(t=[],{symbol:e=O("gray",et),secondarySymbol:n=O("gray",et),output:r=process.stdout,spacing:i=1,withGuide:o}={})=>{let s=[],a=o??jt.withGuide,c=a?n:"",u=a?`${e} `:"",f=a?`${n} `:"";for(let d=0;d<i;d++)s.push(c);let l=Array.isArray(t)?t:t.split(`
|
|
312
312
|
`);if(l.length>0){let[d,...h]=l;d.length>0?s.push(`${u}${d}`):s.push(a?e:"");for(let m of h)m.length>0?s.push(`${f}${m}`):s.push(a?n:"")}r.write(`${s.join(`
|
|
313
313
|
`)}
|
|
314
|
-
`)},info:(t,e)=>{Yr.message(t,{...e,symbol:O("blue",
|
|
314
|
+
`)},info:(t,e)=>{Yr.message(t,{...e,symbol:O("blue",TT)})},success:(t,e)=>{Yr.message(t,{...e,symbol:O("green",HT)})},step:(t,e)=>{Yr.message(t,{...e,symbol:O("green",Yh)})},warn:(t,e)=>{Yr.message(t,{...e,symbol:O("yellow",FT)})},warning:(t,e)=>{Yr.warn(t,e)},error:(t,e)=>{Yr.message(t,{...e,symbol:O("red",LT)})}},Vr=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??jt.withGuide?`${O("gray",In)} `:"";n.write(`${r}${O("red",t)}
|
|
315
315
|
|
|
316
|
-
`)},
|
|
317
|
-
`)},
|
|
318
|
-
${O("gray",
|
|
316
|
+
`)},Ku=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??jt.withGuide?`${O("gray",OT)} `:"";n.write(`${r}${t}
|
|
317
|
+
`)},Ra=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??jt.withGuide?`${O("gray",et)}
|
|
318
|
+
${O("gray",In)} `:"";n.write(`${r}${t}
|
|
319
319
|
|
|
320
|
-
`)};var
|
|
321
|
-
`),o=i.reduce((c,u)=>Math.max(
|
|
322
|
-
`).map(o),""],a=
|
|
323
|
-
`),f=i?`${O("gray",
|
|
324
|
-
`:"",l=i?
|
|
320
|
+
`)};var jT=(t)=>t,_T=(t,e,n)=>{let r={hard:!0,trim:!1},i=Dr(t,e,r).split(`
|
|
321
|
+
`),o=i.reduce((c,u)=>Math.max(G(u),c),0),s=i.map(n).reduce((c,u)=>Math.max(G(u),c),0),a=e-(s-o);return Dr(t,a,r)},Pn=(t="",e="",n)=>{let r=n?.output??Ye.stdout,i=n?.withGuide??jt.withGuide,o=n?.format??jT,s=["",..._T(t,Gu(r)-6,o).split(`
|
|
322
|
+
`).map(o),""],a=G(e),c=Math.max(s.reduce((d,h)=>{let m=G(h);return m>d?m:d},0),a)+2,u=s.map((d)=>`${O("gray",et)} ${d}${" ".repeat(c-G(d))}${O("gray",et)}`).join(`
|
|
323
|
+
`),f=i?`${O("gray",et)}
|
|
324
|
+
`:"",l=i?RT:AT;r.write(`${f}${O("green",Yh)} ${O("reset",e)} ${O("gray",oy.repeat(Math.max(c-a-1,1))+PT)}
|
|
325
325
|
${u}
|
|
326
|
-
${O("gray",l+
|
|
327
|
-
`)};var
|
|
326
|
+
${O("gray",l+oy.repeat(c+2)+NT)}
|
|
327
|
+
`)};var gU={light:ht("─","-"),heavy:ht("━","="),block:ht("█","#")};var GT=[`${O("dim","↑/↓")} to navigate`,`${O("dim","Enter:")} confirm`],Bu=(t,e)=>t.includes(`
|
|
328
328
|
`)?t.split(`
|
|
329
329
|
`).map((n)=>e(n)).join(`
|
|
330
|
-
`):e(t),
|
|
330
|
+
`):e(t),Vh=(t)=>{let e=(r,i)=>{if(r===void 0)return"";let o=r.label??String(r.value);switch(i){case"disabled":return`${O("gray",Uu)} ${Bu(o,(s)=>O("gray",s))}${r.hint?` ${O("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${Bu(o,(s)=>O("dim",s))}`;case"active":return`${O("green",Dh)} ${o}${r.hint?` ${O("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${Bu(o,(s)=>O(["strikethrough","dim"],s))}`;default:return`${O("dim",Uu)} ${Bu(o,(s)=>O("dim",s))}`}},n=t.showInstructions??!0;return new ey({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){let r=t.withGuide??jt.withGuide,i=`${Wu(this.state)} `,o=`${cy(this.state)} `,s=Jr(t.output,t.message,o,i),a=`${r?`${O("gray",et)}
|
|
331
331
|
`:""}${s}
|
|
332
|
-
`;switch(this.state){case"submit":{let c=r?`${O("gray",
|
|
333
|
-
${O("gray",
|
|
334
|
-
`).length,f=n?
|
|
335
|
-
`),d=f.length+1;return`${a}${c}${
|
|
332
|
+
`;switch(this.state){case"submit":{let c=r?`${O("gray",et)} `:"",u=Jr(t.output,e(this.options[this.cursor],"selected"),c);return`${a}${u}`}case"cancel":{let c=r?`${O("gray",et)} `:"",u=Jr(t.output,e(this.options[this.cursor],"cancelled"),c);return`${a}${u}${r?`
|
|
333
|
+
${O("gray",et)}`:""}`}default:{let c=r?`${O("cyan",et)} `:"",u=a.split(`
|
|
334
|
+
`).length,f=n?uy(GT,r):r?[O("cyan",In)]:[],l=f.join(`
|
|
335
|
+
`),d=f.length+1;return`${a}${c}${Jh({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:c.length,rowPadding:u+d,style:(h,m)=>e(h,h.disabled?"disabled":m?"active":"inactive")}).join(`
|
|
336
336
|
${c}`)}
|
|
337
337
|
${l}
|
|
338
|
-
`}}}}).prompt()};var
|
|
339
|
-
`:""}${
|
|
340
|
-
`,r=t.placeholder&&t.placeholder.length>0?O("inverse",t.placeholder[0])+O("dim",t.placeholder.slice(1)):O(["inverse","hidden"],"_"),i=this.userInput?this.userInputWithCursor:r,o=this.value??"";switch(this.state){case"
|
|
338
|
+
`}}}}).prompt()};var bU=`${O("gray",et)} `;var Zh=(t)=>new qh({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){let e=t?.withGuide??jt.withGuide,n=`${`${e?`${O("gray",et)}
|
|
339
|
+
`:""}${Wu(this.state)} `}${t.message}
|
|
340
|
+
`,r=t.placeholder&&t.placeholder.length>0?O("inverse",t.placeholder[0])+O("dim",t.placeholder.slice(1)):O(["inverse","hidden"],"_"),i=this.userInput?this.userInputWithCursor:r,o=this.value??"";switch(this.state){case"validating":{let s=e?`${O("cyan",et)} `:"",a=e?O("cyan",In):"",c=O("dim",i),u=O("dim","Validating...");return`${n}${s}${c}
|
|
341
|
+
${a} ${u}
|
|
342
|
+
`}case"error":{let s=this.error?` ${O("yellow",this.error)}`:"",a=e?`${O("yellow",et)} `:"",c=e?O("yellow",In):"";return`${n.trim()}
|
|
341
343
|
${a}${i}
|
|
342
344
|
${c}${s}
|
|
343
|
-
`}case"submit":{let s=o
|
|
344
|
-
${a}`:""}`}default:{let s=e?`${O("cyan",
|
|
345
|
+
`}case"submit":{let s=o?`${e?" ":""}${O("dim",o)}`:"",a=e?O("gray",et):"";return`${n}${a}${s}`}case"cancel":{let s=o?` ${O(["strikethrough","dim"],o)}`:"",a=e?O("gray",et):"";return`${n}${a}${s}${o.trim()?`
|
|
346
|
+
${a}`:""}`}default:{let s=e?`${O("cyan",et)} `:"",a=e?O("cyan",In):"";return`${n}${s}${i}
|
|
345
347
|
${a}
|
|
346
|
-
`}}}}).prompt();import{existsSync as
|
|
347
|
-
`)}var
|
|
348
|
-
`)){let o=i.trim();if(o.startsWith("[")&&o.endsWith("]"))r=o.slice(1,-1);else if(r===e&&o.startsWith(`${n}=`))return o.slice(n.length+1)}return}function
|
|
349
|
-
`),o=i.findIndex((c)=>c.trim()==="[General]"),s=i.findIndex((c,u)=>u>o&&c.trimStart().startsWith("[")),a=o<0?[]:i.slice(o+1,s<0?void 0:s).filter((c)=>
|
|
350
|
-
`),d=`${C("view")}.${BT("sha1").update(l).digest("hex").slice(0,10)}`,h=zi(r,`${d}.colorscheme`);if(!Bu(h))L(h,l);if(!o.includes(h))o.push(h);for(let m of o.splice(0,Math.max(0,o.length-qT)))cy(m,{force:!0});return Gu(d,f)},a=()=>{for(let c of o.splice(0))cy(c,{force:!0})};return{slots:[],paint:(c)=>s(c.name,c,c.cursor),wear:(c,u)=>u.includes("konsole")?Gu(C(c.name),c.cursor):void 0,saved:async()=>new Map,restore:()=>{return a(),`\x1B]50;${e}\x07`},stop:a}}function my(t,e,n=(r)=>{process.stdout.write(r)}){let r=Vt(t),i=$e[r];if(!e||Ft(t)||t.TMUX||!i.paints)return;if(r==="iterm2")return zT(t,n);if(r==="konsole"&&t.TTHEME_KONSOLE_LOOK)return YT(t,t.TTHEME_KONSOLE_LOOK);let o=i.repaint??cn.map((a,c)=>c),s=cn.filter((a,c)=>o.includes(c));return{slots:o,paint:(a)=>cr(a,o),wear:(a,c)=>!i.schemes?cr(a):c.includes(r)?Gu(C(a.name),a.cursor):void 0,saved:()=>Vh(s),restore:(a)=>_u(a,s,i.hex===!0)}}var ee=["ghostty","kitty","alacritty","wezterm","iterm2","windows-terminal","warp","konsole","terminal-app"];var ZT=[{section:"tab",title:"This tab"},{section:"startup",title:"New tabs"},{section:"catalog",title:"Palettes"},{section:"own",title:"Your own"},{section:"setup",title:"Setup"},{section:"support",title:"Support"}],ds=[{name:"use",args:["<palette>"],about:"Paint this tab — a unique prefix works: ttheme use ho",section:"tab",shell:!0},{name:"default",args:["<palette>"],about:"Make a palette the one new tabs open with",section:"startup"},{name:"on",args:[],about:"Wear the default palette in new tabs again",section:"startup"},{name:"off",args:[],about:"Take the palette and picture off every tab — the terminal's own colors until `ttheme on`",section:"startup"},{name:"pin",args:["[dir|ssh:<host>]"],about:"Pin a palette to a directory or an ssh host — the pin covers everything below it, or its whole repository; cd or ssh in repaints, leaving restores",section:"tab",shell:!0},{name:"unpin",args:["[dir|ssh:<host>]"],about:"Drop a pin — this directory's, every one below it, the one above that paints it, or an ssh host's",section:"tab",shell:!0},{name:"pins",args:[],about:"Map every pin as a file tree — the pinned directories in their palettes' colors, every ssh host, and the pin that covers this one",section:"tab",shell:!0},{name:"config",args:[],about:"Edit settings in $EDITOR — they apply in new tabs",section:"startup",shell:!0},{name:"browse",args:[],about:"Pick palettes and markets in a live picker — shift+←/→ moves between Catalog, Installed, Markets and Errors",section:"catalog",hidden:!0},{name:"list",args:["[query]"],about:"Show the catalog, marking what is installed",section:"catalog",flags:{json:{type:"boolean",about:"Print the matches as JSON — name, group, catalog, installed"}}},{name:"add",args:["<palette...>"],about:"Install palettes — from the catalog, or from a share link: ttheme add https://ttheme.vercel.app/p/tt2:…",section:"catalog",flags:{market:{type:"string",value:"<source>",about:"Add this market first — a repository, a folder or official — and take bare palette names from it"}}},{name:"remove",args:["<palette...>"],about:"Uninstall palettes",section:"catalog"},{name:"update",args:["[market...]"],about:"Update ttheme and refresh your markets — official palettes come with ttheme; an installed palette from another market keeps its colors until Browse's Installed tab takes its update",section:"catalog"},{name:"market",args:["[action]","[source]"],about:"The markets you added — add, remove and search them; init makes one of your own",actions:[["(none)","List the markets you added — their palettes, auto-update and last update"],["add <source>","Add a market — a repository (alice/ttheme-pastel, #v1 pins a tag or branch), a folder, or official; asks whether it updates on its own"],["remove <market>","Drop one by its name (alice@pastel) — the palettes you installed from it keep working"],["search [query]","Repositories on GitHub with the ttheme-market topic"],["init [name]","Make a market of your own — <you>@<name>, in ~/.config/ttheme/market/<name> or a folder you give"],["check [dir]","Check a market's folder before you push it — ttheme-market.toml, every palette, the renames and the gate; nothing is written"]],section:"catalog"},{name:"new",args:["<name>"],about:"Make a palette of your own in the palette editor — <you>@<market>/<name>, from blank, installed at once",section:"own",flags:{from:{type:"string",value:"<palette>",about:"Start from this palette's colors instead of blank"},in:{type:"string",value:"<market>",about:"The local market to put it in — when you have more than one"}}},{name:"edit",args:["[palette]"],about:"Change a palette in the palette editor — your own in its file, any other as your tone over its market's colors, which R and s in the editor put back; with none named, asks to edit the one this tab wears",section:"own"},{name:"check",args:["[palette]"],about:"Measure a palette against the contrast gate — where it misses, suggest colors that pass; with none named, asks to check the one this tab wears",section:"own",flags:{fix:{type:"boolean",about:"Write the suggested colors into your palette"}}},{name:"share",args:["[palette]"],about:"Print a share link and its QR code — the page shows the palette, and ttheme add <link> installs it anywhere, pictures included; with none named, asks to share the one this tab wears — or shares it without asking when the link goes to a pipe",section:"own",flags:{tone:{type:"string",value:"<tuned|original>",choices:["tuned","original"],about:"Share it as you tuned it, or as it was — asked when you tuned it and omit this"}}},{name:"init",args:[],about:"Install the shell layer and wire your terminals",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Accept every default without prompting"}}},{name:"uninstall",args:[],about:"Remove ttheme — its block comes out of every terminal config and what it wrote is deleted",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Remove without asking"}}},{name:"wire",args:["<terminal>"],about:"Wire one more terminal into this setup, after showing what it edits — the shell offers it in a terminal that paints only through the config init would have wired",section:"setup",hidden:!0},{name:"info",args:[],about:"Print what a bug report needs — version, OS, shell, terminal and the settings you changed",section:"support"},{name:"build",args:[],about:"Emit dist/ for every terminal, plus the zsh palette table — from a checkout",section:"setup",hidden:!0,flags:{only:{type:"string",multiple:!0,value:"<terminal>",choices:ee,about:"Rebuild just this terminal — repeat it for more"}}},{name:"find",args:["<palette>"],about:"Pick a booru background for a palette — preview opens this on tab",section:"setup",hidden:!0},{name:"image",args:["<palette>","<action>","[picture]"],about:"Show one of a palette's saved backgrounds, remove one, draw one in its palette's tone or its own colors (or get the other ready before it is asked for), or pass on tuning — preview calls this",section:"setup",hidden:!0},{name:"flatten",args:["<source>","<out>","<background>","<opacity>","[canvas]","[place]","[into]"],about:"Lay a picture on a background color at an opacity, placed on a canvas when given one, for Warp, which fades the window instead, and Terminal.app, which takes it written into the file its profile points at and renamed to the out — preview calls this",section:"setup",hidden:!0},{name:"bake",args:["<source>","<out>","<canvas>","<place>"],about:"Place a picture on a transparent canvas the way sips bakes preview's tuning — preview in Warp calls this",section:"setup",hidden:!0},{name:"tone",args:["<palette>","<action>","[width]"],about:"Print a palette's colors for preview's panel at its width, open them in the palette editor, or reset them to its market's — preview calls this",section:"setup",hidden:!0},{name:"sync",args:[],about:"Write every wired terminal's config again from what is installed and config.zsh — ttheme config and preview call this when TTHEME_TAB_PALETTE changed",section:"setup",hidden:!0},{name:"redraw",args:[],about:"Draw the background pictures again after TTHEME_BG_BLUR changed — ttheme config and preview call this",section:"setup",hidden:!0},{name:"latest",args:[],about:"Ask npm for the newest ttheme — any command starts this in the background once a day",section:"setup",hidden:!0},{name:"names",args:[],about:"Download aninames' character names when its release changed and index them — any command starts this in the background once a day",section:"setup",hidden:!0}];function VT(t){let e=Object.entries(t.flags??{}).map(([n,{value:r}])=>`[--${n}${r?` ${r}`:""}]`);return[t.name,...e,...t.args].join(" ")}function fs(t,e=XT){return t.map(([n,r])=>` ${n.padEnd(e)} ${r}`)}function py(t){return t.split(" — ")[0]}function by(t){return Object.entries(t.flags??{}).map(([e,{short:n,value:r,about:i}])=>[`${n?`-${n}, `:""}--${e}${r?` ${r}`:""}`,i])}function wy(t,e){let n=e?[...t.actions??[],...by(t)]:[];return[[[t.name,...t.args].join(" "),py(t.about)],...n.map(([r,i])=>[` ${r}`,py(i)])]}var $y=[`ttheme ${ft.version}`,ft.description,"Usage: ttheme <command> [options] [args]"],ky=[["ttheme help","Every command"],["ttheme help all","Every command with its options, and examples"],["ttheme help <command>","One command in full"]],yy=[["-h, --help","Show help — after a command, that command's"],["-v, --version","Print the version"]],XT=Math.max(...[...ky,...yy,...ds.filter((t)=>!t.hidden).flatMap((t)=>wy(t,!0))].map(([t])=>t.length)),gy=[["npx @kecan0406/ttheme init -y","Wire the terminals found here, no prompts"],["ttheme add homura madoka","Install two palettes"],["ttheme use homura","Paint this tab with one"],["ttheme list --json madoka","The madoka series as JSON"],["ttheme market add alice/ttheme-pastel","alice's market, alice@pastel — ttheme add alice@pastel/dusk"],["ttheme add dusk --market alice/ttheme-pastel","The same in one step"],["ttheme new rei --from rei","Your own rei, <you>@<market>/rei, to edit and share"]];function vy(){return[...$y,"","Use --help to list every command, or init to set ttheme up"].join(`
|
|
351
|
-
`)}function
|
|
352
|
-
`)}function
|
|
353
|
-
`)}import{readFileSync as
|
|
348
|
+
`}}}}).prompt();import{existsSync as gl,readFileSync as U1,rmSync as Zm}from"node:fs";import{homedir as hn}from"node:os";import{join as Ss}from"node:path";var fy=44,Yt=[{name:"Shell",lines:["«B4»~/code/demo«d» on «5»main«2» +2«3» ~1","«2»❯ «»git status -sb","«w»## «2»main«»...«1»origin/main«3» [ahead 1]","«1» M«» src/main.rs","«1»??«» notes.md","","«w»«2»❯ «»ls","«w»«B4»docs«» «B4»src«» «B4»tests«» Cargo.toml README.md","«w»","«2»❯ «»cargo test","«2» ✓«» parses config","«n»«1» ✗«» renders frame","«w»«1» ✗«» renders frame«d» expected «2»3«d», received «1»2","","«2»❯ «»echo «s»selected text«» «c» "]},{name:"Code",lines:["«d» 12 │ «5»import«» { readFile } «5»from «2»'node:fs/promises'","«d» 13 │","«d» 14 │ «8»// Read a palette and check its sixteen colors","«d» 15 │ «5»export async function «4»load«»(path: «6»string«») {","«d» 16 │ «5»const«» text = «5»await «4»readFile«»(path, «2»'utf8'«»)","«b» 17 «d»│ «5»const«» colors = «s»parse(text)«».colors ?? {}","«d» 18 │ «5»if«» (colors.ansi.length !== «3»16«») {","«d» 19 │ «5»throw new «6»Error«»(«2»'needs 16 colors'«»)","«d» 20 │ }","«d» 21 │ «5»return«» { ...colors, ratio: «c»4«3».5«» }","«d» 22 │ }"]},{name:"Diff",lines:["«2»❯ «»git diff --stat","«» src/theme.ts | 3 «2»++«1»-","«2»❯ «»git diff","«b»diff --git a/src/theme.ts b/src/theme.ts","«6»@@ -16,3 +16,4 @@«» export async function load(","«» const text = await readFile(path, 'utf8')","«1»- const colors = parse(text).colors","«2»+ const colors = parse(text).colors ?? {}","«2»+ const ratio = contrast(colors)","«2»❯ «»git log --oneline --graph -4","«3»* 3f2a1c9 («B6»HEAD -> «B2»main«3»)«» Check contrast on load","«3»* 9b04e7d«» Merge branch ansi","«1»|«5»\\","«1»| «5»* «3»51cd0aa«» Add sixteen ANSI colors","«1»|«5»/","«3»* 07be2f1 («B1»origin/main«3», «B3»tag: v1.0«3»)«» Read palette files"]},{name:"Logs",lines:["«2»❯ «»npm run dev","«B2» VITE v6.2.0«d» ready in «b»412«d» ms","«2» ➜ «b»Local«»: «6»http://localhost:5173/","«d»10:42:07 «2»INFO «» GET /api/palettes «2»200«d» 12 ms","«d»10:42:08 «2»INFO «» GET /api/themes/kita «2»200«d» 8 ms","«d»10:42:09 «3»WARN «» slow query: palettes «3»812 ms","«d»10:42:10 «4»DEBUG«» cache hit themes/kita","«d»10:42:11 «B1»ERROR«» POST /api/share «1»500«d» 41 ms","«1» Error«»: read ECONNRESET","«d» at «»TCP.onStreamRead «d»(«6»node:net:216:20«d»)","«d» at «»share «d»(«6»src/share.ts:48:11«d»)","«d»10:42:12 «2»INFO «» retry 1/3 in 200 ms"]},{name:"Monitor",lines:["«6» 1 «b»[«2»|||||||||||||«1»||«» 42.1%«b»]«6» Tasks: «b»128«», 412 thr; «B2»3«» running","«6» 2 «b»[«2»||||||«4»||«» 21.4%«b»]«6» Load average: «b»1.42 «»1.18 0.97","«6» 3 «b»[«2»||||||||||||||«1»|||||«» 71.0%«b»]«6» Uptime: «b»3 days, 04:12:55","«6» 4 «b»[«2»||«» 7.9%«b»]","«6» Mem«b»[«2»||||||||«4»||«3»||«» 6.21G/16.0G«b»]","«6» Swp«b»[«1»|«» 0.10G/2.00G«b»]","","«K2» PID USER CPU% MEM% TIME+ Command ","«s» 4127 kec 38.2 2.1 3:12.44 node dev.js ","«» 2210 kec 12.0 4.8 1:02.10 «b»ghostty","«» 3301 kec 4.4 1.2 0:05.61 «b»zsh","«» 812 «1»root«» 3.1 0.3 0:44.02 «d»kernel_task","«» 167 «1»root«» 0.9 0.1 0:12.80 «d»WindowServer"]}];function zi(t){let e=Yt.length;return Yt[(t%e+e)%e]}function us(t,e){let n=t.split("«"),r=n[0]?[[n[0],""]]:[];for(let i of n.slice(1)){let o=i.indexOf("»"),s=i.slice(0,o),a=i.slice(o+1);if(s==="w"||s==="n"){if(s==="w"!==e>=44)return}if(a)r.push([a,s==="w"||s==="n"?"":s])}return r}import{createHash as YT}from"node:crypto";import{existsSync as Du,readFileSync as om,rmSync as py}from"node:fs";import{homedir as gy}from"node:os";import{join as qi}from"node:path";function Zr(t){return[`# ${t.name} — ${t.group}${t.native?` (${t.native})`:""}`,`# ANSI: ${t.ansiSource}`]}function ar(t,e){return[`[${t}]`,`Color=${ot(e).join(",")}`,""]}function Xh(t,e,n=["Wallpaper="]){let r=(i)=>Rt(i,t.background,0.5);return[...ar("Background",t.background),...ar("BackgroundFaint",t.background),...ar("BackgroundIntense",t.background),...t.ansi.slice(0,8).flatMap((i,o)=>[...ar(`Color${o}`,i),...ar(`Color${o}Faint`,r(i)),...ar(`Color${o}Intense`,t.ansi[o+8])]),...ar("Foreground",t.foreground),...ar("ForegroundFaint",r(t.foreground)),...ar("ForegroundIntense",t.foreground),"[General]","Blur=false","ColorRandomization=false",`Description=${e}`,"Opacity=1",...n,""]}var dy={left:"0",top:"0",center:"0.5",right:"1",bottom:"1"};function BT(t){if(!t||t.opacity<=0)return["Wallpaper="];let[e="center",n="center"]=t.position.split("-");return[`Wallpaper=${t.image}`,`FillStyle=${t.cover?"Crop":"Adapt"}`,`Anchor=${dy[n]??"0.5"},${dy[e]??"0.5"}`,`WallpaperOpacity=${t.opacity}`]}function Qh(t,e){return[...Zr(t),"",...Xh(t,`ttheme · ${t.name}`,BT(e))].join(`
|
|
349
|
+
`)}var tm={id:"konsole",limits:"draws no OSC 4, so a tab repaints by switching color scheme",emit(t){return[{path:`konsole/${j(t.name)}.colorscheme`,content:Qh(t)}]}};import{openSync as UT,writeSync as WT}from"node:fs";import{ReadStream as KT}from"node:tty";var un=["11","10","12","17",...Array.from({length:16},(t,e)=>`4;${e}`)];function Ht(t=process.env){return Boolean(t.NO_COLOR)||t.TERM==="dumb"}function zT(t,e){return`\x1B]${un[t]};${e}\x1B\\`}function cr(t,e){return[t.background,t.foreground,t.cursor,t.selection,...t.ansi].map((n,r)=>e&&!e.includes(r)?"":zT(r,n)).join("")}function qT(t){return`\x1B]${t.startsWith("4;")?`104;${t.slice(2)}`:`1${t}`}\x1B\\`}function DT(t){let e=new Map;for(let n of t.split("\x1B")){let r=n.match(/^\](\d+(?:;\d+)?);(rgba?:[0-9a-fA-F/]+)/),[,i,o]=r??[];if(i&&o)e.set(i,o)}return e}function hy(t){return`#${t.slice(t.indexOf(":")+1).split("/").slice(0,3).map((n)=>n.slice(0,2).padStart(2,"0")).join("")}`}function my(t){return un.map((e)=>{let n=t.get(e);return n?hy(n):void 0})}function zu(t,e=[...t.keys()],n=!1){return e.map((r)=>{let i=t.get(r);return i?`\x1B]${r};${n?hy(i):i}\x1B\\`:qT(r)}).join("")}function qu(t,e){return`\x1B]50;ColorScheme=${t};UseCustomCursorColor=true;customCursorColor=${e}\x07`}function em(t=un,e="\x1B[5n"){return`${t.map((n)=>`\x1B]${n};?\x1B\\`).join("")}${e}`}function JT(t){return t.includes("\x1B[0n")}async function nm(t=un){let e,n;try{e=UT("/dev/tty","r+"),n=new KT(e),n.setRawMode(!0)}catch{return new Map}try{WT(e,em(t));let r="";return await new Promise((i)=>{let o=setTimeout(i,120);n.on("data",(s)=>{if(r+=s.toString(),JT(r))clearTimeout(o),i()})}),DT(r)}finally{n.setRawMode(!1),n.destroy()}}function sm(t){if(t.NVIM)return"nvim";if(t.VIM_TERMINAL)return"vim";if(t.INSIDE_EMACS)return"emacs";return t.TERM_PROGRAM==="vscode"?"vscode":void 0}function Vt(t){if(sm(t))return"editor";if(t.TERM_PROGRAM==="WarpTerminal")return"warp";if(t.GHOSTTY_RESOURCES_DIR||t.TERM_PROGRAM==="ghostty")return"ghostty";if(t.KITTY_WINDOW_ID)return"kitty";if(t.WEZTERM_PANE)return"wezterm";if(t.ALACRITTY_WINDOW_ID)return"alacritty";if(t.KONSOLE_VERSION)return"konsole";if(t.ITERM_SESSION_ID||t.TERM_PROGRAM==="iTerm.app")return"iterm2";if(t.TERM_PROGRAM==="Apple_Terminal")return"terminal-app";if(t.WT_SESSION&&!t.TERM_PROGRAM)return"windows-terminal";if(t.TERM?.startsWith("foot"))return"foot";return"unknown"}var $e={ghostty:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},kitty:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},iterm2:{links:!0,pictures:!0,bands:!0,files:!0,moves:!0,layers:!0,paints:!0,repaint:[0,1]},wezterm:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!1,paints:!0,wipes:!0,views:!0},alacritty:{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},"windows-terminal":{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},konsole:{links:!1,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0,repaint:[0,1],hex:!0,schemes:!0},foot:{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},"terminal-app":{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},warp:{links:!0,pictures:!0,bands:!0,files:!1,moves:!1,layers:!1,paints:!1},editor:{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!1},unknown:{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0}};function rm(t,e,n){let r="";for(let i of t.split(`
|
|
350
|
+
`)){let o=i.trim();if(o.startsWith("[")&&o.endsWith("]"))r=o.slice(1,-1);else if(r===e&&o.startsWith(`${n}=`))return o.slice(n.length+1)}return}function VT(t){let e=t.XDG_CONFIG_HOME??qi(gy(),".config"),n=qi(e,"konsolerc"),r=Du(n)?rm(om(n,"utf8"),"Desktop Entry","DefaultProfile"):void 0;for(let i=0;i<8&&r&&r!=="FALLBACK/";i++){let o=r.endsWith(".profile")?r:`${r}.profile`,s=ky(t).map((u)=>qi(u,o)).find((u)=>Du(u));if(!s)return!1;let a=om(s,"utf8"),c=rm(a,"Interaction Options","AllowEscapedLinks");if(c!==void 0)return c==="true";r=rm(a,"General","Parent")}return!1}function by(t){let e=Vt(t);return e==="konsole"?VT(t):$e[e].links}function ls(t,e){let n=Vt(t),r=$e[n];return r.pictures&&!t.TMUX&&(!r.views||e.includes(n))}function Ju(t){return $e[Vt(t)].bands}function Yu(t){return $e[Vt(t)].files}function fs(t){return $e[Vt(t)].layers}function wy(t){return $e[Vt(t)].moves}function $y(t){return $e[Vt(t)].wipes===!0}function Di(t){return $e[Vt(t)].views===!0}function Ji(t){return`\x1B]1337;SetUserVar=ttheme_view=${Buffer.from(t).toString("base64")}\x07`}var Yi="\x1B[H\x1B[K\x1B[2H\x1B[J\x1B[H",am=120,im=4,ZT=40;function XT(t){let e=t.TTHEME_ITERM_SHOWN;return t.TTHEME_ITERM_SWITCH==="1"&&t.TTHEME_ITERM_DYED==="0"&&e?`ttheme · ${e}`:void 0}function QT(t,e){let n=$e.iterm2.repaint??[],r=un.map((c,u)=>u).filter((c)=>!n.includes(c)),i=new Set(n),o=XT(t),s=[],a=()=>{for(let c of s)clearTimeout(c);s=[]};return{slots:n,paint(c){a();for(let u=0;u<r.length;u+=im){let f=r.slice(u,u+im),l=setTimeout(()=>{for(let d of f)i.add(d);e(cr(c,f))},am+u/im*ZT);l.unref?.(),s.push(l)}return cr(c,n)},wear:(c)=>cr(c),saved:()=>nm(),restore(c){a();let u=un.filter((f,l)=>i.has(l));return o?`\x1B[?2026h${zu(new Map,u)}\x1B]1337;SetProfile=${o}\x07\x1B[?2026l`:zu(c,u)},stop:a}}var tH=3,eH=/^(Wallpaper|FillStyle|Anchor|WallpaperOpacity|WallpaperFlipType)=/;function ky(t){return[t.XDG_DATA_HOME??qi(gy(),".local","share"),...(t.XDG_DATA_DIRS||"/usr/local/share:/usr/share").split(":")].map((e)=>qi(e,"konsole"))}function nH(t,e){let n=/(?:^|;)ColorScheme=([^;]+)/.exec(e)?.[1],r=n&&t.map((c)=>qi(c,`${n}.colorscheme`)).find((c)=>Du(c));if(!r)return["Wallpaper="];let i=om(r,"utf8").split(`
|
|
351
|
+
`),o=i.findIndex((c)=>c.trim()==="[General]"),s=i.findIndex((c,u)=>u>o&&c.trimStart().startsWith("[")),a=o<0?[]:i.slice(o+1,s<0?void 0:s).filter((c)=>eH.test(c));return a.length>0?a:["Wallpaper="]}function rH(t,e){let n=ky(t),r=n[0],i=nH(n,e),o=[],s=(c,u,f)=>{let l=Xh(u,`ttheme · ${c}`,i).join(`
|
|
352
|
+
`),d=`${j("view")}.${YT("sha1").update(l).digest("hex").slice(0,10)}`,h=qi(r,`${d}.colorscheme`);if(!Du(h))C(h,l);if(!o.includes(h))o.push(h);for(let m of o.splice(0,Math.max(0,o.length-tH)))py(m,{force:!0});return qu(d,f)},a=()=>{for(let c of o.splice(0))py(c,{force:!0})};return{slots:[],paint:(c)=>s(c.name,c,c.cursor),wear:(c,u)=>u.includes("konsole")?qu(j(c.name),c.cursor):void 0,saved:async()=>new Map,restore:()=>{return a(),`\x1B]50;${e}\x07`},stop:a}}function yy(t,e,n=(r)=>{process.stdout.write(r)}){let r=Vt(t),i=$e[r];if(!e||Ht(t)||t.TMUX||!i.paints)return;if(r==="iterm2")return QT(t,n);if(r==="konsole"&&t.TTHEME_KONSOLE_LOOK)return rH(t,t.TTHEME_KONSOLE_LOOK);let o=i.repaint??un.map((a,c)=>c),s=un.filter((a,c)=>o.includes(c));return{slots:o,paint:(a)=>cr(a,o),wear:(a,c)=>!i.schemes?cr(a):c.includes(r)?qu(j(a.name),a.cursor):void 0,saved:()=>nm(s),restore:(a)=>zu(a,s,i.hex===!0)}}var ee=["ghostty","kitty","alacritty","wezterm","iterm2","windows-terminal","warp","konsole","terminal-app"];var iH=[{section:"tab",title:"This tab"},{section:"startup",title:"New tabs"},{section:"catalog",title:"Palettes"},{section:"own",title:"Your own"},{section:"setup",title:"Setup"},{section:"support",title:"Support"}],hs=[{name:"use",args:["<palette>"],about:"Paint this tab — a unique prefix works: ttheme use ho",section:"tab",shell:!0},{name:"default",args:["<palette>"],about:"Make a palette the one new tabs open with",section:"startup"},{name:"on",args:[],about:"Wear the default palette in new tabs again",section:"startup"},{name:"off",args:[],about:"Take the palette and picture off every tab — the terminal's own colors until `ttheme on`",section:"startup"},{name:"pin",args:["[dir|ssh:<host>]"],about:"Pin a palette to a directory or an ssh host — the pin covers everything below it, or its whole repository; cd or ssh in repaints, leaving restores",section:"tab",shell:!0},{name:"unpin",args:["[dir|ssh:<host>]"],about:"Drop a pin — this directory's, every one below it, the one above that paints it, or an ssh host's",section:"tab",shell:!0},{name:"pins",args:[],about:"Map every pin as a file tree — the pinned directories in their palettes' colors, every ssh host, and the pin that covers this one",section:"tab",shell:!0},{name:"config",args:[],about:"Edit settings in $EDITOR — they apply in new tabs",section:"startup",shell:!0},{name:"browse",args:[],about:"Pick palettes and markets in a live picker — one list with every market as a row, which ctrl+s narrows to one market at a time",section:"catalog",hidden:!0},{name:"list",args:["[query]"],about:"Show the catalog, marking what is installed",section:"catalog",flags:{json:{type:"boolean",about:"Print the matches as JSON — name, group, catalog, installed"}}},{name:"add",args:["<palette...>"],about:"Install palettes — from the catalog, or from a share link: ttheme add https://ttheme.vercel.app/p/tt2:…",section:"catalog",flags:{market:{type:"string",value:"<source>",about:"Add this market first — a repository, a folder or official — and take bare palette names from it"}}},{name:"remove",args:["<palette...>"],about:"Uninstall palettes",section:"catalog"},{name:"update",args:["[market...]"],about:"Update ttheme and refresh your markets — official palettes come with ttheme; an installed palette from another market keeps its colors until ctrl+r on it in Browse takes its update",section:"catalog"},{name:"market",args:["[action]","[source]"],about:"The markets you added — add, remove and search them; init makes one of your own",actions:[["(none)","List the markets you added — their palettes, auto-update and last update"],["add <source>","Add a market — a repository (alice/ttheme-pastel, #v1 pins a tag or branch), a folder, or official; asks whether it updates on its own"],["remove <market>","Drop one by its name (alice@pastel) — the palettes you installed from it keep working"],["search [query]","Repositories on GitHub with the ttheme-market topic"],["init [name]","Make a market of your own — <you>@<name>, in ~/.config/ttheme/market/<name> or a folder you give"],["check [dir]","Check a market's folder before you push it — ttheme-market.toml, every palette, the renames and the gate; nothing is written"]],section:"catalog"},{name:"new",args:["<name>"],about:"Make a palette of your own in the palette editor — <you>@<market>/<name>, from blank, installed at once",section:"own",flags:{from:{type:"string",value:"<palette>",about:"Start from this palette's colors instead of blank"},in:{type:"string",value:"<market>",about:"The local market to put it in — when you have more than one"}}},{name:"edit",args:["[palette]"],about:"Change a palette in the palette editor — your own in its file, any other as your tone over its market's colors, which R and s in the editor put back; with none named, asks to edit the one this tab wears",section:"own"},{name:"check",args:["[palette]"],about:"Measure a palette against the contrast gate — where it misses, suggest colors that pass; with none named, asks to check the one this tab wears",section:"own",flags:{fix:{type:"boolean",about:"Write the suggested colors into your palette"}}},{name:"share",args:["[palette]"],about:"Print a share link and its QR code — the page shows the palette, and ttheme add <link> installs it anywhere, pictures included; with none named, asks to share the one this tab wears — or shares it without asking when the link goes to a pipe",section:"own",flags:{tone:{type:"string",value:"<tuned|original>",choices:["tuned","original"],about:"Share it as you tuned it, or as it was — asked when you tuned it and omit this"}}},{name:"init",args:[],about:"Install the shell layer and wire your terminals",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Accept every default without prompting"}}},{name:"uninstall",args:[],about:"Remove ttheme — its block comes out of every terminal config and what it wrote is deleted",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Remove without asking"}}},{name:"wire",args:["<terminal>"],about:"Wire one more terminal into this setup, after showing what it edits — the shell offers it in a terminal that paints only through the config init would have wired",section:"setup",hidden:!0},{name:"info",args:[],about:"Print what a bug report needs — version, OS, shell, terminal and the settings you changed",section:"support"},{name:"build",args:[],about:"Emit dist/ for every terminal, plus the zsh palette table — from a checkout",section:"setup",hidden:!0,flags:{only:{type:"string",multiple:!0,value:"<terminal>",choices:ee,about:"Rebuild just this terminal — repeat it for more"}}},{name:"find",args:["<palette>"],about:"Pick a booru background for a palette — preview opens this on tab",section:"setup",hidden:!0},{name:"image",args:["<palette>","<action>","[picture]"],about:"Show one of a palette's saved backgrounds, remove one, draw one in its palette's tone or its own colors (or get the other ready before it is asked for), or pass on tuning — preview calls this",section:"setup",hidden:!0},{name:"flatten",args:["<source>","<out>","<background>","<opacity>","[canvas]","[place]","[into]"],about:"Lay a picture on a background color at an opacity, placed on a canvas when given one, for Warp, which fades the window instead, and Terminal.app, which takes it written into the file its profile points at and renamed to the out — preview calls this",section:"setup",hidden:!0},{name:"bake",args:["<source>","<out>","<canvas>","<place>"],about:"Place a picture on a transparent canvas the way sips bakes preview's tuning — preview in Warp calls this",section:"setup",hidden:!0},{name:"tone",args:["<palette>","<action>","[width]"],about:"Print a palette's colors for preview's panel at its width, open them in the palette editor, or reset them to its market's — preview calls this",section:"setup",hidden:!0},{name:"sync",args:[],about:"Write every wired terminal's config again from what is installed and config.zsh — ttheme config and preview call this when TTHEME_TAB_PALETTE changed",section:"setup",hidden:!0},{name:"redraw",args:[],about:"Draw the background pictures again after TTHEME_BG_BLUR changed — ttheme config and preview call this",section:"setup",hidden:!0},{name:"latest",args:[],about:"Ask npm for the newest ttheme — any command starts this in the background once a day",section:"setup",hidden:!0},{name:"names",args:[],about:"Download aninames' character names when its release changed and index them — any command starts this in the background once a day",section:"setup",hidden:!0}];function oH(t){let e=Object.entries(t.flags??{}).map(([n,{value:r}])=>`[--${n}${r?` ${r}`:""}]`);return[t.name,...e,...t.args].join(" ")}function ds(t,e=sH){return t.map(([n,r])=>` ${n.padEnd(e)} ${r}`)}function vy(t){return t.split(" — ")[0]}function Ey(t){return Object.entries(t.flags??{}).map(([e,{short:n,value:r,about:i}])=>[`${n?`-${n}, `:""}--${e}${r?` ${r}`:""}`,i])}function My(t,e){let n=e?[...t.actions??[],...Ey(t)]:[];return[[[t.name,...t.args].join(" "),vy(t.about)],...n.map(([r,i])=>[` ${r}`,vy(i)])]}var xy=[`ttheme ${lt.version}`,lt.description,"Usage: ttheme <command> [options] [args]"],Oy=[["ttheme help","Every command"],["ttheme help all","Every command with its options, and examples"],["ttheme help <command>","One command in full"]],Iy=[["-h, --help","Show help — after a command, that command's"],["-v, --version","Print the version"]],sH=Math.max(...[...Oy,...Iy,...hs.filter((t)=>!t.hidden).flatMap((t)=>My(t,!0))].map(([t])=>t.length)),Sy=[["npx @kecan0406/ttheme init -y","Wire the terminals found here, no prompts"],["ttheme add homura madoka","Install two palettes"],["ttheme use homura","Paint this tab with one"],["ttheme list --json madoka","The madoka series as JSON"],["ttheme market add alice/ttheme-pastel","alice's market, alice@pastel — ttheme add alice@pastel/dusk"],["ttheme add dusk --market alice/ttheme-pastel","The same in one step"],["ttheme new rei --from rei","Your own rei, <you>@<market>/rei, to edit and share"]];function Py(){return[...xy,"","Use --help to list every command, or init to set ttheme up"].join(`
|
|
353
|
+
`)}function cm(t){let e=Ey(t);return[`Usage: ttheme ${oH(t)}`,"",t.about,...t.actions?["","Actions:",...ds(t.actions)]:[],...e.length>0?["","Options:",...ds(e)]:[]].join(`
|
|
354
|
+
`)}function Aa(t,e=!1){let n=hs.filter((i)=>!i.hidden&&!(e&&i.section==="setup")),r=iH.filter(({section:i})=>n.some((o)=>o.section===i));return[...xy,"ttheme alone opens Preview and Browse as tabs — tab and shift+tab move between them","","Getting help:",...ds(Oy),"","Global options:",...ds(Iy),...r.flatMap(({section:i,title:o})=>["",`${o}:`,...ds(n.filter((s)=>s.section===i).flatMap((s)=>My(s,t)))]),...t?["","Examples:",...ds(Sy,Math.max(...Sy.map(([i])=>i.length)))]:[],"","https://ttheme.vercel.app"].join(`
|
|
355
|
+
`)}import{readFileSync as aH}from"node:fs";import{join as cH}from"node:path";var um="# ttheme begin",lm="# ttheme end",Vi=/# ttheme begin\n[\s\S]*?# ttheme end\n?/,ke="Managed by ttheme — npx @kecan0406/ttheme@latest uninstall takes it out",Rn="Generated by ttheme — rewritten on every add, remove and default; do not edit.";function Xr(t,e,n){return t.startsWith(`${e}/`)?`${n}${t.slice(e.length)}`:void 0}function Qr(t,e){let n=`${um}
|
|
354
356
|
${e}
|
|
355
|
-
${
|
|
356
|
-
`;if(
|
|
357
|
+
${lm}
|
|
358
|
+
`;if(Vi.test(t))return t.replace(Vi,n);if(t==="")return n;return`${t.replace(/\n*$/,`
|
|
357
359
|
`)}
|
|
358
|
-
${n}`}function
|
|
359
|
-
`)}function ms(t,e){let n=t.replace(
|
|
360
|
-
[[ -r ${
|
|
360
|
+
${n}`}function Nn(t){let e=t.replace(/\n?# ttheme begin\n[\s\S]*?# ttheme end(?=\n|$)/,"");if(e===t)return t;return e.trim()===""?"":e.replace(/\n*$/,`
|
|
361
|
+
`)}function ms(t,e){let n=t.replace(Vi,"");return new RegExp(String.raw`^[ \t]*${e}(?:[ \t]*=|[ \t]+\S)`,"m").test(n)}var Vu='"${XDG_CONFIG_HOME:-$HOME/.config}/ttheme/ttheme.zsh"';function Ry(){return`# ${ke}
|
|
362
|
+
[[ -r ${Vu} ]] && source ${Vu}`}var uH="# ttheme settings — uncomment a line to change it; exported variables win over this file",ps={TTHEME_TAB_PALETTE:{doc:"# new tabs: off keeps the configured terminal theme, seq rotates through the palettes (default off)",default:"off"},TTHEME_ANNOUNCE:{doc:'# the palette notice under "Last login:": 1 shows it, 0 silences it (default 1)',default:"1"},TTHEME_FX:{doc:"# search hint animation: typewriter, decode or glitch (default typewriter)",default:"typewriter"},TTHEME_SORT:{doc:"# series and palettes in ttheme and preview: abc sorts them by name, series keeps the order they were added (default abc)",default:"abc"},TTHEME_MOUSE:{doc:"# clicks, the wheel and drags in preview, browse, the palette editor and find: on, or off to leave the mouse to the terminal, so a drag selects text again without a modifier (default on)",default:"on"},TTHEME_BG_BLUR:{doc:"# soften the background pictures behind the text: a blur radius in screen pixels, 0 keeps them sharp — changing it draws every picture again (default 0)",default:"0"},TTHEME_BG_COLORS:{doc:"# the colors new background pictures are drawn in: tone tints a picture in one color of its palette, original keeps its own — preview switches each picture later (default tone)",default:"tone"},TTHEME_WARP_FAST:{doc:"# Warp tab switches: on keeps Warp rereading its settings while it is in front with tabs of different palettes, so the tab you switch to shows its palette in about 0.2 s instead of 0.6 s — about 8% CPU meanwhile; off leaves it to Warp (default on)",default:"on"},TTHEME_NAMES:{doc:"# character names in every language for searching palettes and find's search box, from aninames' weekly release: on downloads them (about 7 MB) and checks once a day in the background; off leaves them as they are (default on)",default:"on"},TTHEME_AUTO_UPDATE:{doc:"# checks in the background: on refreshes the markets you set to update on their own once a day and says when a newer ttheme is out; off leaves both to ttheme update (default on)",default:"on"},TTHEME_MARKET_LOOKUP:{doc:"# GitHub lookups in browse: on looks GitHub up by itself — the markets carrying the ttheme-market topic when browse opens or you type, and the palettes of a repository you type or move onto; off waits for space (default on)",default:"on"},TTHEME_FIND_RATING:{doc:"# the ratings find lists, any of safe, questionable and explicit, each booru read in its own rating vocabulary (default safe)",default:"safe"},TTHEME_FIND_BLOCK:{doc:'# the posts find drops by tag: nudity, underwear, both, or none to keep them all (default "nudity underwear")',default:"nudity underwear"},TTHEME_FIND_POSTS:{doc:"# what find lists first: all is every post of the character, cutouts are the transparent ones (default all)",default:"all"},TTHEME_FIND_SOLO:{doc:"# on keeps the posts tagged solo, the character alone, by danbooru or zerochan; off lists every post (default on)",default:"on"},TTHEME_FIND_CUTOUTS:{doc:'# the tags find calls a transparent cutout, per site as key=tag,tag pairs — e.g. "konachan=transparent,vector yande=transparent_png" (default the built-in tags)',default:""},TTHEME_FIND_ORDER:{doc:"# the order find lists posts in: fit ranks each page by how well it makes a backdrop, newest or score (default fit)",default:"fit"},TTHEME_FIND_SETS:{doc:"# runs of the same picture at the same size from one uploader: fold shows them as one tile, show lists each (default fold)",default:"fold"},TTHEME_FIND_REMOVE_BG:{doc:"# an opaque picture tried on in find: on cuts the character out with macOS Vision, off leaves it as it is (default on)",default:"on"},TTHEME_FIND_MIN_SCORE:{doc:"# the lowest score find lists: off, or a number such as 5, 10, 25, 50 or 100 — danbooru, konachan and yande.re filter by it, zerochan keeps no score (default off)",default:"off"},TTHEME_FIND_MIN_SIZE:{doc:"# the shortest side a picture find lists must reach, in pixels: off, or a number such as 720, 1080, 1440, 1800 or 2560 (default off)",default:"off"},TTHEME_FIND_SITES:{doc:"# the sites find mixes in its all tab: any of danbooru, konachan, yande.re and zerochan (default all four)",default:"danbooru konachan yande.re zerochan"},TTHEME_FIND_HIDE:{doc:"# the kinds of picture find leaves out by tag: comic, monochrome, sketch, chibi, or none to keep them all (default none)",default:"none"},TTHEME_FIND_HIDE_TAGS:{doc:'# more tags find leaves out, spaced — e.g. "cosplay multiple_girls" (default none)',default:""},TTHEME_FIND_PNG:{doc:"# on lists PNG originals only — a zerochan post counts only where danbooru holds the same file (default off)",default:"off"},TTHEME_FIND_HOSTS:{doc:'# send a find site somewhere else, as key=https://host pairs — e.g. "danbooru=https://danbooru.donmai.us" (default none)',default:""}};function Ta(t){return ps[t]?.default}function fm(t,e){let n=`: \${${t}:=${e}}`;return Ta(t)===e?`# ${n}`:n}function Ny(t){return new RegExp(String.raw`^#? ?: \$\{${t}[^\n]*$`,"m")}function lH(t,e){if(Ny(e).test(t))return t;let n=ps[e];return`${t.replace(/\n*$/,`
|
|
361
363
|
`)}
|
|
362
364
|
${n.doc}
|
|
363
|
-
${
|
|
364
|
-
`}var
|
|
365
|
-
${
|
|
365
|
+
${fm(e,n.default)}
|
|
366
|
+
`}var Zu=Object.keys(ps),fH=8;function gs(t,e){let n="";try{n=aH(cH(t,"ttheme","config.zsh"),"utf8")}catch{}return(new RegExp(String.raw`^: \$\{${e}:=([^}\n]*)\}`,"m").exec(n)?.[1]??ps[e].default).replace(/^(["'])(.*)\1$/,"$2")}function ti(t){let e=Number(gs(t,"TTHEME_BG_BLUR"));return Number.isFinite(e)?Math.min(fH,Math.max(0,e)):0}function Xu(t){return gs(t,"TTHEME_BG_COLORS")==="original"?"original":"tone"}function dm(){let t=Object.entries(ps).map(([e,n])=>`${n.doc}
|
|
367
|
+
${fm(e,n.default)}`);return`${[uH,...t].join(`
|
|
366
368
|
|
|
367
369
|
`)}
|
|
368
|
-
`}function
|
|
370
|
+
`}function Qu(t,e,n){let r=fm(e,n),i=Ny(e);if(i.test(t))return t.replace(i,r);return`${t.replace(/\n*$/,`
|
|
369
371
|
`)}
|
|
370
372
|
${r}
|
|
371
|
-
`}function
|
|
372
|
-
`)}function
|
|
373
|
-
`)}var
|
|
374
|
-
`).filter((n)=>n!==""&&!n.startsWith("#"));return[...new Set(e.map((n)=>n.split(/[ =]/)[0]))].join(", ")}function
|
|
375
|
-
`)}var
|
|
376
|
-
`);return[{path:`alacritty/themes/${
|
|
377
|
-
`);return[{path:`ghostty/themes/${
|
|
378
|
-
`}function
|
|
379
|
-
`)}var
|
|
380
|
-
`);return[{path:`iterm2/${
|
|
381
|
-
`);return[{path:`kitty/themes/${
|
|
382
|
-
`)}function
|
|
383
|
-
`}]}};var
|
|
384
|
-
${n.toLowerCase()}`,"utf8"))r=Math.imul(r^i,16777619)>>>0;return`${
|
|
385
|
-
`)}var
|
|
386
|
-
`);return[{path:`wezterm/colors/${
|
|
387
|
-
`)}var
|
|
388
|
-
`}var
|
|
389
|
-
`}]},emitShared(t){return[{path:"windows-terminal/ttheme.json",content
|
|
373
|
+
`}function Ay(t){if(t==="")return dm();return Object.keys(ps).reduce(lH,t)}var tl=/["$`\\]/;function dH(t){return t.replace(/_\([^)]*\)$/,"").replaceAll("_"," ")}function hm(t,e,n=[],r={},i=[]){for(let l of t)for(let d of[l.name,l.group,l.native??"",...l.nativeNames??[],l.ansiSource])if(tl.test(d))throw Error(`${l.name}: "${d}" contains a character that breaks zsh quoting`);let o=Math.max(0,...t.map((l)=>l.name.length)),s=(l,d)=>` ${l.name.padEnd(o)} "${d}"`,a=(l)=>l.map((d)=>d.name).join(" "),c=At(t),u=(l)=>`'${l.replaceAll("'","'\\''")}'`,f=hs.filter((l)=>l.section!=="setup"&&!l.hidden);return["# Generated by `mise run build` — do not edit.","# Source of truth: themes/*.toml in the ttheme repo.","",`typeset -g TTHEME_VERSION=${lt.version}`,"",'# the palette new tabs open with, which the iTerm2 "ttheme · default" profile wears',`typeset -g TTHEME_STARTUP=${e??""}`,"","# the terminals ttheme is wired into: a picture change reaches every one of them, from whichever runs the shell",`typeset -ga TTHEME_TERMINALS=(${n.join(" ")})`,...Object.keys(r).length>0?["","# what a wired terminal's adapter needs to know of it (src/terminals/)",...Object.entries(r).map(([l,d])=>`typeset -g ${l}=${u(d)}`)]:[],"","# the commands the shell layer knows (src/verbs.ts): help, completion and argument checks read them",`typeset -ga TTHEME_VERBS=(${f.map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_TAB_VERBS=(${f.filter((l)=>l.section==="tab").map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_SHELL_VERBS=(${f.filter((l)=>l.shell).map((l)=>l.name).join(" ")})`,"typeset -gA TTHEME_VERB_ARGS=(",...f.map((l)=>` ${l.name} ${u(l.args.join(" "))}`),")","typeset -gA TTHEME_VERB_ABOUT=(",...f.map((l)=>` ${l.name} ${u(l.about)}`),")",`typeset -g TTHEME_HELP=${u(Aa(!1,!0))}`,`typeset -g TTHEME_HELP_ALL=${u(Aa(!0,!0))}`,"","# the screens the bare ttheme switches between (src/hub.ts): the exit status of a screen run by the CLI says where it went",`typeset -ga TTHEME_HUB_TABS=(${ir.map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_HUB_TITLES=(${ir.map((l)=>l.title).join(" ")})`,`typeset -gi TTHEME_HUB_CLOSED=${Au} TTHEME_HUB_SWITCH=${Tu}`,"","# the settings config.zsh holds, handed to the CLI on every call",`typeset -ga TTHEME_SETTINGS=(${Zu.join(" ")})`,"","# seed for `ttheme config` when no config.zsh exists yet",`typeset -g TTHEME_CONFIG_TEMPLATE='${dm().trimEnd().replaceAll("'","'\\''")}'`,"","typeset -gA TTHEME_PALETTE=(",...t.map((l)=>s(l,[l.background,l.foreground,l.cursor,l.selection,...l.ansi].join(" "))),")","","# the palettes whose colors your tone moves off their market's (tone.json): lists mark them, and preview's panel offers to reset them",`typeset -ga TTHEME_TUNED=(${t.filter((l)=>i.includes(l.name)).map((l)=>l.name).join(" ")})`,"","# series order: new tabs cycle through it and TTHEME_SORT=series lists it — the default role stays applyable but unlisted",`typeset -ga TTHEME_ORDER=(${a(c)})`,"","# the same palettes by series name, then palette name: TTHEME_SORT=abc lists them this way",`typeset -ga TTHEME_ABC=(${a(Li(c))})`,"","typeset -gA TTHEME_GROUP=(",...t.map((l)=>s(l,l.group)),")","","# the catalog a market palette sits in — the folder under the market's palettes/, one level below the market in every list","typeset -gA TTHEME_CATALOG=(",...t.filter((l)=>l.catalog).map((l)=>s(l,l.catalog??"")),")","","# original-language title, rendered dim next to the group","typeset -gA TTHEME_NATIVE=(",...t.filter((l)=>l.native).map((l)=>s(l,l.native??"")),")","","# the character's names in its original language, |-separated, and as its booru tag spells it: preview searches both","typeset -gA TTHEME_NATIVE_NAMES=(",...t.filter((l)=>l.nativeNames).map((l)=>s(l,(l.nativeNames??[]).join("|"))),")","typeset -gA TTHEME_CHARACTER=(",...t.filter((l)=>l.booru&&!tl.test(l.booru)).map((l)=>s(l,dH(l.booru??""))),")","","# the example scenes preview draws beside the list (src/scenes.ts), each line as «role»text runs",`typeset -ga TTHEME_SCENES=(${Yt.map((l)=>l.name).join(" ")})`,...Yt.flatMap((l,d)=>[`typeset -ga TTHEME_SCENE_${d+1}=(`,...l.lines.map((h)=>` ${u(h)}`),")"]),"","# each booru's ANSI color, which marks a link to one of its posts",`typeset -gA TTHEME_SITE_ANSI=(${Z.map((l)=>`${l.name} ${l.ansi}`).join(" ")})`,"","# the terminals that open OSC 8 links (src/terminal.ts)",`typeset -ga TTHEME_LINKS=(${Object.entries($e).flatMap(([l,d])=>d.links?[l]:[]).join(" ")})`,"","# the six colors a list row shows: foreground, the signature, then red and green","typeset -gA TTHEME_SWATCH=(",...t.map((l)=>s(l,pu(l).join(" "))),")","","# where each palette's 16 ANSI colors came from","typeset -gA TTHEME_SRC=(",...t.map((l)=>s(l,l.ansiSource)),")",""].join(`
|
|
374
|
+
`)}function Ty(t){let e=Object.entries(t).flatMap(([r,i])=>{let o=i.filter((s)=>!tl.test(s)&&!s.includes("|"));return o.length>0&&!tl.test(r)?[[r,o.join("|")]]:[]}),n=Math.max(0,...e.map(([r])=>r.length));return["# the character's other names in every language, |-separated, from the aninames index in the cache: preview reads this when it opens and searches them too","typeset -gA TTHEME_ALIASES=(",...e.map(([r,i])=>` ${r.padEnd(n)} "${i}"`),")",""].join(`
|
|
375
|
+
`)}var mm={id:"shell",emitShared(t){return[{path:"shell/palettes.zsh",content:hm(t.map(an))}]}};import{execFileSync as hH}from"node:child_process";import{existsSync as Hy,readdirSync as mH,readFileSync as pH}from"node:fs";import{join as Fy}from"node:path";function ct(t){return Hy(t)?pH(t,"utf8"):""}function ft(t,e){return t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t}function el(t){let e=t.split(`
|
|
376
|
+
`).filter((n)=>n!==""&&!n.startsWith("#"));return[...new Set(e.map((n)=>n.split(/[ =]/)[0]))].join(", ")}function ln(t,e){let n=ct(t),r=e(n);return r===n?[]:[{file:t,content:r}]}function Ha(t){return process.env.XDG_DATA_HOME??Fy(t,".local","share")}function bs(t){return Hy(t)?mH(t).flatMap((e)=>e.startsWith(j(""))?[Fy(t,e)]:[]):[]}function pm(t,e){if(!t.shelf)return[];let n=`${[t.id,t.shelf.from].filter(Boolean).join("/")}/`;return(t.emitter.emit?.(e)??[]).flatMap((r)=>{let i=r.path.startsWith(n)?r.path.slice(n.length):"";return i!==""&&!i.includes("/")?[{file:i,content:r.content}]:[]})}function Ve(){return{platform:process.platform,env:process.env,run:(t,e)=>{try{return hH(t,[...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5000}).trim()}catch{return}}}}import{existsSync as Ca}from"node:fs";import{join as ni}from"node:path";var gH=["black","red","green","yellow","blue","magenta","cyan","white"];function Ly(t,e){return[t,...gH.map((n,r)=>`${n} = '${e[r]}'`),""].join(`
|
|
377
|
+
`)}var gm={id:"alacritty",limits:"no runtime color API (OSC only)",emit(t){let e=[...Zr(t),"","[colors.primary]",`background = '${t.background}'`,`foreground = '${t.foreground}'`,"","[colors.cursor]",`cursor = '${t.cursor}'`,`text = '${t.background}'`,"","[colors.selection]",`background = '${t.selectionBackground}'`,`text = '${t.foreground}'`,"",Ly("[colors.normal]",t.ansi.slice(0,8)),Ly("[colors.bright]",t.ansi.slice(8,16))].join(`
|
|
378
|
+
`);return[{path:`alacritty/themes/${j(t.name)}.toml`,content:e}]}};var bm={id:"ghostty",emit(t){let e=[...Zr(t),`background = ${t.background}`,`foreground = ${t.foreground}`,`cursor-color = ${t.cursor}`,`selection-background = ${t.selectionBackground}`,`selection-foreground = ${t.foreground}`,...t.ansi.map((n,r)=>`palette = ${r}=${n}`),"","macos-icon = custom-style",`macos-icon-ghost-color = ${t.ghostty.iconGhost}`,`macos-icon-screen-color = ${t.ghostty.iconScreen.join(",")}`,"macos-icon-frame = chrome",""].join(`
|
|
379
|
+
`);return[{path:`ghostty/themes/${j(t.name)}`,content:e}]}};function ei(t){let[e,n,r]=ot(t);return{"Alpha Component":1,"Blue Component":r/255,"Color Space":"P3","Green Component":n/255,"Red Component":e/255}}function jy(t){return{...Object.fromEntries(t.ansi.map((e,n)=>[`Ansi ${n} Color`,ei(e)])),"Background Color":ei(t.background),"Bold Color":ei(t.foreground),"Cursor Color":ei(t.cursor),"Cursor Text Color":ei(t.background),"Foreground Color":ei(t.foreground),"Selected Text Color":ei(t.foreground),"Selection Color":ei(t.selectionBackground)}}function Cy(t){return t?{"Background Image Location":t.image,"Background Image Mode":t.cover?2:3,Blend:t.opacity}:{"Background Image Location":""}}function _y(t,e,n,r,i=!1){let o=(c,u)=>({Name:`ttheme · ${u}`,Guid:j(u),...r?{"Dynamic Profile Parent GUID":r}:{},"Use Separate Colors for Light and Dark Mode":!1,...Cy(e.get(c.name)),...jy(c)}),s={Name:"ttheme · default",Guid:j("default"),"Dynamic Profile Parent GUID":r,...Cy(void 0)},a=[...n?[o(n,"default")]:i&&r?[s]:[],...t.map((c)=>o(c,c.name))];return`${JSON.stringify({Profiles:a},null,2)}
|
|
380
|
+
`}function bH(t,e){return[` <key>${t}</key>`,"\t<dict>",...Object.entries(e).flatMap(([n,r])=>[` <key>${n}</key>`,typeof r==="string"?` <string>${r}</string>`:` <real>${r}</real>`]),"\t</dict>"].join(`
|
|
381
|
+
`)}var wm={id:"iterm2",limits:"colors are Display P3, the space iTerm2 reads OSC colors in",emit(t){let e=['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">','<plist version="1.0">',"<dict>",...Object.entries(jy(t)).map(([n,r])=>bH(n,r)),"</dict>","</plist>",""].join(`
|
|
382
|
+
`);return[{path:`iterm2/${j(t.name)}.itermcolors`,content:e}]}};var $m={id:"kitty",emit(t){let e=[...Zr(t),`background ${t.background}`,`foreground ${t.foreground}`,`cursor ${t.cursor}`,`cursor_text_color ${t.background}`,`selection_background ${t.selectionBackground}`,`selection_foreground ${t.foreground}`,...t.ansi.map((n,r)=>`color${r} ${n}`),""].join(`
|
|
383
|
+
`);return[{path:`kitty/themes/${j(t.name)}.conf`,content:e}]}};function Gy(t){return[`# ${Rn}`,"import os","",`THEMES = ${JSON.stringify(t.themes)}`,`BACKGROUNDS = ${JSON.stringify(t.backgrounds)}`,"PLACES = {"," 'top-left': 'top-left', 'top-center': 'top', 'top-right': 'top-right',"," 'center-left': 'left', 'center': 'center', 'center-center': 'center', 'center-right': 'right',"," 'bottom-left': 'bottom-left', 'bottom-center': 'bottom', 'bottom-right': 'bottom-right',","}","","shown = {}","faded = {}","worn = {}","","","def locate(path):"," if path.startswith('~/'):"," return os.path.expanduser(path)"," return path if os.path.isabs(path) else os.path.join(BACKGROUNDS, path)","","","def read(path, into):"," try:"," with open(path, encoding='utf-8') as f:"," lines = f.read().splitlines()"," except OSError:"," return False"," for line in lines:"," key, sep, value = line.partition('=')"," key, value = key.strip(), value.strip()"," if not sep or not key or key.startswith('#'):"," continue"," if key == 'config-file':"," read(locate(value.lstrip('?')), into)"," else:"," into[key] = value"," return True","","","def logo(palette):"," c = {}"," if not palette or not read(os.path.join(BACKGROUNDS, palette.replace('@', '--', 1).replace('/', '--', 1) + '.conf'), c):"," return None"," image = c.get('background-image', '')"," try:"," opacity = min(float(c.get('background-image-opacity', '1')), 1.0)"," except ValueError:"," opacity = 1.0"," if not image or opacity <= 0:"," return None"," return locate(image), PLACES.get(c.get('background-image-position', 'center'), 'center'), opacity","","","def fade(path, opacity):"," key = f'{path}#{opacity}'"," if key not in faded:"," from kitty.fast_data_types import load_png_data, png_from_32bit_rgba_data"," with open(path, 'rb') as f:"," rgba, width, height = load_png_data(f.read())"," data = bytearray(rgba)"," data[3::4] = data[3::4].translate(bytes(round(a * opacity) for a in range(256)))"," if len(faded) > 8:"," faded.clear()"," faded[key] = png_from_32bit_rgba_data(bytes(data), width, height)"," return key, faded[key]","","","def show(window):"," want = logo(window.user_vars.get('ttheme_shown') or '')"," if window.id in shown and shown[window.id] == want:"," return"," shown[window.id] = want"," try:"," if want is None:"," window.set_logo('')"," elif want[2] < 1:"," key, png = fade(want[0], want[2])"," window.set_logo(key, want[1], 1, png)"," else:"," window.set_logo(want[0], want[1], 1)"," except Exception:"," shown.pop(window.id, None)","","","def theme(palette):"," path = os.path.join(THEMES, 'ttheme-' + palette.replace('@', '--', 1).replace('/', '--', 1) + '.conf')"," if not palette or not os.path.exists(path):"," return None"," from kitty.colors import parse_colors"," return parse_colors([path])","","","def wear(palette):"," colors = theme(palette) if worn.get('startup') != palette else None"," if colors is None:"," return"," from kitty.colors import patch_colors"," patch_colors(colors[0], colors[1], True, ())"," worn['startup'] = palette","","","def rewear(boss):"," from kitty.colors import patch_colors"," for window in tuple(boss.all_windows):"," colors = theme(window.user_vars.get('ttheme_worn') or '')"," if colors is not None:"," patch_colors(colors[0], colors[1], False, (window,))","","","def on_load(boss, data):"," if getattr(boss, 'ttheme_rewears', False):"," return"," load = boss.load_config_file",""," def reload(*args, **kwargs):"," load(*args, **kwargs)"," worn.pop('startup', None)"," rewear(boss)",""," boss.load_config_file = reload"," boss.ttheme_rewears = True","","","def on_set_user_var(boss, window, data):"," if data['key'] == 'ttheme_shown':"," show(window)"," elif data['key'] == 'ttheme_startup':"," wear(data['value'] or '')","","","def on_focus_change(boss, window, data):"," if data['focused']:"," show(window)","","","def on_close(boss, window, data):"," shown.pop(window.id, None)",""].join(`
|
|
384
|
+
`)}function wH(t){let[e]=t;if(!e)throw Error("manifest needs at least one theme");return{...gu(),palettes:t.map(an)}}var km={id:"meta",emitShared(t){return[{path:"manifest.json",content:`${JSON.stringify(wH(t),null,2)}
|
|
385
|
+
`}]}};var ym={id:"terminal-app",limits:"profiles go into its own settings at init, so the archive carries none"};import{createHash as $H}from"node:crypto";var kH=["black","red","green","yellow","blue","magenta","cyan","white"];function By(t,e){return[` ${t}:`,...kH.map((n,r)=>` ${n}: "${e[r]}"`)]}function yH(t,e,n){let r=$H("sha1");for(let i of e)r.update(i);return`${j(t)}.${r.digest("hex").slice(0,8)}.${n}`}function Uy(t,e,n){let r=2166136261;for(let i of Buffer.from(`${e}
|
|
386
|
+
${n.toLowerCase()}`,"utf8"))r=Math.imul(r^i,16777619)>>>0;return`${j(t)}.${r.toString(16).padStart(8,"0")}.png`}function Fa(t,e){return e?yH(t,[e.image,String(Wy(e))],"yaml"):`${j(t)}.yaml`}function Wy(t){return Math.max(0,Math.min(100,Math.round(t.opacity*100)))}function La(t,e){return[`name: "${t.name}"`,`background: "${t.background}"`,`foreground: "${t.foreground}"`,`accent: "${t.cursor}"`,`cursor: "${t.cursor}"`,`details: ${St(t.background)<0.18?"darker":"lighter"}`,...e?["background_image:",` path: "${e.image}"`,` opacity: ${Wy(e)}`]:[],"terminal_colors:",...By("normal",t.ansi.slice(0,8)),...By("bright",t.ansi.slice(8,16)),""].join(`
|
|
387
|
+
`)}var vm={id:"warp",limits:"no selection color, and Warp paints one theme app-wide",emit(t){return[{path:`warp/themes/${Fa(t.name)}`,content:La(t)}]}};var Ky=(t)=>`[${t.map((e)=>`"${e}"`).join(", ")}]`,Sm={id:"wezterm",limits:"OSC repaints per pane, pictures show per window",emit(t){let e=["[metadata]",`name = "${j(t.name)}"`,`origin_url = "${t.ansiSource}"`,"","[colors]",`foreground = "${t.foreground}"`,`background = "${t.background}"`,`cursor_bg = "${t.cursor}"`,`cursor_border = "${t.cursor}"`,`cursor_fg = "${t.background}"`,`selection_bg = "${t.selectionBackground}"`,`selection_fg = "${t.foreground}"`,"",`ansi = ${Ky(t.ansi.slice(0,8))}`,`brights = ${Ky(t.ansi.slice(8,16))}`,""].join(`
|
|
388
|
+
`);return[{path:`wezterm/colors/${j(t.name)}.toml`,content:e}]}},ws=(t)=>JSON.stringify(t);function zy(t){return[`-- ${Rn}`,"local wezterm = require 'wezterm'","",`local MODULE = ${ws(t.path)}`,`local COLORS = ${ws(t.colors)}`,`local BACKGROUNDS = ${ws(t.backgrounds)}`,`local STARTUP = ${t.startup?ws(j(t.startup)):"nil"}`,"local PALETTES = {",...t.palettes.map((e)=>` [${ws(e.name)}] = ${ws(e.background)},`),"}","","local X = { left = 'Left', center = 'Center', right = 'Right' }","local Y = { top = 'Top', center = 'Middle', bottom = 'Bottom' }","local SIZE = { cover = 'Cover', contain = 'Contain', stretch = '100%' }","","local function locate(path)"," if path:sub(1, 2) == '~/' then"," return os.getenv('HOME') .. path:sub(2)"," elseif path:sub(1, 1) == '/' or path:match('^%a:[/\\\\]') then"," return path"," end"," return BACKGROUNDS .. '/' .. path","end","","local function read(path, into)"," local f = io.open(path, 'r')"," if not f then"," return false"," end"," for line in f:lines() do"," local key, value = line:match('^%s*([%w%-]+)%s*=%s*(.-)%s*$')"," if key == 'config-file' then"," read(locate((value:gsub('^%?', ''))), into)"," elseif key then"," into[key] = value"," end"," end"," f:close()"," return true","end","","local function layers(palette)"," local color = PALETTES[palette]"," local c = {}"," if not color or not read(BACKGROUNDS .. '/' .. ((palette:gsub('@', '--', 1)):gsub('/', '--', 1)) .. '.conf', c) then"," return nil, 'none'"," end"," local image = c['background-image'] or ''"," local opacity = tonumber(c['background-image-opacity'] or '1') or 1"," if image == '' or opacity <= 0 then"," return nil, 'none'"," end"," local fit = c['background-image-fit'] or 'contain'"," local position = c['background-image-position'] or 'center'"," local y, x = position:match('^(%a+)-(%a+)$')"," local rep = c['background-image-repeat'] == 'true' and 'Repeat' or 'NoRepeat'"," return {"," { source = { Color = color }, width = '100%', height = '100%' },"," {"," source = { File = locate(image) },"," opacity = opacity,"," width = SIZE[fit],"," height = SIZE[fit],"," horizontal_align = X[x or 'center'],"," vertical_align = Y[y or 'center'],"," repeat_x = rep,"," repeat_y = rep,"," },"," }, table.concat({ color, image, opacity, fit, position, rep }, '|')","end","","local function framed(window, view)"," local color, image, opacity, W, H, w, h, x, y, at ="," view:match('^([^|]*)|([^|]*)|([^|]*)|(%d+)|(%d+)|(%-?%d+)|(%-?%d+)|(%-?%d+)|(%-?%d+)|(%d)$')"," if not image or image == '' or tonumber(W) == 0 or tonumber(H) == 0 then"," return nil, 'none'"," end"," local d = window:get_dimensions()"," local k = math.max(d.pixel_width / W, d.pixel_height / H)"," local n = tonumber(at) - 1"," local ax, ay = n % 3, n // 3"," local px = function(n) return string.format('%.2fpx', n) end"," return {"," { source = { Color = color }, width = '100%', height = '100%' },"," {"," source = { File = image },"," opacity = tonumber(opacity) or 1,"," width = px(w * k),"," height = px(h * k),"," horizontal_align = 'Left',"," vertical_align = 'Top',"," horizontal_offset = px(ax * (d.pixel_width - W * k) / 2 + x * k),"," vertical_offset = px(ay * (d.pixel_height - H * k) / 2 + y * k),"," repeat_x = 'NoRepeat',"," repeat_y = 'NoRepeat',"," },"," }, table.concat({ view, d.pixel_width, d.pixel_height }, '|')","end","","local shown = {}","","local function show(window, pane)"," local vars = pane:get_user_vars()"," local id = window:window_id()"," local background, key"," if vars.ttheme_view and vars.ttheme_view ~= '' then"," background, key = framed(window, vars.ttheme_view)"," elseif vars.ttheme_shown and vars.ttheme_shown ~= '' then"," background, key = layers(vars.ttheme_shown)"," elseif shown[id] == nil then"," return"," end"," if shown[id] == key then"," return"," end"," shown[id] = key"," local overrides = window:get_config_overrides() or {}"," overrides.background = background"," window:set_config_overrides(overrides)","end","","wezterm.on('user-var-changed', function(window, pane, name)"," if name == 'ttheme_shown' or name == 'ttheme_view' then"," show(window, pane)"," end","end)","wezterm.on('update-status', show)","","return function(config)"," local dirs = config.color_scheme_dirs or {}"," table.insert(dirs, COLORS)"," config.color_scheme_dirs = dirs"," if STARTUP then"," config.color_scheme = STARTUP"," end"," wezterm.add_to_config_reload_watch_list(MODULE)","end",""].join(`
|
|
389
|
+
`)}var qy=["black","red","green","yellow","blue","purple","cyan","white"];function Dy(t){return{name:j(t.name),background:t.background,foreground:t.foreground,cursorColor:t.cursor,selectionBackground:t.selectionBackground,...Object.fromEntries(qy.map((e,n)=>[e,t.ansi[n]])),...Object.fromEntries(qy.map((e,n)=>[`bright${e[0]?.toUpperCase()}${e.slice(1)}`,t.ansi[n+8]]))}}function Em(t,e,n){let r={...e&&n?{profiles:[{updates:e,colorScheme:j(n)}]}:{},schemes:t.map(Dy)};return`${JSON.stringify(r,null,2)}
|
|
390
|
+
`}var Mm={id:"windows-terminal",limits:"a picture belongs to a profile, which a pane cannot change, so none; OSC repaints per pane",emit(t){return[{path:`windows-terminal/schemes/${j(t.name)}.json`,content:`${JSON.stringify(Dy(t),null,2)}
|
|
391
|
+
`}]},emitShared(t){return[{path:"windows-terminal/ttheme.json",content:Em(t)}]}};function vH(t){let e=t.replace(Vi,"");return/^[ \t]*\[colors[\].]/m.test(e)||/^[ \t]*colors[ \t]*[.=]/m.test(e)}var SH=/^[ \t]*\[general\][ \t]*(?:#.*)?\r?$/m,Jy=/^[ \t]*\[/m,Yy=/^[ \t]*import[ \t]*=/m,EH=/^[ \t]*general[ \t]*[.=]/m;function Im(t){return`import = [${JSON.stringify(t)}]`}function xm(t,e){let n=t.replace(Vi,""),r=SH.exec(n);if(!r){let a=n.search(Jy),c=a<0?n:n.slice(0,a);if(EH.test(n)||Yy.test(c))return;return Qr(t,`# ${ke}
|
|
390
392
|
[general]
|
|
391
|
-
${
|
|
392
|
-
${
|
|
393
|
+
${Im(e)}`)}let i=r.index+r[0].length,o=n.slice(i),s=o.search(Jy);if(Yy.test(s<0?o:o.slice(0,s)))return;return`${n.slice(0,i)}
|
|
394
|
+
${um}
|
|
393
395
|
# ${ke}
|
|
394
|
-
${
|
|
395
|
-
${
|
|
396
|
-
`)}function
|
|
397
|
-
config-file = ?${Xr(n,e,"~")??n}`}function
|
|
398
|
-
`)}function
|
|
399
|
-
include ${Xr(n,e,"~")??n}`}function
|
|
400
|
-
`)}function
|
|
401
|
-
`),i=
|
|
402
|
-
`),r=
|
|
396
|
+
${Im(e)}
|
|
397
|
+
${lm}${o}`}function Vy(t){return[...new Set([ni(t.configHome,"alacritty","alacritty.toml"),ni(t.configHome,"alacritty.toml"),ni(t.home,".config","alacritty","alacritty.toml"),ni(t.home,".alacritty.toml")])]}function MH(t){let e=ct(t);return Vi.test(e)&&Nn(e)===""&&!Ca(Xs(t))}function Om(t){let e=Vy(t),n=e.filter(MH),r=e.find((o)=>Ca(o)&&!n.includes(o)),i=r?void 0:e.map((o)=>o.replace(/\.toml$/,".yml")).find((o)=>Ca(o));if(!r&&!i)return{file:n[0]??e[0]};return{file:r??e[0],...i?{yaml:i}:{},...n.length>0?{leftover:n}:{}}}function Pm(t){return ni(t,"ttheme","alacritty.toml")}function xH(t){return[`# ${Rn}`,...t?["[general]",Im(t)]:[],""].join(`
|
|
398
|
+
`)}function nl(t){let e=Pm(t.configHome);return Xr(e,t.home,"~")??e}function Zy(t){return ni(t.configHome,"alacritty","themes")}function OH(t){return t.startup?ni(Zy(t),`${j(t.startup)}.toml`):void 0}var Rm={id:"alacritty",name:"Alacritty",emitter:gm,shelf:{from:"themes",dir:Zy},offered:()=>!0,present:(t)=>Ca(ni(t.configHome,"alacritty")),sync(t,e){e.themes(Rm),e.write(Pm(t.configHome),xH(OH(t)));let n=Om(t);for(let i of n.leftover??[])e.remove(i);let r=n.yaml?void 0:xm(ct(n.file),nl(t));if(r!==void 0)e.wire(n.file,r)},plan(t){let e=Om(t);return!e.yaml&&xm(ct(e.file),nl(t))!==void 0?[`Edit ${ft(e.file,t.home)} — a ttheme block: general.import`,`Write ${ft(Pm(t.configHome),t.home)} — general.import`]:[]},notes(t){let e=Om(t),n=(e.leftover??[]).map((i)=>`${ft(i,t.home)} held only ttheme's import and hid ${ft(e.yaml??e.file,t.home)} from Alacritty — ttheme removed it`);if(e.yaml)return[...n,`${ft(e.yaml,t.home)} is the config Alacritty reads, and ttheme edits TOML only — \`alacritty migrate\` converts it, and ttheme wires the TOML at its next add, remove or default`];let r=ct(e.file);return[...n,...Ca(e.file)&&xm(r,nl(t))===void 0?[`${ft(e.file,t.home)} already imports files under [general] — ttheme left it alone; add ${nl(t)} to that import list yourself`]:[],...t.startup&&vH(r)?[`${ft(e.file,t.home)} sets its own colors, which win over an imported palette — remove them to open with ttheme's`]:[]]},next:()=>["Alacritty Reloads its config by itself"],unwire:(t)=>({edits:Vy(t).flatMap((e)=>ln(e,Nn)),removals:[],touches:[]})};import{existsSync as IH}from"node:fs";import{join as fn}from"node:path";var PH=["background","foreground","palette","cursor-color","cursor-text","selection-background","selection-foreground"];function rl(t){return fn(t,"ghostty","config")}function Xy(t){return fn(t,"ttheme","ghostty.conf")}function RH(t,e=process.platform){let n=fn(t.home,"Library","Application Support","com.mitchellh.ghostty");return[rl(t.configHome),fn(t.configHome,"ghostty","config.ghostty"),...e==="darwin"?[fn(n,"config"),fn(n,"config.ghostty")]:[]]}function il(t,e){return RH(t).find((n)=>ms(ct(n),e))}function NH(t,e){let n=fn(t,"ghostty.conf");return`# ${ke}
|
|
399
|
+
config-file = ?${Xr(n,e,"~")??n}`}function AH(t,e,n,r){return[`# ${Rn}`,...n?[`command = ${t}/launch-tab.zsh`,...r?["shell-integration = zsh"]:[]]:[],...e?[`theme = ${j(e)}`]:[],"config-file = ?backgrounds/shown.conf",""].join(`
|
|
400
|
+
`)}function t1(t){return gs(t.configHome,"TTHEME_TAB_PALETTE")!=="off"}function Qy(t){return AH(fn(t.configHome,"ttheme"),t.startup,t1(t)&&il(t,"command")===void 0,il(t,"shell-integration")===void 0)}var Nm={id:"ghostty",name:"Ghostty",emitter:bm,shelf:{from:"themes",dir:(t)=>fn(t.configHome,"ghostty","themes")},offered:()=>!0,present:(t)=>IH(fn(t.configHome,"ghostty")),sync(t,e){e.themes(Nm),e.write(Xy(t.configHome),Qy(t));let n=rl(t.configHome);e.wire(n,Qr(ct(n),NH(fn(t.configHome,"ttheme"),t.home)))},plan(t){return[`Edit ${ft(rl(t.configHome),t.home)} — a ttheme block: config-file`,`Write ${ft(Xy(t.configHome),t.home)} — ${el(Qy(t))}`]},notes(t){let e=il(t,"command"),n=t.startup?PH.map((r)=>il(t,r)).find(Boolean):void 0;return[...e&&t1(t)?[`${ft(e,t.home)} sets its own command — ttheme leaves it, so a new tab takes its palette once zsh starts`]:[],...n?[`${ft(n,t.home)} sets its own colors, which win over a theme — remove them to open with ttheme's`]:[]]},next:()=>["Restart Ghostty New tabs pick up its config"],unwire:(t)=>({edits:ln(rl(t.configHome),Nn),removals:[],touches:[]})};import{existsSync as e1}from"node:fs";import{join as i1}from"node:path";var Am="ttheme-default";function $s(t){return i1(t,"Library","Application Support","iTerm2","DynamicProfiles","ttheme.json")}function o1(t){return t.itermBase!==void 0&&t.palettes.length>0}function n1(t){let e=X(t.configHome),n=new Map;for(let i of t.themes){let o=He(e,i.name,t.home);if(o)n.set(i.name,o)}let r=new Set(At(t.entries).map((i)=>i.name));return _y(t.themes.filter((i)=>r.has(i.name)),n,t.themes.find((i)=>i.name===t.startup),t.state.itermBase,o1(t.state))}function Tm(t){return t.env.TTHEME_ITERM_SUITE??"com.googlecode.iterm2"}function r1(t){return t.run("defaults",["read",Tm(t),"Default Bookmark Guid"])||void 0}function TH(t){return t.run("defaults",["read",Tm(t),"PreventEscapeSequenceFromChangingProfile"])==="0"}var HH={key:"itermBase",profile:()=>"ttheme · default",base(t){let e=r1(t.host);return e&&!e.startsWith("ttheme-")?{...t.state,itermBase:e}:t.state},point(t,e){let n=r1(t.host),r=t.startup?e||n===Am?Am:void 0:n===Am&&!o1(t.state)?t.state.itermBase:void 0;if(!r||r===n)return;return t.host.run("defaults",["write",Tm(t.host),"Default Bookmark Guid","-string",r]),{restart:Boolean(t.host.run("pgrep",["-x","iTerm2"]))}}},s1={id:"iterm2",name:"iTerm2",emitter:wm,bakes:!0,offered:(t,e)=>e.platform==="darwin",present:(t)=>e1(i1(t.home,"Library","Application Support","iTerm2")),sync(t,e){e.write($s(t.home),n1(t))},pictures(t,e){e.write($s(t.home),n1(t))},layer:(t,e)=>({TTHEME_ITERM_SWITCH:TH(e)?"1":"",TTHEME_ITERM_PROFILES:$s(t.home)}),plan:(t)=>[`Write ${ft($s(t.home),t.home)} — a "ttheme · <palette>" profile per palette`],notes:()=>[],next(t,e){let n=['iTerm2 profiles A "ttheme · <palette>" per palette in Settings › Profiles'];if(t.startup)n.push(e?.restart?`Restart iTerm2 New tabs open on "ttheme · default", which wears ${t.startup}`:`iTerm2 default "ttheme · default" wears ${t.startup} and follows \`ttheme default\``);return n},unwire:(t)=>({edits:[],removals:e1($s(t.home))?[$s(t.home)]:[],touches:[]}),defaults:HH};import{existsSync as FH}from"node:fs";import{join as ri}from"node:path";function LH(t,e){let n=ri(t,"kitty.conf");return`# ${ke}
|
|
401
|
+
include ${Xr(n,e,"~")??n}`}function CH(t,e,n=""){return[`# ${Rn}`,...t?[`include ${t}`]:[],`watcher ${e}`,...["window_logo_scale 100","window_logo_alpha 1"].filter((r)=>!ms(n,r.split(" ")[0])),""].join(`
|
|
402
|
+
`)}function ja(t){return ri(t,"kitty","kitty.conf")}function a1(t){return ri(t,"ttheme","kitty.conf")}function u1(t){return ri(t,"ttheme","kitty.py")}function Hm(t){return ri(t.configHome,"kitty","themes")}function c1(t){return CH(t.startup&&ri(Hm(t),`${j(t.startup)}.conf`),u1(t.configHome),ct(ja(t.configHome)))}var Fm={id:"kitty",name:"kitty",emitter:$m,shelf:{from:"themes",dir:Hm},offered:()=>!0,present:(t)=>FH(ri(t.configHome,"kitty")),sync(t,e){e.themes(Fm),e.write(u1(t.configHome),Gy({themes:Hm(t),backgrounds:X(t.configHome)})),e.write(a1(t.configHome),c1(t));let n=ja(t.configHome);e.wire(n,Qr(ct(n),LH(ri(t.configHome,"ttheme"),t.home)))},plan(t){return[`Edit ${ft(ja(t.configHome),t.home)} — a ttheme block: include`,`Write ${ft(a1(t.configHome),t.home)} — ${el(c1(t))}`]},notes(t){let e=ct(ja(t.configHome));return ms(e,"window_logo_scale")||ms(e,"window_logo_alpha")?["kitty.conf sets its own window_logo_scale or window_logo_alpha — pictures are drawn with them"]:[]},next:()=>["New kitty window Pictures follow it — kitty reloads its colors by itself"],unwire:(t)=>({edits:ln(ja(t.configHome),Nn),removals:[],touches:[]})};import{createHash as jH}from"node:crypto";import{existsSync as ol}from"node:fs";import{basename as f1,isAbsolute as _H,join as Zi}from"node:path";function ks(t){return Zi(Ha(t),"konsole")}function _a(t){return Zi(t,"konsolerc")}function d1(t){return`${j(t)}.profile`}function Ga(t){return`ttheme · ${t}`}function h1(t,e){let n=t.findIndex((i)=>i.trim()===`[${e}]`);if(n<0)return;let r=t.findIndex((i,o)=>o>n&&i.trimStart().startsWith("["));return[n,r<0?t.length:r]}function Lm(t){return new RegExp(String.raw`^\s*${t}\s*=`)}function ii(t,e,n){let r=t.split(`
|
|
403
|
+
`),i=h1(r,e);return(i&&r.slice(i[0]+1,i[1]).find((s)=>Lm(n).test(s)))?.replace(Lm(n),"").trim()}function m1(t,e){let n=t.split(`
|
|
404
|
+
`),r=h1(n,"Desktop Entry"),i=e===void 0?[]:[`DefaultProfile=${e}`];if(!r)return e===void 0?t:`${t===""?"":t.replace(/\n*$/,`
|
|
403
405
|
|
|
404
406
|
`)}[Desktop Entry]
|
|
405
407
|
${i[0]}
|
|
406
|
-
`;let o=n.findIndex((a,c)=>c>r[0]&&c<r[1]&&
|
|
407
|
-
`)}function
|
|
408
|
-
`)}var
|
|
408
|
+
`;let o=n.findIndex((a,c)=>c>r[0]&&c<r[1]&&Lm("DefaultProfile").test(a));if(o>=0)n.splice(o,1,...i);else n.splice(r[0]+1,0,...i);let s=r[1]+i.length-(o>=0?1:0);if(n.slice(r[0]+1,s).every((a)=>a.trim()==="")){let a=r[0]>0&&n[r[0]-1]?.trim()===""?r[0]-1:r[0],c=s===n.length&&n[s-1]===""?s-1:s;n.splice(a,c-a)}return n.join(`
|
|
409
|
+
`)}function GH(t){if(t&&he(t.toLowerCase()))return t.toLowerCase();let e=t?.split(",").map((n)=>Number(n.trim()));if(!e||e.length<3||e.slice(0,3).some((n)=>!Number.isInteger(n)||n<0||n>255))return;return`#${e.slice(0,3).map((n)=>n.toString(16).padStart(2,"0")).join("")}`}function p1(t,e){let n=e.endsWith(".profile")?e:`${e}.profile`;if(_H(n))return ol(n)?n:void 0;let r=n.includes("/")?n:Zi("konsole",n);return[Ha(t.home),...(process.env.XDG_DATA_DIRS||"/usr/local/share:/usr/share").split(":")].map((o)=>Zi(o,r)).find((o)=>ol(o))}function g1(t,e,n=0){let r=e&&e!=="FALLBACK/"&&n<8?p1(t,e):void 0;if(!r)return{};let i=ct(r),o=g1(t,ii(i,"General","Parent"),n+1);return{scheme:ii(i,"Appearance","ColorScheme")||o.scheme,use:ii(i,"Cursor Options","UseCustomCursorColor")??o.use,cursor:ii(i,"Cursor Options","CustomCursorColor")??o.cursor}}function BH(t,e){let n=g1(t,e),r=n.use==="true"?GH(n.cursor):void 0;return[`ColorScheme=${n.scheme??"Breeze"}`,`UseCustomCursorColor=${r?"true":"false"}`,...r?[`customCursorColor=${r}`]:[]].join(";")}function UH(t,e){return["[Appearance]",`ColorScheme=${j(t.name)}`,"","[Cursor Options]",`CustomCursorColor=${ot(t.cursor).join(",")}`,`CustomCursorTextColor=${ot(t.background).join(",")}`,"UseCustomCursorColor=true","","[General]",`Name=${Ga(t.name)}`,`Parent=${e}`,""].join(`
|
|
410
|
+
`)}var b1=/^ttheme-(.+)\.([0-9a-f]{8})\.colorscheme$/;function WH(t){return jH("sha1").update(t).digest("hex").slice(0,8)}function l1(t,e){let n=ks(t.home),r=X(t.configHome),i=new Set;for(let o of t.themes){let s=Qh(o,He(r,o.name,t.home)),a=Zi(n,`${j(o.name)}.${WH(s)}.colorscheme`);i.add(a),e.write(Zi(n,`${j(o.name)}.colorscheme`),s),e.write(a,s)}for(let o of bs(n))if(b1.test(f1(o))&&!i.has(o))e.remove(o)}function KH(t){return bs(t).flatMap((e)=>{let[,n,r]=b1.exec(f1(e))??[];return n&&r?[`${n} ${r}`]:[]}).sort().join(" ")}function zH(t){let e=new Set(At(t.entries).map((n)=>n.name));return t.themes.filter((n)=>e.has(n.name)||n.name===t.startup)}var Cm=["--session","--print-reply","--reply-timeout=2000"];function qH(t){return[...(t.run("dbus-send",[...Cm,"--dest=org.freedesktop.DBus","/org/freedesktop/DBus","org.freedesktop.DBus.ListNames"])??"").matchAll(/string "(org\.kde\.konsole(?:-\d+)?)"/g)].flatMap(([,n=""])=>{let i=t.run("dbus-send",[...Cm,`--dest=${n}`,"/Windows","org.freedesktop.DBus.Introspectable.Introspect"])?.match(/<node name="(\d+)"/)?.[1];return i?[{service:n,window:`/Windows/${i}`}]:[]})}function DH(t,{service:e,window:n},r){let i=(o,...s)=>t.run("dbus-send",[...Cm,`--dest=${e}`,n,`org.kde.konsole.Window.${o}`,...s]);return i("setDefaultProfile",`string:${r}`),i("defaultProfile")?.includes(`string "${r}"`)===!0}function JH(t,e){let n=p1(t,e);return n?ii(ct(n),"General","Name"):void 0}function YH(t){return ii(ct(_a(t)),"Desktop Entry","DefaultProfile")}var VH={key:"konsoleBase",profile:Ga,base(t){let e=YH(t.configHome);return e&&!e.startsWith(j(""))?{...t.state,konsoleBase:e}:t.state},point(t,e){let n=_a(t.configHome),r=ct(n),i=ii(r,"Desktop Entry","DefaultProfile"),o=i?.startsWith(j(""))===!0,s=t.startup?e||o?d1(t.startup):void 0:o?t.state.konsoleBase??"":void 0;if(s===void 0||s===(i??"")&&!e)return;if(s!==(i??""))$n(n,m1(r,s||void 0));let a=t.startup?Ga(t.startup):s?JH(t,s):void 0,c=qH(t.host),u=a!==void 0&&c.every((f)=>DH(t.host,f,a));return{restart:c.length>0&&!u}}},w1={id:"konsole",name:"Konsole",emitter:tm,shelf:{from:"",dir:(t)=>ks(t.home)},offered:(t,e)=>e.platform!=="darwin"&&e.platform!=="win32",present:(t)=>ol(ks(t.home))||ol(_a(t.configHome)),sync(t,e){l1(t,e);let n=ks(t.home),r=t.state.konsoleBase??"FALLBACK/",i=new Set;for(let o of zH(t)){let s=Zi(n,d1(o.name));i.add(s),e.write(s,UH(o,r))}for(let o of bs(n))if(o.endsWith(".profile")&&!i.has(o))e.remove(o)},pictures:l1,layer:(t)=>({TTHEME_KONSOLE_BASE:BH(t,t.state.konsoleBase),TTHEME_KONSOLE_SCHEMES:KH(ks(t.home))}),plan(t){return[`Write ${ft(ks(t.home),t.home)}/${j("*")}.profile — a "ttheme · <palette>" profile per palette, on top of your own`,...t.startup?[`Edit ${ft(_a(t.configHome),t.home)} — DefaultProfile; \`ttheme off\` puts yours back`]:[]]},notes:()=>[],next(t,e){let n=['Konsole profiles A "ttheme · <palette>" per palette in its profile list'];if(t.startup)n.push(e?.restart?`Restart Konsole New tabs open on "${Ga(t.startup)}"`:`Konsole default "${Ga(t.startup)}", which follows \`ttheme default\``);return n},unwire(t,e){let n=_a(t.configHome),r=ct(n),i=ii(r,"Desktop Entry","DefaultProfile")?.startsWith(j(""))===!0;return{edits:i?[{file:n,content:m1(r,e?.konsoleBase)}]:[],removals:i?[]:Jc(n),touches:[]}},defaults:VH};import{createHash as ZH}from"node:crypto";import{existsSync as y1,readdirSync as XH,readFileSync as QH,rmSync as tF}from"node:fs";import{join as Xi}from"node:path";var v1="com.apple.Terminal",Ba="ttheme · ";function dn(t){return`${Ba}${t}`}function sl(t){return Xi(t,"ttheme","terminal-app.js")}function ys(t){return Xi(t,"ttheme","terminal-app")}function eF(t,e){return Xi(t.XDG_STATE_HOME??Xi(e,".local","state"),"ttheme","terminal-app.window")}var nF=`ObjC.import('AppKit')
|
|
409
411
|
|
|
410
|
-
const OURS = '${
|
|
412
|
+
const OURS = '${Ba}'
|
|
411
413
|
const IMAGE = 'BackgroundImageBookmark'
|
|
412
414
|
const KEYS = ['BackgroundColor', 'TextColor', 'CursorColor', 'SelectionColor', 'ANSIBlackColor', 'ANSIRedColor',
|
|
413
415
|
'ANSIGreenColor', 'ANSIYellowColor', 'ANSIBlueColor', 'ANSIMagentaColor', 'ANSICyanColor', 'ANSIWhiteColor',
|
|
@@ -591,66 +593,66 @@ function run(argv) {
|
|
|
591
593
|
}
|
|
592
594
|
return changed ? 'wrote' : 'same'
|
|
593
595
|
}
|
|
594
|
-
`;function
|
|
595
|
-
`),n=
|
|
596
|
-
`),r=
|
|
596
|
+
`;function jm(t,e,n){return t.run("osascript",["-l","JavaScript",sl(e),...n])}function _m(t){return t.run("defaults",["read",v1,"Default Window Settings"])||void 0}function rF(t){return[t.background,t.foreground,t.cursor,t.selectionBackground,...t.ansi]}function S1(t){let e=new Set(At(t.entries).map((n)=>n.name));return t.themes.filter((n)=>e.has(n.name)||n.name===t.startup)}function Gm(t,e){let n=_m(e);return t.terminalBase??(n&&!n.startsWith(Ba)?n:"Basic")}function Bm(t,e){let n=/^(\d+)x(\d+)$/.exec(ct(eF(t,e)).trim());return n?{width:Number(n[1])*2,height:Number(n[2])*2}:void 0}function Um(t,e,n,r){let i=r?.width??t,o=r?.height??e,s=qt.indexOf(n.position)+1||5,a=Yo(t,e,i,o,100,s,n.cover),c=Math.min(1,t/Math.max(1,a.w));return{width:Math.max(1,Math.round(i*c)),height:Math.max(1,Math.round(o*c)),at:{x:Math.round(a.x*c),y:Math.round(a.y*c),w:Math.round(a.w*c),h:Math.round(a.h*c)}}}var E1=/^ttheme-(.+)\.([0-9a-z-]+)\.png$/;function al(t){let e=new Map;for(let n of y1(t)?XH(t):[]){let[,r]=E1.exec(n)??[];if(r)e.set(r,[...e.get(r)??[],n])}return e}function iF(t){return[...al(t)].map(([e,n])=>`${e} ${(E1.exec(n[0])??[])[2]}`).sort().join(" ")}function $1(t){let e=ys(t.configHome),n=al(e),r=Bm(t.host.env,t.home),i=new Map,o=(s)=>{for(let a of s)tF(Xi(e,a),{force:!0})};for(let s of S1(t)){let a=n.get(ue(s.name))??[];n.delete(ue(s.name));let c=He(X(t.configHome),s.name,t.home),u=c&&y1(c.image)?new Uint8Array(QH(c.image)):void 0,f=u&&yn(u);if(!c||!u||!f||c.opacity<=0){o(a);continue}let l=Um(f.width,f.height,c,r),d=ZH("sha1").update(u).update(JSON.stringify([s.background.toLowerCase(),c.opacity,l])).digest("hex").slice(0,8),h=`${j(s.name)}.${d}.png`,m=Xi(e,h);if(!a.includes(h)){let p;try{p=Tr(Ar(Gt(u),s.background,c.opacity,l))}catch{o(a);continue}let[b,...$]=a;if(b)xi(Xi(e,b),m,p);else C(m,p);o($)}else o(a.filter((p)=>p!==h));i.set(s.name,m)}for(let s of n.values())o(s);return i}function k1(t,e){jm(t.host,t.configHome,["write",Gm(t.state,t.host),...S1(t).flatMap((n)=>[dn(n.name),...rF(n),e.get(n.name)??"-"])])}var oF={key:"terminalBase",profile:dn,base(t){let e=_m(t.host);return e&&!e.startsWith(Ba)?{...t.state,terminalBase:e}:t.state},point(t,e){let n=_m(t.host),r=n?.startsWith(Ba)===!0;if(t.state.palettes.length===0)jm(t.host,t.configHome,["drop"]);let i=t.startup?e||r?dn(t.startup):void 0:r?Gm(t.state,t.host):void 0;if(i===void 0||i===n&&!e)return;for(let s of["Default Window Settings","Startup Window Settings"])t.host.run("defaults",["write",v1,s,"-string",i]);return{restart:Boolean(t.host.run("pgrep",["-x","Terminal"]))&&jm(t.host,t.configHome,["loaded",i])!=="1"}}},M1={id:"terminal-app",name:"Terminal.app",emitter:ym,offered:(t,e)=>e.platform==="darwin",present:()=>!1,sync(t,e){e.write(sl(t.configHome),nF),k1(t,$1(t))},pictures(t){k1(t,$1(t))},layer:(t,e)=>({TTHEME_TERMINAL_APP_BASE:Gm(t.state,e),TTHEME_TERMINAL_PICTURES:iF(ys(t.configHome))}),plan:(t)=>[`Add a "${dn("<palette>")}" profile per palette to Terminal.app's settings — a copy of your own profile in the palette's colors, with its picture`,...t.startup?[`Make "${dn(t.startup)}" Terminal.app's default — \`ttheme off\` puts yours back`]:[]],notes:()=>[],next(t,e){let n=[`Terminal.app A "${dn("<palette>")}" profile per palette in Settings › Profiles`];if(t.startup)n.push(e?.restart?`Restart Terminal New windows and tabs open on "${dn(t.startup)}"`:`Terminal default "${dn(t.startup)}", which follows \`ttheme default\``);return n},unwire:()=>({edits:[],removals:[],touches:[]}),defaults:oF};import{spawn as sF}from"node:child_process";import{randomUUID as aF}from"node:crypto";import{existsSync as oi,mkdirSync as x1,readdirSync as Wm,readFileSync as Km,realpathSync as cF,rmSync as O1,writeFileSync as I1}from"node:fs";import{dirname as zm,join as ye}from"node:path";function Qi(t){return process.platform==="darwin"?ye(t,".warp","themes"):ye(Ha(t),"warp-terminal","themes")}function si(t,e){return process.platform==="darwin"?ye(t,".warp","settings.toml"):ye(e,"warp-terminal","settings.toml")}var ul='"dark"';function ll(t){return ye(t,"ttheme","warp.base")}function uF(t){return ye(t,"ttheme","warp.later")}var A1="[appearance.themes]";function T1(t){let e=t.findIndex((r)=>r.trim()===A1);if(e<0)return;let n=t.findIndex((r,i)=>i>e&&r.trimStart().startsWith("["));return[e,n<0?t.length:n]}function ai(t){let e=t.split(`
|
|
597
|
+
`),n=T1(e);if(!n)return;return e.slice(n[0]+1,n[1]).find((i)=>/^theme\s*=/.test(i))?.replace(/^theme\s*=\s*/,"").trim()}function qm(t,e=`${j(t)}.yaml`){return`{ custom = { name = "${t}", path = "${e}" } }`}function lF(t){return t?.includes(`path = "${j("")}`)===!0?/name = "([^"]+)"/.exec(t)?.[1]:void 0}function fl(t,e){let n=t.split(`
|
|
598
|
+
`),r=T1(n);if(!r)return e===void 0?t:`${t.replace(/\n*$/,`
|
|
597
599
|
`)}
|
|
598
|
-
${
|
|
600
|
+
${A1}
|
|
599
601
|
theme = ${e}
|
|
600
602
|
`;let i=n.findIndex((o,s)=>s>r[0]&&s<r[1]&&/^theme\s*=/.test(o));if(i>=0)n.splice(i,1,...e===void 0?[]:[`theme = ${e}`]);else if(e!==void 0)n.splice(r[0]+1,0,`theme = ${e}`);return n.join(`
|
|
601
|
-
`)}function
|
|
602
|
-
do local path = ${r} local file = io.open(path) if file then file:close() dofile(path)(config) end end`}var
|
|
603
|
+
`)}function cl(t){return ai(t)?.includes(`path = "${j("")}`)===!0}var fF="setTimeout(() => { const fs = require('node:fs'); const [file, next, seen, theme, later, token] = process.argv.slice(-6); if (!fs.existsSync(later) || fs.readFileSync(later, 'utf8') !== token || fs.readFileSync(file, 'utf8') !== seen || !fs.existsSync(theme)) return; const tmp = file + '.ttheme-' + process.pid; fs.writeFileSync(tmp, next); fs.chmodSync(tmp, fs.statSync(file).mode & 0o7777); fs.renameSync(tmp, file) }, 500)";function H1(t,e,n){return{image:ye(t,Uy(e.name,n.image,e.background)),opacity:n.opacity}}function P1(t){let e=Qi(t.home),n=X(t.configHome),r=new Map,i=new Set;for(let o of t.themes){let s=He(n,o.name,t.home),a=Fa(o.name,s&&H1(e,o,s));r.set(o.name,a);for(let c of new Set([a,Fa(o.name)]))if(!oi(ye(e,c)))i.add(c)}return{files:r,fresh:i}}function R1(t,e,n){let r=Qi(t.home),i=X(t.configHome),o=new Set(n.values()),s=ai(ct(si(t.home,t.configHome)))??"";for(let u of t.themes){let f=He(i,u.name,t.home),l=n.get(u.name);if(f&&l){let d=H1(r,u,f);if(!oi(d.image))try{let h=Gt(new Uint8Array(Km(f.image)));C(d.image,Tr(Ar(h,u.background,1)))}catch{n.set(u.name,Fa(u.name));continue}e.write(ye(r,l),La(u,d))}}if(!oi(r))return;let a=(u,f)=>u.startsWith(j(""))&&new RegExp(`\\.[0-9a-f]{8}\\.${f}$`).test(u);for(let u of Wm(r))if(a(u,"yaml")&&!o.has(u)&&!s.includes(`path = "${u}"`))e.remove(ye(r,u));let c=new Set;for(let u of Wm(r)){let f=u.startsWith(j(""))&&u.endsWith(".yaml")?/^ {2}path: "(.+)"$/m.exec(ct(ye(r,u)))?.[1]:void 0;if(f)c.add(f)}for(let u of Wm(r))if(a(u,"png")&&!c.has(ye(r,u)))e.remove(ye(r,u))}function dF(t,e){let n=process.env.TTHEME_WARP_WEARS;return t!==void 0&&n!==void 0&&e.files.has(n)?n:t}function N1(t,e,n,r=!1){let i=si(t.home,t.configHome);if(!oi(i))return;let o=ll(t.configHome),s=Km(i,"utf8"),a=r?lF(ai(s)):e;if(r&&(a===void 0||!n.files.has(a)))return;let c=uF(t.configHome);O1(c,{force:!0});let u;if(a){if(!cl(s)&&!oi(o))x1(zm(o),{recursive:!0}),I1(o,ai(s)??"");u=qm(a,n.files.get(a))}else{if(!cl(s))return;u=oi(o)&&Km(o,"utf8")||ul,O1(o,{force:!0})}let f=fl(s,u);if(f===s)return;let l=a===void 0?void 0:n.files.get(a)??`${j(a)}.yaml`;if(l!==void 0&&n.fresh.has(l)){fd(i);let d=aF();x1(zm(c),{recursive:!0}),I1(c,d),sF(process.execPath,["-e",fF,cF(i),f,s,ye(Qi(t.home),l),c,d],{detached:!0,stdio:"ignore"}).unref()}else $n(i,f);return i}var Dm={id:"warp",name:"Warp",emitter:vm,shelf:{from:"themes",dir:(t)=>Qi(t.home)},bakes:!0,offered:(t,e)=>e.platform!=="win32",present:(t)=>oi(zm(Qi(t.home))),sync(t,e){let n=P1(t);e.themes(Dm),R1(t,e,n.files);let r=N1(t,dF(t.startup,n),n);if(r)e.note(r)},pictures(t,e){let n=P1(t);R1(t,e,n.files),N1(t,void 0,n,!0)},plan(t){let e=si(t.home,t.configHome);return t.startup&&oi(e)?[`Edit ${ft(e,t.home)} — [appearance.themes] theme; \`ttheme off\` puts yours back`]:[]},notes:()=>["Warp wears one theme for the whole app, set through its settings.toml — a tab that takes a palette (`ttheme use`, a pin, preview) switches it, and switching tabs puts on the palette of the tab in front, read from Warp’s session database with sqlite3"],next:()=>[],unwire(t){let e=si(t.home,t.configHome),n=ct(e);return{edits:cl(n)?[{file:e,content:fl(n,ct(ll(t.configHome))||ul)}]:[],removals:cl(n)?[]:Jc(e),touches:[]}}};import{existsSync as ml}from"node:fs";import{join as vs}from"node:path";var F1=/-- ttheme begin\n[\s\S]*?-- ttheme end\n?/,hF=/^return config[ \t]*$/gm;function mF(t,e){let n=Xr(t,e,""),r=n===void 0?JSON.stringify(t):`require('wezterm').home_dir .. ${JSON.stringify(n)}`;return`-- ${ke}
|
|
604
|
+
do local path = ${r} local file = io.open(path) if file then file:close() dofile(path)(config) end end`}var C1=`local wezterm = require 'wezterm'
|
|
603
605
|
local config = wezterm.config_builder()
|
|
604
606
|
|
|
605
|
-
`;function
|
|
606
|
-
`?"":e}function
|
|
607
|
+
`;function pF(t){let e=t.replace(/-- ttheme begin\n[\s\S]*?-- ttheme end\n\n?/,"");return e===`${C1}return config
|
|
608
|
+
`?"":e}function Jm(t,e){let n=`-- ttheme begin
|
|
607
609
|
${e}
|
|
608
610
|
-- ttheme end
|
|
609
|
-
`;if(
|
|
611
|
+
`;if(F1.test(t))return t.replace(F1,n);if(t==="")return`${C1}${n}
|
|
610
612
|
return config
|
|
611
|
-
`;let r=[...t.matchAll(
|
|
612
|
-
${t.slice(r.index)}`}function
|
|
613
|
-
`)}function
|
|
614
|
-
`),this.shown=[]}put(t,e){let n=t.map((o)=>
|
|
613
|
+
`;let r=[...t.matchAll(hF)].at(-1);if(r?.index===void 0)return;return`${t.slice(0,r.index)}${n}
|
|
614
|
+
${t.slice(r.index)}`}function dl(t,e){let n=vs(e,".wezterm.lua");return ml(n)?n:vs(t,"wezterm","wezterm.lua")}function L1(t){return vs(t.configHome,"wezterm","colors")}function hl(t){return vs(t.configHome,"ttheme","wezterm.lua")}var Ym={id:"wezterm",name:"WezTerm",emitter:Sm,shelf:{from:"colors",dir:L1},offered:()=>!0,present:(t)=>ml(vs(t.configHome,"wezterm"))||ml(vs(t.home,".wezterm.lua")),sync(t,e){e.themes(Ym),e.write(hl(t),zy({path:hl(t),colors:L1(t),backgrounds:X(t.configHome),...t.startup?{startup:t.startup}:{},palettes:t.themes}));let n=dl(t.configHome,t.home),r=Jm(ct(n),mF(hl(t),t.home));if(r!==void 0)e.wire(n,r)},plan(t){let e=dl(t.configHome,t.home);return Jm(ct(e),"")!==void 0?[`Edit ${ft(e,t.home)} — a ttheme block before \`return config\`: color_scheme_dirs, color_scheme, pictures`]:[]},notes(t){let e=dl(t.configHome,t.home);return ml(e)&&Jm(ct(e),"")===void 0?[`${e} has no \`return config\` line — ttheme left it alone; call \`dofile("${hl(t)}")(config)\` from it yourself`]:[]},next:()=>["WezTerm Reloads its config by itself"],unwire:(t)=>({edits:ln(dl(t.configHome,t.home),pF),removals:[],touches:[]})};import{existsSync as _1,readFileSync as gF,utimesSync as bF}from"node:fs";import{dirname as wF,join as pl}from"node:path";function Vm(t){return pl(t,"Microsoft","Windows Terminal","Fragments","ttheme","ttheme.json")}function j1(t){return[pl(t,"Packages","Microsoft.WindowsTerminal_8wekyb3d8bbwe","LocalState","settings.json"),pl(t,"Packages","Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe","LocalState","settings.json"),pl(t,"Microsoft","Windows Terminal","settings.json")].filter((e)=>_1(e))}function $F(t){for(let e of t){let n=/"defaultProfile"\s*:\s*"(\{[0-9a-fA-F-]+\})"/.exec(gF(e,"utf8"))?.[1];if(n)return n}return}function G1(t){if(t.platform==="win32")return t.env.LOCALAPPDATA;if(!t.env.WSL_DISTRO_NAME)return;let e=t.run("cmd.exe",["/d","/c","echo %LOCALAPPDATA%"]);return e&&t.run("wslpath",["-u",e])||void 0}var B1={id:"windows-terminal",name:"Windows Terminal",emitter:Mm,offered:(t)=>t.wtHome!==void 0,present:(t)=>t.wtHome!==void 0,installs:(t)=>({wtHome:t.wtHome,wtProfile:t.wtProfile}),sync(t,e){let{wtHome:n,wtProfile:r}=t.state;if(!n)return;let i=j1(n);if(e.write(Vm(n),Em(t.themes,r??$F(i),t.startup))){let o=new Date;for(let s of i)bF(s,o,o);if(i.length>0)e.repaint()}},plan:(t)=>t.state.wtHome?[`Write ${Vm(t.state.wtHome)} — its schemes, and touch settings.json so it reloads`]:[],notes:(t)=>t.state.wtHome?[]:["Windows Terminal: %LOCALAPPDATA% was not found — drop the release fragment into its Fragments folder yourself"],next:()=>["Windows Terminal Reloads its settings by itself"],unwire(t,e){let n=e?.wtHome,r=n?wF(Vm(n)):void 0;return{edits:[],removals:r&&_1(r)?[r]:[],touches:n?j1(n):[]}}};var ur={ghostty:Nm,kitty:Fm,alacritty:Rm,wezterm:Ym,iterm2:s1,"windows-terminal":B1,warp:Dm,konsole:w1,"terminal-app":M1};function yt(t=ee){return t.map((e)=>ur[e])}function eo(t){return t.startup&&t.palettes.includes(t.startup)?t.startup:t.palettes[0]}function je(t){return t.off?void 0:eo(t)}function J(){return process.env.XDG_CONFIG_HOME??Ss(hn(),".config")}var to=(t)=>typeof t==="string"&&t!==""?t:void 0,kF={author:to,startup:to,off:(t)=>t?!0:void 0,itermBase:to,konsoleBase:to,terminalBase:to,wtHome:to,wtProfile:to,markets:(t)=>Array.isArray(t)?t.filter((e)=>typeof e==="string"):void 0,updates:(t)=>t&&typeof t==="object"?Object.fromEntries(Object.entries(t).filter((e)=>typeof e[1]==="boolean")):void 0};function z(t){let e=Qn(t);if(!gl(e))throw Error(`nothing installed yet at ${e} — run \`ttheme init\` first`);let n=JSON.parse(U1(e,"utf8"));if(!Array.isArray(n?.palettes)||!Array.isArray(n.terminals))throw Error(`${e} has no palettes or terminals`);return{terminals:n.terminals.filter((r)=>ee.includes(r)),...Object.fromEntries(Object.entries(kF).flatMap(([r,i])=>{let o=i(n[r]);return o===void 0?[]:[[r,o]]})),palettes:n.palettes}}function Ze(t,e){C(Qn(t),`${JSON.stringify(e,null,2)}
|
|
615
|
+
`)}function W1(t,e){let n=new Map(t.palettes.map((i)=>[i.name,i])),r=e.filter((i)=>!n.has(i));if(r.length>0){let i=[...new Set(r.flatMap((s)=>ut(s)??[]))].filter((s)=>!t.palettes.some((a)=>ut(a.name)===s)),o=i.length>0?`add ${i.join(", ")} first — \`ttheme market search\` finds a market's repository`:Ah(At(t.palettes),r);throw Error(`not in any market: ${r.join(", ")} — ${o}`)}return t.palettes.filter((i)=>e.includes(i.name))}function Ua(t,e,n){return{configHome:t,home:n,state:e,startup:je(e)}}function K1(t,e,n,r,i){return{...Ua(t,n,r),entries:e,themes:e.map(Fe),host:i}}function z1(t){let e=[],n={written:e,repainted:!1,write(r,i){if(e.push(r),gl(r)&&U1(r,"utf8")===i)return!1;return C(r,i),!0},wire(r,i){e.push(r),$n(r,i)},note(r){e.push(r)},remove(r){Zm(r,{force:!0})},themes(r){let i=r.shelf?.dir(t);if(!i)return;for(let o of t.themes)for(let{file:s,content:a}of pm(r,o))n.write(Ss(i,s),a)},repaint(){n.repainted=!0}};return n}function yF(t,e){return Object.assign({},...yt(t.state.terminals).map((n)=>n.layer?.(t,e)??{}))}function Kt(t,e,n,r=hn(),i=Ve()){Nt(X(t));let o=W1(rr(t,e),n.palettes),s=xu(o,Ut(t));H$(t,new Map(s.map((u)=>[u.name,qo(u)]))),S$(t),ss(t,o);let a=K1(t,s,n,r,i),c=z1(a);for(let u of yt(n.terminals))u.sync(a,c);return c.written.push(J1(a,i,c.repainted)),D1(t,s,r),c.written}function q1(t,e=hn()){if(!gl(Ss(t,"ttheme","palettes.zsh")))return;let n=new Set(z(t).palettes);D1(t,we(t).palettes.filter((r)=>n.has(r.name)),e)}function D1(t,e,n){let r=Ss(t,"ttheme","aliases.zsh"),i=Ty(vF(e,n));if(ct(r)!==i)C(r,i)}function vF(t,e){let n=t.flatMap((o)=>o.booru?[o.booru]:[]),r=dh(n,e),i={};for(let o of t){let s=new Set(o.nativeNames??[]),a=(o.booru?r.get(o.booru)??[]:[]).filter((c)=>!s.has(c));if(a.length>0)i[o.name]=a}return i}function J1(t,e,n){let r=Ss(t.configHome,"ttheme","palettes.zsh"),i=hm(t.entries,t.startup,t.state.terminals,yF(t,e),Object.keys(Ut(t.configHome)));if(n||ct(r)!==i)C(r,i),Zm(`${r}.zwc`,{force:!0});return r}function _e(t,e=hn(),n=Ve()){let r=z(t),i=yt(r.terminals).filter((a)=>a.pictures);if(i.length===0)return;let o=K1(t,W1(we(t),r.palettes),r,e,n),s=z1(o);for(let a of i)a.pictures?.(o,s);J1(o,n,!1)}function no(t){return!yt(t).some((e)=>e.bakes)}function bl(t,e,n=hn()){let r=Ua(t,e,n);return yt(e.terminals).flatMap((i)=>[...i.shelf?[`Write ${ft(i.shelf.dir(r),n)}/${j("*")} — a theme file per palette`]:[],...i.plan(r)])}function wl(t,e,n=hn()){let r=Ua(t,e,n);return yt(e.terminals).flatMap((i)=>i.notes(r))}function $l(t,e,n,r=hn()){let i=Ua(t,e,r);return yt(e.terminals).flatMap((o)=>o.next(i,n.get(o.id)))}function Es(t,e,n,r,i=hn()){let o=[],s=Wt(t,e,!1).palettes;for(let a of yt(n)){let c=a.shelf?.dir({configHome:t,home:i});for(let u of c?s.filter((f)=>r.includes(f.name)):[])for(let{file:f}of pm(a,Fe(u))){let l=Ss(c,f);if(gl(l))Zm(l,{force:!0}),o.push(l)}}return o}function Y1(t,e,n,r){return{...Ua(t,e,r),host:n}}function Wa(t,e,n,r=hn()){return yt(e.terminals).reduce((i,o)=>o.defaults?.base(Y1(t,i,n,r))??i,e)}function ro(t,e,n,r,i=hn()){let o=new Map;for(let s of yt(e.terminals)){let a=s.defaults?.point(Y1(t,e,r,i),n);if(a)o.set(s.id,a)}return o}function Xe(t,e,n,r,i=!1,o=Ve(),s=hn()){let a=i||!je(n)&&je(r)!==void 0,c=a?Wa(t,r,o,s):r;return Kt(t,e,c,s,o),Ze(t,c),a||je(n)!==je(r)?ro(t,c,a,o,s):new Map}import{performance as V1}from"node:perf_hooks";var SF=16,Xm=80,Z1="\x1B[?2026h",X1="\x1B[?2026l";class io{shown=[];pointer=new Hh;cursor="";wipe="";immediate;delayed;ticker;last=Number.NEGATIVE_INFINITY;stopped=!1;write;view;beat;constructor(t){this.write=t.write,this.view=t.view,this.beat=t.beat??(()=>{})}request(){if(this.stopped||this.immediate||this.delayed)return;let t=this.last+SF-V1.now();if(t>0)this.delayed=setTimeout(this.paint,t);else this.immediate=setImmediate(this.paint)}soon(){if(this.stopped||this.immediate)return;clearTimeout(this.delayed),this.delayed=void 0,this.immediate=setImmediate(this.paint)}now(){this.cancel(),this.paint()}reset(t=""){this.shown=[],this.cursor="",this.wipe=t}stop(){this.stopped=!0,this.cancel(),clearInterval(this.ticker),this.ticker=void 0}point(t){return this.pointer.point(t)}drop(){this.pointer.drop()}cancel(){clearImmediate(this.immediate),clearTimeout(this.delayed),this.immediate=void 0,this.delayed=void 0}paint=()=>{if(this.immediate=void 0,this.delayed=void 0,this.stopped)return;let{drawn:t,targets:e}=Rk(()=>this.view());if(!t)return;this.last=V1.now();let{lines:n,zones:r}=Tk(t.lines,e);this.pointer.zones=[...t.zones??[],...r];let i=this.wipe;this.wipe="";let o=new Set,s=Math.max(n.length,this.shown.length);for(let f=0;f<s;f++){let l=n[f];if(l!==this.shown[f])i+=`\x1B[${f+1};1H${me}\x1B[2K${l??""}`,o.add(f)}this.shown=n;let a=t.after?.(o)??"",c=t.cursor??"",u=c!==""&&(i!==""||a!==""||c!==this.cursor);if(this.cursor=c,i||a||u)this.write(`${Z1}${i}${a}${me}${u?c:""}${X1}`);this.tick(t.ticking===!0)};tick(t){if(t&&!this.ticker)this.ticker=setInterval(()=>{this.beat(),this.request()},Xm);else if(!t&&this.ticker)clearInterval(this.ticker),this.ticker=void 0}}class Qm{shown=[];write;cols;constructor(t,e){this.write=t,this.cols=e}draw(t){this.put(t,"")}redraw(t){let e=`${this.shown.length>1?`\x1B[${this.shown.length-1}A`:""}${this.shown.length>0?"\r\x1B[J":""}`;this.shown=[],this.put(t,e)}end(t){this.put(t,""),this.write(`
|
|
616
|
+
`),this.shown=[]}put(t,e){let n=t.map((o)=>tt(o,this.cols()-1,!1)),r=0;while(r<n.length&&r<this.shown.length&&n[r]===this.shown[r])r++;if(r===n.length&&n.length===this.shown.length)return;if(r===n.length)r=Math.max(0,n.length-1);let i="";if(this.shown.length===0)i=n.join(`
|
|
615
617
|
`);else if(r>=this.shown.length)i=`
|
|
616
618
|
${n.slice(r).join(`
|
|
617
619
|
`)}`;else{let o=this.shown.length-1-r;i=`${o>0?`\x1B[${o}A`:""}\r\x1B[J${n.slice(r).join(`
|
|
618
|
-
`)}`}this.shown=n,this.write(`${
|
|
620
|
+
`)}`}this.shown=n,this.write(`${Z1}${e}${i}${X1}`)}}var EF=300;function kl(t){return t>=1e6?`${(t/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(t/1000))} KB`}function yl(t,e){if(!e)return kl(t);return e>=1e6?`${(t/1e6).toFixed(1)}/${(e/1e6).toFixed(1)} MB`:`${Math.round(t/1000)}/${Math.round(e/1000)} KB`}var Ms;async function Q1(t,e){Ms=t;try{return await e()}finally{Ms=void 0}}function An(t){if(Ms)Ms.say(t);else console.log(t)}function ci(t=""){if(Ms){let u=Ms;return u.set(t),{set:(f)=>u.set(f),say:(f)=>u.say(f),done:()=>u.set("")}}let e=process.stdout;if(!e.isTTY||process.env.TERM==="dumb")return{set(){},say:(u)=>console.log(u),done(){}};let[n,r]=Ht()?["",""]:[bt("dim"),ed("dim")],i=0,o=!1,s,a=()=>{e.write(`\r\x1B[2K${n}${tt(`${Kn[i%Kn.length]} ${t}`,(e.columns||80)-1,!1)}${r}`)},c=setTimeout(()=>{o=!0,a(),s=setInterval(()=>{i++,a()},Xm),s.unref()},EF);return c.unref(),{set(u){if(t=u,o)a()},say(u){if(o)e.write("\r\x1B[2K");if(console.log(u),o)a()},done(){if(clearTimeout(c),clearInterval(s),o)e.write("\r\x1B[2K"),o=!1}}}import{existsSync as ap,mkdirSync as kv,readFileSync as yv,statSync as UF,utimesSync as WF}from"node:fs";import{homedir as KF}from"node:os";import{dirname as zF,join as wv}from"node:path";function vl(t){if(t.length>0&&process.stderr.isTTY)process.stderr.write(`${t.join(`
|
|
619
621
|
`)}
|
|
620
|
-
`)}import{existsSync as
|
|
622
|
+
`)}import{existsSync as MF,readFileSync as xF}from"node:fs";import{join as OF}from"node:path";function IF(t){return OF(t,"ttheme","pins")}function tv(t,e,n){let r=IF(t);if(!MF(r))return;let i=xF(r,"utf8"),s=i.split(`
|
|
621
623
|
`).flatMap((a)=>{let c=/^((?:[~/]|ssh:).*\s)(\S+)(\s*)$/.exec(a);if(!c)return[a];let[,u,f,l]=c;if(n.includes(f))return[];let d=e.get(f);return[d?`${u}${d}${l}`:a]}).join(`
|
|
622
|
-
`);if(s!==i)
|
|
623
|
-
`)}function
|
|
624
|
-
`).find((f)=>/\S/.test(f))?.replace(/^npm (error|ERR!) /,""),{code:c,killed:u}=r;n(Error(c==="ENOENT"?"cannot run npm":u?`npm did not answer within ${t/1000} s`:`npm could not ask its registry — ${a??"it gave no reason"}`));return}let s=i.trim();if(!
|
|
625
|
-
`)}function
|
|
626
|
-
`)}function
|
|
627
|
-
The Browse tab of \`ttheme\` picks them, or \`ttheme add ${r}/<palette>\``)}function
|
|
624
|
+
`);if(s!==i)C(r,s)}import{execFile as PF,spawn as RF,spawnSync as tp}from"node:child_process";import{mkdirSync as NF,readFileSync as AF,realpathSync as ev}from"node:fs";import{homedir as TF,tmpdir as nv}from"node:os";import{dirname as HF,join as ep}from"node:path";var Ka=`npx ${lt.name}@latest init`,ip=86400000,FF=3600000,LF=1e4,np=/^(\d+)\.(\d+)\.(\d+)$/;function rv(t,e){let n=np.exec(t),r=np.exec(e);if(!n||!r)return!1;for(let i of[1,2,3]){let o=Number(n[i])-Number(r[i]);if(o!==0)return o>0}return!1}function Os(t=process.env){return t.TTHEME_AUTO_UPDATE!=="off"&&(t.CI===void 0||t.CI===""||t.CI==="false")}function rp(){return ep(process.env.XDG_STATE_HOME??ep(TF(),".local","state"),"ttheme","release.json")}function za(){try{let t=JSON.parse(AF(rp(),"utf8"));return{checked:typeof t.checked==="number"?t.checked:0,...typeof t.latest==="string"?{latest:t.latest}:{},...typeof t.told==="number"?{told:t.told}:{}}}catch{return{checked:0}}}function xs(t){NF(HF(rp()),{recursive:!0}),C(rp(),`${JSON.stringify(t)}
|
|
625
|
+
`)}function iv(t=LF){return new Promise((e,n)=>{PF("npm",["view",`${lt.name}@latest`,"version","--prefer-online"],{cwd:nv(),encoding:"utf8",timeout:t,env:{...process.env,npm_config_update_notifier:"false"}},(r,i,o)=>{if(r){let a=o.split(`
|
|
626
|
+
`).find((f)=>/\S/.test(f))?.replace(/^npm (error|ERR!) /,""),{code:c,killed:u}=r;n(Error(c==="ENOENT"?"cannot run npm":u?`npm did not answer within ${t/1000} s`:`npm could not ask its registry — ${a??"it gave no reason"}`));return}let s=i.trim();if(!np.test(s)){n(Error("the npm registry named no version"));return}e(s)})})}function ov(t=Date.now()){let e=za();if(!Os()||t-e.checked<ip)return;try{xs({...e,checked:t}),RF(process.execPath,[process.argv[1],"latest"],{detached:!0,stdio:"ignore",env:process.env}).unref()}catch{}}async function sv(){let t=za();try{return xs({...t,checked:Date.now(),latest:await iv()}),0}catch{return xs({...t,checked:Date.now()-ip+FF}),1}}function av(t=J()){return ep(t,"ttheme","ttheme.js")}function cv(){try{return ev(process.argv[1])===ev(av())}catch{return!1}}function CF(){return cv()?"`ttheme update` updates it":`\`${Ka}\` updates it`}function uv(t,e=lt.version){return`ttheme ${t} is out, you have ${e} — ${CF()}`}function lv(t=Date.now()){let e=za();if(!Os()||!e.latest||!rv(e.latest,lt.version)||t-(e.told??0)<ip)return;if(process.stderr.isTTY)xs({...e,told:t});vl([uv(e.latest)])}function fv(t,e){console.log(`Updating ttheme ${lt.version} → ${t}`);let n=tp("npx",["--yes",`${lt.name}@${t}`,"init","--yes"],{cwd:nv(),stdio:"inherit",env:{...process.env,npm_config_prefer_online:"true"}});if(n.error)throw Error(`cannot run npx — ${n.error.message}; \`${Ka}\` updates ttheme once npm is there`);if(n.status!==0)throw Error(`npx stopped with status ${n.status} — ttheme ${lt.version} is still installed`);let r=av(),i=tp(process.execPath,[r,"--version"],{encoding:"utf8"}).stdout?.trim();if(i!==t)throw Error(`${r} is ${i||"unreadable"} after the update, not ${t} — \`${Ka}\` tries again`);let o=za();return xs({...o,latest:t}),tp(process.execPath,[r,"update",...e],{stdio:"inherit",env:{...process.env,TTHEME_UPDATED:t}}).status??1}async function dv(){if(process.env.TTHEME_UPDATED)return{note:` ttheme ${lt.version} — updated`};let t;try{t=await iv()}catch(e){return{note:` ttheme ${lt.version} — could not check for a newer one: ${e.message}`}}if(xs({...za(),checked:Date.now(),latest:t}),!rv(t,lt.version))return{note:` ttheme ${lt.version} — up to date`};return cv()?{latest:t,note:""}:{note:` ${uv(t)}`}}function hv(t,e){let n=e,r=new Set;while(Object.hasOwn(t,n)&&!r.has(n)){r.add(n);let i=t[n];if(i===!1)return!1;n=i}return r.has(n)||n===e?void 0:n}function mv(t,e,n,r,i){let o=`${t}/`;for(let s of r){let a=s.startsWith(o)?s.slice(o.length):void 0;if(a===void 0||n.has(a))continue;let c=hv(e.renames,a);if(c===!1)i.removed.push(s);else if(c!==void 0&&n.has(c))i.renamed.set(s,`${o}${c}`);else if(e.forceRemove)i.removed.push(s)}}function pv(t,e){let n=[],r=[];for(let i of Object.keys(t)){if(e.has(i)){r.push(`renames.${i}: ${i} is still a palette here, so the rename never applies`);continue}let o=hv(t,i);if(o===void 0)n.push(`renames.${i}: the chain comes back to a name it already passed`);else if(o!==!1&&!e.has(o))n.push(`renames.${i}: the chain ends at ${o}, which is not a palette here — end it at one, or at false`)}return{errors:n,warnings:r}}import{gunzipSync as jF}from"node:zlib";var oo=512,gv=67108864,op=new TextDecoder;function Is(t,e,n){let r=t.subarray(e,e+n),i=r.indexOf(0);return op.decode(i<0?r:r.subarray(0,i))}function _F(t){if((t[124]??0)&128)throw Error("the archive holds a file too large to be a palette");let e=Number.parseInt(Is(t,124,12).trim()||"0",8);if(!Number.isFinite(e)||e<0)throw Error("the archive has a header that does not read");return e}function GF(t){let e=0,n;while(e<t.length){let r=t.indexOf(32,e),i=r<0?Number.NaN:Number.parseInt(op.decode(t.subarray(e,r)),10);if(!Number.isFinite(i)||i<=0)break;let o=op.decode(t.subarray(r+1,e+i-1)),s=o.indexOf("=");if(o.slice(0,s)==="path")n=o.slice(s+1);e+=i}return n}function BF(t){if(t[0]!==31||t[1]!==139)return t;try{return jF(t,{maxOutputLength:gv})}catch(e){throw Error(e instanceof RangeError?`the archive unpacks to more than ${gv/1024/1024} MB`:"the archive is not a gzip file that reads")}}function bv(t){let e=BF(t),n=new Map,r,i=0;while(i+oo<=e.length){let o=e.subarray(i,i+oo);if(o.every((l)=>l===0))break;let s=_F(o),a=e.subarray(i+oo,i+oo+s);i+=oo+Math.ceil(s/oo)*oo;let c=String.fromCharCode(o[156]??0);if(c==="x"){r=GF(a)??r;continue}if(c==="L"){r=Is(a,0,a.length);continue}let u=Is(o,257,5)==="ustar"?Is(o,345,155):"",f=r??(u?`${u}/${Is(o,0,100)}`:Is(o,0,100));if(r=void 0,c==="0"||c==="\x00")n.set(f.split("/").slice(1).join("/"),a)}return n}var qF=86400000,DF=3600000,cp=5000;function sp(){return wv(process.env.XDG_STATE_HOME??wv(KF(),".local","state"),"ttheme","markets.json")}function lr(){try{let t=JSON.parse(yv(sp(),"utf8"));return Object.fromEntries(Object.entries(t).filter((e)=>typeof e[1]?.at==="number"&&typeof e[1].error==="string"))}catch{return{}}}function $v(t,e){let n=lr();if(e===void 0){if(!(t in n))return;delete n[t]}else n[t]={at:Date.now(),error:e};kv(zF(sp()),{recursive:!0}),C(sp(),`${JSON.stringify(n,null,2)}
|
|
627
|
+
`)}function up(t,e){let n=kt(e)?tr(t,e):void 0;try{return n?UF(n).mtimeMs:void 0}catch{return}}function JF(t,e,n,r){return t&&(e===void 0||r-e>=qF)&&(n===void 0||r-n>=DF)}function lp(t,e,n=Date.now()){let r=lr();return Dt(e.markets).filter((i)=>JF(Wr(i,e.updates),up(t,i),r[i]?.at,n))}function YF(t,e){let n={},r=new TextDecoder;for(let[i,o]of bv(t))if(i===Bt||i.startsWith("palettes/")&&i.endsWith(".toml"))n[i]=r.decode(o);return{...e?{etag:e}:{},files:n}}async function vv(t,e,n,r){let i;try{i=await Nh(X$(t),e,n,r?{"if-none-match":r}:{})}catch(o){if(o instanceof Pu){let s=ya(t);throw Error(`${rt(t)}${s?` has no ${s}`:" is not there"} — is the repository public?`)}throw o}if(i.status===304)return;return YF(new Uint8Array(await i.arrayBuffer()),i.headers.get("etag"))}function Sv(t,e,n){let{id:r,info:i,entries:o}=Ki(t,e,n,fe(!1));return{source:t,id:r,entries:o,archive:e,info:i}}function qa(t){return Rs(t,V)}async function Da(t,e,n,r){if(e===V){if(!ap(er(t)))throw Error(`the ttheme catalog is not on this machine — \`${Ka}\` puts it back`);return{source:e,id:V,entries:Rs(t,V)}}let i=await vv(e,n,r);if(!i)throw Error(`${rt(e)} answered as if nothing had changed`);return Sv(e,i,qa(t))}function Ps(t,e){if(!("archive"in e))return;kv(ph(t),{recursive:!0}),C(tr(t,e.source),`${JSON.stringify(e.archive)}
|
|
628
|
+
`)}function VF(t,e){try{return nr(t,e)}catch{return}}function Rs(t,e){try{if(e===V)return zr(yv(er(t),"utf8")).palettes;return Ki(e,nr(t,e),qa(t),fe(!1)).entries}catch{return[]}}function ZF(t,e){let n=new Map(t.map((i)=>[i.name,JSON.stringify(i)])),r=new Map(e.map((i)=>[i.name,JSON.stringify(i)]));return{added:[...r.keys()].filter((i)=>!n.has(i)),changed:[...r].filter(([i,o])=>n.has(i)&&n.get(i)!==o).map(([i])=>i),gone:[...n.keys()].filter((i)=>!r.has(i))}}async function XF(t,e,n){if(!kt(e))return Da(t,e,n);let r=VF(t,e),i=await vv(e,n,void 0,r?.etag);return i&&Sv(e,i,qa(t))}async function fp(t,e,n){let r=Rs(t,e),i;try{i=await XF(t,e,n)}catch(s){throw $v(e,s.message),s}if(i)Ps(t,i);else{let s=new Date;WF(tr(t,e),s,s)}$v(e,void 0);let o=i?.entries??r;return{source:e,id:i?.id??Iu(e,nr(t,e)),count:At(o).length,change:ZF(r,o)}}async function dp(t,e,n){try{return{source:e,refreshed:await fp(t,e,n)}}catch(r){return{source:e,failure:r instanceof Error?r:Error(String(r))}}}function Ev(t,e){return`${rt(t)}: ${e.message}`}function zt(t){return`${t} palette${t===1?"":"s"}`}function hp(t,e=Date.now()){let n=Math.floor(Math.max(0,e-t)/60000);if(n<1)return"just now";if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Mv({added:t,changed:e,gone:n}){return[t.length>0?`${t.length} new`:"",e.length>0?`${e.length} changed`:"",n.length>0?`${n.length} gone`:""].filter(Boolean).join(", ")}function mp(t){let e=Mv(t.change);return`${t.id} — ${zt(t.count)}${e?` (${e})`:""}`}function pp(t){return Mv(t.change)?`Updated ${mp(t)}`:void 0}function Ja(t,e,n=qa(t)){try{if(Tt(e)){let r=cn(e),i=be(r);return{id:i,info:r,entries:xn(e,i,n,fe(!1))}}return kt(e)?Ki(e,nr(t,e),n,fe(!1)):void 0}catch{return}}function QF(t){if(!ap(Qn(t)))return[];let e=z(t),n=qa(t),r={renamed:new Map,removed:[]};for(let u of Dt(e.markets)){let f=Ja(t,u,n);if(f)mv(f.id,f.info,new Set(f.entries.map((l)=>pe(l.name))),e.palettes,r)}if(r.renamed.size===0&&r.removed.length===0)return[];let i=at(t,!1);Es(t,i,e.terminals,[...r.renamed.keys(),...r.removed]),pk(t,r.renamed,r.removed),E$(t,r.renamed),tv(t,r.renamed,r.removed);let o=[...new Set(e.palettes.filter((u)=>!r.removed.includes(u)).map((u)=>r.renamed.get(u)??u))],{startup:s,...a}=e,c=s&&!r.removed.includes(s)?r.renamed.get(s)??s:void 0;return Xe(t,i,e,{...a,palettes:o,...c?{startup:c}:{}}),[...[...r.renamed].map(([u,f])=>`${u} is ${f} now — its market renamed it`),...r.removed.map((u)=>`${u} was removed from its market`)]}function gp(t){let e=as(t,at(t,!1)).map((n)=>n.name);if(e.length===0)return;return`${e.join(", ")} ${e.length===1?"has":"have"} an update from ${e.length===1?"its market":"their markets"} — ctrl+r on a palette marked ↑ in Browse (\`ttheme\`) takes it`}function so(t,e){let n=QF(t),r=z(t),i=new Set(e.flatMap((s)=>s.change.gone)),o=r.palettes.filter((s)=>i.has(s)).map((s)=>`${s} left its market — ttheme keeps the copy you have`);return[...n,...o]}async function xv(t=J()){try{if(!Os()||!ap(Qn(t)))return;let e=lp(t,z(t));if(e.length===0)return;let n=ci(`Checking ${e.map(rt).join(", ")} for updates`),r=await Promise.all(e.map((s)=>dp(t,s,cp)));n.done();let i=r.flatMap((s)=>("refreshed"in s)?[s.refreshed]:[]),o=i.flatMap((s)=>pp(s)??[]);if(o.length===0)return;vl([...o,...so(t,i),...[gp(t)??[]].flat()])}catch{return}}var Nv=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,iL=["add","remove","search","init","check"];function wp(){return process.stdin.isTTY===!0&&process.stdout.isTTY===!0}function oL(){try{let t=tL("gh",["api","user","--jq",".login"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4}).trim().toLowerCase();return Nv.test(t)?t:void 0}catch{return}}async function sL(t,e){if(e.author)return e.author;let n=oL();if(!n){if(!wp())throw Error("your palettes are named after your GitHub handle — log in with `gh auth login`, or run this in a terminal");let r=await Zh({message:"Your GitHub handle — your palettes are named <handle>@<market>/<palette>",validate:(i)=>Nv.test((i??"").toLowerCase())&&(i??"").length<=39?void 0:"that is not a GitHub handle"});if(te(r))throw Error("no handle given");n=r.toLowerCase()}return Ze(t,{...e,author:n}),console.log(`Your palettes are named ${n}@<market>/<palette>`),n}function ui(t,e){if(e===V)return V;return Tt(e)?be(cn(e)):Iu(e,nr(t,e))}function xl(t,e){try{return ui(t,e)}catch{return}}function Av(t){return ut(t)??V}function Va(t){return at(t).palettes.filter((e)=>ut(e.name)===void 0)}function aL(t){let e=Ya(import.meta.dirname,"..","dist","manifest.json");return El(e)?zr(Ml(e,"utf8")).palettes:Va(t)}function Za(t,e,n){let{updates:r,...i}=t,o=Object.entries(n).filter(([s,a])=>kt(s)&&e.includes(s)&&a!==Wr(s,{}));return{...i,markets:e,...o.length>0?{updates:Object.fromEntries(o)}:{}}}function Tv(t,e,n,r){return e.find((i)=>i!==n&&!ns(i,n)&&xl(t,i)===r)}function bp(t,e,n,r){let i=z(t),o=Dt(i.markets),s=Tv(t,o,e,n);if(s)throw Error(`${n} already names the market at ${rt(s)} — \`ttheme market remove ${n}\` first`);let a=r===void 0?{...i.updates}:{...i.updates,[e]:r};Ze(t,Za(i,o.includes(e)?o:[...o,e],a))}async function cL(t){if(!wp())return!1;let e=await Ce({message:`Update ${t} on its own when its author changes it? ttheme checks once a day, when you run it`,initialValue:!1});if(te(e))throw Error("no answer given — nothing was added");return e}async function Hv(t,e){let n=ci(`Fetching ${rt(e)}`);try{return await Da(t,e)}finally{n.done()}}async function uL(t,e,n){let r=await Hv(t,n),i=z(t),o=Dt(i.markets),s=Tv(t,o,n,r.id);if(s)throw Error(`${r.id} already names the market at ${rt(s)} — \`ttheme market remove ${r.id}\` first`);let{[e]:a,...c}=i.updates??{},u=a===void 0?c:{...c,[n]:a};return Ze(t,Za(i,o.map((f)=>f===e?n:f),u)),Ps(t,r),r}async function $p(t,e){let n=Kr(e),r=Dt(z(t).markets);if(r.includes(n))return console.log(`${rt(n)} is already added`),{source:n,id:ui(t,n),fresh:!1};let i=kt(n)?r.find((c)=>kt(c)&&ns(c,n)):void 0;if(i){let c=await uL(t,i,n);return console.log(`Moved ${c.id} to ${ya(n)??"its default branch"} · ${rt(n)} — ${zt(At(c.entries).length)}`),{source:n,id:c.id,fresh:!1}}if(Tt(n)){let c=be(cn(n));bp(t,n,c);let u=xn(n,c,Va(t)).length;return console.log(`Added ${c} · ${rt(n)} — ${zt(u)}, read in place`),{source:n,id:c,fresh:!0}}let o=await Hv(t,n),s=n===V?void 0:await cL(o.id);bp(t,n,o.id,s),Ps(t,o);let a=zt(At(o.entries).length);return console.log(n===V?`Added the ttheme catalog — ${a}`:`Added ${o.id} · ${rt(n)} — ${a}${s?", updating on its own":""}`),{source:n,id:o.id,fresh:!0}}async function lL(t){let e=J(),{source:n,id:r,fresh:i}=await $p(e,t);if(!i)return;if(Tt(n))console.log("\nThe Browse tab of `ttheme` picks them · once the folder is on GitHub, `ttheme market add <owner>/<repo>` adds it anywhere");else if(n===V)console.log("\nThe Browse tab of `ttheme` picks them");else console.log(`
|
|
629
|
+
The Browse tab of \`ttheme\` picks them, or \`ttheme add ${r}/<palette>\``)}function kp(t,e){if(kt(e))rL(tr(t,e),{force:!0})}function yp(t){return`${zt(t.length)} installed from it keep${t.length===1?"s":""} working: ${t.join(", ")} — \`ttheme remove\` drops ${t.length===1?"it":"them"}`}function fL(t){let e=J(),n=z(e),r=Dt(n.markets),i=r.find((u)=>xl(e,u)===t)??r.find((u)=>u===Fv(t));if(!i)throw Error(`no market named ${t} — \`ttheme market\` lists them`);let o=xl(e,i),s=n.palettes.filter((u)=>Av(u)===o),a=r.filter((u)=>u!==i),c=Za(n,a,n.updates??{});if(Ze(e,c),kp(e,i),Kt(e,at(e),c),console.log(`Removed ${o??t} · ${rt(i)}`),s.length>0)console.log(yp(s))}function Fv(t){try{return Kr(t)}catch{return}}function dL(t,e){try{if(e===V)return At(zr(Ml(er(t),"utf8")).palettes).length;if(Tt(e))return xn(e,ui(t,e),Va(t),fe(!1)).length;return Ki(e,nr(t,e),Va(t),fe(!1)).entries.length}catch{return}}function vp(t,e,n=lr(),r=Date.now()){if(Tt(e))return"read in place";if(e===V)return"comes with ttheme";let i=n[e],o=up(t,e);if(i&&(o===void 0||i.at>o))return`update failed ${hp(i.at,r)}`;return o===void 0?"never updated":`updated ${hp(o,r)}`}function hL(){let t=J(),e=z(t),n=Dt(e.markets);if(n.length===0){console.log("No markets — `ttheme market add official` brings the ttheme catalog back");return}let r=lr(),i=n.map((a)=>{let c=xl(t,a)??"?",u=dL(t,a),f=e.palettes.filter((h)=>Av(h)===c).length,l=Tt(a)?[]:[`auto-update ${Wr(a,e.updates)?"on":"off"}`],d=a===V?void 0:Ja(t,a)?.info.description;return{name:c,where:rt(a),about:d,note:[u===void 0?"Unreadable":zt(u),...f>0?[`${f} installed`]:[],...l,vp(t,a,r)].join(" · ")}}),o=Math.max(...i.map((a)=>a.name.length)),s=Math.max(...i.map((a)=>a.where.length));for(let a of i)if(console.log(` ${a.name.padEnd(o)} ${a.where.padEnd(s)} ${a.note}`),a.about)console.log(` ${" ".repeat(o)} ${a.about}`)}function Sp(t){return`${t.owner.login.toLowerCase()}/${t.name}`}function Sl(t){return t.replace(/[\p{Cc}\s]+/gu," ").trim()}async function Ep(t,e){let n=encodeURIComponent(`topic:${ts}${t?` ${t}`:""}`);try{let{items:r}=await Mk(`https://api.github.com/search/repositories?q=${n}&sort=stars&per_page=50`,(i)=>JSON.parse(i),void 0,e);return r.map((i)=>({...i,full_name:Sl(i.full_name),name:Sl(i.name),description:i.description===null?null:Sl(i.description),owner:{...i.owner,login:Sl(i.owner.login)}}))}catch(r){if(r instanceof Ru)throw Error("GitHub lets a search through about ten times a minute without signing in — try again in a minute");throw r}}async function mL(t){let e=J(),n=await Ep(t);if(n.length===0){console.log(`No repository carries the ${ts} topic${t?` and matches ${t}`:""} yet`);return}let r=new Set(Dt(z(e).markets).map(Ur)),i=n.map((s)=>{let a=Sp(s);return{arg:a,added:r.has(a),stars:`★${s.stargazers_count}`,about:s.description??""}}),o=Math.max(...i.map((s)=>s.arg.length));for(let s of i)console.log(` ${s.added?"●":"○"} ${s.arg.padEnd(o)} ${s.stars.padStart(5)} ${s.about}`);console.log("\n`ttheme market add <name>` adds one")}function Lv({name:t}){return`ttheme-${t}`}function pL(t,e){eL(Eu(t),{recursive:!0}),C(Ya(t,Bt),tk(e)),C(Ya(t,"README.md"),`# ${be(e)}
|
|
628
630
|
|
|
629
631
|
A [ttheme](https://github.com/kecan0406/ttheme) market:
|
|
630
632
|
|
|
631
633
|
\`\`\`sh
|
|
632
|
-
ttheme market add ${e.owner}/${
|
|
634
|
+
ttheme market add ${e.owner}/${Lv(e)}
|
|
633
635
|
ttheme
|
|
634
636
|
\`\`\`
|
|
635
|
-
`)}function
|
|
637
|
+
`)}function Cv(t){return Te(`x@${t}/x`)?"takes lowercase letters, digits and single hyphens":void 0}async function jv(){if(!wp())throw Error("name the market: ttheme market init <name>, or --in <name> on new");let t=await Zh({message:"Your market's name — its palettes are <you>@<name>/<palette>",validate:(e)=>Cv((e??"").toLowerCase())});if(te(t))throw Error("no market name given");return t.toLowerCase()}async function _v(t,e){let n=Wi(t);if(e){let s=n.find((a)=>a.name===e||a.id===e||a.dir===Fv(e));if(!s)throw Error(`${e} is not one of your local markets — \`ttheme market init ${e}\` makes it one`);return s}let[r,...i]=n;if(r&&i.length===0)return r;if(r)throw Error(`you have ${n.length} local markets — --in names one: ${n.map((s)=>s.name).join(", ")}`);let o=await jv();return Gv(t,gh(t,o),o)}async function Gv(t,e,n){let r=!El(Ya(e,Bt)),i;if(r){let s=Cv(n);if(s)throw Error(`the market name ${n} ${s}`);if(El(e)&&nL(e).length>0)throw Error(`${e} is not empty — pick a new folder for the market`);i={owner:await sL(t,z(t)),name:n},pL(e,i)}else i=cn(e);let o=be(i);return bp(t,e,o),console.log(`${r?"Made":"Added"} your market ${o} · ${rt(e)}`),{dir:e,...i,id:o}}function Iv(t){return t.startsWith(".")||t.startsWith("/")||t.startsWith("~")}async function gL(t){let e=J(),n=t&&!Iv(t)?t.toLowerCase():t?Rv(Kr(t)).toLowerCase():await jv(),r=t&&Iv(t)?Kr(t):gh(e,n),i=await Gv(e,r,n),o=`${i.owner}/${Lv(i)}`;console.log(`
|
|
636
638
|
\`ttheme new <palette> --from <palette>\` puts palettes in it, and a folder under palettes/ shelves them in a catalog — others see them once it is on GitHub:
|
|
637
639
|
|
|
638
|
-
cd ${
|
|
640
|
+
cd ${rt(r)}
|
|
639
641
|
git init -b main && git add -A && git commit -m "${i.id}"
|
|
640
642
|
gh repo create ${o} --public --source . --push
|
|
641
|
-
gh repo edit ${o} --add-topic ${
|
|
643
|
+
gh repo edit ${o} --add-topic ${ts}
|
|
642
644
|
|
|
643
|
-
Every push is the market: \`ttheme market add ${o}\` works anywhere`)}function
|
|
645
|
+
Every push is the market: \`ttheme market add ${o}\` works anywhere`)}function bL(t){let e=t?Kr(t):process.cwd(),n=Ya(e,Bt);if(!El(n))throw Error(`${rt(e)} has no ${Bt} — \`ttheme market init ${rt(e)}\` makes one`);let r=[],i=[],o=Ml(n,"utf8"),s;try{s=cn(e)}catch(h){return console.error(` ✗ ${h.message}`),1}let a=Hi(o),c=a.owner;for(let h of Object.keys(a).filter((m)=>!V$.includes(m)))i.push(`${Bt}: unknown key ${h} — ttheme ignores it`);for(let h of Object.keys(c).filter((m)=>!Z$.includes(m)))i.push(`${Bt}: unknown key owner.${h} — ttheme ignores it`);if(!s.description)i.push(`${Bt}: no description — Browse and the market page show one`);let u=be(s),f=xn(e,u,aL(J()),(h,m)=>r.push(`${Ov(e,h)}: ${m.replace(`${Rv(h)}: `,"")}`));for(let h of rs(e)){let m;try{m=n$(h.path,Ml(h.path,"utf8"))}catch{m=[]}for(let p of m)i.push(`${Ov(e,h.path)}: unknown key ${p} — ttheme ignores it`)}let l=pv(s.renames,new Set(f.map((h)=>pe(h.name))));r.push(...l.errors.map((h)=>`${Bt}: ${h}`)),i.push(...l.warnings.map((h)=>`${Bt}: ${h}`));for(let h of f){let m=Sa(h).filter((b)=>b.startsWith(" ✗")),p=h.catalog?`${h.catalog}/${pe(h.name)}`:pe(h.name);console.log(` ${p}${m.length>0?`
|
|
644
646
|
${m.join(`
|
|
645
647
|
`)}`:" passes the gate"}`)}for(let h of r)console.error(` ✗ ${h}`);for(let h of i)console.log(` ! ${h}`);let d=(h,m)=>`${h} ${m}${h===1?"":"s"}`;return console.log(`
|
|
646
|
-
${u} · ${zt(f.length)} · ${d(r.length,"error")} · ${d(i.length,"warning")}`),r.length>0?1:0}async function Nv(t,e){switch(t){case void 0:oL();return;case"add":await nL(kv(t,e));return;case"remove":rL(kv(t,e));return;case"search":await sL(e);return;case"init":await cL(e);return;case"check":return uL(e);default:throw Error(`unknown market action ${t} — ${ZF.join(", ")}, or none to list them`)}}function kv(t,e){if(!e)throw Error(t==="add"?"market add takes a repository or a folder: ttheme market add alice/ttheme-dust":"market remove takes a market name — `ttheme market` lists them");return e}function Tv(t,e){let n=ui(t,e);return`${n} — ${zt(On(e,n,qa(t),fe(!1)).length)}, read in place`}function Hv(t){return[...t].length===1&&t>=" "&&t!==""}function lL(t){return[...t.replace(/[\r\n\t]+/g," ")].filter(Hv).join("")}function oo(t,e,n=()=>!0){if(e==="backspace")return[...Xf.segment(t)].slice(0,-1).map((r)=>r.segment).join("");if(e==="ctrl-u")return"";if(e==="ctrl-w"||e==="alt-backspace")return t.replace(/\S*\s*$/,"");return Hv(e)&&n(e)?t+e:void 0}class Ja{value;constructor(t=""){this.value=t}key(t){let e=oo(this.value,t);if(e===void 0)return!1;return this.value=e,!0}paste(t){this.value+=lL(t)}}import{performance as fL}from"node:perf_hooks";import{StringDecoder as dL}from"node:string_decoder";var hL=30,Fv=50,mL=500,pL=5,Lv=Buffer.from("\x1B[M"),yl="\x1B]1337;ReportCellSize\x07\x1B[16t\x1B[14t\x1B[18t",Kv="\x1B[?1016$p\x1B[16t",zv={A:"up",B:"down",C:"right",D:"left",H:"home",F:"end","1~":"home","7~":"home","3~":"delete","4~":"end","8~":"end","5~":"pgup","6~":"pgdn",I:"focus-in",O:"focus-out",Z:"shift-tab","1;2C":"shift-right","1;2D":"shift-left"},gL={"\r":"enter","\n":"enter","\t":"tab","\b":"backspace","":"backspace","\x1B":"esc","\x00":"ctrl-space"},Cv=/\[([0-?]*)([ -/]*)([@-~])/y,bL=/^\[[0-?]*[ -/]*$/,jv=/\[(<-?\d+;-?\d+;-?\d+)([Mm])/y,wL=/^\[<[-\d;]*$/,_v=/\](\d+)/y,$L=/^\]\d*$/,Gv=/\]\d+;/y,kL=/^1337;ReportCellSize=([\d.]+);([\d.]+)(?:;([\d.]+))?$/,yL=/^(1[0-2]|17|4;\d{1,3});(rgba?:[0-9a-fA-F/]+)$/,qv="\x1B[200~",kl="\x1B[201~";function vL(t){let e=gL[t];if(e)return e;let n=t.codePointAt(0)??0;if(n<27)return`ctrl-${String.fromCharCode(n+96)}`;return n<32?void 0:t}function As(t){return{kind:"key",key:t}}function Ns(t){return{events:[As("esc")],end:t+1}}function EL(t){let e={};for(let n of t.split(":")){let r=n.indexOf("=");if(r>0)e[n.slice(0,r)]=n.slice(r+1)}return e}var SL=["left","middle","right",void 0];function kp(t,e,n,r){if(!Number.isInteger(t)||t<0||t>=128||!(e>=0)||!(n>=0))return;let i=t&3,o={kind:"mouse",row:n,col:e,shift:(t&4)!==0,alt:(t&8)!==0,ctrl:(t&16)!==0};if(t&64)return{...o,action:"wheel",button:void 0,wheel:i%2===0?-1:1,sideways:i>=2,count:0};let s=SL[i],a=t&32?s?"drag":"move":r||!s?"release":"press";return{...o,action:a,button:s,wheel:0,sideways:!1,count:a==="press"?1:0}}function ML(t,e,n){let r=[],i=e;while(r.length<3&&i<t.length){let u=t.codePointAt(i);r.push(u),i+=u>65535?2:1}if(r.length<3)return n?{events:[],end:t.length}:void 0;let[o=0,s=0,a=0]=r,c=Math.max(o,s,a)<128?kp(o-32,s-33,a-33,!1):void 0;return{events:c?[c]:[],end:i}}function xL(t,e,n,r,i){let o=Math.max(0,e)/i.w,s=Math.max(0,n)/i.h,a=Math.floor(o),c=Math.floor(s),u=kp(t,a,c,r);return u&&{...u,fx:o-a,fy:s-c}}function Bv(t,e,n,r){if((n==="M"||n==="m")&&e===""&&t.startsWith("<")){let[o=-1,s=0,a=0]=t.slice(1).split(";").map(Number),c=r?xL(o,s,a,n==="m",r):kp(o,s-1,a-1,n==="m");return c?[c]:[]}if(n==="t"&&e===""){let[o,s=0,a=0]=t.split(";").map(Number),c=o===6?"cell":o===4?"window":o===8?"grid":void 0;return c?[{kind:"size",of:c,h:s,w:a}]:[]}if(n==="y"&&e==="$"&&t.startsWith("?")){let[o=0,s=0]=t.slice(1).split(";").map(Number);return[{kind:"mode",mode:o,value:s}]}if(n==="c"&&t.startsWith("?"))return[{kind:"attributes"}];let i=e===""?zv[`${t}${n}`]:void 0;return i?[As(i)]:[]}function OL(t,e,n,r){jv.lastIndex=e+1;let i=jv.exec(t);if(i)return{events:Bv(i[1],"",i[2],r),end:e+1+i[0].length};Cv.lastIndex=e+1;let o=Cv.exec(t);if(!o){let l=t.slice(e+1);return!n&&(bL.test(l)||wL.test(l))?void 0:Ns(e)}let[s,a="",c="",u=""]=o,f=e+1+s.length;if(a===""&&c===""&&u==="M")return ML(t,f,n);if(a==="200"&&u==="~"){let l=t.indexOf(kl,f);if(l===-1)return n?{events:[{kind:"paste",text:t.slice(f)}],end:t.length}:void 0;return{events:[{kind:"paste",text:t.slice(f,l)}],end:l+kl.length}}return{events:Bv(a,c,u,r),end:f}}function IL(t){let e=kL.exec(t);if(e){let s=Number(e[3]??1);return[{kind:"size",of:"cell",h:Math.round(Number(e[1])*s),w:Math.round(Number(e[2])*s)}]}let n=yL.exec(t);if(n)return[{kind:"color",code:n[1],value:n[2]}];let[r="",i="",...o]=t.split(";");return[{kind:"osc",code:r,meta:EL(i),payload:o.join(";")}]}function RL(t,e,n){_v.lastIndex=e+1;let r=_v.exec(t),i=r?t[e+1+r[0].length]:void 0;if(i!==";"&&i!=="\x07"&&i!=="\x1B")return!n&&$L.test(t.slice(e+1))?void 0:Ns(e);let o=[t.indexOf("\x07",e),t.indexOf("\x1B\\",e+2)].filter((a)=>a!==-1);if(o.length===0)return n?{events:[],end:t.length}:void 0;let s=Math.min(...o);return{events:IL(t.slice(e+2,s)),end:s+(t[s]==="\x07"?1:2)}}function PL(t,e,n){let r=t[e+2];if(r===void 0)return n?Ns(e):void 0;if(!/^[A-Za-z]$/.test(r))return Ns(e);let i=zv[r];return{events:i?[As(i)]:[],end:e+3}}function AL(t,e,n,r){let i=t[e+1];if(i===void 0)return n?Ns(e):void 0;if(i==="[")return OL(t,e,n,r);if(i==="]")return RL(t,e,n);if(i==="O")return PL(t,e,n);if(i==="")return{events:[As("alt-backspace")],end:e+2};if(/^[a-z]$/.test(i))return{events:[As(`alt-${i}`)],end:e+2};return Ns(e)}function Uv(t,e=!1,n){let r=[],i=0;while(i<t.length){if(t[i]==="\x1B"){let a=AL(t,i,e,n);if(!a)return{events:r,rest:t.slice(i)};r.push(...a.events),i=a.end;continue}let o=String.fromCodePoint(t.codePointAt(i)),s=vL(o);if(s)r.push(As(s));i+=o.length}return{events:r,rest:""}}function NL(t){let e=t.indexOf(Lv);if(e===-1)return{bytes:t,carry:void 0};let n=[],r=0;while(e!==-1&&e+6<=t.length){n.push(t.subarray(r,e));let[i=0,o=0,s=0]=t.subarray(e+3,e+6);if(o>32&&s>32)n.push(Buffer.from(`\x1B[<${i-32};${o-32};${s-32}M`));r=e+6,e=t.indexOf(Lv,r)}return n.push(t.subarray(r,e===-1?t.length:e)),{bytes:Buffer.concat(n),carry:e===-1?void 0:t.subarray(e)}}function Wv(t){return Gv.lastIndex=1,t.startsWith(qv)||t.startsWith("\x1B]")&&Gv.test(t)}function TL(t,e){let n=t.slice(-kl.length)+e;return t.startsWith(qv)?n.includes(kl):n.includes("\x07")||n.includes("\x1B\\")}class yp{held="";timer;carry;pressed;wheeled;utf8=new dL("utf8");burst;cell;take;constructor(t,e=()=>!1,n=()=>{return}){this.burst=e,this.cell=n,this.take=(r)=>{let i=this.counted(r);if(i.length>0)t(i)}}counted(t){let e=fL.now();return t.filter((n)=>{if(n.kind!=="mouse")return!0;if(n.action==="wheel"){let o=n.wheel*(n.sideways?2:1),s=this.wheeled;if(s!==void 0&&s.way===o&&e-s.at<pL)return!1;return this.wheeled={at:e,way:o},!0}if(n.action==="release")n.count=this.pressed?.count??0;if(n.action!=="press"||!n.button)return!0;let r=this.pressed,i=r!==void 0&&r.button===n.button&&r.row===n.row&&Math.abs(r.col-n.col)<=1&&e-r.at<=mL;return n.count=i?r.count+1:1,this.pressed={at:e,button:n.button,row:n.row,col:n.col,count:n.count},!0})}feed(t){clearTimeout(this.timer);let e=typeof t==="string"?t:this.bytes(t);if(this.carry)this.wait(Fv);if(!this.held&&!e.includes("\x1B")&&this.burst(e)){this.take([{kind:"paste",text:e}]);return}if(Wv(this.held)&&!TL(this.held,e)){this.held+=e;return}let{events:n,rest:r}=Uv(this.held+e,!1,this.cell());if(this.held=r,r&&!Wv(r))this.wait(r.length===1?hL:Fv);if(n.length>0)this.take(n)}bytes(t){let{bytes:e,carry:n}=NL(this.carry?Buffer.concat([this.carry,t]):t);return this.carry=n,this.utf8.write(e)}wait(t){clearTimeout(this.timer),this.timer=setTimeout(()=>this.flush(),t)}flush(){clearTimeout(this.timer),this.carry=void 0;let{events:t}=Uv(this.held,!0,this.cell());if(this.held="",t.length>0)this.take(t)}stop(){clearTimeout(this.timer),this.held="",this.carry=void 0}}class Ya{window;grid;see(t){if(t.kind!=="size")return;if(t.of==="cell")return{w:t.w,h:t.h};if(t.of==="window")this.window=t;else this.grid=t;let e=this.window,n=this.grid;return e&&n&&n.h>0&&n.w>0?{h:Math.floor(e.h/n.h),w:Math.floor(e.w/n.w)}:void 0}}class vp{known=!1;cell;see(t){if(t.kind==="mode"&&t.mode===1016)this.known=t.value===1||t.value===2;else if(t.kind==="size"&&t.of==="cell"&&t.w>0&&t.h>0)this.cell={w:t.w,h:t.h};else if(t.kind==="attributes")return{cell:this.known?this.cell:void 0};return}}var El={on:"\x1B[?1049h",off:"\x1B[?1049l"},Tn={on:"\x1B[?25l",off:"\x1B[?25h"},li={on:"\x1B[?7l",off:"\x1B[?7h"},dr={on:"\x1B[?2004h",off:"\x1B[?2004l"},Xv={on:"\x1B[?1004h",off:"\x1B[?1004l"},HL={on:"\x1B[?1000h\x1B[?1002h\x1B[?1006h",off:"\x1B[?1006l\x1B[?1002l\x1B[?1000l"},Dv={on:"\x1B[?1016h",off:"\x1B[?1016l\x1B[?1006h"};function fi(t=process.env){return t.TTHEME_MOUSE==="off"?[]:[HL]}var Qv={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGTERM:15},FL=3000;class Va extends Error{exit;constructor(t){super(t);this.exit=128+Qv[t]}}var Nn=[],so=new Map,Za=new Map,Jv;function Yv(t){return Nn.findLast((e)=>e.input===t)}var Zv;function tE(t){for(let e of[...Nn].reverse())e.abort(t);if(!Zv)Zv=setTimeout(()=>{eE(),process.exit(t instanceof Va?t.exit:1)},FL).unref()}var LL=Object.fromEntries(Object.keys(Qv).map((t)=>[t,()=>tE(new Va(t))]));function eE(){for(let t of[...Nn].reverse())t.close()}function CL(){for(let t of Nn)t.reassert();Nn.at(-1)?.redraw()}function Vv(t){let e=t?"on":"off";for(let[n,r]of Object.entries(LL))process[e](n,r);if(process[e]("uncaughtException",tE),process[e]("exit",eE),process.platform!=="win32")process[e]("SIGCONT",CL)}function vl(){}class nE{input;output;failed;modes=[];assumed;owned=[];keys;tty;take;resized;queued=[];asking;reject=vl;open=!0;aborted=!1;constructor(t={}){if(this.input=t.input??process.stdin,this.output=t.output??process.stdout,this.tty=this.output.isTTY===!0&&this.input.isTTY===!0,this.assumed=t.assume??[],this.keys=new yp((r)=>this.deliver(r),t.burst,()=>so.has(Dv)?Jv:void 0),this.failed=new Promise((r,i)=>{this.reject=i}),this.failed.catch(vl),this.tty&&!Nn.some((r)=>r.tty))Vv(!0);Nn.push(this);let e="";for(let r of this.assumed)if(!so.has(r))e+=r.on;for(let r of t.modes??[])e+=this.claim(r);this.write(e);let n=Za.get(this.input)??0;if(n===0)this.input.setRawMode?.(!0);Za.set(this.input,n+1),this.input.on("data",this.received),this.input.resume(),this.output.on("resize",this.resizing),this.output.on("error",vl)}hold(t){this.write(this.claim(t))}pixels(t){Jv=t,this.hold(Dv)}get cols(){return this.output.columns||80}get rows(){return this.output.rows||24}write(t){if(t&&this.open)this.output.write(t)}listen(t){this.take=t;let e=this.queued;if(this.queued=[],e.length>0)t(e)}onResize(t){this.resized=t}until(t){return Promise.race([t,this.failed])}loop(t,e=()=>{}){return this.until(new Promise((n)=>{let r=!1;this.listen((i)=>{for(let o of i){let s=r?void 0:t(o);if(s!==void 0)r=!0,n(s)}if(!r)e()})}))}ask(t,e,n,r=!0){return new Promise((i)=>{let o={hold:r,pick:(c)=>{let u=e(c);if(u===void 0)return!1;return s(u),!0}},s=(c)=>{if(clearTimeout(a),this.asking===o)this.asking=void 0;i(c),this.release()},a=setTimeout(()=>s(void 0),n);this.asking=o,this.write(t)})}abort(t){if(this.aborted)return;this.aborted=!0,this.keys.stop(),this.reject(t)}redraw(){this.resized?.()}reassert(){if(this.open)this.input.setRawMode?.(!0),this.write([...this.assumed,...this.owned].map((t)=>t.on).join(""))}close(){if(!this.open)return;this.keys.stop(),this.input.off("data",this.received),this.output.off("resize",this.resizing);let t="";for(let n of[...this.modes].reverse()){let r=(so.get(n)??1)-1;if(r===0)so.delete(n),t+=n.off;else so.set(n,r)}this.write(t),this.open=!1;let e=(Za.get(this.input)??1)-1;if(e===0)Za.delete(this.input),this.input.setRawMode?.(!1),this.input.pause();else Za.set(this.input,e);if(this.output.off("error",vl),Nn.splice(Nn.indexOf(this),1),this.tty&&!Nn.some((n)=>n.tty))Vv(!1)}received=(t)=>{if(Yv(this.input)===this&&!this.aborted)this.keys.feed(t)};resizing=()=>{if(Yv(this.input)===this)this.resized?.()};claim(t){this.modes.push(t);let e=so.get(t)??0;if(so.set(t,e+1),e>0)return"";return this.owned.push(t),t.on}deliver(t){let e=this.asking,n=e?t.filter((r)=>!e.pick(r)):t;if(n.length===0)return;if(!this.take||this.asking?.hold){this.queued.push(...n);return}this.take(n)}release(){if(this.take&&this.queued.length>0){let t=this.queued;this.queued=[],this.take(t)}}}async function di(t,e){let n=new nE(t);try{return await e(n)}finally{n.close()}}var jL=3,iE={series:{top:(t)=>t.group,shelf:(t)=>Qa(t.group)?t.catalog:void 0},markets:{top:(t)=>Qa(t.group)?t.group:Z,shelf:(t)=>Qa(t.group)?t.catalog:t.group}};function tc(t,e){return`${t}/${e}`}function rE(t){return ut(t.name)?pe(t.name):t.name}function Ep(t,e){let n=e.shelf(t);return n===void 0?void 0:tc(e.top(t),n)}function Sl(t){if(t?.kind==="palette")return`palette ${t.entry.name}`;if(t?.kind==="group")return`group ${t.name}`;if(t?.kind==="catalog")return`catalog ${tc(t.group,t.name)}`;if(t?.kind==="extra")return`extra ${t.extra.key}`;return t?.kind??""}function Xa(t){return t?.kind==="rule"||t?.kind==="extra"&&t.extra.rule===!0}function Ml(t,e){return _i([t.name,t.group,t.native??"",t.catalog??"",...t.nativeNames??[],...mu(t.booru)],e)}function oE(t,e,n,r="series",i=[]){let o=iE[r],s=n.trim(),a=[],c=new Set,u=(f)=>({kind:"palette",entry:f});for(let f of t){let l=o.top(f);if(f.default||c.has(l))continue;c.add(l);let d=t.filter((b)=>!b.default&&o.top(b)===l),h=s?d.filter((b)=>Ml(b,s)):d;if(s&&h.length===0)continue;let m=s.length>0||e.has(l);if(a.push({kind:"group",name:l,...l===f.group&&f.native?{native:f.native}:{},lead:d.find((b)=>b.lead)??f,expanded:m,count:h.length}),!m)continue;let p=h.filter((b)=>o.shelf(b)!==void 0);for(let b of new Set(p.map(($)=>o.shelf($)))){let $=p.filter((E)=>o.shelf(E)===b),k=$.find((E)=>E.lead)??$[0],v=s.length>0||e.has(tc(l,b));if(a.push({kind:"catalog",group:l,name:b,...!Qa(k.group)&&k.native?{native:k.native}:{},lead:k,expanded:v,count:$.length}),v)a.push(...$.map(u))}a.push(...h.filter((b)=>o.shelf(b)===void 0).map(u))}for(let f of i)if(!c.has(f)&&(s===""||_i([f],s)))a.push({kind:"group",name:f,expanded:e.has(f),count:0});return a}function _L(t,e){let n=e.trim(),r=new Set(t.filter((i)=>!i.default&&(n===""||Ml(i,n))).map((i)=>i.group));return oE(t,new Set,"").filter((i)=>i.kind==="group"&&r.has(i.name))}function Qa(t){return t.includes("@")}function GL(t,e,n,r,i=!0){let o=n-1;if(o<0)return t;let s;if(!Number.isFinite(e))s=e>0?o:0;else if(e>0)s=t>=o?i?0:o:Math.min(o,t+e);else s=t<=0?i?o:0:Math.max(0,t+e);if(!r(s))return s;let a=Math.sign(e),c=s+a;if(c>=0&&c<=o)return c;return i&&Math.abs(e)===1?c<0?o:0:s-a}function xl(t,e){let n={home:Number.NEGATIVE_INFINITY,end:Number.POSITIVE_INFINITY,pgup:-e,pgdn:e};return t===void 0?void 0:n[t]}function BL(t){let e=t.findIndex((n)=>n.kind==="group"&&Qa(n.name));return e>0&&t.slice(0,e).some((n)=>n.kind==="group")?[...t.slice(0,e),{kind:"rule"},...t.slice(e)]:t}function UL(t){let e=t.findIndex((n)=>n.kind==="palette");return e===-1?0:e}function Ol(t){return t==="decode"||t==="glitch"?t:"typewriter"}function Ts(t,e,n){return ze({kind:"row",at:t,part:e},n)}class Il{picked;scope;maxItems;named=[];series=[];layout;place;color;p;onFocus;note;badge;tops;extras;entries=[];seriesPad=0;namePad=0;expanded=new Set;rows=[];cursor=0;top=0;filter="";lastFocused="";constructor(t){this.picked=t.picked,this.scope=t.scope??"palette",this.layout=t.layout??"series",this.place=iE[this.layout],this.maxItems=t.maxItems??12,this.color=t.color??!0,this.p=Me(this.color),this.onFocus=t.onFocus,this.note=t.note,this.badge=t.badge,this.tops=t.tops,this.extras=t.extras,this.load(t.entries),this.rebuild("first")}load(t){this.entries=t,this.named=t.filter((e)=>!e.default),this.series=[...new Set(this.named.map((e)=>e.group))],this.seriesPad=Math.max(0,...this.series.map((e)=>e.length)),this.namePad=Math.max(0,...this.named.map((e)=>this.indent(e).length+rE(e).length))}indent(t){return this.place.shelf(t)===void 0?" ":" "}setEntries(t){this.load(t),this.rebuild("stay")}setFilter(t){if(t!==this.filter)this.filter=t,this.rebuild("keep")}clear(){let t=this.rows[this.cursor];if(t?.kind==="palette"&&!t.entry.default){this.expanded.add(this.place.top(t.entry));let e=Ep(t.entry,this.place);if(e!==void 0)this.expanded.add(e)}this.setFilter("")}focusedRow(){return this.rows[this.cursor]}refocus(){this.lastFocused="",this.sync()}refresh(){this.rebuild("stay")}select(t){let e=this.rows.findIndex((n)=>Sl(n)===t);if(e===-1)return!1;return this.cursor=e,this.sync(),!0}members(t,e){let n=this.scope==="palette"?this.filter.trim():"";return this.under(t,e).filter((r)=>n===""||Ml(r,n))}under(t,e){return this.named.filter((n)=>this.place.top(n)===t&&(e===void 0||this.place.shelf(n)===e))}inside(t){return t.kind==="palette"?[t.entry]:t.kind==="group"?this.under(t.name):t.kind==="catalog"?this.under(t.group,t.name):[]}everyone(t){return t.flatMap((e)=>e.kind==="group"?this.members(e.name):[])}pick(){let t=this.rows[this.cursor],e=t?.kind==="palette"?[t.entry.name]:t?.kind==="group"?this.members(t.name).map((r)=>r.name):t?.kind==="catalog"?this.members(t.group,t.name).map((r)=>r.name):t?.kind==="all"?this.everyone(this.rows).map((r)=>r.name):[];if(e.length===0)return;let n=e.some((r)=>!this.picked.has(r));for(let r of e)if(n)this.picked.add(r);else this.picked.delete(r)}pickedIn(t,e){return this.members(t,e).filter((n)=>this.picked.has(n.name)).length}pickedCount(){if(this.scope==="palette")return this.named.filter((t)=>this.picked.has(t.name)).length;return this.series.filter((t)=>this.members(t).every((e)=>this.picked.has(e.name))).length}total(){return this.scope==="series"?this.series.length:this.named.length}matched(){let t=this.filter.trim();if(this.scope==="series")return this.rows.filter((e)=>e.kind==="group").length;return t?this.named.filter((e)=>Ml(e,t)).length:this.named.length}sync(){let t=this.rows[this.cursor],e=t?.kind==="palette"?t.entry:t?.kind==="group"&&this.scope==="series"?t.lead:void 0;if(e&&e.name!==this.lastFocused)this.lastFocused=e.name,this.onFocus?.(e)}rebuild(t){let e=this.rows[this.cursor],n=this.scope==="series"?_L(this.entries,this.filter):oE(this.entries,this.expanded,this.filter,this.layout,this.tops?.()??[]),r=this.layout==="markets"||n.length===0?n:BL([{kind:"all",count:this.allCount(n)},...n]);this.rows=[...r,...(this.extras?.()??[]).map((o)=>({kind:"extra",extra:o}))];let i=n.length>0?this.rows.indexOf(n[UL(n)]):0;if(t==="first")this.cursor=i;else if(t==="keep"||t==="stay"){let o=Sl(e),s=e?.kind==="palette"||t==="stay"?this.rows.findIndex((c)=>Sl(c)===o):-1,a=e?.kind==="extra"&&t==="stay";this.cursor=s!==-1?s:a?Math.min(this.cursor,this.rows.length-1):i}else if(this.cursor>=this.rows.length)this.cursor=Math.max(0,this.rows.length-1);this.settle(),this.sync()}settle(){if(!Xa(this.rows[this.cursor]))return;let t=this.rows.findIndex((n,r)=>r>this.cursor&&!Xa(n)),e=this.rows.findLastIndex((n,r)=>r<this.cursor&&!Xa(n));this.cursor=t!==-1?t:e!==-1?e:this.cursor}allCount(t){return this.scope==="series"?t.length:this.everyone(t).length}move(t,e=!0){this.cursor=GL(this.cursor,t,this.rows.length,(n)=>Xa(this.rows[n]),e),this.sync()}point(t){let e=this.rows[t];if(!e||Xa(e))return!1;return this.cursor=t,this.sync(),!0}flip(){let t=this.rows[this.cursor];if(t?.kind==="group"||t?.kind==="catalog")this.fold(!t.expanded)}foldable(){let t=this.rows[this.cursor];return(t?.kind==="group"||t?.kind==="catalog")&&this.scope==="palette"&&!this.filter}open(){if(this.foldable())this.flip();else this.pick()}toggle(t){if(this.expanded.has(t))this.expanded.delete(t);else this.expanded.add(t);this.rebuild("clamp")}climb(t,e){this.expanded.delete(t),this.rebuild("clamp"),this.reach(e)}reach(t){this.cursor=Math.max(0,this.rows.findIndex((e)=>Sl(e)===t)),this.sync()}fold(t){if(this.filter||this.scope==="series")return;let e=this.rows[this.cursor];if(e?.kind==="group"){if(t!==e.expanded)this.toggle(e.name)}else if(e?.kind==="catalog"){if(t!==e.expanded)this.toggle(tc(e.group,e.name));else if(!t)this.reach(`group ${e.group}`)}else if(e?.kind==="palette"&&!t&&!e.entry.default){let n=Ep(e.entry,this.place);if(n===void 0){let r=this.place.top(e.entry);this.climb(r,`group ${r}`)}else this.climb(n,`catalog ${n}`)}}window(){if(this.cursor<this.top)this.top=this.cursor;if(this.cursor>=this.top+this.maxItems)this.top=this.cursor-this.maxItems+1;this.top=Math.min(this.top,Math.max(0,this.rows.length-this.maxItems));let t=this.rows.slice(this.top,this.top+this.maxItems);return{lines:t.map((e,n)=>this.renderRow(e,this.top+n)),above:this.top,below:this.rows.length-this.top-t.length}}renderRow(t,e){if(t.kind==="rule")return` ${this.p.dim("── Markets ──────────")}`;if(t.kind==="extra"){let n=t.extra.text(e===this.cursor,e);return t.extra.rule?n:Ts(e,"row",n)}return Ts(e,"row",this.rowText(t,e))}rowText(t,e){let n=e===this.cursor,r=t.kind==="palette"?t.entry:t.kind==="all"?void 0:t.lead,i=this.color&&n&&r!==void 0,{dim:o,bold:s}=this.p,a=(v)=>this.color?` ${Lb(lu(v),i?Kn(v.foreground):bt)}`:"",c=n?i?`${Kn(r.cursor)}${A.gutter}${bt} `:`${A.gutter} `:" ",u=(v)=>i?`${c}${Fb(r.selection,r.foreground)} ${v} ${se}`:`${c} ${v}`,f=(v)=>Ts(e,"box",`${v?A.on:A.off} `),l=(v)=>Ts(e,"fold",`${v?A.opened:A.closed} `);if(t.kind==="all")return u(`${f(this.everyone(this.rows).every((v)=>this.picked.has(v.name)))}Select all ${o(`(${t.count})`)}`);if(t.kind==="group"&&this.scope==="series"){let v=`(${t.count})${t.native?` ${t.native}`:""}`;return u(`${f(this.pickedIn(t.name)===t.count)}${s(t.name.padEnd(this.seriesPad))}${t.lead?a(t.lead):""}${this.color?" ":" "}${o(v)}`)}let d=this.rows[this.cursor],h=(v,E)=>this.color&&d?.kind==="palette"&&v?this.p.accent(s(E)):s(E);if(t.kind==="group"){let v=h(d?.kind==="palette"&&this.place.top(d.entry)===t.name,t.name),E=t.native?` ${o(t.native)}`:"",x=this.badge?.(t.name)??"";return u(`${l(t.expanded)}${v} ${o(`(${this.pickedIn(t.name)}/${t.count})`)}${E}${x}`)}if(t.kind==="catalog"){let v=d?.kind==="palette"&&Ep(d.entry,this.place)===tc(t.group,t.name),E=o(`(${this.pickedIn(t.group,t.name)}/${t.count})`),x=t.native?` ${o(t.native)}`:"";return u(` ${l(t.expanded)}${h(v,t.name)} ${E}${x}`)}let m=t.entry,p=this.indent(m),b=rE(m),$=this.color?b.padEnd(this.namePad-p.length):b,k=n?s($):$;return u(`${p}${f(this.picked.has(m.name))}${k}${a(m)}${this.note?.(m)??""}`)}}function Sp(t){let e=t.named[Math.floor(Math.random()*t.named.length)],n=t.series[Math.floor(Math.random()*t.series.length)];return e&&n?`${e.name} | ${n}`:""}class Rl{fx;make;redraw;roller;example="";step=0;seed=0;timer;constructor(t,e,n){this.fx=t,this.make=e,this.redraw=n,this.roll(),this.roller=setInterval(()=>{this.roll(),this.step=8,this.redraw()},3000),this.roller.unref?.()}stop(){clearInterval(this.roller),clearTimeout(this.timer)}roll(){let t=this.make();this.example=t.length>30?`${t.slice(0,29)}…`:t,this.seed=Math.floor(Math.random()*997)}text(){if(this.step===0)return this.example;if(!this.timer)this.timer=setTimeout(()=>{this.timer=void 0,this.step-=1,this.redraw()},60),this.timer.unref?.();let t=Math.floor(this.example.length*(8-this.step)/8);if(this.fx==="typewriter")return`${this.example.slice(0,t)}▏`;let e=this.fx==="decode"?"abcdefghijklmnopqrstuvwxyz":"▓▒░#*+=<>?/-_",n=this.fx==="decode"?(r)=>!/[a-z0-9]/i.test(r):(r)=>r===" ";return[...this.example].map((r,i)=>i+(i*7+this.seed)%3<t||n(r)?r:e[Math.floor(Math.random()*e.length)]??r).join("")}}var WL=5;class Mp{picked;list;scope;color;required;most;hint;field=new Ja;input;output;state="active";error="";redraw=()=>{};constructor(t){this.scope=t.scope??"palette",this.picked=new Set(t.installed??[]),this.color=t.color??!0,this.required=t.required??!1,this.most=t.maxItems??12,this.input=t.input,this.output=t.output,this.list=new Il({entries:t.entries,picked:this.picked,scope:this.scope,maxItems:this.most,color:this.color,...t.onFocus?{onFocus:t.onFocus}:{}}),this.hint=new Rl(t.fx??"typewriter",()=>Sp(this.list),()=>this.redraw())}prompt(){return di({input:this.input,output:this.output,modes:[Tn,dr]},async(t)=>{let e=new Jm((r)=>t.write(r),()=>t.cols),n=()=>{return this.list.maxItems=Math.max(jL,Math.min(this.most,t.rows-WL)),this.draw()};this.redraw=()=>e.draw(n()),t.onResize(()=>e.redraw(n())),this.redraw();try{let r=await t.loop((i)=>{return this.take(i),this.state==="submit"||this.state==="cancel"?this.state:void 0},()=>this.redraw());return this.redraw=()=>{},e.end(this.draw()),r}finally{this.hint.stop()}})}take(t){if(t.kind==="paste"){this.field.paste(t.text),this.list.setFilter(this.field.value);return}if(t.kind!=="key")return;let e=t.key;if(this.state==="error")this.state="active";let n=xl(e,this.list.maxItems);if(e==="esc"||e==="ctrl-c")this.state="cancel";else if(e==="enter")if(this.required&&this.picked.size===0)this.error=`Pick at least one ${this.scope}`,this.state="error";else this.state="submit";else if(e==="up"||e==="down")this.list.move(e==="up"?-1:1);else if(e==="left"||e==="right")this.list.fold(e==="right");else if(n!==void 0)this.list.move(n);else if(e===" ")this.list.pick();else if(this.field.key(e))this.list.setFilter(this.field.value)}draw(){let{dim:t,accent:e,warn:n}=Me(this.color),r=this.scope==="series"?"Series":"Catalog";if(this.state==="submit")return[`${t("◇")} ${r} ${t(`· ${this.list.pickedCount()} picked`)}`];if(this.state==="cancel")return[`${t(`◇ ${r} · cancelled`)}`];let i=this.field.value,o=`${e("◆")} ${r} ${t(`(${this.list.matched()}/${this.list.total()} · ${this.list.pickedCount()} picked)`)}`,s=this.hint.text(),a=`${e("│")} ${i?`${i}_`:t(`Search…${s?` e.g. ${s}`:""}`)}`,{lines:c,below:u}=this.list.window(),f=c.length>0?c.map((p)=>`${e("│")} ${p}`):[`${e("│")} ${t(`No ${this.scope==="series"?"series":"palettes"} match '${i}'`)}`];while(f.length<this.list.maxItems)f.push(e("│"));let l=u>0?`${e("│")} ${t(`↓ ${u} more`)}`:e("│"),d=this.scope==="series"?"":" · ←→ fold",h=this.scope==="series"?"continue":"install",m=this.state==="error"?`${e("└")} ${n(this.error)}`:`${e("└")} ${t(`↑↓ move${d} · space pick · type to filter · enter ${h} · esc cancel`)}`;return[o,a,...f,l,m]}}var xp=34,KL=72,zL=94,qL=22,sE=40,aE=10,Pl=3,cE=600,DL=500,JL=300,uE=12,lE={title:"",lines:[],brief:""};function Hs(t){let e=t.trim();if(e!==Z&&!e.includes("/")&&!e.startsWith("~"))return;try{return Kr(e)}catch{return}}function fE(t){return t.charAt(0).toUpperCase()+t.slice(1)}class Op{picked;field=new Ja;adds=new Map;removes=new Set;want=new Map;renew=new Set;updates;tuned;scope;busy=new Map;failed=new Map;peeked=new Map;peekFailed=new Map;staging=new Set;timers=new Map;refreshed=[];inflight=new Set;markets;kept;installed;startup;io;order;color;p;hub;owns;input;output;maxItems=12;paint;catalog;hint;screen;state="active";phase="browse";offset=0;started=!1;log=[];working="";stopped;beat=0;asking;leaving;goto;repos;searching=!1;searchError;searched;asked=0;help=!1;live;constructor(t){this.markets=t.markets,this.kept=t.kept,this.installed=new Set(t.installed),this.updates=new Set(t.updates??[]),this.tuned=new Set(t.tuned??[]),this.startup=t.startup,this.io=t.io,this.order=t.order??((e)=>e),this.color=t.color??!0,this.p=Me(this.color),this.hub=t.hub,this.owns=t.owns??!1,this.input=t.input,this.output=t.output,this.live=t.lookups??!0,this.paint=t.onFocus,this.picked=new Set(t.installed),this.catalog=new Il({entries:this.entries(),picked:this.picked,layout:"markets",color:this.color,maxItems:this.maxItems,note:(e)=>this.mark(e),badge:(e)=>this.badge(e),tops:()=>this.tops(),extras:()=>this.found(),onFocus:(e)=>this.focus(e)}),this.hint=new Rl(t.fx??"typewriter",()=>Sp(this.catalog),()=>this.redraw());for(let e of t.due)this.update(e);this.lookup()}run(){let t=[...this.owns?[El,Tn,li]:[],dr,...fi()],e=this.owns?[]:[Tn,li];return di({input:this.input,output:this.output,modes:t,assume:e},async(n)=>{let r=new no({write:(i)=>n.write(i),view:()=>this.state==="active"?{lines:this.view(),ticking:this.phase==="applying"}:void 0,beat:()=>{this.beat+=1}});this.screen=r,n.onResize(()=>{r.reset(),r.request()}),r.now();try{return await n.loop((i)=>{if(i.kind==="key")this.key(i.key);else if(i.kind==="paste")this.pasted(i.text);else if(i.kind==="mouse")this.mouse(i,r);return this.state==="active"?void 0:this.state},()=>r.soon())}finally{r.stop(),this.screen=void 0,this.hint.stop();for(let i of this.timers.values())clearTimeout(i);this.timers.clear()}})}applied(){return this.started}lines(){return this.log}failure(){return this.stopped}next(){return this.goto}async idle(){await Promise.allSettled([...this.inflight])}result(){let t=new Set(this.entries().map((e)=>e.name));return{picked:new Set([...this.picked].filter((e)=>t.has(e))),adds:[...this.adds.values()],removes:[...this.removes],auto:Object.fromEntries(this.want),renew:[...this.renew].filter((e)=>this.updates.has(e)&&this.picked.has(e)&&t.has(e)),refreshed:this.refreshed}}key(t){if(t==="ctrl-c"){this.state="cancel";return}if(this.help){if(t==="?"||t==="esc")this.help=!1;return}if(this.leaving!==void 0){if(t==="esc")this.leaving=void 0;else if(/^[yn]$/i.test(t)){if(t.toLowerCase()==="y")this.begin();else this.goto=this.leaving,this.state="cancel";this.leaving=void 0}return}if(this.asking){if(t==="esc")this.asking=void 0;else if(/^[yn]$/i.test(t))this.answer(t.toLowerCase()==="y");return}if(this.phase!=="browse"){this.steer(t);return}let e=xl(t,this.maxItems),n=this.catalog;if(t==="enter")if(n.foldable())n.flip();else if(this.dirty())this.phase="review",this.offset=0;else this.state="submit";else if((t==="esc"||t==="ctrl-u")&&this.field.value)this.clear();else if(t==="esc")this.state="cancel";else if(t==="?")this.help=!0;else if(e!==void 0)this.move(e);else if(t==="up"||t==="down")this.move(t==="up"?-1:1);else if(t==="left"||t==="right")n.fold(t==="right");else if(t==="tab"||t==="shift-tab"){if(this.hub)this.leave(Ak(this.hub,t==="tab"?1:-1))}else if(t==="shift-left"||t==="shift-right")this.autoUpdate(t==="shift-right");else if(t===" ")this.activate();else if(t==="delete"){let r=this.focusedMarket();if(r)this.toggleMarket(r)}else if(t==="ctrl-r")this.refresh();else if(t==="ctrl-s")this.cycle();else if(this.field.key(t))this.typed()}refresh(){let t=this.catalog.focusedRow(),e=this.focusedMarket();if(e){if(kt(e.source)&&!this.adds.has(e.source))this.update(e.source)}else if(t?.kind==="extra"){if(t.extra.found?.kind==="find")this.search()}else if(t?.kind!=="group")this.toggleRenew()}pasted(t){if(this.phase==="browse"&&!this.help&&!this.asking&&this.leaving===void 0)this.field.paste(t),this.typed()}mouse(t,e){if(this.help){if(t.action==="release")this.help=!1;return}let n=e.point(t),r=n?.target,i=this.phase==="browse"&&this.leaving===void 0&&!this.asking;if(t.action==="wheel"){if(!t.sideways&&(i||this.phase!=="browse"))this.wheel(t.wheel);return}if(!r)return;if(t.action==="press"&&t.button==="left"){if(!i)return;if(r.kind==="chip")this.scopeTo(r.source);else if(r.kind==="row")this.catalog.point(r.at),this.watch()}else if(t.action==="release"&&n?.inside){if(r.kind==="key")this.key(r.key);else if(r.kind==="page"){if(this.phase!=="browse")this.scroll(r.step*this.span());else if(i)this.move(r.step*this.maxItems)}else if(r.kind==="hub"){if(i&&this.hub&&r.tab!==this.hub)this.leave(Nk(r.tab))}else if(r.kind==="row"&&i)this.openRow(r,t.count)}}wheel(t){if(this.phase!=="browse"){this.scroll(t);return}this.move(t,!1)}openRow(t,e){let n=this.catalog;if(n.focusedRow()?.kind==="extra"){if(t.part==="box"||e===2)this.activate()}else if(t.part==="box")n.pick();else if(t.part==="fold")n.flip();else if(e===2)n.open()}typed(){this.catalog.setFilter(this.field.value),this.later("search",cE,()=>this.lookup()),this.watch()}clear(){this.field.value="",this.catalog.clear(),this.later("search",cE,()=>this.lookup()),this.watch()}redraw(){if(this.state==="active")this.screen?.request()}focus(t){if(this.state!=="submit"&&this.state!=="cancel")this.paint?.(t)}track(t){this.inflight.add(t);let e=()=>this.inflight.delete(t);return t.then(e,e),t}active(){return[...this.markets.filter((t)=>!this.removes.has(t.source)),...this.adds.values()]}entries(){let t=this.active().flatMap((i)=>i.entries),e=new Set(t.map((i)=>i.name)),n=new Map,r=this.markets.filter((i)=>this.removes.has(i.source)).flatMap((i)=>i.entries);for(let i of[...this.kept,...r])if(this.installed.has(i.name)&&!e.has(i.name))n.set(i.name,i);return this.order([...t,...n.values()])}scoped(t){let e=this.scope,n=e===void 0?void 0:this.active().find((i)=>i.source===e);if(!n)return this.scope=void 0,t;let r=new Set(n.entries.map((i)=>i.name));return t.filter((i)=>r.has(i.name))}reload(){this.catalog.setEntries(this.scoped(this.entries()))}chips(){let t=this.active().map((e)=>({source:e.source,label:e.id,count:e.entries.filter((n)=>!n.default).length}));return[{source:void 0,label:"All",count:this.entries().filter((e)=>!e.default).length},...t]}tops(){return[...this.markets,...this.adds.values()].filter((t)=>this.scope===void 0||t.source===this.scope).map((t)=>t.id)}marketNamed(t){return[...this.markets,...this.adds.values()].find((e)=>e.id===t)}focusedMarket(){let t=this.catalog.focusedRow();return t?.kind==="group"?this.marketNamed(t.name):void 0}cycle(){if(this.active().length<2)return;let t=this.chips(),e=Math.max(0,t.findIndex((n)=>n.source===this.scope));this.scopeTo(t[(e+1)%t.length]?.source)}scopeTo(t){this.scope=t,this.reload(),this.catalog.refocus()}move(t,e=!0){this.catalog.move(t,e),this.watch()}autoUpdate(t){let e=this.focusedMarket();if(e&&kt(e.source))if(t===e.auto)this.want.delete(e.source);else this.want.set(e.source,t)}activate(){let t=this.catalog.focusedRow();if(t?.kind!=="extra"){this.catalog.pick();return}let e=t.extra.found;if(e?.kind==="add")this.load(e.source,!0);else if(e?.kind==="repo"){let n=this.known(e.source);if(n)this.catalog.select(`group ${n.id}`);else this.load(e.source,!0)}else if(e?.kind==="find")this.search()}toggleMarket(t){if(this.adds.has(t.source))this.adds.delete(t.source),this.want.delete(t.source);else if(this.removes.has(t.source))this.removes.delete(t.source);else this.removes.add(t.source);this.reload()}known(t){return[...this.markets,...this.adds.values()].find((e)=>es(e.source,t))}load(t,e){let n=this.peeked.get(t);if(n){if(e)this.arrive(t,n);return}if(e)this.staging.add(t);if(this.busy.has(t))return;this.failed.delete(t),this.peekFailed.delete(t),this.busy.set(t,"Fetching…"),this.track(this.io.fetch(t)).then((r)=>{if(this.busy.delete(t),this.peeked.set(t,r),this.staging.delete(t))this.arrive(t,r);this.redraw()},(r)=>{if(this.busy.delete(t),this.staging.delete(t))this.failed.set(t,r.message);else this.peekFailed.set(t,r.message);this.redraw()})}arrive(t,e){let n=this.active().find((r)=>r.id===e.id);if(n)this.failed.set(t,`${e.id} already names the market at ${n.shown}`);else if(Ht(t)||t===Z)this.stage(e,e.auto);else this.asking=e;this.redraw()}later(t,e,n){this.cancel(t),this.timers.set(t,setTimeout(()=>{if(this.timers.delete(t),this.state!=="submit"&&this.state!=="cancel")n()},e))}cancel(t){clearTimeout(this.timers.get(t)),this.timers.delete(t)}wants(t){return!this.known(t)&&!this.peeked.has(t)&&!this.busy.has(t)&&!this.peekFailed.has(t)}focusedFound(){let t=this.catalog.focusedRow();return t?.kind==="extra"?t.extra.found:void 0}watch(){if(!this.live)return;let t=Hs(this.field.value);if(t&&this.wants(t))this.later("typed",DL,()=>this.load(t,!1));else this.cancel("typed");let e=this.focusedFound();if(e?.kind==="repo"&&this.wants(e.source)){let n=e.source;this.later("focus",JL,()=>{let r=this.focusedFound();if(r?.kind==="repo"&&r.source===n)this.load(n,!1)})}else this.cancel("focus")}answer(t){let e=this.asking;if(this.asking=void 0,e)this.stage(e,t)}stage(t,e){if(this.adds.set(t.source,t),e===t.auto)this.want.delete(t.source);else this.want.set(t.source,e);let n=Hs(this.field.value);if(n&&es(n,t.source))this.field.value="",this.catalog.setFilter("");this.reload(),this.catalog.select(`group ${t.id}`)}update(t){if(this.busy.has(t))return;this.failed.delete(t),this.busy.set(t,"Updating…"),this.track(this.io.refresh(t)).then(({market:e,refreshed:n,updates:r})=>{this.busy.delete(t),this.updates=new Set(r),this.markets=this.markets.map((i)=>i.source===t?e:i),this.refreshed.push(n),this.reload(),this.redraw()},(e)=>{this.busy.delete(t),this.failed.set(t,`Update failed: ${e.message}`),this.redraw()})}wanted(){let t=this.field.value.trim();return t&&!Hs(t)?t:""}lookup(){if(this.live&&this.searched!==this.wanted())this.search()}search(){let t=this.wanted(),e=++this.asked;this.searched=t,this.searching=!0,this.searchError=void 0,this.track(this.io.search(t||void 0)).then((n)=>{if(e===this.asked)this.searching=!1,this.repos=n,this.catalog.refresh(),this.watch(),this.redraw()},(n)=>{if(e===this.asked)this.searching=!1,this.searchError=n.message,this.redraw()})}found(){let t=Hs(this.field.value),e=(...i)=>_i(i,this.field.value),n=(this.repos??[]).map((i)=>({repo:i,source:wp(i)})).filter(({repo:i,source:o})=>e(o,i.description??"")),r=[...t&&!this.known(t)?[{kind:"add",source:t}]:[],...n.map(({repo:i,source:o})=>({kind:"repo",repo:i,source:o})),...n.length>0?[]:[{kind:"find"}]];return[{key:"github",rule:!0,text:()=>` ${this.p.dim(`── On GitHub${this.searching?" · searching…":""} ──────────`)}`},...r.map((i)=>({key:i.kind==="find"?"find":`${i.kind} ${i.source}`,found:i,text:(o,s)=>this.foundLine(i,o,s)}))]}lit(t,e){return`${t?`${A.gutter} `:" "} ${e}`}status(t){return this.adds.has(t.source)?"Will add":this.removes.has(t.source)?"Will remove":this.busy.get(t.source)??(this.failed.has(t.source)||t.status.startsWith("update failed")?"Update failed":"")}badge(t){let e=this.marketNamed(t);if(!e)return"";return[kt(e.source)&&(this.want.get(e.source)??e.auto)?`${A.auto} auto-update`:"",this.status(e)].filter(Boolean).map((r)=>` ${this.p.dim(r)}`).join("")}peeking(t){let e=this.peeked.get(t);return e?zt(e.entries.filter((n)=>!n.default).length):""}foundLine(t,e,n){let r=(a)=>Ts(n,"box",`${a} `),i=(a)=>a?` ${this.p.dim(a)}`:"";if(t.kind==="add"){let a=this.failed.get(t.source)??this.peekFailed.get(t.source),c=this.peeked.get(t.source),u=a?` ${this.p.error(a)}`:i(this.busy.get(t.source)??(c?`${c.id} · ${this.peeking(t.source)}`:this.live?"Fetching its palettes…":"space fetches its palettes"));return this.lit(e,`${r("+")}Add ${ot(t.source)}${u}`)}if(t.kind==="find"){let a=this.field.value.trim(),c=a&&!Hs(a),u=!this.searching&&!this.searchError&&this.repos===void 0,f=this.searching?"Searching GitHub…":this.searchError?"GitHub search failed":u?c?`Find "${a}" on GitHub`:"Find markets on GitHub":c?`No market on GitHub matches "${a}"`:"No market on GitHub yet",l=this.searchError??(this.searching?"":u?"space searches":"space searches again");return this.lit(e,`${r(A.search)}${f}${i(l)}`)}let s=[this.busy.get(t.source)??this.peeking(t.source),t.repo.description??""].filter(Boolean).join(" · ");return this.lit(e,`${r(this.known(t.source)?A.on:A.off)}${t.source} ${this.p.dim(`${A.star}${t.repo.stargazers_count}`)}${i(s)}`)}changes(){return this.adds.size+this.removes.size+this.want.size}dirty(){let{picked:t,renew:e}=this.result();return this.changes()>0||e.length>0||t.size!==this.installed.size||[...t].some((n)=>!this.installed.has(n))}mark(t){let e=this.tuned.has(t.name)?` ${this.p.warn(A.on)}`:"";if(!this.updates.has(t.name)||!this.installed.has(t.name))return e;return`${e}${this.renew.has(t.name)?` ${this.p.bold(`${A.update} update`)}`:` ${this.p.dim(A.update)}`}`}toggleRenew(){let t=this.catalog,e=t.focusedRow(),n=(e?t.inside(e):[]).map((i)=>i.name).filter((i)=>this.updates.has(i)&&this.installed.has(i));if(n.length===0)return;let r=n.some((i)=>!this.renew.has(i));for(let i of n)if(r)this.renew.add(i);else this.renew.delete(i)}leave(t){if(this.dirty()){this.leaving=t;return}this.goto=t,this.state="cancel"}steer(t){if(this.phase==="review"){if(t==="enter")this.begin();else if(t==="esc")this.phase="browse"}else if(this.phase==="done"&&(t==="enter"||t==="esc"))this.state="submit";let e=t==="up"?-1:t==="down"?1:xl(t,this.span());if(e!==void 0)this.scroll(e)}scroll(t){this.offset=Number.isFinite(t)?Math.max(0,this.offset+t):t>0?Number.MAX_SAFE_INTEGER:0,this.redraw()}span(){return Math.max(Pl,this.rows()-(this.hub?1:0)-4)}begin(){this.phase="applying",this.started=!0,this.offset=0,this.log=[],this.working="";let t={say:(e)=>{this.log.push(...e.split(`
|
|
647
|
-
`)),this.redraw()},status:(e)=>{this.working=e,this.redraw()}};this.track(this.io.apply(this.result(),t)).then(()=>this.ended(),(e)=>this.ended(e))}ended(t){this.working="",this.stopped=t,this.phase="done",this.offset=0,this.redraw()}pending(){let t=this.entries().filter((e)=>!e.default);return{names:t.filter((e)=>this.picked.has(e.name)&&!this.installed.has(e.name)),dropped:t.filter((e)=>this.installed.has(e.name)&&!this.picked.has(e.name))}}marketChanges(){let t=[];for(let e of this.adds.values()){let n=e.source!==
|
|
648
|
-
`)}keyBar(t,e){let n=`${
|
|
649
|
-
`);return Array.from({length:this.rows()},(e,n)=>t[n]??"")}small(t,e,n){return`Needs ${
|
|
650
|
-
${this.p.dim("esc cancels")}`}draw(){let t=this.columns(),e=this.rows();if(t<
|
|
651
|
-
`)}helpRows(){return[["Move","↑↓ home end pgup pgdn"],["Open","←→ · enter on a market or a series"],["Pick","space · a palette, a series, a market"],["Filter","Any text · bksp · ctrl-u clears"],...this.active().length>=2?[["Scope","ctrl+s · one market, then all"]]:[],["Market","⇧←→ auto-update · ctrl+r updates it"],["","del removes it · again to undo"],["Add","owner/repo, a folder, or a row on GitHub"],["","space adds it · ctrl+r searches again"],["Update","ctrl+r on a palette marked ↑"],["Apply","enter reviews and applies · esc cancels"],...this.hub?[["Screens","tab · shift+tab"]]:[],["Close","? esc"]]}helpBox(t,e,n,r){let i=this.helpRows(),o=Math.min(e-2,58),s=Math.floor((e-o)/2),a=`│${" ".repeat(o-2)}│`,c=[`╭─ Help ${"─".repeat(o-9)}╮`,a,...i.map(([f,l])=>`│${nt(` ${this.p.bold(f.padEnd(10))}${l}`,o-4)} │`),a,`╰${"─".repeat(o-2)}╯`],u=Math.max(0,Math.min(Math.max(r,Math.floor((n-c.length)/2)),n-1-c.length));return t.map((f,l)=>{let d=c[l-u];return d===void 0?f:`${Cb(f,s)}${d}`})}}import{existsSync as l6}from"node:fs";import{existsSync as Rc,mkdirSync as D4,readFileSync as Hg}from"node:fs";import{dirname as J4}from"node:path";class de extends Error{}import{closeSync as p3,mkdtempSync as g3,openSync as b3,readSync as w3,rmSync as AS}from"node:fs";import{homedir as $3,tmpdir as k3}from"node:os";import{join as NS}from"node:path";import{readFileSync as YL}from"node:fs";var vt={pitch:25,cols:22,rows:9,height:13},co={cols:25,rows:21},ve={cols:10,rows:3,pitch:12,top:4},ye=ve.top+ve.rows+1,ZL=1073741824,Hp=2147483648,VL=-1073741826,XL=1600,QL=56,tC=4,dE=20,eC=50,hE=[["space","unfolds a set of ×N"],["o","opens the post page in a browser"],["c","switches between cutouts and every post"],["a","opens the advanced filters"],["1-9","turn a tag of the tags row on or off"],["ctrl+v","tries on a picture from the clipboard — or drop one on the window"]];function Fp(t){return Math.max(0,Math.floor((t-1)/ve.pitch))}function hr(t,e){let n=e-ye-2;return{perRow:Math.max(1,Math.floor((t-1)/vt.pitch)),rowsVis:Math.max(1,Math.floor(n/vt.height)),height:n}}function Hl(t,e=!0){if(e)return`\x1B_Ga=t,t=f,f=100,i=${t.id},q=2;${Buffer.from(t.path).toString("base64")}\x1B\\`;let n;try{n=YL(t.path).toString("base64")}catch{return}let r=n.match(/.{1,4096}/g)??[""];return r.map((i,o)=>{let s=o<r.length-1?1:0;return o===0?`\x1B_Ga=t,f=100,i=${t.id},m=${s},q=2;${i}\x1B\\`:`\x1B_Gm=${s},q=2;${i}\x1B\\`}).join("")}function yE(t,e){let n=t.crop===void 0?"":`,x=0,y=${t.crop*e.h},w=${t.cols*e.w},h=${t.rows*e.h}`;return`\x1B[${t.row+1};${t.col+1}H\x1B_Ga=p,i=${t.id},p=${t.id}${n},c=${t.cols},r=${t.rows},C=1,z=${t.z},q=2\x1B\\`}function Lp(t){return`\x1B_Ga=d,d=i,i=${t},p=${t},q=2\x1B\\`}function ac(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}var Pt=gt("bold"),U=gt("dim"),ic=gt("ok"),Hn=gt("warn"),nc=Kn,Tl=Yf,Rp=!1;function Fl(t){return Rp=!0,t.beat}function Fs(t){return Wn[Fl(t)%Wn.length]}function dt(t){return _(t)}function Pp(t,e){if(_(t)<=e)return t;let n="";for(let r of t){if(_(n+r)>e)break;n+=r}return n}function hi(t){return vi(t)}function Cp(t){return`${gt("reverse")}${vi(t)}`}function uo(t,e,n,r){return n?[[`${A.link} `,r,void 0,{kind:"link",url:n}],[t,e,n]]:[[t,e]]}function Ip(t){let e=Oh(t);return e?{kind:"key",key:e}:void 0}function Ap(t){return t.reduce((e,[n])=>e+dt(n),0)}function nC(t,e){let n=[],r=e;for(let[i,o,s,a]of t){let c=dt(i);if(c<=r){n.push([i,o,s,a]),r-=c;continue}n.push([`${Pp(i,r)}…`,o,s,a]);break}return n}class Nl{parts=[];cols;constructor(t){this.cols=t}put(t,e,n="",r,i){return this.parts.push({col:t,text:e,sgr:n,...r?{link:r}:{},...i?{spot:i}:{}}),t+dt(e)}run(t,e){let n=t;for(let[r,i,o,s]of e)n=this.put(n,r,i,o,s);return n}mark(t,e,n){this.parts.push({col:t,text:" ".repeat(Math.max(0,e)),sgr:"",spot:n,hidden:!0})}zones(t){return this.parts.flatMap(({col:e,text:n,link:r,spot:i})=>{let o=i??(r?{kind:"link",url:r}:void 0),s=e>=0&&e<this.cols?dt(Pp(n,this.cols-e)):0;return o&&s>0?[{row:t,col:e,width:s,height:1,target:o}]:[]})}right(t,e){this.run(t-e.reduce((n,[r])=>n+dt(r),0),e)}center(t,e){this.run(Math.floor((t-e.reduce((n,[r])=>n+dt(r),0))/2),e)}render(){let t="";for(let{col:e,text:n,sgr:r,link:i,hidden:o}of this.parts){if(o||e>=this.cols||e<0)continue;let s=Pp(n,this.cols-e);t+=`\x1B[${e+1}G${r}${Bc(s,i)}${r?me:""}`}return t}}function rC(t){return t.replace(/_\([^)]*\)?$/,"")}function vE(t){return[`${t.reduced?"↓":""}${t.width}×${t.height}`,Math.max(t.width,t.height)<XL?Hn:U]}function oc(t,e,n){let r=[...n.keys??[]],i=n.lead,o=n.right,s=()=>{let u=[...i?[Ap(i)]:[],...r.map(([l,d])=>dt(l)+1+dt(d))];return(n.badge?dt(n.badge)+4:0)+u.reduce((l,d)=>l+d,0)+3*Math.max(0,u.length-1)+(o?3+dt(o[0])+1+dt(o[1]):0)};while(s()>e)if(r.length>2)r.splice(-2,1);else if(o)o=void 0;else if(r.length>1)r.splice(-2,1);else break;if(i&&s()>e)i=nC(i,Math.max(0,Ap(i)-(s()-e)-1));let a=0;if(n.badge)a=t.put(0,` ${n.badge} `,gt("pill"))+2;if([...i?[i]:[],...r.map(([u,f])=>[[u,Pt,void 0,Ip(u)],[` ${f}`,U,void 0,Ip(u)]])].forEach((u,f)=>{a=t.run(a+(f?3:0),u)}),o){let u=Ip(o[0].split(" ")[0]??"");t.right(e,[[o[0],Pt,void 0,u],[` ${o[1]}`,U,void 0,u]])}}function iC(t,e){if(t==="d")return U;if(t==="b")return Pt;if(t==="s")return Tl(e.colors.selection);if(t==="c")return Tl(e.colors.cursor);let n=/^([BK]?)(\d+)$/.exec(t);if(!n)return"";let r=Number(n[2]);if(n[1]==="K")return`${vi(0)}${Tb(r)}`;return`${n[1]==="B"?Pt:""}${vi(r)}`}function oC(t,e,n,r,i){let o=Zt.indexOf(Ki(r.scene)),s=Zt.flatMap((c,u)=>[...u?[[" ",""]]:[],[c.name,u===o?Pt+i:U,void 0,{kind:"scene",scene:u}]]),a=s.reduce((c,[u])=>c+dt(u),0)<=n;t?.run(e,a?s:[[Ki(r.scene).name,Pt+i],[` ${o+1}/${Zt.length}`,U]])}function sC(t,e,n,r,i,o,s){let{ansi:a,cursor:c}=o.colors;oC(t[e-2],n,r,o,s);let u=r<iy?3:4;if(r>=56)u=Math.min(7,Math.floor((r+1)/8)-1);let f=n;for(let d=0;d<8;d++)f=(t[e]?.put(f,"▀".repeat(u),nc(a[d]??c)+Tl(a[d+8]??c))??f)+1;let l=e+2;for(let d of Ki(o.scene).lines){let h=cs(d,r);if(!h)continue;if(l>i)return;t[l]?.run(n,h.map(([m,p])=>[m,iC(p,o)])),l++}}function aC(t,e,n){let r=[[]];for(let s of t){let a=r[r.length-1];if(a.length===0||dt([...a,s].join(" "))<=e)a.push(s);else if(r.length<n)r.push([s]);else break}let i=r.reduce((s,a)=>s+a.length,0),o=r[r.length-1];while(i<t.length&&o.length>0&&dt([...o,`+${t.length-i}`].join(" "))>e)o.pop(),i--;if(i<t.length)o.push(`+${t.length-i}`);return r.filter((s)=>s.length>0).map((s)=>s.join(" "))}function mE(t){return t.replace(/^https?:\/\/(?:www\.)?/,"")}function cC(t,e,n,r,i){let o=r.info,s=o?.artists??[],a=hi(r.tiles[r.focus]?.siteAnsi??r.siteAnsi);[["Post",o?.page?uo(mE(o.page),"",o.page,a):[["—",U]]],["Source",o?.source?uo(mE(o.source),"",o.link,i):[["—",U]]],["Artist",[s.length>0?[s.join(" "),""]:["—",U]]]].forEach(([u,f],l)=>{t[e+l]?.put(n,u,U),t[e+l]?.run(n+12,f)})}function uC(t,e,n,r,i,o){let s=o.info,a=o.tiles[o.focus];if(!s||!a)return;let c=o.shown?.id===a.key?o.shown:void 0,u=n+12,f=Math.max(12,r-12),l=[`${a.width}×${a.height}${s.ext?` ${s.ext.toUpperCase()}`:""}`,...c?[ml(c.bytes)]:[]].join(" · "),d=[s.rating??"—",a.score>0?`★${a.score}`:"",s.posted??""].filter(Boolean).join(" · "),h=(b,$)=>b.length>0?aC(b,f,$).map((k)=>[[k,""]]):[[["—",U]]],m=[["Characters",h(s.characters,2)],["Series",h(s.series,1)],["Tags",h(s.tags,3)],["Rating",[[[d,d==="—"?U:""]]]],["File",[[[l,""],...c?[[" ",""]]:[],...c?EE(c):[]]]],["Uploader",[[s.uploader?[s.uploader,""]:["—",U]]]]],p=e;for(let[b,$]of m){if(p+$.length-1>i)return;t[p]?.put(n,b,U);for(let k of $)t[p]?.run(u,k),p++}}var lC=["Size","Position","Opacity"],fC=[0,3,6];function dC(t,e){let{tune:n,untuned:r}=t;return e===0?n.size!==r.size:e===1?n.at!==r.at:n.opacity!==r.opacity}function hC(t){return t.toFixed(2)}function mC(t,e,n,r,i,o){let s=i.tuning;if(!s)return;let a=i.tiles[i.focus];t[e-3]?.run(n,[[i.palette,Pt+o],[" Background",U],...a?[[" · ",U],...uo(`${a.site} ${a.id}`,U,a.page||void 0,hi(a.siteAnsi))]:[]]);let c=Math.max(8,r-n-21),u=20,f=Math.max(100,s.fill);for(let[l,d]of lC.entries()){let h=e+fC[l],m=s.field===l,p=m?Pt:U;if(m)t[h]?.put(n,"▶",o,void 0,{kind:"field",field:l});t[h]?.put(n+2,d,p,void 0,{kind:"field",field:l});let b;if(l===1){for(let $=1;$<=9;$++){let k=$===i.tune.at,v=t[e+2+Math.floor(($-1)/3)],E=n+12+($-1)%3*3;v?.mark(E-1,3,{kind:"place",at:$}),v?.put(E,k?"■":"·",k?Pt+o:U)}b=qt[i.tune.at-1]??"center"}else{let $;if(l===0){let{size:k}=i.tune;$=k==="fill"?c-1:Math.floor((k-u)*(c-1)/(f-u+1)),b=k==="fill"?"fill":`${k}%`}else $=Math.floor(Math.round(i.tune.opacity*100)*(c-1)/100),b=hC(i.tune.opacity);$=Math.max(0,Math.min(c-1,$)),t[h]?.run(n+12,[["━".repeat($),o],["●",Pt],["─".repeat(c-1-$),U]]),t[h]?.mark(n+12,c,{kind:"track",field:l})}if(t[h]?.right(r-2,[[b,p]]),dC(i,l))t[h]?.put(r-1,"↺",m?Pt+o:U)}}function pC(t,e,n,r,i,o){t[e]?.put(n,`╭${"─".repeat(i-2)}╮`,o);for(let s=e+1;s<e+r-1;s++)t[s]?.put(n,"│",o),t[s]?.put(n+i-1,"│",o);t[e+r-1]?.put(n,`╰${"─".repeat(i-2)}╯`,o)}function Np(t,e=t.site,n=t.siteAnsi){return[` ${e} `,Cp(n)]}function rc(t){return`${V[Math.floor(t/Cr)]?.name??"local"} ${t%Cr}`}function ec(t,e,n){let r=V[Math.floor(e/Cr)],i=rc(e),o=t.indexOf(i);if(!r||o===-1)return[[t,n]];return[[t.slice(0,o),n],...uo(i,n,r.pageUrl(e%Cr),hi(r.ansi)),[t.slice(o+i.length),n]].filter(([a])=>a!=="")}function gC(t,e,n){let r=[{name:"all",moved:!1},...V].flatMap((o,s)=>{let a=`${o.name}${o.moved?"*":""}`,[c,u]=o.name===n.site?Np(n,a):[` ${a} `,U],f=[c,u,void 0,{kind:"site",tab:s}];return s?[[" ",""],f]:[f]}),i=r.reduce((o,[s])=>o+dt(s),0)<=e;t.run(0,i?r:[Np(n)])}function bC(t,e,n,r){if(n.chips.length===0)return;let i=[["tags ",U]],o=dt("tags "),s=n.chips.length;for(let[a,c]of n.chips.entries()){let u=` ${a+1} ${c.name} `;if(o+dt(u)+1>e-2)break;i.push([u,c.on?`${gt("reverse")}${r}`:U,void 0,{kind:"chip",index:a}],[" ",""]),o+=dt(u)+1,s--}if(s>0)i.push([`+${s}`,U]);t.run(0,i)}function wC(t,e,n,r,i){t[ye-1]?.put(0,"─".repeat(n-1),U);let o=t[ve.top-1],s=Fp(n),a=r.held.length>s?Math.max(0,s-1):r.held.length;for(let[c,u]of r.held.slice(0,a).entries()){let f=c*ve.pitch,l=u.up?Pt:"";if(o.run(f+1,u.page?uo(String(u.id),l,u.page,hi(u.ansi)):[["● ",hi(u.ansi)],[String(u.id),l]]),u.up)for(let d=0;d<ve.rows;d++)t[ve.top+d]?.put(f,"▌",i);if(u.thumb)e.push({id:ZL+c,path:u.thumb,row:ve.top,col:f+1,cols:ve.cols,rows:ve.rows,z:-1})}if(a<r.held.length)o.put(a*ve.pitch+1,`+${r.held.length-a}`,U)}function $C(t,e,n,r){if(n.editing!==void 0){let c=t.run(0,[["⌕ ",r],[n.editing,""],["█",r]]),u=n.suggest?.length?" ↑↓ pick enter searches":" enter searches";t.put(c,n.editing?u:` A tag, a post URL or an id, or drop a picture or ctrl+v — ${n.tag||"esc leaves"}`,U);return}let i=t.run(0,[["⌕ ",r,void 0,{kind:"query"}],[n.tag||"Nothing yet — / searches, ctrl+v pastes a picture",n.tag?"":U,void 0,{kind:"query"}]]),o=Pi.filter((c)=>!n.block.includes(c)),s=V.filter((c)=>!n.enabled.includes(c.name)).map((c)=>c.name),a=[n.preset,...n.solo?["solo"]:[],n.order,...n.rating.join("+")==="safe"?[]:[n.rating.join("+")],...o.length>0?[`allows ${o.join("+")}`]:[],...n.narrow.size>0?[`≥${n.narrow.size}px`]:[],...n.narrow.score>0?[`score≥${n.narrow.score}`]:[],...n.narrow.png?["png"]:[],...n.hide.length+n.hideTags.length>0?[`hides ${[...n.hide,...n.hideTags].join("+")}`]:[],...s.length>0?[`all skips ${s.join("+")}`]:[]];if(t.put(i,` ${a.join(" ")}`,U),n.total>0||!n.searching){let c=[[`${n.tiles.length}/${n.checked}`,""]];if(n.checked<n.total)c.push([` of ${n.total}`,U]);t.right(e,c)}}function EE(t){if(t.cut==="on")return[[`Cut out · ${t.clear}% transparent`,ic]];if(t.cut==="off")return[["Opaque · x cuts out",Hn]];if(t.cut==="failed")return[["Opaque · no cut-out",Hn]];return[t.clear>0?[`${t.clear}% transparent`,ic]:["Opaque",Hn]]}function pE(t){return t.site==="all"?"any site":t.site}function Tp(t,e){if(t.installing!==void 0)return ec(`${Fs(t)} Installing ${t.palette} ← ${rc(t.installing)}`,t.installing,Hn);if(t.hint)return[[t.hint,ic]];if(t.error)return[[t.error,Hn]];if(t.waiting!==void 0)return[[`${t.slow??t.site} asked to slow down · ${t.waiting}s`,Hn]];if(t.fetching){let{id:n,got:r,size:i}=t.fetching;return ec(`${Fs(t)} Fetching ${rc(n)} · ${pl(r,i)}`,n,Hn)}if(t.cutting!==void 0)return ec(`${Fs(t)} Cutting out ${rc(t.cutting)}`,t.cutting,Hn);if(t.preparing!==void 0)return ec(`${Fs(t)} Preparing ${rc(t.preparing)}`,t.preparing,Hn);if(e)return[e];if(t.saved)return ec(t.saved.text,t.saved.key,ic);if(t.note)return[[t.note,U]];return}function SE(t){if(t.ranking)return"Ranking previews by palette colors";if(t.stage==="check")return t.preset==="cutouts"?"Checking PNG headers":"Loading previews";return"Fetching posts"}function ME(t,e){return t.ranking?`${e}${t.ranking.done}/${t.ranking.total}`:""}function kC(t,e,n,r,i){let{background:o,cursor:s,selection:a}=r.colors,{ranking:c}=r,u=c?Math.round(n*c.done/c.total):-1,f=Math.max(6,Math.round(n*0.22)),l=Fl(r)%(dE*2)/dE,d=Math.round((n-f)*(0.5-0.5*Math.cos(Math.PI*(l<1?l:2-l)))),h=At(o,s,i),m=At(o,At(a,o,0.15),i),p=Array.from({length:n},($,k)=>{let v=(u>=0?k<u:k>=d&&k<d+f)?h:m;return k===0||k===n-1?At(v,o,0.55):v}),b=0;for(let $=1;$<=n;$++)if($===n||p[$]!==p[b])t?.put(e+b," ".repeat($-b),Tl(p[b])),b=$}function yC(t,e,n,r,i){let{background:o,foreground:s}=i.colors,a=i.loaderFrom===void 0?0:Math.min(1,(Fl(i)-i.loaderFrom)/tC),c=e+(n>=5?Math.floor((n-5)/2):0);t[c]?.center(r,[[SE(i),Pt+nc(At(o,s,a))],[ME(i," "),nc(At(o,At(s,o,0.45),a))]]);let u=Math.min(QL,r-8);if(kC(t[c+(n>=3?2:1)],Math.floor((r-u)/2),u,i,a),n<5)return;t[c+4]?.center(r,i.sites.flatMap(({name:f,arrived:l},d)=>[...d?[[" · ",nc(At(o,s,0.25*a))]]:[],[f,nc(At(o,l?At(s,o,0.2):s,l?a:0.32*a))]]))}function vC(t,e,n,r,i,o){if(i<=r)return;let s=Math.max(1,Math.round(r*r/i)),a=Math.max(0,Math.min(r-s,Math.round(n.scroll*r/i)));for(let c=0;c<r;c++){let u=c>=a&&c<a+s;t[ye+c]?.put(e-1,u?"┃":"│",u?o:U)}}function EC(t,e,n){if(e)return[`${Fs(t)} ${SE(t)}${ME(t," · ")}`,U];let r=n.filter((o)=>!o.missing),i=r.filter((o)=>o.thumb).length;return i<r.length?[`${Fs(t)} Loading thumbnails · ${i}/${r.length}`,U]:void 0}function SC(t,e,n,r,i,o,s){let{perRow:a,rowsVis:c,height:u}=hr(r,i);$C(t[0],r,o,s),gC(t[1],r,o),bC(t[2],r,o,s),wC(t,e,r,o,s);let f=t.map((F,N)=>N>=ye&&N<ye+u?F:void 0),l=Math.floor(o.scroll/vt.height),d=Math.floor((o.scroll+u-1)/vt.height),h=[];for(let F=l;F<=d;F++){let N=ye+F*vt.height-o.scroll;for(let j=0;j<a;j++){let z=F*a+j,G=j*vt.pitch,et=o.tiles[z];if(!et)continue;h.push(et);let q=Math.max(N,ye),Ot=Math.min(N+vt.height,ye+u);if(Ot>q)n.push({row:q,col:G,width:vt.pitch-1,height:Ot-q,target:{kind:"tile",index:z}});let tt=z===o.focus;if(tt)pC(f,N,G,vt.height,vt.pitch-1,s);let Sr=N+1,pn=Math.max(Sr,ye),gn=Math.min(Sr+vt.rows,ye+u);if(et.thumb&&gn>pn)e.push({id:et.key,path:et.thumb,row:pn,col:G+1,cols:vt.cols,rows:gn-pn,...gn-pn<vt.rows?{crop:pn-Sr}:{},z:-1});let bn=[...o.installed.includes(et.key)?[["✓ ",ic]]:[],...et.page||o.site!=="all"?uo(String(et.id),tt?Pt:"",et.page||void 0,hi(et.siteAnsi)):[["● ",hi(et.siteAnsi)],[String(et.id),tt?Pt:""]],[" ",""],vE(et)],Fc=vt.cols-(et.mates.length>0?1:0);if(f[N+10]?.run(G+1,Ap(bn)>Fc?bn.map(([Tf,Hf,Ff])=>[Tf.replace(/^(\S) $/,"$1"),Hf,Ff]):bn),et.mates.length>0)f[N+10]?.put(G+vt.cols,"≈",s);f[N+11]?.put(G+1,et.artist?rC(et.artist).slice(0,vt.cols-8):"—",U);let gi=[];if(et.score>0)gi.push([`★${et.score}`,U]);if(et.variants>1)gi.push([` ×${et.variants}`,s]);if(gi.length>0)f[N+11]?.right(G+vt.cols+1,gi)}}let m=Math.ceil(o.tiles.length/a)*vt.height;vC(t,r,o,u,m,s);let p=Math.max(ye,ye+m-o.scroll),b=ye+u-p,$=o.searching&&b>=2;if($)yC(f,p,b,r-1,o);let k=o.searching&&o.tiles.length===0;if(k&&!o.error){let[F,N]=hE[Math.floor(Fl(o)/eC)%hE.length];t[i-2]?.run(0,[["Tip ",U],[F,Pt],[` ${N}`,U]])}let v=o.top*a,E=o.tiles.length-(o.top+c)*a,x=[...v>0?[`↑ ${v} above`]:[],...E>0?[`↓ ${E} more`]:[]];if(x.length>0)t[i-2]?.put(0,x.join(" "),U);if(!o.searching&&o.tiles.length===0&&!o.error&&o.tag)t[ye+1]?.put(0,o.preset==="cutouts"?`No transparent cutouts of ${o.tag} on ${pE(o)} — c searches every post, tab tries ${o.nextSite}`:`No posts of ${o.tag} on ${pE(o)} — tab tries ${o.nextSite}`,U);let M=EC(o,$,h),R=Tp(o,M);return oc(t[i-1],r,{badge:"IMAGE SEARCH",lead:R,keys:k&&R?.[0]===M?[]:[["←↑↓→","move"],["enter","try on"],["tab","site"],["ctrl+v","picture"],["s","settings"],["/","search"],["?","keys"]],right:["esc","back"]}),$}function MC(t,e,n,r,i,o){let s=i.tiles[i.focus];if(!s)return;let a=i.shown?.id===s.key?i.shown:void 0,c=[Np(i,s.site,s.siteAnsi),[" ",""],...uo(String(s.id),Pt,s.page||void 0,hi(s.siteAnsi)),[" ",""],vE(s)];if(s.score>0)c.push([` · ★${s.score}`,U]);if(a)c.push([` · ${ml(a.bytes)}`,U]);if(a){if(c.push([" ",""],...EE(a)),i.coloring==="original")c.push([" · own colors",U])}if(t[0]?.run(0,c),s.mates.length>0)t[0]?.right(n,[["≈ ",o],[s.mates.join(" "),U]]);if(cC(t,1,2,i,o),i.tuning)mC(t,8,2,2+Math.min(n-4,60),i,o);else if(i.details)uC(t,5,2,Math.min(n-4,Math.max(48,Math.floor(n*0.55))),r-2,i);else sC(t,7,2,n-4,r-2,i,o);if(i.shown)e.push({id:Hp+i.shown.id,path:i.shown.path,row:0,col:0,cols:n,rows:r,z:VL});if(i.tuning){oc(t[r-1],n,{badge:"IMAGE EDIT",lead:Tp(i),keys:[["↑↓","field"],["←→","step"],["=","reset"],["+","reset all"],i.tuning.field===1?["1-9","place"]:["⇧←→","×10"],["c","colors"],["enter","keep"]],right:["esc","undo"]});return}let u=Tp(i);oc(t[r-1],n,{badge:"IMAGE PREVIEW",lead:u,keys:i.installing===void 0?[["←→","browse"],["enter","install"],["t","tune"],["c","colors"],["i","details"],...i.details?[]:[["⇧←→","example"]],...i.shown?.cut==="on"||i.shown?.cut==="off"?[["x","cut out"]]:[],["?","keys"]]:[],right:i.installing===void 0?["esc","grid"]:void 0})}var xC=[["Field","↑↓ size, position, opacity"],["Step","←→ · ⇧←→ ×10"],["Place","1-9 the nine positions"],["Reset","= this field back to its default · + every field"],["Colors","c the palette's tone or its own colors, opacity back to its default"],["Keep","enter back to try, installed with the picture"],["Undo","esc"],["Close","? esc"]],OC={grid:[["Move","←↑↓→ j k home end pgup pgdn"],["Try on","enter"],["Site",`tab shift+tab all, ${V.map((t)=>t.name).join(", ")}`],["Posts","c cutouts or every post"],["Search","/ a tag, a post URL or an id"],["Tags","1-9 turn a tag of the tags row on or off — the palette's own, then danbooru's related characters"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window or paste its link"],["Unfold","space a set of ×N"],["Open","o the post page in a browser"],["Settings","s rating, block, posts, solo, order, sets, remove bg"],["Advanced","a or Advanced › in settings min score, min size, sites, hide, hide tags, PNG only"],["Back","esc returns to preview"],["Close","? esc"]],try:[["Browse","←→"],["Install","enter"],["Tune","t size, position and opacity, installed with the picture"],["Colors","c the palette's tone or its own colors, installed with the picture"],["Details","i characters, series, tags, rating and file, under Post, Source and Artist"],["Example",`⇧←→ ${Zt.map((t)=>t.name.toLowerCase()).join(", ")}`],["Cut out","x the background off or on, on an opaque picture"],["Open","o the post page in a browser"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window"],["Grid","esc"],["Close","? esc"]]},jp=6,IC=24;function sc(t){return[...t.settings.flatMap((e,n)=>Boolean(e.advanced)===t.advanced?[n]:[]),t.settings.length]}function RC(t){return t.replace(/^[A-Z](?=[a-z])/,(e)=>e.toLowerCase())}function gE(t){let e=t.settings.filter((n)=>Boolean(n.advanced)!==t.advanced).map((n)=>RC(n.label));return`${t.advanced?"Back to":"More filters:"} ${e.join(", ")} — enter opens the page, or a from any row`}function xE(t,e,n){let r=t.indexOf(e);if(r!==-1)return t[(r+n+t.length)%t.length];let i=Number(e)||0;return(n>0?t.find((s)=>(Number(s)||0)>i):[...t].reverse().find((s)=>(Number(s)||0)<i))??t[n>0?0:t.length-1]}function ao(t,e){let n=[],r="";for(let i of t.split(" "))if(r&&dt(r)+1+dt(i)>e)n.push(r),r=i;else r=r?`${r} ${i}`:i;return r?[...n,r]:n}function PC(t){if(t.entry!=="number"||t.choices.includes(t.value))return t.choices;let e=t.choices.findIndex((n)=>(Number(n)||0)>Number(t.value));return e===-1?[...t.choices,t.value]:[...t.choices.slice(0,e),t.value,...t.choices.slice(e)]}function AC(t,e,n,r){let i=Cp(r),o=e&&n!==void 0;if(t.entry==="text")return[{text:` ${o?`${n}█`:t.value||"none"} `,sgr:o||e&&t.value?i:t.value?"":U}];let s=o?[]:t.value.split(" "),a=(o?t.choices:PC(t)).map((c,u)=>{let f=s.includes(c),l=t.multi&&e&&u===t.cursor?gt("under"):"";return{text:t.multi?` ${f?"[x]":"[ ]"} ${c} `:` ${c} `,sgr:f?e?`${l}${i}`:"":l?`${l}${U}`:U,choice:c}});return o?[...a,{text:` ${n}█ `,sgr:i}]:a}function bE(t){if(t.entry==="text")return[{text:" ".repeat(IC),sgr:""}];let e=t.choices.map((n)=>({text:t.multi?` [x] ${n} `:` ${n} `,sgr:""}));return t.entry==="number"?[...e,{text:` ${"0".repeat(jp)}█ `,sgr:""}]:e}function NC(t){return t.reduce((e,n)=>e+dt(n.text)+1,0)-1}function wE(t,e){let n=[[]],r=0;for(let i of t){let o=dt(i.text)>e?{...i,text:` …${Array.from(i.text).slice(-(e-2)).join("")}`}:i;if(r>0&&r+dt(o.text)>e)n.push([]),r=0;n[n.length-1]?.push(o),r+=dt(o.text)+1}return n}function $E(t){if(t.multi&&t.choices.every((e)=>t.default.split(" ").includes(e)))return"Default all";return`Default ${t.default&&t.default!==t.multi?.none?t.default:"none"}`}function kE(t){if(!t.tag)return"";if(!t.counts)return`${t.tag}: counting…`;let e=t.counts.map(({site:n,count:r})=>`${n} ${r===void 0?"no count":r.toLocaleString("en-US")}`);return`${t.tag}: ${e.join(" · ")}`}function TC(t,e){let n=t.advanced?"basic":"advanced";if(!e)return{keys:[["↑↓","setting"],["enter",n],["s","save"]],right:["esc","undo"]};if(t.typing!==void 0)return{keys:[["⌫","erase"],["enter","done"]],right:["esc","cancel"]};if(e.entry)return{keys:[["↑↓","setting"],...e.entry==="number"?[["←→","step"]]:[],["a",n],["enter","type"],["s","save"]],right:["esc","undo"]};return{keys:[["↑↓","setting"],["←→","value"],["a",n],...e.multi?[["space","toggle"]]:[],["enter","save"]],right:["esc","undo"]}}function HC(t,e,n,r,i){let o=r.panel??0,s=r.settings.length,c=6+Math.max(...r.settings.map((q)=>dt(q.label))),u=Math.max(...r.settings.map((q)=>dt($E(q)))),f=c+Math.max(...r.settings.map((q)=>NC(bE(q))))+u+5,l=Math.min(e-2,Math.max(48,f)),d=l-c-u-5,h=l-7,m=[!1,!0].map((q)=>({advanced:q,rows:sc({settings:r.settings,advanced:q}).slice(0,-1)})),p=r.settings.map((q)=>wE(bE(q),d).length),b=Math.max(...m.map((q)=>q.rows.reduce((Ot,tt)=>Ot+p[tt],0))),$=Math.max(...m.map((q)=>ao(gE({settings:r.settings,advanced:q.advanced}),h).length),...r.settings.map((q)=>ao(q.about,h).length)),k=`${r.tag}: ${V.map((q)=>`${q.name} 0,000,000`).join(" · ")}`,v=r.tag?Math.max(ao(k,h).length,ao(kE(r),h).length):0,E=b+$+v+8,x=Math.floor((e-l)/2),M=Math.max(1,Math.floor((n-1-E)/2)),R=Cp(r.siteAnsi);t[M]?.put(x,`╭─ Settings ${"─".repeat(Math.max(0,l-13))}╮`);for(let q=M+1;q<M+E-1;q++)t[q]?.put(x,`│${" ".repeat(l-2)}│`);let F=M+2;for(let q of sc(r).slice(0,-1)){let Ot=r.settings[q],tt=q===o;if(tt)t[F]?.put(x+2,"▶",i);if(t[F]?.mark(x+2,c-3,{kind:"setting",index:q}),t[F]?.put(x+4,Ot.label,tt?Pt:""),Ot.value!==Ot.default)t[F]?.right(x+l-3,[[$E(Ot),U]]);wE(AC(Ot,tt,r.typing,r.siteAnsi),d).forEach((Sr,pn)=>{let gn=x+c;for(let bn of Sr)gn=t[F+pn].put(gn,bn.text,bn.sgr,void 0,{kind:"choice",index:q,choice:bn.choice}),gn+=1}),F+=p[q]}let N=m.find((q)=>q.advanced!==r.advanced)?.rows??[],j=t[M+3+b];if(o===s)j.put(x+2,"▶",i);let z=j.put(x+3,r.advanced?" ‹ Basic ":" Advanced › ",o===s?R:Pt,void 0,{kind:"setting",index:s});if(N.some((q)=>r.settings[q]?.value!==r.settings[q]?.default))j.put(z+1,"•",U);t[M+5+b]?.put(x+2,"─".repeat(l-4),U),ao(r.settings[o]?.about??gE(r),h).forEach((q,Ot)=>{t[M+6+b+Ot]?.put(x+4,q)}),ao(kE(r),h).forEach((q,Ot)=>{t[M+6+b+$+Ot]?.put(x+4,q,U)}),t[M+E-1]?.put(x,`╰${"─".repeat(l-2)}╯`);let{keys:G,right:et}=TC(r,r.settings[o]);oc(t[n-1],e,{keys:G,right:et})}function FC(t,e,n,r){let i=r.tuning?xC:OC[r.mode],o=Math.min(e-2,Math.max(50,...i.map(([,l])=>dt(l)+16))),s=i.map(([l,d])=>({label:l,parts:ao(d,o-16)})),a=s.reduce((l,{parts:d})=>l+d.length,0)+4,c=Math.floor((e-o)/2),u=Math.max(2,Math.floor((n-a)/2));t[u]?.put(c,`╭─ Help ${"─".repeat(o-9)}╮`);for(let l=u+1;l<u+a-1;l++)t[l]?.put(c,`│${" ".repeat(o-2)}│`);let f=u+2;for(let{label:l,parts:d}of s){t[f]?.put(c+3,l,Pt);for(let h of d)t[f]?.put(c+13,h),f++}t[u+a-1]?.put(c,`╰${"─".repeat(o-2)}╯`),oc(t[n-1],e,{badge:"HELP",right:["? esc","close"]})}function LC(t,e,n){let r=e.suggest??[],i=r.map((a)=>a.alias??(a.count>0?String(a.count):a.palette??"0")),o=Math.max(...r.map((a)=>dt(a.value))),s=Math.max(7,...i.map(dt));r.forEach((a,c)=>{let u=c===e.pick,f=t[1+c];f?.run(0,[[u?"▸ ":" ",n,void 0,{kind:"suggest",index:c}],[a.value,u?Pt+n:"",void 0,{kind:"suggest",index:c}]]),f?.right(2+o+2+s,[[i[c],U]])})}function Al(t,e=[]){return[...e,...t.flatMap((n,r)=>n.zones(r))]}function _p(t,e,n){let r=Array.from({length:n},()=>new Nl(e)),i=[],o=[],s=gt("accent");if(Rp=!1,e<co.cols||n<co.rows)return r[0]?.put(0,"ttheme find",Pt+s),r[1]?.put(0,`Needs ${co.cols}×${co.rows} — now ${e}×${n}`),r[2]?.put(0,"esc quits",U,void 0,{kind:"key",key:"esc"}),{lines:r.map((c)=>c.render()),images:i,zones:Al(r),loader:!1,tick:!1};let a=!1;if(t.mode==="try")MC(r,i,e,n,t,s);else a=SC(r,i,o,e,n,t,s);if(t.mode==="grid"&&t.editing!==void 0&&t.suggest?.length){for(let c=1;c<n-1;c++)r[c]=new Nl(e);return LC(r,t,s),{lines:r.map((c)=>c.render()),images:[],zones:Al(r),loader:!1,tick:!1}}if(t.help||t.panel!==void 0){let c=t.mode==="try"?i:[];for(let u=0;u<n;u++)r[u]=new Nl(e);if(t.help)FC(r,e,n,t);else HC(r,e,n,t,s);return{lines:r.map((u)=>u.render()),images:c,zones:Al(r),loader:!1,tick:!1}}return{lines:r.map((c)=>c.render()),images:i,zones:Al(r,o),loader:a,tick:Rp}}var CC=130,jC=38,_C=96,GC=28,uc=[{id:"shell",scenes:["Diff","Logs","Shell"],name:"zsh",tail:!0},{id:"code",scenes:["Editor"],name:"nvim",tail:!1},{id:"monitor",scenes:["Top"],name:"htop",tail:!1}],BC={Shell:[0,1,2,3,4,6,7,9,10,12,14],Diff:[0,1,3,4,6,7,8,9,10,15],Logs:[0,1,2,3,4,5,6,7,8,9,10]},OE=(t)=>Array.from({length:8},(e,n)=>`«K${t+n}» «»`).join(" "),UC=["«2»❯ «»colortest",`«d»0-7 ${OE(0)}`,`«d»8-15 ${OE(8)}`],IE=2;function WC(t){let e=uc.length;return uc[(t%e+e)%e]}function AE(){return uc.map((t)=>t.name)}function lc(t,e,n){let r=t>=CC&&e>=jC?"full":t>=_C&&e>=GC?"tabs":void 0;if(!r)return;let i=r==="full"?t>=140?47:38:37,o=t-i-1,s=i+1+IE,a=i+o-IE,c=3,u=e-3,f={col:s,row:c,cols:a-s+1,rows:u-c+1},l={col:s+1,row:c+3,cols:f.cols-2,rows:u-c-3},d=[{row:c,col:s,length:f.cols,down:!1},{row:c+2,col:s,length:f.cols,down:!1},{row:u,col:s,length:f.cols,down:!1},{row:c,col:s,length:u-c+1,down:!0},{row:c,col:a,length:u-c+1,down:!0}],h=WC(n);return{tier:r,side:i,width:o,frame:f,title:{col:l.col,row:c+1,cols:l.cols,rows:1},inner:l,rules:d,tiles:[{id:h.id,name:h.name,col:l.col,row:l.row,width:l.cols,rows:l.rows}]}}var cc="«2»▎ ",RE="«3»▎ ",KC="«1»▁ ",zC=[["","«5»import«» { «4»readFile«» } «5»from «2»'node:fs/promises'"],["","«5»import«» { «5»type «6»Hex«», «4»contrast«» } «5»from «2»'./color.ts'"],["",""],["","«8»/** A palette read from disk and checked against the gate. */"],[cc,"«5»export interface «6»Palette «»{"],[cc," name: «6»string"],[cc," ansi: «6»Hex«»[]"],[cc," ratio?: «6»number"],[cc,"}"],["",""],["","«5»const «»SIXTEEN = «3»16"],["","«5»const «»FLOOR = «3»4.5 «8»// WCAG AA for body text"],["",""],["","«5»export async function «4»load«»(path: «6»string«»): «6»Promise«»<«6»Palette«»> {"],[RE," «5»const «»text = «5»await «4»readFile«»(path, «2»'utf8'«»)"],[RE," «5»const «»colors = «s»parse(text)«».colors ?? {}"],[""," «5»if «»(colors.ansi.length !== «K3»SIXTEEN«») { «1»● needs 16 ANSI colors"],[""," «5»throw new «6»Error«»(«2»'expected sixteen colors, got '«» + colors.ansi.length)"],[""," }"],[KC," «5»const «»ratio = «4»contrast«»(colors.ansi[«3»0«»], colors.ansi[«3»7«»]) «3»● ratio is read once"],[""," «5»return «»{ name: path, ...colors, ratio: «c»r«»atio }"],["","}"],["",""],["","«5»export function «4»passes«»(palette: «6»Palette«»): «6»boolean «»{"],[""," «5»return «»(palette.ratio ?? «3»0«») >= FLOOR «8»// TODO: check the bright pairs"],["","}"]],qC=21;function DC(){return["«K4» theme.ts «s» scenes.ts «s» contrast.ts ",...zC.map(([t,e],n)=>{let r=String(n+1).padStart(3);return`${n+1===qC?`«b»${r}`:`«d»${r}`} ${t||"«» "}«»${e}`})]}function Gp(t,e,n,r){let i=Math.max(1,r-t.length-2-n.length),o=0,s=`«6»${t}«b»[`;for(let[a,c]of e){let u=Math.min(i-o,Math.round(c*i));s+=`«${a}»${"|".repeat(u)}`,o+=u}return`${s}«»${" ".repeat(i-o)}${n}«b»]`}var JC=[[0.31,0.07,0],[0.22,0.02,0.03],[0.04,0.01,0],[0.52,0.12,0],[0.1,0.02,0],[0.41,0.11,0],[0.02,0,0],[0.15,0.03,0.04]],YC=["«s» 4127 kec 24 0 412G 612M «s»R 38.2 3.7 3:12.44 node dev.js"," 2210 kec 31 0 411G 1.2G «2»R«» 12.0 7.5 1:02.10 «d»/Applications/«b»Ghostty"," 3301 kec 31 0 409G 12M S 4.4 0.1 0:05.61 «b»zsh"," 3302 kec 31 0 409G 9.8M S 0.0 0.1 0:00.42 «d»├─ «b»nvim «»src/theme.ts"," 3310 kec 31 0 410G 88M S 1.2 0.5 0:03.18 «d»│ └─ «b»tsserver"," 3402 kec 24 0 409G 21M «2»R«» 0.6 0.1 0:01.02 «d»└─ «b»htop"," 501 kec 31 «4»10«» 409G 34M S 0.3 0.2 0:02.77 «b»bun «»test --watch"," 1180 kec 31 0 409G 72M «1»D«» 0.0 0.4 0:00.91 «b»rsync «»-a ~/Pictures backup:"," 812 «d»root«» «1» 4 -20«» 410G 1.5G S 3.1 9.4 0:44.02 «d»kernel_task"," 167 «d»root«» 31 0 411G 402M S 0.9 2.5 0:12.80 «d»WindowServer"," 344 «d»_mdns«» 31 0 408G 5.1M S 0.0 0.0 0:00.33 «d»mDNSResponder"],ZC=["Help","Setup","Search","Filter","Tree","SortBy","Nice -","Nice +","Kill","Quit"];function VC(t,e,n){return`«${t}»${e}${" ".repeat(Math.max(0,n-_(e)))}`}function XC(t){let e=t-2,n=Math.floor((e-2)/2),r=(i)=>{let[o,s,a]=JC[i],c=`${((o+s+a)*100).toFixed(1)}%`;return Gp(String(i).padStart(3),[["2",o],["1",s],["4",a]],c,n)};return[...[0,1,2,3].map((i)=>`${r(i)} ${r(i+4)}`),`${Gp("Mem",[["2",0.45],["4",0.1],["3",0.07]],"9.84G/16.0G",n)} «6»Tasks: «b»214«», 1093 thr; «B2»4«» running`,`${Gp("Swp",[["1",0.15]],"0.31G/2.00G",n)} «6»Load average: «b»2.14 «»1.87 «d»1.52`,`${" ".repeat(n)} «6»Uptime: «b»3 days, 04:12:55`,"",VC("K2"," PID USER PRI NI VIRT RES S CPU% MEM% TIME+ Command",e),...YC.map((i)=>i.startsWith("«s»")?`${i}${" ".repeat(Math.max(0,e-_(i.replace(/«[^»]*»/g,""))))}`:i)]}function QC(t){let e=t-2,n="",r=0;return ZC.forEach((i,o)=>{let s=`F${o+1}`,a=i.padEnd(6);if(r+s.length+a.length<=e)n+=`«»${s}«K6»${a}`,r+=s.length+a.length}),`${n}«K6»${" ".repeat(Math.max(0,e-r))}`}function PE(t,e,n){if(t==="Editor")return DC();if(t==="Top")return XC(n);let r=Zt.find((s)=>s.name===t)?.lines??[],i=e?BC[t]:void 0,o=i?i.map((s)=>r[s]??""):r;return t==="Shell"?[...o.slice(0,-1),...UC,...o.slice(-1)]:o}function Ll(t,e){let n=[];for(let r of t){let i=cs(r,e);if(!i)continue;let o=0;n.push(i.map(([s,a])=>{let c={text:s,role:a,col:o};return o+=_(s),c}))}return n}function t8(t){let r=t-2-_("«K4» NORMAL «s» main src/theme.ts [+] ".replace(/«[^»]*»/g,""))-_("«K1» 1 «K3» 1 «s» utf-8 typescript 21:28 «K4» 80% ".replace(/«[^»]*»/g,""));return`${"«K4» NORMAL «s» main src/theme.ts [+] "}${" ".repeat(Math.max(0,r))}${"«K1» 1 «K3» 1 «s» utf-8 typescript 21:28 «K4» 80% "}`}function e8(t,e){if(t.id==="code")return[t8(e),'«d»"src/theme.ts" 26L, 912B written'];return t.id==="monitor"?[QC(e)]:[]}function n8(t,e,n){let r=Ll(e8(t,e),e),i=Math.max(0,n-r.length),o=[];for(let a of[...t.scenes].reverse()){let c=Ll(PE(a,!1,e),e),u=Ll(PE(a,!0,e),e),f=[c,u].find((l)=>o.length+l.length<=i);if(!f){if(o.length===0)o=t.tail?u.slice(u.length-i):u.slice(0,i);break}o=[...f,...o]}if(r.length===0)return o;let s=Ll(Array.from({length:i-o.length},()=>t.id==="code"?"«4»~":""),e);return[...o,...s,...r]}function fc(t){let e=uc.find((n)=>n.id===t.id);return e?n8(e,t.width,t.rows):[]}function Bp(t,e){let{text:n,ground:r}=TE(t);return n===e||r===e}function NE(t,e){let n=t.inner;return uc.map((r)=>({name:r.name,count:fc({id:r.id,name:r.name,col:n.col,row:n.row,width:n.cols,rows:n.rows}).flat().filter((i)=>Bp(i.role,e)).length}))}function TE(t){if(t==="s")return{text:1,ground:3};if(t==="c")return{text:1,ground:2};let e=/^([BK]?)(\d+)$/.exec(t);if(!e)return{text:1,ground:0};let n=4+Number(e[2]);return e[1]==="K"?{text:4,ground:n}:{text:n,ground:0}}function Up(t,e){if(e>=4){let n=/^([BK]?)(\d+)$/.exec(t);return n!==null&&Number(n[2])===e-4}return e===3&&t==="s"||e===2&&t==="c"}function Cl(t){let e=[];for(let n of t.tiles)fc(n).forEach((r,i)=>{r.forEach((o,s)=>{e.push({spot:{pane:n.id,line:i,run:s},col:o.col,text:o.text,role:o.role})})});return e}function Wp(t,e){return t.pane===e.pane&&t.line===e.line&&t.run===e.run}function HE(t,e){let n=Cl(t);return(n.find((r)=>Up(r.role,e))??n[0])?.spot}function jl(t,e){return e&&Cl(t).find((n)=>Wp(n.spot,e))?.spot}function FE(t,e,n){let r=Cl(t);if(r.length===0)return;let i=e?r.findIndex((d)=>Wp(d.spot,e)):-1;if(i<0)return r[0]?.spot;let o=r[i];if(n==="left"||n==="right")return r[(i+(n==="left"?r.length-1:1))%r.length]?.spot;if(n==="next"||n==="previous"){let d=t.tiles.map((p)=>p.id),h=d.indexOf(o.spot.pane),m=d[(h+(n==="next"?1:d.length-1))%d.length];return r.find((p)=>p.spot.pane===m)?.spot}let s=n==="up"?-1:1,a=r.filter((d)=>d.spot.pane===o.spot.pane),c=[...new Set(a.map((d)=>d.spot.line))],u=c[c.indexOf(o.spot.line)+s];if(u===void 0){let d=t.tiles.map((k)=>k.id),h=d.indexOf(o.spot.pane)+s,m=d[(h+d.length)%d.length],p=r.filter((k)=>k.spot.pane===m),b=s<0?p.at(-1)?.spot.line??0:p[0]?.spot.line??0,$=p.filter((k)=>k.spot.line===b);return($.find((k)=>k.col>=o.col)??$.at(-1))?.spot}let f=a.filter((d)=>d.spot.line===u);return(f.find((d)=>d.col<=o.col&&d.col+_(d.text)>o.col)??f.find((d)=>d.col>=o.col)??f.at(-1))?.spot}function LE(t,e){let n=Cl(t).find((r)=>Wp(r.spot,e));return n?TE(n.role):void 0}var r8={lr:"─",du:"│",dr:"╭",dl:"╮",ru:"╰",lu:"╯",dlr:"┬",lru:"┴",dru:"├",dlu:"┤",dlru:"┼"};function CE(t){let e=new Map,n=(i,o,s)=>{let a=e.get(i)??new Map;e.set(i,a);let c=a.get(o)??new Set;a.set(o,c),c.add(s)};for(let i of t)for(let o=0;o<i.length;o++){let s=i.down?i.row+o:i.row,a=i.down?i.col:i.col+o;if(o>0)n(s,a,i.down?"u":"l");if(o<i.length-1)n(s,a,i.down?"d":"r")}let r=new Map;for(let[i,o]of e){let s=new Map;for(let[a,c]of o){let u=[...c].sort().join("");s.set(a,r8[u]??(c.has("l")||c.has("r")?"─":"│"))}r.set(i,s)}return r}import{execFile as i8}from"node:child_process";import{createHash as BE}from"node:crypto";import{existsSync as o8,mkdtempSync as s8,readFileSync as Ul,rmSync as a8,statSync as UE,writeFileSync as WE}from"node:fs";import{homedir as c8,tmpdir as u8}from"node:os";import{join as _l}from"node:path";import{fileURLToPath as l8}from"node:url";import{promisify as f8}from"node:util";var Fn=f8(i8),Gl=67108864,d8=4096,qp=["image/png","image/jpeg","image/webp","image/gif","image/tiff","image/heic"],h8=["text/uri-list","text/plain;charset=utf-8","text/plain"],Kp=[...qp,"text/uri-list","text/plain"];function m8(t){try{return UE(t).isFile()}catch{return!1}}function p8(t){let e=[],n="",r="",i=!1;for(let o=0;o<t.length;o++){let s=t[o];if(r==="'")if(s==="'")r="";else n+=s;else if(r==='"')if(s==='"')r="";else if(s==="\\"&&'"\\$`'.includes(t[o+1]??""))n+=t[++o];else n+=s;else if(s==="\\"&&o+1<t.length)n+=t[++o],i=!0;else if(s==="'"||s==='"')r=s,i=!0;else if(/\s/.test(s)){if(i)e.push(n);n="",i=!1}else n+=s,i=!0}if(i)e.push(n);return e}function jE(t){if(/^file:\/\//i.test(t))try{return l8(t)}catch{return}if(t.startsWith("~/"))return _l(c8(),t.slice(2));return t.startsWith("/")?t:void 0}function Ls(t,e=m8){let n=[];for(let r of t.replace(/\r\n?/g,`
|
|
648
|
+
${u} · ${zt(f.length)} · ${d(r.length,"error")} · ${d(i.length,"warning")}`),r.length>0?1:0}async function Bv(t,e){switch(t){case void 0:hL();return;case"add":await lL(Pv(t,e));return;case"remove":fL(Pv(t,e));return;case"search":await mL(e);return;case"init":await gL(e);return;case"check":return bL(e);default:throw Error(`unknown market action ${t} — ${iL.join(", ")}, or none to list them`)}}function Pv(t,e){if(!e)throw Error(t==="add"?"market add takes a repository or a folder: ttheme market add alice/ttheme-dust":"market remove takes a market name — `ttheme market` lists them");return e}function Uv(t,e){let n=ui(t,e);return`${n} — ${zt(xn(e,n,Va(t),fe(!1)).length)}, read in place`}function Wv(t){return[...t].length===1&&t>=" "&&t!==""}function wL(t){return[...t.replace(/[\r\n\t]+/g," ")].filter(Wv).join("")}function ao(t,e,n=()=>!0){if(e==="backspace")return[...od(t)].slice(0,-1).map((r)=>r.segment).join("");if(e==="ctrl-u")return"";if(e==="ctrl-w"||e==="alt-backspace")return t.replace(/\S*\s*$/,"");return Wv(e)&&n(e)?t+e:void 0}class Xa{value;constructor(t=""){this.value=t}key(t){let e=ao(this.value,t);if(e===void 0)return!1;return this.value=e,!0}paste(t){this.value+=wL(t)}}import{performance as $L}from"node:perf_hooks";import{StringDecoder as kL}from"node:string_decoder";var yL=30,vL=50,SL=500,EL=5,Ns=Buffer.from("\x1B[M"),Il="\x1B]1337;ReportCellSize\x07\x1B[16t\x1B[14t\x1B[18t",Zv="\x1B[?1016$p\x1B[16t",Xv={A:"up",B:"down",C:"right",D:"left",H:"home",F:"end","1~":"home","7~":"home","3~":"delete","4~":"end","8~":"end","5~":"pgup","6~":"pgdn",I:"focus-in",O:"focus-out",Z:"shift-tab","1;2C":"shift-right","1;2D":"shift-left"},ML={"\r":"enter","\n":"enter","\t":"tab","\b":"backspace","":"backspace","\x1B":"esc","\x00":"ctrl-space"},Kv=/\[([0-?]*)([ -/]*)([@-~])/y,xL=/^\[[0-?]*[ -/]*$/,zv=/\[(<-?\d+;-?\d+;-?\d+)([Mm])/y,OL=/^\[<[-\d;]*$/,qv=/\](\d+)/y,IL=/^\]\d*$/,Dv=/\]\d+;/y,PL=/^1337;ReportCellSize=([\d.]+);([\d.]+)(?:;([\d.]+))?$/,RL=/^(1[0-2]|17|4;\d{1,3});(rgba?:[0-9a-fA-F/]+)$/,Qv="\x1B[200~",Ol="\x1B[201~";function NL(t){let e=ML[t];if(e)return e;let n=t.codePointAt(0)??0;if(n<27)return`ctrl-${String.fromCharCode(n+96)}`;return n<32?void 0:t}function As(t){return{kind:"key",key:t}}function Ts(t){return{events:[As("esc")],end:t+1}}function AL(t){let e={};for(let n of t.split(":")){let r=n.indexOf("=");if(r>0)e[n.slice(0,r)]=n.slice(r+1)}return e}var TL=["left","middle","right",void 0];function Mp(t,e,n,r){if(!Number.isInteger(t)||t<0||t>=128||!(e>=0)||!(n>=0))return;let i=t&3,o={kind:"mouse",row:n,col:e,shift:(t&4)!==0,alt:(t&8)!==0,ctrl:(t&16)!==0};if(t&64)return{...o,action:"wheel",button:void 0,wheel:i%2===0?-1:1,sideways:i>=2,count:0};let s=TL[i],a=t&32?s?"drag":"move":r||!s?"release":"press";return{...o,action:a,button:s,wheel:0,sideways:!1,count:a==="press"?1:0}}function HL(t,e,n){let r=[],i=e;while(r.length<3&&i<t.length){let u=t.codePointAt(i);r.push(u),i+=u>65535?2:1}if(r.length<3)return n?{events:[],end:t.length}:void 0;let[o=0,s=0,a=0]=r,c=Math.max(o,s,a)<128?Mp(o-32,s-33,a-33,!1):void 0;return{events:c?[c]:[],end:i}}function FL(t,e,n,r,i){let o=Math.max(0,e)/i.w,s=Math.max(0,n)/i.h,a=Math.floor(o),c=Math.floor(s),u=Mp(t,a,c,r);return u&&{...u,fx:o-a,fy:s-c}}function Jv(t,e,n,r){if((n==="M"||n==="m")&&e===""&&t.startsWith("<")){let[o=-1,s=0,a=0]=t.slice(1).split(";").map(Number),c=r?FL(o,s,a,n==="m",r):Mp(o,s-1,a-1,n==="m");return c?[c]:[]}if(n==="t"&&e===""){let[o,s=0,a=0]=t.split(";").map(Number),c=o===6?"cell":o===4?"window":o===8?"grid":void 0;return c?[{kind:"size",of:c,h:s,w:a}]:[]}if(n==="y"&&e==="$"&&t.startsWith("?")){let[o=0,s=0]=t.slice(1).split(";").map(Number);return[{kind:"mode",mode:o,value:s}]}if(n==="c"&&t.startsWith("?"))return[{kind:"attributes"}];let i=e===""?Xv[`${t}${n}`]:void 0;return i?[As(i)]:[]}function LL(t,e,n,r){zv.lastIndex=e+1;let i=zv.exec(t);if(i)return{events:Jv(i[1],"",i[2],r),end:e+1+i[0].length};Kv.lastIndex=e+1;let o=Kv.exec(t);if(!o){let l=t.slice(e+1);return!n&&(xL.test(l)||OL.test(l))?void 0:Ts(e)}let[s,a="",c="",u=""]=o,f=e+1+s.length;if(a===""&&c===""&&u==="M")return HL(t,f,n);if(a==="200"&&u==="~"){let l=t.indexOf(Ol,f);if(l===-1)return n?{events:[{kind:"paste",text:t.slice(f)}],end:t.length}:void 0;return{events:[{kind:"paste",text:t.slice(f,l)}],end:l+Ol.length}}return{events:Jv(a,c,u,r),end:f}}function CL(t){let e=PL.exec(t);if(e){let s=Number(e[3]??1);return[{kind:"size",of:"cell",h:Math.round(Number(e[1])*s),w:Math.round(Number(e[2])*s)}]}let n=RL.exec(t);if(n)return[{kind:"color",code:n[1],value:n[2]}];let[r="",i="",...o]=t.split(";");return[{kind:"osc",code:r,meta:AL(i),payload:o.join(";")}]}function jL(t,e,n){qv.lastIndex=e+1;let r=qv.exec(t),i=r?t[e+1+r[0].length]:void 0;if(i!==";"&&i!=="\x07"&&i!=="\x1B")return!n&&IL.test(t.slice(e+1))?void 0:Ts(e);let o=[t.indexOf("\x07",e),t.indexOf("\x1B\\",e+2)].filter((a)=>a!==-1);if(o.length===0)return n?{events:[],end:t.length}:void 0;let s=Math.min(...o);return{events:CL(t.slice(e+2,s)),end:s+(t[s]==="\x07"?1:2)}}function _L(t,e,n){let r=t[e+2];if(r===void 0)return n?Ts(e):void 0;if(!/^[A-Za-z]$/.test(r))return Ts(e);let i=Xv[r];return{events:i?[As(i)]:[],end:e+3}}function GL(t,e,n,r){let i=t[e+1];if(i===void 0)return n?Ts(e):void 0;if(i==="[")return LL(t,e,n,r);if(i==="]")return jL(t,e,n);if(i==="O")return _L(t,e,n);if(i==="")return{events:[As("alt-backspace")],end:e+2};if(/^[a-z]$/.test(i))return{events:[As(`alt-${i}`)],end:e+2};return Ts(e)}function Yv(t,e=!1,n){let r=[],i=0;while(i<t.length){if(t[i]==="\x1B"){let a=GL(t,i,e,n);if(!a)return{events:r,rest:t.slice(i)};r.push(...a.events),i=a.end;continue}let o=String.fromCodePoint(t.codePointAt(i)),s=NL(o);if(s)r.push(As(s));i+=o.length}return{events:r,rest:""}}function BL(t,e){for(let n=Math.min(Ns.length-1,t.length-e);n>0;n--)if(t.subarray(t.length-n).equals(Ns.subarray(0,n)))return t.length-n;return t.length}function UL(t){let e=[],n=0,r=t.indexOf(Ns);while(r!==-1&&r+6<=t.length){e.push(t.subarray(n,r));let[o=0,s=0,a=0]=t.subarray(r+3,r+6);if(s>32&&a>32)e.push(Buffer.from(`\x1B[<${o-32};${s-32};${a-32}M`));n=r+6,r=t.indexOf(Ns,n)}let i=r===-1?BL(t,n):r;return e.push(t.subarray(n,i)),{bytes:Buffer.concat(e),carry:i<t.length?t.subarray(i):void 0}}function Vv(t){return Dv.lastIndex=1,t.startsWith(Qv)||t.startsWith("\x1B]")&&Dv.test(t)}function WL(t,e){let n=t.slice(-Ol.length)+e;return t.startsWith(Qv)?n.includes(Ol):n.includes("\x07")||n.includes("\x1B\\")}class xp{held="";timer;carry;pressed;wheeled;utf8=new kL("utf8");burst;cell;take;constructor(t,e=()=>!1,n=()=>{return}){this.burst=e,this.cell=n,this.take=(r)=>{let i=this.counted(r);if(i.length>0)t(i)}}counted(t){let e=$L.now();return t.filter((n)=>{if(n.kind!=="mouse")return!0;if(n.action==="wheel"){let o=n.wheel*(n.sideways?2:1),s=this.wheeled;if(s!==void 0&&s.way===o&&e-s.at<EL)return!1;return this.wheeled={at:e,way:o},!0}if(n.action==="release")n.count=this.pressed?.count??0;if(n.action!=="press"||!n.button)return!0;let r=this.pressed,i=r!==void 0&&r.button===n.button&&r.row===n.row&&Math.abs(r.col-n.col)<=1&&e-r.at<=SL;return n.count=i?r.count+1:1,this.pressed={at:e,button:n.button,row:n.row,col:n.col,count:n.count},!0})}feed(t){clearTimeout(this.timer);let e=typeof t==="string"?t:this.bytes(t);if(!this.held&&!e.includes("\x1B")&&this.burst(e)){this.settle(),this.take([{kind:"paste",text:e}]);return}if(Vv(this.held)&&!WL(this.held,e)){this.held+=e;return}let{events:n,rest:r}=Yv(this.held+e,!1,this.cell());if(this.held=r,this.settle(),n.length>0)this.take(n)}settle(){let t=this.held.length+(this.carry?.length??0);if(t>0&&!Vv(this.held))this.wait(t===1?yL:vL)}bytes(t){let{bytes:e,carry:n}=UL(this.carry?Buffer.concat([this.carry,t]):t);return this.carry=n,this.utf8.write(e)}wait(t){clearTimeout(this.timer),this.timer=setTimeout(()=>this.flush(),t)}flush(){clearTimeout(this.timer);let t=this.carry;this.carry=void 0;let e=t&&!t.subarray(0,Ns.length).equals(Ns)?this.utf8.write(t):"",{events:n}=Yv(this.held+e,!0,this.cell());if(this.held="",n.length>0)this.take(n)}stop(){clearTimeout(this.timer),this.held="",this.carry=void 0}}class Qa{window;grid;see(t){if(t.kind!=="size")return;if(t.of==="cell")return{w:t.w,h:t.h};if(t.of==="window")this.window=t;else this.grid=t;let e=this.window,n=this.grid;return e&&n&&n.h>0&&n.w>0?{h:Math.floor(e.h/n.h),w:Math.floor(e.w/n.w)}:void 0}}class Op{known=!1;cell;see(t){if(t.kind==="mode"&&t.mode===1016)this.known=t.value===1||t.value===2;else if(t.kind==="size"&&t.of==="cell"&&t.w>0&&t.h>0)this.cell={w:t.w,h:t.h};else if(t.kind==="attributes")return{cell:this.known?this.cell:void 0};return}}var Rl={on:"\x1B[?1049h",off:"\x1B[?1049l"},Hn={on:"\x1B[?25l",off:"\x1B[?25h"},li={on:"\x1B[?7l",off:"\x1B[?7h"},fr={on:"\x1B[?2004h",off:"\x1B[?2004l"},oS={on:"\x1B[?1004h",off:"\x1B[?1004l"},KL={on:"\x1B[?1000h\x1B[?1002h\x1B[?1006h",off:"\x1B[?1006l\x1B[?1002l\x1B[?1000l"},tS={on:"\x1B[?1016h",off:"\x1B[?1016l\x1B[?1006h"};function fi(t=process.env){return t.TTHEME_MOUSE==="off"?[]:[KL]}var sS={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGTERM:15},zL=3000;class ec extends Error{exit;constructor(t){super(t);this.exit=128+sS[t]}}var Tn=[],co=new Map,tc=new Map,eS;function nS(t){return Tn.findLast((e)=>e.input===t)}var rS;function aS(t){for(let e of[...Tn].reverse())e.abort(t);if(!rS)rS=setTimeout(()=>{cS(),process.exit(t instanceof ec?t.exit:1)},zL).unref()}var qL=Object.fromEntries(Object.keys(sS).map((t)=>[t,()=>aS(new ec(t))]));function cS(){for(let t of[...Tn].reverse())t.close()}function DL(){for(let t of Tn)t.reassert();Tn.at(-1)?.redraw()}function iS(t){let e=t?"on":"off";for(let[n,r]of Object.entries(qL))process[e](n,r);if(process[e]("uncaughtException",aS),process[e]("exit",cS),process.platform!=="win32")process[e]("SIGCONT",DL)}function Pl(){}class uS{input;output;failed;modes=[];assumed;owned=[];keys;tty;take;resized;queued=[];asking;reject=Pl;open=!0;aborted=!1;constructor(t={}){if(this.input=t.input??process.stdin,this.output=t.output??process.stdout,this.tty=this.output.isTTY===!0&&this.input.isTTY===!0,this.assumed=t.assume??[],this.keys=new xp((r)=>this.deliver(r),t.burst,()=>co.has(tS)?eS:void 0),this.failed=new Promise((r,i)=>{this.reject=i}),this.failed.catch(Pl),this.tty&&!Tn.some((r)=>r.tty))iS(!0);Tn.push(this);let e="";for(let r of this.assumed)if(!co.has(r))e+=r.on;for(let r of t.modes??[])e+=this.claim(r);this.write(e);let n=tc.get(this.input)??0;if(n===0)this.input.setRawMode?.(!0);tc.set(this.input,n+1),this.input.on("data",this.received),this.input.resume(),this.output.on("resize",this.resizing),this.output.on("error",Pl)}hold(t){this.write(this.claim(t))}pixels(t){eS=t,this.hold(tS)}get cols(){return this.output.columns||80}get rows(){return this.output.rows||24}write(t){if(t&&this.open)this.output.write(t)}listen(t){this.take=t;let e=this.queued;if(this.queued=[],e.length>0)t(e)}onResize(t){this.resized=t}until(t){return Promise.race([t,this.failed])}loop(t,e=()=>{}){return this.until(new Promise((n)=>{let r=!1;this.listen((i)=>{for(let o of i){let s=r?void 0:t(o);if(s!==void 0)r=!0,n(s)}if(!r)e()})}))}ask(t,e,n,r=!0){return new Promise((i)=>{let o={hold:r,pick:(c)=>{let u=e(c);if(u===void 0)return!1;return s(u),!0}},s=(c)=>{if(clearTimeout(a),this.asking===o)this.asking=void 0;i(c),this.release()},a=setTimeout(()=>s(void 0),n);this.asking=o,this.write(t)})}abort(t){if(this.aborted)return;this.aborted=!0,this.keys.stop(),this.reject(t)}redraw(){this.resized?.()}reassert(){if(this.open)this.input.setRawMode?.(!0),this.write([...this.assumed,...this.owned].map((t)=>t.on).join(""))}close(){if(!this.open)return;this.keys.stop(),this.input.off("data",this.received),this.output.off("resize",this.resizing);let t="";for(let n of[...this.modes].reverse()){let r=(co.get(n)??1)-1;if(r===0)co.delete(n),t+=n.off;else co.set(n,r)}this.write(t),this.open=!1;let e=(tc.get(this.input)??1)-1;if(e===0)tc.delete(this.input),this.input.setRawMode?.(!1),this.input.pause();else tc.set(this.input,e);if(this.output.off("error",Pl),Tn.splice(Tn.indexOf(this),1),this.tty&&!Tn.some((n)=>n.tty))iS(!1)}received=(t)=>{if(nS(this.input)===this&&!this.aborted)this.keys.feed(t)};resizing=()=>{if(nS(this.input)===this)this.resized?.()};claim(t){this.modes.push(t);let e=co.get(t)??0;if(co.set(t,e+1),e>0)return"";return this.owned.push(t),t.on}deliver(t){let e=this.asking,n=e?t.filter((r)=>!e.pick(r)):t;if(n.length===0)return;if(!this.take||this.asking?.hold){this.queued.push(...n);return}this.take(n)}release(){if(this.take&&this.queued.length>0){let t=this.queued;this.queued=[],this.take(t)}}}async function di(t,e){let n=new uS(t);try{return await e(n)}finally{n.close()}}var JL=3,fS={series:{top:(t)=>t.group,shelf:(t)=>rc(t.group)?t.catalog:void 0},markets:{top:(t)=>rc(t.group)?t.group:V,shelf:(t)=>rc(t.group)?t.catalog:t.group}};function ic(t,e){return`${t}/${e}`}function lS(t){return ut(t.name)?pe(t.name):t.name}function Ip(t,e){let n=e.shelf(t);return n===void 0?void 0:ic(e.top(t),n)}function Nl(t){if(t?.kind==="palette")return`palette ${t.entry.name}`;if(t?.kind==="group")return`group ${t.name}`;if(t?.kind==="catalog")return`catalog ${ic(t.group,t.name)}`;if(t?.kind==="extra")return`extra ${t.extra.key}`;return t?.kind??""}function nc(t){return t?.kind==="rule"||t?.kind==="extra"&&t.extra.rule===!0}function Al(t,e){return Gi([t.name,t.group,t.native??"",t.catalog??"",...t.nativeNames??[],...$u(t.booru)],e)}function dS(t,e,n,r="series",i=[]){let o=fS[r],s=n.trim(),a=[],c=new Set,u=(f)=>({kind:"palette",entry:f});for(let f of t){let l=o.top(f);if(f.default||c.has(l))continue;c.add(l);let d=t.filter((b)=>!b.default&&o.top(b)===l),h=s?d.filter((b)=>Al(b,s)):d;if(s&&h.length===0)continue;let m=s.length>0||e.has(l);if(a.push({kind:"group",name:l,...l===f.group&&f.native?{native:f.native}:{},lead:d.find((b)=>b.lead)??f,expanded:m,count:h.length}),!m)continue;let p=h.filter((b)=>o.shelf(b)!==void 0);for(let b of new Set(p.map(($)=>o.shelf($)))){let $=p.filter((S)=>o.shelf(S)===b),k=$.find((S)=>S.lead)??$[0],v=s.length>0||e.has(ic(l,b));if(a.push({kind:"catalog",group:l,name:b,...!rc(k.group)&&k.native?{native:k.native}:{},lead:k,expanded:v,count:$.length}),v)a.push(...$.map(u))}a.push(...h.filter((b)=>o.shelf(b)===void 0).map(u))}for(let f of i)if(!c.has(f)&&(s===""||Gi([f],s)))a.push({kind:"group",name:f,expanded:e.has(f),count:0});return a}function YL(t,e){let n=e.trim(),r=new Set(t.filter((i)=>!i.default&&(n===""||Al(i,n))).map((i)=>i.group));return dS(t,new Set,"").filter((i)=>i.kind==="group"&&r.has(i.name))}function rc(t){return t.includes("@")}function VL(t,e,n,r,i=!0){let o=n-1;if(o<0)return t;let s;if(!Number.isFinite(e))s=e>0?o:0;else if(e>0)s=t>=o?i?0:o:Math.min(o,t+e);else s=t<=0?i?o:0:Math.max(0,t+e);if(!r(s))return s;let a=Math.sign(e),c=s+a;if(c>=0&&c<=o)return c;return i&&Math.abs(e)===1?c<0?o:0:s-a}function Tl(t,e){let n={home:Number.NEGATIVE_INFINITY,end:Number.POSITIVE_INFINITY,pgup:-e,pgdn:e};return t===void 0?void 0:n[t]}function ZL(t){let e=t.findIndex((n)=>n.kind==="group"&&rc(n.name));return e>0&&t.slice(0,e).some((n)=>n.kind==="group")?[...t.slice(0,e),{kind:"rule"},...t.slice(e)]:t}function XL(t){let e=t.findIndex((n)=>n.kind==="palette");return e===-1?0:e}function Hl(t){return t==="decode"||t==="glitch"?t:"typewriter"}function Hs(t,e,n){return qe({kind:"row",at:t,part:e},n)}class Fl{picked;scope;maxItems;named=[];series=[];layout;place;color;p;onFocus;note;badge;tops;extras;entries=[];seriesPad=0;namePad=0;expanded=new Set;rows=[];cursor=0;top=0;filter="";lastFocused="";constructor(t){this.picked=t.picked,this.scope=t.scope??"palette",this.layout=t.layout??"series",this.place=fS[this.layout],this.maxItems=t.maxItems??12,this.color=t.color??!0,this.p=xe(this.color),this.onFocus=t.onFocus,this.note=t.note,this.badge=t.badge,this.tops=t.tops,this.extras=t.extras,this.load(t.entries),this.rebuild("first")}load(t){this.entries=t,this.named=t.filter((e)=>!e.default),this.series=[...new Set(this.named.map((e)=>e.group))],this.seriesPad=Math.max(0,...this.series.map((e)=>e.length)),this.namePad=Math.max(0,...this.named.map((e)=>this.indent(e).length+lS(e).length))}indent(t){return this.place.shelf(t)===void 0?" ":" "}setEntries(t){this.load(t),this.rebuild("stay")}setFilter(t){if(t!==this.filter)this.filter=t,this.rebuild("keep")}clear(){let t=this.rows[this.cursor];if(t?.kind==="palette"&&!t.entry.default){this.expanded.add(this.place.top(t.entry));let e=Ip(t.entry,this.place);if(e!==void 0)this.expanded.add(e)}this.setFilter("")}focusedRow(){return this.rows[this.cursor]}refocus(){this.lastFocused="",this.sync()}refresh(){this.rebuild("stay")}select(t){let e=this.rows.findIndex((n)=>Nl(n)===t);if(e===-1)return!1;return this.cursor=e,this.sync(),!0}members(t,e){let n=this.scope==="palette"?this.filter.trim():"";return this.under(t,e).filter((r)=>n===""||Al(r,n))}under(t,e){return this.named.filter((n)=>this.place.top(n)===t&&(e===void 0||this.place.shelf(n)===e))}inside(t){return t.kind==="palette"?[t.entry]:t.kind==="group"?this.under(t.name):t.kind==="catalog"?this.under(t.group,t.name):[]}everyone(t){return t.flatMap((e)=>e.kind==="group"?this.members(e.name):[])}pick(){let t=this.rows[this.cursor],e=t?.kind==="palette"?[t.entry.name]:t?.kind==="group"?this.members(t.name).map((r)=>r.name):t?.kind==="catalog"?this.members(t.group,t.name).map((r)=>r.name):t?.kind==="all"?this.everyone(this.rows).map((r)=>r.name):[];if(e.length===0)return;let n=e.some((r)=>!this.picked.has(r));for(let r of e)if(n)this.picked.add(r);else this.picked.delete(r)}pickedIn(t,e){return this.members(t,e).filter((n)=>this.picked.has(n.name)).length}pickedCount(){if(this.scope==="palette")return this.named.filter((t)=>this.picked.has(t.name)).length;return this.series.filter((t)=>this.members(t).every((e)=>this.picked.has(e.name))).length}total(){return this.scope==="series"?this.series.length:this.named.length}matched(){let t=this.filter.trim();if(this.scope==="series")return this.rows.filter((e)=>e.kind==="group").length;return t?this.named.filter((e)=>Al(e,t)).length:this.named.length}sync(){let t=this.rows[this.cursor],e=t?.kind==="palette"?t.entry:t?.kind==="group"&&this.scope==="series"?t.lead:void 0;if(e&&e.name!==this.lastFocused)this.lastFocused=e.name,this.onFocus?.(e)}rebuild(t){let e=this.rows[this.cursor],n=this.scope==="series"?YL(this.entries,this.filter):dS(this.entries,this.expanded,this.filter,this.layout,this.tops?.()??[]),r=this.layout==="markets"||n.length===0?n:ZL([{kind:"all",count:this.allCount(n)},...n]);this.rows=[...r,...(this.extras?.()??[]).map((o)=>({kind:"extra",extra:o}))];let i=n.length>0?this.rows.indexOf(n[XL(n)]):0;if(t==="first")this.cursor=i;else if(t==="keep"||t==="stay"){let o=Nl(e),s=e?.kind==="palette"||t==="stay"?this.rows.findIndex((c)=>Nl(c)===o):-1,a=e?.kind==="extra"&&t==="stay";this.cursor=s!==-1?s:a?Math.min(this.cursor,this.rows.length-1):i}else if(this.cursor>=this.rows.length)this.cursor=Math.max(0,this.rows.length-1);this.settle(),this.sync()}settle(){if(!nc(this.rows[this.cursor]))return;let t=this.rows.findIndex((n,r)=>r>this.cursor&&!nc(n)),e=this.rows.findLastIndex((n,r)=>r<this.cursor&&!nc(n));this.cursor=t!==-1?t:e!==-1?e:this.cursor}allCount(t){return this.scope==="series"?t.length:this.everyone(t).length}move(t,e=!0){this.cursor=VL(this.cursor,t,this.rows.length,(n)=>nc(this.rows[n]),e),this.sync()}point(t){let e=this.rows[t];if(!e||nc(e))return!1;return this.cursor=t,this.sync(),!0}flip(){let t=this.rows[this.cursor];if(t?.kind==="group"||t?.kind==="catalog")this.fold(!t.expanded)}foldable(){let t=this.rows[this.cursor];return(t?.kind==="group"||t?.kind==="catalog")&&this.scope==="palette"&&!this.filter}open(){if(this.foldable())this.flip();else this.pick()}toggle(t){if(this.expanded.has(t))this.expanded.delete(t);else this.expanded.add(t);this.rebuild("clamp")}climb(t,e){this.expanded.delete(t),this.rebuild("clamp"),this.reach(e)}reach(t){this.cursor=Math.max(0,this.rows.findIndex((e)=>Nl(e)===t)),this.sync()}fold(t){if(this.filter||this.scope==="series")return;let e=this.rows[this.cursor];if(e?.kind==="group"){if(t!==e.expanded)this.toggle(e.name)}else if(e?.kind==="catalog"){if(t!==e.expanded)this.toggle(ic(e.group,e.name));else if(!t)this.reach(`group ${e.group}`)}else if(e?.kind==="palette"&&!t&&!e.entry.default){let n=Ip(e.entry,this.place);if(n===void 0){let r=this.place.top(e.entry);this.climb(r,`group ${r}`)}else this.climb(n,`catalog ${n}`)}}window(){if(this.cursor<this.top)this.top=this.cursor;if(this.cursor>=this.top+this.maxItems)this.top=this.cursor-this.maxItems+1;this.top=Math.min(this.top,Math.max(0,this.rows.length-this.maxItems));let t=this.rows.slice(this.top,this.top+this.maxItems);return{lines:t.map((e,n)=>this.renderRow(e,this.top+n)),above:this.top,below:this.rows.length-this.top-t.length}}renderRow(t,e){if(t.kind==="rule")return` ${this.p.dim("── Markets ──────────")}`;if(t.kind==="extra"){let n=t.extra.text(e===this.cursor,e);return t.extra.rule?n:Hs(e,"row",n)}return Hs(e,"row",this.rowText(t,e))}rowText(t,e){let n=e===this.cursor,r=t.kind==="palette"?t.entry:t.kind==="all"?void 0:t.lead,i=this.color&&n&&r!==void 0,{dim:o,bold:s}=this.p,a=(v)=>this.color?` ${Bb(pu(v),i?zn(v.foreground):wt)}`:"",c=n?i?`${zn(r.cursor)}${N.gutter}${wt} `:`${N.gutter} `:" ",u=(v)=>i?`${c}${Gb(r.selection,r.foreground)} ${v} ${se}`:`${c} ${v}`,f=(v)=>Hs(e,"box",`${v?N.on:N.off} `),l=(v)=>Hs(e,"fold",`${v?N.opened:N.closed} `);if(t.kind==="all")return u(`${f(this.everyone(this.rows).every((v)=>this.picked.has(v.name)))}Select all ${o(`(${t.count})`)}`);if(t.kind==="group"&&this.scope==="series"){let v=`(${t.count})${t.native?` ${t.native}`:""}`;return u(`${f(this.pickedIn(t.name)===t.count)}${s(t.name.padEnd(this.seriesPad))}${t.lead?a(t.lead):""}${this.color?" ":" "}${o(v)}`)}let d=this.rows[this.cursor],h=(v,S)=>this.color&&d?.kind==="palette"&&v?this.p.accent(s(S)):s(S);if(t.kind==="group"){let v=h(d?.kind==="palette"&&this.place.top(d.entry)===t.name,t.name),S=t.native?` ${o(t.native)}`:"",x=this.badge?.(t.name)??"";return u(`${l(t.expanded)}${v} ${o(`(${this.pickedIn(t.name)}/${t.count})`)}${S}${x}`)}if(t.kind==="catalog"){let v=d?.kind==="palette"&&Ip(d.entry,this.place)===ic(t.group,t.name),S=o(`(${this.pickedIn(t.group,t.name)}/${t.count})`),x=t.native?` ${o(t.native)}`:"";return u(` ${l(t.expanded)}${h(v,t.name)} ${S}${x}`)}let m=t.entry,p=this.indent(m),b=lS(m),$=this.color?b.padEnd(this.namePad-p.length):b,k=n?s($):$;return u(`${p}${f(this.picked.has(m.name))}${k}${a(m)}${this.note?.(m)??""}`)}}function Pp(t){let e=t.named[Math.floor(Math.random()*t.named.length)],n=t.series[Math.floor(Math.random()*t.series.length)];return e&&n?`${e.name} | ${n}`:""}class Ll{fx;make;redraw;roller;example="";step=0;seed=0;timer;constructor(t,e,n){this.fx=t,this.make=e,this.redraw=n,this.roll(),this.roller=setInterval(()=>{this.roll(),this.step=8,this.redraw()},3000),this.roller.unref?.()}stop(){clearInterval(this.roller),clearTimeout(this.timer)}roll(){let t=this.make();this.example=t.length>30?`${t.slice(0,29)}…`:t,this.seed=Math.floor(Math.random()*997)}text(){if(this.step===0)return this.example;if(!this.timer)this.timer=setTimeout(()=>{this.timer=void 0,this.step-=1,this.redraw()},60),this.timer.unref?.();let t=Math.floor(this.example.length*(8-this.step)/8);if(this.fx==="typewriter")return`${this.example.slice(0,t)}▏`;let e=this.fx==="decode"?"abcdefghijklmnopqrstuvwxyz":"▓▒░#*+=<>?/-_",n=this.fx==="decode"?(r)=>!/[a-z0-9]/i.test(r):(r)=>r===" ";return[...this.example].map((r,i)=>i+(i*7+this.seed)%3<t||n(r)?r:e[Math.floor(Math.random()*e.length)]??r).join("")}}var QL=5;class Rp{picked;list;scope;color;required;most;hint;field=new Xa;input;output;state="active";error="";redraw=()=>{};constructor(t){this.scope=t.scope??"palette",this.picked=new Set(t.installed??[]),this.color=t.color??!0,this.required=t.required??!1,this.most=t.maxItems??12,this.input=t.input,this.output=t.output,this.list=new Fl({entries:t.entries,picked:this.picked,scope:this.scope,maxItems:this.most,color:this.color,...t.onFocus?{onFocus:t.onFocus}:{}}),this.hint=new Ll(t.fx??"typewriter",()=>Pp(this.list),()=>this.redraw())}prompt(){return di({input:this.input,output:this.output,modes:[Hn,fr]},async(t)=>{let e=new Qm((r)=>t.write(r),()=>t.cols),n=()=>{return this.list.maxItems=Math.max(JL,Math.min(this.most,t.rows-QL)),this.draw()};this.redraw=()=>e.draw(n()),t.onResize(()=>e.redraw(n())),this.redraw();try{let r=await t.loop((i)=>{return this.take(i),this.state==="submit"||this.state==="cancel"?this.state:void 0},()=>this.redraw());return this.redraw=()=>{},e.end(this.draw()),r}finally{this.hint.stop()}})}take(t){if(t.kind==="paste"){this.field.paste(t.text),this.list.setFilter(this.field.value);return}if(t.kind!=="key")return;let e=t.key;if(this.state==="error")this.state="active";let n=Tl(e,this.list.maxItems);if(e==="esc"||e==="ctrl-c")this.state="cancel";else if(e==="enter")if(this.required&&this.picked.size===0)this.error=`Pick at least one ${this.scope}`,this.state="error";else this.state="submit";else if(e==="up"||e==="down")this.list.move(e==="up"?-1:1);else if(e==="left"||e==="right")this.list.fold(e==="right");else if(n!==void 0)this.list.move(n);else if(e===" ")this.list.pick();else if(this.field.key(e))this.list.setFilter(this.field.value)}draw(){let{dim:t,accent:e,warn:n}=xe(this.color),r=this.scope==="series"?"Series":"Catalog";if(this.state==="submit")return[`${t("◇")} ${r} ${t(`· ${this.list.pickedCount()} picked`)}`];if(this.state==="cancel")return[`${t(`◇ ${r} · cancelled`)}`];let i=this.field.value,o=`${e("◆")} ${r} ${t(`(${this.list.matched()}/${this.list.total()} · ${this.list.pickedCount()} picked)`)}`,s=this.hint.text(),a=`${e("│")} ${i?`${i}_`:t(`Search…${s?` e.g. ${s}`:""}`)}`,{lines:c,below:u}=this.list.window(),f=c.length>0?c.map((p)=>`${e("│")} ${p}`):[`${e("│")} ${t(`No ${this.scope==="series"?"series":"palettes"} match '${i}'`)}`];while(f.length<this.list.maxItems)f.push(e("│"));let l=u>0?`${e("│")} ${t(`↓ ${u} more`)}`:e("│"),d=this.scope==="series"?"":" · ←→ fold",h=this.scope==="series"?"continue":"install",m=this.state==="error"?`${e("└")} ${n(this.error)}`:`${e("└")} ${t(`↑↓ move${d} · space pick · type to filter · enter ${h} · esc cancel`)}`;return[o,a,...f,l,m]}}var Np=34,tC=72,eC=94,nC=22,hS=40,mS=10,Cl=3,pS=600,rC=500,iC=300,gS=12,bS={title:"",lines:[],brief:""};function Fs(t){let e=t.trim();if(e!==V&&!e.includes("/")&&!e.startsWith("~"))return;try{return Kr(e)}catch{return}}function wS(t){return t.charAt(0).toUpperCase()+t.slice(1)}class Ap{picked;field=new Xa;adds=new Map;removes=new Set;want=new Map;renew=new Set;updates;tuned;scope;busy=new Map;failed=new Map;peeked=new Map;peekFailed=new Map;staging=new Set;timers=new Map;refreshed=[];inflight=new Set;markets;kept;installed;startup;io;order;color;p;hub;owns;input;output;maxItems=12;paint;catalog;hint;screen;state="active";phase="browse";offset=0;started=!1;log=[];working="";stopped;beat=0;asking;leaving;goto;repos;searching=!1;searchError;searched;asked=0;help=!1;live;constructor(t){this.markets=t.markets,this.kept=t.kept,this.installed=new Set(t.installed),this.updates=new Set(t.updates??[]),this.tuned=new Set(t.tuned??[]),this.startup=t.startup,this.io=t.io,this.order=t.order??((e)=>e),this.color=t.color??!0,this.p=xe(this.color),this.hub=t.hub,this.owns=t.owns??!1,this.input=t.input,this.output=t.output,this.live=t.lookups??!0,this.paint=t.onFocus,this.picked=new Set(t.installed),this.catalog=new Fl({entries:this.entries(),picked:this.picked,layout:"markets",color:this.color,maxItems:this.maxItems,note:(e)=>this.mark(e),badge:(e)=>this.badge(e),tops:()=>this.tops(),extras:()=>this.found(),onFocus:(e)=>this.focus(e)}),this.hint=new Ll(t.fx??"typewriter",()=>Pp(this.catalog),()=>this.redraw());for(let e of t.due)this.update(e);this.lookup()}run(){let t=[...this.owns?[Rl,Hn,li]:[],fr,...fi()],e=this.owns?[]:[Hn,li];return di({input:this.input,output:this.output,modes:t,assume:e},async(n)=>{let r=new io({write:(i)=>n.write(i),view:()=>this.state==="active"?{lines:this.view(),ticking:this.phase==="applying"}:void 0,beat:()=>{this.beat+=1}});this.screen=r,n.onResize(()=>{r.reset(),r.request()}),r.now();try{return await n.loop((i)=>{if(i.kind==="key")this.key(i.key);else if(i.kind==="paste")this.pasted(i.text);else if(i.kind==="mouse")this.mouse(i,r);return this.state==="active"?void 0:this.state},()=>r.soon())}finally{r.stop(),this.screen=void 0,this.hint.stop();for(let i of this.timers.values())clearTimeout(i);this.timers.clear()}})}applied(){return this.started}lines(){return this.log}failure(){return this.stopped}next(){return this.goto}async idle(){await Promise.allSettled([...this.inflight])}result(){let t=new Set(this.entries().map((e)=>e.name));return{picked:new Set([...this.picked].filter((e)=>t.has(e))),adds:[...this.adds.values()],removes:[...this.removes],auto:Object.fromEntries(this.want),renew:[...this.renew].filter((e)=>this.updates.has(e)&&this.picked.has(e)&&t.has(e)),refreshed:this.refreshed}}key(t){if(t==="ctrl-c"){this.state="cancel";return}if(this.help){if(t==="?"||t==="esc")this.help=!1;return}if(this.leaving!==void 0){if(t==="esc")this.leaving=void 0;else if(/^[yn]$/i.test(t)){if(t.toLowerCase()==="y")this.begin();else this.goto=this.leaving,this.state="cancel";this.leaving=void 0}return}if(this.asking){if(t==="esc")this.asking=void 0;else if(/^[yn]$/i.test(t))this.answer(t.toLowerCase()==="y");return}if(this.phase!=="browse"){this.steer(t);return}let e=Tl(t,this.maxItems),n=this.catalog;if(t==="enter")if(n.foldable())n.flip();else if(this.dirty())this.phase="review",this.offset=0;else this.state="submit";else if((t==="esc"||t==="ctrl-u")&&this.field.value)this.clear();else if(t==="esc")this.state="cancel";else if(t==="?")this.help=!0;else if(e!==void 0)this.move(e);else if(t==="up"||t==="down")this.move(t==="up"?-1:1);else if(t==="left"||t==="right")n.fold(t==="right");else if(t==="tab"||t==="shift-tab"){if(this.hub)this.leave(Ck(this.hub,t==="tab"?1:-1))}else if(t==="shift-left"||t==="shift-right")this.autoUpdate(t==="shift-right");else if(t===" ")this.activate();else if(t==="delete"){let r=this.focusedMarket();if(r)this.toggleMarket(r)}else if(t==="ctrl-r")this.refresh();else if(t==="ctrl-s")this.cycle();else if(this.field.key(t))this.typed()}refresh(){let t=this.catalog.focusedRow(),e=this.focusedMarket();if(e){if(kt(e.source)&&!this.adds.has(e.source))this.update(e.source)}else if(t?.kind==="extra"){if(t.extra.found?.kind==="find")this.search()}else if(t?.kind!=="group")this.toggleRenew()}pasted(t){if(this.phase==="browse"&&!this.help&&!this.asking&&this.leaving===void 0)this.field.paste(t),this.typed()}mouse(t,e){if(this.help){if(t.action==="release")this.help=!1;return}let n=e.point(t),r=n?.target,i=this.phase==="browse"&&this.leaving===void 0&&!this.asking;if(t.action==="wheel"){if(!t.sideways&&(i||this.phase!=="browse"))this.wheel(t.wheel);return}if(!r)return;if(t.action==="press"&&t.button==="left"){if(!i)return;if(r.kind==="chip")this.scopeTo(r.source);else if(r.kind==="row")this.catalog.point(r.at),this.watch()}else if(t.action==="release"&&n?.inside){if(r.kind==="key")this.key(r.key);else if(r.kind==="page"){if(this.phase!=="browse")this.scroll(r.step*this.span());else if(i)this.move(r.step*this.maxItems)}else if(r.kind==="hub"){if(i&&this.hub&&r.tab!==this.hub)this.leave(jk(r.tab))}else if(r.kind==="row"&&i)this.openRow(r,t.count)}}wheel(t){if(this.phase!=="browse"){this.scroll(t);return}this.move(t,!1)}openRow(t,e){let n=this.catalog;if(n.focusedRow()?.kind==="extra"){if(t.part==="box"||e===2)this.activate()}else if(t.part==="box")n.pick();else if(t.part==="fold")n.flip();else if(e===2)n.open()}typed(){this.catalog.setFilter(this.field.value),this.later("search",pS,()=>this.lookup()),this.watch()}clear(){this.field.value="",this.catalog.clear(),this.later("search",pS,()=>this.lookup()),this.watch()}redraw(){if(this.state==="active")this.screen?.request()}focus(t){if(this.state!=="submit"&&this.state!=="cancel")this.paint?.(t)}track(t){this.inflight.add(t);let e=()=>this.inflight.delete(t);return t.then(e,e),t}active(){return[...this.markets.filter((t)=>!this.removes.has(t.source)),...this.adds.values()]}entries(){let t=this.active().flatMap((i)=>i.entries),e=new Set(t.map((i)=>i.name)),n=new Map,r=this.markets.filter((i)=>this.removes.has(i.source)).flatMap((i)=>i.entries);for(let i of[...this.kept,...r])if(this.installed.has(i.name)&&!e.has(i.name))n.set(i.name,i);return this.order([...t,...n.values()])}scoped(t){let e=this.scope,n=e===void 0?void 0:this.active().find((i)=>i.source===e);if(!n)return this.scope=void 0,t;let r=new Set(n.entries.map((i)=>i.name));return t.filter((i)=>r.has(i.name))}reload(){this.catalog.setEntries(this.scoped(this.entries()))}chips(){let t=this.active().map((e)=>({source:e.source,label:e.id,count:e.entries.filter((n)=>!n.default).length}));return[{source:void 0,label:"All",count:this.entries().filter((e)=>!e.default).length},...t]}tops(){return[...this.markets,...this.adds.values()].filter((t)=>this.scope===void 0||t.source===this.scope).map((t)=>t.id)}marketNamed(t){return[...this.markets,...this.adds.values()].find((e)=>e.id===t)}focusedMarket(){let t=this.catalog.focusedRow();return t?.kind==="group"?this.marketNamed(t.name):void 0}cycle(){if(this.active().length<2)return;let t=this.chips(),e=Math.max(0,t.findIndex((n)=>n.source===this.scope));this.scopeTo(t[(e+1)%t.length]?.source)}scopeTo(t){this.scope=t,this.reload(),this.catalog.refocus()}move(t,e=!0){this.catalog.move(t,e),this.watch()}autoUpdate(t){let e=this.focusedMarket();if(e&&kt(e.source))if(t===e.auto)this.want.delete(e.source);else this.want.set(e.source,t)}activate(){let t=this.catalog.focusedRow();if(t?.kind!=="extra"){this.catalog.pick();return}let e=t.extra.found;if(e?.kind==="add")this.load(e.source,!0);else if(e?.kind==="repo"){let n=this.known(e.source);if(n)this.catalog.select(`group ${n.id}`);else this.load(e.source,!0)}else if(e?.kind==="find")this.search()}toggleMarket(t){if(this.adds.has(t.source))this.adds.delete(t.source),this.want.delete(t.source);else if(this.removes.has(t.source))this.removes.delete(t.source);else this.removes.add(t.source);this.reload()}known(t){return[...this.markets,...this.adds.values()].find((e)=>ns(e.source,t))}load(t,e){let n=this.peeked.get(t);if(n){if(e)this.arrive(t,n);return}if(e)this.staging.add(t);if(this.busy.has(t))return;this.failed.delete(t),this.peekFailed.delete(t),this.busy.set(t,"Fetching…"),this.track(this.io.fetch(t)).then((r)=>{if(this.busy.delete(t),this.peeked.set(t,r),this.staging.delete(t))this.arrive(t,r);this.redraw()},(r)=>{if(this.busy.delete(t),this.staging.delete(t))this.failed.set(t,r.message);else this.peekFailed.set(t,r.message);this.redraw()})}arrive(t,e){let n=this.active().find((r)=>r.id===e.id);if(n)this.failed.set(t,`${e.id} already names the market at ${n.shown}`);else if(Tt(t)||t===V)this.stage(e,e.auto);else this.asking=e;this.redraw()}later(t,e,n){this.cancel(t),this.timers.set(t,setTimeout(()=>{if(this.timers.delete(t),this.state!=="submit"&&this.state!=="cancel")n()},e))}cancel(t){clearTimeout(this.timers.get(t)),this.timers.delete(t)}wants(t){return!this.known(t)&&!this.peeked.has(t)&&!this.busy.has(t)&&!this.peekFailed.has(t)}focusedFound(){let t=this.catalog.focusedRow();return t?.kind==="extra"?t.extra.found:void 0}watch(){if(!this.live)return;let t=Fs(this.field.value);if(t&&this.wants(t))this.later("typed",rC,()=>this.load(t,!1));else this.cancel("typed");let e=this.focusedFound();if(e?.kind==="repo"&&this.wants(e.source)){let n=e.source;this.later("focus",iC,()=>{let r=this.focusedFound();if(r?.kind==="repo"&&r.source===n)this.load(n,!1)})}else this.cancel("focus")}answer(t){let e=this.asking;if(this.asking=void 0,e)this.stage(e,t)}stage(t,e){if(this.adds.set(t.source,t),e===t.auto)this.want.delete(t.source);else this.want.set(t.source,e);let n=Fs(this.field.value);if(n&&ns(n,t.source))this.field.value="",this.catalog.setFilter("");this.reload(),this.catalog.select(`group ${t.id}`)}update(t){if(this.busy.has(t))return;this.failed.delete(t),this.busy.set(t,"Updating…"),this.track(this.io.refresh(t)).then(({market:e,refreshed:n,updates:r})=>{this.busy.delete(t),this.updates=new Set(r),this.markets=this.markets.map((i)=>i.source===t?e:i),this.refreshed.push(n),this.reload(),this.redraw()},(e)=>{this.busy.delete(t),this.failed.set(t,`Update failed: ${e.message}`),this.redraw()})}wanted(){let t=this.field.value.trim();return t&&!Fs(t)?t:""}lookup(){if(this.live&&this.searched!==this.wanted())this.search()}search(){let t=this.wanted(),e=++this.asked;this.searched=t,this.searching=!0,this.searchError=void 0,this.track(this.io.search(t||void 0)).then((n)=>{if(e===this.asked)this.searching=!1,this.repos=n,this.catalog.refresh(),this.watch(),this.redraw()},(n)=>{if(e===this.asked)this.searching=!1,this.searchError=n.message,this.redraw()})}found(){let t=Fs(this.field.value),e=(...i)=>Gi(i,this.field.value),n=(this.repos??[]).map((i)=>({repo:i,source:Sp(i)})).filter(({repo:i,source:o})=>e(o,i.description??"")),r=[...t&&!this.known(t)?[{kind:"add",source:t}]:[],...n.map(({repo:i,source:o})=>({kind:"repo",repo:i,source:o})),...n.length>0?[]:[{kind:"find"}]];return[{key:"github",rule:!0,text:()=>` ${this.p.dim(`── On GitHub${this.searching?" · searching…":""} ──────────`)}`},...r.map((i)=>({key:i.kind==="find"?"find":`${i.kind} ${i.source}`,found:i,text:(o,s)=>this.foundLine(i,o,s)}))]}lit(t,e){return`${t?`${N.gutter} `:" "} ${e}`}status(t){return this.adds.has(t.source)?"Will add":this.removes.has(t.source)?"Will remove":this.busy.get(t.source)??(this.failed.has(t.source)||t.status.startsWith("update failed")?"Update failed":"")}badge(t){let e=this.marketNamed(t);if(!e)return"";return[kt(e.source)&&(this.want.get(e.source)??e.auto)?`${N.auto} auto-update`:"",this.status(e)].filter(Boolean).map((r)=>` ${this.p.dim(r)}`).join("")}peeking(t){let e=this.peeked.get(t);return e?zt(e.entries.filter((n)=>!n.default).length):""}foundLine(t,e,n){let r=(a)=>Hs(n,"box",`${a} `),i=(a)=>a?` ${this.p.dim(a)}`:"";if(t.kind==="add"){let a=this.failed.get(t.source)??this.peekFailed.get(t.source),c=this.peeked.get(t.source),u=a?` ${this.p.error(a)}`:i(this.busy.get(t.source)??(c?`${c.id} · ${this.peeking(t.source)}`:this.live?"Fetching its palettes…":"space fetches its palettes"));return this.lit(e,`${r("+")}Add ${rt(t.source)}${u}`)}if(t.kind==="find"){let a=this.field.value.trim(),c=a&&!Fs(a),u=!this.searching&&!this.searchError&&this.repos===void 0,f=this.searching?"Searching GitHub…":this.searchError?"GitHub search failed":u?c?`Find "${a}" on GitHub`:"Find markets on GitHub":c?`No market on GitHub matches "${a}"`:"No market on GitHub yet",l=this.searchError??(this.searching?"":u?"space searches":"space searches again");return this.lit(e,`${r(N.search)}${f}${i(l)}`)}let s=[this.busy.get(t.source)??this.peeking(t.source),t.repo.description??""].filter(Boolean).join(" · ");return this.lit(e,`${r(this.known(t.source)?N.on:N.off)}${t.source} ${this.p.dim(`${N.star}${t.repo.stargazers_count}`)}${i(s)}`)}changes(){return this.adds.size+this.removes.size+this.want.size}dirty(){let{picked:t,renew:e}=this.result();return this.changes()>0||e.length>0||t.size!==this.installed.size||[...t].some((n)=>!this.installed.has(n))}mark(t){let e=this.tuned.has(t.name)?` ${this.p.warn(N.on)}`:"";if(!this.updates.has(t.name)||!this.installed.has(t.name))return e;return`${e}${this.renew.has(t.name)?` ${this.p.bold(`${N.update} update`)}`:` ${this.p.dim(N.update)}`}`}toggleRenew(){let t=this.catalog,e=t.focusedRow(),n=(e?t.inside(e):[]).map((i)=>i.name).filter((i)=>this.updates.has(i)&&this.installed.has(i));if(n.length===0)return;let r=n.some((i)=>!this.renew.has(i));for(let i of n)if(r)this.renew.add(i);else this.renew.delete(i)}leave(t){if(this.dirty()){this.leaving=t;return}this.goto=t,this.state="cancel"}steer(t){if(this.phase==="review"){if(t==="enter")this.begin();else if(t==="esc")this.phase="browse"}else if(this.phase==="done"&&(t==="enter"||t==="esc"))this.state="submit";let e=t==="up"?-1:t==="down"?1:Tl(t,this.span());if(e!==void 0)this.scroll(e)}scroll(t){this.offset=Number.isFinite(t)?Math.max(0,this.offset+t):t>0?Number.MAX_SAFE_INTEGER:0,this.redraw()}span(){return Math.max(Cl,this.rows()-(this.hub?1:0)-4)}begin(){this.phase="applying",this.started=!0,this.offset=0,this.log=[],this.working="";let t={say:(e)=>{this.log.push(...e.split(`
|
|
649
|
+
`)),this.redraw()},status:(e)=>{this.working=e,this.redraw()}};this.track(this.io.apply(this.result(),t)).then(()=>this.ended(),(e)=>this.ended(e))}ended(t){this.working="",this.stopped=t,this.phase="done",this.offset=0,this.redraw()}pending(){let t=this.entries().filter((e)=>!e.default);return{names:t.filter((e)=>this.picked.has(e.name)&&!this.installed.has(e.name)),dropped:t.filter((e)=>this.installed.has(e.name)&&!this.picked.has(e.name))}}marketChanges(){let t=[];for(let e of this.adds.values()){let n=e.source!==V&&(this.want.get(e.source)??e.auto)?"updates on its own":"";t.push(`+ ${e.id} ${this.p.dim([e.source===V?"The ttheme catalog":e.shown,zt(e.entries.filter((r)=>!r.default).length),n].filter(Boolean).join(" · "))}`)}for(let e of this.removes){let n=this.markets.find((i)=>i.source===e),r=(n?.entries??[]).filter((i)=>!i.default&&this.installed.has(i.name)&&this.picked.has(i.name));t.push(`- ${n?.id??e} ${this.p.dim([n?.shown??rt(e),r.length>0?`its ${zt(r.length)} installed keep working`:""].filter(Boolean).join(" · "))}`)}for(let[e,n]of this.want){let r=this.markets.find((i)=>i.source===e);if(r&&!this.removes.has(e))t.push(`${N.auto} ${r.id} ${this.p.dim(n?"updates on its own from now":"stops updating on its own")}`)}return t}reviewLines(){let t=this.marketChanges(),{names:e,dropped:n}=this.pending(),r=new Set(this.result().renew),i=this.entries().filter((c)=>r.has(c.name)),o=Math.max(0,...[...e,...n,...i].map((c)=>c.name.length)),s=(c,u)=>` ${c} ${u.name.padEnd(o)} ${this.p.dim(ut(u.name)?u.catalog??"":u.group)}`,a=[e.length>0?`${e.length} to install`:"",n.length>0?`${n.length} to remove`:"",i.length>0?`${i.length} to update`:""].filter(Boolean);return[...t.length>0?[` ${this.p.bold("Markets")} ${this.p.dim(`(${t.length})`)}`,...t.map((c)=>` ${c}`),""]:[],...a.length>0?[` ${this.p.bold("Palettes")} ${this.p.dim(`(${a.join(" · ")})`)}`,...e.map((c)=>s("+",c)),...n.map((c)=>s("-",c)),...i.map((c)=>s(N.update,c))]:[]]}summary(){let{names:t,dropped:e}=this.pending(),n=this.adds.size;return[n>0?`${n} market${n===1?"":"s"} added`:"",this.removes.size>0?`${this.removes.size} removed`:"",t.length>0?`${t.length} installed`:"",e.length>0?`${e.length} removed`:"",this.result().renew.length>0?`${this.result().renew.length} updated`:""].filter(Boolean).join(" · ")}progressLines(){let t=this.log.map((e)=>` ${e}`);if(this.phase==="applying"){let e=Kn[this.beat%Kn.length];t.push(` ${this.p.dim(`${e} ${this.working||"Working…"}`)}`)}else if(this.stopped)t.push("",...Et(this.stopped.message,Math.max(20,this.columns()-6)).map((e,n)=>` ${n===0?this.p.error(N.miss):" "} ${e}`));return t}frame(t,e){let n=t-1,r=this.phase==="review",i=r?this.reviewLines():this.progressLines(),o=this.phase==="review"?`${this.p.bold("Review changes")}`:this.phase==="applying"?this.p.bold("Applying changes"):this.stopped?`${this.p.error(N.miss)} ${this.p.bold("Stopped")}`:`${this.p.bold(`${N.ok} Applied`)} ${this.p.dim(this.summary()?`(${this.summary()})`:"")}`,s=this.span(),a=Math.max(0,i.length-s),c=this.phase==="applying"?a:Math.min(this.offset,a);this.offset=c;let u=i.slice(c,c+s),f=i.length-c-u.length,l=[c>0?` ${this.more(-1,`↑ ${c} more`)}`:"",...u];while(l.length<s+1)l.push("");l.push(f>0?` ${this.more(1,`↓ ${f} more`)}`:"");let d=a>0?[["↑↓","scroll"]]:[],h=r?{badge:"BROWSE (APPLY)",keys:[...d,["enter","apply"]],right:["esc","back"]}:this.phase==="applying"?{badge:"BROWSE (APPLY)",note:"Keys wait until it ends",keys:[]}:{badge:"BROWSE (APPLY)",keys:d,right:["enter","close"]};return[...this.hub?[tt(Fh(this.hub,this.color),n,!1)]:[],tt(` ${o}`,n,!1),...l.map((m)=>tt(m,n,!1)),` ${this.keyBar(h,n-1)}`].slice(0,e).join(`
|
|
650
|
+
`)}keyBar(t,e){let n=`${De(this.p,t.badge)}${this.color?" ":" "}`,r=([a,c])=>Fk(this.p,a,c),{note:i,keys:o,right:s}=t;for(;;){let a=`${n}${[t.lead??"",i?this.p.dim(i):"",...o.map(r)].filter(Boolean).join(" ")}`,c=s?r(s):"";if(G(a)+(s?3+G(c):0)<=e)return s?Ot(a,c,e):tt(a,e,!1);if(i)i=void 0;else if(o.length>2||!s&&o.length>1){let u=o.length-2;o=o.filter((f,l)=>l!==u)}else if(s)s=void 0;else return tt(a,e,!1)}}more(t,e){return this.p.dim(qe({kind:"page",step:t},e))}counts(){let t=[...this.busy.values()].includes("Updating…")?"Updating… · ":"",e=this.catalog;return`${t}${e.matched()}/${e.total()} · ${e.pickedCount()} picked`}searchText(){let t=this.field.value;if(t)return`${t}_`;let e=this.hint.text();return this.p.dim(`Search…${e?` e.g. ${e}`:""}`)}heading(){return`${this.p.bold("Browse")} ${this.p.dim(`(${this.counts()})`)}`}searchBox(t){let e=(r,i)=>this.p.dim(`${r}${"─".repeat(t-2)}${i}`),n=this.p.dim("│");return[e("╭","╮"),`${n} ${tt(`${this.p.dim(N.search)} ${this.searchText()}`,t-4)} ${n}`,e("╰","╯")]}strip(t){if(this.active().length<2)return;let e=this.chips(),n=Math.max(0,e.findIndex((p)=>p.source===this.scope)),r=e.map((p,b)=>b===n&&!this.color?`[${p.label} ${p.count}]`:`${p.label} ${p.count}`),i=" · ",o=(p)=>p>0?`${i}+${p} more`.length:0,s=(p)=>{let b=p>0?2:0,$=0;for(let k=p;k<r.length;k++){let v=b+($>0?i.length:0)+r[k].length;if(v+o(r.length-k-1)>t)break;b=v,$+=1}return $},a=0;while(a<n&&a+s(a)<=n)a+=1;let c=Math.max(1,s(a)),u=r.slice(a,a+c),f=r.length-a-c,l=u.map((p,b)=>{let $=qe({kind:"chip",source:e[a+b]?.source},p);if(a+b===n)return this.p.accent(this.p.bold($));return this.p.dim($)}),d=`${a>0?`${this.p.dim(Ct("ctrl+s","…"))} `:""}${l.join(this.p.dim(i))}${f>0?this.p.dim(`${i}${Ct("ctrl+s",`+${f} more`)}`):""}`,h=(a>0?2:0)+u.join(i).length+o(f),m="ctrl+s market";return h+2+m.length<=t?`${d} ${this.p.dim(Ct("ctrl+s",m))}`:d}sourceOf(t){let e=t&&this.active().find((n)=>n.entries.some((r)=>r.name===t.name));if(!e)return"In no market you added";return e.source===V?"The ttheme catalog":e.shown}paletteState(t){let e=this.picked.has(t.name),n=this.installed.has(t.name),r=e&&n?"Installed":e?"Will install":n?"Will remove":"Not installed",i=e&&n&&this.updates.has(t.name)?this.renew.has(t.name)?" · Will update":" · Update ready":"";return`${r}${i}${this.startup===t.name?" · Default":""}`}detail(t){let e=this.catalog.focusedRow();if(!e||e.kind==="rule"||e.kind==="all")return bS;if(e.kind==="extra")return e.extra.found?this.foundDetail(e.extra.found,t):bS;let n=e.kind==="group"?this.marketNamed(e.name):void 0;if(n)return this.marketDetail(n,t);if(e.kind==="group"||e.kind==="catalog"){let f=this.catalog.inside(e),l=this.sourceOf(e.lead),d=`${zt(f.length)} · ${f.filter((m)=>this.installed.has(m.name)).length} installed`,h=e.kind==="catalog"?e.group:void 0;return{title:this.p.bold(e.name),lines:[...e.native?Et(e.native,t).map((m)=>this.p.dim(m)):[],...h?[h]:[],...Et(l,t),d],brief:`${h??l} · ${d}`}}let r=e.entry,i=this.sourceOf(r),o=Ia(r),s=`Gate ${Pe.length-o.length}/${Pe.length}`,a=r.pictures?.length??0,c=[...a>0?[`${a} picture${a===1?"":"s"}`]:[],...r.base?[`Base ${r.base}`]:[]].join(" · "),u=ut(r.name)?r.catalog?[r.catalog]:[]:[r.group,...r.native?[this.p.dim(r.native)]:[]];return{title:this.color?this.p.bold(`${zn(r.cursor)}${r.name}${wt}`):r.name,lines:[...Et(i,t),...u,this.paletteState(r),"",o.length===0?`${s} · passes`:s,...o.flatMap((f)=>Et(f,t-2).map((l,d)=>`${d===0?this.p.bold(N.miss):" "} ${l}`)),...c?["",c]:[]],brief:[i,s,...c?[c]:[],this.paletteState(r)].join(" · ")}}marketDetail(t,e){let n=t.source===V?"The ttheme catalog":t.shown,r=t.entries.filter((f)=>!f.default),i=r.filter((f)=>this.installed.has(f.name)).map((f)=>f.name),o=`${zt(r.length)} · ${i.length} installed`,s=kt(t.source)?`Auto-update ${this.want.get(t.source)??t.auto?"on":"off"}`:wS(t.status),a=this.busy.get(t.source)??wS(t.status),c=this.failed.get(t.source),u=this.adds.has(t.source)?["Will add"]:this.removes.has(t.source)?[i.length>0?`Will remove — ${i.join(", ")} stay${i.length===1?"s":""} installed`:"Will remove"]:this.want.has(t.source)?[`Auto-update turns ${this.want.get(t.source)?"on":"off"}`]:[];return{title:this.p.bold(t.id),lines:[...Et(n,e),...t.description?Et(t.description,e).map((f)=>this.p.dim(f)):[],o,"",kt(t.source)?`${s} ${this.p.dim("⇧←→")}`:s,...kt(t.source)?[a]:[],...c?Et(c,e).map((f)=>this.p.error(f)):[],...u.length>0?["",...u.flatMap((f)=>Et(f,e))]:[]],brief:[n,s,...u,...kt(t.source)?[a]:[]].join(" · ")}}foundDetail(t,e){if(t.kind==="add"){let i=this.busy.get(t.source)??this.failed.get(t.source)??this.peekFailed.get(t.source)??(this.peeked.has(t.source)?"space adds it":this.live?"Fetching its palettes…":"space fetches its palettes");return{title:this.p.bold(rt(t.source)),lines:["Not added",...this.peekLines(t.source,e),"",...Et(i,e)],brief:[this.peeking(t.source),i].filter(Boolean).join(" · ")}}if(t.kind==="find"){let i=this.field.value.trim(),o=this.searchError??(this.searching?"Searching…":this.repos?`${this.repos.length} found · space searches again`:"space searches GitHub");return{title:this.p.bold("GitHub"),lines:[...Et(`Repositories with the ${ts} topic`,e),...i&&!Fs(i)?[`Matching "${i}"`]:[],"",...Et(o,e),"",...Et("Type owner/repo or a folder to add one",e)],brief:o}}let r=this.known(t.source)?"Added":this.busy.get(t.source)??this.failed.get(t.source)??this.peekFailed.get(t.source)??"space adds it";return{title:this.p.bold(t.source),lines:[`★ ${t.repo.stargazers_count}`,...Et(t.repo.description??"",e),...this.peekLines(t.source,e),"",...Et(r,e)],brief:[this.peeking(t.source),r].filter(Boolean).join(" · ")}}peekLines(t,e){let n=this.peeked.get(t);if(!n)return[];let r=n.entries.filter((o)=>!o.default),i=`${r.slice(0,gS).map((o)=>pe(o.name)).join(", ")}${r.length>gS?", …":""}`;return["",n.id,...n.description?Et(n.description,e):[],zt(r.length),...Et(i,e).map((o)=>this.p.dim(o))]}footer(){if(this.help)return{badge:"HELP",keys:[],right:["? esc","close"]};if(this.leaving!==void 0)return{badge:"BROWSE",lead:"Apply your changes before you leave?",keys:[["y","apply"],["n","discard"]],right:["esc","stay"]};if(this.asking)return{badge:"BROWSE",lead:`Update ${this.asking.id} on its own when its author changes it?`,keys:[["y","yes"],["n","no"]],right:["esc","back"]};let t=this.field.value,e=["enter",this.dirty()?"apply":"close"],n=[...t?[["bksp","edit"]]:[],["?","keys"]];return{badge:t?"BROWSE (FILTER)":"BROWSE",keys:[...this.rowKeys(e),...n],right:t?["esc","clear filter"]:["esc","cancel"]}}rowKeys(t){let e=this.catalog,n=e.focusedRow();if(!n)return[t];if(n.kind==="extra"){let s=n.extra.found;if(s?.kind==="find")return[["space","search"],t];if(s?.kind==="add"||s?.kind==="repo"&&!this.known(s.source))return[["space","add"],t];return[t]}let r=e.foldable()&&(n.kind==="group"||n.kind==="catalog")?[n.expanded?["←","close"]:["→","open"]]:[],i=this.focusedMarket();if(i){let s=kt(i.source),a=this.adds.has(i.source)||this.removes.has(i.source);return[...r,["space","pick"],...s?[["⇧←→","auto-update"]]:[],...s&&!this.adds.has(i.source)?[["ctrl+r","update"]]:[],["del",a?"undo":"remove"],...r.length>0?[]:[t]]}if(r.length>0)return[...r,["space","pick"]];let o=n.kind==="palette"&&this.updates.has(n.entry.name)&&this.installed.has(n.entry.name);return[["space","pick"],...o?[["ctrl+r",this.renew.has(n.entry.name)?"keep":"update"]]:[],t]}columns(){return(this.output??process.stdout).columns??100}rows(){return(this.output??process.stdout).rows??24}fitItems(t){let e=Math.max(Cl,this.rows()-t);this.maxItems=e,this.catalog.maxItems=e}view(){let t=this.draw().split(`
|
|
651
|
+
`);return Array.from({length:this.rows()},(e,n)=>t[n]??"")}small(t,e,n){return`Needs ${hS}×${n} — now ${t}×${e}
|
|
652
|
+
${this.p.dim("esc cancels")}`}draw(){let t=this.columns(),e=this.rows();if(t<hS||e<mS)return this.small(t,e,mS);if(this.phase!=="browse")return this.frame(t,e);let n=t>=eC,r=t-1,i=n?Math.min(t-Np-4,tC):r,o=this.strip(r-1),s=[...e>=nC?[` ${this.heading()}`,...this.searchBox(t-3).map((b)=>` ${b}`)]:[Ot(` ${this.p.dim(N.search)} ${this.searchText()}`,this.p.dim(this.counts()),r)],...o?[` ${o}`]:[]],a=s.length+3+(n?0:1)+(this.hub?1:0);if(e<a+Cl)return this.small(t,e,a+Cl);this.fitItems(a);let{lines:c,above:u,below:f}=this.catalog.window(),l=c.map((b)=>` ${b}`);while(l.length<this.maxItems)l.push("");let d=[u>0?` ${this.more(-1,`↑ ${u} more`)}`:"",...l,f>0?` ${this.more(1,`↓ ${f} more`)}`:""],h=this.detail(n?Np:i-2),m=n?d.map((b,$)=>`${tt(b,i)} ${this.p.dim("│")} ${tt($===0?h.title:h.lines[$-1]??"",Np,!1)}`):[...d.map((b)=>tt(b,i,!1)),tt(` ${this.p.dim(h.brief)}`,i,!1)],p=[...this.hub?[tt(Fh(this.hub,this.color),r,!1)]:[],...s.map((b)=>tt(b,r,!1)),...m,` ${this.keyBar(this.footer(),r-1)}`];return(this.help?this.helpBox(p,t,e,p.length-m.length-1):p).join(`
|
|
653
|
+
`)}helpRows(){return[["Move","↑↓ home end pgup pgdn"],["Open","←→ · enter on a market or a series"],["Pick","space · a palette, a series, a market"],["Filter","Any text · bksp · ctrl-u clears"],...this.active().length>=2?[["Scope","ctrl+s · one market, then all"]]:[],["Market","⇧←→ auto-update · ctrl+r updates it"],["","del removes it · again to undo"],["Add","owner/repo, a folder, or a row on GitHub"],["","space adds it · ctrl+r searches again"],["Update","ctrl+r on a palette marked ↑"],["Apply","enter reviews and applies · esc cancels"],...this.hub?[["Screens","tab · shift+tab"]]:[],["Close","? esc"]]}helpBox(t,e,n,r){let i=this.helpRows(),o=Math.min(e-2,58),s=Math.floor((e-o)/2),a=`│${" ".repeat(o-2)}│`,c=[`╭─ Help ${"─".repeat(o-9)}╮`,a,...i.map(([f,l])=>`│${tt(` ${this.p.bold(f.padEnd(10))}${l}`,o-4)} │`),a,`╰${"─".repeat(o-2)}╯`],u=Math.max(0,Math.min(Math.max(r,Math.floor((n-c.length)/2)),n-1-c.length));return t.map((f,l)=>{let d=c[l-u];return d===void 0?f:`${Wb(f,s)}${d}`})}}import{existsSync as y6}from"node:fs";import{existsSync as Tc,mkdirSync as i6,readFileSync as _g}from"node:fs";import{dirname as o6}from"node:path";class de extends Error{}import{closeSync as M3,mkdtempSync as x3,openSync as O3,readSync as I3,rmSync as jE}from"node:fs";import{homedir as P3,tmpdir as R3}from"node:os";import{join as _E}from"node:path";import{readFileSync as oC}from"node:fs";var vt={pitch:25,cols:22,rows:9,height:13},lo={cols:25,rows:21},Se={cols:10,rows:3,pitch:12,top:4},ve=Se.top+Se.rows+1,sC=1073741824,_p=2147483648,aC=-1073741826,cC=1600,uC=56,lC=4,$S=20,fC=50,kS=[["space","unfolds a set of ×N"],["o","opens the post page in a browser"],["c","switches between cutouts and every post"],["a","opens the advanced filters"],["1-9","turn a tag of the tags row on or off"],["ctrl+v","tries on a picture from the clipboard — or drop one on the window"]];function Gp(t){return Math.max(0,Math.floor((t-1)/Se.pitch))}function dr(t,e){let n=e-ve-2;return{perRow:Math.max(1,Math.floor((t-1)/vt.pitch)),rowsVis:Math.max(1,Math.floor(n/vt.height)),height:n}}function Bl(t,e=!0){if(e)return`\x1B_Ga=t,t=f,f=100,i=${t.id},q=2;${Buffer.from(t.path).toString("base64")}\x1B\\`;let n;try{n=oC(t.path).toString("base64")}catch{return}let r=n.match(/.{1,4096}/g)??[""];return r.map((i,o)=>{let s=o<r.length-1?1:0;return o===0?`\x1B_Ga=t,f=100,i=${t.id},m=${s},q=2;${i}\x1B\\`:`\x1B_Gm=${s},q=2;${i}\x1B\\`}).join("")}function IS(t,e){let n=t.crop===void 0?"":`,x=0,y=${t.crop*e.h},w=${t.cols*e.w},h=${t.rows*e.h}`;return`\x1B[${t.row+1};${t.col+1}H\x1B_Ga=p,i=${t.id},p=${t.id}${n},c=${t.cols},r=${t.rows},C=1,z=${t.z},q=2\x1B\\`}function Bp(t){return`\x1B_Ga=d,d=i,i=${t},p=${t},q=2\x1B\\`}function fc(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}var Pt=bt("bold"),W=bt("dim"),cc=bt("ok"),Fn=bt("warn"),sc=zn,Gl=nd,Hp=!1;function Ul(t){return Hp=!0,t.beat}function Ls(t){return Kn[Ul(t)%Kn.length]}function dt(t){return G(t)}function Fp(t,e){if(G(t)<=e)return t;let n="";for(let r of t){if(G(n+r)>e)break;n+=r}return n}function hi(t){return Si(t)}function Up(t){return`${bt("reverse")}${Si(t)}`}function fo(t,e,n,r){return n?[[`${N.link} `,r,void 0,{kind:"link",url:n}],[t,e,n]]:[[t,e]]}function Tp(t){let e=Th(t);return e?{kind:"key",key:e}:void 0}function Lp(t){return t.reduce((e,[n])=>e+dt(n),0)}function dC(t,e){let n=[],r=e;for(let[i,o,s,a]of t){let c=dt(i);if(c<=r){n.push([i,o,s,a]),r-=c;continue}n.push([`${Fp(i,r)}…`,o,s,a]);break}return n}class _l{parts=[];cols;constructor(t){this.cols=t}put(t,e,n="",r,i){let o=e.replace(/\p{Cc}/gu,"");return this.parts.push({col:t,text:o,sgr:n,...r?{link:r}:{},...i?{spot:i}:{}}),t+dt(o)}run(t,e){let n=t;for(let[r,i,o,s]of e)n=this.put(n,r,i,o,s);return n}mark(t,e,n){this.parts.push({col:t,text:" ".repeat(Math.max(0,e)),sgr:"",spot:n,hidden:!0})}zones(t){return this.parts.flatMap(({col:e,text:n,link:r,spot:i})=>{let o=i??(r?{kind:"link",url:r}:void 0),s=e>=0&&e<this.cols?dt(Fp(n,this.cols-e)):0;return o&&s>0?[{row:t,col:e,width:s,height:1,target:o}]:[]})}right(t,e){this.run(t-e.reduce((n,[r])=>n+dt(r),0),e)}center(t,e){this.run(Math.floor((t-e.reduce((n,[r])=>n+dt(r),0))/2),e)}render(){let t="";for(let{col:e,text:n,sgr:r,link:i,hidden:o}of this.parts){if(o||e>=this.cols||e<0)continue;let s=Fp(n,this.cols-e);t+=`\x1B[${e+1}G${r}${zc(s,i)}${r?me:""}`}return t}}function hC(t){return t.replace(/_\([^)]*\)?$/,"")}function PS(t){return[`${t.reduced?"↓":""}${t.width}×${t.height}`,Math.max(t.width,t.height)<cC?Fn:W]}function uc(t,e,n){let r=[...n.keys??[]],i=n.lead,o=n.right,s=()=>{let u=[...i?[Lp(i)]:[],...r.map(([l,d])=>dt(l)+1+dt(d))];return(n.badge?dt(n.badge)+4:0)+u.reduce((l,d)=>l+d,0)+3*Math.max(0,u.length-1)+(o?3+dt(o[0])+1+dt(o[1]):0)};while(s()>e)if(r.length>2)r.splice(-2,1);else if(o)o=void 0;else if(r.length>1)r.splice(-2,1);else break;if(i&&s()>e)i=dC(i,Math.max(0,Lp(i)-(s()-e)-1));let a=0;if(n.badge)a=t.put(0,` ${n.badge} `,bt("pill"))+2;if([...i?[i]:[],...r.map(([u,f])=>[[u,Pt,void 0,Tp(u)],[` ${f}`,W,void 0,Tp(u)]])].forEach((u,f)=>{a=t.run(a+(f?3:0),u)}),o){let u=Tp(o[0].split(" ")[0]??"");t.right(e,[[o[0],Pt,void 0,u],[` ${o[1]}`,W,void 0,u]])}}function mC(t,e){if(t==="d")return W;if(t==="b")return Pt;if(t==="s")return Gl(e.colors.selection);if(t==="c")return Gl(e.colors.cursor);let n=/^([BK]?)(\d+)$/.exec(t);if(!n)return"";let r=Number(n[2]);if(n[1]==="K")return`${Si(0)}${jb(r)}`;return`${n[1]==="B"?Pt:""}${Si(r)}`}function pC(t,e,n,r,i){let o=Yt.indexOf(zi(r.scene)),s=Yt.flatMap((c,u)=>[...u?[[" ",""]]:[],[c.name,u===o?Pt+i:W,void 0,{kind:"scene",scene:u}]]),a=s.reduce((c,[u])=>c+dt(u),0)<=n;t?.run(e,a?s:[[zi(r.scene).name,Pt+i],[` ${o+1}/${Yt.length}`,W]])}function gC(t,e,n,r,i,o,s){let{ansi:a,cursor:c}=o.colors;pC(t[e-2],n,r,o,s);let u=r<fy?3:4;if(r>=56)u=Math.min(7,Math.floor((r+1)/8)-1);let f=n;for(let d=0;d<8;d++)f=(t[e]?.put(f,"▀".repeat(u),sc(a[d]??c)+Gl(a[d+8]??c))??f)+1;let l=e+2;for(let d of zi(o.scene).lines){let h=us(d,r);if(!h)continue;if(l>i)return;t[l]?.run(n,h.map(([m,p])=>[m,mC(p,o)])),l++}}function bC(t,e,n){let r=[[]];for(let s of t){let a=r[r.length-1];if(a.length===0||dt([...a,s].join(" "))<=e)a.push(s);else if(r.length<n)r.push([s]);else break}let i=r.reduce((s,a)=>s+a.length,0),o=r[r.length-1];while(i<t.length&&o.length>0&&dt([...o,`+${t.length-i}`].join(" "))>e)o.pop(),i--;if(i<t.length)o.push(`+${t.length-i}`);return r.filter((s)=>s.length>0).map((s)=>s.join(" "))}function yS(t){return t.replace(/^https?:\/\/(?:www\.)?/,"")}function wC(t,e,n,r,i){let o=r.info,s=o?.artists??[],a=hi(r.tiles[r.focus]?.siteAnsi??r.siteAnsi);[["Post",o?.page?fo(yS(o.page),"",o.page,a):[["—",W]]],["Source",o?.source?fo(yS(o.source),"",o.link,i):[["—",W]]],["Artist",[s.length>0?[s.join(" "),""]:["—",W]]]].forEach(([u,f],l)=>{t[e+l]?.put(n,u,W),t[e+l]?.run(n+12,f)})}function $C(t,e,n,r,i,o){let s=o.info,a=o.tiles[o.focus];if(!s||!a)return;let c=o.shown?.id===a.key?o.shown:void 0,u=n+12,f=Math.max(12,r-12),l=[`${a.width}×${a.height}${s.ext?` ${s.ext.toUpperCase()}`:""}`,...c?[kl(c.bytes)]:[]].join(" · "),d=[s.rating??"—",a.score>0?`★${a.score}`:"",s.posted??""].filter(Boolean).join(" · "),h=(b,$)=>b.length>0?bC(b,f,$).map((k)=>[[k,""]]):[[["—",W]]],m=[["Characters",h(s.characters,2)],["Series",h(s.series,1)],["Tags",h(s.tags,3)],["Rating",[[[d,d==="—"?W:""]]]],["File",[[[l,""],...c?[[" ",""]]:[],...c?RS(c):[]]]],["Uploader",[[s.uploader?[s.uploader,""]:["—",W]]]]],p=e;for(let[b,$]of m){if(p+$.length-1>i)return;t[p]?.put(n,b,W);for(let k of $)t[p]?.run(u,k),p++}}var kC=["Size","Position","Opacity"],yC=[0,3,6];function vC(t,e){let{tune:n,untuned:r}=t;return e===0?n.size!==r.size:e===1?n.at!==r.at:n.opacity!==r.opacity}function SC(t){return t.toFixed(2)}function EC(t,e,n,r,i,o){let s=i.tuning;if(!s)return;let a=i.tiles[i.focus];t[e-3]?.run(n,[[i.palette,Pt+o],[" Background",W],...a?[[" · ",W],...fo(`${a.site} ${a.id}`,W,a.page||void 0,hi(a.siteAnsi))]:[]]);let c=Math.max(8,r-n-21),u=20,f=Math.max(100,s.fill);for(let[l,d]of kC.entries()){let h=e+yC[l],m=s.field===l,p=m?Pt:W;if(m)t[h]?.put(n,"▶",o,void 0,{kind:"field",field:l});t[h]?.put(n+2,d,p,void 0,{kind:"field",field:l});let b;if(l===1){for(let $=1;$<=9;$++){let k=$===i.tune.at,v=t[e+2+Math.floor(($-1)/3)],S=n+12+($-1)%3*3;v?.mark(S-1,3,{kind:"place",at:$}),v?.put(S,k?"■":"·",k?Pt+o:W)}b=qt[i.tune.at-1]??"center"}else{let $;if(l===0){let{size:k}=i.tune;$=k==="fill"?c-1:Math.floor((k-u)*(c-1)/(f-u+1)),b=k==="fill"?"fill":`${k}%`}else $=Math.floor(Math.round(i.tune.opacity*100)*(c-1)/100),b=SC(i.tune.opacity);$=Math.max(0,Math.min(c-1,$)),t[h]?.run(n+12,[["━".repeat($),o],["●",Pt],["─".repeat(c-1-$),W]]),t[h]?.mark(n+12,c,{kind:"track",field:l})}if(t[h]?.right(r-2,[[b,p]]),vC(i,l))t[h]?.put(r-1,"↺",m?Pt+o:W)}}function MC(t,e,n,r,i,o){t[e]?.put(n,`╭${"─".repeat(i-2)}╮`,o);for(let s=e+1;s<e+r-1;s++)t[s]?.put(n,"│",o),t[s]?.put(n+i-1,"│",o);t[e+r-1]?.put(n,`╰${"─".repeat(i-2)}╯`,o)}function Cp(t,e=t.site,n=t.siteAnsi){return[` ${e} `,Up(n)]}function ac(t){return`${Z[Math.floor(t/Cr)]?.name??"local"} ${t%Cr}`}function oc(t,e,n){let r=Z[Math.floor(e/Cr)],i=ac(e),o=t.indexOf(i);if(!r||o===-1)return[[t,n]];return[[t.slice(0,o),n],...fo(i,n,r.pageUrl(e%Cr),hi(r.ansi)),[t.slice(o+i.length),n]].filter(([a])=>a!=="")}function xC(t,e,n){let r=[{name:"all",moved:!1},...Z].flatMap((o,s)=>{let a=`${o.name}${o.moved?"*":""}`,[c,u]=o.name===n.site?Cp(n,a):[` ${a} `,W],f=[c,u,void 0,{kind:"site",tab:s}];return s?[[" ",""],f]:[f]}),i=r.reduce((o,[s])=>o+dt(s),0)<=e;t.run(0,i?r:[Cp(n)])}function OC(t,e,n,r){if(n.chips.length===0)return;let i=[["tags ",W]],o=dt("tags "),s=n.chips.length;for(let[a,c]of n.chips.entries()){let u=` ${a+1} ${c.name} `;if(o+dt(u)+1>e-2)break;i.push([u,c.on?`${bt("reverse")}${r}`:W,void 0,{kind:"chip",index:a}],[" ",""]),o+=dt(u)+1,s--}if(s>0)i.push([`+${s}`,W]);t.run(0,i)}function IC(t,e,n,r,i){t[ve-1]?.put(0,"─".repeat(n-1),W);let o=t[Se.top-1],s=Gp(n),a=r.held.length>s?Math.max(0,s-1):r.held.length;for(let[c,u]of r.held.slice(0,a).entries()){let f=c*Se.pitch,l=u.up?Pt:"";if(o.run(f+1,u.page?fo(String(u.id),l,u.page,hi(u.ansi)):[["● ",hi(u.ansi)],[String(u.id),l]]),u.up)for(let d=0;d<Se.rows;d++)t[Se.top+d]?.put(f,"▌",i);if(u.thumb)e.push({id:sC+c,path:u.thumb,row:Se.top,col:f+1,cols:Se.cols,rows:Se.rows,z:-1})}if(a<r.held.length)o.put(a*Se.pitch+1,`+${r.held.length-a}`,W)}function PC(t,e,n,r){if(n.editing!==void 0){let c=t.run(0,[["⌕ ",r],[n.editing,""],["█",r]]),u=n.suggest?.length?" ↑↓ pick enter searches":" enter searches";t.put(c,n.editing?u:` A tag, a post URL or an id, or drop a picture or ctrl+v — ${n.tag||"esc leaves"}`,W);return}let i=t.run(0,[["⌕ ",r,void 0,{kind:"query"}],[n.tag||"Nothing yet — / searches, ctrl+v pastes a picture",n.tag?"":W,void 0,{kind:"query"}]]),o=Ni.filter((c)=>!n.block.includes(c)),s=Z.filter((c)=>!n.enabled.includes(c.name)).map((c)=>c.name),a=[n.preset,...n.solo?["solo"]:[],n.order,...n.rating.join("+")==="safe"?[]:[n.rating.join("+")],...o.length>0?[`allows ${o.join("+")}`]:[],...n.narrow.size>0?[`≥${n.narrow.size}px`]:[],...n.narrow.score>0?[`score≥${n.narrow.score}`]:[],...n.narrow.png?["png"]:[],...n.hide.length+n.hideTags.length>0?[`hides ${[...n.hide,...n.hideTags].join("+")}`]:[],...s.length>0?[`all skips ${s.join("+")}`]:[]];if(t.put(i,` ${a.join(" ")}`,W),n.total>0||!n.searching){let c=[[`${n.tiles.length}/${n.checked}`,""]];if(n.checked<n.total)c.push([` of ${n.total}`,W]);t.right(e,c)}}function RS(t){if(t.cut==="on")return[[`Cut out · ${t.clear}% transparent`,cc]];if(t.cut==="off")return[["Opaque · x cuts out",Fn]];if(t.cut==="failed")return[["Opaque · no cut-out",Fn]];return[t.clear>0?[`${t.clear}% transparent`,cc]:["Opaque",Fn]]}function vS(t){return t.site==="all"?"any site":t.site}function jp(t,e){if(t.installing!==void 0)return oc(`${Ls(t)} Installing ${t.palette} ← ${ac(t.installing)}`,t.installing,Fn);if(t.hint)return[[t.hint,cc]];if(t.error)return[[t.error,Fn]];if(t.waiting!==void 0)return[[`${t.slow??t.site} asked to slow down · ${t.waiting}s`,Fn]];if(t.fetching){let{id:n,got:r,size:i}=t.fetching;return oc(`${Ls(t)} Fetching ${ac(n)} · ${yl(r,i)}`,n,Fn)}if(t.cutting!==void 0)return oc(`${Ls(t)} Cutting out ${ac(t.cutting)}`,t.cutting,Fn);if(t.preparing!==void 0)return oc(`${Ls(t)} Preparing ${ac(t.preparing)}`,t.preparing,Fn);if(e)return[e];if(t.saved)return oc(t.saved.text,t.saved.key,cc);if(t.note)return[[t.note,W]];return}function NS(t){if(t.ranking)return"Ranking previews by palette colors";if(t.stage==="check")return t.preset==="cutouts"?"Checking PNG headers":"Loading previews";return"Fetching posts"}function AS(t,e){return t.ranking?`${e}${t.ranking.done}/${t.ranking.total}`:""}function RC(t,e,n,r,i){let{background:o,cursor:s,selection:a}=r.colors,{ranking:c}=r,u=c?Math.round(n*c.done/c.total):-1,f=Math.max(6,Math.round(n*0.22)),l=Ul(r)%($S*2)/$S,d=Math.round((n-f)*(0.5-0.5*Math.cos(Math.PI*(l<1?l:2-l)))),h=Rt(o,s,i),m=Rt(o,Rt(a,o,0.15),i),p=Array.from({length:n},($,k)=>{let v=(u>=0?k<u:k>=d&&k<d+f)?h:m;return k===0||k===n-1?Rt(v,o,0.55):v}),b=0;for(let $=1;$<=n;$++)if($===n||p[$]!==p[b])t?.put(e+b," ".repeat($-b),Gl(p[b])),b=$}function NC(t,e,n,r,i){let{background:o,foreground:s}=i.colors,a=i.loaderFrom===void 0?0:Math.min(1,(Ul(i)-i.loaderFrom)/lC),c=e+(n>=5?Math.floor((n-5)/2):0);t[c]?.center(r,[[NS(i),Pt+sc(Rt(o,s,a))],[AS(i," "),sc(Rt(o,Rt(s,o,0.45),a))]]);let u=Math.min(uC,r-8);if(RC(t[c+(n>=3?2:1)],Math.floor((r-u)/2),u,i,a),n<5)return;t[c+4]?.center(r,i.sites.flatMap(({name:f,arrived:l},d)=>[...d?[[" · ",sc(Rt(o,s,0.25*a))]]:[],[f,sc(Rt(o,l?Rt(s,o,0.2):s,l?a:0.32*a))]]))}function AC(t,e,n,r,i,o){if(i<=r)return;let s=Math.max(1,Math.round(r*r/i)),a=Math.max(0,Math.min(r-s,Math.round(n.scroll*r/i)));for(let c=0;c<r;c++){let u=c>=a&&c<a+s;t[ve+c]?.put(e-1,u?"┃":"│",u?o:W)}}function TC(t,e,n){if(e)return[`${Ls(t)} ${NS(t)}${AS(t," · ")}`,W];let r=n.filter((o)=>!o.missing),i=r.filter((o)=>o.thumb).length;return i<r.length?[`${Ls(t)} Loading thumbnails · ${i}/${r.length}`,W]:void 0}function HC(t,e,n,r,i,o,s){let{perRow:a,rowsVis:c,height:u}=dr(r,i);PC(t[0],r,o,s),xC(t[1],r,o),OC(t[2],r,o,s),IC(t,e,r,o,s);let f=t.map((L,A)=>A>=ve&&A<ve+u?L:void 0),l=Math.floor(o.scroll/vt.height),d=Math.floor((o.scroll+u-1)/vt.height),h=[];for(let L=l;L<=d;L++){let A=ve+L*vt.height-o.scroll;for(let _=0;_<a;_++){let q=L*a+_,B=_*vt.pitch,F=o.tiles[q];if(!F)continue;h.push(F);let pt=Math.max(A,ve),Zt=Math.min(A+vt.height,ve+u);if(Zt>pt)n.push({row:pt,col:B,width:vt.pitch-1,height:Zt-pt,target:{kind:"tile",index:q}});let it=q===o.focus;if(it)MC(f,A,B,vt.height,vt.pitch-1,s);let Sr=A+1,Be=Math.max(Sr,ve),gn=Math.min(Sr+vt.rows,ve+u);if(F.thumb&&gn>Be)e.push({id:F.key,path:F.thumb,row:Be,col:B+1,cols:vt.cols,rows:gn-Be,...gn-Be<vt.rows?{crop:Be-Sr}:{},z:-1});let Mo=[...o.installed.includes(F.key)?[["✓ ",cc]]:[],...F.page||o.site!=="all"?fo(String(F.id),it?Pt:"",F.page||void 0,hi(F.siteAnsi)):[["● ",hi(F.siteAnsi)],[String(F.id),it?Pt:""]],[" ",""],PS(F)],_c=vt.cols-(F.mates.length>0?1:0);if(f[A+10]?.run(B+1,Lp(Mo)>_c?Mo.map(([Gf,Bf,Uf])=>[Gf.replace(/^(\S) $/,"$1"),Bf,Uf]):Mo),F.mates.length>0)f[A+10]?.put(B+vt.cols,"≈",s);f[A+11]?.put(B+1,F.artist?hC(F.artist).slice(0,vt.cols-8):"—",W);let bi=[];if(F.score>0)bi.push([`★${F.score}`,W]);if(F.variants>1)bi.push([` ×${F.variants}`,s]);if(bi.length>0)f[A+11]?.right(B+vt.cols+1,bi)}}let m=Math.ceil(o.tiles.length/a)*vt.height;AC(t,r,o,u,m,s);let p=Math.max(ve,ve+m-o.scroll),b=ve+u-p,$=o.searching&&b>=2;if($)NC(f,p,b,r-1,o);let k=o.searching&&o.tiles.length===0;if(k&&!o.error){let[L,A]=kS[Math.floor(Ul(o)/fC)%kS.length];t[i-2]?.run(0,[["Tip ",W],[L,Pt],[` ${A}`,W]])}let v=o.top*a,S=o.tiles.length-(o.top+c)*a,x=[...v>0?[`↑ ${v} above`]:[],...S>0?[`↓ ${S} more`]:[]];if(x.length>0)t[i-2]?.put(0,x.join(" "),W);if(!o.searching&&o.tiles.length===0&&!o.error&&o.tag)t[ve+1]?.put(0,o.preset==="cutouts"?`No transparent cutouts of ${o.tag} on ${vS(o)} — c searches every post, tab tries ${o.nextSite}`:`No posts of ${o.tag} on ${vS(o)} — tab tries ${o.nextSite}`,W);let M=TC(o,$,h),P=jp(o,M);return uc(t[i-1],r,{badge:"IMAGE SEARCH",lead:P,keys:k&&P?.[0]===M?[]:[["←↑↓→","move"],["enter","try on"],["tab","site"],["ctrl+v","picture"],["s","settings"],["/","search"],["?","keys"]],right:["esc","back"]}),$}function FC(t,e,n,r,i,o){let s=i.tiles[i.focus];if(!s)return;let a=i.shown?.id===s.key?i.shown:void 0,c=[Cp(i,s.site,s.siteAnsi),[" ",""],...fo(String(s.id),Pt,s.page||void 0,hi(s.siteAnsi)),[" ",""],PS(s)];if(s.score>0)c.push([` · ★${s.score}`,W]);if(a)c.push([` · ${kl(a.bytes)}`,W]);if(a){if(c.push([" ",""],...RS(a)),i.coloring==="original")c.push([" · own colors",W])}if(t[0]?.run(0,c),s.mates.length>0)t[0]?.right(n,[["≈ ",o],[s.mates.join(" "),W]]);if(wC(t,1,2,i,o),i.tuning)EC(t,8,2,2+Math.min(n-4,60),i,o);else if(i.details)$C(t,5,2,Math.min(n-4,Math.max(48,Math.floor(n*0.55))),r-2,i);else gC(t,7,2,n-4,r-2,i,o);if(i.shown)e.push({id:_p+i.shown.id,path:i.shown.path,row:0,col:0,cols:n,rows:r,z:aC});if(i.tuning){uc(t[r-1],n,{badge:"IMAGE EDIT",lead:jp(i),keys:[["↑↓","field"],["←→","step"],["=","reset"],["+","reset all"],i.tuning.field===1?["1-9","place"]:["⇧←→","×10"],["c","colors"],["enter","keep"]],right:["esc","undo"]});return}let u=jp(i);uc(t[r-1],n,{badge:"IMAGE PREVIEW",lead:u,keys:i.installing===void 0?[["←→","browse"],["enter","install"],["t","tune"],["c","colors"],["i","details"],...i.details?[]:[["⇧←→","example"]],...i.shown?.cut==="on"||i.shown?.cut==="off"?[["x","cut out"]]:[],["?","keys"]]:[],right:i.installing===void 0?["esc","grid"]:void 0})}var LC=[["Field","↑↓ size, position, opacity"],["Step","←→ · ⇧←→ ×10"],["Place","1-9 the nine positions"],["Reset","= this field back to its default · + every field"],["Colors","c the palette's tone or its own colors, opacity back to its default"],["Keep","enter back to try, installed with the picture"],["Undo","esc"],["Close","? esc"]],CC={grid:[["Move","←↑↓→ j k home end pgup pgdn"],["Try on","enter"],["Site",`tab shift+tab all, ${Z.map((t)=>t.name).join(", ")}`],["Posts","c cutouts or every post"],["Search","/ a tag, a post URL or an id"],["Tags","1-9 turn a tag of the tags row on or off — the palette's own, then danbooru's related characters"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window or paste its link"],["Unfold","space a set of ×N"],["Open","o the post page in a browser"],["Settings","s rating, block, posts, solo, order, sets, remove bg"],["Advanced","a or Advanced › in settings min score, min size, sites, hide, hide tags, PNG only"],["Back","esc returns to preview"],["Close","? esc"]],try:[["Browse","←→"],["Install","enter"],["Tune","t size, position and opacity, installed with the picture"],["Colors","c the palette's tone or its own colors, installed with the picture"],["Details","i characters, series, tags, rating and file, under Post, Source and Artist"],["Example",`⇧←→ ${Yt.map((t)=>t.name.toLowerCase()).join(", ")}`],["Cut out","x the background off or on, on an opaque picture"],["Open","o the post page in a browser"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window"],["Grid","esc"],["Close","? esc"]]},Wp=6,jC=24;function lc(t){return[...t.settings.flatMap((e,n)=>Boolean(e.advanced)===t.advanced?[n]:[]),t.settings.length]}function _C(t){return t.replace(/^[A-Z](?=[a-z])/,(e)=>e.toLowerCase())}function SS(t){let e=t.settings.filter((n)=>Boolean(n.advanced)!==t.advanced).map((n)=>_C(n.label));return`${t.advanced?"Back to":"More filters:"} ${e.join(", ")} — enter opens the page, or a from any row`}function TS(t,e,n){let r=t.indexOf(e);if(r!==-1)return t[(r+n+t.length)%t.length];let i=Number(e)||0;return(n>0?t.find((s)=>(Number(s)||0)>i):[...t].reverse().find((s)=>(Number(s)||0)<i))??t[n>0?0:t.length-1]}function uo(t,e){let n=[],r="";for(let i of t.split(" "))if(r&&dt(r)+1+dt(i)>e)n.push(r),r=i;else r=r?`${r} ${i}`:i;return r?[...n,r]:n}function GC(t){if(t.entry!=="number"||t.choices.includes(t.value))return t.choices;let e=t.choices.findIndex((n)=>(Number(n)||0)>Number(t.value));return e===-1?[...t.choices,t.value]:[...t.choices.slice(0,e),t.value,...t.choices.slice(e)]}function BC(t,e,n,r){let i=Up(r),o=e&&n!==void 0;if(t.entry==="text")return[{text:` ${o?`${n}█`:t.value||"none"} `,sgr:o||e&&t.value?i:t.value?"":W}];let s=o?[]:t.value.split(" "),a=(o?t.choices:GC(t)).map((c,u)=>{let f=s.includes(c),l=t.multi&&e&&u===t.cursor?bt("under"):"";return{text:t.multi?` ${f?"[x]":"[ ]"} ${c} `:` ${c} `,sgr:f?e?`${l}${i}`:"":l?`${l}${W}`:W,choice:c}});return o?[...a,{text:` ${n}█ `,sgr:i}]:a}function ES(t){if(t.entry==="text")return[{text:" ".repeat(jC),sgr:""}];let e=t.choices.map((n)=>({text:t.multi?` [x] ${n} `:` ${n} `,sgr:""}));return t.entry==="number"?[...e,{text:` ${"0".repeat(Wp)}█ `,sgr:""}]:e}function UC(t){return t.reduce((e,n)=>e+dt(n.text)+1,0)-1}function MS(t,e){let n=[[]],r=0;for(let i of t){let o=dt(i.text)>e?{...i,text:` …${Array.from(i.text).slice(-(e-2)).join("")}`}:i;if(r>0&&r+dt(o.text)>e)n.push([]),r=0;n[n.length-1]?.push(o),r+=dt(o.text)+1}return n}function xS(t){if(t.multi&&t.choices.every((e)=>t.default.split(" ").includes(e)))return"Default all";return`Default ${t.default&&t.default!==t.multi?.none?t.default:"none"}`}function OS(t){if(!t.tag)return"";if(!t.counts)return`${t.tag}: counting…`;let e=t.counts.map(({site:n,count:r})=>`${n} ${r===void 0?"no count":r.toLocaleString("en-US")}`);return`${t.tag}: ${e.join(" · ")}`}function WC(t,e){let n=t.advanced?"basic":"advanced";if(!e)return{keys:[["↑↓","setting"],["enter",n],["s","save"]],right:["esc","undo"]};if(t.typing!==void 0)return{keys:[["⌫","erase"],["enter","done"]],right:["esc","cancel"]};if(e.entry)return{keys:[["↑↓","setting"],...e.entry==="number"?[["←→","step"]]:[],["a",n],["enter","type"],["s","save"]],right:["esc","undo"]};return{keys:[["↑↓","setting"],["←→","value"],["a",n],...e.multi?[["space","toggle"]]:[],["enter","save"]],right:["esc","undo"]}}function KC(t,e,n,r,i){let o=r.panel??0,s=r.settings.length,c=6+Math.max(...r.settings.map((F)=>dt(F.label))),u=Math.max(...r.settings.map((F)=>dt(xS(F)))),f=c+Math.max(...r.settings.map((F)=>UC(ES(F))))+u+5,l=Math.min(e-2,Math.max(48,f)),d=l-c-u-5,h=l-7,m=[!1,!0].map((F)=>({advanced:F,rows:lc({settings:r.settings,advanced:F}).slice(0,-1)})),p=r.settings.map((F)=>MS(ES(F),d).length),b=Math.max(...m.map((F)=>F.rows.reduce((pt,Zt)=>pt+p[Zt],0))),$=Math.max(...m.map((F)=>uo(SS({settings:r.settings,advanced:F.advanced}),h).length),...r.settings.map((F)=>uo(F.about,h).length)),k=`${r.tag}: ${Z.map((F)=>`${F.name} 0,000,000`).join(" · ")}`,v=r.tag?Math.max(uo(k,h).length,uo(OS(r),h).length):0,S=b+$+v+8,x=Math.floor((e-l)/2),M=Math.max(1,Math.floor((n-1-S)/2)),P=Up(r.siteAnsi);t[M]?.put(x,`╭─ Settings ${"─".repeat(Math.max(0,l-13))}╮`);for(let F=M+1;F<M+S-1;F++)t[F]?.put(x,`│${" ".repeat(l-2)}│`);let L=M+2;for(let F of lc(r).slice(0,-1)){let pt=r.settings[F],Zt=F===o;if(Zt)t[L]?.put(x+2,"▶",i);if(t[L]?.mark(x+2,c-3,{kind:"setting",index:F}),t[L]?.put(x+4,pt.label,Zt?Pt:""),pt.value!==pt.default)t[L]?.right(x+l-3,[[xS(pt),W]]);MS(BC(pt,Zt,r.typing,r.siteAnsi),d).forEach((it,Sr)=>{let Be=x+c;for(let gn of it)Be=(t[L+Sr]?.put(Be,gn.text,gn.sgr,void 0,{kind:"choice",index:F,choice:gn.choice})??Be)+1}),L+=p[F]}let A=m.find((F)=>F.advanced!==r.advanced)?.rows??[],_=t[M+3+b];if(_){if(o===s)_.put(x+2,"▶",i);let F=_.put(x+3,r.advanced?" ‹ Basic ":" Advanced › ",o===s?P:Pt,void 0,{kind:"setting",index:s});if(A.some((pt)=>r.settings[pt]?.value!==r.settings[pt]?.default))_.put(F+1,"•",W)}t[M+5+b]?.put(x+2,"─".repeat(l-4),W),uo(r.settings[o]?.about??SS(r),h).forEach((F,pt)=>{t[M+6+b+pt]?.put(x+4,F)}),uo(OS(r),h).forEach((F,pt)=>{t[M+6+b+$+pt]?.put(x+4,F,W)}),t[M+S-1]?.put(x,`╰${"─".repeat(l-2)}╯`);let{keys:q,right:B}=WC(r,r.settings[o]);uc(t[n-1],e,{keys:q,right:B})}function zC(t,e,n,r){let i=r.tuning?LC:CC[r.mode],o=Math.min(e-2,Math.max(50,...i.map(([,l])=>dt(l)+16))),s=i.map(([l,d])=>({label:l,parts:uo(d,o-16)})),a=s.reduce((l,{parts:d})=>l+d.length,0)+4,c=Math.floor((e-o)/2),u=Math.max(2,Math.floor((n-a)/2));t[u]?.put(c,`╭─ Help ${"─".repeat(o-9)}╮`);for(let l=u+1;l<u+a-1;l++)t[l]?.put(c,`│${" ".repeat(o-2)}│`);let f=u+2;for(let{label:l,parts:d}of s){t[f]?.put(c+3,l,Pt);for(let h of d)t[f]?.put(c+13,h),f++}t[u+a-1]?.put(c,`╰${"─".repeat(o-2)}╯`),uc(t[n-1],e,{badge:"HELP",right:["? esc","close"]})}function qC(t,e,n){let r=e.suggest??[],i=r.map((a)=>a.alias??(a.count>0?String(a.count):a.palette??"0")),o=Math.max(...r.map((a)=>dt(a.value))),s=Math.max(7,...i.map(dt));r.forEach((a,c)=>{let u=c===e.pick,f=t[1+c];f?.run(0,[[u?"▸ ":" ",n,void 0,{kind:"suggest",index:c}],[a.value,u?Pt+n:"",void 0,{kind:"suggest",index:c}]]),f?.right(2+o+2+s,[[i[c],W]])})}function jl(t,e=[]){return[...e,...t.flatMap((n,r)=>n.zones(r))]}function Kp(t,e,n){let r=Array.from({length:n},()=>new _l(e)),i=[],o=[],s=bt("accent");if(Hp=!1,e<lo.cols||n<lo.rows)return r[0]?.put(0,"ttheme find",Pt+s),r[1]?.put(0,`Needs ${lo.cols}×${lo.rows} — now ${e}×${n}`),r[2]?.put(0,"esc quits",W,void 0,{kind:"key",key:"esc"}),{lines:r.map((c)=>c.render()),images:i,zones:jl(r),loader:!1,tick:!1};let a=!1;if(t.mode==="try")FC(r,i,e,n,t,s);else a=HC(r,i,o,e,n,t,s);if(t.mode==="grid"&&t.editing!==void 0&&t.suggest?.length){for(let c=1;c<n-1;c++)r[c]=new _l(e);return qC(r,t,s),{lines:r.map((c)=>c.render()),images:[],zones:jl(r),loader:!1,tick:!1}}if(t.help||t.panel!==void 0){let c=t.mode==="try"?i:[];for(let u=0;u<n;u++)r[u]=new _l(e);if(t.help)zC(r,e,n,t);else KC(r,e,n,t,s);return{lines:r.map((u)=>u.render()),images:c,zones:jl(r),loader:!1,tick:!1}}return{lines:r.map((c)=>c.render()),images:i,zones:jl(r,o),loader:a,tick:Hp}}var DC=130,JC=38,YC=96,VC=28,hc=[{id:"shell",scenes:["Diff","Logs","Shell"],name:"zsh",tail:!0},{id:"code",scenes:["Editor"],name:"nvim",tail:!1},{id:"monitor",scenes:["Top"],name:"htop",tail:!1}],ZC={Shell:[0,1,2,3,4,6,7,9,10,12,14],Diff:[0,1,3,4,6,7,8,9,10,15],Logs:[0,1,2,3,4,5,6,7,8,9,10]},HS=(t)=>Array.from({length:8},(e,n)=>`«K${t+n}» «»`).join(" "),XC=["«2»❯ «»colortest",`«d»0-7 ${HS(0)}`,`«d»8-15 ${HS(8)}`],FS=2;function QC(t){let e=hc.length;return hc[(t%e+e)%e]}function jS(){return hc.map((t)=>t.name)}function mc(t,e,n){let r=t>=DC&&e>=JC?"full":t>=YC&&e>=VC?"tabs":void 0;if(!r)return;let i=r==="full"?t>=140?47:38:37,o=t-i-1,s=i+1+FS,a=i+o-FS,c=3,u=e-3,f={col:s,row:c,cols:a-s+1,rows:u-c+1},l={col:s+1,row:c+3,cols:f.cols-2,rows:u-c-3},d=[{row:c,col:s,length:f.cols,down:!1},{row:c+2,col:s,length:f.cols,down:!1},{row:u,col:s,length:f.cols,down:!1},{row:c,col:s,length:u-c+1,down:!0},{row:c,col:a,length:u-c+1,down:!0}],h=QC(n);return{tier:r,side:i,width:o,frame:f,title:{col:l.col,row:c+1,cols:l.cols,rows:1},inner:l,rules:d,tiles:[{id:h.id,name:h.name,col:l.col,row:l.row,width:l.cols,rows:l.rows}]}}var dc="«2»▎ ",LS="«3»▎ ",t8="«1»▁ ",e8=[["","«5»import«» { «4»readFile«» } «5»from «2»'node:fs/promises'"],["","«5»import«» { «5»type «6»Hex«», «4»contrast«» } «5»from «2»'./color.ts'"],["",""],["","«8»/** A palette read from disk and checked against the gate. */"],[dc,"«5»export interface «6»Palette «»{"],[dc," name: «6»string"],[dc," ansi: «6»Hex«»[]"],[dc," ratio?: «6»number"],[dc,"}"],["",""],["","«5»const «»SIXTEEN = «3»16"],["","«5»const «»FLOOR = «3»4.5 «8»// WCAG AA for body text"],["",""],["","«5»export async function «4»load«»(path: «6»string«»): «6»Promise«»<«6»Palette«»> {"],[LS," «5»const «»text = «5»await «4»readFile«»(path, «2»'utf8'«»)"],[LS," «5»const «»colors = «s»parse(text)«».colors ?? {}"],[""," «5»if «»(colors.ansi.length !== «K3»SIXTEEN«») { «1»● needs 16 ANSI colors"],[""," «5»throw new «6»Error«»(«2»'expected sixteen colors, got '«» + colors.ansi.length)"],[""," }"],[t8," «5»const «»ratio = «4»contrast«»(colors.ansi[«3»0«»], colors.ansi[«3»7«»]) «3»● ratio is read once"],[""," «5»return «»{ name: path, ...colors, ratio: «c»r«»atio }"],["","}"],["",""],["","«5»export function «4»passes«»(palette: «6»Palette«»): «6»boolean «»{"],[""," «5»return «»(palette.ratio ?? «3»0«») >= FLOOR «8»// TODO: check the bright pairs"],["","}"]],n8=21;function r8(){return["«K4» theme.ts «s» scenes.ts «s» contrast.ts ",...e8.map(([t,e],n)=>{let r=String(n+1).padStart(3);return`${n+1===n8?`«b»${r}`:`«d»${r}`} ${t||"«» "}«»${e}`})]}function zp(t,e,n,r){let i=Math.max(1,r-t.length-2-n.length),o=0,s=`«6»${t}«b»[`;for(let[a,c]of e){let u=Math.min(i-o,Math.round(c*i));s+=`«${a}»${"|".repeat(u)}`,o+=u}return`${s}«»${" ".repeat(i-o)}${n}«b»]`}var i8=[[0.31,0.07,0],[0.22,0.02,0.03],[0.04,0.01,0],[0.52,0.12,0],[0.1,0.02,0],[0.41,0.11,0],[0.02,0,0],[0.15,0.03,0.04]],o8=["«s» 4127 kec 24 0 412G 612M «s»R 38.2 3.7 3:12.44 node dev.js"," 2210 kec 31 0 411G 1.2G «2»R«» 12.0 7.5 1:02.10 «d»/Applications/«b»Ghostty"," 3301 kec 31 0 409G 12M S 4.4 0.1 0:05.61 «b»zsh"," 3302 kec 31 0 409G 9.8M S 0.0 0.1 0:00.42 «d»├─ «b»nvim «»src/theme.ts"," 3310 kec 31 0 410G 88M S 1.2 0.5 0:03.18 «d»│ └─ «b»tsserver"," 3402 kec 24 0 409G 21M «2»R«» 0.6 0.1 0:01.02 «d»└─ «b»htop"," 501 kec 31 «4»10«» 409G 34M S 0.3 0.2 0:02.77 «b»bun «»test --watch"," 1180 kec 31 0 409G 72M «1»D«» 0.0 0.4 0:00.91 «b»rsync «»-a ~/Pictures backup:"," 812 «d»root«» «1» 4 -20«» 410G 1.5G S 3.1 9.4 0:44.02 «d»kernel_task"," 167 «d»root«» 31 0 411G 402M S 0.9 2.5 0:12.80 «d»WindowServer"," 344 «d»_mdns«» 31 0 408G 5.1M S 0.0 0.0 0:00.33 «d»mDNSResponder"],s8=["Help","Setup","Search","Filter","Tree","SortBy","Nice -","Nice +","Kill","Quit"];function a8(t,e,n){return`«${t}»${e}${" ".repeat(Math.max(0,n-G(e)))}`}function c8(t){let e=t-2,n=Math.floor((e-2)/2),r=(i)=>{let[o,s,a]=i8[i],c=`${((o+s+a)*100).toFixed(1)}%`;return zp(String(i).padStart(3),[["2",o],["1",s],["4",a]],c,n)};return[...[0,1,2,3].map((i)=>`${r(i)} ${r(i+4)}`),`${zp("Mem",[["2",0.45],["4",0.1],["3",0.07]],"9.84G/16.0G",n)} «6»Tasks: «b»214«», 1093 thr; «B2»4«» running`,`${zp("Swp",[["1",0.15]],"0.31G/2.00G",n)} «6»Load average: «b»2.14 «»1.87 «d»1.52`,`${" ".repeat(n)} «6»Uptime: «b»3 days, 04:12:55`,"",a8("K2"," PID USER PRI NI VIRT RES S CPU% MEM% TIME+ Command",e),...o8.map((i)=>i.startsWith("«s»")?`${i}${" ".repeat(Math.max(0,e-G(i.replace(/«[^»]*»/g,""))))}`:i)]}function u8(t){let e=t-2,n="",r=0;return s8.forEach((i,o)=>{let s=`F${o+1}`,a=i.padEnd(6);if(r+s.length+a.length<=e)n+=`«»${s}«K6»${a}`,r+=s.length+a.length}),`${n}«K6»${" ".repeat(Math.max(0,e-r))}`}function CS(t,e,n){if(t==="Editor")return r8();if(t==="Top")return c8(n);let r=Yt.find((s)=>s.name===t)?.lines??[],i=e?ZC[t]:void 0,o=i?i.map((s)=>r[s]??""):r;return t==="Shell"?[...o.slice(0,-1),...XC,...o.slice(-1)]:o}function Wl(t,e){let n=[];for(let r of t){let i=us(r,e);if(!i)continue;let o=0;n.push(i.map(([s,a])=>{let c={text:s,role:a,col:o};return o+=G(s),c}))}return n}function l8(t){let r=t-2-G("«K4» NORMAL «s» main src/theme.ts [+] ".replace(/«[^»]*»/g,""))-G("«K1» 1 «K3» 1 «s» utf-8 typescript 21:28 «K4» 80% ".replace(/«[^»]*»/g,""));return`${"«K4» NORMAL «s» main src/theme.ts [+] "}${" ".repeat(Math.max(0,r))}${"«K1» 1 «K3» 1 «s» utf-8 typescript 21:28 «K4» 80% "}`}function f8(t,e){if(t.id==="code")return[l8(e),'«d»"src/theme.ts" 26L, 912B written'];return t.id==="monitor"?[u8(e)]:[]}function d8(t,e,n){let r=Wl(f8(t,e),e),i=Math.max(0,n-r.length),o=[];for(let a of[...t.scenes].reverse()){let c=Wl(CS(a,!1,e),e),u=Wl(CS(a,!0,e),e),f=[c,u].find((l)=>o.length+l.length<=i);if(!f){if(o.length===0)o=t.tail?u.slice(u.length-i):u.slice(0,i);break}o=[...f,...o]}if(r.length===0)return o;let s=Wl(Array.from({length:i-o.length},()=>t.id==="code"?"«4»~":""),e);return[...o,...s,...r]}function pc(t){let e=hc.find((r)=>r.id===t.id),n=t.width-2;return e?d8(e,t.width,t.rows).map((r)=>r.filter((i)=>i.col<n)):[]}function qp(t,e){let{text:n,ground:r}=GS(t);return n===e||r===e}function _S(t,e){let n=t.inner;return hc.map((r)=>({name:r.name,count:pc({id:r.id,name:r.name,col:n.col,row:n.row,width:n.cols,rows:n.rows}).flat().filter((i)=>qp(i.role,e)).length}))}function GS(t){if(t==="s")return{text:1,ground:3};if(t==="c")return{text:1,ground:2};let e=/^([BK]?)(\d+)$/.exec(t);if(!e)return{text:1,ground:0};let n=4+Number(e[2]);return e[1]==="K"?{text:4,ground:n}:{text:n,ground:0}}function Dp(t,e){if(e>=4){let n=/^([BK]?)(\d+)$/.exec(t);return n!==null&&Number(n[2])===e-4}return e===3&&t==="s"||e===2&&t==="c"}function Kl(t){let e=[];for(let n of t.tiles)pc(n).forEach((r,i)=>{r.forEach((o,s)=>{e.push({spot:{pane:n.id,line:i,run:s},col:o.col,text:o.text,role:o.role})})});return e}function Jp(t,e){return t.pane===e.pane&&t.line===e.line&&t.run===e.run}function BS(t,e){let n=Kl(t);return(n.find((r)=>Dp(r.role,e))??n[0])?.spot}function zl(t,e){return e&&Kl(t).find((n)=>Jp(n.spot,e))?.spot}function US(t,e,n){let r=Kl(t);if(r.length===0)return;let i=e?r.findIndex((d)=>Jp(d.spot,e)):-1;if(i<0)return r[0]?.spot;let o=r[i];if(n==="left"||n==="right")return r[(i+(n==="left"?r.length-1:1))%r.length]?.spot;if(n==="next"||n==="previous"){let d=t.tiles.map((p)=>p.id),h=d.indexOf(o.spot.pane),m=d[(h+(n==="next"?1:d.length-1))%d.length];return r.find((p)=>p.spot.pane===m)?.spot}let s=n==="up"?-1:1,a=r.filter((d)=>d.spot.pane===o.spot.pane),c=[...new Set(a.map((d)=>d.spot.line))],u=c[c.indexOf(o.spot.line)+s];if(u===void 0){let d=t.tiles.map((k)=>k.id),h=d.indexOf(o.spot.pane)+s,m=d[(h+d.length)%d.length],p=r.filter((k)=>k.spot.pane===m),b=s<0?p.at(-1)?.spot.line??0:p[0]?.spot.line??0,$=p.filter((k)=>k.spot.line===b);return($.find((k)=>k.col>=o.col)??$.at(-1))?.spot}let f=a.filter((d)=>d.spot.line===u);return(f.find((d)=>d.col<=o.col&&d.col+G(d.text)>o.col)??f.find((d)=>d.col>=o.col)??f.at(-1))?.spot}function WS(t,e){let n=Kl(t).find((r)=>Jp(r.spot,e));return n?GS(n.role):void 0}var h8={lr:"─",du:"│",dr:"╭",dl:"╮",ru:"╰",lu:"╯",dlr:"┬",lru:"┴",dru:"├",dlu:"┤",dlru:"┼"};function KS(t){let e=new Map,n=(i,o,s)=>{let a=e.get(i)??new Map;e.set(i,a);let c=a.get(o)??new Set;a.set(o,c),c.add(s)};for(let i of t)for(let o=0;o<i.length;o++){let s=i.down?i.row+o:i.row,a=i.down?i.col:i.col+o;if(o>0)n(s,a,i.down?"u":"l");if(o<i.length-1)n(s,a,i.down?"d":"r")}let r=new Map;for(let[i,o]of e){let s=new Map;for(let[a,c]of o){let u=[...c].sort().join("");s.set(a,h8[u]??(c.has("l")||c.has("r")?"─":"│"))}r.set(i,s)}return r}import{execFile as m8}from"node:child_process";import{createHash as JS}from"node:crypto";import{existsSync as p8,mkdtempSync as g8,readFileSync as Yl,rmSync as b8,statSync as YS,writeFileSync as VS}from"node:fs";import{homedir as w8,tmpdir as $8}from"node:os";import{join as ql}from"node:path";import{fileURLToPath as k8}from"node:url";import{promisify as y8}from"node:util";var Ln=y8(m8),Dl=67108864,v8=4096,Zp=["image/png","image/jpeg","image/webp","image/gif","image/tiff","image/heic"],S8=["text/uri-list","text/plain;charset=utf-8","text/plain"],Yp=[...Zp,"text/uri-list","text/plain"];function E8(t){try{return YS(t).isFile()}catch{return!1}}function M8(t){let e=[],n="",r="",i=!1;for(let o=0;o<t.length;o++){let s=t[o];if(r==="'")if(s==="'")r="";else n+=s;else if(r==='"')if(s==='"')r="";else if(s==="\\"&&'"\\$`'.includes(t[o+1]??""))n+=t[++o];else n+=s;else if(s==="\\"&&o+1<t.length)n+=t[++o],i=!0;else if(s==="'"||s==='"')r=s,i=!0;else if(/\s/.test(s)){if(i)e.push(n);n="",i=!1}else n+=s,i=!0}if(i)e.push(n);return e}function zS(t){if(/^file:\/\//i.test(t))try{return k8(t)}catch{return}if(t.startsWith("~/"))return ql(w8(),t.slice(2));return t.startsWith("/")?t:void 0}function Cs(t,e=E8){let n=[];for(let r of t.replace(/\r\n?/g,`
|
|
652
654
|
`).split(`
|
|
653
|
-
`)){let i=
|
|
655
|
+
`)){let i=zS(r.trim());if(i&&e(i)){n.push(i);continue}for(let o of M8(r)){if(/^https?:\/\/\S+$/i.test(o)){n.push(o);continue}let s=zS(o);if(s&&e(s))n.push(s)}}return n}function qS(t){let e=Ii(t)?yn(t):xd(t);if(!e)return;return{ext:Ii(t)?"png":"jpg",width:e.width,height:e.height}}async function Jl(t,e){let n=qS(t);if(n&&n.width*n.height<=Re)return{bytes:t,...n,source:e};if(process.platform!=="darwin")throw Error(n?`${n.width}×${n.height} is over ${Re/1e6} megapixels`:"only PNG and JPEG pictures work here");let r=g8(ql($8(),"ttheme-attach-"));try{let i=ql(r,"in"),o=ql(r,"out.png");VS(i,t);let s=!n||n.width*n.height>Re?["--resampleHeightWidthMax",String(v8)]:[];await Ln("sips",["-s","format","png",...s,i,"--out",o]).catch(()=>{throw Error("that is not a picture macOS can read")});let a=new Uint8Array(Yl(o)),c=qS(a);if(!c)throw Error("that is not a picture macOS can read");return{bytes:a,...c,source:e}}finally{b8(r,{recursive:!0,force:!0})}}async function Xp(t,e){if(/^https?:\/\//i.test(t)){let n=await fetch(t,{headers:{"User-Agent":Td},signal:e});if(!n.ok)throw Error(`${new URL(t).host} answered ${n.status}`);if(Number(n.headers.get("content-length")??0)>Dl)throw Error("that picture is over 64 MB");let r=new Uint8Array(await n.arrayBuffer());if(/^text\/html/i.test(n.headers.get("content-type")??""))throw Error(`${new URL(t).host} sent a web page, not a picture — copy the image address instead`);return Jl(r,t)}if(YS(t).size>Dl)throw Error("that picture is over 64 MB");return Jl(new Uint8Array(Yl(t)),t)}var ZS=new Map,hr={key:"local",name:"local",origin:"file://",moved:!1,cutouts:"",best:"",tagBudget:0,ors:!1,vouched:!0,scored:!1,ansi:7,ratings:{safe:new Set,questionable:new Set,explicit:new Set},rate:()=>"",narrow:()=>[],postsUrl:()=>"",countUrl:()=>"",postUrl:()=>"",pageUrl:(t)=>ZS.get(t)??"",parse:()=>[],count:()=>0};function XS(t){if(/^https?:\/\//i.test(t))return"";return t.split("/").pop()??t}function QS(t,e){ZS.set(t,e)}function tE(t){return Number.parseInt(JS("sha1").update(t).digest("hex").slice(0,8),16)%Cr}var x8=`ObjC.import('AppKit')
|
|
654
656
|
function run(argv) {
|
|
655
657
|
const pb = $.NSPasteboard.generalPasteboard
|
|
656
658
|
const files = pb.readObjectsForClassesOptions($([$.NSURL]), $({ NSPasteboardURLReadingFileURLsOnlyKey: true }))
|
|
@@ -675,16 +677,16 @@ function run(argv) {
|
|
|
675
677
|
if (web && web.count > 0) return web.objectAtIndex(0).absoluteString.js
|
|
676
678
|
const text = pb.stringForType('public.utf8-plain-text')
|
|
677
679
|
return text && !text.isNil() ? text.js : ''
|
|
678
|
-
}`,
|
|
680
|
+
}`,O8=`Add-Type -AssemblyName System.Windows.Forms,System.Drawing
|
|
679
681
|
$c = [Windows.Forms.Clipboard]
|
|
680
682
|
$f = $c::GetFileDropList(); if ($f.Count) { $f; exit }
|
|
681
683
|
$p = Join-Path $env:TEMP 'ttheme-clipboard.png'
|
|
682
684
|
$s = $c::GetData('PNG'); if ($s -is [IO.MemoryStream]) { [IO.File]::WriteAllBytes($p, $s.ToArray()); $p; exit }
|
|
683
685
|
$i = $c::GetImage(); if ($i) { $i.Save($p, [Drawing.Imaging.ImageFormat]::Png); $p; exit }
|
|
684
|
-
$c::GetText()`;function
|
|
685
|
-
`).map((s)=>s.trim()),i=(s)=>e?
|
|
686
|
-
`).map(async(r)=>/^[A-Za-z]:\\/.test(r)?(await
|
|
687
|
-
`)}}if(process.platform==="linux")return
|
|
686
|
+
$c::GetText()`;function eE(){if(process.platform!=="linux")return!1;try{return/microsoft/i.test(Yl("/proc/version","utf8"))}catch{return!1}}async function I8(t){let e=Boolean(process.env.WAYLAND_DISPLAY),n=e?["wl-paste",["--list-types"]]:["xclip",["-selection","clipboard","-t","TARGETS","-o"]],r=(await Ln(n[0],n[1])).stdout.split(`
|
|
687
|
+
`).map((s)=>s.trim()),i=(s)=>e?Ln("wl-paste",["--no-newline","--type",s],{encoding:"buffer",maxBuffer:Dl}):Ln("xclip",["-selection","clipboard","-t",s,"-o"],{encoding:"buffer",maxBuffer:Dl});if(r.includes("text/uri-list"))return{text:(await i("text/uri-list")).stdout.toString("utf8")};let o=Zp.find((s)=>r.includes(s));if(o)return VS(t,(await i(o)).stdout),{image:t};return{text:r.some((s)=>s.startsWith("text/plain")||s==="UTF8_STRING")?(await i(r.includes("text/plain")?"text/plain":"UTF8_STRING")).stdout.toString("utf8"):""}}function Qp(){return Boolean(process.env.SSH_CONNECTION||process.env.SSH_TTY)}async function nE(t){if(process.platform==="darwin"){let e=(await Ln("osascript",["-l","JavaScript","-e",x8,t])).stdout.trim();return e===t?{image:t}:{text:e}}if(eE()){let e=(await Ln("powershell.exe",["-NoProfile","-STA","-Command",O8])).stdout.replace(/\r/g,"").trim(),n=await Promise.all(e.split(`
|
|
688
|
+
`).map(async(r)=>/^[A-Za-z]:\\/.test(r)?(await Ln("wslpath",["-u",r])).stdout.trim():r));return n.length===1&&/ttheme-clipboard\.png$/.test(n[0]??"")?{image:n[0]}:{text:n.join(`
|
|
689
|
+
`)}}if(process.platform==="linux")return I8(t);throw Error(`reading the clipboard is not supported on ${process.platform}`)}var P8=`ObjC.import('AppKit')
|
|
688
690
|
function run() {
|
|
689
691
|
const pb = $.NSPasteboard.generalPasteboard
|
|
690
692
|
const files = pb.readObjectsForClassesOptions($([$.NSURL]), $({ NSPasteboardURLReadingFileURLsOnlyKey: true }))
|
|
@@ -696,7 +698,7 @@ function run() {
|
|
|
696
698
|
picture = ['public.png', 'public.tiff', 'public.jpeg', 'public.heic'].some((t) => types.includes(t))
|
|
697
699
|
}
|
|
698
700
|
return pb.changeCount + '\\t' + (picture ? 'picture' : '')
|
|
699
|
-
}`;async function ZE(){if(Jp())return;if(process.platform==="darwin"){let[t="",e=""]=(await Fn("osascript",["-l","JavaScript","-e",$8])).stdout.trim().split("\t");return{stamp:t,picture:e==="picture"}}if(process.platform==="linux"&&!JE()){let e=Boolean(process.env.WAYLAND_DISPLAY)?(await Fn("wl-paste",["--list-types"])).stdout:(await Fn("xclip",["-selection","clipboard","-t","TARGETS","-o"])).stdout;return{stamp:e,picture:/^image\//m.test(e)}}return}function Wl(t){return t.length>8&&/^(?:\/|~\/|file:|https?:)/.test(t)}var dc=(t)=>Buffer.from(t).toString("base64"),zp=(t)=>Buffer.from(t,"base64");function GE(t,e){return e.find((n)=>t.includes(n))}class Yp{clipboard=!1;drops=!1;reading;offered=[];dropping;pw=dc(BE("sha1").update(`${process.pid}:${Date.now()}`).digest("hex"));send;deliver;constructor(t,e){this.send=t,this.deliver=e}start(){let t="";if(this.clipboard)t+="\x1B[?5522h";if(this.drops)t+=`\x1B]72;t=a;${Kp.join(" ")}\x1B\\`;this.send(t)}stop(){this.send(`${this.clipboard?"\x1B[?5522l":""}${this.drops?"\x1B]72;t=A\x1B\\":""}`)}ask(){this.reading={mime:".",chunks:[],pw:"",listing:!0},this.send(`\x1B]5522;type=read:name=${dc("ttheme")}:pw=${this.pw};${dc(".")}\x1B\\`)}take(t){if(t.code==="5522")this.clip(t.meta,t.payload);else if(t.code==="72")this.drop(t.meta,t.payload)}clip(t,e){if(t.type!=="read")return;let n=t.status??"";if(n==="OK"){if(this.reading??={mime:".",chunks:[],pw:t.pw??"",listing:!0},t.pw)this.reading.pw=t.pw;return}let r=this.reading;if(!r)return;if(n==="DATA"){if(r.mime=t.mime?zp(t.mime).toString("utf8"):r.mime,e)r.chunks.push(zp(e));return}if(this.reading=void 0,n!=="DONE"){this.deliver({kind:"error",message:n==="EPERM"?"The clipboard read was not allowed":`The terminal answered ${n}`});return}let i=Buffer.concat(r.chunks);if(r.listing){let o=i.toString("utf8").split(/\s+/).filter(Boolean),s=GE(o,[...qp,...h8]);if(!s){this.deliver({kind:"text",text:""});return}let a=r.pw||this.pw,c=r.pw?"Paste event":"ttheme";this.reading={mime:s,chunks:[],pw:a,listing:!1},this.send(`\x1B]5522;type=read:name=${dc(c)}:pw=${a};${dc(s)}\x1B\\`);return}this.deliver(r.mime.startsWith("image/")?{kind:"bytes",bytes:new Uint8Array(i),source:"clipboard"}:{kind:"text",text:i.toString("utf8")})}drop(t,e){let n=t.t??"";if(n==="m"){if(t.x==="-1"){this.offered=[];return}if(e){this.offered=e.split(" ").filter(Boolean);let a=Kp.filter((c)=>this.offered.includes(c));this.send(`\x1B]72;t=m:o=${a.length>0?1:0};${a.join(" ")}\x1B\\`)}return}if(n==="M"){let a=e?e.split(" ").filter(Boolean):this.offered,c=GE(a,Kp);if(!c){this.send("\x1B]72;t=r:o=0\x1B\\");return}this.dropping={mimes:a,index:a.indexOf(c)+1,chunks:[]},this.send(`\x1B]72;t=r:x=${this.dropping.index}\x1B\\`);return}let r=this.dropping;if(!r)return;if(n==="R"){this.dropping=void 0,this.send("\x1B]72;t=r:o=0\x1B\\"),this.deliver({kind:"error",message:`The drop failed: ${e.split(":")[0]||"unknown error"}`});return}if(n!=="r"&&n!=="")return;if(e)r.chunks.push(zp(e));if(t.m==="1"||e)return;this.dropping=void 0;let i=Buffer.concat(r.chunks),o=r.mimes[r.index-1]??"",s;if(o.startsWith("image/"))s={kind:"bytes",bytes:new Uint8Array(i),source:"drop"};else{let a=i.toString("utf8"),c=o==="text/uri-list"?Ls(a).find((u)=>o8(u)):void 0;s=c?{kind:"bytes",bytes:new Uint8Array(Ul(c)),source:c}:{kind:"text",text:a}}this.send("\x1B]72;t=r:o=1\x1B\\"),this.deliver(s)}}var Zp=5,k8=6,VE=0.05,y8=[1,2,3,4,5,6,9,10,11,12,13,14],XE=(t,e)=>(e-t+360)%360<=180?1:-1;function Ln(t,e,n){let r=e*Math.cos(n*Math.PI/180),i=e*Math.sin(n*Math.PI/180),o=[t+0.3963377774*r+0.2158037573*i,t-0.1055613458*r-0.0638541728*i,t-0.0894841775*r-1.291485548*i].map((f)=>f**3),[s,a,c]=o,u=[4.0767416621*s-3.3077115913*a+0.2309699292*c,-1.2684380046*s+2.6097574011*a-0.3413193965*c,-0.0041960863*s-0.7034186147*a+1.707614701*c];if(u.some((f)=>f<-0.0001||f>1.0001))return;return u.map((f)=>{let l=Math.min(1,Math.max(0,f));return Math.round(255*(l<=0.0031308?12.92*l:1.055*l**0.4166666666666667-0.055))})}function Cs(t,e,n){if(Ln(t,n,e)!==void 0)return n;let r=0,i=n;for(let o=0;o<24;o++){let s=(r+i)/2;if(Ln(t,s,e)===void 0)i=s;else r=s}return r}function Xe(t,e,n){return`#${(Ln(t,Cs(t,n,e),n)??[0,0,0]).map((i)=>i.toString(16).padStart(2,"0")).join("")}`}function v8(t,e){let{l:n,c:r}=xt(t);return Xe(n,r,(e+360)%360)}function E8(t,e,n){let{l:r,c:i,h:o}=xt(t),s=Et(e)<0.18,a=(f)=>Xe(s?r+(1-r)*f:r*(1-f),i,o);if($t(a(1),e)<n+VE)return a(1);let c=0,u=1;for(let f=0;f<30;f++){let l=(c+u)/2;if($t(a(l),e)>=n+VE)u=l;else c=l}return a(u)}function S8(t,e){let{l:n,c:r,h:i}=xt(t),o=0,s=n;for(let a=0;a<30;a++){let c=(o+s)/2;if(Et(Xe(c,r,i))<=e-0.005)o=c;else s=c}return Xe(o,r,i)}function M8(t,e,n){let r=xe[e],[i,o]=[xt(t[e]),xt(t[e+8])],s=(f,l)=>n.has(f)?[l]:Array.from({length:2*r.width+1},(d,h)=>(r.center-r.width+h+360)%360),a=(f,l,d)=>xr.every((h)=>{let m=(f>8?8:0)+h;if(m===f)return!0;let p=xt(t[m]);return p.c<Si||Oe(p.h,l)>=Io+1||Math.abs(p.l-d)>=Ro}),c,u=Number.POSITIVE_INFINITY;for(let f of s(e,i.h)){if(!n.has(e)&&!a(e,f,i.l))continue;for(let l of s(e+8,o.h)){if(Oe(f,l)>en-Zp||!n.has(e+8)&&!a(e+8,l,o.l))continue;let d=Oe(f,i.h)+Oe(l,o.h);if(d<u)u=d,c=[f,l]}}return c}class QE{theme;moves=[];constructor(t){this.theme={...t,ansi:[...t.ansi]}}set(t,e,n){let r=this.get(t);if(n===r)return;if(this.moves.push({slot:t,rule:e,from:r,to:n}),t==="foreground")this.theme.foreground=n;else if(t==="selection")this.theme.selectionBackground=n;else this.theme.ansi[Number(t.slice(4))]=n}get(t){if(t==="foreground")return this.theme.foreground;if(t==="selection")return this.theme.selectionBackground;return this.theme.ansi[Number(t.slice(4))]}rehue(t,e,n){this.set(`ansi${t}`,e,v8(this.theme.ansi[t],n))}roles(){let t=new Set(this.theme.signatureSlots);for(let{slot:n,hue:r}of Or(this.theme)){let i=xe[wn(n)];this.rehue(n,"ansi-role",i.center+XE(i.center,r)*(i.width-Zp))}for(let{normal:n,gap:r}of qn(this.theme)){if(r<=en)continue;let[i,o]=t.has(`ansi${n+8}`)?[n+8,n]:[n,n+8],s=xt(this.theme.ansi[i]).h,a=xt(this.theme.ansi[o]).h;this.rehue(o,"bright-follows",s+XE(s,a)*(en-Zp))}let e=Po(this.theme);for(let[n,r]of Dn(this.theme)){let i=wn(e.has(r)?n:r),o=M8(this.theme.ansi,i,e);if(o===void 0)continue;this.rehue(i,"distinct",o[0]),this.rehue(i+8,"distinct",o[1])}}readability(){let t=new Set(this.theme.waive),{background:e}=this.theme,n=(r,i,o,s=e)=>{if(t.has(r))return;for(let a of i)if($t(this.get(a),s)<o)this.set(a,r,E8(this.get(a),s,o))};if(n("foreground",["foreground"],7),n("accents",y8.map((r)=>`ansi${r}`),3),n("light-ansi",["ansi7","ansi15"],7),n("ansi8-visible",["ansi8"],1.6),!t.has("ansi0-dark")&&Et(this.get("ansi0"))>0.15)this.set("ansi0","ansi0-dark",S8(this.get("ansi0"),0.15));n("selection",["selection"],7,this.theme.foreground)}net(){return[...new Set(this.moves.map((t)=>t.slot))].flatMap((t)=>{let e=this.moves.filter((i)=>i.slot===t),n=e[0].from,r=this.get(t);return n===r?[]:[{slot:t,rule:[...new Set(e.map((i)=>i.rule))].join(", "),from:n,to:r}]})}}function Kl(t){let e=new QE(t);for(let n=0;n<k8;n++)if(e.readability(),e.roles(),Jn(e.theme).length===0)break;return{theme:e.theme,moves:e.net(),left:Jn(e.theme)}}var lo=[{key:"background",label:"Background",min:0,max:0.5,step:0.01,digits:2},{key:"foreground",label:"Foreground",min:0.5,max:1,step:0.01,digits:2},{key:"hue",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0},{key:"tint",label:"Tint",min:0,max:0.1,step:0.005,digits:3},{key:"lightness",label:"Accent lightness",min:0.4,max:0.95,step:0.01,digits:2},{key:"chroma",label:"Accent chroma",min:0,max:0.3,step:0.005,digits:3},{key:"brights",label:"Brights",min:-0.2,max:0.2,step:0.01,digits:2}],hc={background:0.21,foreground:0.88,hue:265,tint:0.02,lightness:0.72,chroma:0.12,brights:0.06},tS=(t,e,n)=>Math.min(n,Math.max(e,t));function Vp(t,e,n){let r=t[e.key]+e.step*n,i=e.wraps?(r%e.max+e.max)%e.max:tS(r,e.min,e.max);return{...t,[e.key]:Math.round(i*1e4)/1e4}}function mi(t){let e=(r,i,o)=>Xe(tS(r,0,1),i,o),n=Array.from({length:16},()=>"#000000");n[0]=e(t.background+0.06,t.tint,t.hue),n[8]=e(t.background+0.25,t.tint,t.hue),n[7]=e(t.foreground-0.06,t.tint/2,t.hue),n[15]=e(t.foreground+0.06,t.tint/2,t.hue);for(let r of xr){let i=xe[r].center;n[r]=e(t.lightness,t.chroma,i),n[r+8]=e(t.lightness+t.brights,t.chroma,i)}return{background:e(t.background,t.tint,t.hue),foreground:e(t.foreground,t.tint/2,t.hue),cursor:e(t.lightness+t.brights,Math.max(t.chroma,0.08),t.hue),selection:e(t.background+0.1,t.tint*2,t.hue),ansi:n}}var Cn=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)],T=["Background","Foreground","Cursor","Selection"],mn=["Black","Red","Green","Yellow","Blue","Magenta","Cyan","White"],x8=["Behind every cell","Plain text","The cursor block","Selected text","Text on colored bars, dark shades","Errors, deleted lines, failed tests","Success, added lines, prompts","Warnings, commit hashes, skipped tests","Directories, info, keywords","Keywords, branches, pictures in ls","Links, diff hunks, types","Light shades, text in some programs","Comments, muted text, suggestions"],gr=T.length+mn.length,hn=[{key:"l",label:"Lightness",min:0,max:1,step:0.01,digits:2},{key:"c",label:"Chroma",min:0,max:0.37,step:0.005,digits:3},{key:"h",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0}],eS=5,O8=5,ne=hn.length,js=["this","pair","normals","brights","accents"],zl=[1,2,3,4,5,6,9,10,11,12,13,14],nS=zl.filter((t)=>t<8).map((t)=>T.length+t),rS=zl.filter((t)=>t>8).map((t)=>T.length+t);function Xp(t,e){let n=e-T.length;if(n<0||t==="this")return[e];if(t==="pair")return[T.length+n%8,T.length+8+n%8];let r=t==="normals"?nS:t==="brights"?rS:[...nS,...rS];return r.includes(e)?r:[e]}function I8(){return Array.from({length:gr},(t,e)=>e<T.length?[e]:[e,e+8]).flat()}function R8(t){let e=t.trim();return/^https?:\/\/\S+$/i.test(e)||Ls(e).length>0}function Qe(t){return[t.background,t.foreground,t.cursor,t.selection,...t.ansi]}function re(t){let[e,n,r,i,...o]=t;return{background:e,foreground:n,cursor:r,selection:i,ansi:o}}function Ge(t){if(t<T.length)return{name:T[t],about:Cn[t]};let e=t-T.length,n=mn[e%8];return e<8?{name:n,about:`ANSI ${e}`}:{name:`Bright ${n.toLowerCase()}`,about:`ANSI ${e}`}}function aS(t){let e=t-T.length;if(e>=9&&e<=15)return`Bold or bright ${mn[e-8].toLowerCase()} text`;return x8[t]}var fo=(t,e,n)=>Math.min(n,Math.max(e,t));function iS(t){return t.length===1?t.toLowerCase():t}function P8(t){return fo(Math.round(t),0,255).toString(16).padStart(2,"0")}function oS(t){let e=t.trim().toLowerCase(),n=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/.exec(e);if(n){let o=n[1];return`#${o.length===3?[...o].map((s)=>s+s).join(""):o}`}let r=/^rgb\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)\s*\)$/.exec(e);if(r)return`#${r.slice(1,4).map((o)=>P8(Number(o))).join("")}`;let i=/^oklch\(\s*([\d.]+)(%?)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:deg|°)?\s*\)$/.exec(e);if(i){let o=Number(i[1])/(i[2]?100:1);return Xe(fo(o,0,1),Number(i[3]),Number(i[4])%360)}return}function ho(t){let e=Ie.find((n)=>n.rule===t);return e?.min??e?.max??0}function br(t,e,n){let r=re(t);return{name:"draft",background:r.background,foreground:r.foreground,selectionBackground:r.selection,ansi:r.ansi,waive:n,signatureSlots:e}}function A8(t,e){let n=t-T.length,r=t<=1?"foreground":t===3?"selection":n===7||n===15?"light-ansi":n===8?"ansi8-visible":zl.includes(n)?"accents":void 0;return{against:t===0||t===3?1:0,floor:r===void 0||e.includes(r)?void 0:ho(r)}}function ng(t,e,n,r){let i=br(t,e,n),{background:o,foreground:s,selection:a,ansi:c}=re(t),u=(f,l,d)=>$t(l,d)<ho(r)?[f]:[];if(r==="foreground")return $t(s,o)<ho(r)?[1,0]:[];if(r==="selection")return $t(s,a)<ho(r)?[3,1]:[];if(r==="accents")return zl.flatMap((f)=>u(T.length+f,c[f],o));if(r==="light-ansi")return[7,15].flatMap((f)=>u(T.length+f,c[f],o));if(r==="ansi8-visible")return u(T.length+8,c[8],o);if(r==="ansi0-dark")return Et(c[0])>ho(r)?[T.length]:[];if(r==="ansi-role")return Or(i).map(({slot:f})=>T.length+f);if(r==="bright-follows")return qn(i).filter(({gap:f})=>f>en).flatMap(({normal:f})=>[T.length+f,T.length+f+8]);if(r==="distinct")return Dn(i).flatMap(([f,l])=>[T.length+f,T.length+l]);return[]}function rg(t,e,n){return new Set(Cn.flatMap((r,i)=>ig(t,e,n,i).some((o)=>o.ok===!1)?[i]:[]))}function pr(t,e,n,r,i){let o=$t(t,e),s=ho(n);if(i.includes(n))return{ok:void 0,text:`${r} ${o.toFixed(2)}:1 · waived`};return{ok:o>=s,text:`${r} ${o.toFixed(2)}:1 · ≥ ${s}`}}function ig(t,e,n,r){let i=re(t),o=br(t,e,n);if(r===0){let $=[1,2,3,4,5,6,9,10,11,12,13,14].reduce((k,v)=>$t(i.ansi[k],i.background)<=$t(i.ansi[v],i.background)?k:v);return[pr(i.foreground,i.background,"foreground","Foreground on it",n),pr(i.ansi[$],i.background,"accents",`Weakest, ANSI ${$},`,n),pr(i.ansi[8],i.background,"ansi8-visible","ANSI 8 on it",n)]}if(r===1)return[pr(i.foreground,i.background,"foreground","On background",n),pr(i.foreground,i.selection,"selection","On the selection",n)];if(r===2)return[{ok:void 0,text:`On background ${$t(i.cursor,i.background).toFixed(2)}:1`}];if(r===3)return[pr(i.foreground,i.selection,"selection","Foreground on it",n)];let s=r-T.length,a=i.ansi[s];if(s===0){let b=Et(a),$=ho("ansi0-dark");return[n.includes("ansi0-dark")?{ok:void 0,text:`Luminance ${b.toFixed(3)} · waived`}:{ok:b<=$,text:`Luminance ${b.toFixed(3)} · ≤ ${$}`}]}if(s===7||s===15)return[pr(a,i.background,"light-ansi","On background",n)];if(s===8)return[pr(a,i.background,"ansi8-visible","On background",n)];let c=[pr(a,i.background,"accents","On background",n)],u=xt(a),f=wn(s),l=xe[f],d=`${l.name} ${l.center}±${l.width}°`;if(u.c<Si)c.push({ok:void 0,text:"Too grey to have a hue"});else if(Po(o).has(s))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · a signature, free of ${d}`});else if(n.includes("ansi-role"))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · ${d} waived`});else{let b=Oe(u.h,l.center)-l.width;c.push(b>0?{ok:!1,text:`Hue ${u.h.toFixed(0)}° · ${b.toFixed(0)}° outside ${d}`}:{ok:!0,text:`Hue ${u.h.toFixed(0)}° · in ${d}`})}let h=s<8?s+8:s-8,m=qn(o).find((b)=>b.normal===f);if(m)c.push(n.includes("bright-follows")?{ok:void 0,text:`${m.gap.toFixed(0)}° from ANSI ${h} · waived`}:{ok:m.gap<=en,text:`${m.gap.toFixed(0)}° from ANSI ${h} · ≤ ${en}°`});let p=Dn(o).flatMap(([b,$])=>b===s?[$]:$===s?[b]:[]);if(p.length>0&&!n.includes("distinct"))c.push({ok:!1,text:`Reads as ANSI ${p.join(", ")} · within ${Io}° and ${Ro} lightness`});return c}function og(t,e,n){let r=$n(br(t,e,n));return Ie.map((i,o)=>{let s=r[o],a=n.includes(i.rule),c=a||Number.isNaN(s)?void 0:(i.min===void 0||s>=i.min)&&(i.max===void 0||s<=i.max);return{ok:c,label:i.label,value:Number.isNaN(s)?"—":Number.isInteger(s)?String(s):s.toFixed(2),bound:a?"waived":i.min!==void 0?`≥ ${i.min}`:i.max!==void 0?`≤ ${i.max}`:"",slots:c===!1?ng(t,e,n,i.rule):[]}})}var N8=new Set(["reset","reset-all","hex","paste","fix","open","tune","sig","follow"]),cS=hn[1].max;function eg(t){let[e,n,r]=st(t);return e===n&&n===r}function T8(t,e){let n=xt(e);if(!eg(e))return n;let r=[0,1,3,2].map((i)=>t[i]).find((i)=>!eg(i));return{...n,h:r?xt(r).h:hc.hue}}function uS(t,e,n){if(t==="rgb"){let[r,i,o]=st(e);return`rgb(${r} ${i} ${o})`}if(t==="oklch")return`oklch(${n.l.toFixed(3)} ${n.c.toFixed(3)} ${n.h.toFixed(0)})`;return e}function Qp(t,e){return Math.floor(Cs(t,e,cS)*1e4)/1e4}function tg(t,e){return{l:e.l-t.l,c:e.c-t.c,h:((e.h-t.h)%360+540)%360-180}}function sS(t,e){let n=t.wraps?t.max-t.step:t.max;return Math.min(n,Math.round((t.min+(t.max-t.min)*e)/t.step)*t.step)}class sg{mode;seeds=hc;field=0;list;lch;start;original;signature;row=0;col=0;channel=0;scope="this";view="slot";scene=0;typing;overlay;quitting=!1;compare=!1;notice;filter="";pick=0;result;wants;pictures;inspect=!1;spot;format="hex";pic=!0;menu;entry=0;changedOnly=!1;where=!1;size;copied;startPictures;options;fresh;tone;startSignature;seeded=!1;tuneFrom;holds=new Map;clip;history=[];future=[];lastEdit;links=new Map;unlinked=new Set;offsets=new Map;constructor(t){this.options=t,this.tone=t.tone===!0,this.fresh=t.colors===void 0,this.mode=this.fresh?"seeds":"list",this.list=Qe(t.colors??mi(this.seeds)),this.lch=this.lchs(),this.start=[...this.list],this.original=t.original?Qe(t.original):[...this.list],this.signature=[...t.signature],this.startSignature=[...t.signature],this.pictures=t.pictures??0,this.startPictures=this.pictures,this.chain(this.original)}chain(t){this.links=new Map,this.unlinked=new Set,this.offsets=new Map;for(let e=0;e<8;e++){let n=T.length+e,r=n+8,i=this.lchOf(t[n]),o=this.lchOf(t[r]);if(i.c>=Si&&o.c>=Si&&Oe(i.h,o.h)<=3)this.links.set(r,n),this.offsets.set(r,tg(i,o))}}pair(t){if(t<T.length)return;let e=T.length+(t-T.length)%8,n=e+8;return{normal:e,bright:n,on:this.linkOf(n)!==void 0,lift:this.lch[n].l-this.lch[e].l}}linkOf(t){let e=this.links.get(t);return e!==void 0&&!this.unlinked.has(t)?e:void 0}changed(t){return this.list[t]!==this.original[t]}visible(t){return!this.changedOnly||this.changed(t)}changes(){return this.list.filter((t,e)=>this.changed(e)).length}slotAt(t,e){return t<T.length?t:t+(e===1?8:0)}get added(){return Math.max(0,this.pictures-this.startPictures)}found(t){this.pictures=t.count,this.notice=t.note}get waive(){return this.options.waive??[]}get held(){return this.holds.get(this.slot())}colors(){return re(this.list)}edited(){return{colors:this.colors(),signature:[...this.signature]}}shown(){return this.compare?this.start:this.list}slot(){return this.row<T.length?this.row:this.row+(this.col===1?8:0)}dirty(){return this.seeded||this.pictures!==this.startPictures||this.list.some((t,e)=>t!==this.start[e])||this.signature.join()!==this.startSignature.join()}resettable(){return this.dirty()||this.tone&&this.list.some((t,e)=>t!==this.original[e])}misses(){return rg(this.list,this.signature,this.waive)}failing(){return Jn(br(this.list,this.signature,this.waive))}choices(){let t=this.filter.toLowerCase();return(this.options.palettes??[]).filter((e)=>e.name.toLowerCase().includes(t))}paste(t){if(this.notice=void 0,this.overlay==="open"){this.filter+=t.replace(/\s+/g,"").toLowerCase(),this.pick=0;return}if(this.overlay)return;if(!this.tone&&t.trim()===""){this.findPictures({clipboard:!0});return}if(!this.tone&&R8(t)){this.findPictures({paste:t});return}if(this.mode==="seeds")return;let e=this.options.decode?.(t);if(e){this.remember("open"),this.list=Qe(e),this.lch=this.lchs(),this.chain(this.list),this.notice="Took the colors of the share code";return}let n=oS(t);if(!n){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}this.typing=void 0,this.take(n,"paste")}press(t){if(this.notice=void 0,t==="ctrl-c"){this.result="cancelled";return}if(this.quitting){if(this.quitting=!1,t==="y"||t==="Y")this.result="cancelled";return}if(this.typing!==void 0){this.type(t);return}if(this.overlay==="keys"){this.overlay=void 0;return}if(this.overlay==="open"){this.openKey(t);return}if(this.menu){this.menuKey(t);return}if(t==="?"){this.overlay="keys";return}if(this.inspect&&this.mode==="list"&&this.inspectKey(t))return;if(this.tone&&(t==="ctrl-v"||t==="alt-v"||t==="p"))return;if(t==="ctrl-v"||t==="alt-v"){this.findPictures({clipboard:!0});return}if(t==="p"&&this.mode!=="tune"){this.findPictures();return}if(t===" "&&this.mode!=="seeds"){this.compare=!this.compare;return}if(this.compare&&t==="esc"){this.compare=!1;return}if(t==="g"&&this.mode!=="seeds"){this.view=this.view==="slot"?"relations":"slot";return}let e=t==="j"?"down":t==="k"?"up":t;if(this.mode==="seeds")this.seedKey(e);else if(this.mode==="tune")this.tuneKey(e);else this.listKey(e)}select(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return;if(this.mode==="tune"){if(t===this.slot())return;this.tuneKey("enter")}this.notice=void 0,this.seat(t),this.lastEdit=void 0}seat(t){if(this.row=t<T.length?t:T.length+(t-T.length)%8,t>=T.length)this.col=t-T.length>=8?1:0}grip(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return!1;if(this.notice=void 0,this.mode==="list")this.tune();return this.channel=t,!0}slide(t,e){if(!this.grip(t))return;let n=Math.min(1,Math.max(0,e));if(t===ne){this.reach(21**n);return}this.put(sS(hn[t],n))}sow(t,e){let n=lo[t];if(this.mode!=="seeds"||this.overlay||this.quitting||!n)return;this.notice=void 0,this.field=t;let r=Math.min(1,Math.max(0,e));this.seeds=Vp({...this.seeds,[n.key]:sS(n,r)},n,0),this.list=Qe(mi(this.seeds)),this.lch=this.lchs()}scroll(t){let e=(n,r)=>Math.min(r,Math.max(0,n+t));if(this.overlay==="open")this.pick=e(this.pick,Math.max(0,this.choices().length-1));else if(this.overlay||this.quitting||this.typing!==void 0)return;else if(this.mode==="seeds")this.field=e(this.field,lo.length-1);else if(this.mode==="tune")this.channel=0,this.step(-t);else this.row=e(this.row,gr-1),this.lastEdit=void 0}lchOf(t){return T8(this.list,t)}lchs(){return this.list.map((t)=>this.lchOf(t))}seedKey(t){let e=lo.length;if(t==="up"||t==="down")this.field=(this.field+(t==="up"?e-1:1))%e;else if(t==="home"||t==="end")this.field=t==="home"?0:e-1;else if(t==="left"||t==="right"||t==="shift-left"||t==="shift-right"){let n=lo[this.field],r=(t.endsWith("left")?-1:1)*(t.startsWith("shift")?n.wraps?10:eS:1);this.seeds=Vp(this.seeds,n,r),this.list=Qe(mi(this.seeds)),this.lch=this.lchs()}else if(t==="enter")this.leaveSeeds();else if(t==="o")this.openPalettes();else if(t==="esc")this.leave()}leaveSeeds(){this.start=[...this.list],this.original=[...this.list],this.chain(this.original),this.seeded=!0,this.mode="list"}leave(){if(this.dirty())this.quitting=!0;else this.result="cancelled"}findPictures(t){if(!this.options.find){this.notice="Pictures need Ghostty, iTerm2 or kitty, outside tmux";return}this.wants=t?{start:t}:{}}openPalettes(){if((this.options.palettes??[]).length>0)this.overlay="open",this.pick=0;else this.notice="No other palettes to take colors from"}listKey(t){if(t==="up"||t==="down"){let e=t==="up"?-1:1;this.land(this.row+e,e),this.lastEdit=void 0}else if(t==="home"||t==="end")this.land(t==="home"?0:gr-1,t==="home"?1:-1);else if(t==="pgup"||t==="pgdn")this.land(t==="pgup"?0:T.length,1);else if(t==="left"||t==="right"){let e=t==="left"?0:1;if(this.row>=T.length&&this.visible(this.slotAt(this.row,e)))this.col=e,this.lastEdit=void 0}else if(this.builderKey(t))return;else if(t==="shift-left"||t==="shift-right")this.scene+=t==="shift-left"?-1:1;else if(t==="n"||t==="N")this.nextMiss(t==="n"?1:-1);else if(t==="enter"||t==="tab")this.tune();else if(t==="#")this.typing="";else if(t==="c")this.clip=this.list[this.slot()],this.notice=`Copied ${this.clip}`;else if(t==="v")if(this.clip)this.set(this.slot(),this.clip,"paste");else this.notice="Nothing copied yet — c copies a slot";else if(t==="r")this.set(this.slot(),this.original[this.slot()],"reset");else if(t==="R")this.remember("reset-all"),this.list=[...this.original],this.lch=this.lchs();else if(t==="=")this.follow();else if(t==="*"&&!this.tone)this.mark();else if(t==="f")this.fix();else if(t==="o"&&!this.tone)this.openPalettes();else if(t==="u")this.undo();else if(t==="ctrl-r")this.redo();else if(t==="s"||t==="ctrl-s")this.save();else if(t==="esc")this.leave()}viewport(t,e){this.size={cols:t,rows:e}}layout(){return this.size?lc(this.size.cols,this.size.rows,this.scene):void 0}get roomy(){return this.layout()!==void 0}reseat(){if(!this.visible(this.slot()))this.land(this.row,1)}rowShown(t){return this.visible(this.slotAt(t,0))||t>=T.length&&this.visible(this.slotAt(t,1))}land(t,e){for(let n=0;n<gr;n++){let r=((t+e*n)%gr+gr)%gr;if(this.rowShown(r)){if(this.row=r,r>=T.length&&!this.visible(this.slotAt(r,this.col)))this.col=1-this.col;return}}}builderKey(t){if(["i","m","w","x","I"].includes(t)&&!this.roomy)return this.notice="The builder needs a window of at least 96×28",!0;if(t==="i")this.startInspect();else if(t==="l")this.linkKey();else if(t==="m")this.changedOnly=!this.changedOnly,this.reseat(),this.notice=this.changedOnly?this.changes()>0?void 0:"Nothing changed yet":void 0;else if(t==="b")this.pic=!this.pic;else if(t==="w")this.where=!this.where;else if(t==="x"&&this.options.exports)this.menu="export",this.entry=0;else if(t==="I")this.menu="import",this.entry=0;else return!1;return!0}menuKey(t){let e=this.menu==="export"?3:2;if(t==="esc")this.menu=void 0;else if(t==="up"||t==="down"||t==="k"||t==="j")this.entry=(this.entry+(t==="up"||t==="k"?e-1:1))%e;else if(t==="enter")this.choose(this.entry)}choose(t){let e=this.menu;if(this.menu=void 0,e==="import"){if(t===0)this.openPalettes();else this.notice=this.options.decode?"Paste a share link or a tt2: code into this window":"Share codes are not read here";return}let n=this.options.exports;if(e!=="export"||!n)return;try{let r=this.edited(),i=n.code(r);this.copied=t===0?i:t===1?`${n.command} ${i}`:n.toml(r),this.notice=`Copied ${t===0?"the share code":t===1?"the add command":"the palette file"} — paste it where you need it`}catch(r){this.notice=r instanceof Error?r.message:String(r)}}openMenu(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return;this.menu=this.menu===t?void 0:t,this.entry=0}startInspect(){let t=this.layout();if(!t){this.notice="The builder needs a window of at least 96×28";return}this.inspect=!0,this.spot=HE(t,this.slot())}toggleInspect(){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return;if(this.inspect)this.inspect=!1,this.spot=void 0;else this.startInspect()}inspectKey(t){let e=this.layout();if(!e)return this.inspect=!1,!1;let r={left:"left",right:"right",up:"up",k:"up",down:"down",j:"down",tab:"next","shift-tab":"previous"}[t];if(t==="i"||t==="esc")this.inspect=!1,this.spot=void 0;else if(r)this.spot=FE(e,jl(e,this.spot),r);else if(t==="shift-left"||t==="shift-right")this.scene+=t==="shift-left"?-1:1,this.spot=void 0;else if(t==="enter")this.jump();else return!1;return!0}point(t){if(this.mode!=="seeds"&&!this.overlay&&!this.quitting&&this.typing===void 0&&this.layout())this.inspect=!0,this.spot=t}slotsHere(){let t=this.layout();return t&&this.spot?LE(t,this.spot):void 0}jump(){let t=this.slotsHere();if(!t)return;let e=t.ground!==0?t.ground:t.text;this.inspect=!1,this.spot=void 0,this.show(e),this.select(e)}show(t){if(!this.visible(t))this.changedOnly=!1}openSlot(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return;let e=this.mode==="tune"&&t===this.slot();if(this.mode==="tune")this.tuneKey("enter");if(e)return;if(this.show(t),this.select(t),this.mode==="list")this.tune()}dismiss(){if(this.mode!=="tune"||this.overlay||this.quitting)return;this.typing=void 0,this.tuneKey("enter")}plane(t,e){if(!this.grip(0))return;this.channel=0,this.put(t),this.channel=1,this.put(e)}linkKey(){let t=this.slot();if(t<T.length){this.notice="l links a bright to its normal — pick an ANSI row";return}let e=T.length+(t-T.length)%8,n=e+8,r=`${Ge(n).name} and ${Ge(e).name.toLowerCase()}`;if(this.mode!=="tune")this.remember("link");if(this.linkOf(n)!==void 0){this.unlinked.add(n),this.notice=`${r} move apart`;return}this.links.set(n,e),this.unlinked.delete(n),this.offsets.set(n,tg(this.lch[e],this.lch[n])),this.notice=`${r} move together`}nextMiss(t){let e=I8(),n=this.misses();if(n.size===0){this.notice="The gate passes";return}let r=e.indexOf(this.slot());for(let i=1;i<=e.length;i++){let o=e[((r+t*i)%e.length+e.length)%e.length];if(n.has(o)){this.seat(o);return}}}tune(){this.remember("tune"),this.tuneFrom={list:[...this.list],lch:[...this.lch]},this.holds=new Map,this.hold(),this.mode="tune"}hold(){for(let t of this.scoped())if(!this.holds.has(t))this.holds.set(t,this.lch[t].c)}scoped(){return Xp(this.scope,this.slot())}tuneKey(t){let e=this.channel===ne;if(t==="tab"||t==="shift-tab")this.channel=e?0:ne;else if(t==="up"||t==="down"||t==="pgup"||t==="pgdn")this.channel=0,this.step((t==="up"||t==="pgup"?1:-1)*(t.startsWith("pg")?eS:1));else if(t==="left"||t==="right"){let n=t==="left"?-1:1;if(e)this.reach(this.ratio()+n*0.1);else this.channel=1,this.step(n)}else if(t==="shift-left"||t==="shift-right"){let n=t==="shift-left"?-1:1;if(e)this.reach(this.ratio()+n*0.5);else this.channel=2,this.step(n*O8)}else if((t===","||t===".")&&!e)this.channel=2,this.step(t===","?-1:1);else if(t==="home"||t==="end")if(e)this.reach(t==="home"?this.partner().floor??1:21);else{let n=hn[this.channel];this.put(t==="home"?n.min:n.wraps?n.max-n.step:n.max)}else if(/^[0-9]$/.test(t))if(e){if(t!=="0")this.reach(Number(t))}else{let n=hn[this.channel];this.put(n.min+(n.max-n.min)*Number(t)/10)}else if(t==="a")this.rescope();else if(t==="#")this.typing="";else if(t==="l")this.linkKey();else if(t==="s"||t==="ctrl-s")this.tuneKey("enter"),this.save();else if(t==="enter"){if(this.tuneFrom&&this.list.every((n,r)=>n===this.tuneFrom?.list[r]))this.history.pop();this.endTune()}else if(t==="esc"){if(this.tuneFrom)this.list=[...this.tuneFrom.list],this.lch=[...this.tuneFrom.lch],this.history.pop();this.endTune()}}rescope(){if(this.slot()<T.length){this.notice="A base color moves alone";return}let t=js.indexOf(this.scope);for(let e=1;e<=js.length;e++){let n=js[(t+e)%js.length];if(n==="this"||Xp(n,this.slot()).length>1){this.scopeTo(n);return}}}scopeTo(t){if(this.mode!=="tune"||this.typing!==void 0||this.quitting||this.slot()<T.length)return;if(t!=="this"&&Xp(t,this.slot()).length<=1)return;this.scope=t,this.hold();let e=this.scoped().length;this.notice=e>1?`${e} slots move together`:"This slot moves alone"}endTune(){this.tuneFrom=void 0,this.holds=new Map,this.mode="list"}partner(){return A8(this.slot(),this.waive)}ratio(){return $t(this.list[this.slot()],this.list[this.partner().against])}origin(){let t=this.slot(),e=this.original[t];if(e===this.list[t])return;return{hex:e,lch:this.lchOf(e),ratio:$t(e,this.original[this.partner().against])}}reach(t){let e=this.slot(),n=this.list[this.partner().against],r=this.lch[e],i=this.holds.get(e)??r.c,o=(d)=>Xe(d,Math.min(i,Qp(d,r.h)),r.h),s=(d)=>$t(o(d),n),a=Et(this.list[e])>=Et(n),c=xt(n).l,u=Math.max(1,Math.round(t*100)/100),f=a?1:0,l;if(s(f)<u)l=f,this.notice=`The ratio stops at ${s(f).toFixed(2)}:1 on this side of the color it is read against`;else{let d=c,h=f;for(let m=0;m<24;m++){let p=(d+h)/2;if(s(p)>=u)h=p;else d=p}l=h}this.place(e,l,i,r.h);for(let d=0;d<40&&l!==f&&$t(this.list[e],n)<u;d++)l=a?Math.min(1,l+0.001):Math.max(0,l-0.001),this.place(e,l,i,r.h);this.lch[e]={...this.lch[e],l:Math.round(l*1e4)/1e4}}step(t){let e=hn[this.channel],n=this.lch[this.slot()][e.key];this.put(n+e.step*t)}put(t){let e=this.slot(),n=hn[this.channel],r=n.wraps?(t%n.max+n.max)%n.max:fo(t,n.min,n.max),i=Math.round(r*1e4)/1e4,o=this.lch[e],s=this.scoped().filter((u)=>u!==e),a=(u)=>Math.round(u*1e4)/1e4;if(n.key==="c"){let u=Qp(o.l,o.h);if(i>u)this.notice=`Chroma stops at ${u.toFixed(3)}, the sRGB edge for this lightness and hue`;let f=Math.min(i,u),l=f-o.c;this.holds.set(e,f),this.place(e,o.l,f,o.h);for(let d of s){let h=this.lch[d],m=a(fo((this.holds.get(d)??h.c)+l,0,cS));this.holds.set(d,m),this.place(d,h.l,m,h.h)}this.trail([e,...s]);return}let c=n.key==="h"?((i-o.h)%360+540)%360-180:i-o.l;if(this.place(e,n.key==="l"?i:o.l,this.holds.get(e)??o.c,n.key==="h"?i:o.h),n.key==="h"&&eg(this.list[e]))this.notice="A grey shows no hue — raise its chroma first";for(let u of s){let f=this.lch[u];this.place(u,n.key==="l"?a(fo(f.l+c,0,1)):f.l,this.holds.get(u)??f.c,n.key==="h"?a(((f.h+c)%360+360)%360):f.h)}this.trail([e,...s])}trail(t){let e=new Set(t);for(let[n,r]of this.links){if(this.unlinked.has(n))continue;if(e.has(n)&&!e.has(r))this.unlinked.add(n);else if(e.has(r)&&!e.has(n)){let i=this.lch[r],o=this.offsets.get(n);this.place(n,fo(i.l+o.l,0,1),Math.max(0,i.c+o.c),((i.h+o.h)%360+360)%360)}}}place(t,e,n,r){let i=Math.min(n,Qp(e,r));this.lch[t]={l:e,c:i,h:r},this.list[t]=Xe(e,i,r)}take(t,e){if(this.mode==="tune")this.list[this.slot()]=t,this.lch[this.slot()]=this.lchOf(t),this.holds.set(this.slot(),this.lch[this.slot()].c),this.trail([this.slot()]);else this.set(this.slot(),t,e)}type(t){let e=this.typing??"";if(t==="esc")this.typing=void 0;else if(t==="enter"){let n=oS(e);if(!n){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}this.typing=void 0,this.take(n,"hex")}else{let n=oo(e,iS(t),(r)=>/^[0-9a-z#(),.% ]$/.test(r)&&e.length<28);if(n!==void 0)this.typing=n}}openKey(t){let e=this.choices();if(t==="esc")this.overlay=void 0,this.filter="";else if(t==="up"||t==="down"){let n=Math.max(1,e.length);this.pick=(this.pick+(t==="up"?n-1:1))%n}else if(t==="home"||t==="end")this.pick=t==="home"?0:Math.max(0,e.length-1);else if(t==="enter"){let n=e[this.pick];if(!n)return;if(this.remember("open"),this.list=Qe(n.colors),this.lch=this.lchs(),this.chain(this.list),this.overlay=void 0,this.filter="",this.notice=`Took the colors of ${n.name}`,this.mode==="seeds")this.leaveSeeds()}else{let n=oo(this.filter,iS(t),(r)=>/^[a-z0-9@/-]$/.test(r));if(n!==void 0)this.filter=n,this.pick=0}}remember(t){if(t!==this.lastEdit||N8.has(t))this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.future=[];this.lastEdit=t}set(t,e,n){if(!he(e)||this.list[t]===e)return;this.remember(n),this.list[t]=e,this.lch[t]=this.lchOf(e),this.trail([t])}follow(){if(this.row<T.length){this.notice="= works on an ANSI row — the bright takes its normal";return}let t=this.row,e=this.row+8,n=this.lch[t];this.remember("follow"),this.place(e,fo(n.l+0.06,0,1),n.c,n.h),this.links.set(e,t),this.unlinked.delete(e),this.offsets.set(e,tg(n,this.lch[e])),this.seat(e),this.notice=`${Ge(e).name} follows ${Ge(t).name.toLowerCase()}`}mark(){let t=Cn[this.slot()];this.remember("sig");let e=this.signature.includes(t)?this.signature.filter((r)=>r!==t):[...this.signature,t],n=e.length>3?e[0]:void 0;this.signature=e.slice(-3),this.notice=this.signature.length===3?`Signature: ${this.signature.join(", ")}${n?` — ${n} dropped`:""}`:`The signature needs three slots — ${this.signature.length} marked`}fix(){let t=br(this.list,this.signature,this.waive),{theme:e,moves:n,left:r}=Kl({...t,selectionBackground:t.selectionBackground,signatureSlots:this.signature});if(n.length===0){this.notice=Jn(t).length===0?"Already passes the gate":"No color change fixes it";return}this.remember("fix");let i=Qe({...this.colors(),foreground:e.foreground,selection:e.selectionBackground,ansi:e.ansi}),o=this.list;this.list=i,this.lch=i.map((s,a)=>s===o[a]?this.lch[a]:this.lchOf(s)),this.notice=`Moved ${n.length} ${n.length===1?"color":"colors"}${r.length===0?" — passes the gate":" closer to the gate"}`}save(){let t=this.options.check(this.edited());if(t){this.notice=t;return}this.result="saved"}undo(){let t=this.history.pop();if(!t){this.notice="Nothing to undo";return}this.future.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}redo(){let t=this.future.pop();if(!t){this.notice="Nothing to redo";return}this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}restore(t){this.list=[...t.list],this.lch=[...t.lch],this.signature=[...t.signature],this.lastEdit=void 0}}import{mkdirSync as n3,readFileSync as lg,writeFileSync as SS}from"node:fs";import{dirname as r3}from"node:path";import{isMainThread as i3,parentPort as MS,Worker as o3}from"node:worker_threads";var H8=new Set(["comic","4koma","monochrome","greyscale","sketch","lineart","speech_bubble"]),F8=new Set(["scenery","landscape","scenic","no_humans","wide_shot","very_wide_shot"]),L8=0.04,C8=0.1,j8=0.05,_8=4096;function G8(t){return new Set(t.cutouts.split(/\s+/).map((e)=>e.replace(/^~/,"")).filter(Boolean))}function B8(t,e,n,r=0){let{site:i,post:o}=t,s=new Set(o.tags),a=[...G8(i)].some((f)=>s.has(f)),c=Math.min(o.width,o.height),u=o.width>0&&o.height>0?o.width/o.height/(e.w/e.h):1;return(o.solo?2:0)+([...H8].some((f)=>s.has(f))?-3:0)+([...F8].some((f)=>s.has(f))?-1.5:0)+2*Math.min(1,c/e.h)+(a?1.5:-Math.min(1.5,Math.abs(Math.log(u))))+(n>0?1.5*Math.log1p(Math.max(0,o.score))/Math.log1p(n):0)+2*r}function ql(t,e,n=new Map){let r=new Map;for(let{site:i,post:o}of t)r.set(i,Math.max(r.get(i)??0,o.score));return t.map((i,o)=>({pick:i,at:o,score:B8(i,e,r.get(i.site)??0,n.get(i.post))})).sort((i,o)=>o.score-i.score||i.at-o.at).map(({pick:i})=>i)}function fS(t){let e=new Map;for(let r of t)e.set(r.site,[...e.get(r.site)??[],r]);let n=[];for(let r=0;n.length<t.length;r++)for(let i of e.values()){let o=i[r];if(o)n.push(o)}return n}function ag(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function lS(t,e,n){let[r,i,o]=[ag(t),ag(e),ag(n)],s=Math.cbrt(0.4122214708*r+0.5363325363*i+0.0514459929*o),a=Math.cbrt(0.2119034982*r+0.6806995451*i+0.1073969566*o),c=Math.cbrt(0.0883024619*r+0.2817188376*i+0.6299787005*o);return[0.2104542553*s+0.793617785*a-0.0040720468*c,1.9779984951*s-2.428592205*a+0.4505937099*c,0.0259040371*s+0.7827717662*a-0.808675766*c]}function dS(t,e){let n=e.map((s)=>lS(...st(s))).filter(([,s,a])=>Math.hypot(s,a)>=L8);if(n.length===0)return 0;let r=Math.max(1,Math.floor(Math.sqrt(t.width*t.height/_8))),i=n.map(()=>0),o=0;for(let s=0;s<t.height;s+=r)for(let a=0;a<t.width;a+=r){let c=(s*t.width+a)*4;if(t.data[c+3]<128)continue;o++;let[u,f,l]=lS(t.data[c],t.data[c+1],t.data[c+2]);n.forEach(([d,h,m],p)=>{if(Math.hypot(u-d,f-h,l-m)<C8)i[p]=i[p]+1})}if(o===0)return 0;return i.reduce((s,a)=>s+Math.min(1,a/o/j8),0)/n.length}import{existsSync as cg,mkdirSync as hS,readFileSync as Gs}from"node:fs";import{homedir as D8}from"node:os";import{dirname as mS,join as mo}from"node:path";import{spawn as U8}from"node:child_process";var W8=30000,K8=3,z8=97,q8=`ObjC.import('Vision')
|
|
701
|
+
}`;async function rE(){if(Qp())return;if(process.platform==="darwin"){let[t="",e=""]=(await Ln("osascript",["-l","JavaScript","-e",P8])).stdout.trim().split("\t");return{stamp:t,picture:e==="picture"}}if(process.platform==="linux"&&!eE()){let e=Boolean(process.env.WAYLAND_DISPLAY)?(await Ln("wl-paste",["--list-types"])).stdout:(await Ln("xclip",["-selection","clipboard","-t","TARGETS","-o"])).stdout;return{stamp:e,picture:/^image\//m.test(e)}}return}function Vl(t){return t.length>8&&/^(?:\/|~\/|file:|https?:)/.test(t)}var gc=(t)=>Buffer.from(t).toString("base64"),Vp=(t)=>Buffer.from(t,"base64");function DS(t,e){return e.find((n)=>t.includes(n))}class tg{clipboard=!1;drops=!1;reading;offered=[];dropping;pw=gc(JS("sha1").update(`${process.pid}:${Date.now()}`).digest("hex"));send;deliver;constructor(t,e){this.send=t,this.deliver=e}start(){let t="";if(this.clipboard)t+="\x1B[?5522h";if(this.drops)t+=`\x1B]72;t=a;${Yp.join(" ")}\x1B\\`;this.send(t)}stop(){this.send(`${this.clipboard?"\x1B[?5522l":""}${this.drops?"\x1B]72;t=A\x1B\\":""}`)}ask(){this.reading={mime:".",chunks:[],pw:"",listing:!0},this.send(`\x1B]5522;type=read:name=${gc("ttheme")}:pw=${this.pw};${gc(".")}\x1B\\`)}take(t){if(t.code==="5522")this.clip(t.meta,t.payload);else if(t.code==="72")this.drop(t.meta,t.payload)}clip(t,e){if(t.type!=="read")return;let n=t.status??"";if(n==="OK"){if(this.reading??={mime:".",chunks:[],pw:t.pw??"",listing:!0},t.pw)this.reading.pw=t.pw;return}let r=this.reading;if(!r)return;if(n==="DATA"){if(r.mime=t.mime?Vp(t.mime).toString("utf8"):r.mime,e)r.chunks.push(Vp(e));return}if(this.reading=void 0,n!=="DONE"){this.deliver({kind:"error",message:n==="EPERM"?"The clipboard read was not allowed":`The terminal answered ${n}`});return}let i=Buffer.concat(r.chunks);if(r.listing){let o=i.toString("utf8").split(/\s+/).filter(Boolean),s=DS(o,[...Zp,...S8]);if(!s){this.deliver({kind:"text",text:""});return}let a=r.pw||this.pw,c=r.pw?"Paste event":"ttheme";this.reading={mime:s,chunks:[],pw:a,listing:!1},this.send(`\x1B]5522;type=read:name=${gc(c)}:pw=${a};${gc(s)}\x1B\\`);return}this.deliver(r.mime.startsWith("image/")?{kind:"bytes",bytes:new Uint8Array(i),source:"clipboard"}:{kind:"text",text:i.toString("utf8")})}drop(t,e){let n=t.t??"";if(n==="m"){if(t.x==="-1"){this.offered=[];return}if(e){this.offered=e.split(" ").filter(Boolean);let a=Yp.filter((c)=>this.offered.includes(c));this.send(`\x1B]72;t=m:o=${a.length>0?1:0};${a.join(" ")}\x1B\\`)}return}if(n==="M"){let a=e?e.split(" ").filter(Boolean):this.offered,c=DS(a,Yp);if(!c){this.send("\x1B]72;t=r:o=0\x1B\\");return}this.dropping={mimes:a,index:a.indexOf(c)+1,chunks:[]},this.send(`\x1B]72;t=r:x=${this.dropping.index}\x1B\\`);return}let r=this.dropping;if(!r)return;if(n==="R"){this.dropping=void 0,this.send("\x1B]72;t=r:o=0\x1B\\"),this.deliver({kind:"error",message:`The drop failed: ${e.split(":")[0]||"unknown error"}`});return}if(n!=="r"&&n!=="")return;if(e)r.chunks.push(Vp(e));if(t.m==="1"||e)return;this.dropping=void 0;let i=Buffer.concat(r.chunks),o=r.mimes[r.index-1]??"",s;if(o.startsWith("image/"))s={kind:"bytes",bytes:new Uint8Array(i),source:"drop"};else{let a=i.toString("utf8"),c=o==="text/uri-list"?Cs(a).find((u)=>p8(u)):void 0;s=c?{kind:"bytes",bytes:new Uint8Array(Yl(c)),source:c}:{kind:"text",text:a}}this.send("\x1B]72;t=r:o=1\x1B\\"),this.deliver(s)}}var eg=5,R8=6,iE=0.05,N8=[1,2,3,4,5,6,9,10,11,12,13,14],oE=(t,e)=>(e-t+360)%360<=180?1:-1;function Cn(t,e,n){let r=e*Math.cos(n*Math.PI/180),i=e*Math.sin(n*Math.PI/180),o=[t+0.3963377774*r+0.2158037573*i,t-0.1055613458*r-0.0638541728*i,t-0.0894841775*r-1.291485548*i].map((f)=>f**3),[s,a,c]=o,u=[4.0767416621*s-3.3077115913*a+0.2309699292*c,-1.2684380046*s+2.6097574011*a-0.3413193965*c,-0.0041960863*s-0.7034186147*a+1.707614701*c];if(u.some((f)=>f<-0.0001||f>1.0001))return;return u.map((f)=>{let l=Math.min(1,Math.max(0,f));return Math.round(255*(l<=0.0031308?12.92*l:1.055*l**0.4166666666666667-0.055))})}function js(t,e,n){if(Cn(t,n,e)!==void 0)return n;let r=0,i=n;for(let o=0;o<24;o++){let s=(r+i)/2;if(Cn(t,s,e)===void 0)i=s;else r=s}return r}function Qe(t,e,n){return`#${(Cn(t,js(t,n,e),n)??[0,0,0]).map((i)=>i.toString(16).padStart(2,"0")).join("")}`}function A8(t,e){let{l:n,c:r}=xt(t);return Qe(n,r,(e+360)%360)}function T8(t,e,n){let{l:r,c:i,h:o}=xt(t),s=St(e)<0.18,a=(f)=>Qe(s?r+(1-r)*f:r*(1-f),i,o);if($t(a(1),e)<n+iE)return a(1);let c=0,u=1;for(let f=0;f<30;f++){let l=(c+u)/2;if($t(a(l),e)>=n+iE)u=l;else c=l}return a(u)}function H8(t,e){let{l:n,c:r,h:i}=xt(t),o=0,s=n;for(let a=0;a<30;a++){let c=(o+s)/2;if(St(Qe(c,r,i))<=e-0.005)o=c;else s=c}return Qe(o,r,i)}function F8(t,e,n){let r=Oe[e],[i,o]=[xt(t[e]),xt(t[e+8])],s=(f,l)=>n.has(f)?[l]:Array.from({length:2*r.width+1},(d,h)=>(r.center-r.width+h+360)%360),a=(f,l,d)=>Mr.every((h)=>{let m=(f>8?8:0)+h;if(m===f)return!0;let p=xt(t[m]);return p.c<Mi||Ie(p.h,l)>=Ro+1||Math.abs(p.l-d)>=No}),c,u=Number.POSITIVE_INFINITY;for(let f of s(e,i.h)){if(!n.has(e)&&!a(e,f,i.l))continue;for(let l of s(e+8,o.h)){if(Ie(f,l)>nn-eg||!n.has(e+8)&&!a(e+8,l,o.l))continue;let d=Ie(f,i.h)+Ie(l,o.h);if(d<u)u=d,c=[f,l]}}return c}class sE{theme;moves=[];constructor(t){this.theme={...t,ansi:[...t.ansi]}}set(t,e,n){let r=this.get(t);if(n===r)return;if(this.moves.push({slot:t,rule:e,from:r,to:n}),t==="foreground")this.theme.foreground=n;else if(t==="selection")this.theme.selectionBackground=n;else this.theme.ansi[Number(t.slice(4))]=n}get(t){if(t==="foreground")return this.theme.foreground;if(t==="selection")return this.theme.selectionBackground;return this.theme.ansi[Number(t.slice(4))]}rehue(t,e,n){this.set(`ansi${t}`,e,A8(this.theme.ansi[t],n))}roles(){let t=new Set(this.theme.signatureSlots);for(let{slot:n,hue:r}of xr(this.theme)){let i=Oe[bn(n)];this.rehue(n,"ansi-role",i.center+oE(i.center,r)*(i.width-eg))}for(let{normal:n,gap:r}of Dn(this.theme)){if(r<=nn)continue;let[i,o]=t.has(`ansi${n+8}`)?[n+8,n]:[n,n+8],s=xt(this.theme.ansi[i]).h,a=xt(this.theme.ansi[o]).h;this.rehue(o,"bright-follows",s+oE(s,a)*(nn-eg))}let e=Ao(this.theme);for(let[n,r]of Jn(this.theme)){let i=bn(e.has(r)?n:r),o=F8(this.theme.ansi,i,e);if(o===void 0)continue;this.rehue(i,"distinct",o[0]),this.rehue(i+8,"distinct",o[1])}}readability(){let t=new Set(this.theme.waive),{background:e}=this.theme,n=(r,i,o,s=e)=>{if(t.has(r))return;for(let a of i)if($t(this.get(a),s)<o)this.set(a,r,T8(this.get(a),s,o))};if(n("foreground",["foreground"],7),n("accents",N8.map((r)=>`ansi${r}`),3),n("light-ansi",["ansi7","ansi15"],7),n("ansi8-visible",["ansi8"],1.6),!t.has("ansi0-dark")&&St(this.get("ansi0"))>0.15)this.set("ansi0","ansi0-dark",H8(this.get("ansi0"),0.15));n("selection",["selection"],7,this.theme.foreground)}net(){return[...new Set(this.moves.map((t)=>t.slot))].flatMap((t)=>{let e=this.moves.filter((i)=>i.slot===t),n=e[0].from,r=this.get(t);return n===r?[]:[{slot:t,rule:[...new Set(e.map((i)=>i.rule))].join(", "),from:n,to:r}]})}}function Zl(t){let e=new sE(t);for(let n=0;n<R8;n++)if(e.readability(),e.roles(),Yn(e.theme).length===0)break;return{theme:e.theme,moves:e.net(),left:Yn(e.theme)}}var ho=[{key:"background",label:"Background",min:0,max:0.5,step:0.01,digits:2},{key:"foreground",label:"Foreground",min:0.5,max:1,step:0.01,digits:2},{key:"hue",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0},{key:"tint",label:"Tint",min:0,max:0.1,step:0.005,digits:3},{key:"lightness",label:"Accent lightness",min:0.4,max:0.95,step:0.01,digits:2},{key:"chroma",label:"Accent chroma",min:0,max:0.3,step:0.005,digits:3},{key:"brights",label:"Brights",min:-0.2,max:0.2,step:0.01,digits:2}],bc={background:0.21,foreground:0.88,hue:265,tint:0.02,lightness:0.72,chroma:0.12,brights:0.06},aE=(t,e,n)=>Math.min(n,Math.max(e,t));function ng(t,e,n){let r=t[e.key]+e.step*n,i=e.wraps?(r%e.max+e.max)%e.max:aE(r,e.min,e.max);return{...t,[e.key]:Math.round(i*1e4)/1e4}}function mi(t){let e=(r,i,o)=>Qe(aE(r,0,1),i,o),n=Array.from({length:16},()=>"#000000");n[0]=e(t.background+0.06,t.tint,t.hue),n[8]=e(t.background+0.25,t.tint,t.hue),n[7]=e(t.foreground-0.06,t.tint/2,t.hue),n[15]=e(t.foreground+0.06,t.tint/2,t.hue);for(let r of Mr){let i=Oe[r].center;n[r]=e(t.lightness,t.chroma,i),n[r+8]=e(t.lightness+t.brights,t.chroma,i)}return{background:e(t.background,t.tint,t.hue),foreground:e(t.foreground,t.tint/2,t.hue),cursor:e(t.lightness+t.brights,Math.max(t.chroma,0.08),t.hue),selection:e(t.background+0.1,t.tint*2,t.hue),ansi:n}}var jn=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)],T=["Background","Foreground","Cursor","Selection"],pn=["Black","Red","Green","Yellow","Blue","Magenta","Cyan","White"],L8=["Behind every cell","Plain text","The cursor block","Selected text","Text on colored bars, dark shades","Errors, deleted lines, failed tests","Success, added lines, prompts","Warnings, commit hashes, skipped tests","Directories, info, keywords","Keywords, branches, pictures in ls","Links, diff hunks, types","Light shades, text in some programs","Comments, muted text, suggestions"],pr=T.length+pn.length,mn=[{key:"l",label:"Lightness",min:0,max:1,step:0.01,digits:2},{key:"c",label:"Chroma",min:0,max:0.37,step:0.005,digits:3},{key:"h",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0}],cE=5,C8=5,ne=mn.length,_s=["this","pair","normals","brights","accents"],Xl=[1,2,3,4,5,6,9,10,11,12,13,14],uE=Xl.filter((t)=>t<8).map((t)=>T.length+t),lE=Xl.filter((t)=>t>8).map((t)=>T.length+t);function rg(t,e){let n=e-T.length;if(n<0||t==="this")return[e];if(t==="pair")return[T.length+n%8,T.length+8+n%8];let r=t==="normals"?uE:t==="brights"?lE:[...uE,...lE];return r.includes(e)?r:[e]}function j8(){return Array.from({length:pr},(t,e)=>e<T.length?[e]:[e,e+8]).flat()}function _8(t){let e=t.trim();return/^https?:\/\/\S+$/i.test(e)||Cs(e).length>0}function tn(t){return[t.background,t.foreground,t.cursor,t.selection,...t.ansi]}function re(t){let[e,n,r,i,...o]=t;return{background:e,foreground:n,cursor:r,selection:i,ansi:o}}function Ge(t){if(t<T.length)return{name:T[t],about:jn[t]};let e=t-T.length,n=pn[e%8];return e<8?{name:n,about:`ANSI ${e}`}:{name:`Bright ${n.toLowerCase()}`,about:`ANSI ${e}`}}function mE(t){let e=t-T.length;if(e>=9&&e<=15)return`Bold or bright ${pn[e-8].toLowerCase()} text`;return L8[t]}var mo=(t,e,n)=>Math.min(n,Math.max(e,t));function fE(t){return t.length===1?t.toLowerCase():t}function G8(t){return mo(Math.round(t),0,255).toString(16).padStart(2,"0")}function dE(t){let e=t.trim().toLowerCase(),n=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/.exec(e);if(n){let o=n[1];return`#${o.length===3?[...o].map((s)=>s+s).join(""):o}`}let r=/^rgb\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)\s*\)$/.exec(e);if(r)return`#${r.slice(1,4).map((o)=>G8(Number(o))).join("")}`;let i=/^oklch\(\s*([\d.]+)(%?)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:deg|°)?\s*\)$/.exec(e);if(i){let o=Number(i[1])/(i[2]?100:1);return Qe(mo(o,0,1),Number(i[3]),Number(i[4])%360)}return}function po(t){let e=Pe.find((n)=>n.rule===t);return e?.min??e?.max??0}function gr(t,e,n){let r=re(t);return{name:"draft",background:r.background,foreground:r.foreground,selectionBackground:r.selection,ansi:r.ansi,waive:n,signatureSlots:e}}function B8(t,e){let n=t-T.length,r=t<=1?"foreground":t===3?"selection":n===7||n===15?"light-ansi":n===8?"ansi8-visible":Xl.includes(n)?"accents":void 0;return{against:t===0||t===3?1:0,floor:r===void 0||e.includes(r)?void 0:po(r)}}function ag(t,e,n,r){let i=gr(t,e,n),{background:o,foreground:s,selection:a,ansi:c}=re(t),u=(f,l,d)=>$t(l,d)<po(r)?[f]:[];if(r==="foreground")return $t(s,o)<po(r)?[1,0]:[];if(r==="selection")return $t(s,a)<po(r)?[3,1]:[];if(r==="accents")return Xl.flatMap((f)=>u(T.length+f,c[f],o));if(r==="light-ansi")return[7,15].flatMap((f)=>u(T.length+f,c[f],o));if(r==="ansi8-visible")return u(T.length+8,c[8],o);if(r==="ansi0-dark")return St(c[0])>po(r)?[T.length]:[];if(r==="ansi-role")return xr(i).map(({slot:f})=>T.length+f);if(r==="bright-follows")return Dn(i).filter(({gap:f})=>f>nn).flatMap(({normal:f})=>[T.length+f,T.length+f+8]);if(r==="distinct")return Jn(i).flatMap(([f,l])=>[T.length+f,T.length+l]);return[]}function cg(t,e,n){return new Set(jn.flatMap((r,i)=>ug(t,e,n,i).some((o)=>o.ok===!1)?[i]:[]))}function mr(t,e,n,r,i){let o=$t(t,e),s=po(n);if(i.includes(n))return{ok:void 0,text:`${r} ${o.toFixed(2)}:1 · waived`};return{ok:o>=s,text:`${r} ${o.toFixed(2)}:1 · ≥ ${s}`}}function ug(t,e,n,r){let i=re(t),o=gr(t,e,n);if(r===0){let $=[1,2,3,4,5,6,9,10,11,12,13,14].reduce((k,v)=>$t(i.ansi[k],i.background)<=$t(i.ansi[v],i.background)?k:v);return[mr(i.foreground,i.background,"foreground","Foreground on it",n),mr(i.ansi[$],i.background,"accents",`Weakest, ANSI ${$},`,n),mr(i.ansi[8],i.background,"ansi8-visible","ANSI 8 on it",n)]}if(r===1)return[mr(i.foreground,i.background,"foreground","On background",n),mr(i.foreground,i.selection,"selection","On the selection",n)];if(r===2)return[{ok:void 0,text:`On background ${$t(i.cursor,i.background).toFixed(2)}:1`}];if(r===3)return[mr(i.foreground,i.selection,"selection","Foreground on it",n)];let s=r-T.length,a=i.ansi[s];if(s===0){let b=St(a),$=po("ansi0-dark");return[n.includes("ansi0-dark")?{ok:void 0,text:`Luminance ${b.toFixed(3)} · waived`}:{ok:b<=$,text:`Luminance ${b.toFixed(3)} · ≤ ${$}`}]}if(s===7||s===15)return[mr(a,i.background,"light-ansi","On background",n)];if(s===8)return[mr(a,i.background,"ansi8-visible","On background",n)];let c=[mr(a,i.background,"accents","On background",n)],u=xt(a),f=bn(s),l=Oe[f],d=`${l.name} ${l.center}±${l.width}°`;if(u.c<Mi)c.push({ok:void 0,text:"Too grey to have a hue"});else if(Ao(o).has(s))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · a signature, free of ${d}`});else if(n.includes("ansi-role"))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · ${d} waived`});else{let b=Ie(u.h,l.center)-l.width;c.push(b>0?{ok:!1,text:`Hue ${u.h.toFixed(0)}° · ${b.toFixed(0)}° outside ${d}`}:{ok:!0,text:`Hue ${u.h.toFixed(0)}° · in ${d}`})}let h=s<8?s+8:s-8,m=Dn(o).find((b)=>b.normal===f);if(m)c.push(n.includes("bright-follows")?{ok:void 0,text:`${m.gap.toFixed(0)}° from ANSI ${h} · waived`}:{ok:m.gap<=nn,text:`${m.gap.toFixed(0)}° from ANSI ${h} · ≤ ${nn}°`});let p=Jn(o).flatMap(([b,$])=>b===s?[$]:$===s?[b]:[]);if(p.length>0&&!n.includes("distinct"))c.push({ok:!1,text:`Reads as ANSI ${p.join(", ")} · within ${Ro}° and ${No} lightness`});return c}function lg(t,e,n){let r=wn(gr(t,e,n));return Pe.map((i,o)=>{let s=r[o],a=n.includes(i.rule),c=a||Number.isNaN(s)?void 0:(i.min===void 0||s>=i.min)&&(i.max===void 0||s<=i.max);return{ok:c,label:i.label,value:Number.isNaN(s)?"—":Number.isInteger(s)?String(s):s.toFixed(2),bound:a?"waived":i.min!==void 0?`≥ ${i.min}`:i.max!==void 0?`≤ ${i.max}`:"",slots:c===!1?ag(t,e,n,i.rule):[]}})}var U8=new Set(["reset","reset-all","hex","paste","fix","open","tune","sig","follow"]),pE=mn[1].max;function sg(t){let[e,n,r]=ot(t);return e===n&&n===r}function W8(t,e){let n=xt(e);if(!sg(e))return n;let r=[0,1,3,2].map((i)=>t[i]).find((i)=>!sg(i));return{...n,h:r?xt(r).h:bc.hue}}function gE(t,e,n){if(t==="rgb"){let[r,i,o]=ot(e);return`rgb(${r} ${i} ${o})`}if(t==="oklch")return`oklch(${n.l.toFixed(3)} ${n.c.toFixed(3)} ${n.h.toFixed(0)})`;return e}function ig(t,e){return Math.floor(js(t,e,pE)*1e4)/1e4}function og(t,e){return{l:e.l-t.l,c:e.c-t.c,h:((e.h-t.h)%360+540)%360-180}}function hE(t,e){let n=t.wraps?t.max-t.step:t.max;return Math.min(n,Math.round((t.min+(t.max-t.min)*e)/t.step)*t.step)}class fg{mode;seeds=bc;field=0;list;lch;start;original;signature;row=0;col=0;channel=0;scope="this";view="slot";scene=0;typing;overlay;quitting=!1;compare=!1;notice;filter="";pick=0;result;wants;pictures;inspect=!1;spot;format="hex";pic=!0;menu;entry=0;changedOnly=!1;where=!1;size;copied;startPictures;options;fresh;tone;startSignature;seeded=!1;tuneFrom;holds=new Map;clip;history=[];future=[];lastEdit;links=new Map;unlinked=new Set;offsets=new Map;constructor(t){this.options=t,this.tone=t.tone===!0,this.fresh=t.colors===void 0,this.mode=this.fresh?"seeds":"list",this.list=tn(t.colors??mi(this.seeds)),this.lch=this.lchs(),this.start=[...this.list],this.original=t.original?tn(t.original):[...this.list],this.signature=[...t.signature],this.startSignature=[...t.signature],this.pictures=t.pictures??0,this.startPictures=this.pictures,this.chain(this.original)}chain(t){this.links=new Map,this.unlinked=new Set,this.offsets=new Map;for(let e=0;e<8;e++){let n=T.length+e,r=n+8,i=this.lchOf(t[n]),o=this.lchOf(t[r]);if(i.c>=Mi&&o.c>=Mi&&Ie(i.h,o.h)<=3)this.links.set(r,n),this.offsets.set(r,og(i,o))}}pair(t){if(t<T.length)return;let e=T.length+(t-T.length)%8,n=e+8;return{normal:e,bright:n,on:this.linkOf(n)!==void 0,lift:this.lch[n].l-this.lch[e].l}}linkOf(t){let e=this.links.get(t);return e!==void 0&&!this.unlinked.has(t)?e:void 0}changed(t){return this.list[t]!==this.original[t]}visible(t){return!this.changedOnly||this.changed(t)}changes(){return this.list.filter((t,e)=>this.changed(e)).length}slotAt(t,e){return t<T.length?t:t+(e===1?8:0)}get added(){return Math.max(0,this.pictures-this.startPictures)}found(t){this.pictures=t.count,this.notice=t.note}get waive(){return this.options.waive??[]}get held(){return this.holds.get(this.slot())}colors(){return re(this.list)}edited(){return{colors:this.colors(),signature:[...this.signature]}}shown(){return this.compare?this.start:this.list}slot(){return this.row<T.length?this.row:this.row+(this.col===1?8:0)}dirty(){return this.seeded||this.pictures!==this.startPictures||this.list.some((t,e)=>t!==this.start[e])||this.signature.join()!==this.startSignature.join()}resettable(){return this.dirty()||this.tone&&this.list.some((t,e)=>t!==this.original[e])}misses(){return cg(this.list,this.signature,this.waive)}failing(){return Yn(gr(this.list,this.signature,this.waive))}choices(){let t=this.filter.toLowerCase();return(this.options.palettes??[]).filter((e)=>e.name.toLowerCase().includes(t))}paste(t){if(this.notice=void 0,this.overlay==="open"){this.filter+=t.replace(/\s+/g,"").toLowerCase(),this.pick=0;return}if(this.overlay)return;if(!this.tone&&t.trim()===""){this.findPictures({clipboard:!0});return}if(!this.tone&&_8(t)){this.findPictures({paste:t});return}if(this.mode==="seeds")return;let e=this.options.decode?.(t);if(e){this.remember("open"),this.list=tn(e),this.lch=this.lchs(),this.chain(this.list),this.notice="Took the colors of the share code";return}let n=dE(t);if(!n){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}this.typing=void 0,this.take(n,"paste")}press(t){if(this.notice=void 0,t==="ctrl-c"){this.result="cancelled";return}if(this.quitting){if(this.quitting=!1,t==="y"||t==="Y")this.result="cancelled";return}if(this.typing!==void 0){this.type(t);return}if(this.overlay==="keys"){this.overlay=void 0;return}if(this.overlay==="open"){this.openKey(t);return}if(this.menu){this.menuKey(t);return}if(t==="?"){this.overlay="keys";return}if(this.inspect&&this.mode==="list"&&this.inspectKey(t))return;if(this.tone&&(t==="ctrl-v"||t==="alt-v"||t==="p"))return;if(t==="ctrl-v"||t==="alt-v"){this.findPictures({clipboard:!0});return}if(t==="p"&&this.mode!=="tune"){this.findPictures();return}if(t===" "&&this.mode!=="seeds"){this.compare=!this.compare;return}if(this.compare&&t==="esc"){this.compare=!1;return}if(t==="g"&&this.mode!=="seeds"){this.view=this.view==="slot"?"relations":"slot",this.inspect=!1,this.spot=void 0;return}let e=t==="j"?"down":t==="k"?"up":t;if(this.mode==="seeds")this.seedKey(e);else if(this.mode==="tune")this.tuneKey(e);else this.listKey(e)}select(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return;if(this.mode==="tune"){if(t===this.slot())return;this.tuneKey("enter")}this.notice=void 0,this.seat(t),this.lastEdit=void 0}seat(t){if(this.row=t<T.length?t:T.length+(t-T.length)%8,t>=T.length)this.col=t-T.length>=8?1:0}grip(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return!1;if(this.notice=void 0,this.mode==="list")this.tune();return this.channel=t,!0}slide(t,e){if(!this.grip(t))return;let n=Math.min(1,Math.max(0,e));if(t===ne){this.reach(21**n);return}this.put(hE(mn[t],n))}sow(t,e){let n=ho[t];if(this.mode!=="seeds"||this.overlay||this.quitting||!n)return;this.notice=void 0,this.field=t;let r=Math.min(1,Math.max(0,e));this.seeds=ng({...this.seeds,[n.key]:hE(n,r)},n,0),this.list=tn(mi(this.seeds)),this.lch=this.lchs()}scroll(t){let e=(n,r)=>Math.min(r,Math.max(0,n+t));if(this.overlay==="open")this.pick=e(this.pick,Math.max(0,this.choices().length-1));else if(this.overlay||this.quitting||this.typing!==void 0)return;else if(this.mode==="seeds")this.field=e(this.field,ho.length-1);else if(this.mode==="tune")this.channel=0,this.step(-t);else this.row=e(this.row,pr-1),this.lastEdit=void 0}lchOf(t){return W8(this.list,t)}lchs(){return this.list.map((t)=>this.lchOf(t))}seedKey(t){let e=ho.length;if(t==="up"||t==="down")this.field=(this.field+(t==="up"?e-1:1))%e;else if(t==="home"||t==="end")this.field=t==="home"?0:e-1;else if(t==="left"||t==="right"||t==="shift-left"||t==="shift-right"){let n=ho[this.field],r=(t.endsWith("left")?-1:1)*(t.startsWith("shift")?n.wraps?10:cE:1);this.seeds=ng(this.seeds,n,r),this.list=tn(mi(this.seeds)),this.lch=this.lchs()}else if(t==="enter")this.leaveSeeds();else if(t==="o")this.openPalettes();else if(t==="esc")this.leave()}leaveSeeds(){this.start=[...this.list],this.original=[...this.list],this.chain(this.original),this.seeded=!0,this.mode="list"}leave(){if(this.dirty())this.quitting=!0;else this.result="cancelled"}findPictures(t){if(!this.options.find){this.notice="Pictures need Ghostty, iTerm2 or kitty, outside tmux";return}this.wants=t?{start:t}:{}}openPalettes(){if((this.options.palettes??[]).length>0)this.overlay="open",this.pick=0;else this.notice="No other palettes to take colors from"}listKey(t){if(t==="up"||t==="down"){let e=t==="up"?-1:1;this.land(this.row+e,e),this.lastEdit=void 0}else if(t==="home"||t==="end")this.land(t==="home"?0:pr-1,t==="home"?1:-1);else if(t==="pgup"||t==="pgdn")this.land(t==="pgup"?0:T.length,1);else if(t==="left"||t==="right"){let e=t==="left"?0:1;if(this.row>=T.length&&this.visible(this.slotAt(this.row,e)))this.col=e,this.lastEdit=void 0}else if(this.builderKey(t))return;else if(t==="shift-left"||t==="shift-right")this.scene+=t==="shift-left"?-1:1;else if(t==="n"||t==="N")this.nextMiss(t==="n"?1:-1);else if(t==="enter"||t==="tab")this.tune();else if(t==="#")this.typing="";else if(t==="c")this.clip=this.list[this.slot()],this.notice=`Copied ${this.clip}`;else if(t==="v")if(this.clip)this.set(this.slot(),this.clip,"paste");else this.notice="Nothing copied yet — c copies a slot";else if(t==="r")this.set(this.slot(),this.original[this.slot()],"reset");else if(t==="R")this.remember("reset-all"),this.list=[...this.original],this.lch=this.lchs();else if(t==="=")this.follow();else if(t==="*"&&!this.tone)this.mark();else if(t==="f")this.fix();else if(t==="o"&&!this.tone)this.openPalettes();else if(t==="u")this.undo();else if(t==="ctrl-r")this.redo();else if(t==="s"||t==="ctrl-s")this.save();else if(t==="esc")this.leave()}viewport(t,e){this.size={cols:t,rows:e}}layout(){return this.size&&this.view==="slot"?mc(this.size.cols,this.size.rows,this.scene):void 0}get roomy(){return this.layout()!==void 0}reseat(){if(!this.visible(this.slot()))this.land(this.row,1)}rowShown(t){return this.visible(this.slotAt(t,0))||t>=T.length&&this.visible(this.slotAt(t,1))}land(t,e){for(let n=0;n<pr;n++){let r=((t+e*n)%pr+pr)%pr;if(this.rowShown(r)){if(this.row=r,r>=T.length&&!this.visible(this.slotAt(r,this.col)))this.col=1-this.col;return}}}builderKey(t){if(["i","m","w","x","I"].includes(t)&&!this.roomy)return this.notice=this.view==="relations"?"g goes back to the builder":"The builder needs a window of at least 96×28",!0;if(t==="i")this.startInspect();else if(t==="l")this.linkKey();else if(t==="m")this.changedOnly=!this.changedOnly,this.reseat(),this.notice=this.changedOnly?this.changes()>0?void 0:"Nothing changed yet":void 0;else if(t==="b")this.pic=!this.pic;else if(t==="w")this.where=!this.where;else if(t==="x"&&this.options.exports)this.menu="export",this.entry=0;else if(t==="I")this.menu="import",this.entry=0;else return!1;return!0}menuKey(t){let e=this.menu==="export"?3:2;if(t==="esc")this.menu=void 0;else if(t==="up"||t==="down"||t==="k"||t==="j")this.entry=(this.entry+(t==="up"||t==="k"?e-1:1))%e;else if(t==="enter")this.choose(this.entry)}choose(t){let e=this.menu;if(this.menu=void 0,e==="import"){if(t===0)this.openPalettes();else this.notice=this.options.decode?"Paste a share link or a tt2: code into this window":"Share codes are not read here";return}let n=this.options.exports;if(e!=="export"||!n)return;try{let r=this.edited(),i=n.code(r);this.copied=t===0?i:t===1?`${n.command} ${i}`:n.toml(r),this.notice=`Copied ${t===0?"the share code":t===1?"the add command":"the palette file"} — paste it where you need it`}catch(r){this.notice=r instanceof Error?r.message:String(r)}}startInspect(){let t=this.layout();if(!t){this.notice="The builder needs a window of at least 96×28";return}this.inspect=!0,this.spot=BS(t,this.slot())}inspectKey(t){let e=this.layout();if(!e)return this.inspect=!1,!1;let r={left:"left",right:"right",up:"up",k:"up",down:"down",j:"down",tab:"next","shift-tab":"previous"}[t];if(t==="i"||t==="esc")this.inspect=!1,this.spot=void 0;else if(r)this.spot=US(e,zl(e,this.spot),r);else if(t==="shift-left"||t==="shift-right")this.scene+=t==="shift-left"?-1:1,this.spot=void 0;else if(t==="enter")this.jump();else return!1;return!0}point(t){if(this.mode!=="seeds"&&!this.overlay&&!this.quitting&&this.typing===void 0&&this.layout())this.inspect=!0,this.spot=t}slotsHere(){let t=this.layout();return t&&this.spot?WS(t,this.spot):void 0}jump(){let t=this.slotsHere();if(!t)return;let e=t.ground!==0?t.ground:t.text;this.inspect=!1,this.spot=void 0,this.show(e),this.select(e)}show(t){if(!this.visible(t))this.changedOnly=!1}openSlot(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return;let e=this.mode==="tune"&&t===this.slot();if(this.mode==="tune")this.tuneKey("enter");if(e)return;if(this.show(t),this.select(t),this.mode==="list")this.tune()}dismiss(){if(this.mode!=="tune"||this.overlay||this.quitting)return;this.typing=void 0,this.tuneKey("enter")}plane(t,e){if(!this.grip(0))return;this.channel=0,this.put(t),this.channel=1,this.put(e)}linkKey(){let t=this.slot();if(t<T.length){this.notice="l links a bright to its normal — pick an ANSI row";return}let e=T.length+(t-T.length)%8,n=e+8,r=`${Ge(n).name} and ${Ge(e).name.toLowerCase()}`;if(this.mode!=="tune")this.remember("link");if(this.linkOf(n)!==void 0){this.unlinked.add(n),this.notice=`${r} move apart`;return}this.links.set(n,e),this.unlinked.delete(n),this.offsets.set(n,og(this.lch[e],this.lch[n])),this.notice=`${r} move together`}nextMiss(t){let e=j8(),n=this.misses();if(n.size===0){this.notice="The gate passes";return}let r=e.indexOf(this.slot());for(let i=1;i<=e.length;i++){let o=e[((r+t*i)%e.length+e.length)%e.length];if(n.has(o)){this.seat(o);return}}}tune(){this.remember("tune"),this.tuneFrom={list:[...this.list],lch:[...this.lch]},this.holds=new Map,this.hold(),this.mode="tune"}hold(){for(let t of this.scoped())if(!this.holds.has(t))this.holds.set(t,this.lch[t].c)}scoped(){return rg(this.scope,this.slot())}tuneKey(t){let e=this.channel===ne;if(t==="tab"||t==="shift-tab")this.channel=e?0:ne;else if(t==="up"||t==="down"||t==="pgup"||t==="pgdn")this.channel=0,this.step((t==="up"||t==="pgup"?1:-1)*(t.startsWith("pg")?cE:1));else if(t==="left"||t==="right"){let n=t==="left"?-1:1;if(e)this.reach(this.ratio()+n*0.1);else this.channel=1,this.step(n)}else if(t==="shift-left"||t==="shift-right"){let n=t==="shift-left"?-1:1;if(e)this.reach(this.ratio()+n*0.5);else this.channel=2,this.step(n*C8)}else if((t===","||t===".")&&!e)this.channel=2,this.step(t===","?-1:1);else if(t==="home"||t==="end")if(e)this.reach(t==="home"?this.partner().floor??1:21);else{let n=mn[this.channel];this.put(t==="home"?n.min:n.wraps?n.max-n.step:n.max)}else if(/^[0-9]$/.test(t))if(e){if(t!=="0")this.reach(Number(t))}else{let n=mn[this.channel];this.put(n.min+(n.max-n.min)*Number(t)/10)}else if(t==="a")this.rescope();else if(t==="#")this.typing="";else if(t==="l")this.linkKey();else if(t==="s"||t==="ctrl-s")this.tuneKey("enter"),this.save();else if(t==="enter"){if(this.tuneFrom&&this.list.every((n,r)=>n===this.tuneFrom?.list[r]))this.history.pop();this.endTune()}else if(t==="esc"){if(this.tuneFrom)this.list=[...this.tuneFrom.list],this.lch=[...this.tuneFrom.lch],this.history.pop();this.endTune()}}rescope(){if(this.slot()<T.length){this.notice="A base color moves alone";return}let t=_s.indexOf(this.scope);for(let e=1;e<=_s.length;e++){let n=_s[(t+e)%_s.length];if(n==="this"||rg(n,this.slot()).length>1){this.scopeTo(n);return}}}scopeTo(t){if(this.mode!=="tune"||this.typing!==void 0||this.quitting||this.slot()<T.length)return;if(t!=="this"&&rg(t,this.slot()).length<=1)return;this.scope=t,this.hold();let e=this.scoped().length;this.notice=e>1?`${e} slots move together`:"This slot moves alone"}endTune(){this.tuneFrom=void 0,this.holds=new Map,this.mode="list"}partner(){return B8(this.slot(),this.waive)}ratio(){return $t(this.list[this.slot()],this.list[this.partner().against])}origin(){let t=this.slot(),e=this.original[t];if(e===this.list[t])return;return{hex:e,lch:this.lchOf(e),ratio:$t(e,this.original[this.partner().against])}}reach(t){let e=this.slot(),n=this.list[this.partner().against],r=this.lch[e],i=this.holds.get(e)??r.c,o=(d)=>Qe(d,Math.min(i,ig(d,r.h)),r.h),s=(d)=>$t(o(d),n),a=St(this.list[e])>=St(n),c=xt(n).l,u=Math.max(1,Math.round(t*100)/100),f=a?1:0,l;if(s(f)<u)l=f,this.notice=`The ratio stops at ${s(f).toFixed(2)}:1 on this side of the color it is read against`;else{let d=c,h=f;for(let m=0;m<24;m++){let p=(d+h)/2;if(s(p)>=u)h=p;else d=p}l=h}this.place(e,l,i,r.h);for(let d=0;d<40&&l!==f&&$t(this.list[e],n)<u;d++)l=a?Math.min(1,l+0.001):Math.max(0,l-0.001),this.place(e,l,i,r.h);this.lch[e]={...this.lch[e],l:Math.round(l*1e4)/1e4}}step(t){let e=mn[this.channel],n=this.lch[this.slot()][e.key];this.put(n+e.step*t)}put(t){let e=this.slot(),n=mn[this.channel],r=n.wraps?(t%n.max+n.max)%n.max:mo(t,n.min,n.max),i=Math.round(r*1e4)/1e4,o=this.lch[e],s=this.scoped().filter((u)=>u!==e),a=(u)=>Math.round(u*1e4)/1e4;if(n.key==="c"){let u=ig(o.l,o.h);if(i>u)this.notice=`Chroma stops at ${u.toFixed(3)}, the sRGB edge for this lightness and hue`;let f=Math.min(i,u),l=f-o.c;this.holds.set(e,f),this.place(e,o.l,f,o.h);for(let d of s){let h=this.lch[d],m=a(mo((this.holds.get(d)??h.c)+l,0,pE));this.holds.set(d,m),this.place(d,h.l,m,h.h)}this.trail([e,...s]);return}let c=n.key==="h"?((i-o.h)%360+540)%360-180:i-o.l;if(this.place(e,n.key==="l"?i:o.l,this.holds.get(e)??o.c,n.key==="h"?i:o.h),n.key==="h"&&sg(this.list[e]))this.notice="A grey shows no hue — raise its chroma first";for(let u of s){let f=this.lch[u];this.place(u,n.key==="l"?a(mo(f.l+c,0,1)):f.l,this.holds.get(u)??f.c,n.key==="h"?a(((f.h+c)%360+360)%360):f.h)}this.trail([e,...s])}trail(t){let e=new Set(t);for(let[n,r]of this.links){if(this.unlinked.has(n))continue;if(e.has(n)&&!e.has(r))this.unlinked.add(n);else if(e.has(r)&&!e.has(n)){let i=this.lch[r],o=this.offsets.get(n);this.place(n,mo(i.l+o.l,0,1),Math.max(0,i.c+o.c),((i.h+o.h)%360+360)%360)}}}place(t,e,n,r){let i=Math.min(n,ig(e,r));this.lch[t]={l:e,c:i,h:r},this.list[t]=Qe(e,i,r)}take(t,e){if(this.mode==="tune")this.list[this.slot()]=t,this.lch[this.slot()]=this.lchOf(t),this.holds.set(this.slot(),this.lch[this.slot()].c),this.trail([this.slot()]);else this.set(this.slot(),t,e)}type(t){let e=this.typing??"";if(t==="esc")this.typing=void 0;else if(t==="enter"){let n=dE(e);if(!n){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}this.typing=void 0,this.take(n,"hex")}else{let n=ao(e,fE(t),(r)=>/^[0-9a-z#(),.% ]$/.test(r)&&e.length<28);if(n!==void 0)this.typing=n}}openKey(t){let e=this.choices();if(t==="esc")this.overlay=void 0,this.filter="";else if(t==="up"||t==="down"){let n=Math.max(1,e.length);this.pick=(this.pick+(t==="up"?n-1:1))%n}else if(t==="home"||t==="end")this.pick=t==="home"?0:Math.max(0,e.length-1);else if(t==="enter"){let n=e[this.pick];if(!n)return;if(this.remember("open"),this.list=tn(n.colors),this.lch=this.lchs(),this.chain(this.list),this.overlay=void 0,this.filter="",this.notice=`Took the colors of ${n.name}`,this.mode==="seeds")this.leaveSeeds()}else{let n=ao(this.filter,fE(t),(r)=>/^[a-z0-9@/-]$/.test(r));if(n!==void 0)this.filter=n,this.pick=0}}remember(t){if(t!==this.lastEdit||U8.has(t))this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.future=[];this.lastEdit=t}set(t,e,n){if(!he(e)||this.list[t]===e)return;this.remember(n),this.list[t]=e,this.lch[t]=this.lchOf(e),this.trail([t])}follow(){if(this.row<T.length){this.notice="= works on an ANSI row — the bright takes its normal";return}let t=this.row,e=this.row+8,n=this.lch[t];this.remember("follow"),this.place(e,mo(n.l+0.06,0,1),n.c,n.h),this.links.set(e,t),this.unlinked.delete(e),this.offsets.set(e,og(n,this.lch[e])),this.seat(e),this.notice=`${Ge(e).name} follows ${Ge(t).name.toLowerCase()}`}mark(){let t=jn[this.slot()];this.remember("sig");let e=this.signature.includes(t)?this.signature.filter((r)=>r!==t):[...this.signature,t],n=e.length>3?e[0]:void 0;this.signature=e.slice(-3),this.notice=this.signature.length===3?`Signature: ${this.signature.join(", ")}${n?` — ${n} dropped`:""}`:`The signature needs three slots — ${this.signature.length} marked`}fix(){let t=gr(this.list,this.signature,this.waive),{theme:e,moves:n,left:r}=Zl({...t,selectionBackground:t.selectionBackground,signatureSlots:this.signature});if(n.length===0){this.notice=Yn(t).length===0?"Already passes the gate":"No color change fixes it";return}this.remember("fix");let i=tn({...this.colors(),foreground:e.foreground,selection:e.selectionBackground,ansi:e.ansi}),o=this.list;this.list=i,this.lch=i.map((s,a)=>s===o[a]?this.lch[a]:this.lchOf(s)),this.notice=`Moved ${n.length} ${n.length===1?"color":"colors"}${r.length===0?" — passes the gate":" closer to the gate"}`}save(){let t=this.options.check(this.edited());if(t){this.notice=t;return}this.result="saved"}undo(){let t=this.history.pop();if(!t){this.notice="Nothing to undo";return}this.future.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}redo(){let t=this.future.pop();if(!t){this.notice="Nothing to redo";return}this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}restore(t){this.list=[...t.list],this.lch=[...t.lch],this.signature=[...t.signature],this.lastEdit=void 0}}import{mkdirSync as d3,readFileSync as pg,writeFileSync as NE}from"node:fs";import{dirname as h3}from"node:path";import{isMainThread as m3,parentPort as AE,Worker as p3}from"node:worker_threads";var K8=new Set(["comic","4koma","monochrome","greyscale","sketch","lineart","speech_bubble"]),z8=new Set(["scenery","landscape","scenic","no_humans","wide_shot","very_wide_shot"]),q8=0.04,D8=0.1,J8=0.05,Y8=4096;function V8(t){return new Set(t.cutouts.split(/\s+/).map((e)=>e.replace(/^~/,"")).filter(Boolean))}function Z8(t,e,n,r=0){let{site:i,post:o}=t,s=new Set(o.tags),a=[...V8(i)].some((f)=>s.has(f)),c=Math.min(o.width,o.height),u=o.width>0&&o.height>0?o.width/o.height/(e.w/e.h):1;return(o.solo?2:0)+([...K8].some((f)=>s.has(f))?-3:0)+([...z8].some((f)=>s.has(f))?-1.5:0)+2*Math.min(1,c/e.h)+(a?1.5:-Math.min(1.5,Math.abs(Math.log(u))))+(n>0?1.5*Math.log1p(Math.max(0,o.score))/Math.log1p(n):0)+2*r}function Ql(t,e,n=new Map){let r=new Map;for(let{site:i,post:o}of t)r.set(i,Math.max(r.get(i)??0,o.score));return t.map((i,o)=>({pick:i,at:o,score:Z8(i,e,r.get(i.site)??0,n.get(i.post))})).sort((i,o)=>o.score-i.score||i.at-o.at).map(({pick:i})=>i)}function wE(t){let e=new Map;for(let r of t)e.set(r.site,[...e.get(r.site)??[],r]);let n=[];for(let r=0;n.length<t.length;r++)for(let i of e.values()){let o=i[r];if(o)n.push(o)}return n}function dg(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function bE(t,e,n){let[r,i,o]=[dg(t),dg(e),dg(n)],s=Math.cbrt(0.4122214708*r+0.5363325363*i+0.0514459929*o),a=Math.cbrt(0.2119034982*r+0.6806995451*i+0.1073969566*o),c=Math.cbrt(0.0883024619*r+0.2817188376*i+0.6299787005*o);return[0.2104542553*s+0.793617785*a-0.0040720468*c,1.9779984951*s-2.428592205*a+0.4505937099*c,0.0259040371*s+0.7827717662*a-0.808675766*c]}function $E(t,e){let n=e.map((s)=>bE(...ot(s))).filter(([,s,a])=>Math.hypot(s,a)>=q8);if(n.length===0)return 0;let r=Math.max(1,Math.floor(Math.sqrt(t.width*t.height/Y8))),i=n.map(()=>0),o=0;for(let s=0;s<t.height;s+=r)for(let a=0;a<t.width;a+=r){let c=(s*t.width+a)*4;if(t.data[c+3]<128)continue;o++;let[u,f,l]=bE(t.data[c],t.data[c+1],t.data[c+2]);n.forEach(([d,h,m],p)=>{if(Math.hypot(u-d,f-h,l-m)<D8)i[p]=i[p]+1})}if(o===0)return 0;return i.reduce((s,a)=>s+Math.min(1,a/o/J8),0)/n.length}import{existsSync as hg,mkdirSync as kE,readFileSync as Bs}from"node:fs";import{homedir as r3}from"node:os";import{dirname as yE,join as go}from"node:path";import{spawn as X8}from"node:child_process";var Q8=30000,t3=3,e3=97,n3=`ObjC.import('Vision')
|
|
700
702
|
ObjC.import('CoreImage')
|
|
701
703
|
ObjC.import('CoreGraphics')
|
|
702
704
|
function run(argv) {
|
|
@@ -715,63 +717,63 @@ function run(argv) {
|
|
|
715
717
|
$.CIImage.imageWithCVPixelBuffer(buffer), $.NSURL.fileURLWithPath(argv[1]), $.kCIFormatRGBA8,
|
|
716
718
|
$.CGColorSpaceCreateWithName($.kCGColorSpaceSRGB), $({}), error)
|
|
717
719
|
if (!written) throw new Error('write failed')
|
|
718
|
-
}`;function
|
|
719
|
-
`).at(-1)||`osascript exited ${a}`))})})}var pS=90000;function Yl(t,e){let n=X(t),r=ge(t,e).flatMap((i)=>{let[,o,s]=/^([a-z.]+)_(\d+)$/.exec(i.key)??[];return o&&s&&V.some((a)=>a.key===o)?[{site:o,id:Number(s),...Qd(n,i)}]:[]});return r.length>0?r:void 0}function J8(t,e){let n=new Set(Nt(X(t)).palettes[e.name]?.pictures.map((r)=>r.key));return(e.pictures??[]).filter((r)=>!n.has(le(r)))}function gS(t,e){let n=new Set((e??[]).map((r)=>le(r)));return{...t,pictures:(t.pictures??[]).filter((r)=>!n.has(le(r)))}}async function Y8(t,e,n,r,i,o){let s=V.find((b)=>b.key===n.site);if(!s)throw Error(`no site called ${n.site}`);o("Fetching");let a=await _o(s,n.id,i);if(!a)throw Error("the post is gone");if(s!==ce&&a.md5)try{tu([a],await eu([a.md5],i))}catch{}let c=Qc(s,a)?Xc(s,a.id,i).then((b)=>{if(b)sa(a,b)},()=>{}):void 0;if(!Zc(s,a,Ai(process.env.TTHEME_FIND_RATING))||Yc(a,jo(process.env.TTHEME_FIND_BLOCK)).length>0)throw Error("outside your find filters — TTHEME_FIND_RATING and TTHEME_FIND_BLOCK");let u=En(a);if(!u)throw Error("too large to use");let f=mo(rn(s),"orig",`${n.id}.${u.ext}`),l;if(cg(f))l=new Uint8Array(Gs(f));else{o("Downloading");let b=Ni(s,a,u);l=await nu(b.site,b.url,i,($,k)=>o("Downloading",pl($,k))),L(f,l)}let d=Ar(l,Re),h=!1;if(Yn(d)===0&&_s()&&process.env.TTHEME_FIND_REMOVE_BG!=="off"){let b=mo(rn(s),"cut",`${n.id}.png`);try{if(!cg(b))o("Cutting out"),hS(mS(b),{recursive:!0}),await mc(f,b,i);let $=Ar(new Uint8Array(Gs(b)),Re);if(Dl(Yn($)))d=$,h=!0}catch{}}await c;let m=Zd(e);o("Drawing"),uu(t,m,Mn(m,e.signatureSlots),d,{site:s.key,id:n.id,ext:u.ext,bytes:l,from:`${s.name} ${n.id} ${s.pageUrl(n.id)}`,artist:a.named.artist,source:oa(a.source),cut:h},{width:0,height:0},ti(t),qu(t));let p=ge(t,e.name).find((b)=>b.key===le(n));if(p)pa(X(t),p,n,r,D8())}function Z8(t,e){let n=V.find((o)=>o.key===t.site),r=`${n?.name??t.site} ${t.id}`;if(!n||!e)return r;return`${Ft()?A.link:`${vi(n.ansi)}${A.link}${bt}`} ${Bc(r,n.pageUrl(t.id))}`}async function po(t,e,n){let r=e.flatMap((c)=>J8(t,c).map((u)=>({entry:c,shared:u})));if(r.length===0)return;let i=to(n),o=process.stdout.isTTY&&ly(process.env),s=new Set,a=ci();for(let[c,{entry:u,shared:f}]of r.entries()){let l=`${u.name} · ${Z8(f,o)}`,d=r.length>1?` · ${c+1}/${r.length}`:"",h=(m,p)=>a.set(`${m} ${l}${p?` · ${p}`:""}${d}`);try{await Y8(t,u,f,i,AbortSignal.timeout(pS),h),a.say(` ▣ ${l}`),s.add(u)}catch(m){a.say(` ▢ ${l} — ${m instanceof Error?m.message:String(m)}`)}}a.done();for(let c of s){let u=(c.pictures??[]).find((f)=>ge(t,c.name).some((l)=>l.key===le(f)));if(u)Do(t,c.name,le(u))}if(s.size>0)_e(t)}function bS(t,e,n){if(e.width!==t.width||e.height!==t.height)return!1;for(let r=0;r<t.width*t.height;r++)t.data[r*4+3]=e.data[r*4+n]??0;return!0}async function V8(t,e){let[,n,r]=/^(.+)_(\d+)$/.exec(t)??[],i=mo(jr(),n??"local","cut",`${r??t}.png`);if(!cg(i)){if(!_s())return;hS(mS(i),{recursive:!0}),await mc(e,i,AbortSignal.timeout(pS))}return Ar(new Uint8Array(Gs(i)),Re)}function X8(t,e){try{return Yn(Gt(new Uint8Array(Gs(mo(t,`${e.stem}.png`)))))>0}catch{return!1}}function Jl(t,e){return()=>Ar(new Uint8Array(Gs(mo(t,e.original))),Re)}function wS(t,e){let n=Jl(t,e);return()=>{let r=n(),i=Gt(new Uint8Array(Gs(mo(t,e.cut))));return bS(r,i,0)?r:null}}async function Zl(t,e,n,r,i,o,s,a){let c=X(t),u=Nt(c).palettes[e]?.pictures.find((f)=>f.key===n);if(!u?.original)return null;if(u.cut)return ga(t,e,u,wS(c,u),r,i,o,s,!1,a);if(qo(u)){let f=Jl(c,u)();if(Yn(f)===0&&X8(c,u)){let l=await V8(n,mo(c,u.original));if(!l||!bS(f,l,3))return null;return ga(t,e,u,()=>f,r,i,o,s,!0,a)}return ga(t,e,u,()=>f,r,i,o,s,!1,a)}return ga(t,e,u,Jl(c,u),r,i,o,s,!1,a)}function $S(t,e,n,r,i,o){let s=X(t),a=Nt(s).palettes[e]?.pictures.find((u)=>u.key===n);if(!a?.original||qo(a))return!1;let c=a.cut?wS(s,a):Jl(s,a);return O$(t,e,a,c,r,i,o)}var Q8=/(?:^|[^0-9a-f])([0-9a-f]{32})(?:[^0-9a-f]|$)/i,t3=[[/yande\.re\/post\/show\/(\d+)/,"yande"],[/konachan\.(?:com|net)\/post\/show\/(\d+)/,"konachan"],[/danbooru\.donmai\.us\/(?:posts|post\/show)\/(\d+)/,"danbooru"],[/zerochan\.net\/(\d+)(?:[?#\s]|$)/,"zerochan"]];function ug(t){let e=/(\d+)_p(\d+)/.exec(t.source);return[...t.md5?[`md5:${t.md5}`]:[],...e&&t.source.includes("pximg")?[`pixiv:${e[1]}_p${e[2]}`]:[]]}function kS(t,e){let n=Q8.exec(e.source)?.[1]?.toLowerCase();return[`post:${t.key}:${e.id}`,...e.md5?[`md5:${e.md5}`]:[],...n&&n!==e.md5?[`md5:${n}`]:[],...t3.flatMap(([r,i])=>{let o=r.exec(e.source)?.[1];return o?[`post:${i}:${Number(o)}`]:[]}),...e.family?[`family:${t.key}:${e.family}`]:[]]}function yS(t,e){let n=t.owner||t.named.artist[0]||"";return n!==""&&n===(e.owner||e.named.artist[0]||"")&&t.width===e.width&&t.height===e.height}function vS(t){let r=[];for(let o=0;o<8;o++){let s=Math.floor(o*t.height/8),a=Math.max(s+1,Math.floor((o+1)*t.height/8));for(let c=0;c<9;c++){let u=Math.floor(c*t.width/9),f=Math.max(u+1,Math.floor((c+1)*t.width/9)),l=0;for(let d=s;d<a;d++)for(let h=u;h<f;h++){let m=(d*t.width+h)*4,p=t.data[m+3]/255,b=0.299*t.data[m]+0.587*t.data[m+1]+0.114*t.data[m+2];l+=b*p+255*(1-p)}r.push(l/((f-u)*(a-s)))}}let i=0n;for(let o=0;o<8;o++)for(let s=0;s<8;s++)i=i<<1n|(r[o*9+s]>r[o*9+s+1]?1n:0n);return i.toString(16).padStart(16,"0")}function e3(t,e){let n=BigInt(`0x${t}`)^BigInt(`0x${e}`),r=0;while(n>0n)r+=Number(n&1n),n>>=1n;return r}function ES(t,e){if(t.width<=0||t.height<=0||e.width<=0||e.height<=0)return!1;return Math.abs(Math.log(t.width/t.height/(e.width/e.height)))<0.01&&e3(t.hash,e.hash)<=2}var s3={thumb:"tile",band:"band",match:"tile",show:"view",backdrop:"view",redraw:"view"},Vl;async function a3(t){if(t.job==="redraw")return Zl(t.home,t.name,t.key,t.paint,t.blur,t.aligns,t.user);if(t.job==="show"){if(Vl?.from!==t.from){let s=Ar(new Uint8Array(lg(t.from)),Re);Vl={from:t.from,clear:Yn(s),inked:Yd(s)}}let{image:r,fill:i,opacity:o}=p$(Vl.inked,t.colors,t.tone,t.width,t.height,t.blur,t.tune,t.coloring);return n3(r3(t.to),{recursive:!0}),SS(t.to,We(r)),{clear:Vl.clear,fill:i,opacity:o}}let e=Ar(new Uint8Array(lg(t.from)),Re);if(t.job==="backdrop"){uu(t.home,t.colors,t.tone,e,{...t.origin,bytes:new Uint8Array(lg(t.source)),cut:t.from!==t.source},t,t.blur,t.coloring);let r=t.tune&&ge(t.home,t.colors.name).find((i)=>i.key===le(t.origin));if(t.tune&&r)pa(X(t.home),r,t.tune,t.aligns??!0,t.user??t.home);return 0}if(t.job==="match")return{match:dS(e,t.colors),hash:vS(e)};if(t.job==="thumb")return L(t.to,We(Qw(e,t.width,t.height))),0;let n=e.data.subarray(t.y*e.width*4,(t.y+t.height)*e.width*4);return SS(t.to,We({width:e.width,height:t.height,data:n})),0}function c3(t){t.on("message",async(e)=>{try{t.postMessage({id:e.id,value:await a3(e)})}catch(n){t.postMessage({id:e.id,error:n instanceof Error?n.message:String(n)})}})}class fg{worker;next=1;waiting=new Map;send(t){let e=this.next++;return new Promise((n,r)=>{let i=this.open();this.waiting.set(e,{ok:n,no:r}),i.ref(),i.postMessage({...t,id:e})})}close(){this.worker?.terminate(),this.worker=void 0,this.drop(Error("renderer closed"))}open(){if(this.worker)return this.worker;let t=new o3(import.meta.filename);t.unref(),t.on("message",({id:n,value:r,error:i})=>{let o=this.waiting.get(n);if(this.waiting.delete(n),this.waiting.size===0)t.unref();if(i!==void 0)o?.no(Error(i));else o?.ok(r)});let e=(n)=>{if(this.worker===t)this.worker=void 0;this.drop(n instanceof Error?n:Error("renderer stopped"))};return t.on("error",e),t.on("exit",()=>e(void 0)),this.worker=t,t}drop(t){for(let e of this.waiting.values())e.no(t);this.waiting.clear()}}class pc{lines=new Map;run(t){let e=s3[t.job],n=this.lines.get(e);if(!n)n=new fg,this.lines.set(e,n);return n.send(t)}close(){for(let t of this.lines.values())t.close();this.lines.clear()}}class dg{lines;constructor(t){this.lines=Array.from({length:Math.max(1,t)},()=>new fg)}async map(t){let e=[],n=0;return await Promise.all(this.lines.map(async(r)=>{while(n<t.length){let i=n++;try{e[i]=await r.send(t[i])}catch(o){e[i]=o instanceof Error?o:Error(String(o))}}})),e}close(){for(let t of this.lines)t.close()}}if(!i3&&MS)c3(MS);import{existsSync as u3,mkdtempSync as l3,readFileSync as f3,rmSync as xS,writeFileSync as d3}from"node:fs";import{tmpdir as h3}from"node:os";import{basename as IS,join as OS}from"node:path";var m3=6;class hg{dir;made=[];of(t,e){this.dir??=l3(OS(h3(),"ttheme-tint-"));let n=OS(this.dir,`${IS(t,".png")}.${e.slice(1).toLowerCase()}.png`);if(!u3(n)){let r=new Uint8Array(f3(t));d3(n,Kc(r,e)??Ri(Ii(Gt(r)),e)),this.made.push(n);while(this.made.length>m3)xS(this.made.shift(),{force:!0})}return n}clear(){if(this.dir)xS(this.dir,{recursive:!0,force:!0});this.dir=void 0,this.made.length=0}}function RS(t,e,n,r,i){if(Ke(t)==="original")return e;let o=Mn(n,[...r]);return o.color===t.tone?e:i.of(e,o.color)}function PS(t,e){let n=IS(e);return t.find((r)=>n.startsWith(`${r.stem}.`)||n.startsWith(`${r.stem}@`))}var y3=2147483625,TS=2147483626,jn=2147483627,v3=-1073741831,HS=-1073741830,E3=-1073741829,S3=4;function M3(t,e,n,r,i){let o=Math.trunc,s=n.col*r.w,a=n.row*r.h,c=o((Math.max(i.x,s)+r.w-1)/r.w),u=o(Math.min(i.x+i.w,s+n.cols*r.w)/r.w),f=o((Math.max(i.y,a)+r.h-1)/r.h),l=o(Math.min(i.y+i.h,a+n.rows*r.h)/r.h);if(u<=c||l<=f)return;return{col:c,row:f,cols:u-c,rows:l-f,x:o((c*r.w-i.x)*t/i.w),y:o((f*r.h-i.y)*e/i.h),w:o((u-c)*r.w*t/i.w),h:o((l-f)*r.h*e/i.h)}}function x3(t){try{let e=b3(t,"r"),n=Buffer.alloc(24);return w3(e,n,0,24,0),p3(e),n.readUInt32BE(0)===2303741511?{width:n.readUInt32BE(16),height:n.readUInt32BE(20)}:void 0}catch{return}}class Xl{ready=()=>{};cell={w:0,h:0};held;tints=new hg;sent=new Map;placed=new Map;viewed="";renders;scratch;made=0;bands=new Map;home;name;views;banded;files;static of(t,e,n,r){if(Ft(t)||!us(t,r)||!(ls(t)||qi(t)))return;return new Xl(t,e,n)}constructor(t,e,n){this.home=e,this.name=n,this.views=qi(t),this.banded=Uu(t),this.files=Wu(t)}get laid(){return this.cell.w>0}measured(t){if(this.cell.w===0&&t.w>0&&t.h>0)this.cell=t}load(){let t=X(this.home),e=Te(t,this.name,$3()),n=[];try{n=Nt(t).palettes[this.name]?.pictures??[]}catch{}let r=e?PS(n,e.image):void 0;this.held=e&&r?{picture:r,image:e.image,opacity:e.opacity,cover:e.cover,at:qt.indexOf(e.position)+1||5}:void 0}draw(t,e,n,r,i,o={col:0,row:0,cols:r,rows:i}){if(this.cell.w===0)return"";let s=t[0],a=this.look(t,e,n,o,!this.views||o.cols===r&&o.rows===i);if(this.views){let u=r*this.cell.w,f=i*this.cell.h,l=a?`${s}|${a.image}|${a.opacity}|${u}|${f}|${a.box.w}|${a.box.h}|${a.box.x}|${a.box.y}|${this.held?.at??5}`:`${s}||1|${u}|${f}|0|0|0|0|5`;if(l===this.viewed)return"";return this.viewed=l,Di(l)}let c=this.layer(y3,v3,"f=24",Buffer.from(st(s)),o);if(a){let u=Math.max(0,Math.min(255,Math.round((1-a.opacity)*255)));c+=this.picture(a),c+=this.layer(TS,E3,"f=32",Buffer.from([...st(s),u]),o)}else c+=this.drop(jn)+this.drop(TS);return c}resized(){this.sent.clear(),this.placed.clear(),this.viewed=""}clear(){let t=this.views&&this.viewed?Di(""):"";for(let e of this.sent.keys())t+=ac(e);return this.resized(),t}close(){let t=this.clear();if(this.tints.clear(),this.renders?.close(),this.scratch)AS(this.scratch,{recursive:!0,force:!0});return t}look(t,e,n,r,i){let o=this.held;if(!o)return;let s={name:this.name,...re([...t]),waived:[...n]},a=RS(o.picture,o.image,s,e,this.tints),c=x3(a);if(!c)return;let u=Jo(c.width,c.height,r.cols*this.cell.w,r.rows*this.cell.h,100,o.at,o.cover&&i),f={...u,x:u.x+r.col*this.cell.w,y:u.y+r.row*this.cell.h},l=M3(c.width,c.height,r,this.cell,f);if(!l)return;return{image:a,opacity:o.opacity,...c,box:f,rect:l}}layer(t,e,n,r,i){let o=r.toString("base64"),s=`${o}|${i.col}|${i.row}|${i.cols}|${i.rows}`;if(this.placed.get(t)===s)return"";return this.sent.set(t,s),this.placed.set(t,s),`\x1B_Ga=t,${n},s=1,v=1,i=${t},q=2;${o}\x1B\\\x1B[${i.row+1};${i.col+1}H\x1B_Ga=p,i=${t},p=${t},c=${i.cols},r=${i.rows},C=1,z=${e},q=2\x1B\\`}picture(t){let{image:e,rect:n}=t;if(this.banded&&(2*n.y+n.h-t.height)**2>1){let o=this.band(t.image,n.y,n.h);if(!o.ready)return"";e=o.path,n={...n,y:0}}let r="";if(this.sent.get(jn)!==e){let o=Hl({id:jn,path:e,row:0,col:0,cols:0,rows:0,z:HS},this.files);if(o===void 0)return"";r+=o,this.sent.set(jn,e),this.placed.delete(jn)}let i=`${n.col};${n.row};${n.cols};${n.rows};${n.x};${n.y};${n.w};${n.h}`;if(this.placed.get(jn)!==i)r+=`\x1B[${n.row+1};${n.col+1}H\x1B_Ga=p,i=${jn},p=${jn},x=${n.x},y=${n.y},w=${n.w},h=${n.h},c=${n.cols},r=${n.rows},C=1,z=${HS},q=2\x1B\\`,this.placed.set(jn,i);return r}drop(t){if(!this.sent.has(t))return"";return this.sent.delete(t),this.placed.delete(t),ac(t)}band(t,e,n){let r=`${t}|${e}|${n}`,i=this.bands.get(r);if(i)return i;this.scratch??=g3(NS(k3(),"ttheme-edit-")),this.renders??=new pc;let o={path:NS(this.scratch,`band-${++this.made}.png`),ready:!1};this.bands.set(r,o),this.renders.run({job:"band",from:t,to:o.path,y:e,height:n}).then(()=>{o.ready=!0,this.ready()}).catch(()=>{});for(let[s,a]of this.bands){if(this.bands.size<=S3)break;if(a.ready&&a.path!==this.sent.get(jn))this.bands.delete(s),AS(a.path,{force:!0})}return o}}var go=50;function at(t,e){return ze(t,e)}function gc(t){return Et(t)>0.35?"#000000":"#ffffff"}function mg(t,e){return t.held!==void 0&&t.held-e.c>0.0005?t.held:void 0}function Ql(t,e,n,r){let i=e.mode==="tune"&&e.channel===ne,o=e.ratio(),{floor:s}=e.partner(),a=(p)=>Math.round(Math.log(Math.max(1,p))/Math.log(21)*(n-1)),c=a(o),u=s===void 0?-1:a(s),f=r===void 0?-1:a(r),l=i?"━":"─",d=Array.from({length:n},(p,b)=>b===c?t.bold("●"):b===f?"○":b===u?"┃":b<u?t.dim(l):l).join(""),h=`${o.toFixed(2)}:1`.padStart(6),m={kind:"channel",channel:ne};return`${at(m,i?t.bold("▸◐"):t.dim(" ◐"))} ${at({kind:"bar",channel:ne},d)} ${at(m,i?t.bold(h):t.dim(h))}`}function tf(t,e){if(!t.misses().has(e))return;if(ng(t.list,t.signature,t.waive,"bright-follows").includes(e))return e-T.length<8?"= makes the bright follow its normal":"= on the normal makes this follow it";return"f moves the colors the gate misses"}function ef(t,e,n){let r=ig(t.list,t.signature,t.waive,e),i=mg(t,n);if(i!==void 0)r.push({ok:void 0,text:`Chroma ○ ${i.toFixed(3)} is held while you tune — ${n.c.toFixed(3)} fits this lightness and hue`});return r}function nf(t){let e=(n,r)=>n.toFixed(r).replace(/^0(?=\.)/,"");return`${e(t.l,2)} ${e(t.c,3)} ${t.h.toFixed(0).padStart(3)}°`}function FS(t){return`${t.l.toFixed(2)} ${t.c.toFixed(3)} ${t.h.toFixed(0).padStart(3)}°`}function O3(t,e,n,r=go){let i=og(e.list,e.signature,e.waive).sort((u,f)=>Number(u.ok!==!1)-Number(f.ok!==!1)),o=i.filter((u)=>u.ok===!1).length,s=` ${t.dim("Gate")} ${o===0?t.dim("passes"):t.bold(`${o} ${o===1?"miss":"misses"}`)}`,a=r-4,c=i.flatMap((u)=>{let f=`${u.value} ${u.bound}`,l=` ${xu(t,u.ok)} ${It(u.ok===!1?u.label:t.dim(u.label),t.dim(f),a-2)}`,d=[...new Set(u.slots)].map((p)=>Ge(p).name),h=u.slots[0],m=(p)=>h===void 0?p:at({kind:"slot",slot:h},p);return d.length>0?[m(l),m(` ${t.dim(nt(d.join(" · "),a-2))}`)]:[m(l)]});return[o===0?s:It(s,`${t.bold("n")} ${t.dim("next miss")}`,r-2),...c.slice(0,Math.max(0,n-1))]}function LS(t,e){let n=t-T.length;if(n>=0)return e===String(n)||e===`B${n}`||e===`K${n}`;return t===3&&e==="s"||t===2&&e==="c"}function rf(t,e,n,r){let i=r?gt("under"):"";if(n==="d")return`${t.fg(e.foreground)}${gt("dim")}${i}`;if(n==="b")return`${t.fg(e.foreground)}${gt("bold")}${i}`;if(n==="s")return`${t.bg(e.selection)}${t.fg(e.foreground)}${i}`;if(n==="c")return`${t.bg(e.cursor)}${i}`;let o=/^([BK]?)(\d+)$/.exec(n);if(!o)return`${t.fg(e.foreground)}${i}`;let s=e.ansi[Number(o[2])];if(o[1]==="K")return`${t.fg(e.ansi[0])}${t.bg(s)}${i}`;return`${t.fg(s)}${o[1]==="B"?gt("bold"):""}${i}`}function bc(t,e,n,r,i){let o=e.length-1,s=Math.max(0,Math.min(o,n)),a=i===void 0?-1:Math.max(0,Math.min(o,i));if(!t.color)return e.map((c,u)=>u===s?"●":u===a?"○":r?"━":"─").join("");return e.map((c,u)=>{let f=c??"#000000";if(u===s)return`${t.bg(f)}${t.fg(gc(f))}${A.on}${se}`;if(u===a)return c?`${t.bg(c)}${t.fg(gc(c))}${A.off}${se}`:`${t.fg("#aaaaaa")}${A.off}`;return c?`${t.fg(c)}█`:`${t.fg(r?"#777777":"#555555")}░`}).join("").concat(bt)}function of(t,e,n){return Array.from({length:n},(r,i)=>{let o=e.min+(e.max-e.min)*i/(n-1),s={...t,[e.key]:o};return Ln(s.l,s.c,s.h)?Xe(s.l,s.c,s.h):void 0})}function bo(t,e,n,r){return Math.round((t-e)/(n-e)*(r-1))}function pg(t){return og(t.list,t.signature,t.waive).filter((e)=>e.ok===!1).length}function wc(t,e,n,r){if(n<3)return[];let i=pg(e),o=i===0?" Gate ✓ passes ":` Gate ✗ ${i} · n next `;return[t.dim(Jt(r,"top",[[2,o]])),...O3(t,e,n-1,r-1).slice(1).map((s)=>De(t,s,r)),t.dim(Jt(r,"bottom"))]}var $r=0.98,$c=0.12,I3=0.37,CS=0.74,R3=0.15,P3=-1073741828,gg=-1073741827,bg=-1073741826,A3=-1073741825,N3=2147483584,T3=["panel","plane","hue","contrast","mark","hue-thumb","contrast-thumb","origin","hue-origin","contrast-origin"],H3=4096;function kc(t,e){return Cs(t,e,I3)}function af(t,e,n){let r=kc(t,n);return r>0.000001?Math.min(1,e/r):0}function yc(t,e){return{width:t,height:e,data:new Uint8Array(t*e*4)}}function pi(t,e,n,r,i){let o=r[3]*i;if(o<=0||e<0||n<0||e>=t.width||n>=t.height)return;let s=(n*t.width+e)*4,a=t.data;if(o>=1){a[s]=r[0],a[s+1]=r[1],a[s+2]=r[2],a[s+3]=255;return}let c=a[s+3]/255,u=o+c*(1-o);for(let f=0;f<3;f++)a[s+f]=Math.round((r[f]*o+a[s+f]*c*(1-o))/u);a[s+3]=Math.round(u*255)}function wr(t,e=1){return[...st(t),e]}function Us(t,e,n,r,i,o,s){let a=Math.abs(t-(n+i/2))-(i/2-s),c=Math.abs(e-(r+o/2))-(o/2-s);return Math.hypot(Math.max(a,0),Math.max(c,0))+Math.min(Math.max(a,c),0)-s}function wo(t,e,n,r){let i=[],o=[],s=Math.max(0,Math.floor(r?.x??0)),a=Math.max(0,Math.floor(r?.y??0)),c=Math.min(t,Math.ceil(r?r.x+r.w:t)),u=Math.min(e,Math.ceil(r?r.y+r.h:e));for(let f=a;f<u;f++)for(let l=s;l<c;l++){let d=n(l+0.5,f+0.5);if(d>0.002)i.push(f*t+l),o.push(Math.min(1,d))}return{at:Uint32Array.from(i),cover:Float32Array.from(o)}}function $o(t,e,n){for(let r=0;r<e.at.length;r++){let i=e.at[r];pi(t,i%t.width,Math.floor(i/t.width),n,e.cover[r])}}function wg(t,e){return(n,r)=>Math.max(0,0.5-Us(n,r,t.x,t.y,t.w,t.h,e))}function jS(t,e,n){return(r,i)=>Math.max(0,0.5-Math.abs(Us(r,i,t.x,t.y,t.w,t.h,e)+n/2)+n/2)}var sf=new Map;function F3(t,e,n,r){let i=`${e.w}x${e.h} ${BS({...t,ground:"#000000",ink:"#000000",accent:"#000000"})}`,o=sf.get(i);if(o)return o;let{panel:s}=t,a={x:e.w,y:0,w:s.cols*e.w,h:s.rows*e.h},c=Math.round(e.h*0.45),u=Math.round(e.h*0.18),f=e.h*0.6,l=Math.max(1,Math.round(e.h/22)),d=(R)=>({x:(R.col-s.col+1)*e.w,y:(R.row-s.row)*e.h}),h=Math.max(1,Math.round(e.h*0.08)),m=d(t.tabs),p={x:m.x,y:m.y+h,w:t.tabs.cols*e.w,h:e.h-2*h},b=Math.floor(t.tabs.cols/t.tabs.count)*e.w,$=Math.max(1,Math.round(h/2)),k={x:p.x+t.tabs.active*b+$,y:p.y+$,w:(t.tabs.active===t.tabs.count-1?p.w-t.tabs.active*b:b)-2*$,h:p.h-2*$},v=d(t.field),E={x:v.x,y:v.y+h,w:t.field.cols*e.w,h:e.h-2*h},x=t.divider===void 0?void 0:{x:a.x+e.w*0.6,y:(t.divider-s.row)*e.h,w:a.w-e.w*1.2,h:l},M={shadow:wo(n,r,(R,F)=>{let N=Us(R,F,a.x,u,a.w,a.h,c);return N>0&&N<f?(1-N/f)**2:0}),fill:wo(n,r,wg(a,c),a),border:wo(n,r,jS(a,c,l),a),track:wo(n,r,wg(p,p.h*0.3),p),segment:wo(n,r,wg(k,k.h*0.3),k),field:wo(n,r,jS(E,E.h*0.3,l),E),divider:x&&wo(n,r,()=>1,x)};if(sf.size>8)sf.clear();return sf.set(i,M),M}function L3(t){let e=Et(t.ground)<0.18;return{dark:e,surface:At(t.ground,t.ink,e?0.07:0.04)}}function C3(t,e){let n=yc((t.panel.cols+2)*e.w,(t.panel.rows+1)*e.h),r=F3(t,e,n.width,n.height),{dark:i,surface:o}=L3(t);if($o(n,r.shadow,[0,0,0,i?0.45:0.18]),$o(n,r.fill,wr(o)),$o(n,r.border,wr(t.ink,i?0.16:0.2)),$o(n,r.track,wr(t.ink,i?0.06:0.07)),$o(n,r.segment,wr(t.accent,i?0.24:0.2)),$o(n,r.field,wr(t.ink,i?0.22:0.28)),r.divider)$o(n,r.divider,wr(t.ink,i?0.12:0.16));return n}function j3(t,e,n){let r=yc(Math.round(t.cols*n.w),Math.round(t.rows*n.h)),{width:i,height:o,data:s}=r,a=Math.round(n.h*0.3),c=Math.max(1,(t.cols-1)*n.w),u=(h)=>Math.min(1,Math.max(0,(h+0.5-n.w/2)/c)),f=t.rows*2-1,l=(h)=>$r-Math.min(1,Math.max(0,((h+0.5)/n.h*2-0.5)/f))*($r-$c),d=[];for(let h=0;h<o;h++){if(h%2===0){let m=l(h+0.5),p=kc(m,e);d=Array.from({length:Math.ceil(i/2)},(b,$)=>Ln(m,u($*2+0.5)*p,e)??[0,0,0])}for(let m=0;m<i;m++){let b=(m<a||m>=i-a)&&(h<a||h>=o-a)?Math.min(1,Math.max(0,0.5-Us(m+0.5,h+0.5,0,0,i,o,a))):1;if(b<=0)continue;let $=d[m>>1],k=(h*i+m)*4;s[k]=$[0],s[k+1]=$[1],s[k+2]=$[2],s[k+3]=Math.round(b*255)}}return r}function GS(t,e){let n=Math.max(4,Math.round(t.h*0.42));return{top:Math.round((t.h-n)/2),height:n,width:e*t.w}}function _3(t,e){let n=yc(t.cols*e.w,e.h),{top:r,height:i,width:o}=GS(e,t.cols),s=Array.from({length:o},(a,c)=>{let f=Math.min(1,Math.max(0,((c+0.5)/e.w-0.5)/Math.max(1,t.cols-1)))*360;return Ln(CS,Cs(CS,f,R3),f)??[0,0,0]});for(let a=r;a<r+i;a++)for(let c=0;c<o;c++){let u=Math.min(1,Math.max(0,0.5-Us(c+0.5,a+0.5,0,r,o,i,i/2))),f=s[c];pi(n,c,a,[f[0],f[1],f[2],1],u)}return n}function G3(t,e,n){let r=yc(t.cols*n.w,n.h),{top:i,height:o,width:s}=GS(n,t.cols),a=t.floor===void 0?-1:Math.round((t.floor*(t.cols-1)+0.5)*n.w),c=Math.max(2,Math.round(o*0.45)),u=i+Math.round((o-c)/2);for(let f=u;f<u+c;f++)for(let l=0;l<s;l++){let d=Math.min(1,Math.max(0,0.5-Us(l+0.5,f+0.5,0,u,s,c,c/2))),h=a<0||l>=a;pi(r,l,f,wr(e,h?t.lit?0.5:0.36:0.14),d)}if(a>=0){let f=Math.max(2,Math.round(n.w/5));for(let l=i-1;l<i+o+1;l++)for(let d=a-Math.floor(f/2);d<a-Math.floor(f/2)+f;d++)pi(r,d,l,wr(e,0.85),1)}return r}function B3(t,e,n,r,i,o,s){let a=yc(t*s.w,e*s.h),c=Math.max(2,Math.round(i*0.3)),u=(l,d)=>Math.min(1,Math.max(0,l-d+0.5)),f=[0,0,0,0.5];for(let l=0;l<a.height;l++)for(let d=0;d<a.width;d++){let h=Math.hypot(d+0.5-n,l+0.5-r);if(o)pi(a,d,l,wr(o),u(i-c,h));else pi(a,d,l,f,u(i-c,h)-u(i-c-1,h));pi(a,d,l,f,u(i+1,h)-u(i,h)),pi(a,d,l,[255,255,255,1],u(i,h)-u(i-c,h))}return a}function Bs(t,e,n,r,i,o,s=A3){let a=Math.floor((e-r-2)/o.w),c=Math.floor((e+r+2)/o.w),u=Math.floor((n-r-2)/o.h),f=Math.floor((n+r+2)/o.h),l={row:u,col:a,cols:c-a+1,rows:f-u+1},d=Math.round((e-a*o.w)*2)/2,h=Math.round((n-u*o.h)*2)/2;return{name:t,key:`${l.cols}x${l.rows} ${d},${h} ${r} ${i??"-"}`,box:l,z:s,paint:()=>B3(l.cols,l.rows,d,h,r,i,o)}}function BS(t){let{panel:e}=t,n=(i)=>`${i.row-e.row},${i.col-e.col},${i.cols}`,r=t.divider===void 0?"-":t.divider-e.row;return`${e.cols}x${e.rows} ${t.ground} ${t.ink} ${t.accent} ${n(t.tabs)},${t.tabs.active}/${t.tabs.count} ${n(t.field)} ${r}`}function U3(t,e){let n=`${e.w}x${e.h}`,r=Math.max(4,Math.round(e.h*0.34)),i=(l,d)=>(l.col+0.5+d*(l.cols-1))*e.w,o=(l)=>(l.row+0.5)*e.h,s=t.plane,a=(l)=>{let d=($r-l)/($r-$c)*(s.rows*2-1);return s.row*e.h+(Math.min(s.rows*2-1,Math.max(0,d))+0.5)*e.h/2},c=a(s.l),u=[{name:"panel",key:`${n} ${BS(t)}`,box:{row:t.panel.row,col:t.panel.col-1,cols:t.panel.cols+2,rows:t.panel.rows+1},z:P3,paint:()=>C3(t,e)},{name:"plane",key:`${n} ${s.cols}x${s.rows} ${s.h.toFixed(2)}`,box:s,z:gg,paint:()=>j3(s,s.h,e.h>=24?{w:e.w/2,h:e.h/2}:e)},{name:"hue",key:`${n} ${t.hue.cols}`,box:{...t.hue,rows:1},z:gg,paint:()=>_3(t.hue,e)},{name:"contrast",key:`${n} ${t.contrast.cols} ${t.contrast.floor??"-"} ${t.contrast.lit} ${t.ink}`,box:{...t.contrast,rows:1},z:gg,paint:()=>G3(t.contrast,t.ink,e)},Bs("mark",i(s,af(s.l,s.c,s.h)),c,r,void 0,e),Bs("hue-thumb",i(t.hue,t.hue.h/360),o(t.hue),r,t.hue.color,e),Bs("contrast-thumb",i(t.contrast,t.contrast.at),o(t.contrast),r,t.contrast.color,e)],f=t.origin;if(f){let l=Math.max(3,Math.round(r*0.55));u.push(Bs("origin",i(s,af(f.l,f.c,f.h)),a(f.l),l,f.color,e,bg),Bs("hue-origin",i(t.hue,f.h/360),o(t.hue),l,f.color,e,bg),Bs("contrast-origin",i(t.contrast,f.at),o(t.contrast),l,f.color,e,bg))}return u}function W3(t,e){let r=e.toString("base64").match(new RegExp(`.{1,${H3}}`,"g"))??[""];return r.map((i,o)=>{let s=o<r.length-1?1:0;return o===0?`\x1B_Ga=t,f=100,i=${t},m=${s},q=2;${i}\x1B\\`:`\x1B_Gm=${s},q=2;${i}\x1B\\`}).join("")}function _S(t,e,n){return`\x1B[${e.row+1};${e.col+1}H\x1B_Ga=p,i=${t},p=${t},c=${e.cols},r=${e.rows},C=1,z=${n},q=2\x1B\\`}function $g(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}class cf{cell={w:0,h:0};shown=new Map;static of(t,e){return Ft(t)||!us(t,e)||!ls(t)?void 0:new cf}get ready(){return this.cell.w>0}measured(t){if(this.cell.w===0&&t.w>0&&t.h>0)this.cell=t}draw(t){if(!this.ready)return"";let e=t?U3(t,this.cell):[],n="";for(let r of e)n+=this.put(r);for(let[r,i]of this.shown)if(!e.some((o)=>o.name===r))n+=$g(i.id),this.shown.delete(r);return n}clear(){let t="";for(let e of this.shown.values())t+=$g(e.id);return this.shown.clear(),t}put(t){let e=`${t.box.row};${t.box.col};${t.box.cols};${t.box.rows}`,n=this.shown.get(t.name);if(n&&n.key===t.key){if(n.at===e)return"";return n.at=e,_S(n.id,t.box,t.z)}let r=N3+T3.indexOf(t.name)*2,i=n?.id===r?r+1:r;return this.shown.set(t.name,{key:t.key,id:i,at:e}),`${W3(i,We(t.paint()))}${_S(i,t.box,t.z)}${n?$g(n.id):""}`}}var vc=34,kg=2,K3=6,lf=3,z3=7,WS="↑↓ L ←→ C ⇧←→ H tab ◐";function q3(t,e,n){let r="",i=0;for(let o of t){let s=i+_(o);if(s>e&&i<n)r+=i>=e&&s<=n?o:" ".repeat(Math.min(s,n)-Math.max(i,e));if(i=s,i>=n)break}return r}function ff(t){return t.reduce((e,n)=>e+_(n.text),0)}function df(t,e,n){let r=[],i=0;for(let o of t){let s=_(o.text),a=Math.max(e,i),c=Math.min(n,i+s);if(c>a)r.push({...o,text:q3(o.text,a-i,c-i)});i+=s}return r}function D3(t,e,n){return[...df(t,0,e),...n,...df(t,e+ff(n),ff(t))]}function J3(t,e){return t.map((n)=>{let r=e&&n.sgr?`${n.sgr}${n.text}${me}`:n.text;return n.target?ze(n.target,r):r}).join("")}function KS(t){return t<T.length?T[t]:mn[(t-T.length)%8]}function zS(t,e,n,r){let i=t.signature.includes(Cn[n])?A.signature:e.color?A.swatch:" ";return e.color?`${e.fg(t.list[n])}${i}${r}`:i}function qS(t,e,n,r,i){return r.has(n)?e.bold(A.miss):t.changed(n)?e.color?`${gt("warn")}${A.on}${i}`:A.on:" "}function DS(t,e,n){return n?t.color?`${t.fg(e.cursor)}${A.gutter}${bt} `:`${A.gutter} `:" "}function Y3(t,e,n,r,i,o){let s=r===t.slot(),a=s?e.fg(n.foreground):bt,c=KS(r).padEnd(12),u=t.lch[r],f=`${DS(e,n,s)}${zS(t,e,r,a)} ${s?e.bold(c):c}${FS(u)} ${qS(t,e,r,o,a)}`,l=nt(f,i);return at({kind:"open",slot:r},s&&e.color?`${e.bg(n.selection)}${e.fg(n.foreground)}${l}${se}`:l)}var yg=8,JS=44;function Sc(t){return t>=JS?16:11}function US(t,e,n,r,i,o){let s=Sc(i);if(!t.visible(r))return" ".repeat(s);let a=r===t.slot(),c=a&&e.color?e.fg(n.foreground):bt,u=t.lch[r],f=(p,b)=>p.toFixed(b).replace(/^0(?=\.)/,""),l=`${u.h.toFixed(0).padStart(3)}°`,d=i>=JS?`${f(u.l,2)} ${f(u.c,3)} ${l}`:`${f(u.l,2)} ${l}`,h=`${zS(t,e,r,c)} ${d}${qS(t,e,r,o,c)}`,m=a&&e.color?`${e.bg(n.selection)}${e.fg(n.foreground)}${h}${se}`:h;return at({kind:"open",slot:r},m)}function Z3(t,e,n,r,i,o){let s=T.length+r,a=s+8,c=t.row===s,u=mn[r].padEnd(yg),f=t.linkOf(a)!==void 0?e.dim("⇠"):" ";return`${at({kind:"open",slot:s},`${DS(e,n,c)}${c?e.bold(u):u}`)}${US(t,e,n,s,i,o)}${f} ${US(t,e,n,a,i,o)}`}function YS(t){return 14+2*Sc(t)}function V3(t){let e=Sc(t)>=16;return[[2," ANSI "],[2+yg,e?" Normal 0–7 ":" Normal "],[5+yg+Sc(t),e?" Bright 8–15 ":" Bright "]]}function X3(t,e,n,r){let i=t.slot(),o=Ge(i),s=YS(r),a=s-2,c=` ${o.name}${i>=T.length?` · ${o.about}`:""} `,u=[` ${e.dim(aS(i))}`];if(i>=2){let l=NE(n,i).filter((m)=>m.count>0),d=l.length>0?l.map((m)=>`${m.name} ${m.count}`).join(" · "):"none",h=jt("w",t.where?qe(e,"w where"):e.dim("w where"));u.push(It(` ${e.dim("Shown in")} ${d}`,`${h} `,a))}let f=i-T.length;if(f===0||f===7||f===8||f===15){let l=t.lch[i].l,d=t.lch[0].l,h=t.lch[1].l,m=Math.abs(l-d)<=Math.abs(l-h)?"the background":"the text";u.push(` ${e.dim(`L ${l.toFixed(2)} reads near ${m}`)}`)}return[e.dim(Jt(s,"top",[[2,c]])),...u.map((l)=>De(e,l,s)),e.dim(Jt(s,"bottom"))]}function uf(t,e){return $r-t*($r-$c)/(e*2-1)}function ZS(t,e,n,r,i){let o=uf(Math.max(0,Math.min(e*2-1,t*2-0.5)),e),s=Math.max(0,Math.min(1,(n-0.5)/Math.max(1,r-1)));return{lightness:o,chroma:s*kc(o,i)}}function Q3(t,e,n,r,i,o){let s=(l)=>{let d=Math.max(0,Math.min(i*2-1,Math.round(($r-l.l)/($r-$c)*(i*2-1))));return{row:Math.floor(d/2),col:Math.round(af(l.l,l.c,l.h)*(r-1))}},{row:a,col:c}=s(e),u=o?s(o):{row:-1,col:-1},f=(l,d)=>{return`#${(Ln(l,d*kc(l,e.h),e.h)??[0,0,0]).map((m)=>m.toString(16).padStart(2,"0")).join("")}`};return Array.from({length:i},(l,d)=>{let h="";for(let m=0;m<r;m++){if(d===a&&m===c){h+=t.color?`${t.bg(n)}${t.fg(gc(n))}${A.on}${se}`:A.on;continue}let p=m/Math.max(1,r-1);if(d===u.row&&m===u.col){let b=f(uf(d*2+1,i),p);h+=t.color?`${t.bg(b)}${t.fg(gc(b))}${A.off}${se}`:A.off;continue}h+=t.color?`${t.fg(f(uf(d*2,i),p))}${t.bg(f(uf(d*2+1,i),p))}▀${se}`:"·"}return at({kind:"plane",row:d,rows:i},h)})}function VS(t,e,n){let r=t.slot(),i=t.lch[r],s=ef(t,r,i).filter((c)=>c.ok===!1||c.text.startsWith("Chroma ○")).flatMap((c)=>St(c.text,n-2).map((u,f)=>`${f===0?c.ok===!1?e.bold(A.miss):e.dim(A.off):" "} ${u}`)),a=tf(t,r);return[...s.slice(0,3),...a?[e.dim(a)]:[]]}function XS(t,e,n){let r=t.pair(t.slot());if(!r)return;let i=t.slot()>=r.bright,o=KS(i?r.normal:r.bright).toLowerCase(),s=`${r.lift>=0?"+":""}${r.lift.toFixed(2)}`,a=n-9,c=i?r.on?[`⇠ Linked to ${o} · L ${s}`,`⇠ ${o} · L ${s}`,`⇠ ${o}`]:[`Not linked to ${o}`,"Not linked"]:r.on?[`Bright follows · L ${s}`,"Bright follows"]:["Its bright moves on its own","Moves on its own"],u=c.find((f)=>_(f)<=a)??c[c.length-1]??"";return It(e.dim(u),jt("l",`${e.bold("l")} ${e.dim(r.on?"unlink":"link")}`),n)}function QS(t,e,n){let r=t.slot(),i=t.list[r],o=t.lch[r],s=t.typing!==void 0?e.bold(`${t.typing}▏`):jt("#",e.bold(uS(t.format,i,o))),a=t.start[r],c=e.color?`${e.fg(a)}${A.swatch}${bt} `:"";return It(s,a!==i?e.dim(`was ${c}${a}`):"",n)}function t5(t,e,n,r){let i=t.slot(),o=t.lch[i],s=t.list[i],a=n-4,c=e.dim("│"),u=(M)=>`${c} ${nt(M,a)} ${c}`,f=XS(t,e,a),l=6+(f?1:0),d=VS(t,e,a).slice(0,Math.max(0,r-l-lf)),h=Math.max(lf,Math.min(K3,r-l-d.length)),m=" L × C ",p=` H ${o.h.toFixed(0)}° `,b=Math.max(0,n-4-_(" L × C ")-_(p)),$=[`${e.dim("╭─")}${e.dim(" L × C ")}${e.dim("─".repeat(b))}${e.dim(p)}${e.dim("─╮")}`],k=t.origin();for(let M of Q3(e,o,s,a,h,k?.lch))$.push(u(M));let v=hn[2];$.push(u(at({kind:"bar",channel:2},bc(e,of(o,v,a),bo(o.h,v.min,v.max,a),t.mode==="tune"&&t.channel===2,k&&bo(k.lch.h,v.min,v.max,a))))),$.push(u(Ql(e,t,Math.max(8,a-11),k?.ratio)));let E=(M,R)=>at({kind:"format",format:R},t.format===R?qe(e,M):e.dim(` ${M} `));if($.push(u(`${E("Hex","hex")} ${E("RGB","rgb")} ${E("OKLCH","oklch")}`)),$.push(u(QS(t,e,a))),f)$.push(u(f));for(let M of d)$.push(u(M));let x=nt(` ${WS} `,n-4,!1);return $.push(`${e.dim("╰─")}${e.dim(x)}${e.dim("─".repeat(Math.max(0,n-4-_(x))))}${e.dim("─╯")}`),{lines:$.map((M)=>at({kind:"picker"},M))}}var Ec=[["Hex","hex"],["RGB","rgb"],["OKLCH","oklch"]];function e5(t,e,n,r){let i=t.lch[t.slot()],o=n-2,s=XS(t,e,o),a=6+(s?1:0),c=VS(t,e,o).slice(0,Math.max(0,r-a-lf)),u=Math.max(lf,Math.min(z3,r-a-c.length)),f=(M)=>` ${nt(M,o)} `,l=[f(It(e.dim("L × C"),e.dim(`H ${i.h.toFixed(0)}°`),o))];for(let M=0;M<u;M++)l.push(f(at({kind:"plane",row:M,rows:u}," ".repeat(o))));let d=l.length;l.push(f(at({kind:"bar",channel:2}," ".repeat(o))));let h=l.length,m=t.mode==="tune"&&t.channel===ne,p={kind:"channel",channel:ne},b=`${t.ratio().toFixed(2)}:1`.padStart(8),$=o-11;l.push(f(`${at(p,m?e.bold("◐"):e.dim("◐"))} ${at({kind:"bar",channel:ne}," ".repeat($))} ${at(p,m?e.bold(b):e.dim(b))}`));let k=l.length,v=Math.floor(o/Ec.length);l.push(f(Ec.map(([M,R],F)=>{let N=F===Ec.length-1?o-v*F:v,j=Math.floor((N-_(M))/2),z=`${" ".repeat(j)}${M}${" ".repeat(N-j-_(M))}`,G=t.format===R?e.color?e.accent(e.bold(z)):`[${M}]`.padEnd(N):e.dim(z);return at({kind:"format",format:R},G)}).join("")));let E=l.length;l.push(f(` ${QS(t,e,o-2)} `));let x=s?l.length:void 0;if(s)l.push(f(s));for(let M of c)l.push(f(M));return l.push(f(e.dim(WS))),{lines:l.map((M)=>at({kind:"picker"},M)),parts:{plane:{row:1,col:1,cols:o,rows:u},hue:{row:d,col:1,cols:o,rows:1},contrast:{row:h,col:3,cols:$,rows:1},tabs:{row:k,col:1,cols:o,rows:1},field:{row:E,col:1,cols:o,rows:1},divider:x}}}function n5(t,e,n,r,i,o){let s=t.slot(),a=t.lch[s],c=t.list[s],u=(h)=>({row:r+h.row,col:i+h.col,cols:h.cols,rows:h.rows}),f=(h)=>Math.log(Math.max(1,h))/Math.log(21),l=t.partner().floor,d=t.origin();return{panel:{row:r,col:i,cols:n.plane.cols+2,rows:o},ground:e.background,ink:e.foreground,accent:e.cursor,plane:{...u(n.plane),h:a.h,l:a.l,c:a.c},hue:{...u(n.hue),h:a.h,color:c},contrast:{...u(n.contrast),at:f(t.ratio()),floor:l===void 0?void 0:f(l),color:c,lit:t.channel===ne},tabs:{...u(n.tabs),active:Ec.findIndex(([,h])=>h===t.format),count:Ec.length},field:u(n.field),divider:n.divider===void 0?void 0:r+n.divider,origin:d&&{...d.lch,color:d.hex,at:f(d.ratio)}}}function r5(t,e,n,r,i,o,s,a){let u=o??1,f=s-1-u,l=u-2,d=12+2*Sc(r)-kg,h=a?e5:t5,m=h(t,e,d,Number.POSITIVE_INFINITY),p=m.lines.length<=f||m.lines.length>l&&f>=l,b=p?f:l,$=m.lines.length<=b?m:h(t,e,d,b),k=p?u+1:u-$.lines.length,v=Array.from({length:s},(E,x)=>i[x]??"");return $.lines.forEach((E,x)=>{let M=k+x;if(M>=0&&M<s)v[M]=xk(v[M],kg,E)}),{lines:v,art:$.parts&&n5(t,n,$.parts,k,kg,$.lines.length)}}function i5(t,e,n,r,i){let o=r.side,s=pg(t),a=t.changedOnly?e.warn(A.on):" ",c=s===0?e.dim("Gate ✓"):e.bold(`Gate ✗ ${s}`),u=It(` ${e.bold("Colors")} ${c}`,jt("m",`${t.changedOnly?e.bold("⧩ changed"):e.dim("⧩ changed")}${a} `),o),f=i-1,l=t.misses(),d=YS(o),h=[],m,p=T.map((k,v)=>v).filter((k)=>t.visible(k));if(p.length>0){h.push(e.dim(Jt(d,"top",[[2," Base "]])));for(let k of p){if(k===t.slot())m=h.length;h.push(De(e,Y3(t,e,n,k,d-2,l),d))}}let b=mn.map((k,v)=>v).filter((k)=>t.visible(T.length+k)||t.visible(T.length+k+8));if(b.length>0){h.push(e.dim(Jt(d,p.length>0?"mid":"top",V3(o))));for(let k of b){if(t.row===T.length+k)m=h.length;h.push(De(e,Z3(t,e,n,k,o,l),d))}}if(p.length>0||b.length>0)h.push(e.dim(Jt(d,"bottom")));if(t.visible(t.slot()))h.push(...X3(t,e,r,o));let $=wc(e,t,f-h.length,d);return h.push(...Array.from({length:Math.max(0,f-h.length-$.length)},()=>""),...$),{lines:[u,...h.slice(0,f)],anchor:m===void 0?void 0:m+1}}function o5(t,e,n){let r=`${e.accent(A.current)} ${e.bold(t.options.title)} ${e.dim(`· ${t.options.name}`)}`,i=t.dirty(),o=t.changes(),s=e.warn(A.on),a=i?`${s} ${e.dim(o>0?`unsaved · ${o} changed`:"unsaved")}`:"",c=[t.resettable()?jt("R",e.dim("Reset")):"",i?jt("s",qe(e,"Save")):""].filter(Boolean).join(" "),u=[r,a,c].filter(Boolean).join(" "),f=(h,m,p)=>jt(h,p?qe(e,m):e.dim(m)),d=[...t.options.find||t.pictures>0?[f("b",`▣ ${t.pictures>0?`${t.pictures} `:""}Picture`,t.pic&&(t.pictures>0||!!t.options.find))]:[],f("i","⌖ Inspect",t.inspect),`${f("u","↶",!1)} ${f("ctrl+r","↷",!1)}`,f("I","Import ▾",t.menu==="import"),...t.options.exports?[f("x","Export ▾",t.menu==="export")]:[]].join(" ");return It(u,`${d} `,n)}var s5={kind:"open",slot:0};function a5(t,e,n){return t.color?`${n?Nb:t.bg(e.background)}${t.fg(e.foreground)}`:""}function c5(t,e,n,r,i,o){let s=fc(r),a=a5(e,n,o),c=t.slot();return Array.from({length:r.rows},(u,f)=>{let l=s[f],d=[{text:" ",sgr:a}];if(l)l.forEach((p,b)=>{let $=i&&i.pane===r.id&&i.line===f&&i.run===b,k=e.color?$?`${a}${e.bg(n.foreground)}${e.fg(n.background)}`:`${a}${rf(e,n,p.role,Up(p.role,c))}${t.where&&!Bp(p.role,c)?gt("dim"):""}`:"";d.push({text:p.text,sgr:k,target:{kind:"run",spot:{pane:r.id,line:f,run:b}}})});let h=df(d,0,r.width-1),m=r.width-ff(h);return m>0?[...h,{text:" ".repeat(m),sgr:a,target:s5}]:h})}function u5(t,e,n){let r=t.slotsHere();if(!r)return;let i=e.color?`${e.bg(n.background)}${e.fg(n.foreground)}`:"",o=e.color?`${i}${gt("dim")}`:"",s=(l)=>({text:l,sgr:o}),a="┌ Slots here ",c="└ enter its slot · esc ",u=[[s(`${a}${"─".repeat(vc-_(a)-1)}┐`)]],f=[["text",r.text]];if(r.ground!==r.text)f.push(["ground",r.ground]);for(let[l,d]of f){let h={kind:"open",slot:d},m=t.shown()[d],p=d<T.length?"":Ge(d).about;u.push([{text:"│ ",sgr:o,target:h},{text:l.padEnd(7),sgr:o,target:h},{text:A.swatch,sgr:e.color?`${i}${e.fg(m)}`:"",target:h},{text:" ",sgr:i,target:h},{text:Ge(d).name.slice(0,14).padEnd(14),sgr:i,target:h},{text:p.padEnd(vc-27),sgr:o,target:h},{text:" │",sgr:o,target:h}])}return u.push([s(`${c}${"─".repeat(vc-_(c)-1)}┘`)]),u.map((l)=>df(l,0,vc))}function l5(t,e,n){if(!t.menu)return;let r=t.menu==="export"?["Share code","Add command","Palette file"]:["Another palette","A share code"],i=24,o=e.color?`${e.bg(n.background)}${e.fg(n.foreground)}`:"",s=e.color?`${o}${gt("dim")}`:"",a=t.menu==="export"?"Copy ":"Take from ",c=[[{text:`┌ ${a}${"─".repeat(Math.max(0,i-3-a.length))}┐`,sgr:s}]];return r.forEach((u,f)=>{let l=f===t.entry,d={kind:"entry",index:f};c.push([{text:"│",sgr:s},{text:` ${l?"▌":" "} ${u.padEnd(i-6)}`,sgr:l&&e.color?`${e.bg(n.selection)}${e.fg(n.foreground)}${gt("bold")}`:o,target:d},{text:"│",sgr:s}])}),c.push([{text:`└${"─".repeat(i-2)}┘`,sgr:s}]),c}var f5=["#ff5f57","#febc2e","#28c840"];function d5(t,e,n,r){let i=e.color?`${e.bg(tM(n))}${e.fg(n.foreground)}`:"",o=[{text:" ",sgr:i}];for(let u of f5)o.push({text:"●",sgr:e.color?`${i}${e.fg(u)}`:""},{text:" ",sgr:i});o.push({text:" ",sgr:i});let s=AE(),a=(t.scene%s.length+s.length)%s.length;s.forEach((u,f)=>{let l={kind:"scene",scene:f};o.push(f===a?{text:` ${u} `,sgr:e.color?`${i}${e.bg(Ei(n.background,n.foreground,"tab"))}${gt("bold")}`:"",target:l}:{text:` ${u} `,sgr:e.color?`${i}${gt("dim")}`:"",target:l},{text:" ",sgr:i})});let c="⇧←→ ";return[...o,{text:" ".repeat(Math.max(0,r-ff(o)-_(c))),sgr:i},{text:c,sgr:e.color?`${i}${gt("dim")}`:""}]}function tM(t){return Ei(t.background,t.foreground,"bar")}function h5(t,e,n){let{frame:r}=n,i=Ei(e.background,e.foreground,"line"),o=t.color?`${t.bg(eM(e))}${t.fg(i)}`:"",s=t.color?`${t.bg(tM(e))}${t.fg(i)}`:"",a=(u,f)=>u===r.row||u===r.row+r.rows-1||f===r.col||f===r.col+r.cols-1,c=[];for(let[u,f]of CE(n.rules))for(let[l,d]of f)c.push([u,l,[{text:d,sgr:a(u,l)?o:s}]]);return c}function eM(t){return Ei(t.background,t.foreground,"stage")}function nM(t,e){return lc(t,e,0)?.inner}function rM(t,e,n,r,i={}){let o=lc(e,n,t.scene);if(!o)return;let s=Me(r),a=t.shown(),c=re(a),u=re(i.chrome?[...i.chrome]:t.list),f=i5(t,s,u,o,n-1),l=t.mode==="tune"?r5(t,s,u,o.side,f.lines,f.anchor,n-1,r&&i.art===!0):{lines:f.lines,art:void 0},d=l.lines,h=i.behind===!0,m=t.inspect?jl(o,t.spot):void 0,p=s.color?s.bg(eM(u)):"",b=Array.from({length:n-3},()=>[{text:" ".repeat(o.width),sgr:p}]),$=(N,j,z)=>{let G=N-2;if(G>=0&&G<b.length)b[G]=D3(b[G],j,z)},k=o.side+1;for(let[N,j,z]of h5(s,u,o))$(N,j-k,z);for(let N of o.tiles)c5(t,s,c,N,m,h).forEach((j,z)=>{$(N.row+z,N.col-k,j)});$(o.title.row,o.title.col-k,d5(t,s,u,o.title.cols));let v=m?u5(t,s,c):void 0;if(m&&v){let N=o.tiles.find((z)=>z.id===m.pane),j=fc(N)[m.line]?.[m.run];if(j){let z=Math.max(0,Math.min(N.col-k+1+j.col,o.width-vc)),G=N.row+m.line,et=G+1,q=et+v.length-2>n-2?G-v.length:et;v.forEach((Ot,tt)=>{$(q+tt,z,Ot)})}}let E=l5(t,s,c);if(E){let N=Math.max(0,o.width-24-(t.menu==="import"?12:2));E.forEach((j,z)=>{$(2+z,N,j)})}let x=o5(t,s,o.width),M=s.dim("─".repeat(o.width)),R=s.dim("│"),F=[];for(let N=0;N<n-1;N++){let j=N===0?x:N===1?M:J3(b[N-2]??[],r);F.push(`${nt(d[N]??"",o.side)}${R}${j}`)}return{lines:F,art:l.art}}var iM=80,oM=24,vg=11;function m5(t,e,n,r){let i=mg(e,n);return hn.map((o,s)=>{let a=e.mode==="tune"&&s===e.channel,c=n[o.key],u=`${c.toFixed(o.digits)}${o.wraps?"°":""}`.padStart(6),f=bc(t,of(n,o,r),bo(c,o.min,o.max,r),a,o.key==="c"&&i!==void 0?bo(i,o.min,o.max,r):void 0),l=o.key.toUpperCase(),d={kind:"channel",channel:s};return`${at(d,a?t.bold(`▸${l}`):t.dim(` ${l}`))} ${at({kind:"bar",channel:s},f)} ${at(d,a?t.bold(u):t.dim(u))}`})}function p5(t,e){if(e.mode!=="tune"||e.slot()<T.length)return[];let n=js.map((i)=>at({kind:"scope",scope:i},i!==e.scope?t.dim(i):qe(t,i))),r=e.scoped().length;return[`${t.dim("Scope")} ${n.join(" ")}`,t.dim(r>1?`${r} slots move by the same step, each keeping its own color`:"This slot moves alone · a widens it")]}var sM={background:(t)=>t.background,foreground:(t)=>t.foreground,hue:(t)=>t.cursor,tint:(t)=>t.background,lightness:(t)=>t.ansi[4],chroma:(t)=>t.ansi[1],brights:(t)=>t.ansi[12]};function g5(t){return`oklch ${t.l.toFixed(3)} ${t.c.toFixed(3)} ${t.h.toFixed(0)}°`}function b5(t,e){return`${t.dim("oklch")} ${t.bold(`${e.l.toFixed(3)} ${e.c.toFixed(3)} ${e.h.toFixed(0)}°`)}`}function w5(t,e,n,r=go){let i=e.misses(),o=re(e.list),s=e.slot(),a=(l)=>{let d=e.list[l],h=l===s,m=e.signature.includes(Cn[l])?A.signature:t.color?A.swatch:" ",p=i.has(l)?A.miss:e.tone&&e.changed(l)?A.on:" ",$=`${t.color?`${t.fg(d)}${m}${h?t.fg(o.foreground):bt} `:`${m} `}${nf(e.lch[l])}${p}`;if(!h)return at({kind:"slot",slot:l},` ${$}`);return at({kind:"slot",slot:l},t.color?`${t.bg(o.selection)}${t.fg(o.foreground)} ${$}${se}`:`›${$}`)},c=(l)=>l?t.color?`${t.fg(o.cursor)}${A.gutter}${bt} `:`${A.gutter} `:" ",u=[t.dim(Jt(r,"top",[[2," Base "]]))];for(let l=0;l<T.length;l++){let d=l===e.row,h=T[l].padEnd(10);u.push(De(t,`${at({kind:"slot",slot:l},`${c(d)}${d?t.bold(h):h}`)}${a(l)}`,r))}u.push(t.dim(Jt(r,"mid",[[2," ANSI "],[12," Normal 0–7 "],[29," Bright 8–15 "]])));for(let l=T.length;l<gr;l++){let d=l===e.row,h=mn[l-T.length].padEnd(10),m=at({kind:"slot",slot:l+(e.col===1?8:0)},`${c(d)}${d?t.bold(h):h}`);u.push(De(t,`${m}${a(l)}${a(l+8)}`,r))}u.push(t.dim(Jt(r,"bottom")));let f=wc(t,e,n-u.length,r);return[...u,...Array.from({length:Math.max(0,n-u.length-f.length)},()=>""),...f]}function $5(t,e,n){let r=re(e.list),i=[` ${t.dim("Seeds")}`];lo.forEach((o,s)=>{let a=s===e.field,c=e.seeds[o.key],u=Array.from({length:vg},(b,$)=>{let k=o.min+(o.max-o.min)*$/(vg-1);return sM[o.key](mi({...e.seeds,[o.key]:k}))}),f=bc(t,u,bo(c,o.min,o.max,vg),a),l=`${c.toFixed(o.digits)}${o.wraps?"°":""}`.padStart(6),d=sM[o.key](r),h=a?t.color?`${t.fg(r.cursor)}${A.gutter}${bt} `:`${A.gutter} `:" ",m=o.label.padEnd(17),p={kind:"field",field:s};i.push(`${at(p,`${h}${a?t.bold(m):m}`)}${at({kind:"seed",field:s},f)}${at(p,` ${l} ${t.color?`${t.fg(d)}${A.swatch}${bt} `:""}${t.dim(d)}`)}`)}),i.push("");for(let o of St("Seven seeds grow all twenty colors, each accent on the hue its ANSI role reads as — whatever the seeds, they pass the gate. enter moves on to tune each slot, and the seeds stay behind.",go-4))i.push(` ${t.dim(o)}`);return i.push(""),[...i,...wc(t,e,n-i.length,go)]}function lM(t,e,n,r,i,o){let s=Zt.indexOf(Ki(i)),a=Zt.map((f,l)=>at({kind:"scene",scene:l},l!==s?t.dim(f.name):qe(t,f.name))).join(" "),c=[It(a,t.dim("⇧←→"),n)],u=`${t.bg(e.background)}${t.fg(e.foreground)}`;for(let f of Ki(i).lines){let l=cs(f,n-2);if(!l)continue;if(c.length>=r)break;let d=t.color?l.map(([h,m])=>`${rf(t,e,m,LS(o,m))}${h}${me}${u}`).join(""):l.map(([h])=>h).join("");c.push(`${u} ${nt(d,n-2)} ${t.color?me:""}`)}return c}var k5=["Bk","Rd","Gr","Ye","Bl","Ma","Cy","Wh"];function aM(t,e,n,r,i,o,s){let a=(i-o)/(s-1),c=fM(e),u=re(n),f=(l)=>Math.min(s-1,Math.max(0,Math.round((i-r(xt(l)))/a)));return Array.from({length:s},(l,d)=>{let m=`${(d%2===0?(i-a*d).toFixed(i>=1?1:2).replace(/^0(?=\.\d\d)/,""):"").padStart(4)} ${t.dim(d%2===0?"┤":"│")}`;for(let p=0;p<8;p++){let b=[" "," "," "," "," "],$=u.ansi[p],k=u.ansi[p+8],v=f($)===d,E=f(k)===d,x=(R)=>{if(R===1&&v)return t.color?`${t.fg($)}${A.on}`:A.on;if(R===3&&E)return t.color?`${t.fg(k)}${A.off}`:A.off;return b[R]},M=[0,1,2,3,4].map(x).join("");m+=c.has(p)?t.color?`${t.bg(u.selection)}${M}${se}`:M:`${M}${t.color?bt:""}`}return m})}function fM(t){let e=t.mode==="tune"?t.scoped():[t.slot()];return new Set(e.filter((n)=>n>=T.length).map((n)=>(n-T.length)%8))}function y5(t,e){let n=fM(e);return` ${k5.map((r,i)=>n.has(i)?t.bold(` ${r} `):t.dim(` ${r} `)).join("")}`}function v5(t,e){let n=re(e),r=Array.from({length:40},(o,s)=>{let a=s*9+4.5,c=-1,u=999;for(let[f,l]of Object.entries(xe)){let d=Oe(a,l.center);if(d<=l.width&&d<u)u=d,c=Number(f)}return c<0?" ":t.color?`${t.fg(n.ansi[c])}─`:"─"}).join(""),i=(o,s)=>{let a=Array.from({length:40},()=>" ");for(let c of Object.keys(xe).map(Number)){let u=n.ansi[c+o],f=Math.min(39,Math.round(xt(u).h/9));a[f]=t.color?`${t.fg(u)}${s}${bt}`:s}return` ${a.join("")}`};return[`${t.bold("Hue")} ${t.dim("0° 90° 180° 270° 360°")}`,`${t.dim("bands")} ${r}${t.color?bt:""}`,i(0,A.on),i(8,A.off)]}function E5(t,e,n){let r=br(n,e.signature,e.waive),i=(a)=>Ge(T.length+a).name,o=(a)=>xt(n[T.length+a]).h.toFixed(0),s=[...qn(r).filter(({gap:a})=>a>25).map(({normal:a,gap:c})=>`${i(a)} ${o(a)}° → bright ${o(a+8)}° · ${c.toFixed(0)}° apart · ≤ 25°`),...Or(r).map(({slot:a,over:c})=>{let u=xe[wn(a)];return`${i(a)} ${o(a)}° · ${c.toFixed(0)}° outside ${u.name} ${u.center}±${u.width}°`}),...Dn(r).map(([a,c])=>`${i(a)} and ${i(c).toLowerCase()} read as one color`)];return s.length>0?s.map((a)=>`${t.bold(A.miss)} ${a}`):[t.dim(`${A.ok} Every accent keeps its role and its bright`)]}function cM(t,e,n,r,i){let o=e.shown(),s=Math.max(...o.slice(T.length).map((u)=>xt(u).c)),a=Math.max(0.2,Math.ceil(s/0.05)*0.05),c=[It(t.bold("Lightness"),t.dim("● normal ○ bright"),n),...aM(t,e,o,(u)=>u.l,1,0.3,8),y5(t,e)];if(i)c.push("",t.bold("Chroma"),...aM(t,e,o,(u)=>u.c,a,0,5),"",...v5(t,o));return[...c,...E5(t,e,o)].slice(0,r)}function S5(t,e,n){let r=(i,o)=>at({kind:"view",view:o},e.view!==o?t.dim(` ${i} `):qe(t,i));return It(`${r("Slot","slot")}${r("Relations","relations")}`,jt("g",`${t.bold("g")} ${t.dim("switch")}`),n)}function M5(t,e,n,r){let i=e.slot(),o=e.list[i],s=e.lch[i],a=e.start[i],{name:c,about:u}=Ge(i),f=e.signature.includes(Cn[i]),l=Math.max(8,Math.min(64,n-12));if(e.view==="relations"&&e.mode!=="tune")return[S5(t,e,n),"",...cM(t,e,n,r-2,!0)];let d=i>=T.length?t.dim("Uses underlined below"):f?t.dim("◆ signature"):"",h=[It(`${t.bold(c)} ${t.dim(u)}`,e.view==="relations"?"":d,n),""],m=t.color?`${t.fg(o)}${"█".repeat(8)}${bt} `:"",p=e.typing!==void 0?`${t.bold(`${e.typing}▏`)}`:void 0,[b,$,k]=st(o);if(h.push(`${m}${p??b5(t,s)}`),h.push(`${m}${t.dim(`${o} · rgb ${b} ${$} ${k}`)}`),e.view!=="relations"){let M=t.color?`${t.fg(a)}${A.swatch}${bt} `:"";h.push(`${m}${a!==o?t.dim(`was ${M}${g5(e.lchOf(a)).slice(6)} · ${a}`):t.dim("as it opened")}`)}h.push(""),h.push(...m5(t,e,s,l),Ql(t,e,l));let v=p5(t,e);if(v.length>0)h.push(...v);if(e.view==="relations")return h.push("",...cM(t,e,n,r-h.length-1,!1)),h;h.push("");for(let M of ef(e,i,s))St(M.text,n-2).forEach((R,F)=>{h.push(`${F===0?xu(t,M.ok):" "} ${M.ok===!1?R:t.dim(R)}`)});let E=tf(e,i);if(E)h.push(t.dim(` ${E}`));let x=r-h.length-1;if(x>=3)h.push("",...lM(t,re(e.shown()),n,x,e.scene,i));return h}function x5(t,e,n,r){return[It(`${t.bold("Sample")} ${t.dim("what the seeds grow")}`,"",n),"",...lM(t,re(e.list),n,r-2,e.scene,-1)]}var O5=[["Slots","↑↓ slot · ←→ normal or bright · home end · pgup the base colors · pgdn the ANSI ones · n N the next and last miss"],["Tune","enter or tab opens the picker over the list, under the slot · ↑↓ lightness · ←→ chroma · ⇧←→ hue by 5, , . by 1 · pgup pgdn lightness ×5 · tab ◐ contrast · home end the ends · 0-9 jump · enter keeps · esc undoes · a click outside it keeps"],["Contrast","◐ moves lightness until the ratio to the color it is read against changes · home the gate’s floor · 1-9 that ratio"],["Chroma","stops at the sRGB edge · what lightness or hue takes away comes back while you tune, where it fits again (○)"],["Scope","a while tuning: this, pair, normals, brights or accents — the slots in it move by the same step, each keeping its own color"],["Relations","g shows the lightness, chroma and hue of every ANSI color at once, and the relations the gate checks"],["Sample","⇧←→ another tab · the slot under the cursor is underlined where it is used · w dims the rest"],["Inspect","i, or a click on the sample, finds the slots a spot uses · ←→↑↓ move · enter goes to the slot · esc leaves"],["Link","l makes a bright follow its normal — tuning the normal moves it, tuning the bright alone unlinks it · = snaps it to its normal"],["Filter","m only the slots that changed · n and N walk the gate misses listed under the slots"],["Export","x copies the share code, an add command or the palette file · I takes colors from another palette or a share code"],["Type","# then #rrggbb, rgb(r g b) or oklch(l c h) — a paste works too"],["Slot","c copies · v pastes · r puts it back as it opened, R all of them · = the bright follows its normal · * marks it a signature color"],["Palette","f moves the colors the gate misses · o takes another palette’s colors"],["Gate","✗ marks every slot whose own checks miss, and each miss names its slots"],["History","u undo · ctrl+r redo"],["Pictures","p finds one on the boorus, tried on in these colors · b shows or hides it behind the editor · drop a picture on the window, or paste one, its path or its link · ctrl+v takes the clipboard’s"],["Compare","space shows the colors you started from, on the terminal too"],["Save","s saves · esc cancels, asking first when something changed"]];function I5(t,e,n){let r=[` ${t.bold("Help")}`,""];for(let[i,o]of O5.filter(([s])=>s!=="Pictures"||e.options.find))St(o,n-16).forEach((s,a)=>{r.push(` ${t.bold((a===0?i:"").padEnd(11))} ${s}`)});return r}function R5(t,e,n,r){let i=e.choices(),o=e.options.palettes?.length??0,s=e.filter?`${t.bold(e.filter)}▏`:t.dim("type to filter"),a=[It(` ${t.bold("Take colors from")} ${s}`,t.dim(`${i.length}/${o}`),n),""],c=r-2,u=Math.max(0,Math.min(e.pick-Math.floor(c/2),i.length-c)),f=Math.min(40,Math.max(12,...i.map((l)=>_(l.name))));if(i.slice(u,u+c).forEach((l,d)=>{let h=u+d===e.pick,m=l.colors,p=t.color?`${t.bg(m.background)} ${[...m.ansi].map((k)=>`${t.fg(k)}${A.swatch}`).join("")} ${t.fg(m.foreground)}Aa ${se}`:"",b=h?"▌ ":" ",$=l.name.padEnd(f);a.push(at({kind:"choice",index:u+d},`${b}${h?t.bold($):$} ${p}`))}),i.length===0)a.push(` ${t.dim(`No palettes match '${e.filter}'`)}`);return a}var P5=new Set(["enter","s","?","g","a","i"]);function uM(t,e,n){let r="EDIT",i="",o=[],s="";if(e.quitting)r="EDIT (QUIT)",i=e.added>0?`Discard changes and ${e.added} ${e.added===1?"picture":"pictures"}?`:"Discard changes?",o=[["y","discard"],["n","keep editing"]];else if(e.typing!==void 0)r="EDIT (TYPE)",i=t.dim("#rrggbb, rgb(r g b) or oklch(l c h)"),o=[["enter","set"],["ctrl+u","clear"]],s="esc back";else if(e.overlay==="keys")r="HELP",s="any key closes";else if(e.overlay==="open")r="EDIT (OPEN)",o=[["↑↓","palette"],["a-z","filter"],["enter","take its colors"]],s="esc close";else if(e.menu)r=e.menu==="export"?"EDIT (EXPORT)":"EDIT (IMPORT)",o=[["↑↓","item"],["enter","choose"]],s="esc close";else if(e.compare)r="EDIT (BEFORE)",i="The colors you started from",o=[["space","back to yours"]],s="esc back";else if(e.mode==="seeds")r="EDIT (SEEDS)",o=[["↑↓","seed"],["←→","step"],["⇧←→","×5"],["enter","tune the slots"],["o","open a palette"],["p","picture"],["?","keys"]],s="esc cancel";else if(e.mode==="tune")r="EDIT (TUNE)",o=[["↑↓","L"],["←→",e.channel===ne?"ratio":"C"],["⇧←→","H"],["tab","◐"],...e.slot()>=T.length?[["a","scope"]]:[],[e.channel===ne?"1-9":"0-9",e.channel===ne?"ratio":"jump"],["#","type"],["enter","keep"]],s="esc undo";else if(e.inspect)r="EDIT (INSPECT)",o=[["←→↑↓","spot"],["tab","pane"],["enter","its slot"],["i","leave"]],s="esc leave";else o=[["↑↓","slot"],["←→","normal or bright"],["enter","tune"],["i","inspect"],["l","link"],["m","changed"],["g",e.view==="slot"?"relations":"slot"],...e.misses().size>0?[["n","next miss"]]:[],["#","type"],["f","fix"],["p","picture"],["b","picture layer"],["x","export"],["u","undo"],["s","save"],["?","keys"]],s="esc cancel";if(!e.options.find)o=o.filter(([u])=>u!=="p"&&u!=="b");if(!e.options.exports||!e.roomy)o=o.filter(([u])=>u!=="x");if(!e.roomy)o=o.filter(([u])=>u!=="i"&&u!=="m");if(e.notice)i=t.warn(e.notice),o=[];let a=`${qe(t,r)}${t.color?" ":" "}`,c=s?jt(s.split(" ")[0],`${t.bold(s.split(" ")[0])} ${t.dim(s.split(" ").slice(1).join(" "))}`):"";for(;;){let u=[i,...o.map(([d,h])=>jt(d,`${t.bold(d)} ${t.dim(h)}`))].filter(Boolean),f=`${a}${u.join(" ")}`,l=-1;if(o.forEach(([d],h)=>{if(h>0&&!P5.has(d))l=h}),_(f)+_(s)+3<=n||l<0)return s?It(f,c,n):nt(f,n);o=o.filter((d,h)=>h!==l)}}function A5(t,e,n,r,i={}){let o=Me(r);if(e<iM||n<oM){let p=[o.bold("ttheme palette editor"),`Needs ${iM}×${oM} — now ${e}×${n}`,o.dim("esc cancels")];return{lines:Array.from({length:n},(b,$)=>nt(p[$]??"",e)),art:void 0}}if(t.viewport(e,n),!t.overlay&&t.mode!=="seeds"){let p=rM(t,e,n,r,i);if(p)return{lines:[...p.lines,uM(o,t,e)],art:p.art}}let s=t.failing().length,a=s===0?"✓ Passes the gate":`✗ ${s} ${s===1?"miss":"misses"} in the gate`,c=t.pictures>0?o.dim(`▣ ${t.pictures} ${t.pictures===1?"picture":"pictures"} `):"",u=t.resettable()?`${jt("R",o.dim("Reset"))} `:"",f=`${t.dirty()?`${o.warn(A.on)} unsaved `:""}${u}${c}${o.dim(a)}`,l=`${o.accent(A.current)} ${o.bold(t.options.title)} ${o.dim(`· ${t.options.name}`)}`,d=n-4,h;if(t.overlay==="keys")h=I5(o,t,e);else if(t.overlay==="open")h=R5(o,t,e,d);else{let p=e-go-2,b=t.mode==="seeds"?$5(o,t,d):w5(o,t,d),$=t.mode==="seeds"?x5(o,t,p,d):M5(o,t,p,d);h=Array.from({length:d},(k,v)=>`${nt(b[v]??"",go)}${o.dim("│")} ${nt($[v]??"",p)}`)}let m=[It(l,f,e),""];for(let p=0;p<d;p++)m.push(nt(h[p]??"",e));return m.push("",uM(o,t,e)),{lines:m,art:void 0}}var N5=new Set(["tab","a","#","l","enter","esc"]),T5=new Set(["picker","plane","bar","channel","format","scope","open","slot"]);function H5(t){if(!t)return!0;return t.kind==="key"?!N5.has(t.key):!T5.has(t.kind)}function F5(t,e,n){if(n.action==="wheel"){if(!n.sideways)t.scroll(n.wheel);return}if((n.action==="press"||n.action==="drag")&&n.button!=="left")return;if(n.action==="press"&&t.overlay==="keys"){t.press("esc");return}let r=e?.target;if(n.action==="press"&&t.mode==="tune"&&t.roomy&&!t.overlay&&H5(r))t.dismiss();if(!e||!r)return;let i=e.width>1?(e.exact.x-0.5)/(e.width-1):0;if(n.action==="release"){if(!e.inside)return;if(r.kind==="key")t.press(r.key);else if(r.kind==="entry")t.choose(r.index);else if(n.count===2&&r.kind==="slot"&&t.mode==="list")t.press("enter");else if(n.count===2&&r.kind==="choice"&&t.overlay==="open")t.press("enter");return}if(r.kind==="plane"){let o=ZS(r.row+e.exact.y,r.rows,e.exact.x,e.width,t.lch[t.slot()].h);t.plane(o.lightness,o.chroma)}else if(r.kind==="bar")t.slide(r.channel,i);else if(r.kind==="seed")t.sow(r.field,i);else if(n.action!=="press")return;else if(r.kind==="slot")t.select(r.slot);else if(r.kind==="open")t.openSlot(r.slot);else if(r.kind==="run")t.point(r.spot);else if(r.kind==="entry")t.entry=r.index;else if(r.kind==="format")t.format=r.format;else if(r.kind==="channel")t.grip(r.channel);else if(r.kind==="scope")t.scopeTo(r.scope);else if(r.kind==="choice"){if(t.overlay==="open")t.pick=r.index}else if(t.typing===void 0&&!t.overlay&&!t.quitting){if(r.kind==="field"&&t.mode==="seeds")t.field=r.field;else if(r.kind==="view"&&t.mode!=="seeds")t.view=r.view;else if(r.kind==="scene")t.scene=r.scene}}var L5=[El,Tn,li,dr];async function dM(t,e){let n=new sg(t),r=e.backdrop,i=e.layer,o=(a)=>n.typing===void 0&&Wl(a),s=e.hosted?{modes:[dr,...fi()],assume:[Tn,li],burst:o}:{modes:[...L5,...fi()],burst:o};return di(s,async(a)=>{let c=!1,u=!1,f=new Map,l=new vp,d=await a.ask(`${Zh(cn,"")}${fi().length>0?Kv:""}\x1B[c`,(E)=>{if(E.kind==="color"){f.set(E.code,E.value);return}return l.see(E)},1000);if(d?.cell)a.pixels(d.cell);let h=ay(f),m=h.map((E,x)=>E??n.start[x]),[p,b]=m;if(!h[3])m[3]=Ei(p,b,"selection");let $=new no({write:(E)=>a.write(E),view:()=>{if(c)return;let{lines:E,art:x}=A5(n,a.cols,a.rows,e.color,{behind:n.pic&&r?.laid===!0,art:i?.ready===!0,chrome:m});return{lines:E,after:()=>`${(n.pic?r?.draw(n.shown(),n.signature,n.waive,a.cols,a.rows,nM(a.cols,a.rows)):r?.clear())??""}${i?.draw(x)??""}`}}}),k=(E=!1)=>{if(E)$.soon();else $.request()},v=async(E)=>{let x=t.find;if(!x)return;c=!0,a.write(`${r?.clear()??""}${i?.clear()??""}`);try{n.found(await x(n.edited(),E))}catch(M){n.notice=M instanceof Error?M.message:String(M)}if(u)return;c=!1,r?.load(),$.reset(Ji),k()};if(a.write(Ji),a.onResize(()=>{r?.resized(),a.write(i?.clear()??""),$.reset(Ji),$.request()}),r)r.load(),r.ready=()=>$.request();if(r||i){let E=new Ya;a.ask(yl,(x)=>E.see(x),1000).then((x)=>{if(x)r?.measured(x),i?.measured(x);$.request()})}k();try{let{edited:E}=await a.loop((x)=>{if(c)return;if(x.kind==="paste")n.paste(x.text);else if(x.kind==="key")n.press(x.key);else if(x.kind==="mouse")F5(n,$.point(x),x);if(n.copied!==void 0)a.write(`\x1B]52;c;${Buffer.from(n.copied).toString("base64")}\x07`),n.copied=void 0;if(n.result)return{edited:n.result==="saved"?n.edited():void 0};let M=n.wants;if(M)n.wants=void 0,v(M.start);return},()=>{if(!c)k(!0)});return E}finally{u=!0,$.stop(),a.write(`${r?.close()??""}${i?.clear()??""}`)}})}import{spawn as Z5}from"node:child_process";import{createHash as OM}from"node:crypto";import{existsSync as xc,mkdirSync as V5,mkdtempSync as X5,readFileSync as Q5,rmSync as hf}from"node:fs";import{homedir as t4,tmpdir as e4}from"node:os";import{basename as n4,dirname as r4,join as _n}from"node:path";import{pathToFileURL as pM}from"node:url";import{existsSync as C5,readFileSync as j5,statSync as _5}from"node:fs";import{join as hM}from"node:path";function G5(t,e){try{return JSON.parse(j5(hM(rn(t),e),"utf8"))}catch{return{}}}function B5(t,e,n){L(hM(rn(t),e),`${JSON.stringify(n)}
|
|
720
|
-
`)}class Eg{caches=new Map;unsaved=new Set;owners=new Map;crediting=new Map;inflight=new Map;home;catalog;entry;signal;credited;constructor(t){this.home=t.home,this.catalog=t.catalog,this.entry=t.entry,this.signal=t.signal,this.credited=t.credited}matesOf(t,e){return this.owners.get(t.key)?.get(e)??[]}async transparent(t,e){let n=this.keep(t,"probes.json"),r=n[e.id];if(r!==void 0)return r;try{let i=await aa(t,e,this.signal),o=Ni(t,e),s=(i===void 0?await F0(o.site,o.url,this.signal):i)?.alpha===!0;return n[e.id]=s,this.unsaved.add(`${t.key}/probes.json`),s}catch{return!1}}save(){for(let t of this.unsaved){let[e,n]=t.split("/"),r=V.find((i)=>i.key===e);if(r)B5(r,n,this.keep(r,n))}this.unsaved.clear()}owned(t,e,n){this.keep(t,"owners.json")[e]=n,this.unsaved.add(`${t.key}/owners.json`)}credit(t,e){let{site:n,post:r}=t;if(!Qc(n,r))return Promise.resolve();let i=Pe(n,r.id),o=this.crediting.get(i);if(!o)o=this.credits(t,e).finally(()=>this.crediting.delete(i)),this.crediting.set(i,o);return o}async mateOwners(t){let e=this.owners.get(t.key);if(e)return e;let n=E$(this.home),r=this.keep(t,"owners.json"),i=this.catalog.palettes.flatMap((c)=>{let u=n.get(c.name);return c.group===this.entry.group&&c.name!==this.entry.name&&u?.site===t.key?[{name:c.name,id:u.id}]:[]}),o=await Promise.all(i.map(async(c)=>{let u=r[c.id];if(u!==void 0)return{...c,owner:u};try{return{...c,owner:(await _o(t,c.id,this.signal))?.owner??""}}catch{return}})),s=new Map;for(let c of o)if(c)r[c.id]=c.owner,s.set(c.name,c.owner);this.unsaved.add(`${t.key}/owners.json`);let a=R0(s);return this.owners.set(t.key,a),a}async cached(t,e,n,r){if(C5(e))return _5(e).size;let i=this.inflight.get(e);if(i)return i;let o=(async()=>{let s=await nu(t,n,this.signal,r);return L(e,s),s.length})();this.inflight.set(e,o);try{return await o}finally{this.inflight.delete(e)}}keep(t,e){let n=`${t.key}/${e}`,r=this.caches.get(n);if(!r)r=G5(t,e),this.caches.set(n,r);return r}async credits({site:t,post:e},n){let r=this.keep(t,"credits.json"),i=r[e.id];if(!i){try{i=await Xc(t,e.id,n)}catch{return}if(!i?.owner)return;r[e.id]=i,this.unsaved.add(`${t.key}/credits.json`)}sa(e,i),this.credited()}}import{rmSync as U5}from"node:fs";import{join as W5}from"node:path";var Ws=2147483645,Mc=2147483646,mM=-1073741827,K5=-1073741828,z5=16,q5=0.4,D5=3221225472,J5=256;function Y5(t){let e=/^(\d+) (\d+)$/.exec(t??"");return e&&(Number(e[1])>0||Number(e[2])>0)?{x:Number(e[1]),y:Number(e[2])}:void 0}var Sg=Y5(process.env.TTHEME_BG_MARGIN);class Mg{screen;gliding;sent=new Map;placed=new Map;covered="";viewed="";bands=Uu(process.env);files=Wu(process.env);moves=fy(process.env);layers=ls(process.env);wipes=dy(process.env);views=qi(process.env);bandFiles=new Map;nextBand=D5;view;grid;background;renders;scratch;signal;write;constructor(t){this.view=t.view,this.grid=t.grid,this.background=t.background,this.renders=t.renders,this.scratch=t.scratch,this.signal=t.signal,this.write=t.write,this.screen=new no({write:(e)=>this.write(e),view:()=>this.frame(),beat:()=>{this.view.beat++}})}draw(){if(!this.signal.aborted)this.screen.request()}soon(){if(!this.signal.aborted)this.screen.soon()}flush(){if(!this.signal.aborted)this.screen.now()}point(t){return this.screen.point(t)}drop(){this.screen.drop()}frame(){if(this.signal.aborted)return;let{cols:t,rows:e,cell:n}=this.grid(),r=_p(this.view,t,e);return this.view.loaderFrom=r.loader?this.view.loaderFrom??this.view.beat:void 0,{lines:r.lines,zones:r.zones,after:(i)=>this.images(r.images,i,n),...this.view.mode==="grid"&&this.view.editing!==void 0?{cursor:this.caret()}:{},ticking:r.tick}}images(t,e,n){let r="",i=new Set,o;for(let s of t){if(this.views&&s.id>=Hp){o=s;continue}let a=this.bands?this.banded(s):s;if(!a)continue;if(this.wipes&&[...e].some((u)=>u>=a.row&&u<a.row+a.rows))this.placed.delete(a.id);if(i.add(a.id),this.sent.get(a.id)!==a.path){let u=Hl(a,this.files);if(u===void 0)continue;r+=u,this.sent.set(a.id,a.path),this.placed.delete(a.id)}let c=`${a.row};${a.col};${a.cols};${a.rows};${a.crop};${a.z}`;if(this.placed.get(a.id)!==c){if(!this.moves&&this.placed.has(a.id))r+=Lp(a.id);r+=yE(a,n),this.placed.set(a.id,c)}}for(let s of this.sent.keys())if(!i.has(s))r+=ac(s),this.sent.delete(s),this.placed.delete(s);return r+(this.views?this.backdrop(o):this.cover())}glide(){if(this.bands)this.prebake();if(this.gliding)return;let{cols:t,rows:e}=this.grid(),n=hr(t,e).height,r=()=>{let i=this.view,o=i.top*vt.height,s=o-i.scroll;if(s===0||i.mode!=="grid"){i.scroll=o;let a=this.gliding!==void 0;if(this.gliding=void 0,a)this.draw();return}if(Math.abs(s)>2*n)i.scroll=o-Math.sign(s)*n,s=o-i.scroll;i.scroll+=Math.sign(s)*Math.max(1,Math.round(Math.abs(s)*q5)),this.draw(),this.gliding=setTimeout(r,z5)};r()}snap(){clearTimeout(this.gliding),this.gliding=void 0,this.view.scroll=this.view.top*vt.height}resized(){this.screen.reset()}stop(){this.screen.stop(),clearTimeout(this.gliding)}prebake(){let t=this.view,{cols:e,rows:n}=this.grid();for(let r of _p({...t,scroll:t.top*vt.height},e,n).images)if(r.crop!==void 0)this.band(r.path,r.crop,r.rows)}cover(){let{cols:t,rows:e}=this.grid(),n=`${t};${e}`;if(!this.layers||this.covered===n)return"";let r="";if(!this.covered){let i=Buffer.from(st(this.background)).toString("base64");if(r+=`\x1B_Ga=t,f=24,s=1,v=1,i=${Ws},q=2;${i}\x1B\\`,Sg)r+=`\x1B_Ga=t,f=32,s=1,v=1,i=${Mc},q=2;AAAAAA==\x1B\\\x1B[H\x1B_Ga=p,i=${Mc},p=${Mc},c=1,r=1,C=1,z=${K5},q=2\x1B\\`}else if(!this.moves)r+=Lp(Ws);if(this.covered=n,Sg){let{x:i,y:o}=Sg;return`${r}\x1B_Ga=p,i=${Ws},p=${Ws},P=${Mc},Q=${Mc},H=${-i},V=${-o},c=${t+2*i},r=${e+2*o},C=1,z=${mM},q=2\x1B\\`}return`${r}\x1B[H\x1B_Ga=p,i=${Ws},p=${Ws},c=${t},r=${e},C=1,z=${mM},q=2\x1B\\`}backdrop(t){let{cols:e,rows:n,cell:r}=this.grid(),i=e*r.w,o=n*r.h,s=t?`${this.background}|${t.path}|1|${i}|${o}|${i}|${o}|0|0|1`:`${this.background}||1|${i}|${o}|0|0|0|0|5`;if(s===this.viewed)return"";return this.viewed=s,Di(s)}caret(){return`\x1B[1;${Math.min(this.grid().cols,_(`⌕ ${this.view.editing??""}`)+1)}H`}banded(t){if(t.crop===void 0)return t;let e=this.band(t.path,t.crop,t.rows,!this.gliding);return e?.ready?{...t,id:e.id,path:e.path,crop:void 0}:void 0}band(t,e,n,r=!0){let i=`${t}|${e}|${n}`,o=this.bandFiles.get(i);if(o||!r)return o;let{cell:s}=this.grid(),a=this.nextBand++,c={id:a,path:W5(this.scratch,`band-${a}.png`),ready:!1};return this.bandFiles.set(i,c),this.renders.run({job:"band",from:t,to:c.path,y:e*s.h,height:n*s.h}).then(()=>{c.ready=!0,this.draw()}).catch(()=>{}),this.trimBands(),c}trimBands(){for(let[t,e]of this.bandFiles){if(this.bandFiles.size<=J5)return;if(e.ready&&!this.sent.has(e.id))this.bandFiles.delete(t),U5(e.path,{force:!0})}}}var ko=[{name:"TTHEME_FIND_RATING",label:"Rating",about:"The ratings to list, each site read in its own words — space ticks one, and one stays ticked",choices:Lo,multi:{read:Ai}},{name:"TTHEME_FIND_BLOCK",label:"Block",about:"Posts tagged with nudity or underwear are left out — space unticks one",choices:Pi,multi:{read:jo,none:"none"}},{name:"TTHEME_FIND_POSTS",label:"Posts",about:"Every post of the character, or only the transparent cutouts",choices:["all","cutouts"]},{name:"TTHEME_FIND_SOLO",label:"Solo",about:"When on, only the posts known to show the character alone — checked as posts arrive, so the counts below leave it out",choices:["on","off"]},{name:"TTHEME_FIND_ORDER",label:"Order",about:"How posts are ranked: fit, by how well each makes a backdrop; newest; or score",choices:["fit","newest","score"]},{name:"TTHEME_FIND_SETS",label:"Sets",about:"One picture posted over and over, or held by another site too: fold it into one tile, or show each",choices:["fold","show"]},..._s()?[{name:"TTHEME_FIND_REMOVE_BG",label:"Remove bg",about:"Cut the character out of an opaque picture you try on, with macOS Vision",choices:["on","off"]}]:[],{name:"TTHEME_FIND_MIN_SCORE",label:"Min score",about:"Posts scored at least this — danbooru, konachan and yande.re; zerochan keeps no score. ←→ steps, or type any number",choices:g0,entry:"number",advanced:!0},{name:"TTHEME_FIND_MIN_SIZE",label:"Min size",about:"The shorter side of a picture, in px — every site filters it. ←→ steps, or type any number",choices:b0,entry:"number",advanced:!0},{name:"TTHEME_FIND_SITES",label:"Sites",about:"The sites the all tab mixes — each keeps its own tab. Space ticks one, and one stays ticked",choices:V.map((t)=>t.name),multi:{read:ra},advanced:!0},{name:"TTHEME_FIND_HIDE",label:"Hide",about:"Comics, monochrome, sketches or chibi, told by tag in every site's spelling — checked as posts arrive",choices:xd,multi:{read:qc,none:"none"},advanced:!0},{name:"TTHEME_FIND_HIDE_TAGS",label:"Hide tags",about:"Posts with any of these tags are left out, spaced like cosplay multiple_girls — checked as posts arrive",choices:[],entry:"text",advanced:!0},{name:"TTHEME_FIND_PNG",label:"PNG only",about:"PNG originals only — danbooru counts it, the others are told by the file; zerochan only where danbooru holds it",choices:["off","on"],advanced:!0}];function gM(t,e){if(t.multi)return t.multi.read(e).join(" ")||t.multi.none;if(t.entry==="number")return/^\d+$/.test(e??"")&&Number(e)>0?String(Number(e)):"off";if(t.entry==="text")return ia(e).join(" ");return t.choices.find((n)=>n===e)??t.choices[0]}var i4=["fit","newest","score"];function xg(t){return i4.find((e)=>e===t)??"fit"}var o4={left:-1,right:1,"shift-left":-10,"shift-right":10};function bM(t){if(process.env.SSH_CONNECTION||!/^(?:https?|file):/i.test(t))return;try{let e=Z5(process.platform==="darwin"?"open":"xdg-open",[t],{stdio:"ignore",detached:!0});e.on("error",()=>{}),e.unref()}catch{}}function s4(t,e,n){if(e<0){if(t!=="fill")return Math.max(pf,t+e);if(!n)return t;return Math.max(pf,Math.max(100,n)+e+1)}return t==="fill"||t+e>n?"fill":t+e}function IM(t,e){return t.size===e.size&&t.at===e.at&&t.opacity===e.opacity}function a4(t,e){if(IM(t,e))return;return{...t.size!=="fill"?{size:t.size}:{},...t.at!==e.at?{position:qt[t.at-1]}:{},...t.opacity!==e.opacity?{opacity:t.opacity}:{}}}function wM(t,e){let n=X(t);return ge(t,e).flatMap((r,i)=>{let[,o,s]=/^([a-z.]+)_(\d+)$/.exec(r.key)??[],a=[...V,mr].find((c)=>c.key===o);if(!a||!s)return[];return[{key:r.key,id:Number(s),ansi:a.ansi,...a===mr?{}:{page:a.pageUrl(Number(s))},up:i===0,from:_n(n,r.original??r.fill)}]})}function c4(t){return t.length>=2&&!/^\d+$/.test(t)&&!t.includes("://")&&!/^[\w.]+:\d+$/.test(t)}var $M=12,u4=4,l4=150,f4=300,kM=12,d4=2,h4=150,m4="\x1B[?5522$p\x1B]72;t=q\x1B\\\x1B[c",p4=4000,g4=8000,yM=/\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i,b4=process.platform==="win32"?"alt+v":"ctrl+v",vM=process.platform==="darwin"?"ctrl+shift+cmd+4 copies a screenshot":"copy a picture first",w4=1280,$4=16,k4=qt.indexOf("top-right")+1,pf=20,EM=2,SM=3,y4=/[\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,v4=8,E4=9;function mf(t,e){return{key:t,groups:[],sources:[],queue:[],rounds:0,roundOf:new Map,last:new Map,kin:new Map,kindred:new Map,shapes:[],seen:new Set,same:new Map,checked:0,total:0,focus:0,top:0,searching:e,stage:"fetch",arrived:new Set}}function Oc(t){if(!(t instanceof Error))return String(t);if(t instanceof AggregateError&&t.errors[0])return Oc(t.errors[0]);if(t.cause)return Oc(t.cause);let e=t.code;if(typeof e==="string")return e;let n=(t.message||t.name).split(".")[0]??"";return n.length>56?`${n.slice(0,55)}…`:n}function Og(t,e){return`${t}: ${Oc(e)}`}function MM(t){return t.width*t.height}function xM(t,e){return`${t}-${OM("sha1").update(e).digest("hex").slice(0,8)}`}class Ig{view;tone;session=new AbortController;cell={w:0,h:0};cols=process.stdout.columns||80;rows=process.stdout.rows||24;gen=0;pumping=0;boards=new Map;board;posts=new Map;thumbPath=new Map;looking=new Map;looked=new Map;matched=new Map;aheading=!1;pages=new Map;tab=0;values=new Map(ko.map((t)=>[t.name,gM(t,process.env[t.name])]));direction=1;prefetching=0;related=new Map;pool=[];relating;thumbQueue=[];heldFiles=new Map;heldAsked=new Set;thumbing=0;clarity=new Map;tunedFiles=[];presenting=!1;again=!1;renders=new pc;showing;thumbless=new Set;current;fetch;settle;suggestTimer;suggesting;countTimer;counting;terminal;grabber=new Yp((t)=>this.write(t),(t)=>void this.got(t));noticeTimer;peekTimer;peeked;attaching;done;scratch=X5(_n(e4(),"ttheme-find-"));home;catalog;entry;tagged;blurring;start;paint;kept;constructor(t,e,n,r,i){this.start=i,this.home=t,this.catalog=e,this.entry=n,this.tagged=new Set(e.palettes.flatMap((s)=>s.booru?[s.booru]:[])),this.tone=Mn(n,n.signatureSlots),this.blurring=ti(t);let o={size:"fill",at:k4,opacity:this.tone.opacity};this.view={palette:n.name,tag:r,site:this.tabName,siteAnsi:this.tabAnsi,nextSite:this.nextTabName,preset:this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:xg(this.setting("TTHEME_FIND_ORDER")),solo:this.setting("TTHEME_FIND_SOLO")==="on",rating:Ai(this.setting("TTHEME_FIND_RATING")),block:jo(this.setting("TTHEME_FIND_BLOCK")),sets:this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",narrow:this.narrowed(),enabled:ra(this.setting("TTHEME_FIND_SITES")),hide:qc(this.setting("TTHEME_FIND_HIDE")),hideTags:ia(this.setting("TTHEME_FIND_HIDE_TAGS")),advanced:!1,settings:ko.map((s)=>({label:s.label,choices:[...s.choices],value:this.setting(s.name),default:gM(s,Pa(s.name)),multi:s.multi&&{none:s.multi.none},about:s.about,entry:s.entry,advanced:s.advanced,cursor:0})),colors:{cursor:n.cursor,selection:n.selection,background:n.background,foreground:n.foreground,ansi:n.ansi},tiles:[],installed:[],held:wM(t,n.name),checked:0,total:0,searching:r!=="",stage:"fetch",sites:[],focus:0,top:0,scroll:0,beat:0,mode:"grid",help:!1,scene:Math.max(0,Zt.findIndex((s)=>s.name.toLowerCase()===process.env.TTHEME_SCENE)),details:!1,tune:{...o},untuned:o,coloring:qu(t),editing:r===""?"":void 0,chips:[]},this.paint=new Mg({view:this.view,grid:()=>({cols:this.cols,rows:this.rows,cell:this.cell}),background:n.background,renders:this.renders,scratch:this.scratch,signal:this.signal,write:(s)=>this.write(s)}),this.kept=new Eg({home:t,catalog:e,entry:n,signal:this.signal,credited:()=>{this.show(),this.inform(),this.paint.draw()}}),this.pool=this.selected(this.view),this.syncChips(),this.board=mf(this.boardKey,r!==""),this.boards.set(this.board.key,this.board)}get signal(){return this.session.signal}get site(){return this.tab===0?void 0:V[this.tab-1]}get sites(){return this.site?[this.site]:V.filter((t)=>this.view.enabled.includes(t.name))}get tabName(){return this.site?.name??"all"}get tabAnsi(){return this.site?.ansi??u4}get nextTabName(){let t=(this.tab+1)%(V.length+1);return t===0?"all":V[t-1].name}frame(){return{w:this.cols*(this.cell.w||10),h:this.rows*(this.cell.h||20)}}setting(t){return this.values.get(t)}narrowed(){return Id(this.setting("TTHEME_FIND_MIN_SCORE"),this.setting("TTHEME_FIND_MIN_SIZE"),this.setting("TTHEME_FIND_PNG"))}get boardKey(){return`${this.site?.key??"all"}|${this.view.preset}|${this.view.order}`}origPath(t,e,n){return _n(rn(t),"orig",`${e}.${n}`)}previewPath(t){let{url:e}=Jc(t.site,t.post);return _n(rn(t.site),"thumb",`${xM(t.post.id,e)}.${Lr(e)}`)}tileOf(t,e){let{site:n,post:r}=t,i=Pe(n,r.id),o=En(r)??r;return{id:r.id,key:i,site:n.name,siteAnsi:n.ansi,width:o.width,height:o.height,reduced:o!==r,page:n===mr?"":n.pageUrl(r.id),artist:n===mr?zE(r.source):r.named.artist[0]??"",score:r.score,variants:e,mates:this.kept.matesOf(n,r.owner),thumb:this.thumbPath.get(i),missing:this.thumbless.has(i)}}show(){let t=this.view,e=this.board;if(t.tiles=e.groups.flatMap((n)=>n.open?n.posts.map((r)=>this.tileOf(r,0)):[this.tileOf(n.posts[0],n.posts.length)]),t.checked=e.checked,t.total=e.total,t.searching=e.searching,this.stageOf(e),t.note=e.note,t.focus=Math.max(0,Math.min(e.focus,t.tiles.length-1)),t.top=e.top,this.showing!==e)this.showing=e,this.paint.snap()}stageOf(t){let e=this.view;e.stage=t.stage,e.ranking=t.ranking,e.sites=this.sites.map((n)=>({name:n.name,arrived:t.arrived.has(n.name)}))}syncSite(){let t=this.view;t.site=this.tabName,t.siteAnsi=this.tabAnsi,t.nextSite=this.nextTabName}run(){let t=(e)=>this.view.editing===void 0&&Wl(e);return di({modes:[dr,...fi()],assume:[Tn,li],burst:t},async(e)=>{this.terminal=e,e.onResize(this.onResize),e.listen((i)=>{for(let o of i)this.inbound(o);this.paint.soon()}),e.write(Ji);let n=new Promise((i)=>{this.done=i}),r=setInterval(this.onClock,250);setTimeout(pu,0);try{let i=new Ya,o=await e.ask(yl,(s)=>i.see(s),1000);if(o){if(this.cell=o,this.holdThumbs(),this.view.tag)this.search(),this.relate(this.view.tag)}else this.view.searching=!1,this.view.error="This terminal does not report its cell size — find needs kitty graphics";if(!process.env.TMUX)await e.ask(m4,(s)=>s.kind==="attributes"?!0:void 0,500,!1);if(this.grabber.start(),e.hold(Xv),this.start&&"paste"in this.start)this.pasted(this.start.paste);else if(this.start)this.fromClipboard();else this.peek();return this.paint.draw(),await e.until(n)}finally{this.session.abort(),this.grabber.stop(),this.attaching?.abort(),clearTimeout(this.noticeTimer),clearTimeout(this.peekTimer),this.fetch?.abort(),clearTimeout(this.settle),this.quietSuggest(),this.quietCount(),clearInterval(r),this.paint.stop(),e.write(`\x1B_Ga=d,d=A,q=2\x1B\\${Ji}`),this.kept.save(),this.renders.close(),hf(this.scratch,{recursive:!0,force:!0}),P0()}})}write(t){this.terminal?.write(t)}get saved(){return this.view.saved?.text}get installs(){return this.view.installed.length}finish(t){this.done?.(t===2&&this.saved?0:t)}inbound(t){if(t.kind==="key")this.key(t.key);else if(t.kind==="mouse")this.pointer(t);else if(t.kind==="paste")this.pasted(t.text);else if(t.kind==="mode"){if(t.mode===5522)this.grabber.clipboard=t.value!==0&&t.value!==4}else if(t.kind==="osc")if(t.code==="72"&&t.meta.t==="q")this.grabber.drops=!0;else this.grabber.take(t)}pasted(t){let e=this.view;if(e.editing!==void 0&&t.trim()!==""&&!this.picture(t)){e.editing+=t.replace(/[\r\n]+/g," "),this.suggest(),this.paint.draw();return}if(e.installing!==void 0||e.panel!==void 0||e.help)return;if(t.trim()===""){this.fromClipboard();return}this.attach(t)}picture(t){let e=t.trim();if(/^https?:\/\/\S+$/i.test(e))return!Dc(e,this.site??V[0]);return Ls(e).length>0}async got(t){if(t.kind==="error"){this.notice(t.message);return}if(t.kind==="text"){if(t.text.trim()===""){this.notice(`No picture on the clipboard — ${vM}`);return}this.pasted(t.text);return}await this.bring(()=>Bl(t.bytes,t.source))}notice(t,e=p4){let n=this.view;n.error=t,clearTimeout(this.noticeTimer),this.noticeTimer=setTimeout(()=>{if(n.error===t)n.error=void 0,this.paint.draw()},e),this.paint.draw()}async peek(){let t=this.view,e;try{e=await ZE()}catch{return}if(!e||e.stamp===this.peeked)return;if(this.peeked=e.stamp,!e.picture||t.installing!==void 0)return;t.hint=`Picture on the clipboard · ${b4} uses it`,clearTimeout(this.peekTimer),this.peekTimer=setTimeout(()=>{t.hint=void 0,this.paint.draw()},g4),this.paint.draw()}async fromClipboard(){let t=this.view;if(Jp()){if(this.grabber.clipboard){this.grabber.ask();return}this.notice("Over SSH the clipboard is not here — drop the file");return}let e;try{e=await YE(_n(this.scratch,`clipboard-${Date.now()}.png`))}catch(r){this.notice(`Could not read the clipboard: ${Oc(r)}`);return}if(clearTimeout(this.peekTimer),t.hint=void 0,"image"in e){await this.bring(async(r)=>({...await Dp(e.image,r),source:"clipboard"}));return}let n=e.text.trim();if(!n){this.notice(`No picture on the clipboard — ${vM}`);return}if(this.picture(n)){await this.attach(n);return}if(t.editing===void 0)t.editing="";this.pasted(n)}async attach(t){let e=t.trim();if(/^https?:\/\//i.test(e)){let i=Dc(e,this.site??V[0]);if(i){await this.jump(i.site,i.id);return}}let[n,...r]=Ls(e).sort((i,o)=>Number(!yM.test(i))-Number(!yM.test(o)));if(!n){this.notice("Nothing to use in that — drop a picture, or paste one or its link");return}await this.bring((i)=>Dp(n,i),r.length)}async bring(t,e=0){let n=this.view;this.attaching?.abort();let r=new AbortController;this.attaching=r,n.error=void 0,n.saved=void 0,n.note="Reading the picture…",this.paint.draw();let i;try{i=await t(AbortSignal.any([r.signal,this.signal]))}catch(d){if(!r.signal.aborted)n.note=void 0,this.notice(Oc(d),8000);return}if(r.signal.aborted)return;n.note=e>0?`The first picture of ${e+1} — drop one at a time to try the others`:void 0,this.quietSuggest(),n.editing=void 0,n.suggest=void 0,n.pick=void 0;let o=DE(i.bytes);qE(o,i.source);let s=this.origPath(mr,o,i.ext);L(s,i.bytes);let a=pM(s).href,c={id:o,file:a,width:i.width,height:i.height,ext:i.ext,preview:a,owner:"",score:0,rating:"s",md5:OM("md5").update(i.bytes).digest("hex"),source:i.source,tags:[],named:{artist:[],character:[],copyright:[]},solo:void 0,family:0,smaller:[]},u={site:mr,post:c},f=this.previewPath(u);L(f,i.bytes),++this.gen,this.current=void 0,n.shown=void 0;let l=mf(`local|post:${o}`,!1);this.board=l,this.boards.set(l.key,l),this.single(l,u)}single(t,e){t.searching=!1,this.posts.set(Pe(e.site,e.post.id),e),t.groups=[{posts:[e],open:!1}],t.checked=1,t.total=1,this.thumbQueue.push(e),this.thumbs(),this.view.mode="try",this.show(),this.select(),this.paint.draw()}onClock=()=>{let t=this.sites.reduce((r,i)=>Vn(i)>Vn(r)?i:r),e=Math.ceil((Vn(t)-Date.now())/1000),n=e>0?e:void 0;if(n!==this.view.waiting)this.view.waiting=n,this.view.slow=t.name,this.paint.draw()};onResize=()=>{if(this.cols=process.stdout.columns||this.cols,this.rows=process.stdout.rows||this.rows,this.paint.resized(),this.holdThumbs(),this.scroll(),this.paint.snap(),this.view.mode==="try"&&this.current)this.reveal();this.pump(),this.paint.draw()};key(t){let e=this.view;if(t==="ctrl-c"){this.finish(2);return}if(e.installing!==void 0)return;if(t==="focus-in"){this.peek();return}if(t==="focus-out")return;if((t==="ctrl-v"||t==="alt-v")&&e.panel===void 0){this.fromClipboard();return}if(e.editing!==void 0){this.editKey(t);return}if(e.panel!==void 0){this.panelKey(t);return}if(e.help){if(t==="?"||t==="esc")e.help=!1,this.paint.draw();return}if(this.cols<co.cols||this.rows<co.rows){if(t==="esc")this.finish(2);return}if(t==="?"){e.help=!0,this.paint.draw();return}if(e.mode==="try"){this.tryKey(t);return}this.gridKey(t)}pointer(t){let e=this.view,n=this.paint.point(t),r=n?.target;if(e.installing!==void 0)return;if(t.action==="wheel"){if(!t.sideways)this.wheel(t.wheel);return}if((t.action==="press"||t.action==="drag")&&t.button!=="left")return;if(r?.kind==="track"&&n&&t.action!=="release")this.slide(r.field,n);else if(t.action==="press")this.pressed(r);else if(t.action==="release"&&n?.inside)this.released(r,t)}pressed(t){let e=this.view;if(e.help)this.paint.drop(),this.key("esc");else if(e.editing!==void 0||t===void 0)return;else if(e.panel!==void 0){if(t.kind==="setting"&&t.index<e.settings.length&&e.typing===void 0)e.panel=t.index,this.paint.draw()}else if(e.mode==="try")this.tryPoint(t);else if(t.kind==="tile")this.focus(t.index);else if(t.kind==="query")this.gridKey("/");else if(t.kind==="site")this.tab=t.tab,this.syncSite(),this.turn()}released(t,e){let n=this.view;if(t?.kind==="key")this.key(t.key);else if(t?.kind==="link"){if(!e.shift&&!e.alt&&!e.ctrl)bM(t.url)}else if(n.editing!==void 0){if(t?.kind==="suggest")n.pick=t.index,this.editKey("enter")}else if(n.panel!==void 0)this.panelPoint(t);else if(n.mode==="try"){if(t?.kind==="place"&&n.tuning)this.tuneKey(String(t.at))}else if(t?.kind==="tile"&&e.count===2)this.gridKey("enter");else if(t?.kind==="chip")this.toggle(t.index)}wheel(t){let e=this.view;if(e.help)return;if(e.editing!==void 0){if(e.suggest?.length)this.editKey(t<0?"up":"down")}else if(e.panel!==void 0){if(e.typing===void 0)this.panelKey(t<0?"up":"down")}else if(e.tuning)this.tuneKey(t<0?"up":"down");else if(e.mode==="try")this.tryKey(t<0?"left":"right");else this.focus(e.focus+t*hr(this.cols,this.rows).perRow)}panelPoint(t){let e=this.view;if(t?.kind!=="setting"&&t?.kind!=="choice")return;let n=e.settings[t.index];if(e.typing!==void 0){let r=e.settings[e.panel??0];if(r&&(t.index!==e.panel||t.kind==="setting"))this.typeKey(r,"enter");else return}if(t.kind==="setting"&&t.index===e.settings.length){e.panel=t.index,this.panelKey("enter");return}if(e.panel=t.index,t.kind==="choice"&&n){if(n.entry==="text"||t.choice===void 0){this.panelKey("enter");return}if(n.multi){n.cursor=Math.max(0,n.choices.indexOf(t.choice)),this.panelKey(" ");return}if(n.value!==t.choice)n.value=t.choice,this.recount()}this.paint.draw()}tryPoint(t){let e=this.view;if(t.kind==="scene")e.scene=t.scene,e.details=!1,this.paint.draw();else if(e.tuning&&t.kind==="field")e.tuning.field=t.field,this.paint.draw()}slide(t,e){let n=this.view,r=n.tuning;if(!r)return;let i=Math.min(1,Math.max(0,e.width>1?e.x/(e.width-1):0));if(r.field=t,t===0){let o=Math.max(100,r.fill),s=pf+Math.round(i*(o-pf+1));n.tune.size=i===1||r.fill>0&&s>=r.fill?"fill":Math.min(o,s)}else n.tune.opacity=Math.round(i*100)/100;this.retune()}gridKey(t){let e=this.view,{perRow:n,rowsVis:r}=hr(this.cols,this.rows),o={left:-1,right:1,up:-n,down:n,k:-n,j:n,pgup:-n*r,pgdn:n*r,home:-e.focus,end:e.tiles.length}[t];if(o!==void 0){this.focus(e.focus+o);return}if(/^[1-9]$/.test(t)){this.toggle(Number(t)-1);return}if(t==="enter"&&e.tiles[e.focus]){e.mode="try",e.error=void 0,this.select();return}if(t==="v"){this.fromClipboard();return}if(t==="c"){e.preset=e.preset==="cutouts"?"all":"cutouts",this.turn();return}if(t==="tab"||t==="shift-tab"){let s=V.length+1;this.tab=(this.tab+(t==="tab"?1:s-1))%s,this.syncSite(),this.turn();return}if(t==="/"){e.editing="",this.paint.draw();return}if(t===" "){this.unfold();return}if(t==="o"){this.openPage();return}if(t==="s"){e.panel=0,e.advanced=!1,this.recount(),this.paint.draw();return}if(t==="esc")this.finish(2)}panelKey(t){let e=this.view,n=e.panel??0,r=e.settings[n];if(e.typing!==void 0&&r){this.typeKey(r,t);return}let i=sc(e);if(t==="up"||t==="down"){let o=i.indexOf(n)+(t==="up"?-1:1);e.panel=i[(o+i.length)%i.length]??n,this.paint.draw();return}if(t==="a"||t==="enter"&&n===e.settings.length){e.advanced=!e.advanced,e.panel=sc(e)[0]??0,this.paint.draw();return}if(r?.entry&&(t==="enter"||r.entry==="number"&&/^[0-9]$/.test(t))){e.typing=t==="enter"?r.entry==="text"?r.value:"":t,this.paint.draw();return}if((t==="left"||t==="right")&&r&&r.entry!=="text"){let o=t==="left"?-1:1;if(r.multi)r.cursor=(r.cursor+o+r.choices.length)%r.choices.length;else r.value=xE(r.choices,r.value,o),this.recount();this.paint.draw();return}if(t===" "&&r?.multi){let o=r.value.split(" "),s=r.choices.filter((c,u)=>u===r.cursor?!o.includes(c):o.includes(c)),a=r.multi.none;if(s.length>0||a!==void 0)r.value=s.length>0?s.join(" "):a,this.recount(),this.paint.draw();return}if(t==="esc"){e.settings.forEach((o,s)=>{o.value=this.setting(ko[s]?.name??"")}),e.panel=void 0,e.advanced=!1,this.quietCount(),this.paint.draw();return}if(t==="enter"||t==="s"||t==="alt-c")e.panel=void 0,e.advanced=!1,this.quietCount(),this.adopt()}typeKey(t,e){let n=this.view,r=n.typing??"";if(e==="esc"){n.typing=void 0,this.paint.draw();return}if(e==="enter"||e==="up"||e==="down"){if(t.value=t.entry==="number"?Number(r)>0?String(Number(r)):"off":ia(r).join(" "),n.typing=void 0,this.recount(),e==="enter"){this.paint.draw();return}this.panelKey(e);return}let i=oo(r,e,(o)=>t.entry==="number"?/^[0-9]$/.test(o)&&r.length<jp:/^[\x20-\x7e]$/.test(o));if(i!==void 0)n.typing=i,this.paint.draw()}quietCount(){clearTimeout(this.countTimer),this.counting?.abort(),this.counting=void 0}recount(){if(this.quietCount(),this.view.counts=void 0,!this.view.tag)return;let t=new AbortController;this.counting=t,this.countTimer=setTimeout(()=>void this.countPending(t),f4)}pending(){let t=(e)=>this.view.settings[ko.findIndex((n)=>n.name===e)]?.value??this.setting(e);return{tag:this.view.tag,chosen:this.view.chosen,preset:t("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:xg(t("TTHEME_FIND_ORDER")),rating:Ai(t("TTHEME_FIND_RATING")),narrow:Id(t("TTHEME_FIND_MIN_SCORE"),t("TTHEME_FIND_MIN_SIZE"),t("TTHEME_FIND_PNG")),enabled:ra(t("TTHEME_FIND_SITES"))}}async countPending(t){let e=this.pending(),n=this.site?[this.site]:V.filter((o)=>e.enabled.includes(o.name)),r=AbortSignal.any([this.signal,t.signal]),i=await Promise.all(n.map(async(o)=>{let s=this.query(o,e);if(!s)return{site:o.name,count:0};if(o.counts&&!o.counts(s.tags))return{site:o.name};try{let a=await Nd(o,s.tags,r);return{site:o.name,...Number.isFinite(a)?{count:a}:{}}}catch{return{site:o.name}}}));if(this.counting===t&&this.view.panel!==void 0)this.view.counts=i,this.paint.draw()}adopt(){let t=this.view,e=ko.map((r)=>this.setting(r.name));t.settings.forEach((r,i)=>{let o=ko[i];if(o)this.values.set(o.name,r.value)});let n=ko.filter((r,i)=>this.setting(r.name)!==e[i]);if(n.length===0){this.paint.draw();return}this.save(n),t.rating=Ai(this.setting("TTHEME_FIND_RATING")),t.block=jo(this.setting("TTHEME_FIND_BLOCK")),t.sets=this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",t.preset=this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",t.order=xg(this.setting("TTHEME_FIND_ORDER")),t.solo=this.setting("TTHEME_FIND_SOLO")==="on",t.narrow=this.narrowed(),t.enabled=ra(this.setting("TTHEME_FIND_SITES")),t.hide=qc(this.setting("TTHEME_FIND_HIDE")),t.hideTags=ia(this.setting("TTHEME_FIND_HIDE_TAGS")),this.boards.clear(),this.current=void 0,t.shown=void 0,t.mode="grid",this.search()}save(t){this.store(t.map((e)=>[e.name,this.setting(e.name)]))}store(t){let e=_n(this.home,"ttheme","config.zsh");try{let n=xc(e)?Q5(e,"utf8"):"";return L(e,t.reduce((r,[i,o])=>Du(r,i,o),n)),!0}catch(n){return this.view.error=n instanceof Error?n.message:String(n),!1}}editKey(t){let e=this.view,n=e.editing??"",r=e.suggest??[];if((t==="up"||t==="down")&&r.length>0){let s=((e.pick??r.length)+(t==="down"?1:r.length))%(r.length+1);e.pick=s===r.length?void 0:s,this.paint.draw();return}if(t==="esc"||t==="enter")this.quietSuggest();if(t==="esc"){if(e.editing=void 0,e.tag===""){this.finish(2);return}this.paint.draw();return}if(t==="enter"){let o=e.pick===void 0?void 0:r[e.pick],s=o?o.whole?o.value:n.replace(/\S*$/,o.value):n;if(e.editing=void 0,e.suggest=void 0,e.pick=void 0,s.trim()){this.commit(s.trim());return}if(e.tag===""){this.finish(2);return}this.paint.draw();return}let i=oo(n,t);if(i!==void 0)e.editing=i,this.suggest(),this.paint.draw()}quietSuggest(){clearTimeout(this.suggestTimer),this.suggesting?.abort(),this.suggesting=void 0}suggest(){this.quietSuggest();let t=this.view;t.pick=void 0;let e=t.editing??"",n=/\S*$/.exec(e)?.[0]??"",r=c4(n),i=_$(e,SM,this.tagged).map((c)=>({value:c.tag,count:0,alias:c.name,whole:!0}));if(!r&&i.length===0){t.suggest=void 0;return}let o=r?yk(this.catalog.palettes,this.entry,n).map((c)=>({value:c.booru,count:0,palette:c.name})):[],s=[...new Map([...o.slice(0,SM),...i].map((c)=>[c.value,c])).values()];if(t.suggest=s.length>0?s:void 0,i.length>0&&y4.test(e))t.pick=s.findIndex((c)=>("whole"in c));if(!r)return;let a=new AbortController;this.suggesting=a,this.suggestTimer=setTimeout(async()=>{try{let c=await N0(n,AbortSignal.any([this.signal,a.signal]));if(this.suggesting===a&&t.editing!==void 0){let u=new Map(c.map((l)=>[l.value,l.count])),f=new Set(s.map((l)=>l.value));t.suggest=[...s.map((l)=>({...l,count:u.get(l.value)??0})),...c.filter((l)=>!f.has(l.value))].slice(0,v4),t.pick=t.pick!==void 0&&t.pick<s.length?t.pick:void 0,this.paint.draw()}}catch{}},l4)}async commit(t){let e=Dc(t,this.site??V[0]);if(e){await this.jump(e.site,e.id);return}if(this.picture(t)){await this.attach(t);return}this.view.tag=t,this.view.chosen=void 0,this.relate(t),this.boards.clear(),await this.search()}async jump(t,e){let n=++this.gen;this.tab=V.indexOf(t)+1,this.syncSite(),this.current=void 0,this.view.shown=void 0,this.view.error=void 0;let r=mf(`${t.key}|post:${e}`,!0);this.board=r,this.boards.set(r.key,r),this.show(),this.paint.draw();try{let i=await _o(t,e,this.signal);if(n!==this.gen)return;if(!i){r.searching=!1,r.error=`${t.name} has no post ${e}`,this.view.error=r.error,this.show(),this.paint.draw();return}this.single(r,{site:t,post:i})}catch(i){this.fail(n,i,t)}}async turn(){this.fetch?.abort(),this.current=void 0,this.view.shown=void 0;let t=this.boards.get(this.boardKey);if(!t){await this.search();return}this.gen++,this.board=t,this.view.error=t.error,this.show(),this.paint.draw(),await this.pump()}unfold(){let t=this.view,e=0;for(let n of this.board.groups){let r=n.open?n.posts.length:1;if(t.focus<e+r){if(n.posts.length<2)return;n.open=!n.open,this.board.focus=e;for(let i of n.posts)if(!this.thumbPath.has(Pe(i.site,i.post.id)))this.thumbQueue.push(i);this.thumbs(),this.show(),this.scroll(),this.paint.glide(),this.paint.draw();return}e+=r}}openPage(){let t=this.view.tiles[this.view.focus],e=t&&this.posts.get(t.key);if(e)bM(e.site.pageUrl(e.post.id))}tryKey(t){let e=this.view;if(e.tuning){this.tuneKey(t);return}if(t==="left"||t==="right"){this.direction=t==="left"?-1:1,this.focus(e.focus+this.direction);return}if(t==="shift-left"||t==="shift-right"){e.scene+=t==="shift-left"?-1:1,e.details=!1,this.paint.draw();return}if(t==="i"){e.details=!e.details,this.inform(),this.paint.draw();return}if(t==="t"){e.tuning={field:0,held:{...e.tune},fill:this.current?.fill??0,coloring:e.coloring},this.paint.draw();return}if(t==="c"){this.recolor();return}if(t==="o"){this.openPage();return}if(t==="x"){this.swap();return}if(t==="v"){this.fromClipboard();return}if(t==="enter"){this.install();return}if(t==="esc")this.fetch?.abort(),clearTimeout(this.settle),e.fetching=void 0,e.mode="grid",e.error=void 0,this.paint.draw()}tuneKey(t){let e=this.view,n=e.tuning,r=e.tune;if(t==="up"||t==="down"){n.field=(n.field+(t==="up"?2:1))%3,this.paint.draw();return}let i=o4[t];if(i!==void 0){if(n.field===0)r.size=s4(r.size,i,n.fill);else if(n.field===1)r.at=(r.at-1+Math.sign(i)+9)%9+1;else r.opacity=Math.max(0,Math.min(100,Math.round(r.opacity*100)+i))/100;this.retune();return}if(/^[1-9]$/.test(t)){n.field=1,r.at=Number(t),this.retune();return}if(t==="="){let o=e.untuned;if(n.field===0)r.size=o.size;else if(n.field===1)r.at=o.at;else r.opacity=o.opacity;this.retune();return}if(t==="+"){e.tune={...e.untuned},this.retune();return}if(t==="enter"){e.tuning=void 0,this.paint.draw();return}if(t==="c"){this.recolor();return}if(t==="esc")e.tune={...n.held,...n.coloring===e.coloring?{}:{opacity:e.untuned.opacity}},e.tuning=void 0,this.retune()}recolor(){let t=this.view;if(!this.current||t.shown?.id!==this.current.key)return;t.coloring=t.coloring==="tone"?"original":"tone",t.tune.opacity=t.untuned.opacity,this.paint.draw(),this.reveal()}retune(){if(this.paint.draw(),this.current&&this.view.shown?.id===this.current.key)this.reveal()}inform(){let t=this.view,e=t.tiles[t.focus],n=e&&this.posts.get(e.key);t.info=n?this.infoOf(n):void 0}infoOf(t){let{site:e,post:n}=t,r=n.named,i=I0(e,n),o=new Set([...r.artist,...r.character,...r.copyright]),s=oa(n.source),a=/^https?:\/\//i.test(s)?s:e===mr&&s.startsWith("/")?pM(s).href:void 0;return{page:e===mr?"":e.pageUrl(n.id),source:s,...a?{link:a}:{},artists:r.artist,characters:r.character,series:r.copyright,tags:n.tags.filter((c)=>!o.has(c)),...i?{rating:i}:{},...n.posted?{posted:n.posted}:{},ext:(En(n)??n).ext,uploader:n.owner}}focus(t){let e=this.view;if(e.tiles.length===0)return;let n=Math.max(0,Math.min(e.tiles.length-1,t));if(n===e.focus)return;if(e.focus=n,this.board.focus=n,this.scroll(),this.paint.glide(),this.pump(),e.mode==="try")this.select();this.paint.draw()}scroll(){let t=this.view,{perRow:e,rowsVis:n}=hr(this.cols,this.rows),r=Math.floor(t.focus/e);if(r<t.top)t.top=r;if(r>t.top+n-1)t.top=r-n+1;this.board.top=t.top}selected(t){if(t.chosen)return t.chosen;if(!t.tag)return[];return this.namesOf(t.tag,"danbooru")}namesOf(t,e){let n=t===this.entry.booru?this.entry:this.catalog.palettes.find((r)=>r.booru===t);return n?vk(n,e):[t]}syncChips(){let t=this.selected(this.view);this.view.chips=this.pool.slice(0,E4).map((e)=>({name:e,on:t.includes(e)}))}toggle(t){let e=this.view,n=e.chips[t];if(!n)return;let r=this.selected(e),i=n.on?r.filter((o)=>o!==n.name):[...r,n.name];if(i.length===0)return;e.chosen=i,e.tag=i.join(" or "),this.syncChips(),this.boards.clear(),this.search()}async relate(t){this.relating?.abort();let e=this.selected({tag:t,chosen:void 0});if(this.pool=e,this.syncChips(),this.paint.draw(),!t||/\s/.test(t))return;let n=this.related.get(t);if(!n){let r=new AbortController;this.relating=r;try{n=(await T0(t,AbortSignal.any([this.signal,r.signal]))).map((i)=>i.value)}catch{return}if(this.relating!==r)return;this.related.set(t,n)}this.pool=[...new Set([...e,...n])],this.syncChips(),this.paint.draw()}query(t,e=this.view){let n=e.chosen?H0(t,e.chosen):this.namesOf(e.tag,t.key);if(n.length===0)return;let r=e.chosen?.slice(n.length)??[],i=n.length>1,o=e.preset==="cutouts"?t.cutouts:"",s=i&&o.includes("~"),a=[i?n.map((f)=>`~${f}`).join(" "):n[0],t.rate(e.rating),...t.narrow(e.narrow),s?"":o,e.order==="score"?t.best:""].filter(Boolean),c=[],u=[];for(let f of a)if(Ad([...c,f].join(" "))<=t.tagBudget)c.push(f);else u.push(f);return{tags:c.join(" "),notes:[...u.length>0?[`${t.name} takes ${t.tagBudget} tags — ${u.join(" ")} left out`]:[],...r.length>0?[`${t.name} takes ${n.length} tag${n.length===1?"":"s"} — ${r.join(" ")} left out`]:[],...s?[`${t.name} ORs the names, so cutouts are told by the file`]:[],...e.narrow.score>0&&!t.scored?[`${t.name} keeps no score`]:[],...e.narrow.png&&t.guesses?[`${t.name} names a file type only where danbooru holds the file`]:[]]}}async search(){let t=++this.gen,e=mf(this.boardKey,!0);this.board=e,this.boards.set(e.key,e),this.view.error=void 0;let n=this.sites.flatMap((o)=>{let s=this.query(o);return s?[{site:o,...s}]:[]}),r=this.sites.filter((o)=>!n.some((s)=>s.site===o)),i=[...n.flatMap(({notes:o})=>o),...r.length>0?[`${this.entry.name} has no tag on ${r.map((o)=>o.name).join(", ")}`]:[]];if(e.note=i.length>0?i.join(" · "):void 0,n.length===0)e.searching=!1;this.show(),this.paint.draw(),this.tally(t,e,n);try{let o=await Promise.all(n.map(async(s)=>({plan:s,owners:await this.kept.mateOwners(s.site)})));if(t!==this.gen)return;e.sources=o.flatMap(({plan:{site:s,tags:a},owners:c})=>{let u=Ad(a)+1<=s.tagBudget?s.uploadedBy:void 0;return[...u?[...c.keys()].map((f)=>({site:s,tags:`${a} ${u(f)}`,page:0,done:!1})):[],{site:s,tags:a,page:0,done:!1}]}),this.show(),this.paint.draw(),await this.pump()}catch(o){this.fail(t,o)}}async tally(t,e,n){let r=await Promise.allSettled(n.map(({site:i,tags:o})=>Nd(i,o,this.signal)));if(t===this.gen)e.total=r.reduce((i,o)=>i+(o.status==="fulfilled"&&Number.isFinite(o.value)?o.value:0),0),this.show(),this.paint.draw()}fail(t,e,n=this.site){if(t!==this.gen||this.signal.aborted)return;this.board.error=Og(n?.name??this.tabName,e),this.board.searching=!1,this.view.error=this.board.error,this.show(),this.paint.draw()}drop(t,e,n){for(let r of t.sources)if(r.site===e)r.done=!0;t.note=[t.note,Og(e.name,n)].filter(Boolean).join(" · ")}wants(){let{perRow:t,rowsVis:e}=hr(this.cols,this.rows);return this.view.tiles.length<(this.board.top+e+EM)*t}need(){let{perRow:t,rowsVis:e}=hr(this.cols,this.rows);return(e+EM)*t}live(t){return this.boards.get(t.key)===t}page(t,e,n){let r=`${t.key}|${e}|${n}`,i=this.pages.get(r);if(!i)i=A0(t,e,n,this.signal).then((o)=>this.borrow(t,o)),this.pages.set(r,i),i.catch(()=>this.pages.delete(r));return i}async borrow(t,e){let n=t===ce?[]:e.filter((r)=>r.md5!=="");if(n.length>0)try{tu(n,await eu(n.map((r)=>r.md5),this.signal))}catch{}return e}staged(t){if(t===this.board)this.stageOf(t),this.paint.draw()}async round(t){t.stage="fetch",this.staged(t);let e=V.flatMap((a)=>{let c=t.sources.find((u)=>u.site===a&&!u.done);return c?[c]:[]}),n=await Promise.all(e.map(async(a)=>{try{let c=await this.page(a.site,a.tags,a.page);return t.arrived.add(a.site.name),this.staged(t),{source:a,posts:c}}catch(c){if(t.sources.every((u)=>u.site===a.site)||this.signal.aborted)throw c;return this.drop(t,a.site,c),{source:a,posts:void 0}}}));if(!this.live(t))return;let r=[];for(let{source:a,posts:c}of n){if(!c)continue;a.page++,a.done=c.length<Hr;let u=t.last.get(a);for(let f of c){let l=u&&yS(u.post,f)?u.set:`set:${a.site.key}:${f.id}`;u={post:f,set:l};let d=Pe(a.site,f.id);if(t.seen.has(d))continue;t.seen.add(d);let h={site:a.site,post:f};if(this.eligible(h))t.kin.set(h,[l,...kS(a.site,f)]),r.push(h);else t.checked++}if(u)t.last.set(a,u)}let i=this.dedupe(t,r),o=++t.rounds,s;if(this.view.order!=="fit")s=e.length>1?fS(i):i;else{let a=ql(i,this.frame(),this.matched),c=a.slice(0,this.need()),u={done:0,total:c.length};if(t.ranking=u,this.staged(t),await this.looks(c,()=>{u.done++,this.staged(t)}),t.ranking=void 0,!this.live(t))return;s=[...ql(c,this.frame(),this.matched),...a.slice(c.length)]}t.stage="check",this.staged(t);for(let a of s)t.roundOf.set(a,o);t.queue.push(...s),this.ahead(t)}ahead(t){if(this.aheading||this.view.order!=="fit"||!this.live(t))return;let e=t.queue.slice(0,this.need()).filter((n)=>!this.looking.has(Pe(n.site,n.post.id)));if(e.length===0)return;this.aheading=!0,this.looks(e).then(()=>{this.aheading=!1;for(let n of new Set(e.map((r)=>t.roundOf.get(r)??0)))this.resort(t,n);this.ahead(t)})}resort(t,e){let n=t.queue.flatMap((i,o)=>t.roundOf.get(i)===e?[o]:[]),r=ql(n.map((i)=>t.queue[i]),this.frame(),this.matched);n.forEach((i,o)=>{t.queue[i]=r[o]})}dedupe(t,e){let n=[];for(let r of e){let i=ug(r.post),o=i.map((a)=>t.same.get(a)).find(Boolean);if(!o){for(let a of i)t.same.set(a,r);n.push(r);continue}if(t.checked++,MM(r.post)<=MM(o.post))continue;for(let a of[...i,...ug(o.post)])t.same.set(a,r);let s=n.indexOf(o);if(s>=0){n[s]=r;continue}this.replace(t,o,r)}return n}replace(t,e,n){t.roundOf.set(n,t.roundOf.get(e)??0);let r=t.queue.indexOf(e);if(r>=0){t.queue[r]=n;return}for(let i of t.groups){let o=i.posts.indexOf(e);if(o>=0){i.posts[o]=n,this.posts.set(Pe(n.site,n.post.id),n),this.thumbQueue.push(n),this.thumbs();return}}}async looks(t,e){let n=0;await Promise.all(Array.from({length:kM},async()=>{while(n<t.length)await this.look(t[n++]),e?.()}))}look(t){let e=Pe(t.site,t.post.id),n=this.looking.get(e);if(!n)n=(async()=>{let r=this.previewPath(t),i=Jc(t.site,t.post);await this.kept.cached(i.site,r,i.url);let o=await this.renders.run({job:"match",from:r,colors:this.entry.signature});return this.looked.set(e,o),this.matched.set(t.post,o.match),o})().catch(()=>{return}),this.looking.set(e,n);return n}async pump(){let t=this.gen,e=this.board;if(this.pumping===t||e.sources.length===0)return;this.pumping=t;let n=[],r;try{e.searching=!0;while(t===this.gen){while(n.length<$M&&e.queue.length>0&&this.wants()){let s=e.queue.shift();n.push({pick:s,passed:this.vet(s)})}if(this.ahead(e),!r&&e.queue.length<$M&&e.sources.some((s)=>!s.done)&&this.wants()){let s=this.round(e).then(()=>{if(r===s)r=void 0});s.catch(()=>{}),r=s}let i=n.shift();if(!i){if(!r)break;await r,this.show(),this.paint.draw();continue}let o=await i.passed;if(t!==this.gen)return;if(e.checked++,o)this.admit(i.pick);this.show(),this.paint.draw()}if(t===this.gen)e.searching=!1,this.show(),this.paint.draw()}catch(i){this.fail(t,i)}finally{if(this.kept.save(),this.pumping===t)this.pumping=0}}eligible({site:t,post:e}){let n=En(e);if(!Zc(t,e,this.view.rating)||Yc(e,this.view.block).length>0||!n)return!1;if(this.view.solo&&e.solo===!1)return!1;let{score:r,size:i,png:o}=this.view.narrow;if(Math.min(e.width,e.height)<i||t.scored&&e.score<r||o&&e.ext!=="png"||O0(e,this.view.hide).length>0||this.view.hideTags.some((s)=>e.tags.includes(s)))return!1;return this.view.preset==="all"?["png","jpg","jpeg",""].includes(n.ext):["png",""].includes(e.ext)}async vet(t){let[e]=await Promise.all([this.passes(t),this.look(t)]);return e}async passes({site:t,post:e}){return this.view.preset==="all"||t.vouched||this.kept.transparent(t,e)}admit(t){let{site:e,post:n}=t,r=this.board,i=Pe(e,n.id);this.posts.set(i,t);let o=r.kin.get(t)??[],s=this.looked.get(i),a=s&&{hash:s.hash,width:n.width,height:n.height},c=this.view.sets==="fold"?this.kindred(r,o,a):void 0;if(c){if(c.posts.push(t),this.register(r,c,o,a),c.open)this.thumbQueue.push(t),this.thumbs();return}let u={posts:[t],open:!1};r.groups.push(u),this.register(r,u,o,a),this.thumbQueue.push(t),this.thumbs()}kindred(t,e,n){for(let r of e){let i=t.kindred.get(r);if(i)return i}return n&&t.shapes.find((r)=>ES(r.shape,n))?.group}register(t,e,n,r){for(let i of n)if(!t.kindred.has(i))t.kindred.set(i,e);if(r)t.shapes.push({shape:r,group:e})}holds(){this.view.held=wM(this.home,this.entry.name).map((t)=>{let e=this.heldFiles.get(t.from);return e?{...t,thumb:e}:t}),this.holdThumbs()}holdThumbs(){let t=ve.cols*this.cell.w,e=ve.rows*this.cell.h;if(t===0||e===0)return;for(let n of this.view.held.slice(0,Fp(this.cols))){if(n.thumb||this.heldAsked.has(n.from))continue;this.heldAsked.add(n.from);let r=_n(this.scratch,`held-${n4(n.from)}-${t}x${e}.png`);this.renders.run({job:"thumb",from:n.from,to:r,width:t,height:e}).then(()=>{this.heldFiles.set(n.from,r),this.holds(),this.paint.draw()}).catch(()=>{})}}thumbs(){while(!this.signal.aborted&&this.thumbing<kM&&this.thumbQueue.length>0){let t=this.thumbQueue.shift();this.thumbing++,this.thumb(t).catch(()=>{this.thumbless.add(Pe(t.site,t.post.id)),this.show(),this.paint.draw()}).finally(()=>{this.thumbing--,this.thumbs()})}}async thumb(t){let{site:e,post:n}=t,r=vt.cols*this.cell.w,i=vt.rows*this.cell.h,o=Jc(e,n),s=_n(rn(e),"tile",`${xM(n.id,o.url)}-${r}x${i}.png`);if(!xc(s)){let a=this.previewPath(t);if(await this.kept.cached(o.site,a,o.url),this.signal.aborted)return;await this.renders.run({job:"thumb",from:a,to:s,width:r,height:i})}this.thumbPath.set(Pe(e,n.id),s),this.show(),this.paint.draw()}select(){let t=this.view,e=t.tiles[t.focus];if(this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,this.inform(),!e)return;if(this.current?.key===e.key){this.reveal();return}this.settle=setTimeout(()=>void this.load(e),h4),this.paint.draw()}async load(t){let e=this.view,n=this.posts.get(t.key);if(!n)return;let r=new AbortController;if(this.fetch=r,this.kept.credit(n,r.signal),!En(n.post))return;let{site:i}=n,o=this.board;try{await aa(i,n.post,r.signal);let s=En(n.post),a=this.origPath(i,t.id,s.ext);if(!xc(a))e.fetching={id:t.key,got:0,size:0},this.paint.draw();let c=Ni(i,n.post,s),u=await this.kept.cached(c.site,a,c.url,(d,h)=>{if(e.fetching?.id===t.key)e.fetching={id:t.key,got:d,size:h},this.paint.draw()});if(r.signal.aborted)return;if(e.fetching=void 0,o!==this.board)return;let f={site:i,id:t.id,key:t.key,path:a,ext:s.ext,size:u,using:"plain",failed:!1};e.preparing=t.key,this.paint.flush();let l=await this.render(f,"plain");if(r.signal.aborted||o!==this.board)return;if(l.clear===0&&_s()&&this.setting("TTHEME_FIND_REMOVE_BG")!=="off"){if(e.preparing=void 0,e.cutting=t.key,this.paint.flush(),f.cut=await this.cutOut(i,t.id,a,r.signal),r.signal.aborted||o!==this.board)return;if(e.cutting=void 0,f.cut){e.preparing=t.key,this.paint.flush();let d=await this.render(f,"cut").catch(()=>{return});if(r.signal.aborted||o!==this.board)return;if(d&&Dl(d.clear))f.using="cut";else hf(f.cut,{force:!0}),f.cut=void 0,f.failed=!0}else f.failed=!0}if(this.current=f,e.tiles[e.focus]?.key===t.key)await this.present();this.preload()}catch(s){if(!r.signal.aborted&&!this.signal.aborted)e.error=Og(i.name,s)}finally{if(e.fetching?.id===t.key)e.fetching=void 0;if(e.preparing===t.key)e.preparing=void 0;if(e.cutting===t.key)e.cutting=void 0;this.paint.draw()}}async cutOut(t,e,n,r){let i=_n(rn(t),"cut",`${e}.png`);if(xc(i))return i;try{return V5(r4(i),{recursive:!0}),await mc(n,i,r),i}catch{hf(i,{force:!0});return}}swap(){let t=this.current;if(!t?.cut||this.view.shown?.id!==t.key)return;t.using=t.using==="cut"?"plain":"cut",this.reveal()}preload(){let t=this.view;if(t.mode!=="try")return;for(let e of[t.focus+this.direction,t.focus-this.direction]){let n=t.tiles[e],r=n&&this.posts.get(n.key);if(r)this.kept.credit(r,this.signal);if(this.prefetching>=d4||!r||!En(r.post))continue;let{site:i,post:o}=r;this.prefetching++,aa(i,o,this.signal).then(async()=>{let s=En(o),a=this.origPath(i,o.id,s.ext),c=Ni(i,o,s);return await this.kept.cached(c.site,a,c.url),this.render({site:i,id:o.id,key:n.key,path:a,ext:s.ext,size:0,using:"plain",failed:!1},"plain")}).catch(()=>{}).finally(()=>{this.prefetching--})}}async render(t,e){let n=this.cols*this.cell.w,r=this.rows*this.cell.h,i=Math.min(n,w4),o=Math.max(1,Math.round(r*i/n)),s={...this.view.tune},{coloring:a}=this.view,c=!IM(s,this.view.untuned),u=s.opacity!==this.view.untuned.opacity,f=c?`-${s.size}-${s.at}${u?`-${Math.round(s.opacity*100)}`:""}`:"",l=_n(this.scratch,`${t.site.key}-${t.id}${e==="cut"?"c":""}${a==="original"?"o":""}-${i}x${o}${f}.png`),d=`${t.site.key}:${t.id}:${e}:${a}:${i}x${o}`,h=this.clarity.get(d);if(h&&xc(l))return t.fill=h.fill,{clear:h.clear,path:l,opacity:h.opacity,touched:u};let m=await this.renders.run({job:"show",from:e==="cut"?t.cut:t.path,to:l,width:i,height:o,colors:this.entry,tone:this.tone,blur:this.blurring*i/Dd(n,r).width,coloring:a,...c?{tune:{size:s.size,at:s.at,...u?{opacity:s.opacity}:{}}}:{}});if(this.clarity.set(d,m),t.fill=m.fill,c)this.keepTuned(l);return{clear:m.clear,path:l,opacity:m.opacity,touched:u}}keepTuned(t){this.tunedFiles.push(t);while(this.tunedFiles.length>$4){let e=this.tunedFiles.findIndex((n)=>n!==this.view.shown?.path&&n!==t);if(e===-1)return;hf(this.tunedFiles.splice(e,1)[0],{force:!0})}}async present(){let t=this.current;if(!t)return;let e=t.using,{coloring:n}=this.view,r=this.view.tune.opacity,{clear:i,path:o,opacity:s,touched:a}=await this.render(t,e);if(this.current!==t||t.using!==e||this.view.coloring!==n)return;if(!a&&this.view.tune.opacity===r)this.view.untuned.opacity=s,this.view.tune.opacity=s;if(this.view.tuning&&t.fill)this.view.tuning.fill=t.fill;this.view.shown={id:t.key,clear:i,bytes:t.size,path:o,cut:t.cut?e==="cut"?"on":"off":t.failed?"failed":"none"}}reveal(){let t=this.view;if(this.presenting){this.again=!0;return}this.presenting=!0,t.preparing=this.current?.key,this.paint.flush(),this.present().catch((e)=>{t.error=e instanceof Error?e.message:String(e)}).finally(()=>{if(this.presenting=!1,this.again){this.again=!1,this.reveal();return}if(t.preparing===this.current?.key)t.preparing=void 0;this.paint.draw()})}async install(){let t=this.view,e=t.tiles[t.focus],n=this.current;if(!e||n?.key!==e.key||t.preparing!==void 0||t.shown?.id!==e.key)return;t.installing=e.key,t.error=void 0,this.paint.flush();let r=a4(t.tune,t.untuned),i=this.posts.get(n.key)?.post;try{await this.renders.run({job:"backdrop",from:n.using==="cut"?n.cut:n.path,source:n.path,home:this.home,colors:this.entry,tone:this.tone,origin:{site:n.site.key,id:n.id,ext:n.ext,from:`${n.site.name} ${n.id} ${n.site.pageUrl(n.id)}`,artist:i?.named.artist??[],source:oa(i?.source??"")},width:this.cols*this.cell.w,height:this.rows*this.cell.h,blur:this.blurring,coloring:t.coloring,...r?{tune:r,aligns:to(K(this.home).terminals),user:t4()}:{}}),this.kept.owned(n.site,n.id,i?.owner??""),_e(this.home),this.holds();let{size:o,at:s,opacity:a}=t.tune,c=r?` · ${o==="fill"?"fill":`${o}%`} · ${qt[s-1]} · ${a.toFixed(2)}`:"",u=i?.named.artist.length?`${i.named.artist.join(", ")} · `:"";t.saved={text:`Background · ${this.entry.name} ← ${u}${n.site.name} ${n.id}${c}`,key:e.key},t.installed.push(e.key),this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,t.mode="grid"}catch(o){t.error=o instanceof Error?o.message:String(o)}t.installing=void 0,this.paint.draw()}}async function RM(t,e,n){let r=new Ig(t,we(t),e,e.booru??"",n);if(await r.run(),qi(process.env))process.stdout.write(Di(""));return{saved:r.saved,installs:r.installs}}async function PM(t){let e=J(),n=we(e),r=In(n.palettes,t);if(!process.stdin.isTTY||!process.stdout.isTTY)throw Error("needs a terminal");let i=new Ig(e,n,r,r.booru??""),o=await i.run();if(i.saved&&o!==0)return process.stderr.write(`${i.saved}
|
|
721
|
-
`),0;return o}var yo=((t)=>{return t[t.Border=-1]="Border",t[t.Data=0]="Data",t[t.Function=1]="Function",t[t.Position=2]="Position",t[t.Timing=3]="Timing",t[t.Alignment=4]="Alignment",t})(yo||{}),S4=[0,1],NM=[1,0],TM=[2,3],HM=[3,2],M4={L:S4,M:NM,Q:TM,H:HM},x4=/^\d*$/,O4=/^[A-Z0-9 $%*+./:-]*$/,Rg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ng=1,Tg=40,AM=3,I4=3,gf=40,R4=10,FM=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],LM=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class CM{constructor(t,e,n,r){if(this.version=t,this.ecc=e,t<Ng||t>Tg)throw RangeError("Version value out of range");if(r<-1||r>7)throw RangeError("Mask value out of range");this.size=t*4+17;let i=Array.from({length:this.size}).fill(!1);for(let s=0;s<this.size;s++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(n);if(this.drawCodewords(o),r===-1){let s=1e9;for(let a=0;a<8;a++){this.applyMask(a),this.drawFormatBits(a);let c=this.getPenaltyScore();if(c<s)r=a,s=c;this.applyMask(a)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(t,e){return t>=0&&t<this.size&&e>=0&&e<this.size&&this.modules[e][t]}drawFunctionPatterns(){for(let n=0;n<this.size;n++)this.setFunctionModule(6,n,n%2===0,yo.Timing),this.setFunctionModule(n,6,n%2===0,yo.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let t=this.getAlignmentPatternPositions(),e=t.length;for(let n=0;n<e;n++)for(let r=0;r<e;r++)if(!(n===0&&r===0||n===0&&r===e-1||n===e-1&&r===0))this.drawAlignmentPattern(t[n],t[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){let e=this.ecc[1]<<3|t,n=e;for(let i=0;i<10;i++)n=n<<1^(n>>>9)*1335;let r=(e<<10|n)^21522;for(let i=0;i<=5;i++)this.setFunctionModule(8,i,kr(r,i));this.setFunctionModule(8,7,kr(r,6)),this.setFunctionModule(8,8,kr(r,7)),this.setFunctionModule(7,8,kr(r,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,kr(r,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,kr(r,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,kr(r,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let n=0;n<12;n++)t=t<<1^(t>>>11)*7973;let e=this.version<<12|t;for(let n=0;n<18;n++){let r=kr(e,n),i=this.size-11+n%3,o=Math.floor(n/3);this.setFunctionModule(i,o,r),this.setFunctionModule(o,i,r)}}drawFinderPattern(t,e){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),o=t+r,s=e+n;if(o>=0&&o<this.size&&s>=0&&s<this.size)this.setFunctionModule(o,s,i!==2&&i!==4,yo.Position)}}drawAlignmentPattern(t,e){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(t+r,e+n,Math.max(Math.abs(r),Math.abs(n))!==1,yo.Alignment)}setFunctionModule(t,e,n,r=yo.Function){this.modules[e][t]=n,this.types[e][t]=r}addEccAndInterleave(t){let e=this.version,n=this.ecc;if(t.length!==bf(e,n))throw RangeError("Invalid argument");let r=LM[n[0]][e],i=FM[n[0]][e],o=Math.floor(Pg(e)/8),s=r-o%r,a=Math.floor(o/r),c=[],u=j4(i);for(let l=0,d=0;l<r;l++){let h=t.slice(d,d+a-i+(l<s?0:1));d+=h.length;let m=_4(h,u);if(l<s)h.push(0);c.push(h.concat(m))}let f=[];for(let l=0;l<c[0].length;l++)c.forEach((d,h)=>{if(l!==a-i||h>=s)f.push(d[l])});return f}drawCodewords(t){if(t.length!==Math.floor(Pg(this.version)/8))throw RangeError("Invalid argument");let e=0;for(let n=this.size-1;n>=1;n-=2){if(n===6)n=5;for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let o=n-i,a=(n+1&2)===0?this.size-1-r:r;if(!this.types[a][o]&&e<t.length*8)this.modules[a][o]=kr(t[e>>>3],7-(e&7)),e++}}}applyMask(t){if(t<0||t>7)throw RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let n=0;n<this.size;n++){let r;switch(t){case 0:r=(n+e)%2===0;break;case 1:r=e%2===0;break;case 2:r=n%3===0;break;case 3:r=(n+e)%3===0;break;case 4:r=(Math.floor(n/3)+Math.floor(e/2))%2===0;break;case 5:r=n*e%2+n*e%3===0;break;case 6:r=(n*e%2+n*e%3)%2===0;break;case 7:r=((n+e)%2+n*e%3)%2===0;break;default:throw Error("Unreachable")}if(!this.types[e][n]&&r)this.modules[e][n]=!this.modules[e][n]}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let o=!1,s=0,a=[0,0,0,0,0,0,0];for(let c=0;c<this.size;c++)if(this.modules[i][c]===o){if(s++,s===5)t+=AM;else if(s>5)t++}else{if(this.finderPenaltyAddHistory(s,a),!o)t+=this.finderPenaltyCountPatterns(a)*gf;o=this.modules[i][c],s=1}t+=this.finderPenaltyTerminateAndCount(o,s,a)*gf}for(let i=0;i<this.size;i++){let o=!1,s=0,a=[0,0,0,0,0,0,0];for(let c=0;c<this.size;c++)if(this.modules[c][i]===o){if(s++,s===5)t+=AM;else if(s>5)t++}else{if(this.finderPenaltyAddHistory(s,a),!o)t+=this.finderPenaltyCountPatterns(a)*gf;o=this.modules[c][i],s=1}t+=this.finderPenaltyTerminateAndCount(o,s,a)*gf}for(let i=0;i<this.size-1;i++)for(let o=0;o<this.size-1;o++){let s=this.modules[i][o];if(s===this.modules[i][o+1]&&s===this.modules[i+1][o]&&s===this.modules[i+1][o+1])t+=I4}let e=0;for(let i of this.modules)e=i.reduce((o,s)=>o+(s?1:0),e);let n=this.size*this.size,r=Math.ceil(Math.abs(e*20-n*10)/n)-1;return t+=r*R4,t}getAlignmentPatternPositions(){if(this.version===1)return[];else{let t=Math.floor(this.version/7)+2,e=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,n=[6];for(let r=this.size-7;n.length<t;r-=e)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(t){let e=t[1],n=e>0&&t[2]===e&&t[3]===e*3&&t[4]===e&&t[5]===e;return(n&&t[0]>=e*4&&t[6]>=e?1:0)+(n&&t[6]>=e*4&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,n){if(t)this.finderPenaltyAddHistory(e,n),e=0;return e+=this.size,this.finderPenaltyAddHistory(e,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(t,e){if(e[0]===0)t+=this.size;e.pop(),e.unshift(t)}}function yr(t,e,n){if(e<0||e>31||t>>>e!==0)throw RangeError("Value out of range");for(let r=e-1;r>=0;r--)n.push(t>>>r&1)}function kr(t,e){return(t>>>e&1)!==0}class wf{constructor(t,e,n){if(this.mode=t,this.numChars=e,this.bitData=n,e<0)throw RangeError("Invalid argument");this.bitData=n.slice()}getData(){return this.bitData.slice()}}var P4=[1,10,12,14],A4=[2,9,11,13],N4=[4,8,16,16];function jM(t,e){return t[Math.floor((e+7)/17)+1]}function _M(t){let e=[];for(let n of t)yr(n,8,e);return new wf(N4,t.length,e)}function T4(t){if(!GM(t))throw RangeError("String contains non-numeric characters");let e=[];for(let n=0;n<t.length;){let r=Math.min(t.length-n,3);yr(Number.parseInt(t.substring(n,n+r),10),r*3+1,e),n+=r}return new wf(P4,t.length,e)}function H4(t){if(!BM(t))throw RangeError("String contains unencodable characters in alphanumeric mode");let e=[],n;for(n=0;n+2<=t.length;n+=2){let r=Rg.indexOf(t.charAt(n))*45;r+=Rg.indexOf(t.charAt(n+1)),yr(r,11,e)}if(n<t.length)yr(Rg.indexOf(t.charAt(n)),6,e);return new wf(A4,t.length,e)}function F4(t){if(t==="")return[];else if(GM(t))return[T4(t)];else if(BM(t))return[H4(t)];else return[_M(C4(t))]}function GM(t){return x4.test(t)}function BM(t){return O4.test(t)}function L4(t,e){let n=0;for(let r of t){let i=jM(r.mode,e);if(r.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+r.bitData.length}return n}function C4(t){t=encodeURI(t);let e=[];for(let n=0;n<t.length;n++)if(t.charAt(n)!=="%")e.push(t.charCodeAt(n));else e.push(Number.parseInt(t.substring(n+1,n+3),16)),n+=2;return e}function Pg(t){if(t<Ng||t>Tg)throw RangeError("Version number out of range");let e=(16*t+128)*t+64;if(t>=2){let n=Math.floor(t/7)+2;if(e-=(25*n-10)*n-55,t>=7)e-=36}return e}function bf(t,e){return Math.floor(Pg(t)/8)-FM[e[0]][t]*LM[e[0]][t]}function j4(t){if(t<1||t>255)throw RangeError("Degree out of range");let e=[];for(let r=0;r<t-1;r++)e.push(0);e.push(1);let n=1;for(let r=0;r<t;r++){for(let i=0;i<e.length;i++)if(e[i]=Ag(e[i],n),i+1<e.length)e[i]^=e[i+1];n=Ag(n,2)}return e}function _4(t,e){let n=e.map((r)=>0);for(let r of t){let i=r^n.shift();n.push(0),e.forEach((o,s)=>n[s]^=Ag(o,i))}return n}function Ag(t,e){if(t>>>8!==0||e>>>8!==0)throw RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(e>>>r&1)*t;return n}function G4(t,e,n=1,r=40,i=-1,o=!0){if(!(Ng<=n&&n<=r&&r<=Tg)||i<-1||i>7)throw RangeError("Invalid value");let s,a;for(s=n;;s++){let l=bf(s,e)*8,d=L4(t,s);if(d<=l){a=d;break}if(s>=r)throw RangeError("Data too long")}for(let l of[NM,TM,HM])if(o&&a<=bf(s,l)*8)e=l;let c=[];for(let l of t){yr(l.mode[0],4,c),yr(l.numChars,jM(l.mode,s),c);for(let d of l.getData())c.push(d)}let u=bf(s,e)*8;yr(0,Math.min(4,u-c.length),c),yr(0,(8-c.length%8)%8,c);for(let l=236;c.length<u;l^=253)yr(l,8,c);let f=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((l,d)=>f[d>>>3]|=l<<7-(d&7)),new CM(s,e,f,i)}function UM(t,e){let{ecc:n="L",boostEcc:r=!1,minVersion:i=1,maxVersion:o=40,maskPattern:s=-1,border:a=1}=e||{},c=typeof t==="string"?F4(t):Array.isArray(t)?[_M(t)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof t}`);let u=G4(c,M4[n],i,o,s,r),f=B4({version:u.version,maskPattern:u.mask,size:u.size,data:u.modules,types:u.types},a);if(e?.invert)f.data=f.data.map((l)=>l.map((d)=>!d));return e?.onEncoded?.(f),f}function B4(t,e=1){if(!e)return t;let{size:n}=t,r=n+e*2;t.size=r,t.data.forEach((o)=>{for(let s=0;s<e;s++)o.unshift(!1),o.push(!1)});for(let o=0;o<e;o++)t.data.unshift(Array.from({length:r},(s)=>!1)),t.data.push(Array.from({length:r},(s)=>!1));let i=yo.Border;t.types.forEach((o)=>{for(let s=0;s<e;s++)o.unshift(i),o.push(i)});for(let o=0;o<e;o++)t.types.unshift(Array.from({length:r},(s)=>i)),t.types.push(Array.from({length:r},(s)=>i));return t}var U4=Hb(16,231),W4=[" ","▀","▄","█"];function WM(t){let{data:e}=UM(t,{border:2,boostEcc:!0}),n=[];for(let r=0;r<e.length;r+=2){let i=e[r]??[],o=e[r+1]??[];n.push(`${U4}${i.map((s,a)=>W4[(s?1:0)+(o[a]?2:0)]).join("")}${me}`)}return n}var K4=50;function z4(t){return{background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selection,ansi:t.ansi}}function q4(t,e,n){for(let r of n){let i=t-4-r.length;if(i>e.length+2)return[[2,e],[i,` ${r} `]]}return[[2,e]]}function KM(t,e,n,r=K4){let i=Me(n),o=Qe(z4(e)),s=ck(t).map((p)=>p.toLowerCase()),a=rg(o,e.signatureSlots,e.waived??[]),c=Jn(br(o,e.signatureSlots,e.waived??[])).length,u=(p)=>o[p]?.toLowerCase()!==s[p],f=o.filter((p,b)=>u(b)).length,l=(p)=>{let b=o[p],$=e.signatureSlots.includes(Cn[p])?A.signature:n?A.swatch:" ",k=n?`${i.fg(b)}${$}${bt}`:$,v=a.has(p)?i.bold(A.miss):u(p)?i.warn(A.on):" ";return` ${k} ${nf(xt(b))}${v}`},d=c===0?"passes the gate":`${c} ${c===1?"miss":"misses"} in the gate`,h=f>0?[`${f} tuned · ${d}`,d]:[d],m=[i.dim(Jt(r,"top",q4(r," Palette ",h)))];for(let p=0;p<T.length;p++)m.push(De(i,` ${T[p].padEnd(10)}${l(p)}`,r));return m.push(i.dim(Jt(r,"mid",[[2," ANSI "],[12," Normal 0–7 "],[29," Bright 8–15 "]]))),mn.forEach((p,b)=>{m.push(De(i,` ${p.padEnd(10)}${l(T.length+b)}${l(T.length+8+b)}`,r))}),m.push(i.dim(Jt(r,"bottom"))),m}function Ks(){return process.stdin.isTTY===!0&&process.stdout.isTTY===!0}async function Fg(){let t=process.env.TTHEME_WORN;if(!t||!Ks())return;let e=await Le({message:`Use ${t}, the palette this tab wears?`});if(te(e)||!e)throw new de;return t}async function DM(t){let e=process.env.TTHEME_WORN;if(!e)return;if(!Ks())return console.error(`Sharing ${e}, the palette this tab wears`),{name:e,...t?{tone:t}:{}};if(t!==void 0||Ut(J())[e]===void 0)return await Fg(),{name:e,...t?{tone:t}:{}};let n=await zh({message:`Share ${e}, the palette this tab wears?`,options:[{value:"tuned",label:"Your tone",hint:`named ${Ic(e)}`},{value:"original",label:"The original"},{value:"no",label:"No"}]});if(te(n)||n==="no")throw new de;return{name:e,tone:n}}function JM(t,e){if(t.includes("/"))return t;let n=Ui(e,!1),r=n.filter((o)=>ns(o.dir).some((s)=>s.slug===t)),[i]=r.length===1?r:n.length===1?n:[];return i?`${i.id}/${t}`:t}function Y4(t,e,n){let r=K(t),i=n.filter((o)=>!r.palettes.includes(o));if(i.length>0)Ve(t,e,r,{...r,palettes:[...r.palettes,...i]});else if(n.some((o)=>r.palettes.includes(o)))Kt(t,e,r);return{state:r,fresh:i}}function Z4(t){let e=Math.max(0,...t.map((n)=>n.slot.length));return t.map((n)=>` ${n.slot.padEnd(e)} ${n.from} → ${n.to} ${n.rule}`)}function zM(t){return JSON.stringify([t.background,t.foreground,t.cursor,t.selection,t.ansi])}function YM(t,e,n){let r=ik(e,n.palettes),i=nr(t,n,!1).palettes.find((o)=>o.name===r.name);if(i&&zM(i)!==zM(r))throw Error(`${r.name} is already in ${ut(r.name)??"the ttheme catalog"} and differs — \`ttheme add ${r.name}\` wears that one`);if(!i)os(t,[...qr(t),r]);return r}var V4=["background","foreground","cursor"];function ZM(t){try{t();return}catch(e){return e.message}}function VM(t,e,n){return Wt(t,e,!1).palettes.filter((r)=>r.name!==n).map((r)=>({name:r.name,colors:{background:r.background,foreground:r.foreground,cursor:r.cursor,selection:r.selection,ansi:r.ansi}}))}function XM(t,e){let n=new Set(ge(t,e).map((r)=>r.key));return{count:()=>ge(t,e).length,added:()=>ge(t,e).filter((r)=>!n.has(r.key)).length,fresh:()=>(Yl(t,e)??[]).filter((r)=>!n.has(le(r))),discard:()=>{let r=ge(t,e).filter((i)=>!n.has(i.key));for(let i of r)Do(t,e,i.key),cu(t,e);if(r.length>0)_e(t)}}}function X4(...t){let e=new Map;for(let n of t.flatMap((r)=>r??[]))e.set(le(n),n);return e.size>0?[...e.values()]:void 0}function QM(t,e,n,r){if(!us(process.env,K(t).terminals))return;return async(i,o)=>{let s=sn(xn(e,r(i),n.palettes)),{saved:a}=await RM(t,s,o);return{...a?{note:a}:{},count:ge(t,e).length}}}async function Lg(t,e=!1){let n=process.stdout.isTTY===!0,r=J(),i=K(r).terminals,o=n?Xl.of(process.env,r,t.name,i):void 0,s=n?cf.of(process.env,i):void 0;return dM(t,{color:!Ft(),...o?{backdrop:o}:{},...s?{layer:s}:{},...e?{hosted:!0}:{}})}async function tx(t,e,n){let r=J(),i=ct(r),o=await Pv(r,n),s=t.includes("/")?t:`${o.id}/${t}`,a=Ne(s);if(a)throw Error(`${s} ${a}`);if(ut(s)!==o.id)throw Error(`palettes in ${o.dir} are named ${o.id}/<palette> — ${s} belongs elsewhere`);let c=gh(r,s);if(Rc(c))throw Error(`${s} already exists — \`ttheme edit ${s}\` changes it`);let u=e?In(Wt(r,i).palettes,e):void 0;if(!Ks())throw Error("new opens the palette editor — run it in a terminal");let f=u&&(ut(u.name)?u.base:u.default?void 0:u.name),l=u?wh(u,s,`kept from ${u.name}`):void 0,d=u?Yl(r,u.name)??u.pictures:void 0,{base:h,ansiSource:m,group:p,...b}=l??{name:s,signature:V4,...mi(hc)},$=XM(r,s),k=({colors:x,signature:M})=>{let R=X4(d,$.fresh());return $h({...b,...x,signature:M,...f?{base:f}:{},...R?{pictures:R}:{}})},v=await Lg({title:"New palette",name:s,...l?{colors:l}:{},signature:b.signature,...b.waive?{waive:b.waive}:{},palettes:VM(r,i,s),pictures:$.count(),find:QM(r,s,i,k),exports:ax(r,s,i,k),decode:Cg,check:(x)=>ZM(()=>xn(s,k(x),i.palettes))});if(!v){$.discard(),console.log("Nothing made");return}D4(J4(c),{recursive:!0}),L(c,k(v));let{state:E}=Y4(r,i,[s]);console.log(` + ${s}${u?` from ${u.name}`:""}
|
|
722
|
-
${c}`),await
|
|
723
|
-
\`ttheme use ${s}\` wears it · \`ttheme edit ${s}\` opens it again`)}function
|
|
720
|
+
}`;function Gs(){return process.platform==="darwin"}function tf(t){return t>=t3&&t<=e3}function wc(t,e,n){return new Promise((r,i)=>{let o=X8("osascript",["-l","JavaScript","-e",n3,t,e],{stdio:["ignore","ignore","pipe"],signal:AbortSignal.any([n,AbortSignal.timeout(Q8)])}),s="";o.stderr.on("data",(a)=>{s+=a}),o.on("error",i),o.on("close",(a)=>{if(a===0){r();return}i(Error(s.trim().split(`
|
|
721
|
+
`).at(-1)||`osascript exited ${a}`))})})}var vE=90000;function nf(t,e){let n=X(t),r=ge(t,e).flatMap((i)=>{let[,o,s]=/^([a-z.]+)_(\d+)$/.exec(i.key)??[];return o&&s&&Z.some((a)=>a.key===o)?[{site:o,id:Number(s),...oh(n,i)}]:[]});return r.length>0?r:void 0}function i3(t,e){let n=new Set(Nt(X(t)).palettes[e.name]?.pictures.map((r)=>r.key));return(e.pictures??[]).filter((r)=>!n.has(le(r)))}function SE(t,e){let n=new Set((e??[]).map((r)=>le(r)));return{...t,pictures:(t.pictures??[]).filter((r)=>!n.has(le(r)))}}async function o3(t,e,n,r,i,o){let s=Z.find((b)=>b.key===n.site);if(!s)throw Error(`no site called ${n.site}`);o("Fetching");let a=await Go(s,n.id,i);if(!a)throw Error("the post is gone");if(s!==ce&&a.md5)try{ou([a],await su([a.md5],i))}catch{}let c=iu(s,a)?ru(s,a.id,i).then((b)=>{if(b)ua(a,b)},()=>{}):void 0;if(!eu(s,a,Ai(process.env.TTHEME_FIND_RATING))||tu(a,_o(process.env.TTHEME_FIND_BLOCK)).length>0)throw Error("outside your find filters — TTHEME_FIND_RATING and TTHEME_FIND_BLOCK");let u=vn(a);if(!u)throw Error("too large to use");let f=go(on(s),"orig",`${n.id}.${u.ext}`),l;if(hg(f))l=new Uint8Array(Bs(f));else{o("Downloading");let b=Ti(s,a,u);l=await au(b.site,b.url,i,($,k)=>o("Downloading",yl($,k))),C(f,l)}let d=Nr(l,Re),h=!1;if(Vn(d)===0&&Gs()&&process.env.TTHEME_FIND_REMOVE_BG!=="off"){let b=go(on(s),"cut",`${n.id}.png`);try{if(!hg(b))o("Cutting out"),kE(yE(b),{recursive:!0}),await wc(f,b,i);let $=Nr(new Uint8Array(Bs(b)),Re);if(tf(Vn($)))d=$,h=!0}catch{}}await c;let m=nh(e);o("Drawing"),mu(t,m,En(m,e.signatureSlots),d,{site:s.key,id:n.id,ext:u.ext,bytes:l,from:`${s.name} ${n.id} ${s.pageUrl(n.id)}`,artist:a.named.artist,source:ca(a.source),cut:h},{width:0,height:0},ti(t),Xu(t));let p=ge(t,e.name).find((b)=>b.key===le(n));if(p)wa(X(t),p,n,r,r3())}function s3(t,e){let n=Z.find((o)=>o.key===t.site),r=`${n?.name??t.site} ${t.id}`;if(!n||!e)return r;return`${Ht()?N.link:`${Si(n.ansi)}${N.link}${wt}`} ${zc(r,n.pageUrl(t.id))}`}async function bo(t,e,n){let r=e.flatMap((c)=>i3(t,c).map((u)=>({entry:c,shared:u})));if(r.length===0)return;let i=no(n),o=process.stdout.isTTY&&by(process.env),s=new Set,a=ci();for(let[c,{entry:u,shared:f}]of r.entries()){let l=`${u.name} · ${s3(f,o)}`,d=r.length>1?` · ${c+1}/${r.length}`:"",h=(m,p)=>a.set(`${m} ${l}${p?` · ${p}`:""}${d}`);try{await o3(t,u,f,i,AbortSignal.timeout(vE),h),a.say(` ▣ ${l}`),s.add(u)}catch(m){a.say(` ▢ ${l} — ${m instanceof Error?m.message:String(m)}`)}}a.done();for(let c of s){let u=(c.pictures??[]).find((f)=>ge(t,c.name).some((l)=>l.key===le(f)));if(u)Jo(t,c.name,le(u))}if(s.size>0)_e(t)}function EE(t,e,n){if(e.width!==t.width||e.height!==t.height)return!1;for(let r=0;r<t.width*t.height;r++)t.data[r*4+3]=e.data[r*4+n]??0;return!0}async function a3(t,e){let[,n,r]=/^(.+)_(\d+)$/.exec(t)??[],i=go(jr(),n??"local","cut",`${r??t}.png`);if(!hg(i)){if(!Gs())return;kE(yE(i),{recursive:!0}),await wc(e,i,AbortSignal.timeout(vE))}return Nr(new Uint8Array(Bs(i)),Re)}function c3(t,e){try{return Vn(Gt(new Uint8Array(Bs(go(t,`${e.stem}.png`)))))>0}catch{return!1}}function ef(t,e){return()=>Nr(new Uint8Array(Bs(go(t,e.original))),Re)}function ME(t,e){let n=ef(t,e);return()=>{let r=n(),i=Gt(new Uint8Array(Bs(go(t,e.cut))));return EE(r,i,0)?r:null}}async function rf(t,e,n,r,i,o,s,a){let c=X(t),u=Nt(c).palettes[e]?.pictures.find((f)=>f.key===n);if(!u?.original)return null;if(u.cut)return $a(t,e,u,ME(c,u),r,i,o,s,!1,a);if(Do(u)){let f=ef(c,u)();if(Vn(f)===0&&c3(c,u)){let l=await a3(n,go(c,u.original));if(!l||!EE(f,l,3))return null;return $a(t,e,u,()=>f,r,i,o,s,!0,a)}return $a(t,e,u,()=>f,r,i,o,s,!1,a)}return $a(t,e,u,ef(c,u),r,i,o,s,!1,a)}function xE(t,e,n,r,i,o){let s=X(t),a=Nt(s).palettes[e]?.pictures.find((u)=>u.key===n);if(!a?.original||Do(a))return!1;let c=a.cut?ME(s,a):ef(s,a);return T$(t,e,a,c,r,i,o)}var u3=/(?:^|[^0-9a-f])([0-9a-f]{32})(?:[^0-9a-f]|$)/i,l3=[[/yande\.re\/post\/show\/(\d+)/,"yande"],[/konachan\.(?:com|net)\/post\/show\/(\d+)/,"konachan"],[/danbooru\.donmai\.us\/(?:posts|post\/show)\/(\d+)/,"danbooru"],[/zerochan\.net\/(\d+)(?:[?#\s]|$)/,"zerochan"]];function mg(t){let e=/(\d+)_p(\d+)/.exec(t.source);return[...t.md5?[`md5:${t.md5}`]:[],...e&&t.source.includes("pximg")?[`pixiv:${e[1]}_p${e[2]}`]:[]]}function OE(t,e){let n=u3.exec(e.source)?.[1]?.toLowerCase();return[`post:${t.key}:${e.id}`,...e.md5?[`md5:${e.md5}`]:[],...n&&n!==e.md5?[`md5:${n}`]:[],...l3.flatMap(([r,i])=>{let o=r.exec(e.source)?.[1];return o?[`post:${i}:${Number(o)}`]:[]}),...e.family?[`family:${t.key}:${e.family}`]:[]]}function IE(t,e){let n=t.owner||t.named.artist[0]||"";return n!==""&&n===(e.owner||e.named.artist[0]||"")&&t.width===e.width&&t.height===e.height}function PE(t){let r=[];for(let o=0;o<8;o++){let s=Math.floor(o*t.height/8),a=Math.max(s+1,Math.floor((o+1)*t.height/8));for(let c=0;c<9;c++){let u=Math.floor(c*t.width/9),f=Math.max(u+1,Math.floor((c+1)*t.width/9)),l=0;for(let d=s;d<a;d++)for(let h=u;h<f;h++){let m=(d*t.width+h)*4,p=t.data[m+3]/255,b=0.299*t.data[m]+0.587*t.data[m+1]+0.114*t.data[m+2];l+=b*p+255*(1-p)}r.push(l/((f-u)*(a-s)))}}let i=0n;for(let o=0;o<8;o++)for(let s=0;s<8;s++)i=i<<1n|(r[o*9+s]>r[o*9+s+1]?1n:0n);return i.toString(16).padStart(16,"0")}function f3(t,e){let n=BigInt(`0x${t}`)^BigInt(`0x${e}`),r=0;while(n>0n)r+=Number(n&1n),n>>=1n;return r}function RE(t,e){if(t.width<=0||t.height<=0||e.width<=0||e.height<=0)return!1;return Math.abs(Math.log(t.width/t.height/(e.width/e.height)))<0.01&&f3(t.hash,e.hash)<=2}var g3={thumb:"tile",band:"band",match:"tile",show:"view",backdrop:"view",redraw:"view"},of;async function b3(t){if(t.job==="redraw")return rf(t.home,t.name,t.key,t.paint,t.blur,t.aligns,t.user);if(t.job==="show"){if(of?.from!==t.from){let s=Nr(new Uint8Array(pg(t.from)),Re);of={from:t.from,clear:Vn(s),inked:eh(s)}}let{image:r,fill:i,opacity:o}=y$(of.inked,t.colors,t.tone,t.width,t.height,t.blur,t.tune,t.coloring);return d3(h3(t.to),{recursive:!0}),NE(t.to,Ke(r)),{clear:of.clear,fill:i,opacity:o}}let e=Nr(new Uint8Array(pg(t.from)),Re);if(t.job==="backdrop"){mu(t.home,t.colors,t.tone,e,{...t.origin,bytes:new Uint8Array(pg(t.source)),cut:t.from!==t.source},t,t.blur,t.coloring);let r=t.tune&&ge(t.home,t.colors.name).find((i)=>i.key===le(t.origin));if(t.tune&&r)wa(X(t.home),r,t.tune,t.aligns??!0,t.user??t.home);return 0}if(t.job==="match")return{match:$E(e,t.colors),hash:PE(e)};if(t.job==="thumb")return C(t.to,Ke(o0(e,t.width,t.height))),0;let n=e.data.subarray(t.y*e.width*4,(t.y+t.height)*e.width*4);return NE(t.to,Ke({width:e.width,height:t.height,data:n})),0}function w3(t){t.on("message",async(e)=>{try{t.postMessage({id:e.id,value:await b3(e)})}catch(n){t.postMessage({id:e.id,error:n instanceof Error?n.message:String(n)})}})}class gg{worker;next=1;waiting=new Map;send(t){let e=this.next++;return new Promise((n,r)=>{let i=this.open();this.waiting.set(e,{ok:n,no:r}),i.ref(),i.postMessage({...t,id:e})})}close(){this.worker?.terminate(),this.worker=void 0,this.drop(Error("renderer closed"))}open(){if(this.worker)return this.worker;let t=new p3(import.meta.filename);t.unref(),t.on("message",({id:n,value:r,error:i})=>{let o=this.waiting.get(n);if(this.waiting.delete(n),this.waiting.size===0)t.unref();if(i!==void 0)o?.no(Error(i));else o?.ok(r)});let e=(n)=>{if(this.worker===t)this.worker=void 0;this.drop(n instanceof Error?n:Error("renderer stopped"))};return t.on("error",e),t.on("exit",()=>e(void 0)),this.worker=t,t}drop(t){for(let e of this.waiting.values())e.no(t);this.waiting.clear()}}class $c{lines=new Map;run(t){let e=g3[t.job],n=this.lines.get(e);if(!n)n=new gg,this.lines.set(e,n);return n.send(t)}close(){for(let t of this.lines.values())t.close();this.lines.clear()}}class bg{lines;constructor(t){this.lines=Array.from({length:Math.max(1,t)},()=>new gg)}async map(t){let e=[],n=0;return await Promise.all(this.lines.map(async(r)=>{while(n<t.length){let i=n++;try{e[i]=await r.send(t[i])}catch(o){e[i]=o instanceof Error?o:Error(String(o))}}})),e}close(){for(let t of this.lines)t.close()}}if(!m3&&AE)w3(AE);import{existsSync as $3,mkdtempSync as k3,readFileSync as y3,rmSync as TE,writeFileSync as v3}from"node:fs";import{tmpdir as S3}from"node:os";import{basename as FE,join as HE}from"node:path";var E3=6;class wg{dir;made=[];of(t,e){this.dir??=k3(HE(S3(),"ttheme-tint-"));let n=HE(this.dir,`${FE(t,".png")}.${e.slice(1).toLowerCase()}.png`);if(!$3(n)){let r=new Uint8Array(y3(t));v3(n,Yc(r,e)??Ri(Pi(Gt(r)),e)),this.made.push(n);while(this.made.length>E3)TE(this.made.shift(),{force:!0})}return n}clear(){if(this.dir)TE(this.dir,{recursive:!0,force:!0});this.dir=void 0,this.made.length=0}}function LE(t,e,n,r,i){if(ze(t)==="original")return e;let o=En(n,[...r]);return o.color===t.tone?e:i.of(e,o.color)}function CE(t,e){let n=FE(e);return t.find((r)=>n.startsWith(`${r.stem}.`)||n.startsWith(`${r.stem}@`))}var N3=2147483625,GE=2147483626,_n=2147483627,A3=-1073741831,BE=-1073741830,T3=-1073741829,H3=4;function F3(t,e,n,r,i){let o=Math.trunc,s=n.col*r.w,a=n.row*r.h,c=o((Math.max(i.x,s)+r.w-1)/r.w),u=o(Math.min(i.x+i.w,s+n.cols*r.w)/r.w),f=o((Math.max(i.y,a)+r.h-1)/r.h),l=o(Math.min(i.y+i.h,a+n.rows*r.h)/r.h);if(u<=c||l<=f)return;return{col:c,row:f,cols:u-c,rows:l-f,x:o((c*r.w-i.x)*t/i.w),y:o((f*r.h-i.y)*e/i.h),w:o((u-c)*r.w*t/i.w),h:o((l-f)*r.h*e/i.h)}}function L3(t){try{let e=O3(t,"r"),n=Buffer.alloc(24);return I3(e,n,0,24,0),M3(e),n.readUInt32BE(0)===2303741511?{width:n.readUInt32BE(16),height:n.readUInt32BE(20)}:void 0}catch{return}}class sf{ready=()=>{};cell={w:0,h:0};held;tints=new wg;sent=new Map;placed=new Map;viewed="";renders;scratch;made=0;bands=new Map;home;name;views;banded;files;static of(t,e,n,r){if(Ht(t)||!ls(t,r)||!(fs(t)||Di(t)))return;return new sf(t,e,n)}constructor(t,e,n){this.home=e,this.name=n,this.views=Di(t),this.banded=Ju(t),this.files=Yu(t)}get laid(){return this.cell.w>0}measured(t){if(this.cell.w===0&&t.w>0&&t.h>0)this.cell=t}load(){let t=X(this.home),e=He(t,this.name,P3()),n=[];try{n=Nt(t).palettes[this.name]?.pictures??[]}catch{}let r=e?CE(n,e.image):void 0;this.held=e&&r?{picture:r,image:e.image,opacity:e.opacity,cover:e.cover,at:qt.indexOf(e.position)+1||5}:void 0}draw(t,e,n,r,i,o={col:0,row:0,cols:r,rows:i}){if(this.cell.w===0)return"";let s=t[0],a=this.look(t,e,n,o,!this.views||o.cols===r&&o.rows===i);if(this.views){let u=r*this.cell.w,f=i*this.cell.h,l=a?`${s}|${a.image}|${a.opacity}|${u}|${f}|${a.box.w}|${a.box.h}|${a.box.x}|${a.box.y}|${this.held?.at??5}`:`${s}||1|${u}|${f}|0|0|0|0|5`;if(l===this.viewed)return"";return this.viewed=l,Ji(l)}let c=this.layer(N3,A3,"f=24",Buffer.from(ot(s)),o);if(a){let u=Math.max(0,Math.min(255,Math.round((1-a.opacity)*255)));c+=this.picture(a),c+=this.layer(GE,T3,"f=32",Buffer.from([...ot(s),u]),o)}else c+=this.drop(_n)+this.drop(GE);return c}resized(){this.sent.clear(),this.placed.clear(),this.viewed=""}clear(){let t=this.views&&this.viewed?Ji(""):"";for(let e of this.sent.keys())t+=fc(e);return this.resized(),t}close(){let t=this.clear();if(this.tints.clear(),this.renders?.close(),this.scratch)jE(this.scratch,{recursive:!0,force:!0});return t}look(t,e,n,r,i){let o=this.held;if(!o)return;let s={name:this.name,...re([...t]),waived:[...n]},a=LE(o.picture,o.image,s,e,this.tints),c=L3(a);if(!c)return;let u=Yo(c.width,c.height,r.cols*this.cell.w,r.rows*this.cell.h,100,o.at,o.cover&&i),f={...u,x:u.x+r.col*this.cell.w,y:u.y+r.row*this.cell.h},l=F3(c.width,c.height,r,this.cell,f);if(!l)return;return{image:a,opacity:o.opacity,...c,box:f,rect:l}}layer(t,e,n,r,i){let o=r.toString("base64"),s=`${o}|${i.col}|${i.row}|${i.cols}|${i.rows}`;if(this.placed.get(t)===s)return"";return this.sent.set(t,s),this.placed.set(t,s),`\x1B_Ga=t,${n},s=1,v=1,i=${t},q=2;${o}\x1B\\\x1B[${i.row+1};${i.col+1}H\x1B_Ga=p,i=${t},p=${t},c=${i.cols},r=${i.rows},C=1,z=${e},q=2\x1B\\`}picture(t){let{image:e,rect:n}=t;if(this.banded&&(2*n.y+n.h-t.height)**2>1){let o=this.band(t.image,n.y,n.h);if(!o.ready)return"";e=o.path,n={...n,y:0}}let r="";if(this.sent.get(_n)!==e){let o=Bl({id:_n,path:e,row:0,col:0,cols:0,rows:0,z:BE},this.files);if(o===void 0)return"";r+=o,this.sent.set(_n,e),this.placed.delete(_n)}let i=`${n.col};${n.row};${n.cols};${n.rows};${n.x};${n.y};${n.w};${n.h}`;if(this.placed.get(_n)!==i)r+=`\x1B[${n.row+1};${n.col+1}H\x1B_Ga=p,i=${_n},p=${_n},x=${n.x},y=${n.y},w=${n.w},h=${n.h},c=${n.cols},r=${n.rows},C=1,z=${BE},q=2\x1B\\`,this.placed.set(_n,i);return r}drop(t){if(!this.sent.has(t))return"";return this.sent.delete(t),this.placed.delete(t),fc(t)}band(t,e,n){let r=`${t}|${e}|${n}`,i=this.bands.get(r);if(i)return i;this.scratch??=x3(_E(R3(),"ttheme-edit-")),this.renders??=new $c;let o={path:_E(this.scratch,`band-${++this.made}.png`),ready:!1};this.bands.set(r,o),this.renders.run({job:"band",from:t,to:o.path,y:e,height:n}).then(()=>{o.ready=!0,this.ready()}).catch(()=>{});for(let[s,a]of this.bands){if(this.bands.size<=H3)break;if(a.ready&&a.path!==this.sent.get(_n))this.bands.delete(s),jE(a.path,{force:!0})}return o}}var wo=50;function st(t,e){return qe(t,e)}function kc(t){return St(t)>0.35?"#000000":"#ffffff"}function $g(t,e){return t.held!==void 0&&t.held-e.c>0.0005?t.held:void 0}function af(t,e,n,r){let i=e.mode==="tune"&&e.channel===ne,o=e.ratio(),{floor:s}=e.partner(),a=(p)=>Math.round(Math.log(Math.max(1,p))/Math.log(21)*(n-1)),c=a(o),u=s===void 0?-1:a(s),f=r===void 0?-1:a(r),l=i?"━":"─",d=Array.from({length:n},(p,b)=>b===c?t.bold("●"):b===f?"○":b===u?"┃":b<u?t.dim(l):l).join(""),h=`${o.toFixed(2)}:1`.padStart(6),m={kind:"channel",channel:ne};return`${st(m,i?t.bold("▸◐"):t.dim(" ◐"))} ${st({kind:"bar",channel:ne},d)} ${st(m,i?t.bold(h):t.dim(h))}`}function cf(t,e){if(!t.misses().has(e))return;if(ag(t.list,t.signature,t.waive,"bright-follows").includes(e))return e-T.length<8?"= makes the bright follow its normal":"= on the normal makes this follow it";return"f moves the colors the gate misses"}function uf(t,e,n){let r=ug(t.list,t.signature,t.waive,e),i=$g(t,n);if(i!==void 0)r.push({ok:void 0,text:`Chroma ○ ${i.toFixed(3)} is held while you tune — ${n.c.toFixed(3)} fits this lightness and hue`});return r}function lf(t){let e=(n,r)=>n.toFixed(r).replace(/^0(?=\.)/,"");return`${e(t.l,2)} ${e(t.c,3)} ${t.h.toFixed(0).padStart(3)}°`}function UE(t){return`${t.l.toFixed(2)} ${t.c.toFixed(3)} ${t.h.toFixed(0).padStart(3)}°`}function C3(t,e,n,r=wo){let i=lg(e.list,e.signature,e.waive).sort((u,f)=>Number(u.ok!==!1)-Number(f.ok!==!1)),o=i.filter((u)=>u.ok===!1).length,s=` ${t.dim("Gate")} ${o===0?t.dim("passes"):t.bold(`${o} ${o===1?"miss":"misses"}`)}`,a=r-4,c=i.flatMap((u)=>{let f=`${u.value} ${u.bound}`,l=` ${Nu(t,u.ok)} ${Ot(u.ok===!1?u.label:t.dim(u.label),t.dim(f),a-2)}`,d=[...new Set(u.slots)].map((p)=>Ge(p).name),h=u.slots[0],m=(p)=>h===void 0?p:st({kind:"slot",slot:h},p);return d.length>0?[m(l),m(` ${t.dim(tt(d.join(" · "),a-2))}`)]:[m(l)]});return[o===0?s:Ot(s,`${t.bold("n")} ${t.dim("next miss")}`,r-2),...c.slice(0,Math.max(0,n-1))]}function WE(t,e){let n=t-T.length;if(n>=0)return e===String(n)||e===`B${n}`||e===`K${n}`;return t===3&&e==="s"||t===2&&e==="c"}function ff(t,e,n,r){let i=r?bt("under"):"";if(n==="d")return`${t.fg(e.foreground)}${bt("dim")}${i}`;if(n==="b")return`${t.fg(e.foreground)}${bt("bold")}${i}`;if(n==="s")return`${t.bg(e.selection)}${t.fg(e.foreground)}${i}`;if(n==="c")return`${t.bg(e.cursor)}${i}`;let o=/^([BK]?)(\d+)$/.exec(n);if(!o)return`${t.fg(e.foreground)}${i}`;let s=e.ansi[Number(o[2])];if(o[1]==="K")return`${t.fg(e.ansi[0])}${t.bg(s)}${i}`;return`${t.fg(s)}${o[1]==="B"?bt("bold"):""}${i}`}function yc(t,e,n,r,i){let o=e.length-1,s=Math.max(0,Math.min(o,n)),a=i===void 0?-1:Math.max(0,Math.min(o,i));if(!t.color)return e.map((c,u)=>u===s?"●":u===a?"○":r?"━":"─").join("");return e.map((c,u)=>{let f=c??"#000000";if(u===s)return`${t.bg(f)}${t.fg(kc(f))}${N.on}${se}`;if(u===a)return c?`${t.bg(c)}${t.fg(kc(c))}${N.off}${se}`:`${t.fg("#aaaaaa")}${N.off}`;return c?`${t.fg(c)}█`:`${t.fg(r?"#777777":"#555555")}░`}).join("").concat(wt)}function df(t,e,n){return Array.from({length:n},(r,i)=>{let o=e.min+(e.max-e.min)*i/(n-1),s={...t,[e.key]:o};return Cn(s.l,s.c,s.h)?Qe(s.l,s.c,s.h):void 0})}function $o(t,e,n,r){return Math.round((t-e)/(n-e)*(r-1))}function kg(t){return lg(t.list,t.signature,t.waive).filter((e)=>e.ok===!1).length}function vc(t,e,n,r){if(n<3)return[];let i=kg(e),o=i===0?" Gate ✓ passes ":` Gate ✗ ${i} · n next `;return[t.dim(Jt(r,"top",[[2,o]])),...C3(t,e,n-1,r-1).slice(1).map((s)=>Je(t,s,r)),t.dim(Jt(r,"bottom"))]}var wr=0.98,Sc=0.12,j3=0.37,KE=0.74,_3=0.15,G3=-1073741828,yg=-1073741827,vg=-1073741826,B3=-1073741825,U3=2147483584,W3=["panel","plane","hue","contrast","mark","hue-thumb","contrast-thumb","origin","hue-origin","contrast-origin"],K3=4096;function Ec(t,e){return js(t,e,j3)}function mf(t,e,n){let r=Ec(t,n);return r>0.000001?Math.min(1,e/r):0}function Mc(t,e){return{width:t,height:e,data:new Uint8Array(t*e*4)}}function pi(t,e,n,r,i){let o=r[3]*i;if(o<=0||e<0||n<0||e>=t.width||n>=t.height)return;let s=(n*t.width+e)*4,a=t.data;if(o>=1){a[s]=r[0],a[s+1]=r[1],a[s+2]=r[2],a[s+3]=255;return}let c=a[s+3]/255,u=o+c*(1-o);for(let f=0;f<3;f++)a[s+f]=Math.round((r[f]*o+a[s+f]*c*(1-o))/u);a[s+3]=Math.round(u*255)}function br(t,e=1){return[...ot(t),e]}function Ws(t,e,n,r,i,o,s){let a=Math.abs(t-(n+i/2))-(i/2-s),c=Math.abs(e-(r+o/2))-(o/2-s);return Math.hypot(Math.max(a,0),Math.max(c,0))+Math.min(Math.max(a,c),0)-s}function ko(t,e,n,r){let i=[],o=[],s=Math.max(0,Math.floor(r?.x??0)),a=Math.max(0,Math.floor(r?.y??0)),c=Math.min(t,Math.ceil(r?r.x+r.w:t)),u=Math.min(e,Math.ceil(r?r.y+r.h:e));for(let f=a;f<u;f++)for(let l=s;l<c;l++){let d=n(l+0.5,f+0.5);if(d>0.002)i.push(f*t+l),o.push(Math.min(1,d))}return{at:Uint32Array.from(i),cover:Float32Array.from(o)}}function yo(t,e,n){for(let r=0;r<e.at.length;r++){let i=e.at[r];pi(t,i%t.width,Math.floor(i/t.width),n,e.cover[r])}}function Sg(t,e){return(n,r)=>Math.max(0,0.5-Ws(n,r,t.x,t.y,t.w,t.h,e))}function zE(t,e,n){return(r,i)=>Math.max(0,0.5-Math.abs(Ws(r,i,t.x,t.y,t.w,t.h,e)+n/2)+n/2)}var hf=new Map;function z3(t,e,n,r){let i=`${e.w}x${e.h} ${JE({...t,ground:"#000000",ink:"#000000",accent:"#000000"})}`,o=hf.get(i);if(o)return o;let{panel:s}=t,a={x:e.w,y:0,w:s.cols*e.w,h:s.rows*e.h},c=Math.round(e.h*0.45),u=Math.round(e.h*0.18),f=e.h*0.6,l=Math.max(1,Math.round(e.h/22)),d=(P)=>({x:(P.col-s.col+1)*e.w,y:(P.row-s.row)*e.h}),h=Math.max(1,Math.round(e.h*0.08)),m=d(t.tabs),p={x:m.x,y:m.y+h,w:t.tabs.cols*e.w,h:e.h-2*h},b=Math.floor(t.tabs.cols/t.tabs.count)*e.w,$=Math.max(1,Math.round(h/2)),k={x:p.x+t.tabs.active*b+$,y:p.y+$,w:(t.tabs.active===t.tabs.count-1?p.w-t.tabs.active*b:b)-2*$,h:p.h-2*$},v=d(t.field),S={x:v.x,y:v.y+h,w:t.field.cols*e.w,h:e.h-2*h},x=t.divider===void 0?void 0:{x:a.x+e.w*0.6,y:(t.divider-s.row)*e.h,w:a.w-e.w*1.2,h:l},M={shadow:ko(n,r,(P,L)=>{let A=Ws(P,L,a.x,u,a.w,a.h,c);return A>0&&A<f?(1-A/f)**2:0}),fill:ko(n,r,Sg(a,c),a),border:ko(n,r,zE(a,c,l),a),track:ko(n,r,Sg(p,p.h*0.3),p),segment:ko(n,r,Sg(k,k.h*0.3),k),field:ko(n,r,zE(S,S.h*0.3,l),S),divider:x&&ko(n,r,()=>1,x)};if(hf.size>8)hf.clear();return hf.set(i,M),M}function q3(t){let e=St(t.ground)<0.18;return{dark:e,surface:Rt(t.ground,t.ink,e?0.07:0.04)}}function D3(t,e){let n=Mc((t.panel.cols+2)*e.w,(t.panel.rows+1)*e.h),r=z3(t,e,n.width,n.height),{dark:i,surface:o}=q3(t);if(yo(n,r.shadow,[0,0,0,i?0.45:0.18]),yo(n,r.fill,br(o)),yo(n,r.border,br(t.ink,i?0.16:0.2)),yo(n,r.track,br(t.ink,i?0.06:0.07)),yo(n,r.segment,br(t.accent,i?0.24:0.2)),yo(n,r.field,br(t.ink,i?0.22:0.28)),r.divider)yo(n,r.divider,br(t.ink,i?0.12:0.16));return n}function J3(t,e,n){let r=Mc(Math.round(t.cols*n.w),Math.round(t.rows*n.h)),{width:i,height:o,data:s}=r,a=Math.round(n.h*0.3),c=Math.max(1,(t.cols-1)*n.w),u=(h)=>Math.min(1,Math.max(0,(h+0.5-n.w/2)/c)),f=t.rows*2-1,l=(h)=>wr-Math.min(1,Math.max(0,((h+0.5)/n.h*2-0.5)/f))*(wr-Sc),d=[];for(let h=0;h<o;h++){if(h%2===0){let m=l(h+0.5),p=Ec(m,e);d=Array.from({length:Math.ceil(i/2)},(b,$)=>Cn(m,u($*2+0.5)*p,e)??[0,0,0])}for(let m=0;m<i;m++){let b=(m<a||m>=i-a)&&(h<a||h>=o-a)?Math.min(1,Math.max(0,0.5-Ws(m+0.5,h+0.5,0,0,i,o,a))):1;if(b<=0)continue;let $=d[m>>1],k=(h*i+m)*4;s[k]=$[0],s[k+1]=$[1],s[k+2]=$[2],s[k+3]=Math.round(b*255)}}return r}function DE(t,e){let n=Math.max(4,Math.round(t.h*0.42));return{top:Math.round((t.h-n)/2),height:n,width:e*t.w}}function Y3(t,e){let n=Mc(t.cols*e.w,e.h),{top:r,height:i,width:o}=DE(e,t.cols),s=Array.from({length:o},(a,c)=>{let f=Math.min(1,Math.max(0,((c+0.5)/e.w-0.5)/Math.max(1,t.cols-1)))*360;return Cn(KE,js(KE,f,_3),f)??[0,0,0]});for(let a=r;a<r+i;a++)for(let c=0;c<o;c++){let u=Math.min(1,Math.max(0,0.5-Ws(c+0.5,a+0.5,0,r,o,i,i/2))),f=s[c];pi(n,c,a,[f[0],f[1],f[2],1],u)}return n}function V3(t,e,n){let r=Mc(t.cols*n.w,n.h),{top:i,height:o,width:s}=DE(n,t.cols),a=t.floor===void 0?-1:Math.round((t.floor*(t.cols-1)+0.5)*n.w),c=Math.max(2,Math.round(o*0.45)),u=i+Math.round((o-c)/2);for(let f=u;f<u+c;f++)for(let l=0;l<s;l++){let d=Math.min(1,Math.max(0,0.5-Ws(l+0.5,f+0.5,0,u,s,c,c/2))),h=a<0||l>=a;pi(r,l,f,br(e,h?t.lit?0.5:0.36:0.14),d)}if(a>=0){let f=Math.max(2,Math.round(n.w/5));for(let l=i-1;l<i+o+1;l++)for(let d=a-Math.floor(f/2);d<a-Math.floor(f/2)+f;d++)pi(r,d,l,br(e,0.85),1)}return r}function Z3(t,e,n,r,i,o,s){let a=Mc(t*s.w,e*s.h),c=Math.max(2,Math.round(i*0.3)),u=(l,d)=>Math.min(1,Math.max(0,l-d+0.5)),f=[0,0,0,0.5];for(let l=0;l<a.height;l++)for(let d=0;d<a.width;d++){let h=Math.hypot(d+0.5-n,l+0.5-r);if(o)pi(a,d,l,br(o),u(i-c,h));else pi(a,d,l,f,u(i-c,h)-u(i-c-1,h));pi(a,d,l,f,u(i+1,h)-u(i,h)),pi(a,d,l,[255,255,255,1],u(i,h)-u(i-c,h))}return a}function Us(t,e,n,r,i,o,s=B3){let a=Math.floor((e-r-2)/o.w),c=Math.floor((e+r+2)/o.w),u=Math.floor((n-r-2)/o.h),f=Math.floor((n+r+2)/o.h),l={row:u,col:a,cols:c-a+1,rows:f-u+1},d=Math.round((e-a*o.w)*2)/2,h=Math.round((n-u*o.h)*2)/2;return{name:t,key:`${l.cols}x${l.rows} ${d},${h} ${r} ${i??"-"}`,box:l,z:s,paint:()=>Z3(l.cols,l.rows,d,h,r,i,o)}}function JE(t){let{panel:e}=t,n=(i)=>`${i.row-e.row},${i.col-e.col},${i.cols}`,r=t.divider===void 0?"-":t.divider-e.row;return`${e.cols}x${e.rows} ${t.ground} ${t.ink} ${t.accent} ${n(t.tabs)},${t.tabs.active}/${t.tabs.count} ${n(t.field)} ${r}`}function X3(t,e){let n=`${e.w}x${e.h}`,r=Math.max(4,Math.round(e.h*0.34)),i=(l,d)=>(l.col+0.5+d*(l.cols-1))*e.w,o=(l)=>(l.row+0.5)*e.h,s=t.plane,a=(l)=>{let d=(wr-l)/(wr-Sc)*(s.rows*2-1);return s.row*e.h+(Math.min(s.rows*2-1,Math.max(0,d))+0.5)*e.h/2},c=a(s.l),u=[{name:"panel",key:`${n} ${JE(t)}`,box:{row:t.panel.row,col:t.panel.col-1,cols:t.panel.cols+2,rows:t.panel.rows+1},z:G3,paint:()=>D3(t,e)},{name:"plane",key:`${n} ${s.cols}x${s.rows} ${s.h.toFixed(2)}`,box:s,z:yg,paint:()=>J3(s,s.h,e.h>=24?{w:e.w/2,h:e.h/2}:e)},{name:"hue",key:`${n} ${t.hue.cols}`,box:{...t.hue,rows:1},z:yg,paint:()=>Y3(t.hue,e)},{name:"contrast",key:`${n} ${t.contrast.cols} ${t.contrast.floor??"-"} ${t.contrast.lit} ${t.ink}`,box:{...t.contrast,rows:1},z:yg,paint:()=>V3(t.contrast,t.ink,e)},Us("mark",i(s,mf(s.l,s.c,s.h)),c,r,void 0,e),Us("hue-thumb",i(t.hue,t.hue.h/360),o(t.hue),r,t.hue.color,e),Us("contrast-thumb",i(t.contrast,t.contrast.at),o(t.contrast),r,t.contrast.color,e)],f=t.origin;if(f){let l=Math.max(3,Math.round(r*0.55));u.push(Us("origin",i(s,mf(f.l,f.c,f.h)),a(f.l),l,f.color,e,vg),Us("hue-origin",i(t.hue,f.h/360),o(t.hue),l,f.color,e,vg),Us("contrast-origin",i(t.contrast,f.at),o(t.contrast),l,f.color,e,vg))}return u}function Q3(t,e){let r=e.toString("base64").match(new RegExp(`.{1,${K3}}`,"g"))??[""];return r.map((i,o)=>{let s=o<r.length-1?1:0;return o===0?`\x1B_Ga=t,f=100,i=${t},m=${s},q=2;${i}\x1B\\`:`\x1B_Gm=${s},q=2;${i}\x1B\\`}).join("")}function qE(t,e,n){return`\x1B[${e.row+1};${e.col+1}H\x1B_Ga=p,i=${t},p=${t},c=${e.cols},r=${e.rows},C=1,z=${n},q=2\x1B\\`}function Eg(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}class pf{cell={w:0,h:0};shown=new Map;static of(t,e){return Ht(t)||!ls(t,e)||!fs(t)?void 0:new pf}get ready(){return this.cell.w>0}measured(t){if(this.cell.w===0&&t.w>0&&t.h>0)this.cell=t}draw(t){if(!this.ready)return"";let e=t?X3(t,this.cell):[],n="";for(let r of e)n+=this.put(r);for(let[r,i]of this.shown)if(!e.some((o)=>o.name===r))n+=Eg(i.id),this.shown.delete(r);return n}clear(){let t="";for(let e of this.shown.values())t+=Eg(e.id);return this.shown.clear(),t}put(t){let e=`${t.box.row};${t.box.col};${t.box.cols};${t.box.rows}`,n=this.shown.get(t.name);if(n&&n.key===t.key){if(n.at===e)return"";return n.at=e,qE(n.id,t.box,t.z)}let r=U3+W3.indexOf(t.name)*2,i=n?.id===r?r+1:r;return this.shown.set(t.name,{key:t.key,id:i,at:e}),`${Q3(i,Ke(t.paint()))}${qE(i,t.box,t.z)}${n?Eg(n.id):""}`}}var xc=34,Mg=2,t5=6,bf=3,e5=7,VE="↑↓ L ←→ C ⇧←→ H tab ◐";function n5(t,e,n){let r="",i=0;for(let o of t){let s=i+G(o);if(s>e&&i<n)r+=i>=e&&s<=n?o:" ".repeat(Math.min(s,n)-Math.max(i,e));if(i=s,i>=n)break}return r}function wf(t){return t.reduce((e,n)=>e+G(n.text),0)}function $f(t,e,n){let r=[],i=0;for(let o of t){let s=G(o.text),a=Math.max(e,i),c=Math.min(n,i+s);if(c>a)r.push({...o,text:n5(o.text,a-i,c-i)});i+=s}return r}function r5(t,e,n){return[...$f(t,0,e),...n,...$f(t,e+wf(n),wf(t))]}function i5(t,e){return t.map((n)=>{let r=e&&n.sgr?`${n.sgr}${n.text}${me}`:n.text;return n.target?qe(n.target,r):r}).join("")}function ZE(t){return t<T.length?T[t]:pn[(t-T.length)%8]}function XE(t,e,n,r){let i=t.signature.includes(jn[n])?N.signature:e.color?N.swatch:" ";return e.color?`${e.fg(t.list[n])}${i}${r}`:i}function QE(t,e,n,r,i){return r.has(n)?e.bold(N.miss):t.changed(n)?e.color?`${bt("warn")}${N.on}${i}`:N.on:" "}function tM(t,e,n){return n?t.color?`${t.fg(e.cursor)}${N.gutter}${wt} `:`${N.gutter} `:" "}function o5(t,e,n,r,i,o){let s=r===t.slot(),a=s?e.fg(n.foreground):wt,c=ZE(r).padEnd(12),u=t.lch[r],f=`${tM(e,n,s)}${XE(t,e,r,a)} ${s?e.bold(c):c}${UE(u)} ${QE(t,e,r,o,a)}`,l=tt(f,i);return st({kind:"open",slot:r},s&&e.color?`${e.bg(n.selection)}${e.fg(n.foreground)}${l}${se}`:l)}var xg=8,eM=44;function Ic(t){return t>=eM?16:11}function YE(t,e,n,r,i,o){let s=Ic(i);if(!t.visible(r))return" ".repeat(s);let a=r===t.slot(),c=a&&e.color?e.fg(n.foreground):wt,u=t.lch[r],f=(p,b)=>p.toFixed(b).replace(/^0(?=\.)/,""),l=`${u.h.toFixed(0).padStart(3)}°`,d=i>=eM?`${f(u.l,2)} ${f(u.c,3)} ${l}`:`${f(u.l,2)} ${l}`,h=`${XE(t,e,r,c)} ${d}${QE(t,e,r,o,c)}`,m=a&&e.color?`${e.bg(n.selection)}${e.fg(n.foreground)}${h}${se}`:h;return st({kind:"open",slot:r},m)}function s5(t,e,n,r,i,o){let s=T.length+r,a=s+8,c=t.row===s,u=pn[r].padEnd(xg),f=t.linkOf(a)!==void 0?e.dim("⇠"):" ";return`${st({kind:"open",slot:s},`${tM(e,n,c)}${c?e.bold(u):u}`)}${YE(t,e,n,s,i,o)}${f} ${YE(t,e,n,a,i,o)}`}function nM(t){return 14+2*Ic(t)}function a5(t){let e=Ic(t)>=16;return[[2," ANSI "],[2+xg,e?" Normal 0–7 ":" Normal "],[5+xg+Ic(t),e?" Bright 8–15 ":" Bright "]]}function c5(t,e,n,r){let i=t.slot(),o=Ge(i),s=nM(r),a=s-2,c=` ${o.name}${i>=T.length?` · ${o.about}`:""} `,u=[` ${e.dim(mE(i))}`];if(i>=2){let l=_S(n,i).filter((m)=>m.count>0),d=l.length>0?l.map((m)=>`${m.name} ${m.count}`).join(" · "):"none",h=Ct("w",t.where?De(e,"w where"):e.dim("w where"));u.push(Ot(` ${e.dim("Shown in")} ${d}`,`${h} `,a))}let f=i-T.length;if(f===0||f===7||f===8||f===15){let l=t.lch[i].l,d=t.lch[0].l,h=t.lch[1].l,m=Math.abs(l-d)<=Math.abs(l-h)?"the background":"the text";u.push(` ${e.dim(`L ${l.toFixed(2)} reads near ${m}`)}`)}return[e.dim(Jt(s,"top",[[2,c]])),...u.map((l)=>Je(e,l,s)),e.dim(Jt(s,"bottom"))]}function gf(t,e){return wr-t*(wr-Sc)/(e*2-1)}function rM(t,e,n,r,i){let o=gf(Math.max(0,Math.min(e*2-1,t*2-0.5)),e),s=Math.max(0,Math.min(1,(n-0.5)/Math.max(1,r-1)));return{lightness:o,chroma:s*Ec(o,i)}}function u5(t,e,n,r,i,o){let s=(l)=>{let d=Math.max(0,Math.min(i*2-1,Math.round((wr-l.l)/(wr-Sc)*(i*2-1))));return{row:Math.floor(d/2),col:Math.round(mf(l.l,l.c,l.h)*(r-1))}},{row:a,col:c}=s(e),u=o?s(o):{row:-1,col:-1},f=(l,d)=>{return`#${(Cn(l,d*Ec(l,e.h),e.h)??[0,0,0]).map((m)=>m.toString(16).padStart(2,"0")).join("")}`};return Array.from({length:i},(l,d)=>{let h="";for(let m=0;m<r;m++){if(d===a&&m===c){h+=t.color?`${t.bg(n)}${t.fg(kc(n))}${N.on}${se}`:N.on;continue}let p=m/Math.max(1,r-1);if(d===u.row&&m===u.col){let b=f(gf(d*2+1,i),p);h+=t.color?`${t.bg(b)}${t.fg(kc(b))}${N.off}${se}`:N.off;continue}h+=t.color?`${t.fg(f(gf(d*2,i),p))}${t.bg(f(gf(d*2+1,i),p))}▀${se}`:"·"}return st({kind:"plane",row:d,rows:i},h)})}function iM(t,e,n){let r=t.slot(),i=t.lch[r],s=uf(t,r,i).filter((c)=>c.ok===!1||c.text.startsWith("Chroma ○")).flatMap((c)=>Et(c.text,n-2).map((u,f)=>`${f===0?c.ok===!1?e.bold(N.miss):e.dim(N.off):" "} ${u}`)),a=cf(t,r);return[...s.slice(0,3),...a?[e.dim(a)]:[]]}function oM(t,e,n){let r=t.pair(t.slot());if(!r)return;let i=t.slot()>=r.bright,o=ZE(i?r.normal:r.bright).toLowerCase(),s=`${r.lift>=0?"+":""}${r.lift.toFixed(2)}`,a=n-9,c=i?r.on?[`⇠ Linked to ${o} · L ${s}`,`⇠ ${o} · L ${s}`,`⇠ ${o}`]:[`Not linked to ${o}`,"Not linked"]:r.on?[`Bright follows · L ${s}`,"Bright follows"]:["Its bright moves on its own","Moves on its own"],u=c.find((f)=>G(f)<=a)??c[c.length-1]??"";return Ot(e.dim(u),Ct("l",`${e.bold("l")} ${e.dim(r.on?"unlink":"link")}`),n)}function sM(t,e,n){let r=t.slot(),i=t.list[r],o=t.lch[r],s=t.typing!==void 0?e.bold(`${t.typing}▏`):Ct("#",e.bold(gE(t.format,i,o))),a=t.start[r],c=e.color?`${e.fg(a)}${N.swatch}${wt} `:"";return Ot(s,a!==i?e.dim(`was ${c}${a}`):"",n)}function l5(t,e,n,r){let i=t.slot(),o=t.lch[i],s=t.list[i],a=n-4,c=e.dim("│"),u=(M)=>`${c} ${tt(M,a)} ${c}`,f=oM(t,e,a),l=6+(f?1:0),d=iM(t,e,a).slice(0,Math.max(0,r-l-bf)),h=Math.max(bf,Math.min(t5,r-l-d.length)),m=" L × C ",p=` H ${o.h.toFixed(0)}° `,b=Math.max(0,n-4-G(" L × C ")-G(p)),$=[`${e.dim("╭─")}${e.dim(" L × C ")}${e.dim("─".repeat(b))}${e.dim(p)}${e.dim("─╮")}`],k=t.origin();for(let M of u5(e,o,s,a,h,k?.lch))$.push(u(M));let v=mn[2];$.push(u(st({kind:"bar",channel:2},yc(e,df(o,v,a),$o(o.h,v.min,v.max,a),t.mode==="tune"&&t.channel===2,k&&$o(k.lch.h,v.min,v.max,a))))),$.push(u(af(e,t,Math.max(8,a-11),k?.ratio)));let S=(M,P)=>st({kind:"format",format:P},t.format===P?De(e,M):e.dim(` ${M} `));if($.push(u(`${S("Hex","hex")} ${S("RGB","rgb")} ${S("OKLCH","oklch")}`)),$.push(u(sM(t,e,a))),f)$.push(u(f));for(let M of d)$.push(u(M));let x=tt(` ${VE} `,n-4,!1);return $.push(`${e.dim("╰─")}${e.dim(x)}${e.dim("─".repeat(Math.max(0,n-4-G(x))))}${e.dim("─╯")}`),{lines:$.map((M)=>st({kind:"picker"},M))}}var Oc=[["Hex","hex"],["RGB","rgb"],["OKLCH","oklch"]];function f5(t,e,n,r){let i=t.lch[t.slot()],o=n-2,s=oM(t,e,o),a=6+(s?1:0),c=iM(t,e,o).slice(0,Math.max(0,r-a-bf)),u=Math.max(bf,Math.min(e5,r-a-c.length)),f=(M)=>` ${tt(M,o)} `,l=[f(Ot(e.dim("L × C"),e.dim(`H ${i.h.toFixed(0)}°`),o))];for(let M=0;M<u;M++)l.push(f(st({kind:"plane",row:M,rows:u}," ".repeat(o))));let d=l.length;l.push(f(st({kind:"bar",channel:2}," ".repeat(o))));let h=l.length,m=t.mode==="tune"&&t.channel===ne,p={kind:"channel",channel:ne},b=`${t.ratio().toFixed(2)}:1`.padStart(8),$=o-11;l.push(f(`${st(p,m?e.bold("◐"):e.dim("◐"))} ${st({kind:"bar",channel:ne}," ".repeat($))} ${st(p,m?e.bold(b):e.dim(b))}`));let k=l.length,v=Math.floor(o/Oc.length);l.push(f(Oc.map(([M,P],L)=>{let A=L===Oc.length-1?o-v*L:v,_=Math.floor((A-G(M))/2),q=`${" ".repeat(_)}${M}${" ".repeat(A-_-G(M))}`,B=t.format===P?e.color?e.accent(e.bold(q)):`[${M}]`.padEnd(A):e.dim(q);return st({kind:"format",format:P},B)}).join("")));let S=l.length;l.push(f(` ${sM(t,e,o-2)} `));let x=s?l.length:void 0;if(s)l.push(f(s));for(let M of c)l.push(f(M));return l.push(f(e.dim(VE))),{lines:l.map((M)=>st({kind:"picker"},M)),parts:{plane:{row:1,col:1,cols:o,rows:u},hue:{row:d,col:1,cols:o,rows:1},contrast:{row:h,col:3,cols:$,rows:1},tabs:{row:k,col:1,cols:o,rows:1},field:{row:S,col:1,cols:o,rows:1},divider:x}}}function d5(t,e,n,r,i,o){let s=t.slot(),a=t.lch[s],c=t.list[s],u=(h)=>({row:r+h.row,col:i+h.col,cols:h.cols,rows:h.rows}),f=(h)=>Math.log(Math.max(1,h))/Math.log(21),l=t.partner().floor,d=t.origin();return{panel:{row:r,col:i,cols:n.plane.cols+2,rows:o},ground:e.background,ink:e.foreground,accent:e.cursor,plane:{...u(n.plane),h:a.h,l:a.l,c:a.c},hue:{...u(n.hue),h:a.h,color:c},contrast:{...u(n.contrast),at:f(t.ratio()),floor:l===void 0?void 0:f(l),color:c,lit:t.channel===ne},tabs:{...u(n.tabs),active:Oc.findIndex(([,h])=>h===t.format),count:Oc.length},field:u(n.field),divider:n.divider===void 0?void 0:r+n.divider,origin:d&&{...d.lch,color:d.hex,at:f(d.ratio)}}}function h5(t,e,n,r,i,o,s,a){let u=o??1,f=s-1-u,l=u-2,d=12+2*Ic(r)-Mg,h=a?f5:l5,m=h(t,e,d,Number.POSITIVE_INFINITY),p=m.lines.length<=f||m.lines.length>l&&f>=l,b=p?f:l,$=m.lines.length<=b?m:h(t,e,d,b),k=p?u+1:u-$.lines.length,v=Array.from({length:s},(S,x)=>i[x]??"");return $.lines.forEach((S,x)=>{let M=k+x;if(M>=0&&M<s)v[M]=Ak(v[M],Mg,S)}),{lines:v,art:$.parts&&d5(t,n,$.parts,k,Mg,$.lines.length)}}function m5(t,e,n,r,i){let o=r.side,s=kg(t),a=t.changedOnly?e.warn(N.on):" ",c=s===0?e.dim("Gate ✓"):e.bold(`Gate ✗ ${s}`),u=Ot(` ${e.bold("Colors")} ${c}`,Ct("m",`${t.changedOnly?e.bold("⧩ changed"):e.dim("⧩ changed")}${a} `),o),f=i-1,l=t.misses(),d=nM(o),h=[],m,p=T.map((k,v)=>v).filter((k)=>t.visible(k));if(p.length>0){h.push(e.dim(Jt(d,"top",[[2," Base "]])));for(let k of p){if(k===t.slot())m=h.length;h.push(Je(e,o5(t,e,n,k,d-2,l),d))}}let b=pn.map((k,v)=>v).filter((k)=>t.visible(T.length+k)||t.visible(T.length+k+8));if(b.length>0){h.push(e.dim(Jt(d,p.length>0?"mid":"top",a5(o))));for(let k of b){if(t.row===T.length+k)m=h.length;h.push(Je(e,s5(t,e,n,k,o,l),d))}}if(p.length>0||b.length>0)h.push(e.dim(Jt(d,"bottom")));if(t.visible(t.slot()))h.push(...c5(t,e,r,o));let $=vc(e,t,f-h.length,d);return h.push(...Array.from({length:Math.max(0,f-h.length-$.length)},()=>""),...$),{lines:[u,...h.slice(0,f)],anchor:m===void 0?void 0:m+1}}function p5(t,e,n){let r=`${e.accent(N.current)} ${e.bold(t.options.title)} ${e.dim(`· ${t.options.name}`)}`,i=t.dirty(),o=t.changes(),s=e.warn(N.on),a=i?`${s} ${e.dim(o>0?`unsaved · ${o} changed`:"unsaved")}`:"",c=[t.resettable()?Ct("R",e.dim("Reset")):"",i?Ct("s",De(e,"Save")):""].filter(Boolean).join(" "),u=[r,a,c].filter(Boolean).join(" "),f=(h,m,p)=>Ct(h,p?De(e,m):e.dim(m)),d=[...t.options.find||t.pictures>0?[f("b",`▣ ${t.pictures>0?`${t.pictures} `:""}Picture`,t.pic&&(t.pictures>0||!!t.options.find))]:[],f("i","⌖ Inspect",t.inspect),`${f("u","↶",!1)} ${f("ctrl+r","↷",!1)}`,f("I","Import ▾",t.menu==="import"),...t.options.exports?[f("x","Export ▾",t.menu==="export")]:[]].join(" ");return Ot(u,`${d} `,n)}var g5={kind:"open",slot:0};function b5(t,e,n){return t.color?`${n?Cb:t.bg(e.background)}${t.fg(e.foreground)}`:""}function w5(t,e,n,r,i,o){let s=pc(r),a=b5(e,n,o),c=t.slot();return Array.from({length:r.rows},(u,f)=>{let l=s[f],d=[{text:" ",sgr:a}];if(l)l.forEach((p,b)=>{let $=i&&i.pane===r.id&&i.line===f&&i.run===b,k=e.color?$?`${a}${e.bg(n.foreground)}${e.fg(n.background)}`:`${a}${ff(e,n,p.role,Dp(p.role,c))}${t.where&&!qp(p.role,c)?bt("dim"):""}`:"";d.push({text:p.text,sgr:k,target:{kind:"run",spot:{pane:r.id,line:f,run:b}}})});let h=$f(d,0,r.width-1),m=r.width-wf(h);return m>0?[...h,{text:" ".repeat(m),sgr:a,target:g5}]:h})}function $5(t,e,n){let r=t.slotsHere();if(!r)return;let i=e.color?`${e.bg(n.background)}${e.fg(n.foreground)}`:"",o=e.color?`${i}${bt("dim")}`:"",s=(l)=>({text:l,sgr:o}),a="┌ Slots here ",c="└ enter its slot · esc ",u=[[s(`${a}${"─".repeat(xc-G(a)-1)}┐`)]],f=[["text",r.text]];if(r.ground!==r.text)f.push(["ground",r.ground]);for(let[l,d]of f){let h={kind:"open",slot:d},m=t.shown()[d],p=d<T.length?"":Ge(d).about;u.push([{text:"│ ",sgr:o,target:h},{text:l.padEnd(7),sgr:o,target:h},{text:N.swatch,sgr:e.color?`${i}${e.fg(m)}`:"",target:h},{text:" ",sgr:i,target:h},{text:Ge(d).name.slice(0,14).padEnd(14),sgr:i,target:h},{text:p.padEnd(xc-27),sgr:o,target:h},{text:" │",sgr:o,target:h}])}return u.push([s(`${c}${"─".repeat(xc-G(c)-1)}┘`)]),u.map((l)=>$f(l,0,xc))}function k5(t,e,n){if(!t.menu)return;let r=t.menu==="export"?["Share code","Add command","Palette file"]:["Another palette","A share code"],i=24,o=e.color?`${e.bg(n.background)}${e.fg(n.foreground)}`:"",s=e.color?`${o}${bt("dim")}`:"",a=t.menu==="export"?"Copy ":"Take from ",c=[[{text:`┌ ${a}${"─".repeat(Math.max(0,i-3-a.length))}┐`,sgr:s}]];return r.forEach((u,f)=>{let l=f===t.entry,d={kind:"entry",index:f};c.push([{text:"│",sgr:s},{text:` ${l?"▌":" "} ${u.padEnd(i-6)}`,sgr:l&&e.color?`${e.bg(n.selection)}${e.fg(n.foreground)}${bt("bold")}`:o,target:d},{text:"│",sgr:s}])}),c.push([{text:`└${"─".repeat(i-2)}┘`,sgr:s}]),c}var y5=["#ff5f57","#febc2e","#28c840"];function v5(t,e,n,r){let i=e.color?`${e.bg(aM(n))}${e.fg(n.foreground)}`:"",o=[{text:" ",sgr:i}];for(let u of y5)o.push({text:"●",sgr:e.color?`${i}${e.fg(u)}`:""},{text:" ",sgr:i});o.push({text:" ",sgr:i});let s=jS(),a=(t.scene%s.length+s.length)%s.length;s.forEach((u,f)=>{let l={kind:"scene",scene:f};o.push(f===a?{text:` ${u} `,sgr:e.color?`${i}${e.bg(Ei(n.background,n.foreground,"tab"))}${bt("bold")}`:"",target:l}:{text:` ${u} `,sgr:e.color?`${i}${bt("dim")}`:"",target:l},{text:" ",sgr:i})});let c="⇧←→ ";return[...o,{text:" ".repeat(Math.max(0,r-wf(o)-G(c))),sgr:i},{text:c,sgr:e.color?`${i}${bt("dim")}`:""}]}function aM(t){return Ei(t.background,t.foreground,"bar")}function S5(t,e,n){let{frame:r}=n,i=Ei(e.background,e.foreground,"line"),o=t.color?`${t.bg(cM(e))}${t.fg(i)}`:"",s=t.color?`${t.bg(aM(e))}${t.fg(i)}`:"",a=(u,f)=>u===r.row||u===r.row+r.rows-1||f===r.col||f===r.col+r.cols-1,c=[];for(let[u,f]of KS(n.rules))for(let[l,d]of f)c.push([u,l,[{text:d,sgr:a(u,l)?o:s}]]);return c}function cM(t){return Ei(t.background,t.foreground,"stage")}function uM(t,e){return mc(t,e,0)?.inner}function lM(t,e,n,r,i={}){let o=mc(e,n,t.scene);if(!o)return;let s=xe(r),a=t.shown(),c=re(a),u=re(i.chrome?[...i.chrome]:t.list),f=m5(t,s,u,o,n-1),l=t.mode==="tune"?h5(t,s,u,o.side,f.lines,f.anchor,n-1,r&&i.art===!0):{lines:f.lines,art:void 0},d=l.lines,h=i.behind===!0,m=t.inspect?zl(o,t.spot):void 0,p=s.color?s.bg(cM(u)):"",b=Array.from({length:n-3},()=>[{text:" ".repeat(o.width),sgr:p}]),$=(A,_,q)=>{let B=A-2;if(B>=0&&B<b.length)b[B]=r5(b[B],_,q)},k=o.side+1;for(let[A,_,q]of S5(s,u,o))$(A,_-k,q);for(let A of o.tiles)w5(t,s,c,A,m,h).forEach((_,q)=>{$(A.row+q,A.col-k,_)});$(o.title.row,o.title.col-k,v5(t,s,u,o.title.cols));let v=m?$5(t,s,c):void 0;if(m&&v){let A=o.tiles.find((q)=>q.id===m.pane),_=pc(A)[m.line]?.[m.run];if(_){let q=Math.max(0,Math.min(A.col-k+1+_.col,o.width-xc)),B=A.row+m.line,F=B+1,pt=F+v.length-2>n-2?B-v.length:F;v.forEach((Zt,it)=>{$(pt+it,q,Zt)})}}let S=k5(t,s,c);if(S){let A=Math.max(0,o.width-24-(t.menu==="import"?12:2));S.forEach((_,q)=>{$(2+q,A,_)})}let x=p5(t,s,o.width),M=s.dim("─".repeat(o.width)),P=s.dim("│"),L=[];for(let A=0;A<n-1;A++){let _=A===0?x:A===1?M:i5(b[A-2]??[],r);L.push(`${tt(d[A]??"",o.side)}${P}${_}`)}return{lines:L,art:l.art}}var fM=80,dM=24,Og=11;function E5(t,e,n,r){let i=$g(e,n);return mn.map((o,s)=>{let a=e.mode==="tune"&&s===e.channel,c=n[o.key],u=`${c.toFixed(o.digits)}${o.wraps?"°":""}`.padStart(6),f=yc(t,df(n,o,r),$o(c,o.min,o.max,r),a,o.key==="c"&&i!==void 0?$o(i,o.min,o.max,r):void 0),l=o.key.toUpperCase(),d={kind:"channel",channel:s};return`${st(d,a?t.bold(`▸${l}`):t.dim(` ${l}`))} ${st({kind:"bar",channel:s},f)} ${st(d,a?t.bold(u):t.dim(u))}`})}function M5(t,e){if(e.mode!=="tune"||e.slot()<T.length)return[];let n=_s.map((i)=>st({kind:"scope",scope:i},i!==e.scope?t.dim(i):De(t,i))),r=e.scoped().length;return[`${t.dim("Scope")} ${n.join(" ")}`,t.dim(r>1?`${r} slots move by the same step, each keeping its own color`:"This slot moves alone · a widens it")]}var hM={background:(t)=>t.background,foreground:(t)=>t.foreground,hue:(t)=>t.cursor,tint:(t)=>t.background,lightness:(t)=>t.ansi[4],chroma:(t)=>t.ansi[1],brights:(t)=>t.ansi[12]};function x5(t){return`oklch ${t.l.toFixed(3)} ${t.c.toFixed(3)} ${t.h.toFixed(0)}°`}function O5(t,e){return`${t.dim("oklch")} ${t.bold(`${e.l.toFixed(3)} ${e.c.toFixed(3)} ${e.h.toFixed(0)}°`)}`}function I5(t,e,n,r=wo){let i=e.misses(),o=re(e.list),s=e.slot(),a=(l)=>{let d=e.list[l],h=l===s,m=e.signature.includes(jn[l])?N.signature:t.color?N.swatch:" ",p=i.has(l)?N.miss:e.tone&&e.changed(l)?N.on:" ",$=`${t.color?`${t.fg(d)}${m}${h?t.fg(o.foreground):wt} `:`${m} `}${lf(e.lch[l])}${p}`;if(!h)return st({kind:"slot",slot:l},` ${$}`);return st({kind:"slot",slot:l},t.color?`${t.bg(o.selection)}${t.fg(o.foreground)} ${$}${se}`:`›${$}`)},c=(l)=>l?t.color?`${t.fg(o.cursor)}${N.gutter}${wt} `:`${N.gutter} `:" ",u=[t.dim(Jt(r,"top",[[2," Base "]]))];for(let l=0;l<T.length;l++){let d=l===e.row,h=T[l].padEnd(10);u.push(Je(t,`${st({kind:"slot",slot:l},`${c(d)}${d?t.bold(h):h}`)}${a(l)}`,r))}u.push(t.dim(Jt(r,"mid",[[2," ANSI "],[12," Normal 0–7 "],[29," Bright 8–15 "]])));for(let l=T.length;l<pr;l++){let d=l===e.row,h=pn[l-T.length].padEnd(10),m=st({kind:"slot",slot:l+(e.col===1?8:0)},`${c(d)}${d?t.bold(h):h}`);u.push(Je(t,`${m}${a(l)}${a(l+8)}`,r))}u.push(t.dim(Jt(r,"bottom")));let f=vc(t,e,n-u.length,r);return[...u,...Array.from({length:Math.max(0,n-u.length-f.length)},()=>""),...f]}function P5(t,e,n){let r=re(e.list),i=[` ${t.dim("Seeds")}`];ho.forEach((o,s)=>{let a=s===e.field,c=e.seeds[o.key],u=Array.from({length:Og},(b,$)=>{let k=o.min+(o.max-o.min)*$/(Og-1);return hM[o.key](mi({...e.seeds,[o.key]:k}))}),f=yc(t,u,$o(c,o.min,o.max,Og),a),l=`${c.toFixed(o.digits)}${o.wraps?"°":""}`.padStart(6),d=hM[o.key](r),h=a?t.color?`${t.fg(r.cursor)}${N.gutter}${wt} `:`${N.gutter} `:" ",m=o.label.padEnd(17),p={kind:"field",field:s};i.push(`${st(p,`${h}${a?t.bold(m):m}`)}${st({kind:"seed",field:s},f)}${st(p,` ${l} ${t.color?`${t.fg(d)}${N.swatch}${wt} `:""}${t.dim(d)}`)}`)}),i.push("");for(let o of Et("Seven seeds grow all twenty colors, each accent on the hue its ANSI role reads as — whatever the seeds, they pass the gate. enter moves on to tune each slot, and the seeds stay behind.",wo-4))i.push(` ${t.dim(o)}`);return i.push(""),[...i,...vc(t,e,n-i.length,wo)]}function bM(t,e,n,r,i,o){let s=Yt.indexOf(zi(i)),a=Yt.map((f,l)=>st({kind:"scene",scene:l},l!==s?t.dim(f.name):De(t,f.name))).join(" "),c=[Ot(a,t.dim("⇧←→"),n)],u=`${t.bg(e.background)}${t.fg(e.foreground)}`;for(let f of zi(i).lines){let l=us(f,n-2);if(!l)continue;if(c.length>=r)break;let d=t.color?l.map(([h,m])=>`${ff(t,e,m,WE(o,m))}${h}${me}${u}`).join(""):l.map(([h])=>h).join("");c.push(`${u} ${tt(d,n-2)} ${t.color?me:""}`)}return c}var R5=["Bk","Rd","Gr","Ye","Bl","Ma","Cy","Wh"];function mM(t,e,n,r,i,o,s){let a=(i-o)/(s-1),c=wM(e),u=re(n),f=(l)=>Math.min(s-1,Math.max(0,Math.round((i-r(xt(l)))/a)));return Array.from({length:s},(l,d)=>{let m=`${(d%2===0?(i-a*d).toFixed(i>=1?1:2).replace(/^0(?=\.\d\d)/,""):"").padStart(4)} ${t.dim(d%2===0?"┤":"│")}`;for(let p=0;p<8;p++){let b=[" "," "," "," "," "],$=u.ansi[p],k=u.ansi[p+8],v=f($)===d,S=f(k)===d,x=(P)=>{if(P===1&&v)return t.color?`${t.fg($)}${N.on}`:N.on;if(P===3&&S)return t.color?`${t.fg(k)}${N.off}`:N.off;return b[P]},M=[0,1,2,3,4].map(x).join("");m+=c.has(p)?t.color?`${t.bg(u.selection)}${M}${se}`:M:`${M}${t.color?wt:""}`}return m})}function wM(t){let e=t.mode==="tune"?t.scoped():[t.slot()];return new Set(e.filter((n)=>n>=T.length).map((n)=>(n-T.length)%8))}function N5(t,e){let n=wM(e);return` ${R5.map((r,i)=>n.has(i)?t.bold(` ${r} `):t.dim(` ${r} `)).join("")}`}function A5(t,e){let n=re(e),r=Array.from({length:40},(o,s)=>{let a=s*9+4.5,c=-1,u=999;for(let[f,l]of Object.entries(Oe)){let d=Ie(a,l.center);if(d<=l.width&&d<u)u=d,c=Number(f)}return c<0?" ":t.color?`${t.fg(n.ansi[c])}─`:"─"}).join(""),i=(o,s)=>{let a=Array.from({length:40},()=>" ");for(let c of Object.keys(Oe).map(Number)){let u=n.ansi[c+o],f=Math.min(39,Math.round(xt(u).h/9));a[f]=t.color?`${t.fg(u)}${s}${wt}`:s}return` ${a.join("")}`};return[`${t.bold("Hue")} ${t.dim("0° 90° 180° 270° 360°")}`,`${t.dim("bands")} ${r}${t.color?wt:""}`,i(0,N.on),i(8,N.off)]}function T5(t,e,n){let r=gr(n,e.signature,e.waive),i=(a)=>Ge(T.length+a).name,o=(a)=>xt(n[T.length+a]).h.toFixed(0),s=[...Dn(r).filter(({gap:a})=>a>25).map(({normal:a,gap:c})=>`${i(a)} ${o(a)}° → bright ${o(a+8)}° · ${c.toFixed(0)}° apart · ≤ 25°`),...xr(r).map(({slot:a,over:c})=>{let u=Oe[bn(a)];return`${i(a)} ${o(a)}° · ${c.toFixed(0)}° outside ${u.name} ${u.center}±${u.width}°`}),...Jn(r).map(([a,c])=>`${i(a)} and ${i(c).toLowerCase()} read as one color`)];return s.length>0?s.map((a)=>`${t.bold(N.miss)} ${a}`):[t.dim(`${N.ok} Every accent keeps its role and its bright`)]}function pM(t,e,n,r,i){let o=e.shown(),s=Math.max(...o.slice(T.length).map((u)=>xt(u).c)),a=Math.max(0.2,Math.ceil(s/0.05)*0.05),c=[Ot(t.bold("Lightness"),t.dim("● normal ○ bright"),n),...mM(t,e,o,(u)=>u.l,1,0.3,8),N5(t,e)];if(i)c.push("",t.bold("Chroma"),...mM(t,e,o,(u)=>u.c,a,0,5),"",...A5(t,o));return[...c,...T5(t,e,o)].slice(0,r)}function H5(t,e,n){let r=(i,o)=>st({kind:"view",view:o},e.view!==o?t.dim(` ${i} `):De(t,i));return Ot(`${r("Slot","slot")}${r("Relations","relations")}`,Ct("g",`${t.bold("g")} ${t.dim("switch")}`),n)}function F5(t,e,n,r){let i=e.slot(),o=e.list[i],s=e.lch[i],a=e.start[i],{name:c,about:u}=Ge(i),f=e.signature.includes(jn[i]),l=Math.max(8,Math.min(64,n-12));if(e.view==="relations"&&e.mode!=="tune")return[H5(t,e,n),"",...pM(t,e,n,r-2,!0)];let d=i>=T.length?t.dim("Uses underlined below"):f?t.dim("◆ signature"):"",h=[Ot(`${t.bold(c)} ${t.dim(u)}`,e.view==="relations"?"":d,n),""],m=t.color?`${t.fg(o)}${"█".repeat(8)}${wt} `:"",p=e.typing!==void 0?`${t.bold(`${e.typing}▏`)}`:void 0,[b,$,k]=ot(o);if(h.push(`${m}${p??O5(t,s)}`),h.push(`${m}${t.dim(`${o} · rgb ${b} ${$} ${k}`)}`),e.view!=="relations"){let M=t.color?`${t.fg(a)}${N.swatch}${wt} `:"";h.push(`${m}${a!==o?t.dim(`was ${M}${x5(e.lchOf(a)).slice(6)} · ${a}`):t.dim("as it opened")}`)}h.push(""),h.push(...E5(t,e,s,l),af(t,e,l));let v=M5(t,e);if(v.length>0)h.push(...v);if(e.view==="relations")return h.push("",...pM(t,e,n,r-h.length-1,!1)),h;h.push("");for(let M of uf(e,i,s))Et(M.text,n-2).forEach((P,L)=>{h.push(`${L===0?Nu(t,M.ok):" "} ${M.ok===!1?P:t.dim(P)}`)});let S=cf(e,i);if(S)h.push(t.dim(` ${S}`));let x=r-h.length-1;if(x>=3)h.push("",...bM(t,re(e.shown()),n,x,e.scene,i));return h}function L5(t,e,n,r){return[Ot(`${t.bold("Sample")} ${t.dim("what the seeds grow")}`,"",n),"",...bM(t,re(e.list),n,r-2,e.scene,-1)]}var C5=[["Slots","↑↓ slot · ←→ normal or bright · home end · pgup the base colors · pgdn the ANSI ones · n N the next and last miss"],["Tune","enter or tab opens the picker over the list, under the slot · ↑↓ lightness · ←→ chroma · ⇧←→ hue by 5, , . by 1 · pgup pgdn lightness ×5 · tab ◐ contrast · home end the ends · 0-9 jump · enter keeps · esc undoes · a click outside it keeps"],["Contrast","◐ moves lightness until the ratio to the color it is read against changes · home the gate’s floor · 1-9 that ratio"],["Chroma","stops at the sRGB edge · what lightness or hue takes away comes back while you tune, where it fits again (○)"],["Scope","a while tuning: this, pair, normals, brights or accents — the slots in it move by the same step, each keeping its own color"],["Relations","g shows the lightness, chroma and hue of every ANSI color at once, and the relations the gate checks"],["Sample","⇧←→ another tab · the slot under the cursor is underlined where it is used · w dims the rest"],["Inspect","i, or a click on the sample, finds the slots a spot uses · ←→↑↓ move · enter goes to the slot · esc leaves"],["Link","l makes a bright follow its normal — tuning the normal moves it, tuning the bright alone unlinks it · = snaps it to its normal"],["Filter","m only the slots that changed · n and N walk the gate misses listed under the slots"],["Export","x copies the share code, an add command or the palette file · I takes colors from another palette or a share code"],["Type","# then #rrggbb, rgb(r g b) or oklch(l c h) — a paste works too"],["Slot","c copies · v pastes · r puts it back as it opened, R all of them · = the bright follows its normal · * marks it a signature color"],["Palette","f moves the colors the gate misses · o takes another palette’s colors"],["Gate","✗ marks every slot whose own checks miss, and each miss names its slots"],["History","u undo · ctrl+r redo"],["Pictures","p finds one on the boorus, tried on in these colors · b shows or hides it behind the editor · drop a picture on the window, or paste one, its path or its link · ctrl+v takes the clipboard’s"],["Compare","space shows the colors you started from, on the terminal too"],["Save","s saves · esc cancels, asking first when something changed"]];function j5(t,e,n){let r=[` ${t.bold("Help")}`,""];for(let[i,o]of C5.filter(([s])=>s!=="Pictures"||e.options.find))Et(o,n-16).forEach((s,a)=>{r.push(` ${t.bold((a===0?i:"").padEnd(11))} ${s}`)});return r}function _5(t,e,n,r){let i=e.choices(),o=e.options.palettes?.length??0,s=e.filter?`${t.bold(e.filter)}▏`:t.dim("type to filter"),a=[Ot(` ${t.bold("Take colors from")} ${s}`,t.dim(`${i.length}/${o}`),n),""],c=r-2,u=Math.max(0,Math.min(e.pick-Math.floor(c/2),i.length-c)),f=Math.min(40,Math.max(12,...i.map((l)=>G(l.name))));if(i.slice(u,u+c).forEach((l,d)=>{let h=u+d===e.pick,m=l.colors,p=t.color?`${t.bg(m.background)} ${[...m.ansi].map((k)=>`${t.fg(k)}${N.swatch}`).join("")} ${t.fg(m.foreground)}Aa ${se}`:"",b=h?"▌ ":" ",$=l.name.padEnd(f);a.push(st({kind:"choice",index:u+d},`${b}${h?t.bold($):$} ${p}`))}),i.length===0)a.push(` ${t.dim(`No palettes match '${e.filter}'`)}`);return a}var G5=new Set(["enter","s","?","g","a","i"]);function gM(t,e,n){let r="EDIT",i="",o=[],s="";if(e.quitting)r="EDIT (QUIT)",i=e.added>0?`Discard changes and ${e.added} ${e.added===1?"picture":"pictures"}?`:"Discard changes?",o=[["y","discard"],["n","keep editing"]];else if(e.typing!==void 0)r="EDIT (TYPE)",i=t.dim("#rrggbb, rgb(r g b) or oklch(l c h)"),o=[["enter","set"],["ctrl+u","clear"]],s="esc back";else if(e.overlay==="keys")r="HELP",s="any key closes";else if(e.overlay==="open")r="EDIT (OPEN)",o=[["↑↓","palette"],["a-z","filter"],["enter","take its colors"]],s="esc close";else if(e.menu)r=e.menu==="export"?"EDIT (EXPORT)":"EDIT (IMPORT)",o=[["↑↓","item"],["enter","choose"]],s="esc close";else if(e.compare)r="EDIT (BEFORE)",i="The colors you started from",o=[["space","back to yours"]],s="esc back";else if(e.mode==="seeds")r="EDIT (SEEDS)",o=[["↑↓","seed"],["←→","step"],["⇧←→","×5"],["enter","tune the slots"],["o","open a palette"],["p","picture"],["?","keys"]],s="esc cancel";else if(e.mode==="tune")r="EDIT (TUNE)",o=[["↑↓","L"],["←→",e.channel===ne?"ratio":"C"],["⇧←→","H"],["tab","◐"],...e.slot()>=T.length?[["a","scope"]]:[],[e.channel===ne?"1-9":"0-9",e.channel===ne?"ratio":"jump"],["#","type"],["enter","keep"]],s="esc undo";else if(e.inspect)r="EDIT (INSPECT)",o=[["←→↑↓","spot"],["⇧←→","tab"],["enter","its slot"],["i","leave"]],s="esc leave";else o=[["↑↓","slot"],["←→","normal or bright"],["enter","tune"],["i","inspect"],["l","link"],["m","changed"],["g",e.view==="slot"?"relations":"slot"],...e.misses().size>0?[["n","next miss"]]:[],["#","type"],["f","fix"],["p","picture"],["b","picture layer"],["x","export"],["u","undo"],["s","save"],["?","keys"]],s="esc cancel";if(!e.options.find)o=o.filter(([u])=>u!=="p"&&u!=="b");if(!e.options.exports||!e.roomy)o=o.filter(([u])=>u!=="x");if(!e.roomy)o=o.filter(([u])=>u!=="i"&&u!=="m");if(e.notice)i=t.warn(e.notice),o=[];let a=`${De(t,r)}${t.color?" ":" "}`,c=s?Ct(s.split(" ")[0],`${t.bold(s.split(" ")[0])} ${t.dim(s.split(" ").slice(1).join(" "))}`):"";for(;;){let u=[i,...o.map(([d,h])=>Ct(d,`${t.bold(d)} ${t.dim(h)}`))].filter(Boolean),f=`${a}${u.join(" ")}`,l=-1;if(o.forEach(([d],h)=>{if(h>0&&!G5.has(d))l=h}),G(f)+G(s)+3<=n||l<0)return s?Ot(f,c,n):tt(f,n);o=o.filter((d,h)=>h!==l)}}function B5(t,e,n,r,i={}){let o=xe(r);if(e<fM||n<dM){let p=[o.bold("ttheme palette editor"),`Needs ${fM}×${dM} — now ${e}×${n}`,o.dim("esc cancels")];return{lines:Array.from({length:n},(b,$)=>tt(p[$]??"",e)),art:void 0}}if(t.viewport(e,n),!t.overlay&&t.mode!=="seeds"&&t.view==="slot"){let p=lM(t,e,n,r,i);if(p)return{lines:[...p.lines,gM(o,t,e)],art:p.art}}let s=t.failing().length,a=s===0?"✓ Passes the gate":`✗ ${s} ${s===1?"miss":"misses"} in the gate`,c=t.pictures>0?o.dim(`▣ ${t.pictures} ${t.pictures===1?"picture":"pictures"} `):"",u=t.resettable()?`${Ct("R",o.dim("Reset"))} `:"",f=`${t.dirty()?`${o.warn(N.on)} unsaved `:""}${u}${c}${o.dim(a)}`,l=`${o.accent(N.current)} ${o.bold(t.options.title)} ${o.dim(`· ${t.options.name}`)}`,d=n-4,h;if(t.overlay==="keys")h=j5(o,t,e);else if(t.overlay==="open")h=_5(o,t,e,d);else{let p=e-wo-2,b=t.mode==="seeds"?P5(o,t,d):I5(o,t,d),$=t.mode==="seeds"?L5(o,t,p,d):F5(o,t,p,d);h=Array.from({length:d},(k,v)=>`${tt(b[v]??"",wo)}${o.dim("│")} ${tt($[v]??"",p)}`)}let m=[Ot(l,f,e),""];for(let p=0;p<d;p++)m.push(tt(h[p]??"",e));return m.push("",gM(o,t,e)),{lines:m,art:void 0}}var U5=new Set(["tab","a","#","l","enter","esc"]),W5=new Set(["picker","plane","bar","channel","format","scope","open","slot"]);function K5(t){if(!t)return!0;return t.kind==="key"?!U5.has(t.key):!W5.has(t.kind)}function z5(t,e,n){if(n.action==="wheel"){if(!n.sideways)t.scroll(n.wheel);return}if((n.action==="press"||n.action==="drag")&&n.button!=="left")return;if(n.action==="press"&&t.overlay==="keys"){t.press("esc");return}let r=e?.target;if(n.action==="press"&&t.mode==="tune"&&t.roomy&&!t.overlay&&K5(r))t.dismiss();if(!e||!r)return;let i=e.width>1?(e.exact.x-0.5)/(e.width-1):0;if(n.action==="release"){if(!e.inside)return;if(r.kind==="key")t.press(r.key);else if(r.kind==="entry")t.choose(r.index);else if(n.count===2&&r.kind==="slot"&&t.mode==="list")t.press("enter");else if(n.count===2&&r.kind==="choice"&&t.overlay==="open")t.press("enter");return}if(r.kind==="plane"){let o=rM(r.row+e.exact.y,r.rows,e.exact.x,e.width,t.lch[t.slot()].h);t.plane(o.lightness,o.chroma)}else if(r.kind==="bar")t.slide(r.channel,i);else if(r.kind==="seed")t.sow(r.field,i);else if(n.action!=="press")return;else if(r.kind==="slot")t.select(r.slot);else if(r.kind==="open")t.openSlot(r.slot);else if(r.kind==="run")t.point(r.spot);else if(r.kind==="entry")t.entry=r.index;else if(r.kind==="format")t.format=r.format;else if(r.kind==="channel")t.grip(r.channel);else if(r.kind==="scope")t.scopeTo(r.scope);else if(r.kind==="choice"){if(t.overlay==="open")t.pick=r.index}else if(t.typing===void 0&&!t.overlay&&!t.quitting){if(r.kind==="field"&&t.mode==="seeds")t.field=r.field;else if(r.kind==="view"&&t.mode!=="seeds")t.view=r.view;else if(r.kind==="scene")t.scene=r.scene}}var q5=[Rl,Hn,li,fr];async function $M(t,e){let n=new fg(t),r=e.backdrop,i=e.layer,o=(a)=>n.typing===void 0&&Vl(a),s=e.hosted?{modes:[fr,...fi()],assume:[Hn,li],burst:o}:{modes:[...q5,...fi()],burst:o};return di(s,async(a)=>{let c=!1,u=!1,f=new Map,l=new Op,d=await a.ask(`${em(un,"")}${fi().length>0?Zv:""}\x1B[c`,(S)=>{if(S.kind==="color"){f.set(S.code,S.value);return}return l.see(S)},1000);if(d?.cell)a.pixels(d.cell);let h=my(f),m=h.map((S,x)=>S??n.start[x]),[p,b]=m;if(!h[3])m[3]=Ei(p,b,"selection");let $=new io({write:(S)=>a.write(S),view:()=>{if(c)return;let{lines:S,art:x}=B5(n,a.cols,a.rows,e.color,{behind:n.pic&&r?.laid===!0,art:i?.ready===!0,chrome:m});return{lines:S,after:()=>`${(n.pic?r?.draw(n.shown(),n.signature,n.waive,a.cols,a.rows,uM(a.cols,a.rows)):r?.clear())??""}${i?.draw(x)??""}`}}}),k=(S=!1)=>{if(S)$.soon();else $.request()},v=async(S)=>{let x=t.find;if(!x)return;c=!0,a.write(`${r?.clear()??""}${i?.clear()??""}`);try{n.found(await x(n.edited(),S))}catch(M){n.notice=M instanceof Error?M.message:String(M)}if(u)return;c=!1,r?.load(),$.reset(Yi),k()};if(a.write(Yi),a.onResize(()=>{r?.resized(),a.write(i?.clear()??""),$.reset(Yi),$.request()}),r)r.load(),r.ready=()=>$.request();if(r||i){let S=new Qa;a.ask(Il,(x)=>S.see(x),1000).then((x)=>{if(x)r?.measured(x),i?.measured(x);$.request()})}k();try{let{edited:S}=await a.loop((x)=>{if(c)return;if(x.kind==="paste")n.paste(x.text);else if(x.kind==="key")n.press(x.key);else if(x.kind==="mouse")z5(n,$.point(x),x);if(n.copied!==void 0)a.write(`\x1B]52;c;${Buffer.from(n.copied).toString("base64")}\x07`),n.copied=void 0;if(n.result)return{edited:n.result==="saved"?n.edited():void 0};let M=n.wants;if(M)n.wants=void 0,v(M.start);return},()=>{if(!c)k(!0)});return S}finally{u=!0,$.stop(),a.write(`${r?.close()??""}${i?.clear()??""}`)}})}import{spawn as s4}from"node:child_process";import{createHash as HM}from"node:crypto";import{existsSync as Rc,mkdirSync as a4,mkdtempSync as c4,readFileSync as u4,rmSync as kf}from"node:fs";import{homedir as l4,tmpdir as f4}from"node:os";import{basename as d4,dirname as h4,join as Gn}from"node:path";import{pathToFileURL as vM}from"node:url";import{existsSync as D5,readFileSync as J5,statSync as Y5}from"node:fs";import{join as kM}from"node:path";function V5(t,e){try{return JSON.parse(J5(kM(on(t),e),"utf8"))}catch{return{}}}function Z5(t,e,n){C(kM(on(t),e),`${JSON.stringify(n)}
|
|
722
|
+
`)}class Ig{caches=new Map;unsaved=new Set;owners=new Map;crediting=new Map;inflight=new Map;home;catalog;entry;signal;credited;constructor(t){this.home=t.home,this.catalog=t.catalog,this.entry=t.entry,this.signal=t.signal,this.credited=t.credited}matesOf(t,e){return this.owners.get(t.key)?.get(e)??[]}async transparent(t,e){let n=this.keep(t,"probes.json"),r=n[e.id];if(r!==void 0)return r;try{let i=await la(t,e,this.signal),o=Ti(t,e),s=(i===void 0?await B0(o.site,o.url,this.signal):i)?.alpha===!0;return n[e.id]=s,this.unsaved.add(`${t.key}/probes.json`),s}catch{return!1}}save(){for(let t of this.unsaved){let[e,n]=t.split("/"),r=Z.find((i)=>i.key===e);if(r)Z5(r,n,this.keep(r,n))}this.unsaved.clear()}owned(t,e,n){this.keep(t,"owners.json")[e]=n,this.unsaved.add(`${t.key}/owners.json`)}credit(t,e){let{site:n,post:r}=t;if(!iu(n,r))return Promise.resolve();let i=Ne(n,r.id),o=this.crediting.get(i);if(!o)o=this.credits(t,e).finally(()=>this.crediting.delete(i)),this.crediting.set(i,o);return o}async mateOwners(t){let e=this.owners.get(t.key);if(e)return e;let n=P$(this.home),r=this.keep(t,"owners.json"),i=this.catalog.palettes.flatMap((c)=>{let u=n.get(c.name);return c.group===this.entry.group&&c.name!==this.entry.name&&u?.site===t.key?[{name:c.name,id:u.id}]:[]}),o=await Promise.all(i.map(async(c)=>{let u=r[c.id];if(u!==void 0)return{...c,owner:u};try{return{...c,owner:(await Go(t,c.id,this.signal))?.owner??""}}catch{return}})),s=new Map;for(let c of o)if(c)r[c.id]=c.owner,s.set(c.name,c.owner);this.unsaved.add(`${t.key}/owners.json`);let a=F0(s);return this.owners.set(t.key,a),a}async cached(t,e,n,r){if(D5(e))return Y5(e).size;let i=this.inflight.get(e);if(i)return i;let o=(async()=>{let s=await au(t,n,this.signal,r);return C(e,s),s.length})();this.inflight.set(e,o);try{return await o}finally{this.inflight.delete(e)}}keep(t,e){let n=`${t.key}/${e}`,r=this.caches.get(n);if(!r)r=V5(t,e),this.caches.set(n,r);return r}async credits({site:t,post:e},n){let r=this.keep(t,"credits.json"),i=r[e.id];if(!i){try{i=await ru(t,e.id,n)}catch{return}if(!i?.owner)return;r[e.id]=i,this.unsaved.add(`${t.key}/credits.json`)}ua(e,i),this.credited()}}import{rmSync as X5}from"node:fs";import{join as Q5}from"node:path";var Ks=2147483645,Pc=2147483646,yM=-1073741827,t4=-1073741828,e4=16,n4=0.4,r4=3221225472,i4=256;function o4(t){let e=/^(\d+) (\d+)$/.exec(t??"");return e&&(Number(e[1])>0||Number(e[2])>0)?{x:Number(e[1]),y:Number(e[2])}:void 0}var Pg=o4(process.env.TTHEME_BG_MARGIN);class Rg{screen;gliding;sent=new Map;placed=new Map;covered="";viewed="";bands=Ju(process.env);files=Yu(process.env);moves=wy(process.env);layers=fs(process.env);wipes=$y(process.env);views=Di(process.env);bandFiles=new Map;nextBand=r4;view;grid;background;renders;scratch;signal;write;constructor(t){this.view=t.view,this.grid=t.grid,this.background=t.background,this.renders=t.renders,this.scratch=t.scratch,this.signal=t.signal,this.write=t.write,this.screen=new io({write:(e)=>this.write(e),view:()=>this.frame(),beat:()=>{this.view.beat++}})}draw(){if(!this.signal.aborted)this.screen.request()}soon(){if(!this.signal.aborted)this.screen.soon()}flush(){if(!this.signal.aborted)this.screen.now()}point(t){return this.screen.point(t)}drop(){this.screen.drop()}frame(){if(this.signal.aborted)return;let{cols:t,rows:e,cell:n}=this.grid(),r=Kp(this.view,t,e);return this.view.loaderFrom=r.loader?this.view.loaderFrom??this.view.beat:void 0,{lines:r.lines,zones:r.zones,after:(i)=>this.images(r.images,i,n),...this.view.mode==="grid"&&this.view.editing!==void 0?{cursor:this.caret()}:{},ticking:r.tick}}images(t,e,n){let r="",i=new Set,o;for(let s of t){if(this.views&&s.id>=_p){o=s;continue}let a=this.bands?this.banded(s):s;if(!a)continue;if(this.wipes&&[...e].some((u)=>u>=a.row&&u<a.row+a.rows))this.placed.delete(a.id);if(i.add(a.id),this.sent.get(a.id)!==a.path){let u=Bl(a,this.files);if(u===void 0)continue;r+=u,this.sent.set(a.id,a.path),this.placed.delete(a.id)}let c=`${a.row};${a.col};${a.cols};${a.rows};${a.crop};${a.z}`;if(this.placed.get(a.id)!==c){if(!this.moves&&this.placed.has(a.id))r+=Bp(a.id);r+=IS(a,n),this.placed.set(a.id,c)}}for(let s of this.sent.keys())if(!i.has(s))r+=fc(s),this.sent.delete(s),this.placed.delete(s);return r+(this.views?this.backdrop(o):this.cover())}glide(){if(this.bands)this.prebake();if(this.gliding)return;let{cols:t,rows:e}=this.grid(),n=dr(t,e).height,r=()=>{let i=this.view,o=i.top*vt.height,s=o-i.scroll;if(s===0||i.mode!=="grid"){i.scroll=o;let a=this.gliding!==void 0;if(this.gliding=void 0,a)this.draw();return}if(Math.abs(s)>2*n)i.scroll=o-Math.sign(s)*n,s=o-i.scroll;i.scroll+=Math.sign(s)*Math.max(1,Math.round(Math.abs(s)*n4)),this.draw(),this.gliding=setTimeout(r,e4)};r()}snap(){clearTimeout(this.gliding),this.gliding=void 0,this.view.scroll=this.view.top*vt.height}resized(){this.screen.reset()}stop(){this.screen.stop(),clearTimeout(this.gliding)}prebake(){let t=this.view,{cols:e,rows:n}=this.grid();for(let r of Kp({...t,scroll:t.top*vt.height},e,n).images)if(r.crop!==void 0)this.band(r.path,r.crop,r.rows)}cover(){let{cols:t,rows:e}=this.grid(),n=`${t};${e}`;if(!this.layers||this.covered===n)return"";let r="";if(!this.covered){let i=Buffer.from(ot(this.background)).toString("base64");if(r+=`\x1B_Ga=t,f=24,s=1,v=1,i=${Ks},q=2;${i}\x1B\\`,Pg)r+=`\x1B_Ga=t,f=32,s=1,v=1,i=${Pc},q=2;AAAAAA==\x1B\\\x1B[H\x1B_Ga=p,i=${Pc},p=${Pc},c=1,r=1,C=1,z=${t4},q=2\x1B\\`}else if(!this.moves)r+=Bp(Ks);if(this.covered=n,Pg){let{x:i,y:o}=Pg;return`${r}\x1B_Ga=p,i=${Ks},p=${Ks},P=${Pc},Q=${Pc},H=${-i},V=${-o},c=${t+2*i},r=${e+2*o},C=1,z=${yM},q=2\x1B\\`}return`${r}\x1B[H\x1B_Ga=p,i=${Ks},p=${Ks},c=${t},r=${e},C=1,z=${yM},q=2\x1B\\`}backdrop(t){let{cols:e,rows:n,cell:r}=this.grid(),i=e*r.w,o=n*r.h,s=t?`${this.background}|${t.path}|1|${i}|${o}|${i}|${o}|0|0|1`:`${this.background}||1|${i}|${o}|0|0|0|0|5`;if(s===this.viewed)return"";return this.viewed=s,Ji(s)}caret(){return`\x1B[1;${Math.min(this.grid().cols,G(`⌕ ${this.view.editing??""}`)+1)}H`}banded(t){if(t.crop===void 0)return t;let e=this.band(t.path,t.crop,t.rows,!this.gliding);return e?.ready?{...t,id:e.id,path:e.path,crop:void 0}:void 0}band(t,e,n,r=!0){let i=`${t}|${e}|${n}`,o=this.bandFiles.get(i);if(o||!r)return o;let{cell:s}=this.grid(),a=this.nextBand++,c={id:a,path:Q5(this.scratch,`band-${a}.png`),ready:!1};return this.bandFiles.set(i,c),this.renders.run({job:"band",from:t,to:c.path,y:e*s.h,height:n*s.h}).then(()=>{c.ready=!0,this.draw()}).catch(()=>{}),this.trimBands(),c}trimBands(){for(let[t,e]of this.bandFiles){if(this.bandFiles.size<=i4)return;if(e.ready&&!this.sent.has(e.id))this.bandFiles.delete(t),X5(e.path,{force:!0})}}}var vo=[{name:"TTHEME_FIND_RATING",label:"Rating",about:"The ratings to list, each site read in its own words — space ticks one, and one stays ticked",choices:Co,multi:{read:Ai}},{name:"TTHEME_FIND_BLOCK",label:"Block",about:"Posts tagged with nudity or underwear are left out — space unticks one",choices:Ni,multi:{read:_o,none:"none"}},{name:"TTHEME_FIND_POSTS",label:"Posts",about:"Every post of the character, or only the transparent cutouts",choices:["all","cutouts"]},{name:"TTHEME_FIND_SOLO",label:"Solo",about:"When on, only the posts known to show the character alone — checked as posts arrive, so the counts below leave it out",choices:["on","off"]},{name:"TTHEME_FIND_ORDER",label:"Order",about:"How posts are ranked: fit, by how well each makes a backdrop; newest; or score",choices:["fit","newest","score"]},{name:"TTHEME_FIND_SETS",label:"Sets",about:"One picture posted over and over, or held by another site too: fold it into one tile, or show each",choices:["fold","show"]},...Gs()?[{name:"TTHEME_FIND_REMOVE_BG",label:"Remove bg",about:"Cut the character out of an opaque picture you try on, with macOS Vision",choices:["on","off"]}]:[],{name:"TTHEME_FIND_MIN_SCORE",label:"Min score",about:"Posts scored at least this — danbooru, konachan and yande.re; zerochan keeps no score. ←→ steps, or type any number",choices:v0,entry:"number",advanced:!0},{name:"TTHEME_FIND_MIN_SIZE",label:"Min size",about:"The shorter side of a picture, in px — every site filters it. ←→ steps, or type any number",choices:S0,entry:"number",advanced:!0},{name:"TTHEME_FIND_SITES",label:"Sites",about:"The sites the all tab mixes — each keeps its own tab. Space ticks one, and one stays ticked",choices:Z.map((t)=>t.name),multi:{read:sa},advanced:!0},{name:"TTHEME_FIND_HIDE",label:"Hide",about:"Comics, monochrome, sketches or chibi, told by tag in every site's spelling — checked as posts arrive",choices:Ad,multi:{read:Zc,none:"none"},advanced:!0},{name:"TTHEME_FIND_HIDE_TAGS",label:"Hide tags",about:"Posts with any of these tags are left out, spaced like cosplay multiple_girls — checked as posts arrive",choices:[],entry:"text",advanced:!0},{name:"TTHEME_FIND_PNG",label:"PNG only",about:"PNG originals only — danbooru counts it, the others are told by the file; zerochan only where danbooru holds it",choices:["off","on"],advanced:!0}];function SM(t,e){if(t.multi)return t.multi.read(e).join(" ")||t.multi.none;if(t.entry==="number")return/^\d+$/.test(e??"")&&Number(e)>0?String(Number(e)):"off";if(t.entry==="text")return aa(e).join(" ");return t.choices.find((n)=>n===e)??t.choices[0]}var m4=["fit","newest","score"];function Ng(t){return m4.find((e)=>e===t)??"fit"}var p4={left:-1,right:1,"shift-left":-10,"shift-right":10};function EM(t){if(process.env.SSH_CONNECTION||!/^(?:https?|file):/i.test(t))return;try{let e=s4(process.platform==="darwin"?"open":"xdg-open",[t],{stdio:"ignore",detached:!0});e.on("error",()=>{}),e.unref()}catch{}}function g4(t,e,n){if(e<0){if(t!=="fill")return Math.max(vf,t+e);if(!n)return t;return Math.max(vf,Math.max(100,n)+e+1)}return t==="fill"||t+e>n?"fill":t+e}function FM(t,e){return t.size===e.size&&t.at===e.at&&t.opacity===e.opacity}function b4(t,e){if(FM(t,e))return;return{...t.size!=="fill"?{size:t.size}:{},...t.at!==e.at?{position:qt[t.at-1]}:{},...t.opacity!==e.opacity?{opacity:t.opacity}:{}}}function MM(t,e){let n=X(t);return ge(t,e).flatMap((r,i)=>{let[,o,s]=/^([a-z.]+)_(\d+)$/.exec(r.key)??[],a=[...Z,hr].find((c)=>c.key===o);if(!a||!s)return[];return[{key:r.key,id:Number(s),ansi:a.ansi,...a===hr?{}:{page:a.pageUrl(Number(s))},up:i===0,from:Gn(n,r.original??r.fill)}]})}function w4(t){return t.length>=2&&!/^\d+$/.test(t)&&!t.includes("://")&&!/^[\w.]+:\d+$/.test(t)}var xM=12,$4=4,k4=150,y4=300,OM=12,v4=2,S4=150,E4="\x1B[?5522$p\x1B]72;t=q\x1B\\\x1B[c",M4=4000,x4=8000,IM=/\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i,O4=process.platform==="win32"?"alt+v":"ctrl+v",PM=process.platform==="darwin"?"ctrl+shift+cmd+4 copies a screenshot":"copy a picture first",I4=1280,P4=16,R4=qt.indexOf("top-right")+1,vf=20,RM=2,NM=3,N4=/[\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,A4=8,T4=9;function yf(t,e){return{key:t,groups:[],sources:[],queue:[],rounds:0,roundOf:new Map,last:new Map,kin:new Map,kindred:new Map,shapes:[],seen:new Set,same:new Map,checked:0,total:0,focus:0,top:0,searching:e,stage:"fetch",arrived:new Set}}function Nc(t){if(!(t instanceof Error))return String(t);if(t instanceof AggregateError&&t.errors[0])return Nc(t.errors[0]);if(t.cause)return Nc(t.cause);let e=t.code;if(typeof e==="string")return e;let n=(t.message||t.name).split(".")[0]??"";return n.length>56?`${n.slice(0,55)}…`:n}function Ag(t,e){return`${t}: ${Nc(e)}`}function AM(t){return t.width*t.height}function TM(t,e){return`${t}-${HM("sha1").update(e).digest("hex").slice(0,8)}`}class Tg{view;tone;session=new AbortController;cell={w:0,h:0};cols=process.stdout.columns||80;rows=process.stdout.rows||24;gen=0;pumping=0;boards=new Map;board;posts=new Map;thumbPath=new Map;looking=new Map;looked=new Map;matched=new Map;aheading=!1;pages=new Map;tab=0;values=new Map(vo.map((t)=>[t.name,SM(t,process.env[t.name])]));direction=1;prefetching=0;related=new Map;pool=[];relating;thumbQueue=[];heldFiles=new Map;heldAsked=new Set;thumbing=0;clarity=new Map;tunedFiles=[];presenting=!1;again=!1;renders=new $c;showing;thumbless=new Set;current;fetch;settle;suggestTimer;suggesting;countTimer;counting;terminal;grabber=new tg((t)=>this.write(t),(t)=>void this.got(t));noticeTimer;peekTimer;peeked;attaching;done;scratch=c4(Gn(f4(),"ttheme-find-"));home;catalog;entry;tagged;blurring;start;paint;kept;constructor(t,e,n,r,i){this.start=i,this.home=t,this.catalog=e,this.entry=n,this.tagged=new Set(e.palettes.flatMap((s)=>s.booru?[s.booru]:[])),this.tone=En(n,n.signatureSlots),this.blurring=ti(t);let o={size:"fill",at:R4,opacity:this.tone.opacity};this.view={palette:n.name,tag:r,site:this.tabName,siteAnsi:this.tabAnsi,nextSite:this.nextTabName,preset:this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:Ng(this.setting("TTHEME_FIND_ORDER")),solo:this.setting("TTHEME_FIND_SOLO")==="on",rating:Ai(this.setting("TTHEME_FIND_RATING")),block:_o(this.setting("TTHEME_FIND_BLOCK")),sets:this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",narrow:this.narrowed(),enabled:sa(this.setting("TTHEME_FIND_SITES")),hide:Zc(this.setting("TTHEME_FIND_HIDE")),hideTags:aa(this.setting("TTHEME_FIND_HIDE_TAGS")),advanced:!1,settings:vo.map((s)=>({label:s.label,choices:[...s.choices],value:this.setting(s.name),default:SM(s,Ta(s.name)),multi:s.multi&&{none:s.multi.none},about:s.about,entry:s.entry,advanced:s.advanced,cursor:0})),colors:{cursor:n.cursor,selection:n.selection,background:n.background,foreground:n.foreground,ansi:n.ansi},tiles:[],installed:[],held:MM(t,n.name),checked:0,total:0,searching:r!=="",stage:"fetch",sites:[],focus:0,top:0,scroll:0,beat:0,mode:"grid",help:!1,scene:Math.max(0,Yt.findIndex((s)=>s.name.toLowerCase()===process.env.TTHEME_SCENE)),details:!1,tune:{...o},untuned:o,coloring:Xu(t),editing:r===""?"":void 0,chips:[]},this.paint=new Rg({view:this.view,grid:()=>({cols:this.cols,rows:this.rows,cell:this.cell}),background:n.background,renders:this.renders,scratch:this.scratch,signal:this.signal,write:(s)=>this.write(s)}),this.kept=new Ig({home:t,catalog:e,entry:n,signal:this.signal,credited:()=>{this.show(),this.inform(),this.paint.draw()}}),this.pool=this.selected(this.view),this.syncChips(),this.board=yf(this.boardKey,r!==""),this.boards.set(this.board.key,this.board)}get signal(){return this.session.signal}get site(){return this.tab===0?void 0:Z[this.tab-1]}get sites(){return this.site?[this.site]:Z.filter((t)=>this.view.enabled.includes(t.name))}get tabName(){return this.site?.name??"all"}get tabAnsi(){return this.site?.ansi??$4}get nextTabName(){let t=(this.tab+1)%(Z.length+1);return t===0?"all":Z[t-1].name}frame(){return{w:this.cols*(this.cell.w||10),h:this.rows*(this.cell.h||20)}}setting(t){return this.values.get(t)}narrowed(){return Hd(this.setting("TTHEME_FIND_MIN_SCORE"),this.setting("TTHEME_FIND_MIN_SIZE"),this.setting("TTHEME_FIND_PNG"))}get boardKey(){return`${this.site?.key??"all"}|${this.view.preset}|${this.view.order}`}origPath(t,e,n){return Gn(on(t),"orig",`${e}.${n}`)}previewPath(t){let{url:e}=Qc(t.site,t.post);return Gn(on(t.site),"thumb",`${TM(t.post.id,e)}.${Lr(e)}`)}tileOf(t,e){let{site:n,post:r}=t,i=Ne(n,r.id),o=vn(r)??r;return{id:r.id,key:i,site:n.name,siteAnsi:n.ansi,width:o.width,height:o.height,reduced:o!==r,page:n===hr?"":n.pageUrl(r.id),artist:n===hr?XS(r.source):r.named.artist[0]??"",score:r.score,variants:e,mates:this.kept.matesOf(n,r.owner),thumb:this.thumbPath.get(i),missing:this.thumbless.has(i)}}show(){let t=this.view,e=this.board;if(t.tiles=e.groups.flatMap((n)=>n.open?n.posts.map((r)=>this.tileOf(r,0)):[this.tileOf(n.posts[0],n.posts.length)]),t.checked=e.checked,t.total=e.total,t.searching=e.searching,this.stageOf(e),t.note=e.note,t.focus=Math.max(0,Math.min(e.focus,t.tiles.length-1)),t.top=e.top,this.showing!==e)this.showing=e,this.paint.snap()}stageOf(t){let e=this.view;e.stage=t.stage,e.ranking=t.ranking,e.sites=this.sites.map((n)=>({name:n.name,arrived:t.arrived.has(n.name)}))}syncSite(){let t=this.view;t.site=this.tabName,t.siteAnsi=this.tabAnsi,t.nextSite=this.nextTabName}run(){let t=(e)=>this.view.editing===void 0&&Vl(e);return di({modes:[fr,...fi()],assume:[Hn,li],burst:t},async(e)=>{this.terminal=e,e.onResize(this.onResize),e.listen((i)=>{for(let o of i)this.inbound(o);this.paint.soon()}),e.write(Yi);let n=new Promise((i)=>{this.done=i}),r=setInterval(this.onClock,250);setTimeout(ku,0);try{let i=new Qa,o=await e.ask(Il,(s)=>i.see(s),1000);if(o){if(this.cell=o,this.holdThumbs(),this.view.tag)this.search(),this.relate(this.view.tag)}else this.view.searching=!1,this.view.error="This terminal does not report its cell size — find needs kitty graphics";if(!process.env.TMUX)await e.ask(E4,(s)=>s.kind==="attributes"?!0:void 0,500,!1);if(this.grabber.start(),e.hold(oS),this.start&&"paste"in this.start)this.pasted(this.start.paste);else if(this.start)this.fromClipboard();else this.peek();return this.paint.draw(),await e.until(n)}finally{this.session.abort(),this.grabber.stop(),this.attaching?.abort(),clearTimeout(this.noticeTimer),clearTimeout(this.peekTimer),this.fetch?.abort(),clearTimeout(this.settle),this.quietSuggest(),this.quietCount(),clearInterval(r),this.paint.stop(),e.write(`\x1B_Ga=d,d=A,q=2\x1B\\${Yi}`),this.kept.save(),this.renders.close(),kf(this.scratch,{recursive:!0,force:!0}),L0()}})}write(t){this.terminal?.write(t)}get saved(){return this.view.saved?.text}get installs(){return this.view.installed.length}finish(t){this.done?.(t===2&&this.saved?0:t)}inbound(t){if(t.kind==="key")this.key(t.key);else if(t.kind==="mouse")this.pointer(t);else if(t.kind==="paste")this.pasted(t.text);else if(t.kind==="mode"){if(t.mode===5522)this.grabber.clipboard=t.value!==0&&t.value!==4}else if(t.kind==="osc")if(t.code==="72"&&t.meta.t==="q")this.grabber.drops=!0;else this.grabber.take(t)}pasted(t){let e=this.view;if(e.editing!==void 0&&t.trim()!==""&&!this.picture(t)){e.editing+=t.replace(/[\r\n]+/g," "),this.suggest(),this.paint.draw();return}if(e.installing!==void 0||e.panel!==void 0||e.help)return;if(t.trim()===""){this.fromClipboard();return}this.attach(t)}picture(t){let e=t.trim();if(/^https?:\/\/\S+$/i.test(e))return!Xc(e,this.site??Z[0]);return Cs(e).length>0}async got(t){if(t.kind==="error"){this.notice(t.message);return}if(t.kind==="text"){if(t.text.trim()===""){this.notice(`No picture on the clipboard — ${PM}`);return}this.pasted(t.text);return}await this.bring(()=>Jl(t.bytes,t.source))}notice(t,e=M4){let n=this.view;n.error=t,clearTimeout(this.noticeTimer),this.noticeTimer=setTimeout(()=>{if(n.error===t)n.error=void 0,this.paint.draw()},e),this.paint.draw()}async peek(){let t=this.view,e;try{e=await rE()}catch{return}if(!e||e.stamp===this.peeked)return;if(this.peeked=e.stamp,!e.picture||t.installing!==void 0)return;t.hint=`Picture on the clipboard · ${O4} uses it`,clearTimeout(this.peekTimer),this.peekTimer=setTimeout(()=>{t.hint=void 0,this.paint.draw()},x4),this.paint.draw()}async fromClipboard(){let t=this.view;if(Qp()){if(this.grabber.clipboard){this.grabber.ask();return}this.notice("Over SSH the clipboard is not here — drop the file");return}let e;try{e=await nE(Gn(this.scratch,`clipboard-${Date.now()}.png`))}catch(r){this.notice(`Could not read the clipboard: ${Nc(r)}`);return}if(clearTimeout(this.peekTimer),t.hint=void 0,"image"in e){await this.bring(async(r)=>({...await Xp(e.image,r),source:"clipboard"}));return}let n=e.text.trim();if(!n){this.notice(`No picture on the clipboard — ${PM}`);return}if(this.picture(n)){await this.attach(n);return}if(t.editing===void 0)t.editing="";this.pasted(n)}async attach(t){let e=t.trim();if(/^https?:\/\//i.test(e)){let i=Xc(e,this.site??Z[0]);if(i){await this.jump(i.site,i.id);return}}let[n,...r]=Cs(e).sort((i,o)=>Number(!IM.test(i))-Number(!IM.test(o)));if(!n){this.notice("Nothing to use in that — drop a picture, or paste one or its link");return}await this.bring((i)=>Xp(n,i),r.length)}async bring(t,e=0){let n=this.view;this.attaching?.abort();let r=new AbortController;this.attaching=r,n.error=void 0,n.saved=void 0,n.note="Reading the picture…",this.paint.draw();let i;try{i=await t(AbortSignal.any([r.signal,this.signal]))}catch(d){if(!r.signal.aborted)n.note=void 0,this.notice(Nc(d),8000);return}if(r.signal.aborted)return;n.note=e>0?`The first picture of ${e+1} — drop one at a time to try the others`:void 0,this.quietSuggest(),n.editing=void 0,n.suggest=void 0,n.pick=void 0;let o=tE(i.bytes);QS(o,i.source);let s=this.origPath(hr,o,i.ext);C(s,i.bytes);let a=vM(s).href,c={id:o,file:a,width:i.width,height:i.height,ext:i.ext,preview:a,owner:"",score:0,rating:"s",md5:HM("md5").update(i.bytes).digest("hex"),source:i.source,tags:[],named:{artist:[],character:[],copyright:[]},solo:void 0,family:0,smaller:[]},u={site:hr,post:c},f=this.previewPath(u);C(f,i.bytes),++this.gen,this.current=void 0,n.shown=void 0;let l=yf(`local|post:${o}`,!1);this.board=l,this.boards.set(l.key,l),this.single(l,u)}single(t,e){t.searching=!1,this.posts.set(Ne(e.site,e.post.id),e),t.groups=[{posts:[e],open:!1}],t.checked=1,t.total=1,this.thumbQueue.push(e),this.thumbs(),this.view.mode="try",this.show(),this.select(),this.paint.draw()}onClock=()=>{let t=this.sites.reduce((r,i)=>Xn(i)>Xn(r)?i:r),e=Math.ceil((Xn(t)-Date.now())/1000),n=e>0?e:void 0;if(n!==this.view.waiting)this.view.waiting=n,this.view.slow=t.name,this.paint.draw()};onResize=()=>{if(this.cols=process.stdout.columns||this.cols,this.rows=process.stdout.rows||this.rows,this.paint.resized(),this.holdThumbs(),this.scroll(),this.paint.snap(),this.view.mode==="try"&&this.current)this.reveal();this.pump(),this.paint.draw()};key(t){let e=this.view;if(t==="ctrl-c"){this.finish(2);return}if(e.installing!==void 0)return;if(t==="focus-in"){this.peek();return}if(t==="focus-out")return;if((t==="ctrl-v"||t==="alt-v")&&e.panel===void 0){this.fromClipboard();return}if(e.editing!==void 0){this.editKey(t);return}if(e.panel!==void 0){this.panelKey(t);return}if(e.help){if(t==="?"||t==="esc")e.help=!1,this.paint.draw();return}if(this.cols<lo.cols||this.rows<lo.rows){if(t==="esc")this.finish(2);return}if(t==="?"){e.help=!0,this.paint.draw();return}if(e.mode==="try"){this.tryKey(t);return}this.gridKey(t)}pointer(t){let e=this.view,n=this.paint.point(t),r=n?.target;if(e.installing!==void 0)return;if(t.action==="wheel"){if(!t.sideways)this.wheel(t.wheel);return}if((t.action==="press"||t.action==="drag")&&t.button!=="left")return;if(r?.kind==="track"&&n&&t.action!=="release")this.slide(r.field,n);else if(t.action==="press")this.pressed(r);else if(t.action==="release"&&n?.inside)this.released(r,t)}pressed(t){let e=this.view;if(e.help)this.paint.drop(),this.key("esc");else if(e.editing!==void 0||t===void 0)return;else if(e.panel!==void 0){if(t.kind==="setting"&&t.index<e.settings.length&&e.typing===void 0)e.panel=t.index,this.paint.draw()}else if(e.mode==="try")this.tryPoint(t);else if(t.kind==="tile")this.focus(t.index);else if(t.kind==="query")this.gridKey("/");else if(t.kind==="site")this.tab=t.tab,this.syncSite(),this.turn()}released(t,e){let n=this.view;if(t?.kind==="key")this.key(t.key);else if(t?.kind==="link"){if(!e.shift&&!e.alt&&!e.ctrl)EM(t.url)}else if(n.editing!==void 0){if(t?.kind==="suggest")n.pick=t.index,this.editKey("enter")}else if(n.panel!==void 0)this.panelPoint(t);else if(n.mode==="try"){if(t?.kind==="place"&&n.tuning)this.tuneKey(String(t.at))}else if(t?.kind==="tile"&&e.count===2)this.gridKey("enter");else if(t?.kind==="chip")this.toggle(t.index)}wheel(t){let e=this.view;if(e.help)return;if(e.editing!==void 0){if(e.suggest?.length)this.editKey(t<0?"up":"down")}else if(e.panel!==void 0){if(e.typing===void 0)this.panelKey(t<0?"up":"down")}else if(e.tuning)this.tuneKey(t<0?"up":"down");else if(e.mode==="try")this.tryKey(t<0?"left":"right");else this.focus(e.focus+t*dr(this.cols,this.rows).perRow)}panelPoint(t){let e=this.view;if(t?.kind!=="setting"&&t?.kind!=="choice")return;let n=e.settings[t.index];if(e.typing!==void 0){let r=e.settings[e.panel??0];if(r&&(t.index!==e.panel||t.kind==="setting"))this.typeKey(r,"enter");else return}if(t.kind==="setting"&&t.index===e.settings.length){e.panel=t.index,this.panelKey("enter");return}if(e.panel=t.index,t.kind==="choice"&&n){if(n.entry==="text"||t.choice===void 0){this.panelKey("enter");return}if(n.multi){n.cursor=Math.max(0,n.choices.indexOf(t.choice)),this.panelKey(" ");return}if(n.value!==t.choice)n.value=t.choice,this.recount()}this.paint.draw()}tryPoint(t){let e=this.view;if(t.kind==="scene")e.scene=t.scene,e.details=!1,this.paint.draw();else if(e.tuning&&t.kind==="field")e.tuning.field=t.field,this.paint.draw()}slide(t,e){let n=this.view,r=n.tuning;if(!r)return;let i=Math.min(1,Math.max(0,e.width>1?e.x/(e.width-1):0));if(r.field=t,t===0){let o=Math.max(100,r.fill),s=vf+Math.round(i*(o-vf+1));n.tune.size=i===1||r.fill>0&&s>=r.fill?"fill":Math.min(o,s)}else n.tune.opacity=Math.round(i*100)/100;this.retune()}gridKey(t){let e=this.view,{perRow:n,rowsVis:r}=dr(this.cols,this.rows),o={left:-1,right:1,up:-n,down:n,k:-n,j:n,pgup:-n*r,pgdn:n*r,home:-e.focus,end:e.tiles.length}[t];if(o!==void 0){this.focus(e.focus+o);return}if(/^[1-9]$/.test(t)){this.toggle(Number(t)-1);return}if(t==="enter"&&e.tiles[e.focus]){e.mode="try",e.error=void 0,this.select();return}if(t==="v"){this.fromClipboard();return}if(t==="c"){e.preset=e.preset==="cutouts"?"all":"cutouts",this.turn();return}if(t==="tab"||t==="shift-tab"){let s=Z.length+1;this.tab=(this.tab+(t==="tab"?1:s-1))%s,this.syncSite(),this.turn();return}if(t==="/"){e.editing="",this.paint.draw();return}if(t===" "){this.unfold();return}if(t==="o"){this.openPage();return}if(t==="s"){e.panel=0,e.advanced=!1,this.recount(),this.paint.draw();return}if(t==="esc")this.finish(2)}panelKey(t){let e=this.view,n=e.panel??0,r=e.settings[n];if(e.typing!==void 0&&r){this.typeKey(r,t);return}let i=lc(e);if(t==="up"||t==="down"){let o=i.indexOf(n)+(t==="up"?-1:1);e.panel=i[(o+i.length)%i.length]??n,this.paint.draw();return}if(t==="a"||t==="enter"&&n===e.settings.length){e.advanced=!e.advanced,e.panel=lc(e)[0]??0,this.paint.draw();return}if(r?.entry&&(t==="enter"||r.entry==="number"&&/^[0-9]$/.test(t))){e.typing=t==="enter"?r.entry==="text"?r.value:"":t,this.paint.draw();return}if((t==="left"||t==="right")&&r&&r.entry!=="text"){let o=t==="left"?-1:1;if(r.multi)r.cursor=(r.cursor+o+r.choices.length)%r.choices.length;else r.value=TS(r.choices,r.value,o),this.recount();this.paint.draw();return}if(t===" "&&r?.multi){let o=r.value.split(" "),s=r.choices.filter((c,u)=>u===r.cursor?!o.includes(c):o.includes(c)),a=r.multi.none;if(s.length>0||a!==void 0)r.value=s.length>0?s.join(" "):a,this.recount(),this.paint.draw();return}if(t==="esc"){e.settings.forEach((o,s)=>{o.value=this.setting(vo[s]?.name??"")}),e.panel=void 0,e.advanced=!1,this.quietCount(),this.paint.draw();return}if(t==="enter"||t==="s"||t==="alt-c")e.panel=void 0,e.advanced=!1,this.quietCount(),this.adopt()}typeKey(t,e){let n=this.view,r=n.typing??"";if(e==="esc"){n.typing=void 0,this.paint.draw();return}if(e==="enter"||e==="up"||e==="down"){if(t.value=t.entry==="number"?Number(r)>0?String(Number(r)):"off":aa(r).join(" "),n.typing=void 0,this.recount(),e==="enter"){this.paint.draw();return}this.panelKey(e);return}let i=ao(r,e,(o)=>t.entry==="number"?/^[0-9]$/.test(o)&&r.length<Wp:/^[\x20-\x7e]$/.test(o));if(i!==void 0)n.typing=i,this.paint.draw()}quietCount(){clearTimeout(this.countTimer),this.counting?.abort(),this.counting=void 0}recount(){if(this.quietCount(),this.view.counts=void 0,!this.view.tag)return;let t=new AbortController;this.counting=t,this.countTimer=setTimeout(()=>void this.countPending(t),y4)}pending(){let t=(e)=>this.view.settings[vo.findIndex((n)=>n.name===e)]?.value??this.setting(e);return{tag:this.view.tag,chosen:this.view.chosen,preset:t("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:Ng(t("TTHEME_FIND_ORDER")),rating:Ai(t("TTHEME_FIND_RATING")),narrow:Hd(t("TTHEME_FIND_MIN_SCORE"),t("TTHEME_FIND_MIN_SIZE"),t("TTHEME_FIND_PNG")),enabled:sa(t("TTHEME_FIND_SITES"))}}async countPending(t){let e=this.pending(),n=this.site?[this.site]:Z.filter((o)=>e.enabled.includes(o.name)),r=AbortSignal.any([this.signal,t.signal]),i=await Promise.all(n.map(async(o)=>{let s=this.query(o,e);if(!s)return{site:o.name,count:0};if(o.counts&&!o.counts(s.tags))return{site:o.name};try{let a=await jd(o,s.tags,r);return{site:o.name,...Number.isFinite(a)?{count:a}:{}}}catch{return{site:o.name}}}));if(this.counting===t&&this.view.panel!==void 0)this.view.counts=i,this.paint.draw()}adopt(){let t=this.view,e=vo.map((r)=>this.setting(r.name));t.settings.forEach((r,i)=>{let o=vo[i];if(o)this.values.set(o.name,r.value)});let n=vo.filter((r,i)=>this.setting(r.name)!==e[i]);if(n.length===0){this.paint.draw();return}this.save(n),t.rating=Ai(this.setting("TTHEME_FIND_RATING")),t.block=_o(this.setting("TTHEME_FIND_BLOCK")),t.sets=this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",t.preset=this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",t.order=Ng(this.setting("TTHEME_FIND_ORDER")),t.solo=this.setting("TTHEME_FIND_SOLO")==="on",t.narrow=this.narrowed(),t.enabled=sa(this.setting("TTHEME_FIND_SITES")),t.hide=Zc(this.setting("TTHEME_FIND_HIDE")),t.hideTags=aa(this.setting("TTHEME_FIND_HIDE_TAGS")),this.boards.clear(),this.current=void 0,t.shown=void 0,t.mode="grid",this.search()}save(t){this.store(t.map((e)=>[e.name,this.setting(e.name)]))}store(t){let e=Gn(this.home,"ttheme","config.zsh");try{let n=Rc(e)?u4(e,"utf8"):"";return C(e,t.reduce((r,[i,o])=>Qu(r,i,o),n)),!0}catch(n){return this.view.error=n instanceof Error?n.message:String(n),!1}}editKey(t){let e=this.view,n=e.editing??"",r=e.suggest??[];if((t==="up"||t==="down")&&r.length>0){let s=((e.pick??r.length)+(t==="down"?1:r.length))%(r.length+1);e.pick=s===r.length?void 0:s,this.paint.draw();return}if(t==="esc"||t==="enter")this.quietSuggest();if(t==="esc"){if(e.editing=void 0,e.tag===""){this.finish(2);return}this.paint.draw();return}if(t==="enter"){let o=e.pick===void 0?void 0:r[e.pick],s=o?o.whole?o.value:n.replace(/\S*$/,o.value):n;if(e.editing=void 0,e.suggest=void 0,e.pick=void 0,s.trim()){this.commit(s.trim());return}if(e.tag===""){this.finish(2);return}this.paint.draw();return}let i=ao(n,t);if(i!==void 0)e.editing=i,this.suggest(),this.paint.draw()}quietSuggest(){clearTimeout(this.suggestTimer),this.suggesting?.abort(),this.suggesting=void 0}suggest(){this.quietSuggest();let t=this.view;t.pick=void 0;let e=t.editing??"",n=/\S*$/.exec(e)?.[0]??"",r=w4(n),i=z$(e,NM,this.tagged).map((c)=>({value:c.tag,count:0,alias:c.name,whole:!0}));if(!r&&i.length===0){t.suggest=void 0;return}let o=r?Ok(this.catalog.palettes,this.entry,n).map((c)=>({value:c.booru,count:0,palette:c.name})):[],s=[...new Map([...o.slice(0,NM),...i].map((c)=>[c.value,c])).values()];if(t.suggest=s.length>0?s:void 0,i.length>0&&N4.test(e))t.pick=s.findIndex((c)=>("whole"in c));if(!r)return;let a=new AbortController;this.suggesting=a,this.suggestTimer=setTimeout(async()=>{try{let c=await j0(n,AbortSignal.any([this.signal,a.signal]));if(this.suggesting===a&&t.editing!==void 0){let u=new Map(c.map((l)=>[l.value,l.count])),f=new Set(s.map((l)=>l.value));t.suggest=[...s.map((l)=>({...l,count:u.get(l.value)??0})),...c.filter((l)=>!f.has(l.value))].slice(0,A4),t.pick=t.pick!==void 0&&t.pick<s.length?t.pick:void 0,this.paint.draw()}}catch{}},k4)}async commit(t){let e=Xc(t,this.site??Z[0]);if(e){await this.jump(e.site,e.id);return}if(this.picture(t)){await this.attach(t);return}this.view.tag=t,this.view.chosen=void 0,this.relate(t),this.boards.clear(),await this.search()}async jump(t,e){let n=++this.gen;this.tab=Z.indexOf(t)+1,this.syncSite(),this.current=void 0,this.view.shown=void 0,this.view.error=void 0;let r=yf(`${t.key}|post:${e}`,!0);this.board=r,this.boards.set(r.key,r),this.show(),this.paint.draw();try{let i=await Go(t,e,this.signal);if(n!==this.gen)return;if(!i){r.searching=!1,r.error=`${t.name} has no post ${e}`,this.view.error=r.error,this.show(),this.paint.draw();return}this.single(r,{site:t,post:i})}catch(i){this.fail(n,i,t)}}async turn(){this.fetch?.abort(),this.current=void 0,this.view.shown=void 0;let t=this.boards.get(this.boardKey);if(!t){await this.search();return}this.gen++,this.board=t,this.view.error=t.error,this.show(),this.paint.draw(),await this.pump()}unfold(){let t=this.view,e=0;for(let n of this.board.groups){let r=n.open?n.posts.length:1;if(t.focus<e+r){if(n.posts.length<2)return;n.open=!n.open,this.board.focus=e;for(let i of n.posts)if(!this.thumbPath.has(Ne(i.site,i.post.id)))this.thumbQueue.push(i);this.thumbs(),this.show(),this.scroll(),this.paint.glide(),this.paint.draw();return}e+=r}}openPage(){let t=this.view.tiles[this.view.focus],e=t&&this.posts.get(t.key);if(e)EM(e.site.pageUrl(e.post.id))}tryKey(t){let e=this.view;if(e.tuning){this.tuneKey(t);return}if(t==="left"||t==="right"){this.direction=t==="left"?-1:1,this.focus(e.focus+this.direction);return}if(t==="shift-left"||t==="shift-right"){e.scene+=t==="shift-left"?-1:1,e.details=!1,this.paint.draw();return}if(t==="i"){e.details=!e.details,this.inform(),this.paint.draw();return}if(t==="t"){e.tuning={field:0,held:{...e.tune},fill:this.current?.fill??0,coloring:e.coloring},this.paint.draw();return}if(t==="c"){this.recolor();return}if(t==="o"){this.openPage();return}if(t==="x"){this.swap();return}if(t==="v"){this.fromClipboard();return}if(t==="enter"){this.install();return}if(t==="esc")this.fetch?.abort(),clearTimeout(this.settle),e.fetching=void 0,e.mode="grid",e.error=void 0,this.paint.draw()}tuneKey(t){let e=this.view,n=e.tuning,r=e.tune;if(t==="up"||t==="down"){n.field=(n.field+(t==="up"?2:1))%3,this.paint.draw();return}let i=p4[t];if(i!==void 0){if(n.field===0)r.size=g4(r.size,i,n.fill);else if(n.field===1)r.at=(r.at-1+Math.sign(i)+9)%9+1;else r.opacity=Math.max(0,Math.min(100,Math.round(r.opacity*100)+i))/100;this.retune();return}if(/^[1-9]$/.test(t)){n.field=1,r.at=Number(t),this.retune();return}if(t==="="){let o=e.untuned;if(n.field===0)r.size=o.size;else if(n.field===1)r.at=o.at;else r.opacity=o.opacity;this.retune();return}if(t==="+"){e.tune={...e.untuned},this.retune();return}if(t==="enter"){e.tuning=void 0,this.paint.draw();return}if(t==="c"){this.recolor();return}if(t==="esc")e.tune={...n.held,...n.coloring===e.coloring?{}:{opacity:e.untuned.opacity}},e.tuning=void 0,this.retune()}recolor(){let t=this.view;if(!this.current||t.shown?.id!==this.current.key)return;t.coloring=t.coloring==="tone"?"original":"tone",t.tune.opacity=t.untuned.opacity,this.paint.draw(),this.reveal()}retune(){if(this.paint.draw(),this.current&&this.view.shown?.id===this.current.key)this.reveal()}inform(){let t=this.view,e=t.tiles[t.focus],n=e&&this.posts.get(e.key);t.info=n?this.infoOf(n):void 0}infoOf(t){let{site:e,post:n}=t,r=n.named,i=H0(e,n),o=new Set([...r.artist,...r.character,...r.copyright]),s=ca(n.source),a=/^https?:\/\//i.test(s)?s:e===hr&&s.startsWith("/")?vM(s).href:void 0;return{page:e===hr?"":e.pageUrl(n.id),source:s,...a?{link:a}:{},artists:r.artist,characters:r.character,series:r.copyright,tags:n.tags.filter((c)=>!o.has(c)),...i?{rating:i}:{},...n.posted?{posted:n.posted}:{},ext:(vn(n)??n).ext,uploader:n.owner}}focus(t){let e=this.view;if(e.tiles.length===0)return;let n=Math.max(0,Math.min(e.tiles.length-1,t));if(n===e.focus)return;if(e.focus=n,this.board.focus=n,this.scroll(),this.paint.glide(),this.pump(),e.mode==="try")this.select();this.paint.draw()}scroll(){let t=this.view,{perRow:e,rowsVis:n}=dr(this.cols,this.rows),r=Math.floor(t.focus/e);if(r<t.top)t.top=r;if(r>t.top+n-1)t.top=r-n+1;this.board.top=t.top}selected(t){if(t.chosen)return t.chosen;if(!t.tag)return[];return this.namesOf(t.tag,"danbooru")}namesOf(t,e){let n=t===this.entry.booru?this.entry:this.catalog.palettes.find((r)=>r.booru===t);return n?Ik(n,e):[t]}syncChips(){let t=this.selected(this.view);this.view.chips=this.pool.slice(0,T4).map((e)=>({name:e,on:t.includes(e)}))}toggle(t){let e=this.view,n=e.chips[t];if(!n)return;let r=this.selected(e),i=n.on?r.filter((o)=>o!==n.name):[...r,n.name];if(i.length===0)return;e.chosen=i,e.tag=i.join(" or "),this.syncChips(),this.boards.clear(),this.search()}async relate(t){this.relating?.abort();let e=this.selected({tag:t,chosen:void 0});if(this.pool=e,this.syncChips(),this.paint.draw(),!t||/\s/.test(t))return;let n=this.related.get(t);if(!n){let r=new AbortController;this.relating=r;try{n=(await _0(t,AbortSignal.any([this.signal,r.signal]))).map((i)=>i.value)}catch{return}if(this.relating!==r)return;this.related.set(t,n)}this.pool=[...new Set([...e,...n])],this.syncChips(),this.paint.draw()}query(t,e=this.view){let n=e.chosen?G0(t,e.chosen):this.namesOf(e.tag,t.key);if(n.length===0)return;let r=e.chosen?.slice(n.length)??[],i=n.length>1,o=e.preset==="cutouts"?t.cutouts:"",s=i&&o.includes("~"),a=[i?n.map((f)=>`~${f}`).join(" "):n[0],t.rate(e.rating),...t.narrow(e.narrow),s?"":o,e.order==="score"?t.best:""].filter(Boolean),c=[],u=[];for(let f of a)if(Cd([...c,f].join(" "))<=t.tagBudget)c.push(f);else u.push(f);return{tags:c.join(" "),notes:[...u.length>0?[`${t.name} takes ${t.tagBudget} tags — ${u.join(" ")} left out`]:[],...r.length>0?[`${t.name} takes ${n.length} tag${n.length===1?"":"s"} — ${r.join(" ")} left out`]:[],...s?[`${t.name} ORs the names, so cutouts are told by the file`]:[],...e.narrow.score>0&&!t.scored?[`${t.name} keeps no score`]:[],...e.narrow.png&&t.guesses?[`${t.name} names a file type only where danbooru holds the file`]:[]]}}async search(){let t=++this.gen,e=yf(this.boardKey,!0);this.board=e,this.boards.set(e.key,e),this.view.error=void 0;let n=this.sites.flatMap((o)=>{let s=this.query(o);return s?[{site:o,...s}]:[]}),r=this.sites.filter((o)=>!n.some((s)=>s.site===o)),i=[...n.flatMap(({notes:o})=>o),...r.length>0?[`${this.entry.name} has no tag on ${r.map((o)=>o.name).join(", ")}`]:[]];if(e.note=i.length>0?i.join(" · "):void 0,n.length===0)e.searching=!1;this.show(),this.paint.draw(),this.tally(t,e,n);try{let o=await Promise.all(n.map(async(s)=>({plan:s,owners:await this.kept.mateOwners(s.site)})));if(t!==this.gen)return;e.sources=o.flatMap(({plan:{site:s,tags:a},owners:c})=>{let u=Cd(a)+1<=s.tagBudget?s.uploadedBy:void 0;return[...u?[...c.keys()].map((f)=>({site:s,tags:`${a} ${u(f)}`,page:0,done:!1})):[],{site:s,tags:a,page:0,done:!1}]}),this.show(),this.paint.draw(),await this.pump()}catch(o){this.fail(t,o)}}async tally(t,e,n){let r=await Promise.allSettled(n.map(({site:i,tags:o})=>jd(i,o,this.signal)));if(t===this.gen)e.total=r.reduce((i,o)=>i+(o.status==="fulfilled"&&Number.isFinite(o.value)?o.value:0),0),this.show(),this.paint.draw()}fail(t,e,n=this.site){if(t!==this.gen||this.signal.aborted)return;this.board.error=Ag(n?.name??this.tabName,e),this.board.searching=!1,this.view.error=this.board.error,this.show(),this.paint.draw()}drop(t,e,n){for(let r of t.sources)if(r.site===e)r.done=!0;t.note=[t.note,Ag(e.name,n)].filter(Boolean).join(" · ")}wants(){let{perRow:t,rowsVis:e}=dr(this.cols,this.rows);return this.view.tiles.length<(this.board.top+e+RM)*t}need(){let{perRow:t,rowsVis:e}=dr(this.cols,this.rows);return(e+RM)*t}live(t){return this.boards.get(t.key)===t}page(t,e,n){let r=`${t.key}|${e}|${n}`,i=this.pages.get(r);if(!i)i=C0(t,e,n,this.signal).then((o)=>this.borrow(t,o)),this.pages.set(r,i),i.catch(()=>this.pages.delete(r));return i}async borrow(t,e){let n=t===ce?[]:e.filter((r)=>r.md5!=="");if(n.length>0)try{ou(n,await su(n.map((r)=>r.md5),this.signal))}catch{}return e}staged(t){if(t===this.board)this.stageOf(t),this.paint.draw()}async round(t){t.stage="fetch",this.staged(t);let e=Z.flatMap((a)=>{let c=t.sources.find((u)=>u.site===a&&!u.done);return c?[c]:[]}),n=await Promise.all(e.map(async(a)=>{try{let c=await this.page(a.site,a.tags,a.page);return t.arrived.add(a.site.name),this.staged(t),{source:a,posts:c}}catch(c){if(t.sources.every((u)=>u.site===a.site)||this.signal.aborted)throw c;return this.drop(t,a.site,c),{source:a,posts:void 0}}}));if(!this.live(t))return;let r=[];for(let{source:a,posts:c}of n){if(!c)continue;a.page++,a.done=c.length<Hr;let u=t.last.get(a);for(let f of c){let l=u&&IE(u.post,f)?u.set:`set:${a.site.key}:${f.id}`;u={post:f,set:l};let d=Ne(a.site,f.id);if(t.seen.has(d))continue;t.seen.add(d);let h={site:a.site,post:f};if(this.eligible(h))t.kin.set(h,[l,...OE(a.site,f)]),r.push(h);else t.checked++}if(u)t.last.set(a,u)}let i=this.dedupe(t,r),o=++t.rounds,s;if(this.view.order!=="fit")s=e.length>1?wE(i):i;else{let a=Ql(i,this.frame(),this.matched),c=a.slice(0,this.need()),u={done:0,total:c.length};if(t.ranking=u,this.staged(t),await this.looks(c,()=>{u.done++,this.staged(t)}),t.ranking=void 0,!this.live(t))return;s=[...Ql(c,this.frame(),this.matched),...a.slice(c.length)]}t.stage="check",this.staged(t);for(let a of s)t.roundOf.set(a,o);t.queue.push(...s),this.ahead(t)}ahead(t){if(this.aheading||this.view.order!=="fit"||!this.live(t))return;let e=t.queue.slice(0,this.need()).filter((n)=>!this.looking.has(Ne(n.site,n.post.id)));if(e.length===0)return;this.aheading=!0,this.looks(e).then(()=>{this.aheading=!1;for(let n of new Set(e.map((r)=>t.roundOf.get(r)??0)))this.resort(t,n);this.ahead(t)})}resort(t,e){let n=t.queue.flatMap((i,o)=>t.roundOf.get(i)===e?[o]:[]),r=Ql(n.map((i)=>t.queue[i]),this.frame(),this.matched);n.forEach((i,o)=>{t.queue[i]=r[o]})}dedupe(t,e){let n=[];for(let r of e){let i=mg(r.post),o=i.map((a)=>t.same.get(a)).find(Boolean);if(!o){for(let a of i)t.same.set(a,r);n.push(r);continue}if(t.checked++,AM(r.post)<=AM(o.post))continue;for(let a of[...i,...mg(o.post)])t.same.set(a,r);let s=n.indexOf(o);if(s>=0){n[s]=r;continue}this.replace(t,o,r)}return n}replace(t,e,n){t.roundOf.set(n,t.roundOf.get(e)??0);let r=t.queue.indexOf(e);if(r>=0){t.queue[r]=n;return}for(let i of t.groups){let o=i.posts.indexOf(e);if(o>=0){i.posts[o]=n,this.posts.set(Ne(n.site,n.post.id),n),this.thumbQueue.push(n),this.thumbs();return}}}async looks(t,e){let n=0;await Promise.all(Array.from({length:OM},async()=>{while(n<t.length)await this.look(t[n++]),e?.()}))}look(t){let e=Ne(t.site,t.post.id),n=this.looking.get(e);if(!n)n=(async()=>{let r=this.previewPath(t),i=Qc(t.site,t.post);await this.kept.cached(i.site,r,i.url);let o=await this.renders.run({job:"match",from:r,colors:this.entry.signature});return this.looked.set(e,o),this.matched.set(t.post,o.match),o})().catch(()=>{return}),this.looking.set(e,n);return n}async pump(){let t=this.gen,e=this.board;if(this.pumping===t||e.sources.length===0)return;this.pumping=t;let n=[],r;try{e.searching=!0;while(t===this.gen){while(n.length<xM&&e.queue.length>0&&this.wants()){let s=e.queue.shift();n.push({pick:s,passed:this.vet(s)})}if(this.ahead(e),!r&&e.queue.length<xM&&e.sources.some((s)=>!s.done)&&this.wants()){let s=this.round(e).then(()=>{if(r===s)r=void 0});s.catch(()=>{}),r=s}let i=n.shift();if(!i){if(!r)break;await r,this.show(),this.paint.draw();continue}let o=await i.passed;if(t!==this.gen)return;if(e.checked++,o)this.admit(i.pick);this.show(),this.paint.draw()}if(t===this.gen)e.searching=!1,this.show(),this.paint.draw()}catch(i){this.fail(t,i)}finally{if(this.kept.save(),this.pumping===t)this.pumping=0}}eligible({site:t,post:e}){let n=vn(e);if(!eu(t,e,this.view.rating)||tu(e,this.view.block).length>0||!n)return!1;if(this.view.solo&&e.solo===!1)return!1;let{score:r,size:i,png:o}=this.view.narrow;if(Math.min(e.width,e.height)<i||t.scored&&e.score<r||o&&e.ext!=="png"||T0(e,this.view.hide).length>0||this.view.hideTags.some((s)=>e.tags.includes(s)))return!1;return this.view.preset==="all"?["png","jpg","jpeg",""].includes(n.ext):["png",""].includes(e.ext)}async vet(t){let[e]=await Promise.all([this.passes(t),this.look(t)]);return e}async passes({site:t,post:e}){return this.view.preset==="all"||t.vouched||this.kept.transparent(t,e)}admit(t){let{site:e,post:n}=t,r=this.board,i=Ne(e,n.id);this.posts.set(i,t);let o=r.kin.get(t)??[],s=this.looked.get(i),a=s&&{hash:s.hash,width:n.width,height:n.height},c=this.view.sets==="fold"?this.kindred(r,o,a):void 0;if(c){if(c.posts.push(t),this.register(r,c,o,a),c.open)this.thumbQueue.push(t),this.thumbs();return}let u={posts:[t],open:!1};r.groups.push(u),this.register(r,u,o,a),this.thumbQueue.push(t),this.thumbs()}kindred(t,e,n){for(let r of e){let i=t.kindred.get(r);if(i)return i}return n&&t.shapes.find((r)=>RE(r.shape,n))?.group}register(t,e,n,r){for(let i of n)if(!t.kindred.has(i))t.kindred.set(i,e);if(r)t.shapes.push({shape:r,group:e})}holds(){this.view.held=MM(this.home,this.entry.name).map((t)=>{let e=this.heldFiles.get(t.from);return e?{...t,thumb:e}:t}),this.holdThumbs()}holdThumbs(){let t=Se.cols*this.cell.w,e=Se.rows*this.cell.h;if(t===0||e===0)return;for(let n of this.view.held.slice(0,Gp(this.cols))){if(n.thumb||this.heldAsked.has(n.from))continue;this.heldAsked.add(n.from);let r=Gn(this.scratch,`held-${d4(n.from)}-${t}x${e}.png`);this.renders.run({job:"thumb",from:n.from,to:r,width:t,height:e}).then(()=>{this.heldFiles.set(n.from,r),this.holds(),this.paint.draw()}).catch(()=>{})}}thumbs(){while(!this.signal.aborted&&this.thumbing<OM&&this.thumbQueue.length>0){let t=this.thumbQueue.shift();this.thumbing++,this.thumb(t).catch(()=>{this.thumbless.add(Ne(t.site,t.post.id)),this.show(),this.paint.draw()}).finally(()=>{this.thumbing--,this.thumbs()})}}async thumb(t){let{site:e,post:n}=t,r=vt.cols*this.cell.w,i=vt.rows*this.cell.h,o=Qc(e,n),s=Gn(on(e),"tile",`${TM(n.id,o.url)}-${r}x${i}.png`);if(!Rc(s)){let a=this.previewPath(t);if(await this.kept.cached(o.site,a,o.url),this.signal.aborted)return;await this.renders.run({job:"thumb",from:a,to:s,width:r,height:i})}this.thumbPath.set(Ne(e,n.id),s),this.show(),this.paint.draw()}select(){let t=this.view,e=t.tiles[t.focus];if(this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,this.inform(),!e)return;if(this.current?.key===e.key){this.reveal();return}this.settle=setTimeout(()=>void this.load(e),S4),this.paint.draw()}async load(t){let e=this.view,n=this.posts.get(t.key);if(!n)return;let r=new AbortController;if(this.fetch=r,this.kept.credit(n,r.signal),!vn(n.post))return;let{site:i}=n,o=this.board;try{await la(i,n.post,r.signal);let s=vn(n.post),a=this.origPath(i,t.id,s.ext);if(!Rc(a))e.fetching={id:t.key,got:0,size:0},this.paint.draw();let c=Ti(i,n.post,s),u=await this.kept.cached(c.site,a,c.url,(d,h)=>{if(e.fetching?.id===t.key)e.fetching={id:t.key,got:d,size:h},this.paint.draw()});if(r.signal.aborted)return;if(e.fetching=void 0,o!==this.board)return;let f={site:i,id:t.id,key:t.key,path:a,ext:s.ext,size:u,using:"plain",failed:!1};e.preparing=t.key,this.paint.flush();let l=await this.render(f,"plain");if(r.signal.aborted||o!==this.board)return;if(l.clear===0&&Gs()&&this.setting("TTHEME_FIND_REMOVE_BG")!=="off"){if(e.preparing=void 0,e.cutting=t.key,this.paint.flush(),f.cut=await this.cutOut(i,t.id,a,r.signal),r.signal.aborted||o!==this.board)return;if(e.cutting=void 0,f.cut){e.preparing=t.key,this.paint.flush();let d=await this.render(f,"cut").catch(()=>{return});if(r.signal.aborted||o!==this.board)return;if(d&&tf(d.clear))f.using="cut";else kf(f.cut,{force:!0}),f.cut=void 0,f.failed=!0}else f.failed=!0}if(this.current=f,e.tiles[e.focus]?.key===t.key)await this.present();this.preload()}catch(s){if(!r.signal.aborted&&!this.signal.aborted)e.error=Ag(i.name,s)}finally{if(e.fetching?.id===t.key)e.fetching=void 0;if(e.preparing===t.key)e.preparing=void 0;if(e.cutting===t.key)e.cutting=void 0;this.paint.draw()}}async cutOut(t,e,n,r){let i=Gn(on(t),"cut",`${e}.png`);if(Rc(i))return i;try{return a4(h4(i),{recursive:!0}),await wc(n,i,r),i}catch{kf(i,{force:!0});return}}swap(){let t=this.current;if(!t?.cut||this.view.shown?.id!==t.key)return;t.using=t.using==="cut"?"plain":"cut",this.reveal()}preload(){let t=this.view;if(t.mode!=="try")return;for(let e of[t.focus+this.direction,t.focus-this.direction]){let n=t.tiles[e],r=n&&this.posts.get(n.key);if(r)this.kept.credit(r,this.signal);if(this.prefetching>=v4||!r||!vn(r.post))continue;let{site:i,post:o}=r;this.prefetching++,la(i,o,this.signal).then(async()=>{let s=vn(o),a=this.origPath(i,o.id,s.ext),c=Ti(i,o,s);return await this.kept.cached(c.site,a,c.url),this.render({site:i,id:o.id,key:n.key,path:a,ext:s.ext,size:0,using:"plain",failed:!1},"plain")}).catch(()=>{}).finally(()=>{this.prefetching--})}}async render(t,e){let n=this.cols*this.cell.w,r=this.rows*this.cell.h,i=Math.min(n,I4),o=Math.max(1,Math.round(r*i/n)),s={...this.view.tune},{coloring:a}=this.view,c=!FM(s,this.view.untuned),u=s.opacity!==this.view.untuned.opacity,f=c?`-${s.size}-${s.at}${u?`-${Math.round(s.opacity*100)}`:""}`:"",l=Gn(this.scratch,`${t.site.key}-${t.id}${e==="cut"?"c":""}${a==="original"?"o":""}-${i}x${o}${f}.png`),d=`${t.site.key}:${t.id}:${e}:${a}:${i}x${o}`,h=this.clarity.get(d);if(h&&Rc(l))return t.fill=h.fill,{clear:h.clear,path:l,opacity:h.opacity,touched:u};let m=await this.renders.run({job:"show",from:e==="cut"?t.cut:t.path,to:l,width:i,height:o,colors:this.entry,tone:this.tone,blur:this.blurring*i/Qd(n,r).width,coloring:a,...c?{tune:{size:s.size,at:s.at,...u?{opacity:s.opacity}:{}}}:{}});if(this.clarity.set(d,m),t.fill=m.fill,c)this.keepTuned(l);return{clear:m.clear,path:l,opacity:m.opacity,touched:u}}keepTuned(t){this.tunedFiles.push(t);while(this.tunedFiles.length>P4){let e=this.tunedFiles.findIndex((n)=>n!==this.view.shown?.path&&n!==t);if(e===-1)return;kf(this.tunedFiles.splice(e,1)[0],{force:!0})}}async present(){let t=this.current;if(!t)return;let e=t.using,{coloring:n}=this.view,r=this.view.tune.opacity,{clear:i,path:o,opacity:s,touched:a}=await this.render(t,e);if(this.current!==t||t.using!==e||this.view.coloring!==n)return;if(!a&&this.view.tune.opacity===r)this.view.untuned.opacity=s,this.view.tune.opacity=s;if(this.view.tuning&&t.fill)this.view.tuning.fill=t.fill;this.view.shown={id:t.key,clear:i,bytes:t.size,path:o,cut:t.cut?e==="cut"?"on":"off":t.failed?"failed":"none"}}reveal(){let t=this.view;if(this.presenting){this.again=!0;return}this.presenting=!0,t.preparing=this.current?.key,this.paint.flush(),this.present().catch((e)=>{t.error=e instanceof Error?e.message:String(e)}).finally(()=>{if(this.presenting=!1,this.again){this.again=!1,this.reveal();return}if(t.preparing===this.current?.key)t.preparing=void 0;this.paint.draw()})}async install(){let t=this.view,e=t.tiles[t.focus],n=this.current;if(!e||n?.key!==e.key||t.preparing!==void 0||t.shown?.id!==e.key)return;t.installing=e.key,t.error=void 0,this.paint.flush();let r=b4(t.tune,t.untuned),i=this.posts.get(n.key)?.post;try{await this.renders.run({job:"backdrop",from:n.using==="cut"?n.cut:n.path,source:n.path,home:this.home,colors:this.entry,tone:this.tone,origin:{site:n.site.key,id:n.id,ext:n.ext,from:`${n.site.name} ${n.id} ${n.site.pageUrl(n.id)}`,artist:i?.named.artist??[],source:ca(i?.source??"")},width:this.cols*this.cell.w,height:this.rows*this.cell.h,blur:this.blurring,coloring:t.coloring,...r?{tune:r,aligns:no(z(this.home).terminals),user:l4()}:{}}),this.kept.owned(n.site,n.id,i?.owner??""),_e(this.home),this.holds();let{size:o,at:s,opacity:a}=t.tune,c=r?` · ${o==="fill"?"fill":`${o}%`} · ${qt[s-1]} · ${a.toFixed(2)}`:"",u=i?.named.artist.length?`${i.named.artist.join(", ")} · `:"";t.saved={text:`Background · ${this.entry.name} ← ${u}${n.site.name} ${n.id}${c}`,key:e.key},t.installed.push(e.key),this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,t.mode="grid"}catch(o){t.error=o instanceof Error?o.message:String(o)}t.installing=void 0,this.paint.draw()}}async function LM(t,e,n){let r=new Tg(t,we(t),e,e.booru??"",n);if(await r.run(),Di(process.env))process.stdout.write(Ji(""));return{saved:r.saved,installs:r.installs}}async function CM(t){let e=J(),n=we(e),r=On(n.palettes,t);if(!process.stdin.isTTY||!process.stdout.isTTY)throw Error("needs a terminal");let i=new Tg(e,n,r,r.booru??""),o=await i.run();if(i.saved&&o!==0)return process.stderr.write(`${i.saved}
|
|
723
|
+
`),0;return o}var So=((t)=>{return t[t.Border=-1]="Border",t[t.Data=0]="Data",t[t.Function=1]="Function",t[t.Position=2]="Position",t[t.Timing=3]="Timing",t[t.Alignment=4]="Alignment",t})(So||{}),H4=[0,1],_M=[1,0],GM=[2,3],BM=[3,2],F4={L:H4,M:_M,Q:GM,H:BM},L4=/^\d*$/,C4=/^[A-Z0-9 $%*+./:-]*$/,Hg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Cg=1,jg=40,jM=3,j4=3,Sf=40,_4=10,UM=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],WM=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class KM{constructor(t,e,n,r){if(this.version=t,this.ecc=e,t<Cg||t>jg)throw RangeError("Version value out of range");if(r<-1||r>7)throw RangeError("Mask value out of range");this.size=t*4+17;let i=Array.from({length:this.size}).fill(!1);for(let s=0;s<this.size;s++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(n);if(this.drawCodewords(o),r===-1){let s=1e9;for(let a=0;a<8;a++){this.applyMask(a),this.drawFormatBits(a);let c=this.getPenaltyScore();if(c<s)r=a,s=c;this.applyMask(a)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(t,e){return t>=0&&t<this.size&&e>=0&&e<this.size&&this.modules[e][t]}drawFunctionPatterns(){for(let n=0;n<this.size;n++)this.setFunctionModule(6,n,n%2===0,So.Timing),this.setFunctionModule(n,6,n%2===0,So.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let t=this.getAlignmentPatternPositions(),e=t.length;for(let n=0;n<e;n++)for(let r=0;r<e;r++)if(!(n===0&&r===0||n===0&&r===e-1||n===e-1&&r===0))this.drawAlignmentPattern(t[n],t[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){let e=this.ecc[1]<<3|t,n=e;for(let i=0;i<10;i++)n=n<<1^(n>>>9)*1335;let r=(e<<10|n)^21522;for(let i=0;i<=5;i++)this.setFunctionModule(8,i,$r(r,i));this.setFunctionModule(8,7,$r(r,6)),this.setFunctionModule(8,8,$r(r,7)),this.setFunctionModule(7,8,$r(r,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,$r(r,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,$r(r,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,$r(r,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let n=0;n<12;n++)t=t<<1^(t>>>11)*7973;let e=this.version<<12|t;for(let n=0;n<18;n++){let r=$r(e,n),i=this.size-11+n%3,o=Math.floor(n/3);this.setFunctionModule(i,o,r),this.setFunctionModule(o,i,r)}}drawFinderPattern(t,e){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),o=t+r,s=e+n;if(o>=0&&o<this.size&&s>=0&&s<this.size)this.setFunctionModule(o,s,i!==2&&i!==4,So.Position)}}drawAlignmentPattern(t,e){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(t+r,e+n,Math.max(Math.abs(r),Math.abs(n))!==1,So.Alignment)}setFunctionModule(t,e,n,r=So.Function){this.modules[e][t]=n,this.types[e][t]=r}addEccAndInterleave(t){let e=this.version,n=this.ecc;if(t.length!==Ef(e,n))throw RangeError("Invalid argument");let r=WM[n[0]][e],i=UM[n[0]][e],o=Math.floor(Fg(e)/8),s=r-o%r,a=Math.floor(o/r),c=[],u=J4(i);for(let l=0,d=0;l<r;l++){let h=t.slice(d,d+a-i+(l<s?0:1));d+=h.length;let m=Y4(h,u);if(l<s)h.push(0);c.push(h.concat(m))}let f=[];for(let l=0;l<c[0].length;l++)c.forEach((d,h)=>{if(l!==a-i||h>=s)f.push(d[l])});return f}drawCodewords(t){if(t.length!==Math.floor(Fg(this.version)/8))throw RangeError("Invalid argument");let e=0;for(let n=this.size-1;n>=1;n-=2){if(n===6)n=5;for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let o=n-i,a=(n+1&2)===0?this.size-1-r:r;if(!this.types[a][o]&&e<t.length*8)this.modules[a][o]=$r(t[e>>>3],7-(e&7)),e++}}}applyMask(t){if(t<0||t>7)throw RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let n=0;n<this.size;n++){let r;switch(t){case 0:r=(n+e)%2===0;break;case 1:r=e%2===0;break;case 2:r=n%3===0;break;case 3:r=(n+e)%3===0;break;case 4:r=(Math.floor(n/3)+Math.floor(e/2))%2===0;break;case 5:r=n*e%2+n*e%3===0;break;case 6:r=(n*e%2+n*e%3)%2===0;break;case 7:r=((n+e)%2+n*e%3)%2===0;break;default:throw Error("Unreachable")}if(!this.types[e][n]&&r)this.modules[e][n]=!this.modules[e][n]}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let o=!1,s=0,a=[0,0,0,0,0,0,0];for(let c=0;c<this.size;c++)if(this.modules[i][c]===o){if(s++,s===5)t+=jM;else if(s>5)t++}else{if(this.finderPenaltyAddHistory(s,a),!o)t+=this.finderPenaltyCountPatterns(a)*Sf;o=this.modules[i][c],s=1}t+=this.finderPenaltyTerminateAndCount(o,s,a)*Sf}for(let i=0;i<this.size;i++){let o=!1,s=0,a=[0,0,0,0,0,0,0];for(let c=0;c<this.size;c++)if(this.modules[c][i]===o){if(s++,s===5)t+=jM;else if(s>5)t++}else{if(this.finderPenaltyAddHistory(s,a),!o)t+=this.finderPenaltyCountPatterns(a)*Sf;o=this.modules[c][i],s=1}t+=this.finderPenaltyTerminateAndCount(o,s,a)*Sf}for(let i=0;i<this.size-1;i++)for(let o=0;o<this.size-1;o++){let s=this.modules[i][o];if(s===this.modules[i][o+1]&&s===this.modules[i+1][o]&&s===this.modules[i+1][o+1])t+=j4}let e=0;for(let i of this.modules)e=i.reduce((o,s)=>o+(s?1:0),e);let n=this.size*this.size,r=Math.ceil(Math.abs(e*20-n*10)/n)-1;return t+=r*_4,t}getAlignmentPatternPositions(){if(this.version===1)return[];else{let t=Math.floor(this.version/7)+2,e=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,n=[6];for(let r=this.size-7;n.length<t;r-=e)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(t){let e=t[1],n=e>0&&t[2]===e&&t[3]===e*3&&t[4]===e&&t[5]===e;return(n&&t[0]>=e*4&&t[6]>=e?1:0)+(n&&t[6]>=e*4&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,n){if(t)this.finderPenaltyAddHistory(e,n),e=0;return e+=this.size,this.finderPenaltyAddHistory(e,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(t,e){if(e[0]===0)t+=this.size;e.pop(),e.unshift(t)}}function kr(t,e,n){if(e<0||e>31||t>>>e!==0)throw RangeError("Value out of range");for(let r=e-1;r>=0;r--)n.push(t>>>r&1)}function $r(t,e){return(t>>>e&1)!==0}class Mf{constructor(t,e,n){if(this.mode=t,this.numChars=e,this.bitData=n,e<0)throw RangeError("Invalid argument");this.bitData=n.slice()}getData(){return this.bitData.slice()}}var G4=[1,10,12,14],B4=[2,9,11,13],U4=[4,8,16,16];function zM(t,e){return t[Math.floor((e+7)/17)+1]}function qM(t){let e=[];for(let n of t)kr(n,8,e);return new Mf(U4,t.length,e)}function W4(t){if(!DM(t))throw RangeError("String contains non-numeric characters");let e=[];for(let n=0;n<t.length;){let r=Math.min(t.length-n,3);kr(Number.parseInt(t.substring(n,n+r),10),r*3+1,e),n+=r}return new Mf(G4,t.length,e)}function K4(t){if(!JM(t))throw RangeError("String contains unencodable characters in alphanumeric mode");let e=[],n;for(n=0;n+2<=t.length;n+=2){let r=Hg.indexOf(t.charAt(n))*45;r+=Hg.indexOf(t.charAt(n+1)),kr(r,11,e)}if(n<t.length)kr(Hg.indexOf(t.charAt(n)),6,e);return new Mf(B4,t.length,e)}function z4(t){if(t==="")return[];else if(DM(t))return[W4(t)];else if(JM(t))return[K4(t)];else return[qM(D4(t))]}function DM(t){return L4.test(t)}function JM(t){return C4.test(t)}function q4(t,e){let n=0;for(let r of t){let i=zM(r.mode,e);if(r.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+r.bitData.length}return n}function D4(t){t=encodeURI(t);let e=[];for(let n=0;n<t.length;n++)if(t.charAt(n)!=="%")e.push(t.charCodeAt(n));else e.push(Number.parseInt(t.substring(n+1,n+3),16)),n+=2;return e}function Fg(t){if(t<Cg||t>jg)throw RangeError("Version number out of range");let e=(16*t+128)*t+64;if(t>=2){let n=Math.floor(t/7)+2;if(e-=(25*n-10)*n-55,t>=7)e-=36}return e}function Ef(t,e){return Math.floor(Fg(t)/8)-UM[e[0]][t]*WM[e[0]][t]}function J4(t){if(t<1||t>255)throw RangeError("Degree out of range");let e=[];for(let r=0;r<t-1;r++)e.push(0);e.push(1);let n=1;for(let r=0;r<t;r++){for(let i=0;i<e.length;i++)if(e[i]=Lg(e[i],n),i+1<e.length)e[i]^=e[i+1];n=Lg(n,2)}return e}function Y4(t,e){let n=e.map((r)=>0);for(let r of t){let i=r^n.shift();n.push(0),e.forEach((o,s)=>n[s]^=Lg(o,i))}return n}function Lg(t,e){if(t>>>8!==0||e>>>8!==0)throw RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(e>>>r&1)*t;return n}function V4(t,e,n=1,r=40,i=-1,o=!0){if(!(Cg<=n&&n<=r&&r<=jg)||i<-1||i>7)throw RangeError("Invalid value");let s,a;for(s=n;;s++){let l=Ef(s,e)*8,d=q4(t,s);if(d<=l){a=d;break}if(s>=r)throw RangeError("Data too long")}for(let l of[_M,GM,BM])if(o&&a<=Ef(s,l)*8)e=l;let c=[];for(let l of t){kr(l.mode[0],4,c),kr(l.numChars,zM(l.mode,s),c);for(let d of l.getData())c.push(d)}let u=Ef(s,e)*8;kr(0,Math.min(4,u-c.length),c),kr(0,(8-c.length%8)%8,c);for(let l=236;c.length<u;l^=253)kr(l,8,c);let f=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((l,d)=>f[d>>>3]|=l<<7-(d&7)),new KM(s,e,f,i)}function YM(t,e){let{ecc:n="L",boostEcc:r=!1,minVersion:i=1,maxVersion:o=40,maskPattern:s=-1,border:a=1}=e||{},c=typeof t==="string"?z4(t):Array.isArray(t)?[qM(t)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof t}`);let u=V4(c,F4[n],i,o,s,r),f=Z4({version:u.version,maskPattern:u.mask,size:u.size,data:u.modules,types:u.types},a);if(e?.invert)f.data=f.data.map((l)=>l.map((d)=>!d));return e?.onEncoded?.(f),f}function Z4(t,e=1){if(!e)return t;let{size:n}=t,r=n+e*2;t.size=r,t.data.forEach((o)=>{for(let s=0;s<e;s++)o.unshift(!1),o.push(!1)});for(let o=0;o<e;o++)t.data.unshift(Array.from({length:r},(s)=>!1)),t.data.push(Array.from({length:r},(s)=>!1));let i=So.Border;t.types.forEach((o)=>{for(let s=0;s<e;s++)o.unshift(i),o.push(i)});for(let o=0;o<e;o++)t.types.unshift(Array.from({length:r},(s)=>i)),t.types.push(Array.from({length:r},(s)=>i));return t}var X4=_b(16,231),Q4=[" ","▀","▄","█"],t6=2953;function VM(t){if(Buffer.byteLength(t)>t6)return;let{data:e}=YM(t,{border:2,boostEcc:!0}),n=[];for(let r=0;r<e.length;r+=2){let i=e[r]??[],o=e[r+1]??[];n.push(`${X4}${i.map((s,a)=>Q4[(s?1:0)+(o[a]?2:0)]).join("")}${me}`)}return n}var e6=50;function n6(t){return{background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selection,ansi:t.ansi}}function r6(t,e,n){for(let r of n){let i=t-4-r.length;if(i>e.length+2)return[[2,e],[i,` ${r} `]]}return[[2,e]]}function ZM(t,e,n,r=e6){let i=xe(n),o=tn(n6(e)),s=mk(t).map((p)=>p.toLowerCase()),a=cg(o,e.signatureSlots,e.waived??[]),c=Yn(gr(o,e.signatureSlots,e.waived??[])).length,u=(p)=>o[p]?.toLowerCase()!==s[p],f=o.filter((p,b)=>u(b)).length,l=(p)=>{let b=o[p],$=e.signatureSlots.includes(jn[p])?N.signature:n?N.swatch:" ",k=n?`${i.fg(b)}${$}${wt}`:$,v=a.has(p)?i.bold(N.miss):u(p)?i.warn(N.on):" ";return` ${k} ${lf(xt(b))}${v}`},d=c===0?"passes the gate":`${c} ${c===1?"miss":"misses"} in the gate`,h=f>0?[`${f} tuned · ${d}`,d]:[d],m=[i.dim(Jt(r,"top",r6(r," Palette ",h)))];for(let p=0;p<T.length;p++)m.push(Je(i,` ${T[p].padEnd(10)}${l(p)}`,r));return m.push(i.dim(Jt(r,"mid",[[2," ANSI "],[12," Normal 0–7 "],[29," Bright 8–15 "]]))),pn.forEach((p,b)=>{m.push(Je(i,` ${p.padEnd(10)}${l(T.length+b)}${l(T.length+8+b)}`,r))}),m.push(i.dim(Jt(r,"bottom"))),m}function zs(){return process.stdin.isTTY===!0&&process.stdout.isTTY===!0}async function Gg(){let t=process.env.TTHEME_WORN;if(!t||!zs())return;let e=await Ce({message:`Use ${t}, the palette this tab wears?`});if(te(e)||!e)throw new de;return t}async function tx(t){let e=process.env.TTHEME_WORN;if(!e)return;if(!zs())return console.error(`Sharing ${e}, the palette this tab wears`),{name:e,...t?{tone:t}:{}};if(t!==void 0||Ut(J())[e]===void 0)return await Gg(),{name:e,...t?{tone:t}:{}};let n=await Vh({message:`Share ${e}, the palette this tab wears?`,options:[{value:"tuned",label:"Your tone",hint:`named ${Ac(e)}`},{value:"original",label:"The original"},{value:"no",label:"No"}]});if(te(n)||n==="no")throw new de;return{name:e,tone:n}}function ex(t,e){if(t.includes("/"))return t;let n=Wi(e,!1),r=n.filter((o)=>rs(o.dir).some((s)=>s.slug===t)),[i]=r.length===1?r:n.length===1?n:[];return i?`${i.id}/${t}`:t}function s6(t,e,n){let r=z(t),i=n.filter((o)=>!r.palettes.includes(o));if(i.length>0)Xe(t,e,r,{...r,palettes:[...r.palettes,...i]});else if(n.some((o)=>r.palettes.includes(o)))Kt(t,e,r);return{state:r,fresh:i}}function a6(t){let e=Math.max(0,...t.map((n)=>n.slot.length));return t.map((n)=>` ${n.slot.padEnd(e)} ${n.from} → ${n.to} ${n.rule}`)}function XM(t){return JSON.stringify([t.background,t.foreground,t.cursor,t.selection,t.ansi])}function nx(t,e,n){let r=lk(e,n.palettes),i=rr(t,n,!1).palettes.find((o)=>o.name===r.name);if(i&&XM(i)!==XM(r))throw Error(`${r.name} is already in ${ut(r.name)??"the ttheme catalog"} and differs — \`ttheme add ${r.name}\` wears that one`);if(!i)ss(t,[...qr(t),r]);return r}var c6=["background","foreground","cursor"];function rx(t){try{t();return}catch(e){return e.message}}function ix(t,e,n){return Wt(t,e,!1).palettes.filter((r)=>r.name!==n).map((r)=>({name:r.name,colors:{background:r.background,foreground:r.foreground,cursor:r.cursor,selection:r.selection,ansi:r.ansi}}))}function ox(t,e){let n=new Set(ge(t,e).map((r)=>r.key));return{count:()=>ge(t,e).length,added:()=>ge(t,e).filter((r)=>!n.has(r.key)).length,fresh:()=>(nf(t,e)??[]).filter((r)=>!n.has(le(r))),discard:()=>{let r=ge(t,e).filter((i)=>!n.has(i.key));for(let i of r)Jo(t,e,i.key),hu(t,e);if(r.length>0)_e(t)}}}function u6(...t){let e=new Map;for(let n of t.flatMap((r)=>r??[]))e.set(le(n),n);return e.size>0?[...e.values()]:void 0}function sx(t,e,n,r){if(!ls(process.env,z(t).terminals))return;return async(i,o)=>{let s=an(Mn(e,r(i),n.palettes)),{saved:a}=await LM(t,s,o);return{...a?{note:a}:{},count:ge(t,e).length}}}async function Bg(t,e=!1){let n=process.stdout.isTTY===!0,r=J(),i=z(r).terminals,o=n?sf.of(process.env,r,t.name,i):void 0,s=n?pf.of(process.env,i):void 0;return $M(t,{color:!Ht(),...o?{backdrop:o}:{},...s?{layer:s}:{},...e?{hosted:!0}:{}})}async function ax(t,e,n){let r=J(),i=at(r),o=await _v(r,n),s=t.includes("/")?t:`${o.id}/${t}`,a=Te(s);if(a)throw Error(`${s} ${a}`);if(ut(s)!==o.id)throw Error(`palettes in ${o.dir} are named ${o.id}/<palette> — ${s} belongs elsewhere`);let c=vh(r,s);if(Tc(c))throw Error(`${s} already exists — \`ttheme edit ${s}\` changes it`);let u=e?On(Wt(r,i).palettes,e):void 0;if(!zs())throw Error("new opens the palette editor — run it in a terminal");let f=u&&(ut(u.name)?u.base:u.default?void 0:u.name),l=u?Eh(u,s,`kept from ${u.name}`):void 0,d=u?nf(r,u.name)??u.pictures:void 0,{base:h,ansiSource:m,group:p,...b}=l??{name:s,signature:c6,...mi(bc)},$=ox(r,s),k=({colors:x,signature:M})=>{let P=u6(d,$.fresh());return Mh({...b,...x,signature:M,...f?{base:f}:{},...P?{pictures:P}:{}})},v=await Bg({title:"New palette",name:s,...l?{colors:l}:{},signature:b.signature,...b.waive?{waive:b.waive}:{},palettes:ix(r,i,s),pictures:$.count(),find:sx(r,s,i,k),exports:mx(r,s,i,k),decode:Ug,check:(x)=>rx(()=>Mn(s,k(x),i.palettes))});if(!v){$.discard(),console.log("Nothing made");return}i6(o6(c),{recursive:!0}),C(c,k(v));let{state:S}=s6(r,i,[s]);console.log(` + ${s}${u?` from ${u.name}`:""}
|
|
724
|
+
${c}`),await bo(r,Wt(r,i).palettes.filter((x)=>x.name===s),S.terminals),console.log(`
|
|
725
|
+
\`ttheme use ${s}\` wears it · \`ttheme edit ${s}\` opens it again`)}function l6(t,e,n){let r=an(Mn(t,e,n.palettes));return Ia(r).length>0?Sa(r).filter((i)=>i.startsWith(" ✗")):[]}async function cx(t){let e=J(),n=at(e),r=z(e),i=Wt(e,n,!1),o=ex(t,e),s=xf(e,o),a=s&&Tc(s)?o:i.palettes.some((k)=>k.name===t)?t:o,c=xf(e,a),u=!c||!Tc(c);if(u&&!i.palettes.some((k)=>k.name===a))throw Error(`no palette called ${a} — \`ttheme new\` makes one`);if(!zs())throw Error("edit opens the palette editor — run it in a terminal");if(u){let k=await fx(e,a,!1);console.log(k===void 0?"Nothing changed":k===0?`${a} is back to its own colors`:`Saved ${a} · ${lx(k)} — R then s in \`ttheme edit ${a}\` puts its own colors back`);return}let f=_g(c,"utf8"),l;try{l=Mn(a,f,n.palettes)}catch(k){throw Error(`${c} cannot be read — ${k.message}`)}let d=ox(e,a),h=new Set((l.pictures??[]).map((k)=>le(k))),m=({colors:k,signature:v})=>ok(fk(Ih(f,k),v),d.fresh().filter((S)=>!h.has(le(S)))),p=await Bg({title:"Edit palette",name:a,colors:os(l),signature:l.signatureSlots,waive:l.waive,palettes:ix(e,n,a),pictures:d.count(),find:sx(e,a,n,m),exports:mx(e,a,n,m),decode:Ug,check:(k)=>rx(()=>Mn(a,m(k),n.palettes))});if(!p){d.discard(),console.log("Nothing changed");return}let b=m(p);if(b===f){console.log(d.added()>0?`Kept the pictures you added to ${a}`:"Nothing changed");return}if(C(c,b),r.palettes.includes(a))Kt(e,n,r);console.log(`Saved ${a}${r.palettes.includes(a)?" — new tabs and `ttheme use` wear it":` — \`ttheme add ${a}\` installs it`}`);let $=l6(a,b,n);if($.length>0)console.log(`
|
|
724
726
|
It misses the contrast gate:
|
|
725
727
|
${$.join(`
|
|
726
728
|
`)}
|
|
727
|
-
\`ttheme check --fix ${a}\` suggests colors that pass`)}var
|
|
728
|
-
`)),0}if(e==="reset"){let o=Ut(r);if(o[t]===void 0)return
|
|
729
|
-
`),console.log(
|
|
730
|
-
`)),
|
|
731
|
-
Passes the gate`),0;let{theme:a,moves:c,left:u}=
|
|
729
|
+
\`ttheme check --fix ${a}\` suggests colors that pass`)}var QM=2;async function ux(t,e,n){let r=J();if(e==="show"){let o=On(rr(r,at(r),!1).palettes,t),s=Oa(o,Ut(r)[t]);return console.log(ZM(o,s,!Ht(),n===void 0?void 0:Number(n)).join(`
|
|
730
|
+
`)),0}if(e==="reset"){let o=Ut(r);if(o[t]===void 0)return QM;return xa(r,Ou(o,t,{})),Kt(r,at(r),z(r)),process.stderr.write("Back to the original colors"),0}if(e!=="edit")throw Error(`tone takes show, edit or reset, not ${e}`);if(!zs())throw Error("needs a terminal");let i=await fx(r,t,!0);if(i===void 0)return QM;return process.stderr.write(i===0?"Back to the original colors":`Saved · ${lx(i)}`),0}function lx(t){return`${t} ${t===1?"color":"colors"} tuned`}async function fx(t,e,n){let r=On(rr(t,at(t),!1).palettes,e),i=Oa(r,Ut(t)[e]),o=await Bg({title:"Edit palette",name:e,colors:os(Fe(i)),original:os(Fe(r)),tone:!0,signature:i.signatureSlots,...i.waived?{waive:i.waived}:{},decode:Ug,check:()=>{return}},n);if(!o)return;let s=Ut(t),a=Ph(r,tn(o.colors));if(JSON.stringify(a)===JSON.stringify(s[e]??{}))return;return xa(t,Ou(s,e,a)),Kt(t,at(t),z(t)),Object.keys(a).length}function dx(t,e,n){return On(t.palettes,t.palettes.some((r)=>r.name===e)?e:ex(e,n))}function hx(t,e=!1){let n=J(),r=at(n),i=z(n),o=dx(Wt(n,r),t,n);if(console.log(`${o.name} · ${o.group}
|
|
731
|
+
`),console.log(Sa(o).join(`
|
|
732
|
+
`)),Ia(o).length===0)return console.log(`
|
|
733
|
+
Passes the gate`),0;let{theme:a,moves:c,left:u}=Zl(Fe(o));if(c.length===0)return console.log(`
|
|
732
734
|
No color change fixes it — waive the rule in [contrast] with a reason, or pick other colors`),1;console.log(`
|
|
733
735
|
${u.length===0?"These colors pass":"These colors come closer"}:
|
|
734
|
-
${
|
|
735
|
-
`)}`);let f
|
|
736
|
-
\`ttheme check --fix ${o.name}\` writes them${l?" as your tone of it":""}`),1;if(l){let d=
|
|
737
|
-
Saved as your tone of ${o.name} — R then s in \`ttheme edit ${o.name}\` puts its own colors back`),u.length===0?0:1}if(
|
|
738
|
-
Wrote ${f}`),u.length===0?0:1}function
|
|
739
|
-
${
|
|
740
|
-
`)}`)
|
|
741
|
-
Anyone can open the link or scan the code to see ${a.name}, and ttheme add <link> installs it${c?`
|
|
742
|
-
It carries your tone, named ${a.name} so it does not clash with ${s.name}`:""}`)}import{spawn as
|
|
743
|
-
${t} palettes installed — open a new tab, or reload your terminal config`)}function
|
|
744
|
-
`))}function
|
|
745
|
-
`))}function
|
|
746
|
-
${d} palettes — ${a.filter((h)=>i.has(h.name)).length} installed`)}}function
|
|
747
|
-
${n.length} themes (${
|
|
748
|
-
`)),0}async function
|
|
749
|
-
`),0}if(e==="drop"){let{key:i,left:o}=
|
|
750
|
-
`),0}if(e==="tone"||e==="original"){let i=await
|
|
751
|
-
`),0}if(e==="prepare"){let{key:i,coloring:o}=
|
|
752
|
-
`),0}if(e==="tuned")return _e(r),0;throw Error(`unknown image action ${e} — show, drop, tone, original, prepare or tuned`)}function
|
|
753
|
-
`)[0]:void 0)??t.SHELL??"unknown"}function
|
|
754
|
-
ttheme() { ${
|
|
755
|
-
`)}function
|
|
756
|
-
`)}function
|
|
736
|
+
${a6(c).join(`
|
|
737
|
+
`)}`);let f=xf(n,o.name),l=!f||!Tc(f);if(!e)return console.log(`
|
|
738
|
+
\`ttheme check --fix ${o.name}\` writes them${l?" as your tone of it":""}`),1;if(l){let d=On(rr(n,r,!1).palettes,o.name);return xa(n,Ou(Ut(n),o.name,Ph(d,tn(os(a))))),Kt(n,r,i),console.log(`
|
|
739
|
+
Saved as your tone of ${o.name} — R then s in \`ttheme edit ${o.name}\` puts its own colors back`),u.length===0?0:1}if(C(f,Ih(_g(f,"utf8"),os(a))),i.palettes.includes(o.name))Kt(n,r,i);return console.log(`
|
|
740
|
+
Wrote ${f}`),u.length===0?0:1}function xf(t,e){let n=ut(e);return n&&Wi(t,!1).some((r)=>r.id===n)?vh(t,e):void 0}function Ug(t){let e=is(t);if(!e)return;try{let{background:n,foreground:r,cursor:i,selection:o,ansi:s}=Oh(e);return{background:n,foreground:r,cursor:i,selection:o,ansi:s}}catch{return}}function mx(t,e,n,r){return{code:(i)=>xh(px(t,an(Mn(e,r(i),n.palettes)))),toml:r,command:"ttheme add"}}function px(t,e){let n=xf(t,e.name),r=n&&Tc(n)?Mn(e.name,_g(n,"utf8"),[e]).waiveReason:void 0,i=nf(t,e.name)??e.pictures,{pictures:o,...s}=Eh(e,e.name,r);return{...s,...i?{pictures:i}:{}}}async function f6(t,e,n){if(t===e)return e;let r=n;if(r===void 0)if(!zs())r="tuned";else{let i=await Vh({message:`Share ${e.name} as…`,options:[{value:"tuned",label:"Your tone",hint:`named ${Ac(e.name)}`},{value:"original",label:"The original"}]});if(te(i))throw new de;r=i}return r==="original"?e:t}function Ac(t){return`${t}-tuned`}async function Wg(t,e){let n=J(),r=at(n),i=dx(rr(n,r),t,n),o=Oa(i,Ut(n)[i.name]),s=await f6(o,i,e),a=px(n,s),c=s===o&&o!==i;if(c){let f=Te(Ac(s.name));if(f)throw Error(`${Ac(s.name)} ${f} — share the original, or tune a palette with a shorter name`);a.name=Ac(s.name)}let u=uk(xh(a));if(console.log(u),process.stdout.isTTY){let f=VM(u);if(f)console.log(`
|
|
741
|
+
${f.join(`
|
|
742
|
+
`)}`);console.error(`
|
|
743
|
+
Anyone can open the link${f?" or scan the code":""} to see ${a.name}, and ttheme add <link> installs it${c?`
|
|
744
|
+
It carries your tone, named ${a.name} so it does not clash with ${s.name}`:""}`)}}import{spawn as d6,spawnSync as gx}from"node:child_process";import{existsSync as h6,readFileSync as bx}from"node:fs";import{homedir as m6}from"node:os";import{join as wx}from"node:path";function $x(t,e,n,r=m6(),i=(o)=>{process.stdout.write(o)}){if(!e||Ht(t)||t.TMUX||Vt(t)!=="terminal-app")return;let[o="",s="-"]=(t.TTHEME_TERMINAL_SHOWN??"").split(" "),a=t.TTHEME_TTY,c=o?He(X(n),o,r):void 0,u=al(ys(n)).get(ue(o))??[],f=u.find((B)=>B===`${j(o)}.${s}.png`)??u[0];if(!a||!c||s==="-"||!f||!h6(c.image))return;let l=wx(ys(n),f),d=["-l","JavaScript",sl(n),"tab",a,dn(o)],h=z(n).terminalBase??"Basic",m=Bm(t,r),p=bx(l),b,$=l,k=0,v,S=!1,x=!1,M,P=(B)=>{S=!0,d6("osascript",[...d,h],{stdio:"ignore"}).on("close",()=>{if(S=!1,x)return;i(B);let F=M;M=void 0,F?.()})},L=(B,F)=>{b??=Gt(new Uint8Array(bx(c.image)));let pt=wx(ys(n),`${j(o)}.h${process.pid}-${++k}.png`);xi($,pt,Tr(Ar(b,B,c.opacity,Um(b.width,b.height,c,m)))),$=pt,P(F)},A=()=>{if($!==l)xi($,l,p),$=l},_=(B)=>{clearTimeout(v),v=setTimeout(()=>{if(S)M=B;else B()},am)},q=()=>{clearTimeout(v),M=void 0};return{slots:[],paint(B){return _(B.name===o?()=>{A(),P("")}:()=>L(B.background,cr(B))),""},wear(B){return gx("osascript",[...d.slice(0,-1),dn(B.name),h],{encoding:"utf8"}).stdout?.trim()==="worn"?"":cr(B)},saved:async()=>new Map,restore(){return q(),x=!0,A(),gx("osascript",[...d,h],{stdio:"ignore"}),""},stop:q}}import{existsSync as Hc,readdirSync as p6,readFileSync as If,rmSync as kx,statSync as vx}from"node:fs";import{homedir as g6}from"node:os";import{join as Eo}from"node:path";var b6=150,w6=260;function Of(t){return t?.includes(`path = "${j("")}`)===!0}function $6(t){try{return z(t).terminals.includes("warp")}catch{return!1}}function yx(t,e){let n=j(e);if(!Hc(t))return;return p6(t).filter((i)=>i.startsWith(`${n}.`)&&/^[0-9a-f]{8}\.yaml$/.test(i.slice(n.length+1))).map((i)=>({file:i,at:vx(Eo(t,i)).mtimeMs})).sort((i,o)=>o.at-i.at)[0]?.file??(Hc(Eo(t,`${n}.yaml`))?`${n}.yaml`:void 0)}function k6(t,e){if(!e)return;let n;try{n=If(Eo(t,e),"utf8")}catch{return}let r=/^background_image:\n\s+path:\s*"([^"]*)"\n\s+opacity:\s*(\d+)/m.exec(n);return r?.[1]?{image:r[1],opacity:Number(r[2])/100}:void 0}function Sx(t,e,n,r=g6()){if(!e||Ht(t)||t.TMUX||Vt(t)!=="warp")return;let i=si(r,n);if(!Hc(i)||!$6(n))return;let o=Qi(r),s=ll(n),a=[],c=t.TTHEME_WARP_WEARS??je(z(n)),u=k6(o,c&&yx(o,c)),f,l,d=(b)=>{let $=If(i,"utf8"),k=ai($);if(k===b)return;if(Of(b)&&!Of(k)&&!Hc(s))C(s,k??"");if($n(i,fl($,b)),!Of(b))kx(s,{force:!0})},h=(b)=>{for(let $ of a.splice(0))if($===b)a.push($);else kx(Eo(o,$),{force:!0})},m=()=>{clearTimeout(f),clearTimeout(l)},p=(b,$,k)=>{m(),f=setTimeout(()=>{let v=$;if(!v)v=`${j(b.name)}.view-${process.pid}-${a.length+1}.yaml`,C(Eo(o,v),La(b,k)),a.push(v);let S=v,x=Date.now()-vx(Eo(o,S)).mtimeMs;l=setTimeout(()=>{d(qm(b.name,S)),h(S)},Math.max(0,w6-x))},b6)};return{slots:[],paint:(b)=>{if(b.name===c)p(b,yx(o,b.name));else if(u)p(b,void 0,u);else p(b,Hc(Eo(o,`${j(b.name)}.yaml`))?`${j(b.name)}.yaml`:void 0);return""},wear:(b,$)=>$.includes("warp")?"":void 0,saved:async()=>new Map([["theme",ai(If(i,"utf8"))??""]]),restore:(b)=>{m();let $=b.get("theme");if($)d($);else if(Of(ai(If(i,"utf8"))))d(ul);return h(),""}}}function qs(t,e,n){return $x(t,e,n)??yy(t,e)??Sx(t,e,n)}function Pf(t){An(`
|
|
745
|
+
${t} palettes installed — open a new tab, or reload your terminal config`)}function v6(t,e){return t.map((n)=>{if(is(n))return n;let r=ut(n);if(r===void 0)return e===V?n:`${e}/${n}`;if(r!==e)throw Error(`${n} is not in ${e} — give its bare name, or leave --market out`);return n})}async function Ex(t,e){let n=t.find((d)=>/^https?:\/\//i.test(d.trim())&&!is(d));if(n)throw Error(`${n} is not a share link — one reads ${kh}tt2:…`);let r=J(),i=e?v6(t,(await $p(r,e)).id):t,o=at(r),s=new Map,a=[...new Set(i.map((d)=>{let h=is(d);if(!h)return d;let m=nx(r,h,o);return s.set(m.name,m),m.name}))],c=z(r),u=a.filter((d)=>c.palettes.includes(d)),f=a.filter((d)=>!c.palettes.includes(d));if(f.length===0){Kt(r,o,c),console.log(`Already installed: ${u.join(", ")}`);return}let l={...c,palettes:[...c.palettes,...f]};Xe(r,o,c,l);for(let d of f)console.log(` + ${d}`);await bo(r,Wt(r,o,!1).palettes.filter((d)=>f.includes(d.name)).map((d)=>{let h=s.get(d.name);return h?{...d,pictures:h.pictures}:d}),l.terminals),Pf(l.palettes.length)}function Mx(t){let e=J(),n=at(e),r=z(e),i=t.filter((a)=>r.palettes.includes(a)),o=t.filter((a)=>!r.palettes.includes(a));if(i.length===0)throw Error(`not installed: ${o.join(", ")} — \`ttheme list\` marks what is`);let s={...r,palettes:r.palettes.filter((a)=>!i.includes(a))};Xe(e,n,r,s),Es(e,n,r.terminals,i);for(let a of i)console.log(` - ${a}`);if(Pf(s.palettes.length),o.length>0)return console.error(`ttheme remove: not installed: ${o.join(", ")}`),1;return 0}function xx(t){let e=J(),n=at(e),r=z(e);if(!r.palettes.includes(t))throw Error(`${t} is not installed — \`ttheme add ${t}\` first`);let{off:i,...o}=r,s=Xe(e,n,r,{...o,startup:t},!0);console.log(Rx(t,r.terminals,s).join(`
|
|
746
|
+
`))}function Ox(){let t=J();Kt(t,at(t),z(t))}function Ix(){let t=J(),e=z(t),n=eo(e);if(!n)throw Error("no palettes installed — `ttheme` picks some");if(!e.off){console.log(`Already on · ${n}`);return}let{off:r,...i}=e,o=Xe(t,at(t),e,i);console.log(Rx(n,i.terminals,o).join(`
|
|
747
|
+
`))}function Px(){let t=J(),e=z(t);if(e.off){console.log("Already off");return}let n=Xe(t,at(t),e,{...e,off:!0}),r=eo(e);console.log(`Off · new tabs open in the terminal's own colors${r?` — \`ttheme on\` wears ${r} again`:""}`);for(let i of yt(e.terminals))if(n.get(i.id)?.restart)console.log(`${i.name} new tabs open on your own profile once ${i.name} restarts`)}function Rx(t,e,n){let r=yt(e).filter((o)=>!o.defaults),i=r.length>0?[`Default ${t} · ${r.map((o)=>o.name).join(", ")} open new tabs with it once their config reloads`]:[];for(let o of yt(e)){let s=o.defaults?.profile(t);if(s)i.push(n.get(o.id)?.restart?`${o.name} new tabs open with it once ${o.name} restarts — "${s}" is now its default profile`:`${o.name} new tabs open with it — "${s}" is its default profile`)}return i.length>0?i:[`Default ${t} · no terminal is wired to open with it — \`ttheme init\` wires one`]}function S6(t,e){let n=new Map(e.palettes.map((r)=>[r.name,"market"]));for(let r of Mu(t,e.palettes,!1))n.set(r.name,"mine");return n}function Nx(t,e=!1){let n=J(),r=at(n),i=new Set(z(n).palettes),o=S6(n,r),s=At(Wt(n,r).palettes);if(t)Bi(s);let a=Li(t?xk(s,t):s),c=(d)=>o.get(d)??"kept";if(e){let d=a.map((h)=>({name:h.name,group:h.group,...h.catalog?{catalog:h.catalog}:{},installed:i.has(h.name),source:c(h.name)}));console.log(JSON.stringify(d,null,2));return}let u=Math.max(...a.map((d)=>d.name.length),0),f={market:"",mine:" · yours",kept:" · in no market you added"},l=Ut(n);for(let d of a){let h=d.catalog?`${d.group} / ${d.catalog}`:d.group,m=l[d.name]?" · tuned":"";console.log(` ${i.has(d.name)?"●":"○"} ${d.name.padEnd(u)} ${h}${f[c(d.name)]}${m}`)}if(process.stdout.isTTY){let d=t?`${a.length} of ${s.length}`:`${s.length}`;console.log(`
|
|
748
|
+
${d} palettes — ${a.filter((h)=>i.has(h.name)).length} installed`)}}function E6(t,e,n){let r=(o)=>{try{return ui(t,o)}catch{return}},i=e.find((o)=>o===n||rt(o)===n||r(o)===n);if(!i)throw Error(`no market named ${n} — \`ttheme market\` lists them`);return i}async function Ax(t=[]){let e=J(),n=es(e),r=t.map((m)=>E6(e,n,m)),i=await dv(),o=!1;if(i.latest)try{return fv(i.latest,t)}catch(m){o=!0,console.log(` ttheme could not update to ${i.latest}: ${m.message}`)}else console.log(i.note);let s=(r.length>0?r:n).filter((m)=>m!==V);if(r.length===0&&s.length===0)console.log("No markets to update — `ttheme market add <owner>/<repo>` adds one");let a=(m,p)=>`${Ev(m,p)} — kept the copy from the last update`;for(let m of s.filter(Tt))try{console.log(` ${Uv(e,m)}`)}catch(p){console.log(` ${a(m,p)}`)}let c=s.filter((m)=>!Tt(m)),u=new Set(c),f=[],l=ci(),d=()=>l.set(`Updating ${[...u].map(rt).join(", ")}${c.length>1?` · ${c.length-u.size}/${c.length}`:""}`);if(d(),await Promise.all(c.map(async(m)=>{let p=await dp(e,m);if("refreshed"in p)f.push(p.refreshed);if(u.delete(m),u.size>0)d();else l.done();l.say(` ${"refreshed"in p?mp(p.refreshed):a(m,p.failure)}`)})),l.done(),!y6(Qn(e)))return o?1:0;for(let m of so(e,f))console.log(` ${m}`);let h=gp(e);if(h)console.log(h);return o?1:0}async function Tx(t,e){let n=at(t,!1),r=new Map(as(t,n).filter((a)=>e.includes(a.name)).map((a)=>[a.name,a]));if(r.size===0)return;let i=qr(t);ss(t,i.map((a)=>r.get(a.name)??a));let o=z(t);Kt(t,n,o);let s=new Map(i.map((a)=>[a.name,a.pictures]));await bo(t,Wt(t,n,!1).palettes.filter((a)=>r.has(a.name)).map((a)=>SE(a,s.get(a.name))),o.terminals)}async function Kg(t,e,n,r=!1){let i=process.env.TTHEME_SORT==="series"?t.palettes:Li(t.palettes);Bi(i);let o=process.stdout.isTTY===!0,s=qs(process.env,o,J()),a=s?await s.saved():new Map,c=new Rp({entries:i,scope:n,installed:e,required:r,color:!Ht(),fx:Hl(process.env.TTHEME_FX),onFocus:s?(f)=>process.stdout.write(s.paint(f)):void 0}),u=await c.prompt();if(s)process.stdout.write(s.restore(a));if(u==="cancel")return;return t.palettes.filter((f)=>c.picked.has(f.name)).map((f)=>f.name)}function zg(t,e,n,r){let i=n===V?void 0:Ja(t,n),o;try{o=i?.id??ui(t,n)}catch{o=kt(n)?Ur(n):rt(n)}return{source:n,id:o,...i?.info.description?{description:i.info.description}:{},shown:rt(n),entries:n===V?Rs(t,n):i?.entries??[],auto:Wr(n,e.updates),status:vp(t,n,r)}}function qg(t){return as(t,at(t,!1)).map((e)=>e.name)}function M6(t,e,n,r,i){return{refresh:async(o)=>{if(Tt(o)){let a=zg(t,e,o,lr());return{market:a,refreshed:{source:o,id:a.id,count:At(a.entries).length,change:{added:[],changed:[],gone:[]}},updates:qg(t)}}let s=await fp(t,o,cp);return{market:zg(t,e,o,lr()),refreshed:s,updates:qg(t)}},fetch:async(o)=>{if(Tt(o)){let a=cn(o),c=be(a);return{source:o,id:c,...a.description?{description:a.description}:{},shown:rt(o),entries:xn(o,c,Rs(t,V),fe(!1)),auto:!1,status:"read in place"}}let s=await Da(t,o,void 0,r);return n.set(o,s),{source:o,id:s.id,..."info"in s&&s.info.description?{description:s.info.description}:{},shown:rt(o),entries:s.entries,auto:Wr(o,{}),status:"not added yet"}},search:(o)=>Ep(o,r),apply:i}}function Hx(...t){for(let e of so(...t))An(e)}function x6(t,e,n){let r=[];for(let i of t.adds){let o=i.source!==V&&(t.auto[i.source]??i.auto);r.push(`Added ${i.id} · ${i.shown} — ${zt(At(i.entries).length)}${o?", updating on its own":""}`)}for(let i of t.removes){let o=e.find((a)=>a.source===i)?.id??i;r.push(`Removed ${o} · ${rt(i)}`);let s=n.filter((a)=>(ut(a)??V)===o);if(s.length>0)r.push(yp(s))}for(let[i,o]of Object.entries(t.auto)){let s=e.find((a)=>a.source===i);if(s&&!t.removes.includes(i))r.push(`${s.id} ${o?"updates on its own now":"no longer updates on its own"}`)}return r}async function O6(t,e,n,r){let i=z(t),o=n.adds.length+n.removes.length+Object.keys(n.auto).length>0;for(let m of n.adds){let p=r.get(m.source);if(p)Ps(t,p)}for(let m of n.removes)kp(t,m);let s=[...Dt(i.markets).filter((m)=>!n.removes.includes(m)),...n.adds.map((m)=>m.source)],a=Za(i,s,{...i.updates,...n.auto});if(o)Ze(t,a);let c=at(t,!1),u=Wt(t,c,!1).palettes.filter((m)=>n.picked.has(m.name)).map((m)=>m.name),f=i.palettes.filter((m)=>!u.includes(m)),l=u.filter((m)=>!i.palettes.includes(m)),d=n.renew.filter((m)=>u.includes(m));if(!o&&l.length===0&&f.length===0&&d.length===0){Hx(t,n.refreshed),An("Nothing changed");return}let h={...a,palettes:u};Xe(t,c,i,h),Es(t,c,i.terminals,f);for(let m of x6(n,e,u))An(m);for(let m of l)An(` + ${m}`);for(let m of f)An(` - ${m}`);for(let m of so(t,n.refreshed))An(m);if(await bo(t,Wt(t,c,!1).palettes.filter((m)=>l.includes(m.name)),h.terminals),d.length>0){await Tx(t,d);for(let m of d)An(` ↑ ${m}`)}if(l.length>0||f.length>0)Pf(h.palettes.length)}async function Fx(){let t=Lk(process.env),e=J(),n=z(e),r=qr(e),i=lr(),o=Os(),s=Dt(n.markets).map((k)=>zg(e,n,k,i)),a=new Set(s.flatMap((k)=>k.entries.map((v)=>v.name))),c=r.filter((k)=>n.palettes.includes(k.name)&&!a.has(k.name));Bi([...s.flatMap((k)=>k.entries),...c]);let u=new Map,f=new AbortController,l=process.stdout.isTTY===!0,d=qs(process.env,l,e),h=d&&!t?await d.saved():new Map,m=je(n);if(t)process.stdout.write("\x1B[?2026h");let p=new Ap({markets:s,kept:c,installed:n.palettes,updates:qg(e),tuned:Object.keys(Ut(e)),...m?{startup:m}:{},...t?{hub:t}:{},due:o?lp(e,n):[],io:M6(e,n,u,f.signal,(k,v)=>Q1({say:v.say,set:v.status},()=>O6(e,s,k,u))),...process.env.TTHEME_SORT==="series"?{}:{order:Li},color:!Ht(),lookups:process.env.TTHEME_MARKET_LOOKUP!=="off",fx:Hl(process.env.TTHEME_FX),owns:l&&!t,...d?{onFocus:(k)=>process.stdout.write(d.paint(k))}:{}});try{await p.run()}finally{if(d?.stop?.(),d&&(!t||p.next()===void 0))process.stdout.write(d.restore(h));f.abort()}await p.idle();let b=p.result(),$=p.next();if(t&&$!==void 0)return Hx(e,b.refreshed),$;if(l&&t)process.stdout.write("\x1B[?1049l\x1B[?25h");for(let k of b.refreshed){let v=pp(k);if(v)console.log(v)}if(p.applied()){for(let v of p.lines())console.log(v);let k=p.failure();if(k)throw k}else{for(let k of so(e,b.refreshed))console.log(k);console.log("Nothing changed")}return t?Au:0}import{rmSync as Lx}from"node:fs";import{basename as I6,join as Fc}from"node:path";var Cx=Fc(import.meta.dirname,".."),P6=Fc(Cx,"themes"),Dg=Fc(Cx,"dist"),Rf=ee.map((t)=>ur[t].emitter),R6=[mm,km],WV=Rf.map((t)=>t.id);async function Nf({only:t}={}){if(typeof Bun>"u")throw Error("needs bun — run it from a checkout: bun src/bin.ts build");let e=t&&t.length>0?Rf.filter((o)=>t.includes(o.id)):Rf,n=r$(P6),r=Zb(n);if(r.length>0){for(let o of r)console.error(` ✗ ${o.theme} [${o.rule}] ${o.detail}`);throw Error(`${r.length} contrast violation(s). Fix the palette, or waive the rule in its [contrast] section with a reason.`)}if(e.length===Rf.length)Lx(Dg,{recursive:!0,force:!0});else for(let o of e)Lx(Fc(Dg,o.id),{recursive:!0,force:!0});let i=0;for(let o of[...e,...R6]){let s=n.flatMap((u)=>o.emit?.(u)??[]),a=o.emitShared?.(n)??[];for(let u of[...s,...a])await Bun.write(Fc(Dg,u.path),u.content),i++;let c=s.length>0?`${n.length} themes${o.limits?` (${o.limits})`:""}`:a.length>0?a.map((u)=>I6(u.path)).join(" "):`no files (${o.limits??"nothing to write"})`;console.log(` ${o.id.padEnd(16)} ${c}`)}console.log(`
|
|
749
|
+
${n.length} themes (${i$(n).length} in the new-tab rotation) -> ${i} files in dist/`)}import{existsSync as T6,readFileSync as Ux}from"node:fs";import{availableParallelism as N6,homedir as jx}from"node:os";var A6=4;async function Af(t,e,n=jx()){let r=Nt(X(t)),i=ti(t),o=new Map(we(t).palettes.map((l)=>[l.name,qo(l)])),s=Object.entries(r.palettes).flatMap(([l,d])=>{let h=o.get(l);return h?d.pictures.filter((m)=>Do(m)||(m.blur??0)!==i).map((m)=>({name:l,key:m.key,paint:h})):[]});if(s.length===0)return 0;e(`Drawing ${s.length} background picture${s.length===1?"":"s"} again${i?` · blur ${i}px`:""}`);let a=no(z(t).terminals),c=new bg(Math.min(A6,N6()-1)),u=await c.map(s.map(({name:l,key:d,paint:h})=>({job:"redraw",home:t,user:n,name:l,key:d,paint:h,blur:i,aligns:a})));c.close();let f=[];return u.forEach((l,d)=>{let{name:h,key:m}=s[d];if(l instanceof Error||l===null){e(` ▢ ${h} ${m} — ${l instanceof Error?l.message:"no original to draw it from"}, left as it was`);return}f.push({name:h,picture:l})}),sh(t,f),_e(t,n),f.length}async function _x(t,e,n,r,i=jx()){let o=Nt(X(t)).palettes[e],s=o?.pictures.find((f)=>f.key===(r??o.active));if(!o||!s)throw Error(`${e} has no picture ${r??"shown"}`);if(ze(s)===n)return{key:s.key,changed:!1};let a=we(t).palettes.find((f)=>f.name===e);if(!a)throw Error(`no palette called ${e}`);let c=no(z(t).terminals),u=await rf(t,e,s.key,qo(a),ti(t),c,i,n);if(!u)throw Error(`${e} ${s.key} has no original to draw it from`);return sh(t,[{name:e,picture:u}]),_e(t,i),{key:s.key,changed:!0}}function Gx(t,e,n){let r=Nt(X(t)).palettes[e],i=r?.pictures.find((a)=>a.key===(n??r.active));if(!r||!i)throw Error(`${e} has no picture ${n??"shown"}`);let o=we(t).palettes.find((a)=>a.name===e);if(!o)throw Error(`no palette called ${e}`);let s=ze(i)==="original"?"tone":"original";if(!xE(t,e,i.key,qo(o),ti(t),s))throw Error(`${e} ${i.key} has no original to draw it from`);return{key:i.key,coloring:s}}async function Bx(){return await Af(J(),(t)=>process.stderr.write(`${t}
|
|
750
|
+
`)),0}async function Wx(t,e,n){let r=J();if(On(we(r).palettes,t),e==="show"){if(!n)throw Error("image show needs the picture to show");let{at:i,of:o}=Jo(r,t,n);return _e(r),process.stderr.write(`Background · ${t} ${i}/${o} ${n}
|
|
751
|
+
`),0}if(e==="drop"){let{key:i,left:o}=hu(r,t,n);return _e(r),process.stderr.write(`Background · ${t} removed ${i} · ${o} left
|
|
752
|
+
`),0}if(e==="tone"||e==="original"){let i=await _x(r,t,e,n);return process.stderr.write(`Background · ${t} ${i.key} ${e==="tone"?"tinted":"in its own colors"}
|
|
753
|
+
`),0}if(e==="prepare"){let{key:i,coloring:o}=Gx(r,t,n);return process.stderr.write(`Background · ${t} ${i} ready in ${o==="tone"?"its tone":"its own colors"}
|
|
754
|
+
`),0}if(e==="tuned")return _e(r),0;throw Error(`unknown image action ${e} — show, drop, tone, original, prepare or tuned`)}function Kx(t,e){let n=/^(\d+)x(\d+)$/.exec(t),r=/^(\d+)x(\d+)([+-]\d+)([+-]\d+)$/.exec(e);if(!n||!r)throw Error("a canvas is <width>x<height> and a place <width>x<height>+<x>+<y>");let[i,o]=n.slice(1).map(Number),[s,a,c,u]=r.slice(1).map(Number);return{width:i,height:o,at:{x:c,y:u,w:s,h:a}}}function H6(t,e,n){let r=Kx(e,n),i=Math.min(1,t.width/r.at.w);if(i===1)return r;return{width:Math.max(1,Math.round(r.width*i)),height:Math.max(1,Math.round(r.height*i)),at:{x:Math.round(r.at.x*i),y:Math.round(r.at.y*i),w:t.width,h:t.height}}}function zx(t,e,n,r){let i=Gt(new Uint8Array(Ux(t)));return C(e,Ke(r0(i,Kx(n,r)))),0}function qx(t,e,n,r,i,o,s){let a=Number(r);if(!he(n)||!Number.isFinite(a))throw Error("flatten needs a #rrggbb background and an opacity from 0 to 1");let c=Gt(new Uint8Array(Ux(t))),u=i?H6(c,i,o??""):void 0,f=Tr(Ar(c,n,Math.max(0,Math.min(1,a)),u));if(s&&T6(s))xi(s,e,f);else C(e,f);return 0}import{execFileSync as F6}from"node:child_process";import{readFileSync as L6}from"node:fs";import{arch as C6,platform as Tf,release as Jg}from"node:os";var j6={ghostty:"ghostty",iterm2:"iTerm.app",wezterm:"WezTerm","terminal-app":"Apple_Terminal",warp:"WarpTerminal"};function _6(t,e){if(t==="konsole"){let r=/^(\d{2})(\d{2})(\d{2})$/.exec(e.KONSOLE_VERSION??"");return r?`${r[1]}.${r[2]}.${Number(r[3])}`:e.KONSOLE_VERSION}let n=j6[t];return n!==void 0&&e.TERM_PROGRAM===n?e.TERM_PROGRAM_VERSION:void 0}function G6(t){let e=Vt(t),n=t.TERM_PROGRAM&&t.TERM_PROGRAM!=="tmux"?t.TERM_PROGRAM:void 0,r=e==="unknown"?`unknown${n?` (TERM_PROGRAM=${n})`:""}`:e==="editor"?`editor (${sm(t)})`:`${e} ${_6(e,t)??"(version unknown)"}`,i=t.TERM_PROGRAM==="tmux"?t.TERM_PROGRAM_VERSION:void 0;return[r,t.TMUX?`tmux ${i??"yes"}`:"tmux no",t.SSH_CONNECTION||t.SSH_TTY?"ssh yes":"ssh no"].join(" · ")}function Dx(t,e){try{return F6(t,e,{encoding:"utf8",timeout:2000,stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}function B6(){let t=C6();if(Tf()==="darwin")return`macOS ${Dx("sw_vers",["-productVersion"])??`(Darwin ${Jg()})`} · ${t}`;if(Tf()==="linux"){let e="";try{e=L6("/etc/os-release","utf8")}catch{}return`${/^PRETTY_NAME="?([^"\n]*)"?$/m.exec(e)?.[1]??"Linux"} · linux ${Jg()} · ${t}`}return`${Tf()==="win32"?"Windows":Tf()} ${Jg()} · ${t}`}function U6(t){if(t.TTHEME_ZSH)return`zsh ${t.TTHEME_ZSH}`;return(t.SHELL?Dx(t.SHELL,["--version"])?.split(`
|
|
755
|
+
`)[0]:void 0)??t.SHELL??"unknown"}function W6(t){try{let{terminals:e}=z(t);return e.length>0?e.join(", "):"none"}catch{return"installed.json missing or unreadable"}}function K6(t){let e=Zu.flatMap((n)=>{let r=t[n];return r===void 0||r===Ta(n)?[]:[`${n}=${/\s/.test(r)?JSON.stringify(r):r}`]});return e.length>0?e.join(" "):void 0}function Jx(){let t=process.env,n=[["ttheme",lt.version],["OS",B6()],["Shell",U6(t)],["Terminal",G6(t)],["Wired",W6(J())],["Settings",K6(t)]].filter((i)=>i[1]!==void 0),r=Math.max(...n.map(([i])=>i.length));for(let[i,o]of n)console.log(`${i.padEnd(r)} ${o}`)}import{execFileSync as q6,spawnSync as D6}from"node:child_process";import{chmodSync as J6,copyFileSync as Y6,existsSync as yr,mkdirSync as o2,readdirSync as V6,readFileSync as jc,rmSync as Zg}from"node:fs";import{homedir as Z6}from"node:os";import{dirname as Ds,join as mt}from"node:path";import{existsSync as Yx}from"node:fs";import{basename as z6,join as Lc}from"node:path";var Vx=["zsh","bash","fish"];function Hf(t){let e=z6(t??"").replace(/^-/,"");return Vx.includes(e)?e:void 0}function Vg(t,e){for(let n=e,r=0;n>1&&r<12;r++){let[i,...o]=t("ps",["-o","ppid=,comm=","-p",String(n)])?.trim().split(/\s+/)??[],s=Hf(o.join(" "));if(s)return s;n=Number(i)}return}function Zx(t,e){let n=new Set(["zsh"]);for(let r of[Hf(t.env.SHELL),Vg(t.run,e)])if(r)n.add(r);return Vx.filter((r)=>n.has(r))}var Yg="ttheme-zdotdir:";function Ff(t,e){if(t.env.ZDOTDIR)return t.env.ZDOTDIR;let n=t.run("zsh",["-c",`print -rn -- "${Yg}\${ZDOTDIR:-$HOME}"`])??"",r=n.lastIndexOf(Yg);return r>=0&&n.slice(r+Yg.length)||e}function Xx(t){return t.run("zsh",["-fc","print ok"])==="ok"}var Qx=[".bash_profile",".bash_login",".profile"];function t2(t,e){let n=Lc(t,".bashrc"),r=Qx.map((o)=>Lc(t,o)).find((o)=>Yx(o)),i=[...Yx(n)?[n]:[],...r?[r]:[]];if(e==="darwin"&&!r)i.push(Lc(t,".bash_profile"));return i.length>0?i:[n]}function e2(t){return[".bashrc",...Qx].map((e)=>Lc(t,e))}var n2=`zsh -c 'source ${Vu} && ttheme "$@"' ttheme`;function r2(){return`# ${ke}
|
|
756
|
+
ttheme() { ${n2} "$@"; }`}function Lf(t){return Lc(t,"fish","functions","ttheme.fish")}function i2(){return[`# ${ke}`,"function ttheme --description 'Run ttheme through zsh'",` ${n2} $argv`,"end",""].join(`
|
|
757
|
+
`)}function Cf(t){return t.startsWith(`# ${ke}
|
|
758
|
+
`)}function X6(t,e,n){for(let r of V6(e))t.push({from:mt(e,r),to:mt(n,r)})}function eb(t){return zr(jc(mt(t,"dist","manifest.json"),"utf8"))}function jf(t,e){let n=mt(e.configHome,"ttheme"),r=[{from:mt(e.root,"bin","ttheme.js"),to:mt(n,"ttheme.js")},{from:mt(e.root,"bin","ttheme.js.map"),to:mt(n,"ttheme.js.map")},{from:mt(e.root,"bin","package.json"),to:mt(n,"package.json")},{from:mt(e.root,"shell","ttheme.zsh"),to:mt(n,"ttheme.zsh")},{from:mt(e.root,"shell","preview.zsh"),to:mt(n,"preview.zsh")},{from:mt(e.root,"shell","launch-tab.zsh"),to:mt(n,"launch-tab.zsh"),executable:!0}];X6(r,mt(e.root,"shell","adapters"),mt(n,"adapters"));let i=e.shells??["zsh"],o=[{file:mt(e.zdotdir,".zshrc"),block:Ry(),about:"source ttheme.zsh"},...i.includes("bash")?t2(e.home,e.platform??process.platform).map((p)=>({file:p,block:r2(),about:"the ttheme command, run through zsh"})):[]],s=Lf(e.configHome),a=!yr(s)||Cf(jc(s,"utf8")),c=i.includes("fish")&&a?[{file:s,content:i2(),about:"the ttheme command, run through zsh"}]:[],u=mt(n,"config.zsh"),f=Ay(yr(u)?jc(u,"utf8"):""),l={file:u,content:t.warpFast===void 0?f:Qu(f,"TTHEME_WARP_FAST",t.warpFast?"on":"off")},d={terminals:t.terminals,palettes:t.palettes,...Object.fromEntries(yt(t.terminals).flatMap((p)=>Object.entries(p.installs?.(e)??{}).filter(([,b])=>b!==void 0))),...t.off?{off:!0}:{}},h=[...wl(e.configHome,d,e.home),...i.includes("fish")&&!a?[`${ft(s,e.home)} is a function of your own — ttheme left it, so fish has no ttheme command`]:[],...i.some((p)=>p!=="zsh")?[`${i.filter((p)=>p!=="zsh").join(" and ")} run ttheme through zsh — a pin taking effect on cd, the picture following the tab in front and the repaint after a program resets the colors stay with zsh tabs`]:[]],m=e.stateDir?[mt(e.stateDir,"ghostty",".blind")]:[];return{home:e.home,copies:r,edits:o,writes:c,settings:l,forget:m,catalog:eb(e.root),installed:d,notes:h}}function a2(t){try{return z(t)}catch{return}}function c2(t,e){try{return Wt(t,at(t,!1,e),!1).palettes}catch{return[]}}function Q6(t,e){let n=eb(e.root),r=Dt(t.markets).includes(V)?n.palettes:[],i=new Set(r.map((s)=>s.name)),o=c2(e.configHome,n).filter((s)=>!i.has(s.name)&&(ut(s.name)!==void 0||t.palettes.includes(s.name)));return{...n,palettes:[...r,...o]}}function u2(t,e){let n=eo(t);return n&&e.includes(n)?n:void 0}function tj(t,e,n){let r=jf(e,n),i=u2(t,e.palettes),o=new Set(["terminals","palettes","off","startup",...ee.flatMap((a)=>Object.keys(ur[a].installs?.(n)??{}))]),s=Object.fromEntries(Object.entries(t).filter(([a])=>!o.has(a)));return{...r,installed:{...s,...r.installed,...i?{startup:i}:{}}}}function ej(t,e){let n=jf({terminals:t.terminals,palettes:t.palettes,off:t.off},e),r=new Set([...n.catalog.palettes,...c2(e.configHome,n.catalog)].map((f)=>f.name)),i=t.palettes.filter((f)=>r.has(f)),o=t.palettes.filter((f)=>!r.has(f)),{startup:s,...a}=t,c={...a,palettes:i,...s&&i.includes(s)?{startup:s}:{}},u=o.length>0?[`Dropped ${o.join(", ")} — no longer in the catalog`,...n.notes]:n.notes;return{...n,installed:c,notes:u}}function nj(t){try{return q6(process.execPath,[mt(t,"ttheme","ttheme.js"),"--version"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}function l2(t){let e=je(t);return[yt(t.terminals).map((n)=>n.name).join(", "),`${t.palettes.length} palettes`,e?`default ${e}`:"no default — ttheme is off"].join(" · ")}function Xg(t,e=Ve()){for(let s of t.copies)if(o2(Ds(s.to),{recursive:!0}),Zg(s.to,{force:!0}),Zg(`${s.to}.zwc`,{force:!0}),Y6(s.from,s.to),s.executable)J6(s.to,493);C(t.settings.file,t.settings.content);for(let s of t.forget)Zg(s,{force:!0});let n=Ds(Ds(t.settings.file)),r=a2(n),i=Object.fromEntries(yt(t.installed.terminals).flatMap((s)=>{let a=s.defaults?.key,c=a?r?.[a]:void 0;return a&&c?[[a,c]]:[]})),o=Wa(n,{...t.installed,...i},e,t.home);if(Dt(o.markets).includes(V))kk(n,t.catalog);Ze(n,o),Kt(n,at(n),o,t.home,e);for(let s of t.edits){o2(Ds(s.file),{recursive:!0});let a=yr(s.file)?jc(s.file,"utf8"):"";$n(s.file,Qr(a,s.block))}for(let s of t.writes)C(s.file,s.content);return ro(n,o,!0,e,t.home)}function Cc(t){if(te(t))throw Vr("Nothing changed"),new de;return t}function Qg(t,e){return ee.filter((n)=>ur[n].offered(t,e))}async function rj(t,e,n,r){return Cc(await ly({message:"Wire which terminals?",options:Qg(n,r).map((i)=>({value:i,label:ur[i].name,hint:i===t?"detected":void 0})),initialValues:e,required:!0}))}async function ij(t){return Cc(await Ce({message:"Switch Warp to each tab's palette in about 0.2 s instead of 0.6 s?\nAbout 8% CPU while Warp is in front with tabs of different palettes — `ttheme config` changes it",initialValue:gs(t,"TTHEME_WARP_FAST")!=="off"}))}function tb(t){let e=[...t.copies.filter((n)=>!yr(n.to)).map((n)=>n.to),...yr(t.settings.file)?[]:[t.settings.file],...t.edits.filter((n)=>!jc(n.file,"utf8").includes("# ttheme begin")).map((n)=>n.file),...t.writes.filter((n)=>!yr(n.file)).map((n)=>n.file)];if(e.length>0)throw Error(`init left gaps:
|
|
757
759
|
${e.join(`
|
|
758
|
-
`)}`)}function
|
|
759
|
-
`),`Installed ${e.palettes.length} palettes`),
|
|
760
|
-
`),"Next"),
|
|
761
|
-
`));return}
|
|
762
|
-
`),c),
|
|
763
|
-
`))}async function
|
|
764
|
-
${
|
|
765
|
-
`),`Wiring ${yt(d).map((
|
|
760
|
+
`)}`)}function f2(t,e){return[...new Set(t.palettes.filter((n)=>e.includes(n.name)).map((n)=>n.group))]}function oj(t,e,n){let r=t.palettes.find((s)=>s.name===je(e)),i=process.stdout.isTTY===!0,o=r&&qs(process.env,i,n)?.wear(r,e.terminals);if(o===void 0)return!1;return process.stdout.write(o),!0}function sj(t,e){let n=je(t);if(!n)return["Default none — new tabs keep the terminal colors",`Turn on \`ttheme on\` wears ${eo(t)}`];return[`Default ${n}${e?" — this tab wears it already":""}`,"Change it `ttheme`, enter on a palette, then default"]}function aj(t){D6("zsh",["-c",'source "$1" && __tt_preview init',"zsh",mt(t,"ttheme","ttheme.zsh")],{stdio:"inherit"})}function nb(t){return t==="bash"?"exec bash -l":`exec ${t}`}function cj(t,e,n,r,i){let o=f2(t.catalog,e.palettes);Pn([`${o.join(", ")} (${e.palettes.length})`,...sj(t.installed,n)].join(`
|
|
761
|
+
`),`Installed ${e.palettes.length} palettes`),Pn([`${nb(i).padEnd(18)}The ttheme command in this tab`,...rb(t,r)].join(`
|
|
762
|
+
`),"Next"),Ra("Done")}function rb(t,e){return[...$l(Ds(Ds(t.settings.file)),t.installed,e,t.home),...t.notes]}function d2(t){return t?(e)=>Yr.step(e):(e)=>console.log(e)}async function s2(t,e,n,r,i){let o=ej(t,e),s=Xg(o,n);tb(o),await Af(e.configHome,d2(r),e.home);let a=[`${nb(i).padEnd(18)}Open tabs run the new layer — new tabs already do`,...rb(o,s)],c=`Updated to ${lt.version} — kept ${l2(o.installed)}`;if(!r){console.log([c,...a].join(`
|
|
763
|
+
`));return}Pn(a.join(`
|
|
764
|
+
`),c),Ra("Done")}function uj(t,e,n){let r=[`Placed ${t.copies.length} files`,`Settings in ${t.settings.file} — edit later with \`ttheme config\``,...[...t.edits,...t.writes].map((i)=>`Wired ${i.file}`),...rb(t,e),`No palettes yet — open a new shell (\`${nb(n)}\`), then \`ttheme\` picks them from the catalog`];console.log(r.join(`
|
|
765
|
+
`))}async function h2(t={}){let e=mt(import.meta.dirname,"..");for(let P of["ttheme.js","package.json"])if(!yr(mt(e,"bin",P)))throw Error(`bin/${P} is missing — run \`mise run bin:build\` first`);if(!yr(mt(e,"dist"))){if(typeof Bun>"u")throw Error("this package is missing dist/ — reinstall @kecan0406/ttheme");await Nf()}let n=Z6(),r=J(),i=Ve();if(!Xx(i))throw Error("ttheme runs its tab layer in zsh, even for bash and fish — install zsh first");let o=G1(i),s=process.env.WT_PROFILE_ID,a={root:e,home:n,configHome:r,zdotdir:Ff(i,n),shells:Zx(i,process.ppid),platform:i.platform,stateDir:mt(process.env.XDG_STATE_HOME??mt(n,".local","state"),"ttheme"),...o?{wtHome:o}:{},...s?{wtProfile:s}:{}},c=Vg(i.run,process.ppid)??Hf(i.env.SHELL)??"zsh",u=Vt(process.env),f=Qg(a,i).filter((P)=>P===u);if(!t.yes&&(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0))throw Error("init asks before it edits your configs — run it in a terminal, or pass --yes to accept the defaults");let l=a2(r);if(t.yes&&l){await s2(l,a,i,!1,c);return}if(t.yes){if(f.length===0)throw Error(`no supported terminal detected — run this inside ${yt(Qg(a,i)).map((_)=>_.name.toLowerCase()).join(", ").replace(/, ([^,]*)$/," or $1")}`);let L=jf({terminals:f,palettes:[]},a),A=Xg(L,i);tb(L),uj(L,A,c);return}if(Ku("ttheme init"),l){let P=nj(r);if(Cc(await Ce({message:`ttheme${P?` ${P}`:""} is installed — ${l2(l)}
|
|
766
|
+
${P===lt.version?"Reinstall":"Update to"} ${lt.version} and keep all of it?`,active:"Yes",inactive:"No, set it up again",initialValue:!0}))){await s2(l,a,i,!0,c);return}}let d=await rj(u,l?.terminals??f,a,i),h=d.includes("warp")?await ij(r):void 0,m=l?Q6(l,a):eb(e),p=l?await Kg(m,l.palettes,"palette",!0):await Kg(m,[],"series",!0);if(!p)throw Vr("Nothing changed"),new de;let b=(l&&u2(l,p))??p[0],$=p.length>1&&($e[u].paints||u==="warp"&&d.includes("warp")&&yr(si(n,r))),k=Cc(await Ce({message:$?"Pick a default palette in ttheme once installed?":`Wear ${b} in every tab?`,initialValue:l?!l.off:!0})),v={terminals:d,palettes:p,off:!k,warpFast:h},S=l?tj(l,v,a):jf(v,a);if(Pn([`Install ${p.length} palettes — ${f2(m,p).join(", ")}`,`Copy ${S.copies.length} files under ${r}`,`Write ${S.settings.file}`,...S.edits.map((P)=>`Edit ${P.file} — a ttheme block: ${P.about}`),...S.writes.map((P)=>`Write ${P.file} — ${P.about}`),...bl(r,S.installed,n),"Each config is backed up once to <file>.ttheme.bak before the first edit — `npx @kecan0406/ttheme uninstall` takes it all out",k?$?`Open ttheme — every tab wears the palette picked there, ${b} until then`:`Paint every tab with ${b}, this one now`:"Leave the terminal colors as they are — `ttheme on` wears a palette later",...k&&b?yt(d).flatMap((P)=>P.defaults?[`Make "${P.defaults.profile(b)}" the ${P.name} default profile`]:[]):[]].join(`
|
|
767
|
+
`),`Wiring ${yt(d).map((P)=>P.name).join(", ")}`),!Cc(await Ce({message:"Apply these changes?"})))throw Vr("Nothing changed"),new de;let x=Xg(S,i);if(tb(S),await Af(r,d2(!0),n),k&&$)aj(r);let M=z(r);cj({...S,catalog:m,installed:M},v,oj(m,M,r),x,c)}import{spawn as lj}from"node:child_process";import{createHash as fj}from"node:crypto";import{existsSync as ib,mkdirSync as dj,readFileSync as hj,statSync as mj,utimesSync as pj,writeFileSync as gj}from"node:fs";import{homedir as b2}from"node:os";import{join as w2}from"node:path";import{gunzipSync as bj}from"node:zlib";var m2="https://github.com/kecan0406/aninames/releases/latest/download",$2=86400000,wj=3600000,$j=120000;function k2(t){return w2(Br(t),".checked")}function kj(t=process.env){return t.TTHEME_NAMES!=="off"}function yj(t){try{return Date.now()-mj(k2(t)).mtimeMs>=$2}catch{return!0}}function ob(t,e){let n=k2(t);if(dj(Br(t),{recursive:!0}),!ib(n))gj(n,"");pj(n,e/1000,e/1000)}function y2(t=b2()){if(!kj()||!yj(t))return;try{ob(t,Date.now()),lj(process.execPath,[process.argv[1],"names"],{detached:!0,stdio:"ignore",env:process.env}).unref()}catch{}}function p2(t){return fj("sha256").update(t).digest("hex")}async function g2(t){let e=await fetch(t,{signal:AbortSignal.timeout($j)});if(!e.ok)throw Error(`${t} answered ${e.status}`);return new Uint8Array(await e.arrayBuffer())}async function v2(t=b2()){let e=Br(t);try{let r=JSON.parse(new TextDecoder().decode(await g2(`${m2}/ttheme.json`)));for(let[i,{file:o,sha256:s}]of Object.entries(r.layers)){let a=w2(e,`ttheme-${i}.json`);if(ib(a)&&p2(hj(a))===s)continue;let c=bj(await g2(`${m2}/${o}`));if(p2(c)!==s)throw Error(`${o} does not match its hash`);C(a,c)}ob(t,Date.now())}catch{return ob(t,Date.now()-$2+wj),1}ku(t);let n=J();if(ib(er(n)))Bi(we(n).palettes,t),q1(n,t);return 0}import{createHash as vj}from"node:crypto";import{existsSync as sb,readdirSync as S2,readFileSync as ab,rmSync as Sj,statSync as Ej,utimesSync as Mj}from"node:fs";import{homedir as xj}from"node:os";import{join as gi}from"node:path";var Oj=new Set(["814e75361c745b9f1467c82bee90ab3f47daeaa70a528d330a4bc8aec9faeeb9","668092ea188445700b02d60a102c429e092e46fcd88c33509b9f1fd64d68e6a6","bf52a8c6d019f59f71723be460d7fe450234d0f03ff0f35e94db2c42455f00ba","8df4e3246f2cf26deaa0f620f31e94efac21104ec2dbe81fba55ba066141aeb4","7bdc8051f34b902e970df84df0e4c8d27331b5e04da7f7b498d50b592eaa72f2","e06b39cd6fa2701bd360b7062d82d4a56766aba97889dfa547d14db5895454f1"]);function E2(t){try{return S2(t).map((e)=>gi(t,e)).filter((e)=>Ej(e).isFile())}catch{return[]}}function Ij(t){let e=t.slice(t.lastIndexOf("/")+1);if(e.startsWith(j("")))return!1;let n=e.replace(/\.(conf|toml)$/,""),r=ab(t,"utf8");return r.startsWith(`# ${n} — `)&&r.split(`
|
|
766
768
|
`)[1]?.startsWith("# ANSI: ")===!0||r.startsWith(`[metadata]
|
|
767
769
|
name = "${n}"
|
|
768
|
-
origin_url = "`)}function
|
|
769
|
-
`),"Uninstall");let i=await
|
|
770
|
-
`),`Wiring ${n.name}`);let u=await
|
|
771
|
-
`),"Next");return
|
|
770
|
+
origin_url = "`)}function Pj(t){let n=E2(t).filter((r)=>Oj.has(vj("sha256").update(ab(r)).digest("hex")));return n.length>0&&n.length===S2(t).length?[t]:n}function Rj(t){try{return z(t)}catch{return}}function Nj(t){let{home:e,configHome:n}=t,r=Rj(n),i={configHome:n,home:e},o=yt(ee),s=o.map((u)=>u.unwire(i,r)),a=[gi(n,"ttheme"),t.cacheDir,t.stateDir],c=Lf(n);return{edits:[...[...new Set([gi(t.zdotdir,".zshrc"),gi(e,".zshrc")])].flatMap((u)=>ln(u,Nn)),...e2(e).flatMap((u)=>ln(u,Nn)),...s.flatMap((u)=>u.edits)],removals:[...sb(c)&&Cf(ab(c,"utf8"))?[c]:[],...o.flatMap((u)=>u.shelf?bs(u.shelf.dir(i)):[]),...o.flatMap((u)=>u.shelf?E2(u.shelf.dir(i)).filter(Ij):[]),...Pj(gi(n,"ghostty","shaders")),...s.flatMap((u)=>u.removals),...a.filter((u)=>sb(u))],touches:s.flatMap((u)=>u.touches),...r?{state:r}:{}}}function Aj(t,e,n=Ve()){let r=[];for(let{file:o,content:s}of t.edits){let a=nw(o,s);r.push(a==="removed"?`Removed ${o} — ttheme had created it`:a==="restored"?`Took ttheme out of ${o}`:`Took ttheme out of ${o} — kept ${o}.ttheme.bak, since the file changed after ttheme's first edit`)}if(t.state){let o=ro(e.configHome,{...t.state,off:!0,palettes:[]},!1,n,e.home);for(let s of yt(t.state.terminals))if(o.has(s.id))r.push(`Gave ${s.name} its own default profile back — it takes it at its next start`)}for(let o of t.removals)Sj(o,{recursive:!0,force:!0});if(t.removals.length>0)r.push(`Deleted ${t.removals.length} files and folders ttheme wrote`);let i=new Date;for(let o of t.touches)Mj(o,i,i);return r}function Tj(){let t=xj();return{home:t,configHome:J(),zdotdir:Ff(Ve(),t),cacheDir:jr(),stateDir:gi(process.env.XDG_STATE_HOME??gi(t,".local","state"),"ttheme")}}async function M2(t=!1){let e=Tj(),n=Nj(e);if(n.edits.length===0&&n.removals.length===0){console.log("Nothing of ttheme is installed");return}if(!t){if(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0)throw Error("uninstall asks before it deletes anything — run it in a terminal, or pass --yes");let r=gi(e.configHome,"ttheme");Ku("ttheme uninstall"),Pn([...n.edits.map((o)=>`Take ttheme out of ${o.file}`),...n.removals.map((o)=>o===r?`Delete ${o} — settings, pins, every installed picture${sb(yu(e.configHome))?`, and your markets under ${yu(e.configHome)} (push them to GitHub first to keep them)`:""}`:`Delete ${o}`)].join(`
|
|
771
|
+
`),"Uninstall");let i=await Ce({message:"Remove ttheme?"});if(te(i)||!i)throw Vr("Nothing changed"),new de}for(let r of Aj(n,e))console.log(r);console.log("Open tabs keep their colors until they close — restart your terminal to drop ttheme everywhere")}import{homedir as Hj}from"node:os";async function x2(t){if(!ee.includes(t))throw Error(`no terminal ${t} — one of ${ee.join(", ")}`);let e=t,n=ur[e],r=J(),i=Hj(),o=Ve(),s=z(r);if(s.terminals.includes(e))return console.log(`${n.name} is wired already`),0;let a={configHome:r,home:i};if(!n.offered(a,o))throw Error(`${n.name} cannot be wired on this system`);if(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0)throw Error("wire asks before it edits your configs — run it in a terminal");let c={...s,...n.installs?.(a)??{},terminals:[e]};Pn([...bl(r,c,i),...wl(r,c,i),"Each config is backed up once to <file>.ttheme.bak before the first edit — `npx @kecan0406/ttheme uninstall` takes it all out"].join(`
|
|
772
|
+
`),`Wiring ${n.name}`);let u=await Ce({message:`Wire ${n.name} now?`,initialValue:!1});if(te(u)||!u)throw Vr("Nothing changed"),new de;let f=Wa(r,c,o,i),l={...f,terminals:[...s.terminals,e]};Ze(r,l),Kt(r,at(r),l,i,o);let d=ro(r,f,!0,o,i),h=$l(r,f,d,i);if(h.length>0)Pn(h.join(`
|
|
773
|
+
`),"Next");return Ra(`Wired ${n.name}`),0}var Lj=new Set(["add","remove","market","default","on","off"]),Cj={default:([t])=>xx(t),on:()=>Ix(),off:()=>Px(),browse:()=>Fx(),list:([t],{json:e})=>Nx(t,e),add:(t,{market:e})=>Ex(t,e),remove:(t)=>Mx(t),update:(t)=>Ax(t),market:([t,e])=>Bv(t,e),new:([t],{from:e,in:n})=>ax(t,e,n),edit:async(t)=>cx(await O2(t,"edit")),check:async(t,{fix:e})=>hx(await O2(t,"check"),e),share:async([t],{tone:e})=>{let n=e;if(t!==void 0)return Wg(t,n);let r=await tx(n);if(!r)throw new vr("name a palette",_f("share"));return Wg(r.name,r.tone)},init:(t,{yes:e})=>h2({yes:e}),uninstall:(t,{yes:e})=>M2(e),wire:([t])=>x2(t),info:()=>Jx(),build:(t,{only:e})=>Nf({only:e}),find:([t])=>CM(t),image:([t,e,n])=>Wx(t,e,n),sync:()=>Ox(),redraw:()=>Bx(),names:()=>v2(),latest:()=>sv(),tone:([t,e,n])=>ux(t,e,n),flatten:([t,e,n,r,i,o,s])=>qx(t,e,n,r,i,o,s),bake:([t,e,n,r])=>zx(t,e,n,r)},jj=hs.map((t)=>({...t,run:Cj[t.name]}));class vr extends Error{verb;constructor(t,e){super(t);this.verb=e}}function _f(t){let e=jj.find((n)=>n.name===t);if(!e)throw new vr(t.startsWith("-")?`unknown option '${t}'`:`unknown command '${t}'`);return e}async function O2([t],e){let n=t??await Gg();if(n===void 0){let r=process.env.TTHEME_WORN;throw new vr(`name a palette${r?` — this tab wears ${r}`:""}`,_f(e))}return n}function _j(t,e){let n={help:{type:"boolean",short:"h"}};for(let[r,{type:i,short:o,multiple:s}]of Object.entries(t.flags??{}))n[r]={type:i,multiple:s===!0,...o?{short:o}:{}};try{return Fj({args:e,options:n,allowPositionals:!0})}catch(r){let[i=""]=(r instanceof Error?r.message:String(r)).split(". ");throw new vr(`${i.charAt(0).toLowerCase()}${i.slice(1)}`,t)}}function Gj(t){let[e,...n]=t;if(e===void 0)return{kind:"brief"};if(e==="-h"||e==="--help")return{kind:"help"};if(e==="-v"||e==="--version")return{kind:"version"};if(e==="help"){if(n[0]===void 0||n[0]==="all")return{kind:"help",all:n[0]==="all"};return{kind:"help",verb:_f(n[0])}}let r=_f(e),i=_j(r,n);if(i.values.help)return{kind:"help",verb:r};for(let[f,{choices:l}]of Object.entries(r.flags??{}))for(let d of[i.values[f]??[]].flat())if(l&&!l.includes(String(d)))throw new vr(`--${f} takes ${l.join(", ")} — not ${d}`,r);let o=i.positionals,s=r.args.filter((f)=>f.startsWith("<")).length,a=r.args.some((f)=>f.includes("..."))?Number.POSITIVE_INFINITY:r.args.length;if(o.length<s)throw new vr(`missing ${r.args[o.length]}`,r);if(o.length>a)throw new vr(`too many arguments: ${o.slice(a).join(" ")}`,r);let{help:c,...u}=i.values;return{kind:"run",verb:r,args:o,flags:u}}var Bj=[TypeError,RangeError,ReferenceError,SyntaxError];function Uj(t){return Bj.some((e)=>t instanceof e)||t instanceof Error&&"code"in t}async function I2(t){let e;try{let n=Gj(t);if(n.kind==="version")return console.log(lt.version),0;if(n.kind==="brief")return console.error(Py()),1;if(n.kind==="help")return console.log(n.verb?cm(n.verb):Aa(n.all===!0)),0;if(e=n.verb,!n.verb.run)throw Error("runs in the shell layer — open a new tab once `ttheme init` has wired it");if(Lj.has(n.verb.name))await xv();let r=await n.verb.run(n.args,n.flags);if(!n.verb.hidden&&n.verb.name!=="uninstall"){if(y2(),n.verb.name!=="update"&&n.verb.name!=="init")ov(),lv()}return typeof r==="number"?r:0}catch(n){if(n instanceof vr)return console.error(n.verb?`ttheme ${n.verb.name}: ${n.message}
|
|
772
774
|
|
|
773
|
-
${
|
|
774
|
-
ttheme${e?` ${e.name}`:""}: ${r??(n instanceof Error?n.message:String(n))}${
|
|
775
|
+
${cm(n.verb)}`:`ttheme: ${n.message} — see \`ttheme help\``),1;if(n instanceof de)return 1;if(n instanceof ec)return n.exit;let r=process.env.TTHEME_DEBUG&&n instanceof Error?n.stack:void 0;return console.error(`
|
|
776
|
+
ttheme${e?` ${e.name}`:""}: ${r??(n instanceof Error?n.message:String(n))}${Uj(n)?"\nReport a bug with the output of `ttheme info`":""}`),1}}if(Kj)if(process.env.TTHEME_DEBUG&&typeof Bun>"u"&&!process.sourceMapsEnabled){let t=Wj(process.execPath,["--enable-source-maps",...process.argv.slice(1)],{stdio:"inherit"});process.exitCode=t.status??1}else process.exitCode=await I2(process.argv.slice(2));
|
|
775
777
|
|
|
776
|
-
//# debugId=
|
|
778
|
+
//# debugId=4E332F2B43C1FB0264756E2164756E21
|
|
777
779
|
//# sourceMappingURL=ttheme.js.map
|