blink 0.1.21 → 0.1.22

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.
@@ -47,7 +47,7 @@ Your platform (`+process.platform+`-`+process.arch+`) might not be supported.`:P
47
47
  `));let pax=opts.pax;if(pax)for(let key in pax)result+=addLength(` `+key+`=`+pax[key]+`
48
48
  `);return b4a$2.from(result)},exports.decodePax=function(buf){let result={};for(;buf.length;){let i$5=0;for(;i$5<buf.length&&buf[i$5]!==32;)i$5++;let len$1=parseInt(b4a$2.toString(buf.subarray(0,i$5)),10);if(!len$1)return result;let b$4=b4a$2.toString(buf.subarray(i$5+1,len$1-1)),keyIndex=b$4.indexOf(`=`);if(keyIndex===-1)return result;result[b$4.slice(0,keyIndex)]=b$4.slice(keyIndex+1),buf=buf.subarray(len$1)}return result},exports.encode=function(opts){let buf=b4a$2.alloc(512),name$5=opts.name,prefix=``;if(opts.typeflag===5&&name$5[name$5.length-1]!==`/`&&(name$5+=`/`),b4a$2.byteLength(name$5)!==name$5.length)return null;for(;b4a$2.byteLength(name$5)>100;){let i$5=name$5.indexOf(`/`);if(i$5===-1)return null;prefix+=prefix?`/`+name$5.slice(0,i$5):name$5.slice(0,i$5),name$5=name$5.slice(i$5+1)}return b4a$2.byteLength(name$5)>100||b4a$2.byteLength(prefix)>155||opts.linkname&&b4a$2.byteLength(opts.linkname)>100?null:(b4a$2.write(buf,name$5),b4a$2.write(buf,encodeOct(opts.mode&4095,6),100),b4a$2.write(buf,encodeOct(opts.uid,6),108),b4a$2.write(buf,encodeOct(opts.gid,6),116),encodeSize(opts.size,buf,124),b4a$2.write(buf,encodeOct(opts.mtime.getTime()/1e3|0,11),136),buf[156]=48+toTypeflag(opts.type),opts.linkname&&b4a$2.write(buf,opts.linkname,157),b4a$2.copy(USTAR_MAGIC,buf,257),b4a$2.copy(USTAR_VER,buf,263),opts.uname&&b4a$2.write(buf,opts.uname,265),opts.gname&&b4a$2.write(buf,opts.gname,297),b4a$2.write(buf,encodeOct(opts.devmajor||0,6),329),b4a$2.write(buf,encodeOct(opts.devminor||0,6),337),prefix&&b4a$2.write(buf,prefix,345),b4a$2.write(buf,encodeOct(cksum(buf),6),148),buf)},exports.decode=function(buf,filenameEncoding,allowUnknownFormat){let typeflag=buf[156]===0?0:buf[156]-48,name$5=decodeStr(buf,0,100,filenameEncoding),mode=decodeOct(buf,100,8),uid$2=decodeOct(buf,108,8),gid=decodeOct(buf,116,8),size=decodeOct(buf,124,12),mtime=decodeOct(buf,136,12),type=toType(typeflag),linkname=buf[157]===0?null:decodeStr(buf,157,100,filenameEncoding),uname=decodeStr(buf,265,32),gname=decodeStr(buf,297,32),devmajor=decodeOct(buf,329,8),devminor=decodeOct(buf,337,8),c$3=cksum(buf);if(c$3===256)return null;if(c$3!==decodeOct(buf,148,8))throw Error(`Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?`);if(isUSTAR(buf))buf[345]&&(name$5=decodeStr(buf,345,155,filenameEncoding)+`/`+name$5);else if(!isGNU(buf)&&!allowUnknownFormat)throw Error(`Invalid tar header: unknown format.`);return typeflag===0&&name$5&&name$5[name$5.length-1]===`/`&&(typeflag=5),{name:name$5,mode,uid:uid$2,gid,size,mtime:new Date(1e3*mtime),type,linkname,uname,gname,devmajor,devminor,pax:null}};function isUSTAR(buf){return b4a$2.equals(USTAR_MAGIC,buf.subarray(257,263))}function isGNU(buf){return b4a$2.equals(GNU_MAGIC,buf.subarray(257,263))&&b4a$2.equals(GNU_VER,buf.subarray(263,265))}function clamp$1(index,len$1,defaultValue){return typeof index==`number`?(index=~~index,index>=len$1?len$1:index>=0||(index+=len$1,index>=0)?index:0):defaultValue}function toType(flag){switch(flag){case 0:return`file`;case 1:return`link`;case 2:return`symlink`;case 3:return`character-device`;case 4:return`block-device`;case 5:return`directory`;case 6:return`fifo`;case 7:return`contiguous-file`;case 72:return`pax-header`;case 55:return`pax-global-header`;case 27:return`gnu-long-link-path`;case 28:case 30:return`gnu-long-path`}return null}function toTypeflag(flag){switch(flag){case`file`:return 0;case`link`:return 1;case`symlink`:return 2;case`character-device`:return 3;case`block-device`:return 4;case`directory`:return 5;case`fifo`:return 6;case`contiguous-file`:return 7;case`pax-header`:return 72}return 0}function indexOf(block$1,num,offset,end){for(;offset<end;offset++)if(block$1[offset]===num)return offset;return end}function cksum(block$1){let sum=256;for(let i$5=0;i$5<148;i$5++)sum+=block$1[i$5];for(let j$2=156;j$2<512;j$2++)sum+=block$1[j$2];return sum}function encodeOct(val,n$2){return val=val.toString(8),val.length>n$2?`7777777777777777777`.slice(0,n$2)+` `:`0000000000000000000`.slice(0,n$2-val.length)+val+` `}function encodeSizeBin(num,buf,off){buf[off]=128;for(let i$5=11;i$5>0;i$5--)buf[off+i$5]=num&255,num=Math.floor(num/256)}function encodeSize(num,buf,off){num.toString(8).length>11?encodeSizeBin(num,buf,off):b4a$2.write(buf,encodeOct(num,11),off)}function parse256(buf){let positive;if(buf[0]===128)positive=!0;else if(buf[0]===255)positive=!1;else return null;let tuple=[],i$5;for(i$5=buf.length-1;i$5>0;i$5--){let byte$1=buf[i$5];positive?tuple.push(byte$1):tuple.push(255-byte$1)}let sum=0,l$2=tuple.length;for(i$5=0;i$5<l$2;i$5++)sum+=tuple[i$5]*256**i$5;return positive?sum:-1*sum}function decodeOct(val,offset,length){if(val=val.subarray(offset,offset+length),offset=0,val[offset]&128)return parse256(val);{for(;offset<val.length&&val[offset]===32;)offset++;let end=clamp$1(indexOf(val,32,offset,val.length),val.length,val.length);for(;offset<end&&val[offset]===0;)offset++;return end===offset?0:parseInt(b4a$2.toString(val.subarray(offset,end)),8)}}function decodeStr(val,offset,length,encoding){return b4a$2.toString(val.subarray(offset,indexOf(val,0,offset,offset+length)),encoding)}function addLength(str$1){let len$1=b4a$2.byteLength(str$1),digits=Math.floor(Math.log(len$1)/Math.log(10))+1;return len$1+digits>=10**digits&&digits++,len$1+digits+str$1}})),require_extract=__commonJSMin(((exports,module)=>{let{Writable:Writable$8,Readable:Readable$12,getStreamError:getStreamError$1}=require_streamx(),FIFO=require_fast_fifo(),b4a$1=require_b4a(),headers$1=require_headers$1(),EMPTY$1=b4a$1.alloc(0);var BufferList=class{constructor(){this.buffered=0,this.shifted=0,this.queue=new FIFO,this._offset=0}push(buffer$2){this.buffered+=buffer$2.byteLength,this.queue.push(buffer$2)}shiftFirst(size){return this._buffered===0?null:this._next(size)}shift(size){if(size>this.buffered)return null;if(size===0)return EMPTY$1;let chunk$1=this._next(size);if(size===chunk$1.byteLength)return chunk$1;let chunks=[chunk$1];for(;(size-=chunk$1.byteLength)>0;)chunk$1=this._next(size),chunks.push(chunk$1);return b4a$1.concat(chunks)}_next(size){let buf=this.queue.peek(),rem=buf.byteLength-this._offset;if(size>=rem){let sub=this._offset?buf.subarray(this._offset,buf.byteLength):buf;return this.queue.shift(),this._offset=0,this.buffered-=rem,this.shifted+=rem,sub}return this.buffered-=size,this.shifted+=size,buf.subarray(this._offset,this._offset+=size)}},Source=class extends Readable$12{constructor(self$1,header,offset){super(),this.header=header,this.offset=offset,this._parent=self$1}_read(cb){this.header.size===0&&this.push(null),this._parent._stream===this&&this._parent._update(),cb(null)}_predestroy(){this._parent.destroy(getStreamError$1(this))}_detach(){this._parent._stream===this&&(this._parent._stream=null,this._parent._missing=overflow$1(this.header.size),this._parent._update())}_destroy(cb){this._detach(),cb(null)}},Extract=class extends Writable$8{constructor(opts){super(opts),opts||={},this._buffer=new BufferList,this._offset=0,this._header=null,this._stream=null,this._missing=0,this._longHeader=!1,this._callback=noop$24,this._locked=!1,this._finished=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null,this._filenameEncoding=opts.filenameEncoding||`utf-8`,this._allowUnknownFormat=!!opts.allowUnknownFormat,this._unlockBound=this._unlock.bind(this)}_unlock(err$1){if(this._locked=!1,err$1){this.destroy(err$1),this._continueWrite(err$1);return}this._update()}_consumeHeader(){if(this._locked)return!1;this._offset=this._buffer.shifted;try{this._header=headers$1.decode(this._buffer.shift(512),this._filenameEncoding,this._allowUnknownFormat)}catch(err$1){return this._continueWrite(err$1),!1}if(!this._header)return!0;switch(this._header.type){case`gnu-long-path`:case`gnu-long-link-path`:case`pax-global-header`:case`pax-header`:return this._longHeader=!0,this._missing=this._header.size,!0}return this._locked=!0,this._applyLongHeaders(),this._header.size===0||this._header.type===`directory`?(this.emit(`entry`,this._header,this._createStream(),this._unlockBound),!0):(this._stream=this._createStream(),this._missing=this._header.size,this.emit(`entry`,this._header,this._stream,this._unlockBound),!0)}_applyLongHeaders(){this._gnuLongPath&&=(this._header.name=this._gnuLongPath,null),this._gnuLongLinkPath&&=(this._header.linkname=this._gnuLongLinkPath,null),this._pax&&=(this._pax.path&&(this._header.name=this._pax.path),this._pax.linkpath&&(this._header.linkname=this._pax.linkpath),this._pax.size&&(this._header.size=parseInt(this._pax.size,10)),this._header.pax=this._pax,null)}_decodeLongHeader(buf){switch(this._header.type){case`gnu-long-path`:this._gnuLongPath=headers$1.decodeLongPath(buf,this._filenameEncoding);break;case`gnu-long-link-path`:this._gnuLongLinkPath=headers$1.decodeLongPath(buf,this._filenameEncoding);break;case`pax-global-header`:this._paxGlobal=headers$1.decodePax(buf);break;case`pax-header`:this._pax=this._paxGlobal===null?headers$1.decodePax(buf):Object.assign({},this._paxGlobal,headers$1.decodePax(buf));break}}_consumeLongHeader(){this._longHeader=!1,this._missing=overflow$1(this._header.size);let buf=this._buffer.shift(this._header.size);try{this._decodeLongHeader(buf)}catch(err$1){return this._continueWrite(err$1),!1}return!0}_consumeStream(){let buf=this._buffer.shiftFirst(this._missing);if(buf===null)return!1;this._missing-=buf.byteLength;let drained=this._stream.push(buf);return this._missing===0?(this._stream.push(null),drained&&this._stream._detach(),drained&&this._locked===!1):drained}_createStream(){return new Source(this,this._header,this._offset)}_update(){for(;this._buffer.buffered>0&&!this.destroying;){if(this._missing>0){if(this._stream!==null){if(this._consumeStream()===!1)return;continue}if(this._longHeader===!0){if(this._missing>this._buffer.buffered)break;if(this._consumeLongHeader()===!1)return!1;continue}let ignore$3=this._buffer.shiftFirst(this._missing);ignore$3!==null&&(this._missing-=ignore$3.byteLength);continue}if(this._buffer.buffered<512)break;if(this._stream!==null||this._consumeHeader()===!1)return}this._continueWrite(null)}_continueWrite(err$1){let cb=this._callback;this._callback=noop$24,cb(err$1)}_write(data$2,cb){this._callback=cb,this._buffer.push(data$2),this._update()}_final(cb){this._finished=this._missing===0&&this._buffer.buffered===0,cb(this._finished?null:Error(`Unexpected end of data`))}_predestroy(){this._continueWrite(null)}_destroy(cb){this._stream&&this._stream.destroy(getStreamError$1(this)),cb(null)}[Symbol.asyncIterator](){let error$21=null,promiseResolve=null,promiseReject=null,entryStream=null,entryCallback=null,extract=this;return this.on(`entry`,onentry),this.on(`error`,err$1=>{error$21=err$1}),this.on(`close`,onclose),{[Symbol.asyncIterator](){return this},next(){return new Promise(onnext)},return(){return destroy$2(null)},throw(err$1){return destroy$2(err$1)}};function consumeCallback(err$1){if(!entryCallback)return;let cb=entryCallback;entryCallback=null,cb(err$1)}function onnext(resolve$10,reject){if(error$21)return reject(error$21);if(entryStream){resolve$10({value:entryStream,done:!1}),entryStream=null;return}promiseResolve=resolve$10,promiseReject=reject,consumeCallback(null),extract._finished&&promiseResolve&&(promiseResolve({value:void 0,done:!0}),promiseResolve=promiseReject=null)}function onentry(header,stream$10,callback$1){entryCallback=callback$1,stream$10.on(`error`,noop$24),promiseResolve?(promiseResolve({value:stream$10,done:!1}),promiseResolve=promiseReject=null):entryStream=stream$10}function onclose(){consumeCallback(error$21),promiseResolve&&=(error$21?promiseReject(error$21):promiseResolve({value:void 0,done:!0}),promiseReject=null)}function destroy$2(err$1){return extract.destroy(err$1),consumeCallback(err$1),new Promise((resolve$10,reject)=>{if(extract.destroyed)return resolve$10({value:void 0,done:!0});extract.once(`close`,function(){err$1?reject(err$1):resolve$10({value:void 0,done:!0})})})}}};module.exports=function(opts){return new Extract(opts)};function noop$24(){}function overflow$1(size){return size&=511,size&&512-size}})),require_constants$10=__commonJSMin(((exports,module)=>{let constants$8={S_IFMT:61440,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960};try{module.exports=__require$1(`fs`).constants||constants$8}catch{module.exports=constants$8}})),require_pack=__commonJSMin(((exports,module)=>{let{Readable:Readable$11,Writable:Writable$7,getStreamError}=require_streamx(),b4a=require_b4a(),constants$7=require_constants$10(),headers=require_headers$1(),DMODE=493,FMODE=420,END_OF_TAR=b4a.alloc(1024);var Sink=class extends Writable$7{constructor(pack,header,callback$1){super({mapWritable,eagerOpen:!0}),this.written=0,this.header=header,this._callback=callback$1,this._linkname=null,this._isLinkname=header.type===`symlink`&&!header.linkname,this._isVoid=header.type!==`file`&&header.type!==`contiguous-file`,this._finished=!1,this._pack=pack,this._openCallback=null,this._pack._stream===null?this._pack._stream=this:this._pack._pending.push(this)}_open(cb){this._openCallback=cb,this._pack._stream===this&&this._continueOpen()}_continuePack(err$1){if(this._callback===null)return;let callback$1=this._callback;this._callback=null,callback$1(err$1)}_continueOpen(){this._pack._stream===null&&(this._pack._stream=this);let cb=this._openCallback;if(this._openCallback=null,cb!==null){if(this._pack.destroying)return cb(Error(`pack stream destroyed`));if(this._pack._finalized)return cb(Error(`pack stream is already finalized`));this._pack._stream=this,this._isLinkname||this._pack._encode(this.header),this._isVoid&&(this._finish(),this._continuePack(null)),cb(null)}}_write(data$2,cb){if(this._isLinkname)return this._linkname=this._linkname?b4a.concat([this._linkname,data$2]):data$2,cb(null);if(this._isVoid)return data$2.byteLength>0?cb(Error(`No body allowed for this entry`)):cb();if(this.written+=data$2.byteLength,this._pack.push(data$2))return cb();this._pack._drain=cb}_finish(){this._finished||(this._finished=!0,this._isLinkname&&(this.header.linkname=this._linkname?b4a.toString(this._linkname,`utf-8`):``,this._pack._encode(this.header)),overflow(this._pack,this.header.size),this._pack._done(this))}_final(cb){if(this.written!==this.header.size)return cb(Error(`Size mismatch`));this._finish(),cb(null)}_getError(){return getStreamError(this)||Error(`tar entry destroyed`)}_predestroy(){this._pack.destroy(this._getError())}_destroy(cb){this._pack._done(this),this._continuePack(this._finished?null:this._getError()),cb()}},Pack=class extends Readable$11{constructor(opts){super(opts),this._drain=noop$23,this._finalized=!1,this._finalizing=!1,this._pending=[],this._stream=null}entry(header,buffer$2,callback$1){if(this._finalized||this.destroying)throw Error(`already finalized or destroyed`);typeof buffer$2==`function`&&(callback$1=buffer$2,buffer$2=null),callback$1||=noop$23,(!header.size||header.type===`symlink`)&&(header.size=0),header.type||=modeToType(header.mode),header.mode||=header.type===`directory`?493:420,header.uid||=0,header.gid||=0,header.mtime||=new Date,typeof buffer$2==`string`&&(buffer$2=b4a.from(buffer$2));let sink=new Sink(this,header,callback$1);return b4a.isBuffer(buffer$2)?(header.size=buffer$2.byteLength,sink.write(buffer$2),sink.end(),sink):(sink._isVoid,sink)}finalize(){if(this._stream||this._pending.length>0){this._finalizing=!0;return}this._finalized||(this._finalized=!0,this.push(END_OF_TAR),this.push(null))}_done(stream$10){stream$10===this._stream&&(this._stream=null,this._finalizing&&this.finalize(),this._pending.length&&this._pending.shift()._continueOpen())}_encode(header){if(!header.pax){let buf=headers.encode(header);if(buf){this.push(buf);return}}this._encodePax(header)}_encodePax(header){let paxHeader=headers.encodePax({name:header.name,linkname:header.linkname,pax:header.pax}),newHeader={name:`PaxHeader`,mode:header.mode,uid:header.uid,gid:header.gid,size:paxHeader.byteLength,mtime:header.mtime,type:`pax-header`,linkname:header.linkname&&`PaxHeader`,uname:header.uname,gname:header.gname,devmajor:header.devmajor,devminor:header.devminor};this.push(headers.encode(newHeader)),this.push(paxHeader),overflow(this,paxHeader.byteLength),newHeader.size=header.size,newHeader.type=header.type,this.push(headers.encode(newHeader))}_doDrain(){let drain=this._drain;this._drain=noop$23,drain()}_predestroy(){let err$1=getStreamError(this);for(this._stream&&this._stream.destroy(err$1);this._pending.length;){let stream$10=this._pending.shift();stream$10.destroy(err$1),stream$10._continueOpen()}this._doDrain()}_read(cb){this._doDrain(),cb()}};module.exports=function(opts){return new Pack(opts)};function modeToType(mode){switch(mode&constants$7.S_IFMT){case constants$7.S_IFBLK:return`block-device`;case constants$7.S_IFCHR:return`character-device`;case constants$7.S_IFDIR:return`directory`;case constants$7.S_IFIFO:return`fifo`;case constants$7.S_IFLNK:return`symlink`}return`file`}function noop$23(){}function overflow(self$1,size){size&=511,size&&self$1.push(END_OF_TAR.subarray(0,512-size))}function mapWritable(buf){return b4a.isBuffer(buf)?buf:b4a.from(buf)}})),require_tar_stream=__commonJSMin((exports=>{exports.extract=require_extract(),exports.pack=require_pack()})),import_tar_stream=__toESM(require_tar_stream());const createTarFromDirectory=async(path$34,opts)=>{let{maxBytes=50*1024*1024}=opts??{},stat$5=await fs$3.stat(path$34);if(!stat$5.isDirectory())throw Error(`Path is not a directory: ${path$34}`);let pack=import_tar_stream.pack(),walk=async(dir,prefix=``)=>{let entries$1=await fs$3.readdir(dir,{withFileTypes:!0});for(let entry of entries$1){let fullPath=`${dir}/${entry.name}`,headerName=prefix?`${prefix}/${entry.name}`:entry.name;if(entry.isDirectory()){pack.entry({name:`${headerName}/`,type:`directory`}),await walk(fullPath,headerName);continue}if(entry.isSymbolicLink?.()){let link$4=await fs$3.readlink(fullPath);pack.entry({name:headerName,type:`symlink`,linkname:link$4});continue}if(entry.isFile()){let fileStat=await fs$3.stat(fullPath);await new Promise((resolve$10,reject)=>{let fileStream=createReadStream(fullPath),tarEntry=pack.entry({name:headerName,size:fileStat.size,mode:fileStat.mode,mtime:fileStat.mtime},err$1=>{err$1&&reject(err$1)});fileStream.on(`error`,reject),fileStream.on(`data`,chunk$1=>tarEntry.write(chunk$1)),fileStream.on(`end`,()=>{tarEntry.end(),resolve$10()})});continue}}};(async()=>{try{await walk(path$34),pack.finalize()}catch(err$1){pack.destroy(err$1)}})();let nodeReadable=pack,emitted=0,ended=!1;return new ReadableStream({start(controller){let onData=chunk$1=>{if(!ended){if(emitted+=chunk$1.length,emitted>maxBytes){ended=!0,controller.error(Error(`Archive exceeds size limit (${maxBytes} bytes). Emitted=${emitted} bytes.`));try{nodeReadable.destroy()}catch{}return}controller.enqueue(new Uint8Array(chunk$1))}},onError$3=err$1=>{ended||(ended=!0,controller.error(err$1 instanceof Error?err$1:Error(String(err$1))))},onEnd=()=>{ended||(ended=!0,controller.close())};nodeReadable.on(`data`,onData),nodeReadable.once(`error`,onError$3),nodeReadable.once(`end`,onEnd)},cancel(){try{nodeReadable.destroy()}catch{}}})},truncateAnsi=(text$2,limit)=>text$2.length<=limit?text$2:text$2.slice(text$2.length-limit),truncateLinesByChars=(lines,limit)=>{if(lines.length===0)return{lines:[],truncated:!1};let total=0,startIdx=lines.length;for(let i$5=lines.length-1;i$5>=0;i$5--){let len$1=lines[i$5].length;if(total+len$1>limit&&startIdx!==lines.length)break;total+=len$1,startIdx=i$5}return startIdx===0?{lines,truncated:!1}:{lines:lines.slice(startIdx),truncated:!0}};var Server$1=class{multiplexer;notificationStream;decoder=new TextDecoder;encoder=new TextEncoder;processManager;createDeploymentFromTar;constructor(opts){this.createDeploymentFromTar=opts.createDeploymentFromTar,this.multiplexer=new Multiplexer({send:msg=>{opts.send(msg)}}),this.multiplexer.onStream(stream$10=>{this.handleStream(stream$10)}),this.notificationStream=this.multiplexer.createStream(),this.processManager=new ProcessManager(opts.env),this.processManager.onSpawn(process$10=>{let update=()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(process$10.pid)}})};update(),process$10.terminal.onTitleChange(()=>{update()}),process$10.onExit(()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(process$10.pid)}})}),process$10.onOutput(output=>{let maxTypedChunk=FrameCodec.getMaxPayloadSize()-1;for(let i$5=0;i$5<output.length;i$5+=maxTypedChunk){let chunk$1=output.slice(i$5,i$5+maxTypedChunk);this.sendNotification({type:`process_output`,payload:{pid:process$10.pid,output:chunk$1}})}})})}handleMessage(message){this.multiplexer.handleMessage(message)}handleStream(stream$10){let signal=new AbortController;stream$10.onClose(()=>{signal.abort()}),stream$10.onData(message=>{let type=message[0],payload=message.subarray(1);switch(type){case ClientMessageType.REQUEST:{let request$3=JSON.parse(this.decoder.decode(payload));this.handleRequest(stream$10,request$3,signal.signal).catch(err$1=>{this.sendResponse(stream$10,{id:request$3.id,error:err$1 instanceof Error?err$1.message:String(err$1)})});break}case ClientMessageType.PROXY_INIT:{let parsed=ClientMessageSchema[ClientMessageType.PROXY_INIT].safeParse(JSON.parse(this.decoder.decode(payload)));if(!parsed.success)throw Error(`Invalid proxy init message`);let promise$1;promise$1=parsed.data.headers.upgrade===`websocket`?this.handleProxyWebSocket(stream$10,parsed.data):this.handleProxyRequest(stream$10,parsed.data),promise$1.catch(err$1=>{stream$10.error(err$1.message)});break}}})}async handleProxyWebSocket(stream$10,request$3){let url$3=new URL(request$3.url);url$3.protocol===`http:`?url$3.protocol=`ws:`:url$3.protocol===`https:`&&(url$3.protocol=`wss:`);let ws$2=new import_websocket.default(url$3.toString(),request$3.headers[`sec-websocket-protocol`]?request$3.headers[`sec-websocket-protocol`]:void 0,{headers:request$3.headers,perMessageDeflate:!1});ws$2.addEventListener(`open`,()=>{let init$4={status_code:101,status_message:`Switching Protocols`,headers:{}};stream$10.writeTyped(ServerMessageType.PROXY_INIT,this.encoder.encode(JSON.stringify(init$4)))}),ws$2.addEventListener(`message`,event=>{stream$10.disposed||stream$10.writeTyped(ServerMessageType.PROXY_WEBSOCKET_MESSAGE,createWebSocketMessagePayload(event.data,this.encoder))}),ws$2.addEventListener(`close`,event=>{if(stream$10.disposed)return;let payload={code:event.code,reason:event.reason};stream$10.writeTyped(ServerMessageType.PROXY_WEBSOCKET_CLOSE,this.encoder.encode(JSON.stringify(payload))),stream$10.close()}),ws$2.addEventListener(`error`,event=>{console.log(`err`,event)}),stream$10.onClose(()=>{ws$2.close()}),stream$10.onError(err$1=>{ws$2.close(1011,err$1)}),stream$10.onData(message=>{let payload=message.subarray(1);switch(message[0]){case ClientMessageType.PROXY_WEBSOCKET_MESSAGE:{let parsed=parseWebSocketMessagePayload(payload,this.decoder);ws$2.send(parsed);break}case ClientMessageType.PROXY_WEBSOCKET_CLOSE:{let parsed=ClientMessageSchema[ClientMessageType.PROXY_WEBSOCKET_CLOSE].safeParse(JSON.parse(this.decoder.decode(payload)));if(!parsed.success)throw Error(`Invalid proxy websocket close message`);try{ws$2.close(parsed.data.code,parsed.data.reason)}catch(err$1){console.error(`Error closing websocket`,err$1,parsed.data)}break}default:stream$10.error(`Unexpected message type: ${message[0]}`)}})}async handleProxyRequest(stream$10,request$3){let bodyWriter,bodyReader;if(request$3.method!==`GET`&&request$3.method!==`HEAD`&&request$3.method!==`OPTIONS`){let transform=new TransformStream;bodyWriter=transform.writable.getWriter(),bodyReader=transform.readable}stream$10.onData(message=>{switch(message[0]){case ClientMessageType.PROXY_BODY:if(bodyWriter){let chunk$1=message.subarray(1);chunk$1.length===0?bodyWriter.close():bodyWriter.write(chunk$1)}break;default:stream$10.error(`Unexpected message type: ${message[0]}`)}});let response=await fetch(request$3.url,{headers:request$3.headers,method:request$3.method,body:bodyReader}),headers$2={};response.headers.forEach((value,key)=>{headers$2[key]=value});let init$4={headers:headers$2,status_code:response.status,status_message:response.statusText};stream$10.writeTyped(ServerMessageType.PROXY_INIT,this.encoder.encode(JSON.stringify(init$4)));let contentLength=response.headers.get(`content-length`),responseSize=contentLength?parseInt(contentLength):0,maxChunkSize=FrameCodec.getMaxPayloadSize()-1;if(responseSize>=maxChunkSize){if(!response.body){stream$10.close();return}let reader=response.body.getReader();try{for(;;){let{done,value}=await reader.read();if(done)break;if(value){let offset=0;for(;offset<value.length;){let chunkSize=Math.min(maxChunkSize,value.length-offset),chunk$1=value.subarray(offset,offset+chunkSize);stream$10.writeTyped(ServerMessageType.PROXY_DATA,chunk$1),offset+=chunkSize}}}}finally{reader.releaseLock()}}else response.body&&await response.body.pipeTo(new WritableStream({write:chunk$1=>{stream$10.writeTyped(ServerMessageType.PROXY_DATA,chunk$1)}}));stream$10.close()}async handleRequest(stream$10,request$3,signal){let requestSchema=RequestSchema$3[request$3.type],parsed=requestSchema.safeParse(request$3.payload);if(!parsed.success)throw Error(`Invalid request payload: ${parsed.error.message}`);switch(request$3.type){case`process_execute`:{let process$10=this.processManager.execute(request$3.payload.command,request$3.payload.args,{cwd:request$3.payload.cwd,env:request$3.payload.env});this.sendResponse(stream$10,{id:request$3.id,payload:{pid:process$10.pid}});break}case`process_wait`:this.handleProcessWait(stream$10,request$3,signal);break;case`process_kill`:{let process$10=this.mustGetProcess(request$3.payload.pid);process$10.kill(request$3.payload.signal),this.sendResponse(stream$10,{id:request$3.id,payload:{}});break}case`process_list`:this.sendResponse(stream$10,{id:request$3.id,payload:{processes:this.processManager.list(request$3.payload.include_dead??!1)}});break;case`process_read_plain_output`:{let process$10=this.mustGetProcess(request$3.payload.pid),plainOutput=this.processManager.readPlainOutput(request$3.payload.pid,request$3.payload.start_line,request$3.payload.end_line),truncated=truncateLinesByChars(plainOutput.lines,256e3);this.sendResponse(stream$10,{id:request$3.id,payload:{lines:truncated.lines,total_lines:plainOutput.totalLines,duration_ms:Date.now()-process$10.startTimeMS,exit_code:process$10.exitCode,exit_signal:process$10.exitSignal}});break}case`process_send_input`:{let process$10=this.mustGetProcess(request$3.payload.pid);process$10.sendInput(request$3.payload.data),this.sendResponse(stream$10,{id:request$3.id,payload:{}});break}case`set_env`:this.processManager.setEnv(request$3.payload.env),this.sendResponse(stream$10,{id:request$3.id,payload:{}});break;case`deploy_static_files`:{if(!this.createDeploymentFromTar)throw Error(`This server does not support static file deployments!`);let tar=await createTarFromDirectory(request$3.payload.path),deploymentID=await this.createDeploymentFromTar(tar);this.sendResponse(stream$10,{id:request$3.id,payload:{deployment_id:deploymentID}});break}case`read_file`:{let file=await fs$37.readFile(request$3.payload.path),fileType=await fileTypeFromBuffer(file),readAsText=!fileType||fileType?.mime===`text/plain`;if(!readAsText){this.sendResponse(stream$10,{id:request$3.id,payload:{content:file.toString(`base64`),mime_type:fileType?.mime,total_lines:0,lines_read:0,start_line:0}});break}let content=file.toString(`utf-8`),allLines=content.split(`
49
49
  `),startLine=(request$3.payload.line_start??1)-1,endLine=request$3.payload.line_end??allLines.length,readLines=allLines.slice(startLine,endLine);this.sendResponse(stream$10,{id:request$3.id,payload:{content:readLines.join(`
50
- `),mime_type:`text/plain`,total_lines:allLines.length,lines_read:readLines.length,start_line:startLine}});break}case`write_file`:request$3.payload.base64?await fs$37.writeFile(request$3.payload.path,Buffer.from(request$3.payload.content,`base64`)):await fs$37.writeFile(request$3.payload.path,request$3.payload.content),typeof request$3.payload.mode==`number`&&await fs$37.chmod(request$3.payload.path,request$3.payload.mode),this.sendResponse(stream$10,{id:request$3.id,payload:{}});break;case`read_directory`:{let files=await fs$37.readdir(request$3.payload.path,{withFileTypes:!0});this.sendResponse(stream$10,{id:request$3.id,payload:{entries:files.map(file=>({name:file.name,type:file.isDirectory()?`directory`:file.isSymbolicLink()?`symlink`:`file`}))}});break}default:throw Error(`Unknown request type: ${request$3.type}`)}}sendResponse(stream$10,response){stream$10.writeTyped(ServerMessageType.RESPONSE,this.encoder.encode(JSON.stringify(response)))}sendNotification(notification){this.notificationStream.write(new Uint8Array([ServerMessageType.NOTIFICATION,...this.encoder.encode(JSON.stringify(notification))]))}handleProcessWait(stream$10,request$3,signal){let payload=request$3.payload,process$10=this.mustGetProcess(payload.pid),onOutput,onExit$1,ended=!1,outputIdleTimeout,timeout;typeof payload.timeout_ms==`number`&&(timeout=setTimeout(()=>{end()},payload.timeout_ms));let end=()=>{if(ended||(ended=!0,onOutput&&onOutput.dispose(),onExit$1&&onExit$1.dispose(),timeout&&clearTimeout(timeout),outputIdleTimeout&&clearTimeout(outputIdleTimeout),signal?.aborted))return;let status=this.processManager.status(payload.pid),plainOutput=this.processManager.readPlainOutput(status.pid),ansi_output_truncated=truncateAnsi(this.processManager.readANSIOutput(status.pid),64e3),plain_trunc=truncateLinesByChars(plainOutput.lines,256e3);this.sendResponse(stream$10,{id:request$3.id,payload:{...status,ansi_output:ansi_output_truncated,plain_output:{lines:plain_trunc.lines,total_lines:plainOutput.totalLines}}})};if(typeof process$10.exitCode==`number`||typeof process$10.exitSignal==`number`){end();return}onOutput=process$10.onOutput(()=>{outputIdleTimeout&&clearTimeout(outputIdleTimeout),typeof payload.output_idle_timeout_ms==`number`&&(outputIdleTimeout=setTimeout(()=>{end()},payload.output_idle_timeout_ms))}),onExit$1=process$10.onExit(()=>{setTimeout(()=>{end()},10)}),signal.addEventListener(`abort`,()=>{end()})}mustGetProcess(pid){let process$10=this.processManager.getProcess(pid);if(!process$10)throw Error(`Process ${pid} not found`);return process$10}};init_wrapper();const tempLogPath=path.join(os.tmpdir(),`blink-connect-${process.pid}.log`),serializeError=err$1=>{if(err$1 instanceof Error)return err$1.stack??err$1.message;try{return JSON.stringify(err$1)}catch{return String(err$1)}},appendLog=async message=>{let line$1=`${new Date().toISOString()} ${message}\n`;try{await fs.promises.appendFile(tempLogPath,line$1,`utf8`)}catch{}};async function connect(){let url$3=process.env.BLINK_URL,token$1=process.env.BLINK_TOKEN;delete process.env.BLINK_TOKEN,process.env.GIT_TERMINAL_PROMPT=`0`,process.env.GIT_PAGER=`cat`,process.env.GIT_AUTHOR_NAME=`blink-so[bot]`,process.env.GIT_AUTHOR_EMAIL=`211532188+blink-so[bot]@users.noreply.github.com`,process.env.GIT_COMMITTER_NAME=`blink-so[bot]`,process.env.GIT_COMMITTER_EMAIL=`211532188+blink-so[bot]@users.noreply.github.com`,process.env.GIT_CONFIG_COUNT=`1`,process.env.GIT_CONFIG_KEY_0=`credential.https://github.com.helper`,process.env.GIT_CONFIG_VALUE_0=`!gh auth git-credential`,process.addListener(`uncaughtException`,err$1=>{appendLog(`uncaughtException: ${serializeError(err$1)}`),reportException(token$1,err$1)}),process.addListener(`unhandledRejection`,err$1=>{appendLog(`unhandledRejection: ${serializeError(err$1)}`),reportException(token$1,err$1)});let srv=new WorkspaceConnect({url:url$3??`wss://blink.so/api/connect`,token:token$1,createDeploymentFromTar:async tar=>{let uploadURL=new URL(`/api/static-deployment`,url$3??`https://blink.so`),response=await fetch(uploadURL,{method:`POST`,body:tar,headers:{"Content-Type":`application/tar`,Authorization:`Bearer ${token$1}`},duplex:`half`}),data$2=await response.json();return data$2.deployment_id}});srv.onConnect(()=>{console.log(`Connected`),appendLog(`Connected`)}),srv.onDisconnect(()=>{console.log(`Disconnected`),appendLog(`Disconnected`)})}const reportException=async(token$1,err$1)=>{let url$3=new URL(`https://blink.so/api/connect-error`);await fetch(url$3.toString(),{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${token$1}`},body:JSON.stringify({error:err$1})})};var WorkspaceConnect=class{_onConnect=new Emitter;onConnect=this._onConnect.event;_onDisconnect=new Emitter;onDisconnect=this._onDisconnect.event;reconnectTimeout=null;disposed=!1;ws;server;hasReconnectedOnce=!1;constructor(opts){this.opts=opts,this.server=new Server$1({send:message=>{this.ws.readyState===wrapper_default.OPEN?this.ws.send(message):console.warn(`Message skipped because connection is closed.`)},createDeploymentFromTar:this.opts.createDeploymentFromTar}),this.connect()}dispose(){this.disposed||(this.disposed=!0,this.ws.close(),this.reconnectTimeout&&clearTimeout(this.reconnectTimeout))}scheduleReconnect(){if(this.disposed)return;let immediateFirst=this.opts.immediateReconnectFirst??!0,baseDelay=this.opts.reconnectionDelay??2500,delay$3=baseDelay;!this.hasReconnectedOnce&&immediateFirst&&(delay$3=0),this.hasReconnectedOnce=!0,this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.reconnectTimeout=setTimeout(()=>{this.connect()},delay$3)}connect(){let url$3=new URL(this.opts.url);url$3.protocol===`http:`?url$3.protocol=`ws:`:url$3.protocol===`https:`&&(url$3.protocol=`wss:`);let headers$2={};this.opts.token&&(headers$2.Authorization=`Bearer ${this.opts.token}`),this.ws=new wrapper_default(url$3.toString(),{headers:headers$2}),this.ws.addEventListener(`open`,()=>{this._onConnect.emit()}),this.ws.addEventListener(`close`,()=>{this._onDisconnect.emit(),!this.disposed&&this.scheduleReconnect()}),this.ws.addEventListener(`error`,event=>{console.error(`Error`,event.message??event)}),this.ws.addEventListener(`message`,event=>{if(typeof event.data==`string`){console.warn(`Message skipped because it is not a buffer.`);return}try{this.server.handleMessage(new Uint8Array(event.data))}catch(err$1){console.error(`message handler error`,err$1);try{this.ws.close(1011)}catch{}}})}};init_wrapper();async function chat(){let id=crypto.randomUUID(),ws$2=new import_websocket.default(`wss://blink.so/auth?id=${id}`),opened=new Promise((resolve$10,reject)=>{ws$2.onopen=()=>{resolve$10()},ws$2.onerror=event=>{reject(event)}});await opened;let tokenPromise=new Promise((resolve$10,reject)=>{ws$2.onmessage=event=>{let data$2=JSON.parse(event.data.toString());data$2.type===`connect`&&resolve$10(data$2.token)}}),url$3=`https://blink.so/auth?id=${id}&type=workspace`;console.log(`Opening the following URL in your browser: ${url$3}`),await open_default(url$3);let token$1=await tokenPromise,srv=new WorkspaceConnect({url:`wss://blink.so/api/connect`,token:token$1});srv.onConnect(()=>{console.log(`Connected to Blink`)}),srv.onDisconnect(()=>{console.log(`Disconnected from Blink`)})}var require_react_production=__commonJSMin((exports=>{var REACT_ELEMENT_TYPE$2=Symbol.for(`react.transitional.element`),REACT_PORTAL_TYPE=Symbol.for(`react.portal`),REACT_FRAGMENT_TYPE$1=Symbol.for(`react.fragment`),REACT_STRICT_MODE_TYPE=Symbol.for(`react.strict_mode`),REACT_PROFILER_TYPE=Symbol.for(`react.profiler`),REACT_CONSUMER_TYPE=Symbol.for(`react.consumer`),REACT_CONTEXT_TYPE=Symbol.for(`react.context`),REACT_FORWARD_REF_TYPE=Symbol.for(`react.forward_ref`),REACT_SUSPENSE_TYPE=Symbol.for(`react.suspense`),REACT_MEMO_TYPE=Symbol.for(`react.memo`),REACT_LAZY_TYPE=Symbol.for(`react.lazy`),MAYBE_ITERATOR_SYMBOL=Symbol.iterator;function getIteratorFn(maybeIterable){return typeof maybeIterable!=`object`||!maybeIterable?null:(maybeIterable=MAYBE_ITERATOR_SYMBOL&&maybeIterable[MAYBE_ITERATOR_SYMBOL]||maybeIterable[`@@iterator`],typeof maybeIterable==`function`?maybeIterable:null)}var ReactNoopUpdateQueue={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},assign=Object.assign,emptyObject={};function Component(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}Component.prototype.isReactComponent={},Component.prototype.setState=function(partialState,callback$1){if(typeof partialState!=`object`&&typeof partialState!=`function`&&partialState!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,partialState,callback$1,`setState`)},Component.prototype.forceUpdate=function(callback$1){this.updater.enqueueForceUpdate(this,callback$1,`forceUpdate`)};function ComponentDummy(){}ComponentDummy.prototype=Component.prototype;function PureComponent$1(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}var pureComponentPrototype=PureComponent$1.prototype=new ComponentDummy;pureComponentPrototype.constructor=PureComponent$1,assign(pureComponentPrototype,Component.prototype),pureComponentPrototype.isPureReactComponent=!0;var isArrayImpl=Array.isArray,ReactSharedInternals={H:null,A:null,T:null,S:null,V:null},hasOwnProperty$1=Object.prototype.hasOwnProperty;function ReactElement(type,key,self$1,source$39,owner,props){return self$1=props.ref,{$$typeof:REACT_ELEMENT_TYPE$2,type,key,ref:self$1===void 0?null:self$1,props}}function cloneAndReplaceKey(oldElement,newKey){return ReactElement(oldElement.type,newKey,void 0,void 0,void 0,oldElement.props)}function isValidElement(object$2){return typeof object$2==`object`&&!!object$2&&object$2.$$typeof===REACT_ELEMENT_TYPE$2}function escape$7(key){var escaperLookup={"=":`=0`,":":`=2`};return`$`+key.replace(/[=:]/g,function(match$1){return escaperLookup[match$1]})}var userProvidedKeyEscapeRegex=/\/+/g;function getElementKey(element,index){return typeof element==`object`&&element&&element.key!=null?escape$7(``+element.key):index.toString(36)}function noop$1$1(){}function resolveThenable(thenable){switch(thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason;default:switch(typeof thenable.status==`string`?thenable.then(noop$1$1,noop$1$1):(thenable.status=`pending`,thenable.then(function(fulfilledValue){thenable.status===`pending`&&(thenable.status=`fulfilled`,thenable.value=fulfilledValue)},function(error$21){thenable.status===`pending`&&(thenable.status=`rejected`,thenable.reason=error$21)})),thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason}}throw thenable}function mapIntoArray(children,array,escapedPrefix,nameSoFar,callback$1){var type=typeof children;(type===`undefined`||type===`boolean`)&&(children=null);var invokeCallback=!1;if(children===null)invokeCallback=!0;else switch(type){case`bigint`:case`string`:case`number`:invokeCallback=!0;break;case`object`:switch(children.$$typeof){case REACT_ELEMENT_TYPE$2:case REACT_PORTAL_TYPE:invokeCallback=!0;break;case REACT_LAZY_TYPE:return invokeCallback=children._init,mapIntoArray(invokeCallback(children._payload),array,escapedPrefix,nameSoFar,callback$1)}}if(invokeCallback)return callback$1=callback$1(children),invokeCallback=nameSoFar===``?`.`+getElementKey(children,0):nameSoFar,isArrayImpl(callback$1)?(escapedPrefix=``,invokeCallback!=null&&(escapedPrefix=invokeCallback.replace(userProvidedKeyEscapeRegex,`$&/`)+`/`),mapIntoArray(callback$1,array,escapedPrefix,``,function(c$3){return c$3})):callback$1!=null&&(isValidElement(callback$1)&&(callback$1=cloneAndReplaceKey(callback$1,escapedPrefix+(callback$1.key==null||children&&children.key===callback$1.key?``:(``+callback$1.key).replace(userProvidedKeyEscapeRegex,`$&/`)+`/`)+invokeCallback)),array.push(callback$1)),1;invokeCallback=0;var nextNamePrefix=nameSoFar===``?`.`:nameSoFar+`:`;if(isArrayImpl(children))for(var i$5=0;i$5<children.length;i$5++)nameSoFar=children[i$5],type=nextNamePrefix+getElementKey(nameSoFar,i$5),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback$1);else if(i$5=getIteratorFn(children),typeof i$5==`function`)for(children=i$5.call(children),i$5=0;!(nameSoFar=children.next()).done;)nameSoFar=nameSoFar.value,type=nextNamePrefix+getElementKey(nameSoFar,i$5++),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback$1);else if(type===`object`){if(typeof children.then==`function`)return mapIntoArray(resolveThenable(children),array,escapedPrefix,nameSoFar,callback$1);throw array=String(children),Error(`Objects are not valid as a React child (found: `+(array===`[object Object]`?`object with keys {`+Object.keys(children).join(`, `)+`}`:array)+`). If you meant to render a collection of children, use an array instead.`)}return invokeCallback}function mapChildren(children,func,context$1){if(children==null)return children;var result=[],count$1=0;return mapIntoArray(children,result,``,``,function(child){return func.call(context$1,child,count$1++)}),result}function lazyInitializer(payload){if(payload._status===-1){var ctor=payload._result;ctor=ctor(),ctor.then(function(moduleObject){(payload._status===0||payload._status===-1)&&(payload._status=1,payload._result=moduleObject)},function(error$21){(payload._status===0||payload._status===-1)&&(payload._status=2,payload._result=error$21)}),payload._status===-1&&(payload._status=0,payload._result=ctor)}if(payload._status===1)return payload._result.default;throw payload._result}var reportGlobalError=typeof reportError==`function`?reportError:function(error$21){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var event=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof error$21==`object`&&error$21&&typeof error$21.message==`string`?String(error$21.message):String(error$21),error:error$21});if(!window.dispatchEvent(event))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,error$21);return}console.error(error$21)};function noop$22(){}exports.Children={map:mapChildren,forEach:function(children,forEachFunc,forEachContext){mapChildren(children,function(){forEachFunc.apply(this,arguments)},forEachContext)},count:function(children){var n$2=0;return mapChildren(children,function(){n$2++}),n$2},toArray:function(children){return mapChildren(children,function(child){return child})||[]},only:function(children){if(!isValidElement(children))throw Error(`React.Children.only expected to receive a single React element child.`);return children}},exports.Component=Component,exports.Fragment=REACT_FRAGMENT_TYPE$1,exports.Profiler=REACT_PROFILER_TYPE,exports.PureComponent=PureComponent$1,exports.StrictMode=REACT_STRICT_MODE_TYPE,exports.Suspense=REACT_SUSPENSE_TYPE,exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ReactSharedInternals,exports.__COMPILER_RUNTIME={__proto__:null,c:function(size){return ReactSharedInternals.H.useMemoCache(size)}},exports.cache=function(fn){return function(){return fn.apply(null,arguments)}},exports.cloneElement=function(element,config,children){if(element==null)throw Error(`The argument must be a React element, but you passed `+element+`.`);var props=assign({},element.props),key=element.key,owner=void 0;if(config!=null)for(propName in config.ref!==void 0&&(owner=void 0),config.key!==void 0&&(key=``+config.key),config)!hasOwnProperty$1.call(config,propName)||propName===`key`||propName===`__self`||propName===`__source`||propName===`ref`&&config.ref===void 0||(props[propName]=config[propName]);var propName=arguments.length-2;if(propName===1)props.children=children;else if(1<propName){for(var childArray=Array(propName),i$5=0;i$5<propName;i$5++)childArray[i$5]=arguments[i$5+2];props.children=childArray}return ReactElement(element.type,key,void 0,void 0,owner,props)},exports.createContext=function(defaultValue){return defaultValue={$$typeof:REACT_CONTEXT_TYPE,_currentValue:defaultValue,_currentValue2:defaultValue,_threadCount:0,Provider:null,Consumer:null},defaultValue.Provider=defaultValue,defaultValue.Consumer={$$typeof:REACT_CONSUMER_TYPE,_context:defaultValue},defaultValue},exports.createElement=function(type,config,children){var propName,props={},key=null;if(config!=null)for(propName in config.key!==void 0&&(key=``+config.key),config)hasOwnProperty$1.call(config,propName)&&propName!==`key`&&propName!==`__self`&&propName!==`__source`&&(props[propName]=config[propName]);var childrenLength=arguments.length-2;if(childrenLength===1)props.children=children;else if(1<childrenLength){for(var childArray=Array(childrenLength),i$5=0;i$5<childrenLength;i$5++)childArray[i$5]=arguments[i$5+2];props.children=childArray}if(type&&type.defaultProps)for(propName in childrenLength=type.defaultProps,childrenLength)props[propName]===void 0&&(props[propName]=childrenLength[propName]);return ReactElement(type,key,void 0,void 0,null,props)},exports.createRef=function(){return{current:null}},exports.forwardRef=function(render$2){return{$$typeof:REACT_FORWARD_REF_TYPE,render:render$2}},exports.isValidElement=isValidElement,exports.lazy=function(ctor){return{$$typeof:REACT_LAZY_TYPE,_payload:{_status:-1,_result:ctor},_init:lazyInitializer}},exports.memo=function(type,compare$3){return{$$typeof:REACT_MEMO_TYPE,type,compare:compare$3===void 0?null:compare$3}},exports.startTransition=function(scope){var prevTransition=ReactSharedInternals.T,currentTransition={};ReactSharedInternals.T=currentTransition;try{var returnValue=scope(),onStartTransitionFinish=ReactSharedInternals.S;onStartTransitionFinish!==null&&onStartTransitionFinish(currentTransition,returnValue),typeof returnValue==`object`&&returnValue&&typeof returnValue.then==`function`&&returnValue.then(noop$22,reportGlobalError)}catch(error$21){reportGlobalError(error$21)}finally{ReactSharedInternals.T=prevTransition}},exports.unstable_useCacheRefresh=function(){return ReactSharedInternals.H.useCacheRefresh()},exports.use=function(usable){return ReactSharedInternals.H.use(usable)},exports.useActionState=function(action,initialState$1,permalink){return ReactSharedInternals.H.useActionState(action,initialState$1,permalink)},exports.useCallback=function(callback$1,deps){return ReactSharedInternals.H.useCallback(callback$1,deps)},exports.useContext=function(Context){return ReactSharedInternals.H.useContext(Context)},exports.useDebugValue=function(){},exports.useDeferredValue=function(value,initialValue){return ReactSharedInternals.H.useDeferredValue(value,initialValue)},exports.useEffect=function(create$4,createDeps,update){var dispatcher=ReactSharedInternals.H;if(typeof update==`function`)throw Error(`useEffect CRUD overload is not enabled in this build of React.`);return dispatcher.useEffect(create$4,createDeps)},exports.useId=function(){return ReactSharedInternals.H.useId()},exports.useImperativeHandle=function(ref,create$4,deps){return ReactSharedInternals.H.useImperativeHandle(ref,create$4,deps)},exports.useInsertionEffect=function(create$4,deps){return ReactSharedInternals.H.useInsertionEffect(create$4,deps)},exports.useLayoutEffect=function(create$4,deps){return ReactSharedInternals.H.useLayoutEffect(create$4,deps)},exports.useMemo=function(create$4,deps){return ReactSharedInternals.H.useMemo(create$4,deps)},exports.useOptimistic=function(passthrough,reducer){return ReactSharedInternals.H.useOptimistic(passthrough,reducer)},exports.useReducer=function(reducer,initialArg,init$4){return ReactSharedInternals.H.useReducer(reducer,initialArg,init$4)},exports.useRef=function(initialValue){return ReactSharedInternals.H.useRef(initialValue)},exports.useState=function(initialState$1){return ReactSharedInternals.H.useState(initialState$1)},exports.useSyncExternalStore=function(subscribe,getSnapshot,getServerSnapshot){return ReactSharedInternals.H.useSyncExternalStore(subscribe,getSnapshot,getServerSnapshot)},exports.useTransition=function(){return ReactSharedInternals.H.useTransition()},exports.version=`19.1.1`})),require_react_development=__commonJSMin(((exports,module)=>{process.env.NODE_ENV!==`production`&&(function(){function defineDeprecationWarning(methodName,info$1){Object.defineProperty(Component$1.prototype,methodName,{get:function(){console.warn(`%s(...) is deprecated in plain JavaScript React classes. %s`,info$1[0],info$1[1])}})}function getIteratorFn$1(maybeIterable){return typeof maybeIterable!=`object`||!maybeIterable?null:(maybeIterable=MAYBE_ITERATOR_SYMBOL$1&&maybeIterable[MAYBE_ITERATOR_SYMBOL$1]||maybeIterable[`@@iterator`],typeof maybeIterable==`function`?maybeIterable:null)}function warnNoop(publicInstance,callerName){publicInstance=(publicInstance=publicInstance.constructor)&&(publicInstance.displayName||publicInstance.name)||`ReactClass`;var warningKey=publicInstance+`.`+callerName;didWarnStateUpdateForUnmountedComponent[warningKey]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",callerName,publicInstance),didWarnStateUpdateForUnmountedComponent[warningKey]=!0)}function Component$1(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject$1,this.updater=updater||ReactNoopUpdateQueue$1}function ComponentDummy$1(){}function PureComponent$2(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject$1,this.updater=updater||ReactNoopUpdateQueue$1}function testStringCoercion(value){return``+value}function checkKeyStringCoercion(value){try{testStringCoercion(value);var JSCompiler_inline_result=!1}catch{JSCompiler_inline_result=!0}if(JSCompiler_inline_result){JSCompiler_inline_result=console;var JSCompiler_temp_const=JSCompiler_inline_result.error,JSCompiler_inline_result$jscomp$0=typeof Symbol==`function`&&Symbol.toStringTag&&value[Symbol.toStringTag]||value.constructor.name||`Object`;return JSCompiler_temp_const.call(JSCompiler_inline_result,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,JSCompiler_inline_result$jscomp$0),testStringCoercion(value)}}function getComponentNameFromType(type){if(type==null)return null;if(typeof type==`function`)return type.$$typeof===REACT_CLIENT_REFERENCE?null:type.displayName||type.name||null;if(typeof type==`string`)return type;switch(type){case REACT_FRAGMENT_TYPE$2:return`Fragment`;case REACT_PROFILER_TYPE$1:return`Profiler`;case REACT_STRICT_MODE_TYPE$1:return`StrictMode`;case REACT_SUSPENSE_TYPE$1:return`Suspense`;case REACT_SUSPENSE_LIST_TYPE:return`SuspenseList`;case REACT_ACTIVITY_TYPE:return`Activity`}if(typeof type==`object`)switch(typeof type.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),type.$$typeof){case REACT_PORTAL_TYPE$1:return`Portal`;case REACT_CONTEXT_TYPE$1:return(type.displayName||`Context`)+`.Provider`;case REACT_CONSUMER_TYPE$1:return(type._context.displayName||`Context`)+`.Consumer`;case REACT_FORWARD_REF_TYPE$1:var innerType=type.render;return type=type.displayName,type||=(type=innerType.displayName||innerType.name||``,type===``?`ForwardRef`:`ForwardRef(`+type+`)`),type;case REACT_MEMO_TYPE$1:return innerType=type.displayName||null,innerType===null?getComponentNameFromType(type.type)||`Memo`:innerType;case REACT_LAZY_TYPE$1:innerType=type._payload,type=type._init;try{return getComponentNameFromType(type(innerType))}catch{}}return null}function getTaskName(type){if(type===REACT_FRAGMENT_TYPE$2)return`<>`;if(typeof type==`object`&&type&&type.$$typeof===REACT_LAZY_TYPE$1)return`<...>`;try{var name$5=getComponentNameFromType(type);return name$5?`<`+name$5+`>`:`<...>`}catch{return`<...>`}}function getOwner(){var dispatcher=ReactSharedInternals$1.A;return dispatcher===null?null:dispatcher.getOwner()}function UnknownOwner(){return Error(`react-stack-top-frame`)}function hasValidKey(config){if(hasOwnProperty$2.call(config,`key`)){var getter=Object.getOwnPropertyDescriptor(config,`key`).get;if(getter&&getter.isReactWarning)return!1}return config.key!==void 0}function defineKeyPropWarningGetter(props,displayName){function warnAboutAccessingKey(){specialPropKeyWarningShown||(specialPropKeyWarningShown=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",displayName))}warnAboutAccessingKey.isReactWarning=!0,Object.defineProperty(props,`key`,{get:warnAboutAccessingKey,configurable:!0})}function elementRefGetterWithDeprecationWarning(){var componentName=getComponentNameFromType(this.type);return didWarnAboutElementRef[componentName]||(didWarnAboutElementRef[componentName]=!0,console.error(`Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.`)),componentName=this.props.ref,componentName===void 0?null:componentName}function ReactElement$1(type,key,self$1,source$39,owner,props,debugStack,debugTask){return self$1=props.ref,type={$$typeof:REACT_ELEMENT_TYPE$3,type,key,props,_owner:owner},(self$1===void 0?null:self$1)===null?Object.defineProperty(type,`ref`,{enumerable:!1,value:null}):Object.defineProperty(type,`ref`,{enumerable:!1,get:elementRefGetterWithDeprecationWarning}),type._store={},Object.defineProperty(type._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(type,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(type,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:debugStack}),Object.defineProperty(type,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:debugTask}),Object.freeze&&(Object.freeze(type.props),Object.freeze(type)),type}function cloneAndReplaceKey$1(oldElement,newKey){return newKey=ReactElement$1(oldElement.type,newKey,void 0,void 0,oldElement._owner,oldElement.props,oldElement._debugStack,oldElement._debugTask),oldElement._store&&(newKey._store.validated=oldElement._store.validated),newKey}function isValidElement$1(object$2){return typeof object$2==`object`&&!!object$2&&object$2.$$typeof===REACT_ELEMENT_TYPE$3}function escape$8(key){var escaperLookup={"=":`=0`,":":`=2`};return`$`+key.replace(/[=:]/g,function(match$1){return escaperLookup[match$1]})}function getElementKey$1(element,index){return typeof element==`object`&&element&&element.key!=null?(checkKeyStringCoercion(element.key),escape$8(``+element.key)):index.toString(36)}function noop$1$2(){}function resolveThenable$1(thenable){switch(thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason;default:switch(typeof thenable.status==`string`?thenable.then(noop$1$2,noop$1$2):(thenable.status=`pending`,thenable.then(function(fulfilledValue){thenable.status===`pending`&&(thenable.status=`fulfilled`,thenable.value=fulfilledValue)},function(error$21){thenable.status===`pending`&&(thenable.status=`rejected`,thenable.reason=error$21)})),thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason}}throw thenable}function mapIntoArray$1(children,array,escapedPrefix,nameSoFar,callback$1){var type=typeof children;(type===`undefined`||type===`boolean`)&&(children=null);var invokeCallback=!1;if(children===null)invokeCallback=!0;else switch(type){case`bigint`:case`string`:case`number`:invokeCallback=!0;break;case`object`:switch(children.$$typeof){case REACT_ELEMENT_TYPE$3:case REACT_PORTAL_TYPE$1:invokeCallback=!0;break;case REACT_LAZY_TYPE$1:return invokeCallback=children._init,mapIntoArray$1(invokeCallback(children._payload),array,escapedPrefix,nameSoFar,callback$1)}}if(invokeCallback){invokeCallback=children,callback$1=callback$1(invokeCallback);var childKey=nameSoFar===``?`.`+getElementKey$1(invokeCallback,0):nameSoFar;return isArrayImpl$1(callback$1)?(escapedPrefix=``,childKey!=null&&(escapedPrefix=childKey.replace(userProvidedKeyEscapeRegex$1,`$&/`)+`/`),mapIntoArray$1(callback$1,array,escapedPrefix,``,function(c$3){return c$3})):callback$1!=null&&(isValidElement$1(callback$1)&&(callback$1.key!=null&&(invokeCallback&&invokeCallback.key===callback$1.key||checkKeyStringCoercion(callback$1.key)),escapedPrefix=cloneAndReplaceKey$1(callback$1,escapedPrefix+(callback$1.key==null||invokeCallback&&invokeCallback.key===callback$1.key?``:(``+callback$1.key).replace(userProvidedKeyEscapeRegex$1,`$&/`)+`/`)+childKey),nameSoFar!==``&&invokeCallback!=null&&isValidElement$1(invokeCallback)&&invokeCallback.key==null&&invokeCallback._store&&!invokeCallback._store.validated&&(escapedPrefix._store.validated=2),callback$1=escapedPrefix),array.push(callback$1)),1}if(invokeCallback=0,childKey=nameSoFar===``?`.`:nameSoFar+`:`,isArrayImpl$1(children))for(var i$5=0;i$5<children.length;i$5++)nameSoFar=children[i$5],type=childKey+getElementKey$1(nameSoFar,i$5),invokeCallback+=mapIntoArray$1(nameSoFar,array,escapedPrefix,type,callback$1);else if(i$5=getIteratorFn$1(children),typeof i$5==`function`)for(i$5===children.entries&&(didWarnAboutMaps||console.warn(`Using Maps as children is not supported. Use an array of keyed ReactElements instead.`),didWarnAboutMaps=!0),children=i$5.call(children),i$5=0;!(nameSoFar=children.next()).done;)nameSoFar=nameSoFar.value,type=childKey+getElementKey$1(nameSoFar,i$5++),invokeCallback+=mapIntoArray$1(nameSoFar,array,escapedPrefix,type,callback$1);else if(type===`object`){if(typeof children.then==`function`)return mapIntoArray$1(resolveThenable$1(children),array,escapedPrefix,nameSoFar,callback$1);throw array=String(children),Error(`Objects are not valid as a React child (found: `+(array===`[object Object]`?`object with keys {`+Object.keys(children).join(`, `)+`}`:array)+`). If you meant to render a collection of children, use an array instead.`)}return invokeCallback}function mapChildren$1(children,func,context$1){if(children==null)return children;var result=[],count$1=0;return mapIntoArray$1(children,result,``,``,function(child){return func.call(context$1,child,count$1++)}),result}function lazyInitializer$1(payload){if(payload._status===-1){var ctor=payload._result;ctor=ctor(),ctor.then(function(moduleObject){(payload._status===0||payload._status===-1)&&(payload._status=1,payload._result=moduleObject)},function(error$21){(payload._status===0||payload._status===-1)&&(payload._status=2,payload._result=error$21)}),payload._status===-1&&(payload._status=0,payload._result=ctor)}if(payload._status===1)return ctor=payload._result,ctor===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
50
+ `),mime_type:`text/plain`,total_lines:allLines.length,lines_read:readLines.length,start_line:startLine}});break}case`write_file`:request$3.payload.base64?await fs$37.writeFile(request$3.payload.path,Buffer.from(request$3.payload.content,`base64`)):await fs$37.writeFile(request$3.payload.path,request$3.payload.content),typeof request$3.payload.mode==`number`&&await fs$37.chmod(request$3.payload.path,request$3.payload.mode),this.sendResponse(stream$10,{id:request$3.id,payload:{}});break;case`read_directory`:{let files=await fs$37.readdir(request$3.payload.path,{withFileTypes:!0});this.sendResponse(stream$10,{id:request$3.id,payload:{entries:files.map(file=>({name:file.name,type:file.isDirectory()?`directory`:file.isSymbolicLink()?`symlink`:`file`}))}});break}default:throw Error(`Unknown request type: ${request$3.type}`)}}sendResponse(stream$10,response){stream$10.writeTyped(ServerMessageType.RESPONSE,this.encoder.encode(JSON.stringify(response)))}sendNotification(notification){this.notificationStream.write(new Uint8Array([ServerMessageType.NOTIFICATION,...this.encoder.encode(JSON.stringify(notification))]))}handleProcessWait(stream$10,request$3,signal){let payload=request$3.payload,process$10=this.mustGetProcess(payload.pid),onOutput,onExit$1,ended=!1,outputIdleTimeout,timeout;typeof payload.timeout_ms==`number`&&(timeout=setTimeout(()=>{end()},payload.timeout_ms));let end=()=>{if(ended||(ended=!0,onOutput&&onOutput.dispose(),onExit$1&&onExit$1.dispose(),timeout&&clearTimeout(timeout),outputIdleTimeout&&clearTimeout(outputIdleTimeout),signal?.aborted))return;let status=this.processManager.status(payload.pid),plainOutput=this.processManager.readPlainOutput(status.pid),ansi_output_truncated=truncateAnsi(this.processManager.readANSIOutput(status.pid),64e3),plain_trunc=truncateLinesByChars(plainOutput.lines,256e3);this.sendResponse(stream$10,{id:request$3.id,payload:{...status,ansi_output:ansi_output_truncated,plain_output:{lines:plain_trunc.lines,total_lines:plainOutput.totalLines}}})};if(typeof process$10.exitCode==`number`||typeof process$10.exitSignal==`number`){end();return}onOutput=process$10.onOutput(()=>{outputIdleTimeout&&clearTimeout(outputIdleTimeout),typeof payload.output_idle_timeout_ms==`number`&&(outputIdleTimeout=setTimeout(()=>{end()},payload.output_idle_timeout_ms))}),onExit$1=process$10.onExit(()=>{setTimeout(()=>{end()},10)}),signal.addEventListener(`abort`,()=>{end()})}mustGetProcess(pid){let process$10=this.processManager.getProcess(pid);if(!process$10)throw Error(`Process ${pid} not found`);return process$10}};init_wrapper();const tempLogPath=path.join(os.tmpdir(),`blink-connect-${process.pid}.log`),serializeError=err$1=>{if(err$1 instanceof Error)return err$1.stack??err$1.message;try{return JSON.stringify(err$1)}catch{return String(err$1)}},appendLog=async message=>{let line$1=`${new Date().toISOString()} ${message}\n`;try{await fs.promises.appendFile(tempLogPath,line$1,`utf8`)}catch{}};async function connect(){let url$3=process.env.BLINK_URL,token$1=process.env.BLINK_TOKEN;delete process.env.BLINK_TOKEN,process.env.GIT_TERMINAL_PROMPT=`0`,process.env.GIT_PAGER=`cat`,process.env.GIT_AUTHOR_NAME=`blink-so[bot]`,process.env.GIT_AUTHOR_EMAIL=`211532188+blink-so[bot]@users.noreply.github.com`,process.env.GIT_COMMITTER_NAME=`blink-so[bot]`,process.env.GIT_COMMITTER_EMAIL=`211532188+blink-so[bot]@users.noreply.github.com`,process.env.GIT_CONFIG_COUNT=`1`,process.env.GIT_CONFIG_KEY_0=`credential.https://github.com.helper`,process.env.GIT_CONFIG_VALUE_0=`!gh auth git-credential`,process.addListener(`uncaughtException`,err$1=>{appendLog(`uncaughtException: ${serializeError(err$1)}`),reportException(token$1,err$1)}),process.addListener(`unhandledRejection`,err$1=>{appendLog(`unhandledRejection: ${serializeError(err$1)}`),reportException(token$1,err$1)});let srv=new WorkspaceConnect({url:url$3??`wss://blink.so/api/connect`,token:token$1,createDeploymentFromTar:async tar=>{let uploadURL=new URL(`/api/static-deployment`,url$3??`https://blink.so`),response=await fetch(uploadURL,{method:`POST`,body:tar,headers:{"Content-Type":`application/tar`,Authorization:`Bearer ${token$1}`},duplex:`half`}),data$2=await response.json();return data$2.deployment_id}});srv.onConnect(()=>{console.log(`Connected`),appendLog(`Connected`)}),srv.onDisconnect(()=>{console.log(`Disconnected`),appendLog(`Disconnected`)})}const reportException=async(token$1,err$1)=>{let url$3=new URL(`https://blink.so/api/connect-error`);await fetch(url$3.toString(),{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${token$1}`},body:JSON.stringify({error:err$1})})};var WorkspaceConnect=class{_onConnect=new Emitter;onConnect=this._onConnect.event;_onDisconnect=new Emitter;onDisconnect=this._onDisconnect.event;reconnectTimeout=null;disposed=!1;ws;server;hasReconnectedOnce=!1;constructor(opts){this.opts=opts,this.server=new Server$1({send:message=>{this.ws.readyState===wrapper_default.OPEN?this.ws.send(message):console.warn(`Message skipped because connection is closed.`)},createDeploymentFromTar:this.opts.createDeploymentFromTar}),this.connect()}dispose(){this.disposed||(this.disposed=!0,this.ws.close(),this.reconnectTimeout&&clearTimeout(this.reconnectTimeout))}scheduleReconnect(){if(this.disposed)return;let immediateFirst=this.opts.immediateReconnectFirst??!0,baseDelay=this.opts.reconnectionDelay??2500,delay$3=baseDelay;!this.hasReconnectedOnce&&immediateFirst&&(delay$3=0),this.hasReconnectedOnce=!0,this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.reconnectTimeout=setTimeout(()=>{this.connect()},delay$3)}connect(){let url$3=new URL(this.opts.url);url$3.protocol===`http:`?url$3.protocol=`ws:`:url$3.protocol===`https:`&&(url$3.protocol=`wss:`);let headers$2={};this.opts.token&&(headers$2.Authorization=`Bearer ${this.opts.token}`),this.ws=new wrapper_default(url$3.toString(),{headers:headers$2}),this.ws.addEventListener(`open`,()=>{this._onConnect.emit()}),this.ws.addEventListener(`close`,()=>{this._onDisconnect.emit(),!this.disposed&&this.scheduleReconnect()}),this.ws.addEventListener(`error`,event=>{console.error(`Error`,event.message??event)}),this.ws.addEventListener(`message`,event=>{if(typeof event.data==`string`){console.warn(`Message skipped because it is not a buffer.`);return}try{this.server.handleMessage(new Uint8Array(event.data))}catch(err$1){console.error(`message handler error`,err$1);try{this.ws.close(1011)}catch{}}})}};init_wrapper();async function chat(){let id=crypto.randomUUID(),ws$2=new import_websocket.default(`wss://blink.so/auth?id=${id}`),opened=new Promise((resolve$10,reject)=>{ws$2.onopen=()=>{resolve$10()},ws$2.onerror=event=>{reject(event)}});await opened;let tokenPromise=new Promise((resolve$10,reject)=>{ws$2.onmessage=event=>{resolve$10(event.data.toString())}}),url$3=`https://blink.so/auth?id=${id}&type=workspace`;console.log(`Opening the following URL in your browser: ${url$3}`),await open_default(url$3);let token$1=await tokenPromise,srv=new WorkspaceConnect({url:`wss://blink.so/api/connect`,token:token$1});srv.onConnect(()=>{console.log(`Connected to Blink`)}),srv.onDisconnect(()=>{console.log(`Disconnected from Blink`)})}var require_react_production=__commonJSMin((exports=>{var REACT_ELEMENT_TYPE$2=Symbol.for(`react.transitional.element`),REACT_PORTAL_TYPE=Symbol.for(`react.portal`),REACT_FRAGMENT_TYPE$1=Symbol.for(`react.fragment`),REACT_STRICT_MODE_TYPE=Symbol.for(`react.strict_mode`),REACT_PROFILER_TYPE=Symbol.for(`react.profiler`),REACT_CONSUMER_TYPE=Symbol.for(`react.consumer`),REACT_CONTEXT_TYPE=Symbol.for(`react.context`),REACT_FORWARD_REF_TYPE=Symbol.for(`react.forward_ref`),REACT_SUSPENSE_TYPE=Symbol.for(`react.suspense`),REACT_MEMO_TYPE=Symbol.for(`react.memo`),REACT_LAZY_TYPE=Symbol.for(`react.lazy`),MAYBE_ITERATOR_SYMBOL=Symbol.iterator;function getIteratorFn(maybeIterable){return typeof maybeIterable!=`object`||!maybeIterable?null:(maybeIterable=MAYBE_ITERATOR_SYMBOL&&maybeIterable[MAYBE_ITERATOR_SYMBOL]||maybeIterable[`@@iterator`],typeof maybeIterable==`function`?maybeIterable:null)}var ReactNoopUpdateQueue={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},assign=Object.assign,emptyObject={};function Component(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}Component.prototype.isReactComponent={},Component.prototype.setState=function(partialState,callback$1){if(typeof partialState!=`object`&&typeof partialState!=`function`&&partialState!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,partialState,callback$1,`setState`)},Component.prototype.forceUpdate=function(callback$1){this.updater.enqueueForceUpdate(this,callback$1,`forceUpdate`)};function ComponentDummy(){}ComponentDummy.prototype=Component.prototype;function PureComponent$1(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}var pureComponentPrototype=PureComponent$1.prototype=new ComponentDummy;pureComponentPrototype.constructor=PureComponent$1,assign(pureComponentPrototype,Component.prototype),pureComponentPrototype.isPureReactComponent=!0;var isArrayImpl=Array.isArray,ReactSharedInternals={H:null,A:null,T:null,S:null,V:null},hasOwnProperty$1=Object.prototype.hasOwnProperty;function ReactElement(type,key,self$1,source$39,owner,props){return self$1=props.ref,{$$typeof:REACT_ELEMENT_TYPE$2,type,key,ref:self$1===void 0?null:self$1,props}}function cloneAndReplaceKey(oldElement,newKey){return ReactElement(oldElement.type,newKey,void 0,void 0,void 0,oldElement.props)}function isValidElement(object$2){return typeof object$2==`object`&&!!object$2&&object$2.$$typeof===REACT_ELEMENT_TYPE$2}function escape$7(key){var escaperLookup={"=":`=0`,":":`=2`};return`$`+key.replace(/[=:]/g,function(match$1){return escaperLookup[match$1]})}var userProvidedKeyEscapeRegex=/\/+/g;function getElementKey(element,index){return typeof element==`object`&&element&&element.key!=null?escape$7(``+element.key):index.toString(36)}function noop$1$1(){}function resolveThenable(thenable){switch(thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason;default:switch(typeof thenable.status==`string`?thenable.then(noop$1$1,noop$1$1):(thenable.status=`pending`,thenable.then(function(fulfilledValue){thenable.status===`pending`&&(thenable.status=`fulfilled`,thenable.value=fulfilledValue)},function(error$21){thenable.status===`pending`&&(thenable.status=`rejected`,thenable.reason=error$21)})),thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason}}throw thenable}function mapIntoArray(children,array,escapedPrefix,nameSoFar,callback$1){var type=typeof children;(type===`undefined`||type===`boolean`)&&(children=null);var invokeCallback=!1;if(children===null)invokeCallback=!0;else switch(type){case`bigint`:case`string`:case`number`:invokeCallback=!0;break;case`object`:switch(children.$$typeof){case REACT_ELEMENT_TYPE$2:case REACT_PORTAL_TYPE:invokeCallback=!0;break;case REACT_LAZY_TYPE:return invokeCallback=children._init,mapIntoArray(invokeCallback(children._payload),array,escapedPrefix,nameSoFar,callback$1)}}if(invokeCallback)return callback$1=callback$1(children),invokeCallback=nameSoFar===``?`.`+getElementKey(children,0):nameSoFar,isArrayImpl(callback$1)?(escapedPrefix=``,invokeCallback!=null&&(escapedPrefix=invokeCallback.replace(userProvidedKeyEscapeRegex,`$&/`)+`/`),mapIntoArray(callback$1,array,escapedPrefix,``,function(c$3){return c$3})):callback$1!=null&&(isValidElement(callback$1)&&(callback$1=cloneAndReplaceKey(callback$1,escapedPrefix+(callback$1.key==null||children&&children.key===callback$1.key?``:(``+callback$1.key).replace(userProvidedKeyEscapeRegex,`$&/`)+`/`)+invokeCallback)),array.push(callback$1)),1;invokeCallback=0;var nextNamePrefix=nameSoFar===``?`.`:nameSoFar+`:`;if(isArrayImpl(children))for(var i$5=0;i$5<children.length;i$5++)nameSoFar=children[i$5],type=nextNamePrefix+getElementKey(nameSoFar,i$5),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback$1);else if(i$5=getIteratorFn(children),typeof i$5==`function`)for(children=i$5.call(children),i$5=0;!(nameSoFar=children.next()).done;)nameSoFar=nameSoFar.value,type=nextNamePrefix+getElementKey(nameSoFar,i$5++),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback$1);else if(type===`object`){if(typeof children.then==`function`)return mapIntoArray(resolveThenable(children),array,escapedPrefix,nameSoFar,callback$1);throw array=String(children),Error(`Objects are not valid as a React child (found: `+(array===`[object Object]`?`object with keys {`+Object.keys(children).join(`, `)+`}`:array)+`). If you meant to render a collection of children, use an array instead.`)}return invokeCallback}function mapChildren(children,func,context$1){if(children==null)return children;var result=[],count$1=0;return mapIntoArray(children,result,``,``,function(child){return func.call(context$1,child,count$1++)}),result}function lazyInitializer(payload){if(payload._status===-1){var ctor=payload._result;ctor=ctor(),ctor.then(function(moduleObject){(payload._status===0||payload._status===-1)&&(payload._status=1,payload._result=moduleObject)},function(error$21){(payload._status===0||payload._status===-1)&&(payload._status=2,payload._result=error$21)}),payload._status===-1&&(payload._status=0,payload._result=ctor)}if(payload._status===1)return payload._result.default;throw payload._result}var reportGlobalError=typeof reportError==`function`?reportError:function(error$21){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var event=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof error$21==`object`&&error$21&&typeof error$21.message==`string`?String(error$21.message):String(error$21),error:error$21});if(!window.dispatchEvent(event))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,error$21);return}console.error(error$21)};function noop$22(){}exports.Children={map:mapChildren,forEach:function(children,forEachFunc,forEachContext){mapChildren(children,function(){forEachFunc.apply(this,arguments)},forEachContext)},count:function(children){var n$2=0;return mapChildren(children,function(){n$2++}),n$2},toArray:function(children){return mapChildren(children,function(child){return child})||[]},only:function(children){if(!isValidElement(children))throw Error(`React.Children.only expected to receive a single React element child.`);return children}},exports.Component=Component,exports.Fragment=REACT_FRAGMENT_TYPE$1,exports.Profiler=REACT_PROFILER_TYPE,exports.PureComponent=PureComponent$1,exports.StrictMode=REACT_STRICT_MODE_TYPE,exports.Suspense=REACT_SUSPENSE_TYPE,exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ReactSharedInternals,exports.__COMPILER_RUNTIME={__proto__:null,c:function(size){return ReactSharedInternals.H.useMemoCache(size)}},exports.cache=function(fn){return function(){return fn.apply(null,arguments)}},exports.cloneElement=function(element,config,children){if(element==null)throw Error(`The argument must be a React element, but you passed `+element+`.`);var props=assign({},element.props),key=element.key,owner=void 0;if(config!=null)for(propName in config.ref!==void 0&&(owner=void 0),config.key!==void 0&&(key=``+config.key),config)!hasOwnProperty$1.call(config,propName)||propName===`key`||propName===`__self`||propName===`__source`||propName===`ref`&&config.ref===void 0||(props[propName]=config[propName]);var propName=arguments.length-2;if(propName===1)props.children=children;else if(1<propName){for(var childArray=Array(propName),i$5=0;i$5<propName;i$5++)childArray[i$5]=arguments[i$5+2];props.children=childArray}return ReactElement(element.type,key,void 0,void 0,owner,props)},exports.createContext=function(defaultValue){return defaultValue={$$typeof:REACT_CONTEXT_TYPE,_currentValue:defaultValue,_currentValue2:defaultValue,_threadCount:0,Provider:null,Consumer:null},defaultValue.Provider=defaultValue,defaultValue.Consumer={$$typeof:REACT_CONSUMER_TYPE,_context:defaultValue},defaultValue},exports.createElement=function(type,config,children){var propName,props={},key=null;if(config!=null)for(propName in config.key!==void 0&&(key=``+config.key),config)hasOwnProperty$1.call(config,propName)&&propName!==`key`&&propName!==`__self`&&propName!==`__source`&&(props[propName]=config[propName]);var childrenLength=arguments.length-2;if(childrenLength===1)props.children=children;else if(1<childrenLength){for(var childArray=Array(childrenLength),i$5=0;i$5<childrenLength;i$5++)childArray[i$5]=arguments[i$5+2];props.children=childArray}if(type&&type.defaultProps)for(propName in childrenLength=type.defaultProps,childrenLength)props[propName]===void 0&&(props[propName]=childrenLength[propName]);return ReactElement(type,key,void 0,void 0,null,props)},exports.createRef=function(){return{current:null}},exports.forwardRef=function(render$2){return{$$typeof:REACT_FORWARD_REF_TYPE,render:render$2}},exports.isValidElement=isValidElement,exports.lazy=function(ctor){return{$$typeof:REACT_LAZY_TYPE,_payload:{_status:-1,_result:ctor},_init:lazyInitializer}},exports.memo=function(type,compare$3){return{$$typeof:REACT_MEMO_TYPE,type,compare:compare$3===void 0?null:compare$3}},exports.startTransition=function(scope){var prevTransition=ReactSharedInternals.T,currentTransition={};ReactSharedInternals.T=currentTransition;try{var returnValue=scope(),onStartTransitionFinish=ReactSharedInternals.S;onStartTransitionFinish!==null&&onStartTransitionFinish(currentTransition,returnValue),typeof returnValue==`object`&&returnValue&&typeof returnValue.then==`function`&&returnValue.then(noop$22,reportGlobalError)}catch(error$21){reportGlobalError(error$21)}finally{ReactSharedInternals.T=prevTransition}},exports.unstable_useCacheRefresh=function(){return ReactSharedInternals.H.useCacheRefresh()},exports.use=function(usable){return ReactSharedInternals.H.use(usable)},exports.useActionState=function(action,initialState$1,permalink){return ReactSharedInternals.H.useActionState(action,initialState$1,permalink)},exports.useCallback=function(callback$1,deps){return ReactSharedInternals.H.useCallback(callback$1,deps)},exports.useContext=function(Context){return ReactSharedInternals.H.useContext(Context)},exports.useDebugValue=function(){},exports.useDeferredValue=function(value,initialValue){return ReactSharedInternals.H.useDeferredValue(value,initialValue)},exports.useEffect=function(create$4,createDeps,update){var dispatcher=ReactSharedInternals.H;if(typeof update==`function`)throw Error(`useEffect CRUD overload is not enabled in this build of React.`);return dispatcher.useEffect(create$4,createDeps)},exports.useId=function(){return ReactSharedInternals.H.useId()},exports.useImperativeHandle=function(ref,create$4,deps){return ReactSharedInternals.H.useImperativeHandle(ref,create$4,deps)},exports.useInsertionEffect=function(create$4,deps){return ReactSharedInternals.H.useInsertionEffect(create$4,deps)},exports.useLayoutEffect=function(create$4,deps){return ReactSharedInternals.H.useLayoutEffect(create$4,deps)},exports.useMemo=function(create$4,deps){return ReactSharedInternals.H.useMemo(create$4,deps)},exports.useOptimistic=function(passthrough,reducer){return ReactSharedInternals.H.useOptimistic(passthrough,reducer)},exports.useReducer=function(reducer,initialArg,init$4){return ReactSharedInternals.H.useReducer(reducer,initialArg,init$4)},exports.useRef=function(initialValue){return ReactSharedInternals.H.useRef(initialValue)},exports.useState=function(initialState$1){return ReactSharedInternals.H.useState(initialState$1)},exports.useSyncExternalStore=function(subscribe,getSnapshot,getServerSnapshot){return ReactSharedInternals.H.useSyncExternalStore(subscribe,getSnapshot,getServerSnapshot)},exports.useTransition=function(){return ReactSharedInternals.H.useTransition()},exports.version=`19.1.1`})),require_react_development=__commonJSMin(((exports,module)=>{process.env.NODE_ENV!==`production`&&(function(){function defineDeprecationWarning(methodName,info$1){Object.defineProperty(Component$1.prototype,methodName,{get:function(){console.warn(`%s(...) is deprecated in plain JavaScript React classes. %s`,info$1[0],info$1[1])}})}function getIteratorFn$1(maybeIterable){return typeof maybeIterable!=`object`||!maybeIterable?null:(maybeIterable=MAYBE_ITERATOR_SYMBOL$1&&maybeIterable[MAYBE_ITERATOR_SYMBOL$1]||maybeIterable[`@@iterator`],typeof maybeIterable==`function`?maybeIterable:null)}function warnNoop(publicInstance,callerName){publicInstance=(publicInstance=publicInstance.constructor)&&(publicInstance.displayName||publicInstance.name)||`ReactClass`;var warningKey=publicInstance+`.`+callerName;didWarnStateUpdateForUnmountedComponent[warningKey]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",callerName,publicInstance),didWarnStateUpdateForUnmountedComponent[warningKey]=!0)}function Component$1(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject$1,this.updater=updater||ReactNoopUpdateQueue$1}function ComponentDummy$1(){}function PureComponent$2(props,context$1,updater){this.props=props,this.context=context$1,this.refs=emptyObject$1,this.updater=updater||ReactNoopUpdateQueue$1}function testStringCoercion(value){return``+value}function checkKeyStringCoercion(value){try{testStringCoercion(value);var JSCompiler_inline_result=!1}catch{JSCompiler_inline_result=!0}if(JSCompiler_inline_result){JSCompiler_inline_result=console;var JSCompiler_temp_const=JSCompiler_inline_result.error,JSCompiler_inline_result$jscomp$0=typeof Symbol==`function`&&Symbol.toStringTag&&value[Symbol.toStringTag]||value.constructor.name||`Object`;return JSCompiler_temp_const.call(JSCompiler_inline_result,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,JSCompiler_inline_result$jscomp$0),testStringCoercion(value)}}function getComponentNameFromType(type){if(type==null)return null;if(typeof type==`function`)return type.$$typeof===REACT_CLIENT_REFERENCE?null:type.displayName||type.name||null;if(typeof type==`string`)return type;switch(type){case REACT_FRAGMENT_TYPE$2:return`Fragment`;case REACT_PROFILER_TYPE$1:return`Profiler`;case REACT_STRICT_MODE_TYPE$1:return`StrictMode`;case REACT_SUSPENSE_TYPE$1:return`Suspense`;case REACT_SUSPENSE_LIST_TYPE:return`SuspenseList`;case REACT_ACTIVITY_TYPE:return`Activity`}if(typeof type==`object`)switch(typeof type.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),type.$$typeof){case REACT_PORTAL_TYPE$1:return`Portal`;case REACT_CONTEXT_TYPE$1:return(type.displayName||`Context`)+`.Provider`;case REACT_CONSUMER_TYPE$1:return(type._context.displayName||`Context`)+`.Consumer`;case REACT_FORWARD_REF_TYPE$1:var innerType=type.render;return type=type.displayName,type||=(type=innerType.displayName||innerType.name||``,type===``?`ForwardRef`:`ForwardRef(`+type+`)`),type;case REACT_MEMO_TYPE$1:return innerType=type.displayName||null,innerType===null?getComponentNameFromType(type.type)||`Memo`:innerType;case REACT_LAZY_TYPE$1:innerType=type._payload,type=type._init;try{return getComponentNameFromType(type(innerType))}catch{}}return null}function getTaskName(type){if(type===REACT_FRAGMENT_TYPE$2)return`<>`;if(typeof type==`object`&&type&&type.$$typeof===REACT_LAZY_TYPE$1)return`<...>`;try{var name$5=getComponentNameFromType(type);return name$5?`<`+name$5+`>`:`<...>`}catch{return`<...>`}}function getOwner(){var dispatcher=ReactSharedInternals$1.A;return dispatcher===null?null:dispatcher.getOwner()}function UnknownOwner(){return Error(`react-stack-top-frame`)}function hasValidKey(config){if(hasOwnProperty$2.call(config,`key`)){var getter=Object.getOwnPropertyDescriptor(config,`key`).get;if(getter&&getter.isReactWarning)return!1}return config.key!==void 0}function defineKeyPropWarningGetter(props,displayName){function warnAboutAccessingKey(){specialPropKeyWarningShown||(specialPropKeyWarningShown=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",displayName))}warnAboutAccessingKey.isReactWarning=!0,Object.defineProperty(props,`key`,{get:warnAboutAccessingKey,configurable:!0})}function elementRefGetterWithDeprecationWarning(){var componentName=getComponentNameFromType(this.type);return didWarnAboutElementRef[componentName]||(didWarnAboutElementRef[componentName]=!0,console.error(`Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.`)),componentName=this.props.ref,componentName===void 0?null:componentName}function ReactElement$1(type,key,self$1,source$39,owner,props,debugStack,debugTask){return self$1=props.ref,type={$$typeof:REACT_ELEMENT_TYPE$3,type,key,props,_owner:owner},(self$1===void 0?null:self$1)===null?Object.defineProperty(type,`ref`,{enumerable:!1,value:null}):Object.defineProperty(type,`ref`,{enumerable:!1,get:elementRefGetterWithDeprecationWarning}),type._store={},Object.defineProperty(type._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(type,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(type,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:debugStack}),Object.defineProperty(type,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:debugTask}),Object.freeze&&(Object.freeze(type.props),Object.freeze(type)),type}function cloneAndReplaceKey$1(oldElement,newKey){return newKey=ReactElement$1(oldElement.type,newKey,void 0,void 0,oldElement._owner,oldElement.props,oldElement._debugStack,oldElement._debugTask),oldElement._store&&(newKey._store.validated=oldElement._store.validated),newKey}function isValidElement$1(object$2){return typeof object$2==`object`&&!!object$2&&object$2.$$typeof===REACT_ELEMENT_TYPE$3}function escape$8(key){var escaperLookup={"=":`=0`,":":`=2`};return`$`+key.replace(/[=:]/g,function(match$1){return escaperLookup[match$1]})}function getElementKey$1(element,index){return typeof element==`object`&&element&&element.key!=null?(checkKeyStringCoercion(element.key),escape$8(``+element.key)):index.toString(36)}function noop$1$2(){}function resolveThenable$1(thenable){switch(thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason;default:switch(typeof thenable.status==`string`?thenable.then(noop$1$2,noop$1$2):(thenable.status=`pending`,thenable.then(function(fulfilledValue){thenable.status===`pending`&&(thenable.status=`fulfilled`,thenable.value=fulfilledValue)},function(error$21){thenable.status===`pending`&&(thenable.status=`rejected`,thenable.reason=error$21)})),thenable.status){case`fulfilled`:return thenable.value;case`rejected`:throw thenable.reason}}throw thenable}function mapIntoArray$1(children,array,escapedPrefix,nameSoFar,callback$1){var type=typeof children;(type===`undefined`||type===`boolean`)&&(children=null);var invokeCallback=!1;if(children===null)invokeCallback=!0;else switch(type){case`bigint`:case`string`:case`number`:invokeCallback=!0;break;case`object`:switch(children.$$typeof){case REACT_ELEMENT_TYPE$3:case REACT_PORTAL_TYPE$1:invokeCallback=!0;break;case REACT_LAZY_TYPE$1:return invokeCallback=children._init,mapIntoArray$1(invokeCallback(children._payload),array,escapedPrefix,nameSoFar,callback$1)}}if(invokeCallback){invokeCallback=children,callback$1=callback$1(invokeCallback);var childKey=nameSoFar===``?`.`+getElementKey$1(invokeCallback,0):nameSoFar;return isArrayImpl$1(callback$1)?(escapedPrefix=``,childKey!=null&&(escapedPrefix=childKey.replace(userProvidedKeyEscapeRegex$1,`$&/`)+`/`),mapIntoArray$1(callback$1,array,escapedPrefix,``,function(c$3){return c$3})):callback$1!=null&&(isValidElement$1(callback$1)&&(callback$1.key!=null&&(invokeCallback&&invokeCallback.key===callback$1.key||checkKeyStringCoercion(callback$1.key)),escapedPrefix=cloneAndReplaceKey$1(callback$1,escapedPrefix+(callback$1.key==null||invokeCallback&&invokeCallback.key===callback$1.key?``:(``+callback$1.key).replace(userProvidedKeyEscapeRegex$1,`$&/`)+`/`)+childKey),nameSoFar!==``&&invokeCallback!=null&&isValidElement$1(invokeCallback)&&invokeCallback.key==null&&invokeCallback._store&&!invokeCallback._store.validated&&(escapedPrefix._store.validated=2),callback$1=escapedPrefix),array.push(callback$1)),1}if(invokeCallback=0,childKey=nameSoFar===``?`.`:nameSoFar+`:`,isArrayImpl$1(children))for(var i$5=0;i$5<children.length;i$5++)nameSoFar=children[i$5],type=childKey+getElementKey$1(nameSoFar,i$5),invokeCallback+=mapIntoArray$1(nameSoFar,array,escapedPrefix,type,callback$1);else if(i$5=getIteratorFn$1(children),typeof i$5==`function`)for(i$5===children.entries&&(didWarnAboutMaps||console.warn(`Using Maps as children is not supported. Use an array of keyed ReactElements instead.`),didWarnAboutMaps=!0),children=i$5.call(children),i$5=0;!(nameSoFar=children.next()).done;)nameSoFar=nameSoFar.value,type=childKey+getElementKey$1(nameSoFar,i$5++),invokeCallback+=mapIntoArray$1(nameSoFar,array,escapedPrefix,type,callback$1);else if(type===`object`){if(typeof children.then==`function`)return mapIntoArray$1(resolveThenable$1(children),array,escapedPrefix,nameSoFar,callback$1);throw array=String(children),Error(`Objects are not valid as a React child (found: `+(array===`[object Object]`?`object with keys {`+Object.keys(children).join(`, `)+`}`:array)+`). If you meant to render a collection of children, use an array instead.`)}return invokeCallback}function mapChildren$1(children,func,context$1){if(children==null)return children;var result=[],count$1=0;return mapIntoArray$1(children,result,``,``,function(child){return func.call(context$1,child,count$1++)}),result}function lazyInitializer$1(payload){if(payload._status===-1){var ctor=payload._result;ctor=ctor(),ctor.then(function(moduleObject){(payload._status===0||payload._status===-1)&&(payload._status=1,payload._result=moduleObject)},function(error$21){(payload._status===0||payload._status===-1)&&(payload._status=2,payload._result=error$21)}),payload._status===-1&&(payload._status=0,payload._result=ctor)}if(payload._status===1)return ctor=payload._result,ctor===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
51
51
 
52
52
  Your code should look like:
53
53
  const MyComponent = lazy(() => import('./MyComponent'))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blink",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Blink is a JavaScript runtime for building and deploying AI agents.",
5
5
  "type": "module",
6
6
  "bin": {
File without changes