velloo 0.3.1 → 0.4.1
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/canvas/assets/index-B1OD0Yz5.css +2 -0
- package/canvas/assets/index-BWYFx2Rr.js +29 -0
- package/canvas/assets/lucide-all-Bcm80WFX.js +1 -0
- package/canvas/index.html +2 -2
- package/{chunk-2zbn6641.js → chunk-00t0bz7x.js} +1 -1
- package/{chunk-4e9jh482.js → chunk-0446t32z.js} +1 -1
- package/{chunk-2fgfex9b.js → chunk-2dm4x17z.js} +1 -1
- package/{chunk-9cdwhrkh.js → chunk-2h24va0j.js} +1 -1
- package/{chunk-98vvrj0c.js → chunk-2jbhv7vh.js} +1 -1
- package/{chunk-3px2d1j1.js → chunk-2y9nnzpr.js} +1 -1
- package/chunk-5ywkk7d6.js +2 -0
- package/{chunk-as08hzp3.js → chunk-6zr596r2.js} +1 -1
- package/{chunk-nte0t7v3.js → chunk-7a45tn73.js} +1 -1
- package/{chunk-sn9vg42q.js → chunk-7gtvstne.js} +1 -1
- package/{chunk-whw3epmr.js → chunk-7xffbj5h.js} +1 -1
- package/{chunk-c6hywdvq.js → chunk-8t5phg0s.js} +1 -1
- package/{chunk-2p37rp3j.js → chunk-91pajfnm.js} +1 -1
- package/{chunk-c4fym47a.js → chunk-a9mgvspm.js} +1 -1
- package/{chunk-t947mxr1.js → chunk-aa3str7g.js} +1 -1
- package/chunk-b4jy4hcd.js +2 -0
- package/{chunk-mfbxfb9b.js → chunk-b58pnj20.js} +1 -1
- package/{chunk-nev5mv85.js → chunk-b7famda5.js} +1 -1
- package/{chunk-p62fygqz.js → chunk-cejmmx3r.js} +1 -1
- package/{chunk-t2w8a591.js → chunk-db7mf114.js} +1 -1
- package/{chunk-wafb2xm9.js → chunk-dj1pp4e3.js} +1 -1
- package/chunk-e6nhc3ay.js +6 -0
- package/{chunk-7yaafw73.js → chunk-f5g45xed.js} +1 -1
- package/{chunk-1xb88e07.js → chunk-hsrg23gd.js} +1 -1
- package/{chunk-mt8ds8zj.js → chunk-hv52a6hf.js} +1 -1
- package/{chunk-bhx8k09w.js → chunk-j5axqyan.js} +1 -1
- package/chunk-jep31ffe.js +2 -0
- package/{chunk-p6e1eg76.js → chunk-jwzhhhzn.js} +1 -1
- package/{chunk-wndntr7s.js → chunk-k3dpwjx4.js} +1 -1
- package/{chunk-z21hg6j3.js → chunk-km3z2czq.js} +1 -1
- package/chunk-m1wp8cpt.js +2 -0
- package/chunk-mcymwefw.js +5 -0
- package/{chunk-pve2mmnr.js → chunk-n0kx20s2.js} +1 -1
- package/{chunk-9p1dk5cb.js → chunk-npsg7btt.js} +1 -1
- package/{chunk-59zas5y2.js → chunk-nwf2kn41.js} +1 -1
- package/{chunk-t5m5mznb.js → chunk-ph94nrc8.js} +1 -1
- package/chunk-phz993p3.js +2 -0
- package/{chunk-4g250157.js → chunk-py6sjyzk.js} +1 -1
- package/{chunk-88eqqdk1.js → chunk-qan5dnjt.js} +12 -12
- package/{chunk-9ydc34wc.js → chunk-r03aywsb.js} +1 -1
- package/{chunk-wvs939t5.js → chunk-r5d0jsnd.js} +1 -1
- package/{chunk-js6mz7h1.js → chunk-r9ekd92e.js} +1 -1
- package/{chunk-ph2jfg1x.js → chunk-rfrbnw8r.js} +1 -1
- package/{chunk-4ma2wnqw.js → chunk-shac6bat.js} +1 -1
- package/{chunk-8z3ykvcs.js → chunk-t4zvcece.js} +1 -1
- package/{chunk-wp123630.js → chunk-t9ygewjx.js} +1 -1
- package/{chunk-tt7fys2w.js → chunk-tarws372.js} +1 -1
- package/chunk-tr49kraa.js +3 -0
- package/{chunk-avkfsc3p.js → chunk-vjrn10xr.js} +1 -1
- package/{chunk-g71v35gd.js → chunk-xbhxzdat.js} +1 -1
- package/chunk-yfttm20w.js +5 -0
- package/chunk-yghypth2.js +2 -0
- package/chunk-ykdx12na.js +4 -0
- package/{chunk-9psr8atb.js → chunk-zqtz23xk.js} +1 -1
- package/cli.js +1 -1
- package/package.json +1 -1
- package/pkgs/schema/src/comment.ts +12 -0
- package/pkgs/schema/src/index.ts +1 -0
- package/canvas/assets/index-DZFrkC4P.js +0 -29
- package/canvas/assets/index-gB0StCrx.css +0 -2
- package/canvas/assets/lucide-all-Bu8-9UDF.js +0 -1
- package/chunk-0s6drs3n.js +0 -2
- package/chunk-2e3nd4tz.js +0 -2
- package/chunk-5wv5a52y.js +0 -2
- package/chunk-6zz9kfbd.js +0 -3
- package/chunk-7cvhnp9h.js +0 -5
- package/chunk-7s8frnag.js +0 -2
- package/chunk-7t13w87m.js +0 -2
- package/chunk-asbajsmd.js +0 -5
- package/chunk-f0vsjfpc.js +0 -3
- package/chunk-hfzg98c8.js +0 -4
- package/chunk-n9t36h0q.js +0 -2
- package/chunk-wnwgqvtd.js +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{require_react_development}from"./chunk-
|
|
2
|
+
import{require_react_development}from"./chunk-a9mgvspm.js";import{__toESM,__commonJS}from"./chunk-2smsg2ct.js";var require_react_jsx_runtime_development=__commonJS(function(exports){var React=__toESM(require_react_development());(function(){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:return"Fragment";case REACT_PROFILER_TYPE:return"Profiler";case REACT_STRICT_MODE_TYPE:return"StrictMode";case REACT_SUSPENSE_TYPE: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:return"Portal";case REACT_CONTEXT_TYPE:return type.displayName||"Context";case REACT_CONSUMER_TYPE:return(type._context.displayName||"Context")+".Consumer";case REACT_FORWARD_REF_TYPE:var innerType=type.render;return type=type.displayName,type||(type=innerType.displayName||innerType.name||"",type=type!==""?"ForwardRef("+type+")":"ForwardRef"),type;case REACT_MEMO_TYPE:return innerType=type.displayName||null,innerType!==null?innerType:getComponentNameFromType(type.type)||"Memo";case REACT_LAZY_TYPE:innerType=type._payload,type=type._init;try{return getComponentNameFromType(type(innerType))}catch(x){}}return null}function testStringCoercion(value){return""+value}function checkKeyStringCoercion(value){try{testStringCoercion(value);var JSCompiler_inline_result=!1}catch(e){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 getTaskName(type){if(type===REACT_FRAGMENT_TYPE)return"<>";if(typeof type==="object"&&type!==null&&type.$$typeof===REACT_LAZY_TYPE)return"<...>";try{var name=getComponentNameFromType(type);return name?"<"+name+">":"<...>"}catch(x){return"<...>"}}function getOwner(){var dispatcher=ReactSharedInternals.A;return dispatcher===null?null:dispatcher.getOwner()}function UnknownOwner(){return Error("react-stack-top-frame")}function hasValidKey(config){if(hasOwnProperty.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?componentName:null}function ReactElement(type,key,props,owner,debugStack,debugTask){var refProp=props.ref;return type={$$typeof:REACT_ELEMENT_TYPE,type,key,props,_owner:owner},(refProp!==void 0?refProp:null)!==null?Object.defineProperty(type,"ref",{enumerable:!1,get:elementRefGetterWithDeprecationWarning}):Object.defineProperty(type,"ref",{enumerable:!1,value:null}),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 jsxDEVImpl(type,config,maybeKey,isStaticChildren,debugStack,debugTask){var children=config.children;if(children!==void 0)if(isStaticChildren)if(isArrayImpl(children)){for(isStaticChildren=0;isStaticChildren<children.length;isStaticChildren++)validateChildKeys(children[isStaticChildren]);Object.freeze&&Object.freeze(children)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else validateChildKeys(children);if(hasOwnProperty.call(config,"key")){children=getComponentNameFromType(type);var keys=Object.keys(config).filter(function(k){return k!=="key"});isStaticChildren=0<keys.length?"{key: someKey, "+keys.join(": ..., ")+": ...}":"{key: someKey}",didWarnAboutKeySpread[children+isStaticChildren]||(keys=0<keys.length?"{"+keys.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
3
3
|
let props = %s;
|
|
4
4
|
<%s {...props} />
|
|
5
5
|
React keys must be passed directly to JSX without using spread:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{isCancel,select}from"./chunk-80fjfyha.js";import{preflightScreens}from"./chunk-
|
|
2
|
+
import{isCancel,select}from"./chunk-80fjfyha.js";import{preflightScreens}from"./chunk-qan5dnjt.js";import{fail}from"./chunk-s23gtejf.js";import{copyToClipboard}from"./chunk-vbk1qhdz.js";import{require_picocolors}from"./chunk-jrsknzjt.js";import{__toESM}from"./chunk-2smsg2ct.js";import{stripVTControlCharacters}from"util";var import_picocolors=__toESM(require_picocolors(),1);function plural(count,noun){return`${count} ${noun}${count===1?"":"s"}`}function formatFailures(command,failures){let byScreen=new Map;for(let failure of failures)byScreen.set(failure.screenId,[...byScreen.get(failure.screenId)??[],failure]);let notDrawn=[...byScreen.values()].filter((group)=>group.some((failure)=>failure.componentId===null)),placeholders=[...byScreen.values()].filter((group)=>!notDrawn.includes(group)).reduce((sum,group)=>sum+group.length,0),consequences=[placeholders>0&&`${plural(placeholders,"component")} will appear as placeholders`,notDrawn.length>0&&`${plural(notDrawn.length,"screen")} will not render at all`].filter(Boolean),lines=[`${import_picocolors.default.yellow(`velloo ${command}:`)} render failures on ${plural(byScreen.size,"screen")} \u2014 ${consequences.join(", and ")}:`];for(let group of byScreen.values()){let[first]=group;if(!first)continue;let boards=first.boards.length>0?first.boards.map((board)=>board.name).join(", "):"no board";lines.push("",` ${import_picocolors.default.dim(`${boards} \u203A`)} ${import_picocolors.default.bold(first.screenName)} ${import_picocolors.default.dim(`(${first.screenId})`)}`);let pinned=group.some((failure)=>failure.componentId!==null);for(let failure of group)if(failure.componentId!==null)lines.push(` ${import_picocolors.default.cyan(failure.componentId)}: ${failure.reason}`);else{let label=pinned?"screen not drawn":"screen not drawn \u2014 the error could not be pinned on one component";lines.push(` ${import_picocolors.default.red(label)}: ${failure.reason}`)}}return lines}async function confirmRenderFailures(command,source,screens,yes){let failures=preflightScreens(source,screens);if(failures.length===0)return;let report=formatFailures(command,failures);for(let line of report)console.error(line);if(console.error(""),yes)return;if(!process.stdin.isTTY)fail(command,"refusing to continue \u2014 re-run with --yes to accept the placeholders.");for(;;){let choice=await select({message:"Continue anyway?",options:[{value:"cancel",label:"No, cancel"},{value:"continue",label:"Yes, continue with the failures"},{value:"copy",label:"Copy errors to clipboard"}],initialValue:"cancel"});if(isCancel(choice)||choice==="cancel")fail(command,"cancelled.");if(choice==="continue")return;let copied=await copyToClipboard(stripVTControlCharacters(report.join(`
|
|
3
3
|
`)));console.error(copied?` ${import_picocolors.default.green("\u2713")} Errors copied to the clipboard.`:import_picocolors.default.dim(" Couldn't reach a clipboard tool \u2014 copy the errors printed above."))}}
|
|
4
4
|
export{confirmRenderFailures};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{isCssIdent,sanitizeCssTokenValue,neutralizeCssText,sanitizeGoogleFontSpec,isComponentNode,isSnippetInstance,isParamRef,isRepoNode,repoKey,ScreenSchema,resolveSnippetArgs,substituteSnippetParams,applySnippetOverrides,applySnippetExtraClassName,ThemeSchema,typesetCss}from"./chunk-nte0t7v3.js";import{__toESM,__commonJS,__exportCjs,__require}from"./chunk-2smsg2ct.js";var require_chunkstream=__commonJS(function(exports,module){var util=__require("util"),Stream=__require("stream"),ChunkStream=module.exports=function(){Stream.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};util.inherits(ChunkStream,Stream);ChunkStream.prototype.read=function(length,callback){this._reads.push({length:Math.abs(length),allowLess:length<0,func:callback}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};ChunkStream.prototype.write=function(data,encoding){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let dataBuffer;if(Buffer.isBuffer(data))dataBuffer=data;else dataBuffer=Buffer.from(data,encoding||this._encoding);if(this._buffers.push(dataBuffer),this._buffered+=dataBuffer.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};ChunkStream.prototype.end=function(data,encoding){if(data)this.write(data,encoding);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};ChunkStream.prototype.destroySoon=ChunkStream.prototype.end;ChunkStream.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};ChunkStream.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};ChunkStream.prototype._processReadAllowingLess=function(read){this._reads.shift();let smallerBuf=this._buffers[0];if(smallerBuf.length>read.length)this._buffered-=read.length,this._buffers[0]=smallerBuf.slice(read.length),read.func.call(this,smallerBuf.slice(0,read.length));else this._buffered-=smallerBuf.length,this._buffers.shift(),read.func.call(this,smallerBuf)};ChunkStream.prototype._processRead=function(read){this._reads.shift();let pos=0,count=0,data=Buffer.alloc(read.length);while(pos<read.length){let buf=this._buffers[count++],len=Math.min(buf.length,read.length-pos);if(buf.copy(data,pos,0,len),pos+=len,len!==buf.length)this._buffers[--count]=buf.slice(len)}if(count>0)this._buffers.splice(0,count);this._buffered-=read.length,read.func.call(this,data)};ChunkStream.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let read=this._reads[0];if(read.allowLess)this._processReadAllowingLess(read);else if(this._buffered>=read.length)this._processRead(read);else break}if(this._buffers&&!this.writable)this._end()}catch(ex){this.emit("error",ex)}}});var require_interlace=__commonJS(function(exports){var imagePasses=[{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]}];exports.getImagePasses=function(width,height){let images=[],xLeftOver=width%8,yLeftOver=height%8,xRepeats=(width-xLeftOver)/8,yRepeats=(height-yLeftOver)/8;for(let i=0;i<imagePasses.length;i++){let pass=imagePasses[i],passWidth=xRepeats*pass.x.length,passHeight=yRepeats*pass.y.length;for(let j=0;j<pass.x.length;j++)if(pass.x[j]<xLeftOver)passWidth++;else break;for(let j=0;j<pass.y.length;j++)if(pass.y[j]<yLeftOver)passHeight++;else break;if(passWidth>0&&passHeight>0)images.push({width:passWidth,height:passHeight,index:i})}return images};exports.getInterlaceIterator=function(width){return function(x,y,pass){let outerXLeftOver=x%imagePasses[pass].x.length,outerX=(x-outerXLeftOver)/imagePasses[pass].x.length*8+imagePasses[pass].x[outerXLeftOver],outerYLeftOver=y%imagePasses[pass].y.length,outerY=(y-outerYLeftOver)/imagePasses[pass].y.length*8+imagePasses[pass].y[outerYLeftOver];return outerX*4+outerY*width*4}}});var require_paeth_predictor=__commonJS(function(exports,module){module.exports=function(left,above,upLeft){let paeth=left+above-upLeft,pLeft=Math.abs(paeth-left),pAbove=Math.abs(paeth-above),pUpLeft=Math.abs(paeth-upLeft);if(pLeft<=pAbove&&pLeft<=pUpLeft)return left;if(pAbove<=pUpLeft)return above;return upLeft}});var require_filter_parse=__commonJS(function(exports,module){var interlaceUtils=require_interlace(),paethPredictor=require_paeth_predictor();function getByteWidth(width,bpp,depth){let byteWidth=width*bpp;if(depth!==8)byteWidth=Math.ceil(byteWidth/(8/depth));return byteWidth}var Filter=module.exports=function(bitmapInfo,dependencies){let{width,height,interlace,bpp,depth}=bitmapInfo;if(this.read=dependencies.read,this.write=dependencies.write,this.complete=dependencies.complete,this._imageIndex=0,this._images=[],interlace){let passes=interlaceUtils.getImagePasses(width,height);for(let i=0;i<passes.length;i++)this._images.push({byteWidth:getByteWidth(passes[i].width,bpp,depth),height:passes[i].height,lineIndex:0})}else this._images.push({byteWidth:getByteWidth(width,bpp,depth),height,lineIndex:0});if(depth===8)this._xComparison=bpp;else if(depth===16)this._xComparison=bpp*2;else this._xComparison=1};Filter.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};Filter.prototype._unFilterType1=function(rawData,unfilteredLine,byteWidth){let xComparison=this._xComparison,xBiggerThan=xComparison-1;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f1Left=x>xBiggerThan?unfilteredLine[x-xComparison]:0;unfilteredLine[x]=rawByte+f1Left}};Filter.prototype._unFilterType2=function(rawData,unfilteredLine,byteWidth){let lastLine=this._lastLine;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f2Up=lastLine?lastLine[x]:0;unfilteredLine[x]=rawByte+f2Up}};Filter.prototype._unFilterType3=function(rawData,unfilteredLine,byteWidth){let xComparison=this._xComparison,xBiggerThan=xComparison-1,lastLine=this._lastLine;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f3Up=lastLine?lastLine[x]:0,f3Left=x>xBiggerThan?unfilteredLine[x-xComparison]:0,f3Add=Math.floor((f3Left+f3Up)/2);unfilteredLine[x]=rawByte+f3Add}};Filter.prototype._unFilterType4=function(rawData,unfilteredLine,byteWidth){let xComparison=this._xComparison,xBiggerThan=xComparison-1,lastLine=this._lastLine;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f4Up=lastLine?lastLine[x]:0,f4Left=x>xBiggerThan?unfilteredLine[x-xComparison]:0,f4UpLeft=x>xBiggerThan&&lastLine?lastLine[x-xComparison]:0,f4Add=paethPredictor(f4Left,f4Up,f4UpLeft);unfilteredLine[x]=rawByte+f4Add}};Filter.prototype._reverseFilterLine=function(rawData){let filter=rawData[0],unfilteredLine,currentImage=this._images[this._imageIndex],byteWidth=currentImage.byteWidth;if(filter===0)unfilteredLine=rawData.slice(1,byteWidth+1);else switch(unfilteredLine=Buffer.alloc(byteWidth),filter){case 1:this._unFilterType1(rawData,unfilteredLine,byteWidth);break;case 2:this._unFilterType2(rawData,unfilteredLine,byteWidth);break;case 3:this._unFilterType3(rawData,unfilteredLine,byteWidth);break;case 4:this._unFilterType4(rawData,unfilteredLine,byteWidth);break;default:throw Error("Unrecognised filter type - "+filter)}if(this.write(unfilteredLine),currentImage.lineIndex++,currentImage.lineIndex>=currentImage.height)this._lastLine=null,this._imageIndex++,currentImage=this._images[this._imageIndex];else this._lastLine=unfilteredLine;if(currentImage)this.read(currentImage.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var require_filter_parse_async=__commonJS(function(exports,module){var util=__require("util"),ChunkStream=require_chunkstream(),Filter=require_filter_parse(),FilterAsync=module.exports=function(bitmapInfo){ChunkStream.call(this);let buffers=[],that=this;this._filter=new Filter(bitmapInfo,{read:this.read.bind(this),write:function(buffer){buffers.push(buffer)},complete:function(){that.emit("complete",Buffer.concat(buffers))}}),this._filter.start()};util.inherits(FilterAsync,ChunkStream)});var require_constants=__commonJS(function(exports,module){module.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 require_crc=__commonJS(function(exports,module){var crcTable=[];(function(){for(let i=0;i<256;i++){let currentCrc=i;for(let j=0;j<8;j++)if(currentCrc&1)currentCrc=3988292384^currentCrc>>>1;else currentCrc=currentCrc>>>1;crcTable[i]=currentCrc}})();var CrcCalculator=module.exports=function(){this._crc=-1};CrcCalculator.prototype.write=function(data){for(let i=0;i<data.length;i++)this._crc=crcTable[(this._crc^data[i])&255]^this._crc>>>8;return!0};CrcCalculator.prototype.crc32=function(){return this._crc^-1};CrcCalculator.crc32=function(buf){let crc=-1;for(let i=0;i<buf.length;i++)crc=crcTable[(crc^buf[i])&255]^crc>>>8;return crc^-1}});var require_parser=__commonJS(function(exports,module){var constants=require_constants(),CrcCalculator=require_crc(),Parser=module.exports=function(options,dependencies){this._options=options,options.checkCRC=options.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[constants.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[constants.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[constants.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[constants.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[constants.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[constants.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=dependencies.read,this.error=dependencies.error,this.metadata=dependencies.metadata,this.gamma=dependencies.gamma,this.transColor=dependencies.transColor,this.palette=dependencies.palette,this.parsed=dependencies.parsed,this.inflateData=dependencies.inflateData,this.finished=dependencies.finished,this.simpleTransparency=dependencies.simpleTransparency,this.headersFinished=dependencies.headersFinished||function(){}};Parser.prototype.start=function(){this.read(constants.PNG_SIGNATURE.length,this._parseSignature.bind(this))};Parser.prototype._parseSignature=function(data){let signature=constants.PNG_SIGNATURE;for(let i=0;i<signature.length;i++)if(data[i]!==signature[i]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};Parser.prototype._parseChunkBegin=function(data){let length=data.readUInt32BE(0),type=data.readUInt32BE(4),name="";for(let i=4;i<8;i++)name+=String.fromCharCode(data[i]);let ancillary=Boolean(data[4]&32);if(!this._hasIHDR&&type!==constants.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new CrcCalculator,this._crc.write(Buffer.from(name)),this._chunks[type])return this._chunks[type](length);if(!ancillary){this.error(Error("Unsupported critical chunk type "+name));return}this.read(length+4,this._skipChunk.bind(this))};Parser.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};Parser.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};Parser.prototype._parseChunkEnd=function(data){let fileCrc=data.readInt32BE(0),calcCrc=this._crc.crc32();if(this._options.checkCRC&&calcCrc!==fileCrc){this.error(Error("Crc error - "+fileCrc+" - "+calcCrc));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};Parser.prototype._handleIHDR=function(length){this.read(length,this._parseIHDR.bind(this))};Parser.prototype._parseIHDR=function(data){this._crc.write(data);let width=data.readUInt32BE(0),height=data.readUInt32BE(4),depth=data[8],colorType=data[9],compr=data[10],filter=data[11],interlace=data[12];if(depth!==8&&depth!==4&&depth!==2&&depth!==1&&depth!==16){this.error(Error("Unsupported bit depth "+depth));return}if(!(colorType in constants.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(compr!==0){this.error(Error("Unsupported compression method"));return}if(filter!==0){this.error(Error("Unsupported filter method"));return}if(interlace!==0&&interlace!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=colorType;let bpp=constants.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width,height,depth,interlace:Boolean(interlace),palette:Boolean(colorType&constants.COLORTYPE_PALETTE),color:Boolean(colorType&constants.COLORTYPE_COLOR),alpha:Boolean(colorType&constants.COLORTYPE_ALPHA),bpp,colorType}),this._handleChunkEnd()};Parser.prototype._handlePLTE=function(length){this.read(length,this._parsePLTE.bind(this))};Parser.prototype._parsePLTE=function(data){this._crc.write(data);let entries=Math.floor(data.length/3);for(let i=0;i<entries;i++)this._palette.push([data[i*3],data[i*3+1],data[i*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};Parser.prototype._handleTRNS=function(length){this.simpleTransparency(),this.read(length,this._parseTRNS.bind(this))};Parser.prototype._parseTRNS=function(data){if(this._crc.write(data),this._colorType===constants.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(data.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let i=0;i<data.length;i++)this._palette[i][3]=data[i];this.palette(this._palette)}if(this._colorType===constants.COLORTYPE_GRAYSCALE)this.transColor([data.readUInt16BE(0)]);if(this._colorType===constants.COLORTYPE_COLOR)this.transColor([data.readUInt16BE(0),data.readUInt16BE(2),data.readUInt16BE(4)]);this._handleChunkEnd()};Parser.prototype._handleGAMA=function(length){this.read(length,this._parseGAMA.bind(this))};Parser.prototype._parseGAMA=function(data){this._crc.write(data),this.gamma(data.readUInt32BE(0)/constants.GAMMA_DIVISION),this._handleChunkEnd()};Parser.prototype._handleIDAT=function(length){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-length,this._parseIDAT.bind(this,length))};Parser.prototype._parseIDAT=function(length,data){if(this._crc.write(data),this._colorType===constants.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(data);let leftOverLength=length-data.length;if(leftOverLength>0)this._handleIDAT(leftOverLength);else this._handleChunkEnd()};Parser.prototype._handleIEND=function(length){this.read(length,this._parseIEND.bind(this))};Parser.prototype._parseIEND=function(data){if(this._crc.write(data),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var require_bitmapper=__commonJS(function(exports){var interlaceUtils=require_interlace(),pixelBppMapper=[function(){},function(pxData,data,pxPos,rawPos){if(rawPos===data.length)throw Error("Ran out of data");let pixel=data[rawPos];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=255},function(pxData,data,pxPos,rawPos){if(rawPos+1>=data.length)throw Error("Ran out of data");let pixel=data[rawPos];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=data[rawPos+1]},function(pxData,data,pxPos,rawPos){if(rawPos+2>=data.length)throw Error("Ran out of data");pxData[pxPos]=data[rawPos],pxData[pxPos+1]=data[rawPos+1],pxData[pxPos+2]=data[rawPos+2],pxData[pxPos+3]=255},function(pxData,data,pxPos,rawPos){if(rawPos+3>=data.length)throw Error("Ran out of data");pxData[pxPos]=data[rawPos],pxData[pxPos+1]=data[rawPos+1],pxData[pxPos+2]=data[rawPos+2],pxData[pxPos+3]=data[rawPos+3]}],pixelBppCustomMapper=[function(){},function(pxData,pixelData,pxPos,maxBit){let pixel=pixelData[0];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=maxBit},function(pxData,pixelData,pxPos){let pixel=pixelData[0];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=pixelData[1]},function(pxData,pixelData,pxPos,maxBit){pxData[pxPos]=pixelData[0],pxData[pxPos+1]=pixelData[1],pxData[pxPos+2]=pixelData[2],pxData[pxPos+3]=maxBit},function(pxData,pixelData,pxPos){pxData[pxPos]=pixelData[0],pxData[pxPos+1]=pixelData[1],pxData[pxPos+2]=pixelData[2],pxData[pxPos+3]=pixelData[3]}];function bitRetriever(data,depth){let leftOver=[],i=0;function split(){if(i===data.length)throw Error("Ran out of data");let byte=data[i];i++;let byte8,byte7,byte6,byte5,byte4,byte3,byte2,byte1;switch(depth){default:throw Error("unrecognised depth");case 16:byte2=data[i],i++,leftOver.push((byte<<8)+byte2);break;case 4:byte2=byte&15,byte1=byte>>4,leftOver.push(byte1,byte2);break;case 2:byte4=byte&3,byte3=byte>>2&3,byte2=byte>>4&3,byte1=byte>>6&3,leftOver.push(byte1,byte2,byte3,byte4);break;case 1:byte8=byte&1,byte7=byte>>1&1,byte6=byte>>2&1,byte5=byte>>3&1,byte4=byte>>4&1,byte3=byte>>5&1,byte2=byte>>6&1,byte1=byte>>7&1,leftOver.push(byte1,byte2,byte3,byte4,byte5,byte6,byte7,byte8);break}}return{get:function(count){while(leftOver.length<count)split();let returner=leftOver.slice(0,count);return leftOver=leftOver.slice(count),returner},resetAfterLine:function(){leftOver.length=0},end:function(){if(i!==data.length)throw Error("extra data found")}}}function mapImage8Bit(image,pxData,getPxPos,bpp,data,rawPos){let{width:imageWidth,height:imageHeight,index:imagePass}=image;for(let y=0;y<imageHeight;y++)for(let x=0;x<imageWidth;x++){let pxPos=getPxPos(x,y,imagePass);pixelBppMapper[bpp](pxData,data,pxPos,rawPos),rawPos+=bpp}return rawPos}function mapImageCustomBit(image,pxData,getPxPos,bpp,bits,maxBit){let{width:imageWidth,height:imageHeight,index:imagePass}=image;for(let y=0;y<imageHeight;y++){for(let x=0;x<imageWidth;x++){let pixelData=bits.get(bpp),pxPos=getPxPos(x,y,imagePass);pixelBppCustomMapper[bpp](pxData,pixelData,pxPos,maxBit)}bits.resetAfterLine()}}exports.dataToBitMap=function(data,bitmapInfo){let{width,height,depth,bpp,interlace}=bitmapInfo,bits;if(depth!==8)bits=bitRetriever(data,depth);let pxData;if(depth<=8)pxData=Buffer.alloc(width*height*4);else pxData=new Uint16Array(width*height*4);let maxBit=Math.pow(2,depth)-1,rawPos=0,images,getPxPos;if(interlace)images=interlaceUtils.getImagePasses(width,height),getPxPos=interlaceUtils.getInterlaceIterator(width,height);else{let nonInterlacedPxPos=0;getPxPos=function(){let returner=nonInterlacedPxPos;return nonInterlacedPxPos+=4,returner},images=[{width,height}]}for(let imageIndex=0;imageIndex<images.length;imageIndex++)if(depth===8)rawPos=mapImage8Bit(images[imageIndex],pxData,getPxPos,bpp,data,rawPos);else mapImageCustomBit(images[imageIndex],pxData,getPxPos,bpp,bits,maxBit);if(depth===8){if(rawPos!==data.length)throw Error("extra data found")}else bits.end();return pxData}});var require_format_normaliser=__commonJS(function(exports,module){function dePalette(indata,outdata,width,height,palette){let pxPos=0;for(let y=0;y<height;y++)for(let x=0;x<width;x++){let color=palette[indata[pxPos]];if(!color)throw Error("index "+indata[pxPos]+" not in palette");for(let i=0;i<4;i++)outdata[pxPos+i]=color[i];pxPos+=4}}function replaceTransparentColor(indata,outdata,width,height,transColor){let pxPos=0;for(let y=0;y<height;y++)for(let x=0;x<width;x++){let makeTrans=!1;if(transColor.length===1){if(transColor[0]===indata[pxPos])makeTrans=!0}else if(transColor[0]===indata[pxPos]&&transColor[1]===indata[pxPos+1]&&transColor[2]===indata[pxPos+2])makeTrans=!0;if(makeTrans)for(let i=0;i<4;i++)outdata[pxPos+i]=0;pxPos+=4}}function scaleDepth(indata,outdata,width,height,depth){let maxOutSample=255,maxInSample=Math.pow(2,depth)-1,pxPos=0;for(let y=0;y<height;y++)for(let x=0;x<width;x++){for(let i=0;i<4;i++)outdata[pxPos+i]=Math.floor(indata[pxPos+i]*maxOutSample/maxInSample+0.5);pxPos+=4}}module.exports=function(indata,imageData,skipRescale=!1){let{depth,width,height,colorType,transColor,palette}=imageData,outdata=indata;if(colorType===3)dePalette(indata,outdata,width,height,palette);else{if(transColor)replaceTransparentColor(indata,outdata,width,height,transColor);if(depth!==8&&!skipRescale){if(depth===16)outdata=Buffer.alloc(width*height*4);scaleDepth(indata,outdata,width,height,depth)}}return outdata}});var require_parser_async=__commonJS(function(exports,module){var util=__require("util"),zlib=__require("zlib"),ChunkStream=require_chunkstream(),FilterAsync=require_filter_parse_async(),Parser=require_parser(),bitmapper=require_bitmapper(),formatNormaliser=require_format_normaliser(),ParserAsync=module.exports=function(options){ChunkStream.call(this),this._parser=new Parser(options,{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=options,this.writable=!0,this._parser.start()};util.inherits(ParserAsync,ChunkStream);ParserAsync.prototype._handleError=function(err){if(this.emit("error",err),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};ParserAsync.prototype._inflateData=function(data){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=zlib.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 imageSize=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,chunkSize=Math.max(imageSize,zlib.Z_MIN_CHUNK);this._inflate=zlib.createInflate({chunkSize});let leftToInflate=imageSize,emitError=this.emit.bind(this,"error");this._inflate.on("error",function(err){if(!leftToInflate)return;emitError(err)}),this._filter.on("complete",this._complete.bind(this));let filterWrite=this._filter.write.bind(this._filter);this._inflate.on("data",function(chunk){if(!leftToInflate)return;if(chunk.length>leftToInflate)chunk=chunk.slice(0,leftToInflate);leftToInflate-=chunk.length,filterWrite(chunk)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(data)};ParserAsync.prototype._handleMetaData=function(metaData){this._metaData=metaData,this._bitmapInfo=Object.create(metaData),this._filter=new FilterAsync(this._bitmapInfo)};ParserAsync.prototype._handleTransColor=function(transColor){this._bitmapInfo.transColor=transColor};ParserAsync.prototype._handlePalette=function(palette){this._bitmapInfo.palette=palette};ParserAsync.prototype._simpleTransparency=function(){this._metaData.alpha=!0};ParserAsync.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};ParserAsync.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};ParserAsync.prototype._complete=function(filteredData){if(this.errord)return;let normalisedBitmapData;try{let bitmapData=bitmapper.dataToBitMap(filteredData,this._bitmapInfo);normalisedBitmapData=formatNormaliser(bitmapData,this._bitmapInfo,this._options.skipRescale),bitmapData=null}catch(ex){this._handleError(ex);return}this.emit("parsed",normalisedBitmapData)}});var require_bitpacker=__commonJS(function(exports,module){var constants=require_constants();module.exports=function(dataIn,width,height,options){let outHasAlpha=[constants.COLORTYPE_COLOR_ALPHA,constants.COLORTYPE_ALPHA].indexOf(options.colorType)!==-1;if(options.colorType===options.inputColorType){let bigEndian=function(){let buffer=new ArrayBuffer(2);return new DataView(buffer).setInt16(0,256,!0),new Int16Array(buffer)[0]!==256}();if(options.bitDepth===8||options.bitDepth===16&&bigEndian)return dataIn}let data=options.bitDepth!==16?dataIn:new Uint16Array(dataIn.buffer),maxValue=255,inBpp=constants.COLORTYPE_TO_BPP_MAP[options.inputColorType];if(inBpp===4&&!options.inputHasAlpha)inBpp=3;let outBpp=constants.COLORTYPE_TO_BPP_MAP[options.colorType];if(options.bitDepth===16)maxValue=65535,outBpp*=2;let outData=Buffer.alloc(width*height*outBpp),inIndex=0,outIndex=0,bgColor=options.bgColor||{};if(bgColor.red===void 0)bgColor.red=maxValue;if(bgColor.green===void 0)bgColor.green=maxValue;if(bgColor.blue===void 0)bgColor.blue=maxValue;function getRGBA(){let red,green,blue,alpha=maxValue;switch(options.inputColorType){case constants.COLORTYPE_COLOR_ALPHA:alpha=data[inIndex+3],red=data[inIndex],green=data[inIndex+1],blue=data[inIndex+2];break;case constants.COLORTYPE_COLOR:red=data[inIndex],green=data[inIndex+1],blue=data[inIndex+2];break;case constants.COLORTYPE_ALPHA:alpha=data[inIndex+1],red=data[inIndex],green=red,blue=red;break;case constants.COLORTYPE_GRAYSCALE:red=data[inIndex],green=red,blue=red;break;default:throw Error("input color type:"+options.inputColorType+" is not supported at present")}if(options.inputHasAlpha){if(!outHasAlpha)alpha/=maxValue,red=Math.min(Math.max(Math.round((1-alpha)*bgColor.red+alpha*red),0),maxValue),green=Math.min(Math.max(Math.round((1-alpha)*bgColor.green+alpha*green),0),maxValue),blue=Math.min(Math.max(Math.round((1-alpha)*bgColor.blue+alpha*blue),0),maxValue)}return{red,green,blue,alpha}}for(let y=0;y<height;y++)for(let x=0;x<width;x++){let rgba=getRGBA(data,inIndex);switch(options.colorType){case constants.COLORTYPE_COLOR_ALPHA:case constants.COLORTYPE_COLOR:if(options.bitDepth===8){if(outData[outIndex]=rgba.red,outData[outIndex+1]=rgba.green,outData[outIndex+2]=rgba.blue,outHasAlpha)outData[outIndex+3]=rgba.alpha}else if(outData.writeUInt16BE(rgba.red,outIndex),outData.writeUInt16BE(rgba.green,outIndex+2),outData.writeUInt16BE(rgba.blue,outIndex+4),outHasAlpha)outData.writeUInt16BE(rgba.alpha,outIndex+6);break;case constants.COLORTYPE_ALPHA:case constants.COLORTYPE_GRAYSCALE:{let grayscale=(rgba.red+rgba.green+rgba.blue)/3;if(options.bitDepth===8){if(outData[outIndex]=grayscale,outHasAlpha)outData[outIndex+1]=rgba.alpha}else if(outData.writeUInt16BE(grayscale,outIndex),outHasAlpha)outData.writeUInt16BE(rgba.alpha,outIndex+2);break}default:throw Error("unrecognised color Type "+options.colorType)}inIndex+=inBpp,outIndex+=outBpp}return outData}});var require_filter_pack=__commonJS(function(exports,module){var paethPredictor=require_paeth_predictor();function filterNone(pxData,pxPos,byteWidth,rawData,rawPos){for(let x=0;x<byteWidth;x++)rawData[rawPos+x]=pxData[pxPos+x]}function filterSumNone(pxData,pxPos,byteWidth){let sum=0,length=pxPos+byteWidth;for(let i=pxPos;i<length;i++)sum+=Math.abs(pxData[i]);return sum}function filterSub(pxData,pxPos,byteWidth,rawData,rawPos,bpp){for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,val=pxData[pxPos+x]-left;rawData[rawPos+x]=val}}function filterSumSub(pxData,pxPos,byteWidth,bpp){let sum=0;for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,val=pxData[pxPos+x]-left;sum+=Math.abs(val)}return sum}function filterUp(pxData,pxPos,byteWidth,rawData,rawPos){for(let x=0;x<byteWidth;x++){let up=pxPos>0?pxData[pxPos+x-byteWidth]:0,val=pxData[pxPos+x]-up;rawData[rawPos+x]=val}}function filterSumUp(pxData,pxPos,byteWidth){let sum=0,length=pxPos+byteWidth;for(let x=pxPos;x<length;x++){let up=pxPos>0?pxData[x-byteWidth]:0,val=pxData[x]-up;sum+=Math.abs(val)}return sum}function filterAvg(pxData,pxPos,byteWidth,rawData,rawPos,bpp){for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,val=pxData[pxPos+x]-(left+up>>1);rawData[rawPos+x]=val}}function filterSumAvg(pxData,pxPos,byteWidth,bpp){let sum=0;for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,val=pxData[pxPos+x]-(left+up>>1);sum+=Math.abs(val)}return sum}function filterPaeth(pxData,pxPos,byteWidth,rawData,rawPos,bpp){for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,upleft=pxPos>0&&x>=bpp?pxData[pxPos+x-(byteWidth+bpp)]:0,val=pxData[pxPos+x]-paethPredictor(left,up,upleft);rawData[rawPos+x]=val}}function filterSumPaeth(pxData,pxPos,byteWidth,bpp){let sum=0;for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,upleft=pxPos>0&&x>=bpp?pxData[pxPos+x-(byteWidth+bpp)]:0,val=pxData[pxPos+x]-paethPredictor(left,up,upleft);sum+=Math.abs(val)}return sum}var filters={0:filterNone,1:filterSub,2:filterUp,3:filterAvg,4:filterPaeth},filterSums={0:filterSumNone,1:filterSumSub,2:filterSumUp,3:filterSumAvg,4:filterSumPaeth};module.exports=function(pxData,width,height,options,bpp){let filterTypes;if(!("filterType"in options)||options.filterType===-1)filterTypes=[0,1,2,3,4];else if(typeof options.filterType==="number")filterTypes=[options.filterType];else throw Error("unrecognised filter types");if(options.bitDepth===16)bpp*=2;let byteWidth=width*bpp,rawPos=0,pxPos=0,rawData=Buffer.alloc((byteWidth+1)*height),sel=filterTypes[0];for(let y=0;y<height;y++){if(filterTypes.length>1){let min=1/0;for(let i=0;i<filterTypes.length;i++){let sum=filterSums[filterTypes[i]](pxData,pxPos,byteWidth,bpp);if(sum<min)sel=filterTypes[i],min=sum}}rawData[rawPos]=sel,rawPos++,filters[sel](pxData,pxPos,byteWidth,rawData,rawPos,bpp),rawPos+=byteWidth,pxPos+=byteWidth}return rawData}});var require_packer=__commonJS(function(exports,module){var constants=require_constants(),CrcStream=require_crc(),bitPacker=require_bitpacker(),filter=require_filter_pack(),zlib=__require("zlib"),Packer=module.exports=function(options){if(this._options=options,options.deflateChunkSize=options.deflateChunkSize||32768,options.deflateLevel=options.deflateLevel!=null?options.deflateLevel:9,options.deflateStrategy=options.deflateStrategy!=null?options.deflateStrategy:3,options.inputHasAlpha=options.inputHasAlpha!=null?options.inputHasAlpha:!0,options.deflateFactory=options.deflateFactory||zlib.createDeflate,options.bitDepth=options.bitDepth||8,options.colorType=typeof options.colorType==="number"?options.colorType:constants.COLORTYPE_COLOR_ALPHA,options.inputColorType=typeof options.inputColorType==="number"?options.inputColorType:constants.COLORTYPE_COLOR_ALPHA,[constants.COLORTYPE_GRAYSCALE,constants.COLORTYPE_COLOR,constants.COLORTYPE_COLOR_ALPHA,constants.COLORTYPE_ALPHA].indexOf(options.colorType)===-1)throw Error("option color type:"+options.colorType+" is not supported at present");if([constants.COLORTYPE_GRAYSCALE,constants.COLORTYPE_COLOR,constants.COLORTYPE_COLOR_ALPHA,constants.COLORTYPE_ALPHA].indexOf(options.inputColorType)===-1)throw Error("option input color type:"+options.inputColorType+" is not supported at present");if(options.bitDepth!==8&&options.bitDepth!==16)throw Error("option bit depth:"+options.bitDepth+" is not supported at present")};Packer.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Packer.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Packer.prototype.filterData=function(data,width,height){let packedData=bitPacker(data,width,height,this._options),bpp=constants.COLORTYPE_TO_BPP_MAP[this._options.colorType];return filter(packedData,width,height,this._options,bpp)};Packer.prototype._packChunk=function(type,data){let len=data?data.length:0,buf=Buffer.alloc(len+12);if(buf.writeUInt32BE(len,0),buf.writeUInt32BE(type,4),data)data.copy(buf,8);return buf.writeInt32BE(CrcStream.crc32(buf.slice(4,buf.length-4)),buf.length-4),buf};Packer.prototype.packGAMA=function(gamma){let buf=Buffer.alloc(4);return buf.writeUInt32BE(Math.floor(gamma*constants.GAMMA_DIVISION),0),this._packChunk(constants.TYPE_gAMA,buf)};Packer.prototype.packIHDR=function(width,height){let buf=Buffer.alloc(13);return buf.writeUInt32BE(width,0),buf.writeUInt32BE(height,4),buf[8]=this._options.bitDepth,buf[9]=this._options.colorType,buf[10]=0,buf[11]=0,buf[12]=0,this._packChunk(constants.TYPE_IHDR,buf)};Packer.prototype.packIDAT=function(data){return this._packChunk(constants.TYPE_IDAT,data)};Packer.prototype.packIEND=function(){return this._packChunk(constants.TYPE_IEND,null)}});var require_packer_async=__commonJS(function(exports,module){var util=__require("util"),Stream=__require("stream"),constants=require_constants(),Packer=require_packer(),PackerAsync=module.exports=function(opt){Stream.call(this);let options=opt||{};this._packer=new Packer(options),this._deflate=this._packer.createDeflate(),this.readable=!0};util.inherits(PackerAsync,Stream);PackerAsync.prototype.pack=function(data,width,height,gamma){if(this.emit("data",Buffer.from(constants.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(width,height)),gamma)this.emit("data",this._packer.packGAMA(gamma));let filteredData=this._packer.filterData(data,width,height);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(compressedData){this.emit("data",this._packer.packIDAT(compressedData))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(filteredData)}});var require_sync_inflate=__commonJS(function(exports,module){var assert=__require("assert").ok,zlib=__require("zlib"),util=__require("util"),kMaxLength=__require("buffer").kMaxLength;function Inflate(opts){if(!(this instanceof Inflate))return new Inflate(opts);if(opts&&opts.chunkSize<zlib.Z_MIN_CHUNK)opts.chunkSize=zlib.Z_MIN_CHUNK;if(zlib.Inflate.call(this,opts),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,opts&&opts.maxLength!=null)this._maxLength=opts.maxLength}function createInflate(opts){return new Inflate(opts)}function _close(engine,callback){if(callback)process.nextTick(callback);if(!engine._handle)return;engine._handle.close(),engine._handle=null}Inflate.prototype._processChunk=function(chunk,flushFlag,asyncCb){if(typeof asyncCb==="function")return zlib.Inflate._processChunk.call(this,chunk,flushFlag,asyncCb);let self=this,availInBefore=chunk&&chunk.length,availOutBefore=this._chunkSize-this._offset,leftToInflate=this._maxLength,inOff=0,buffers=[],nread=0,error;this.on("error",function(err){error=err});function handleChunk(availInAfter,availOutAfter){if(self._hadError)return;let have=availOutBefore-availOutAfter;if(assert(have>=0,"have should not go down"),have>0){let out=self._buffer.slice(self._offset,self._offset+have);if(self._offset+=have,out.length>leftToInflate)out=out.slice(0,leftToInflate);if(buffers.push(out),nread+=out.length,leftToInflate-=out.length,leftToInflate===0)return!1}if(availOutAfter===0||self._offset>=self._chunkSize)availOutBefore=self._chunkSize,self._offset=0,self._buffer=Buffer.allocUnsafe(self._chunkSize);if(availOutAfter===0)return inOff+=availInBefore-availInAfter,availInBefore=availInAfter,!0;return!1}assert(this._handle,"zlib binding closed");let res;do res=this._handle.writeSync(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore),res=res||this._writeState;while(!this._hadError&&handleChunk(res[0],res[1]));if(this._hadError)throw error;if(nread>=kMaxLength)throw _close(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+kMaxLength.toString(16)+" bytes");let buf=Buffer.concat(buffers,nread);return _close(this),buf};util.inherits(Inflate,zlib.Inflate);function zlibBufferSync(engine,buffer){if(typeof buffer==="string")buffer=Buffer.from(buffer);if(!(buffer instanceof Buffer))throw TypeError("Not a string or buffer");let flushFlag=engine._finishFlushFlag;if(flushFlag==null)flushFlag=zlib.Z_FINISH;return engine._processChunk(buffer,flushFlag)}function inflateSync(buffer,opts){return zlibBufferSync(new Inflate(opts),buffer)}module.exports=exports=inflateSync;exports.Inflate=Inflate;exports.createInflate=createInflate;exports.inflateSync=inflateSync});var require_sync_reader=__commonJS(function(exports,module){var SyncReader=module.exports=function(buffer){this._buffer=buffer,this._reads=[]};SyncReader.prototype.read=function(length,callback){this._reads.push({length:Math.abs(length),allowLess:length<0,func:callback})};SyncReader.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let read=this._reads[0];if(this._buffer.length&&(this._buffer.length>=read.length||read.allowLess)){this._reads.shift();let buf=this._buffer;this._buffer=buf.slice(read.length),read.func.call(this,buf.slice(0,read.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 require_filter_parse_sync=__commonJS(function(exports){var SyncReader=require_sync_reader(),Filter=require_filter_parse();exports.process=function(inBuffer,bitmapInfo){let outBuffers=[],reader=new SyncReader(inBuffer);return new Filter(bitmapInfo,{read:reader.read.bind(reader),write:function(bufferPart){outBuffers.push(bufferPart)},complete:function(){}}).start(),reader.process(),Buffer.concat(outBuffers)}});var require_parser_sync=__commonJS(function(exports,module){var hasSyncZlib=!0,zlib=__require("zlib"),inflateSync=require_sync_inflate();if(!zlib.deflateSync)hasSyncZlib=!1;var SyncReader=require_sync_reader(),FilterSync=require_filter_parse_sync(),Parser=require_parser(),bitmapper=require_bitmapper(),formatNormaliser=require_format_normaliser();module.exports=function(buffer,options){if(!hasSyncZlib)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let err;function handleError(_err_){err=_err_}let metaData;function handleMetaData(_metaData_){metaData=_metaData_}function handleTransColor(transColor){metaData.transColor=transColor}function handlePalette(palette){metaData.palette=palette}function handleSimpleTransparency(){metaData.alpha=!0}let gamma;function handleGamma(_gamma_){gamma=_gamma_}let inflateDataList=[];function handleInflateData(inflatedData){inflateDataList.push(inflatedData)}let reader=new SyncReader(buffer);if(new Parser(options,{read:reader.read.bind(reader),error:handleError,metadata:handleMetaData,gamma:handleGamma,palette:handlePalette,transColor:handleTransColor,inflateData:handleInflateData,simpleTransparency:handleSimpleTransparency}).start(),reader.process(),err)throw err;let inflateData=Buffer.concat(inflateDataList);inflateDataList.length=0;let inflatedData;if(metaData.interlace)inflatedData=zlib.inflateSync(inflateData);else{let imageSize=((metaData.width*metaData.bpp*metaData.depth+7>>3)+1)*metaData.height;inflatedData=inflateSync(inflateData,{chunkSize:imageSize,maxLength:imageSize})}if(inflateData=null,!inflatedData||!inflatedData.length)throw Error("bad png - invalid inflate data response");let unfilteredData=FilterSync.process(inflatedData,metaData);inflateData=null;let bitmapData=bitmapper.dataToBitMap(unfilteredData,metaData);unfilteredData=null;let normalisedBitmapData=formatNormaliser(bitmapData,metaData,options.skipRescale);return metaData.data=normalisedBitmapData,metaData.gamma=gamma||0,metaData}});var require_packer_sync=__commonJS(function(exports,module){var hasSyncZlib=!0,zlib=__require("zlib");if(!zlib.deflateSync)hasSyncZlib=!1;var constants=require_constants(),Packer=require_packer();module.exports=function(metaData,opt){if(!hasSyncZlib)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let packer=new Packer(opt||{}),chunks=[];if(chunks.push(Buffer.from(constants.PNG_SIGNATURE)),chunks.push(packer.packIHDR(metaData.width,metaData.height)),metaData.gamma)chunks.push(packer.packGAMA(metaData.gamma));let filteredData=packer.filterData(metaData.data,metaData.width,metaData.height),compressedData=zlib.deflateSync(filteredData,packer.getDeflateOptions());if(filteredData=null,!compressedData||!compressedData.length)throw Error("bad png - invalid compressed data response");return chunks.push(packer.packIDAT(compressedData)),chunks.push(packer.packIEND()),Buffer.concat(chunks)}});var require_png_sync=__commonJS(function(exports){var parse=require_parser_sync(),pack=require_packer_sync();exports.read=function(buffer,options){return parse(buffer,options||{})};exports.write=function(png,options){return pack(png,options)}});var require_png=__commonJS(function(exports){var util=__require("util"),Stream=__require("stream"),Parser=require_parser_async(),Packer=require_packer_async(),PNGSync=require_png_sync(),PNG=exports.PNG=function(options){if(Stream.call(this),options=options||{},this.width=options.width|0,this.height=options.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,options.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new Parser(options),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(data){this.data=data,this.emit("parsed",data)}.bind(this)),this._packer=new Packer(options),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"))};util.inherits(PNG,Stream);PNG.sync=PNGSync;PNG.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};PNG.prototype.parse=function(data,callback){if(callback){let onParsed,onError;onParsed=function(parsedData){this.removeListener("error",onError),this.data=parsedData,callback(null,this)}.bind(this),onError=function(err){this.removeListener("parsed",onParsed),callback(err,null)}.bind(this),this.once("parsed",onParsed),this.once("error",onError)}return this.end(data),this};PNG.prototype.write=function(data){return this._parser.write(data),!0};PNG.prototype.end=function(data){this._parser.end(data)};PNG.prototype._metadata=function(metadata){this.width=metadata.width,this.height=metadata.height,this.emit("metadata",metadata)};PNG.prototype._gamma=function(gamma){this.gamma=gamma};PNG.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};PNG.bitblt=function(src,dst,srcX,srcY,width,height,deltaX,deltaY){if(srcX|=0,srcY|=0,width|=0,height|=0,deltaX|=0,deltaY|=0,srcX>src.width||srcY>src.height||srcX+width>src.width||srcY+height>src.height)throw Error("bitblt reading outside image");if(deltaX>dst.width||deltaY>dst.height||deltaX+width>dst.width||deltaY+height>dst.height)throw Error("bitblt writing outside image");for(let y=0;y<height;y++)src.data.copy(dst.data,(deltaY+y)*dst.width+deltaX<<2,(srcY+y)*src.width+srcX<<2,(srcY+y)*src.width+srcX+width<<2)};PNG.prototype.bitblt=function(dst,srcX,srcY,width,height,deltaX,deltaY){return PNG.bitblt(this,dst,srcX,srcY,width,height,deltaX,deltaY),this};PNG.adjustGamma=function(src){if(src.gamma){for(let y=0;y<src.height;y++)for(let x=0;x<src.width;x++){let idx=src.width*y+x<<2;for(let i=0;i<3;i++){let sample=src.data[idx+i]/255;sample=Math.pow(sample,0.45454545454545453/src.gamma),src.data[idx+i]=Math.round(sample*255)}}src.gamma=0}};PNG.prototype.adjustGamma=function(){PNG.adjustGamma(this)}});var require_react_development=__commonJS(function(exports,module){(function(){function defineDeprecationWarning(methodName,info){Object.defineProperty(Component.prototype,methodName,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",info[0],info[1])}})}function getIteratorFn(maybeIterable){if(maybeIterable===null||typeof maybeIterable!=="object")return null;return maybeIterable=MAYBE_ITERATOR_SYMBOL&&maybeIterable[MAYBE_ITERATOR_SYMBOL]||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(props,context,updater){this.props=props,this.context=context,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}function ComponentDummy(){}function PureComponent(props,context,updater){this.props=props,this.context=context,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}function noop(){}function testStringCoercion(value){return""+value}function checkKeyStringCoercion(value){try{testStringCoercion(value);var JSCompiler_inline_result=!1}catch(e){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:return"Fragment";case REACT_PROFILER_TYPE:return"Profiler";case REACT_STRICT_MODE_TYPE:return"StrictMode";case REACT_SUSPENSE_TYPE: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:return"Portal";case REACT_CONTEXT_TYPE:return type.displayName||"Context";case REACT_CONSUMER_TYPE:return(type._context.displayName||"Context")+".Consumer";case REACT_FORWARD_REF_TYPE:var innerType=type.render;return type=type.displayName,type||(type=innerType.displayName||innerType.name||"",type=type!==""?"ForwardRef("+type+")":"ForwardRef"),type;case REACT_MEMO_TYPE:return innerType=type.displayName||null,innerType!==null?innerType:getComponentNameFromType(type.type)||"Memo";case REACT_LAZY_TYPE:innerType=type._payload,type=type._init;try{return getComponentNameFromType(type(innerType))}catch(x){}}return null}function getTaskName(type){if(type===REACT_FRAGMENT_TYPE)return"<>";if(typeof type==="object"&&type!==null&&type.$$typeof===REACT_LAZY_TYPE)return"<...>";try{var name=getComponentNameFromType(type);return name?"<"+name+">":"<...>"}catch(x){return"<...>"}}function getOwner(){var dispatcher=ReactSharedInternals.A;return dispatcher===null?null:dispatcher.getOwner()}function UnknownOwner(){return Error("react-stack-top-frame")}function hasValidKey(config){if(hasOwnProperty.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?componentName:null}function ReactElement(type,key,props,owner,debugStack,debugTask){var refProp=props.ref;return type={$$typeof:REACT_ELEMENT_TYPE,type,key,props,_owner:owner},(refProp!==void 0?refProp:null)!==null?Object.defineProperty(type,"ref",{enumerable:!1,get:elementRefGetterWithDeprecationWarning}):Object.defineProperty(type,"ref",{enumerable:!1,value:null}),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(oldElement,newKey){return newKey=ReactElement(oldElement.type,newKey,oldElement.props,oldElement._owner,oldElement._debugStack,oldElement._debugTask),oldElement._store&&(newKey._store.validated=oldElement._store.validated),newKey}function validateChildKeys(node){isValidElement(node)?node._store&&(node._store.validated=1):typeof node==="object"&&node!==null&&node.$$typeof===REACT_LAZY_TYPE&&(node._payload.status==="fulfilled"?isValidElement(node._payload.value)&&node._payload.value._store&&(node._payload.value._store.validated=1):node._store&&(node._store.validated=1))}function isValidElement(object){return typeof object==="object"&&object!==null&&object.$$typeof===REACT_ELEMENT_TYPE}function escape(key){var escaperLookup={"=":"=0",":":"=2"};return"$"+key.replace(/[=:]/g,function(match){return escaperLookup[match]})}function getElementKey(element,index){return typeof element==="object"&&element!==null&&element.key!=null?(checkKeyStringCoercion(element.key),escape(""+element.key)):index.toString(36)}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,noop):(thenable.status="pending",thenable.then(function(fulfilledValue){thenable.status==="pending"&&(thenable.status="fulfilled",thenable.value=fulfilledValue)},function(error){thenable.status==="pending"&&(thenable.status="rejected",thenable.reason=error)})),thenable.status){case"fulfilled":return thenable.value;case"rejected":throw thenable.reason}}throw thenable}function mapIntoArray(children,array,escapedPrefix,nameSoFar,callback){var type=typeof children;if(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:case REACT_PORTAL_TYPE:invokeCallback=!0;break;case REACT_LAZY_TYPE:return invokeCallback=children._init,mapIntoArray(invokeCallback(children._payload),array,escapedPrefix,nameSoFar,callback)}}if(invokeCallback){invokeCallback=children,callback=callback(invokeCallback);var childKey=nameSoFar===""?"."+getElementKey(invokeCallback,0):nameSoFar;return isArrayImpl(callback)?(escapedPrefix="",childKey!=null&&(escapedPrefix=childKey.replace(userProvidedKeyEscapeRegex,"$&/")+"/"),mapIntoArray(callback,array,escapedPrefix,"",function(c){return c})):callback!=null&&(isValidElement(callback)&&(callback.key!=null&&(invokeCallback&&invokeCallback.key===callback.key||checkKeyStringCoercion(callback.key)),escapedPrefix=cloneAndReplaceKey(callback,escapedPrefix+(callback.key==null||invokeCallback&&invokeCallback.key===callback.key?"":(""+callback.key).replace(userProvidedKeyEscapeRegex,"$&/")+"/")+childKey),nameSoFar!==""&&invokeCallback!=null&&isValidElement(invokeCallback)&&invokeCallback.key==null&&invokeCallback._store&&!invokeCallback._store.validated&&(escapedPrefix._store.validated=2),callback=escapedPrefix),array.push(callback)),1}if(invokeCallback=0,childKey=nameSoFar===""?".":nameSoFar+":",isArrayImpl(children))for(var i=0;i<children.length;i++)nameSoFar=children[i],type=childKey+getElementKey(nameSoFar,i),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback);else if(i=getIteratorFn(children),typeof i==="function")for(i===children.entries&&(didWarnAboutMaps||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),didWarnAboutMaps=!0),children=i.call(children),i=0;!(nameSoFar=children.next()).done;)nameSoFar=nameSoFar.value,type=childKey+getElementKey(nameSoFar,i++),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback);else if(type==="object"){if(typeof children.then==="function")return mapIntoArray(resolveThenable(children),array,escapedPrefix,nameSoFar,callback);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){if(children==null)return children;var result=[],count=0;return mapIntoArray(children,result,"","",function(child){return func.call(context,child,count++)}),result}function lazyInitializer(payload){if(payload._status===-1){var ioInfo=payload._ioInfo;ioInfo!=null&&(ioInfo.start=ioInfo.end=performance.now()),ioInfo=payload._result;var thenable=ioInfo();if(thenable.then(function(moduleObject){if(payload._status===0||payload._status===-1){payload._status=1,payload._result=moduleObject;var _ioInfo=payload._ioInfo;_ioInfo!=null&&(_ioInfo.end=performance.now()),thenable.status===void 0&&(thenable.status="fulfilled",thenable.value=moduleObject)}},function(error){if(payload._status===0||payload._status===-1){payload._status=2,payload._result=error;var _ioInfo2=payload._ioInfo;_ioInfo2!=null&&(_ioInfo2.end=performance.now()),thenable.status===void 0&&(thenable.status="rejected",thenable.reason=error)}}),ioInfo=payload._ioInfo,ioInfo!=null){ioInfo.value=thenable;var displayName=thenable.displayName;typeof displayName==="string"&&(ioInfo.name=displayName)}payload._status===-1&&(payload._status=0,payload._result=thenable)}if(payload._status===1)return ioInfo=payload._result,ioInfo===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
2
|
+
import{isCssIdent,sanitizeCssTokenValue,neutralizeCssText,sanitizeGoogleFontSpec,isComponentNode,isSnippetInstance,isParamRef,isRepoNode,repoKey,ScreenSchema,resolveSnippetArgs,substituteSnippetParams,applySnippetOverrides,applySnippetExtraClassName,ThemeSchema,typesetCss}from"./chunk-7a45tn73.js";import{__toESM,__commonJS,__exportCjs,__require}from"./chunk-2smsg2ct.js";var require_chunkstream=__commonJS(function(exports,module){var util=__require("util"),Stream=__require("stream"),ChunkStream=module.exports=function(){Stream.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};util.inherits(ChunkStream,Stream);ChunkStream.prototype.read=function(length,callback){this._reads.push({length:Math.abs(length),allowLess:length<0,func:callback}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};ChunkStream.prototype.write=function(data,encoding){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let dataBuffer;if(Buffer.isBuffer(data))dataBuffer=data;else dataBuffer=Buffer.from(data,encoding||this._encoding);if(this._buffers.push(dataBuffer),this._buffered+=dataBuffer.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};ChunkStream.prototype.end=function(data,encoding){if(data)this.write(data,encoding);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};ChunkStream.prototype.destroySoon=ChunkStream.prototype.end;ChunkStream.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};ChunkStream.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};ChunkStream.prototype._processReadAllowingLess=function(read){this._reads.shift();let smallerBuf=this._buffers[0];if(smallerBuf.length>read.length)this._buffered-=read.length,this._buffers[0]=smallerBuf.slice(read.length),read.func.call(this,smallerBuf.slice(0,read.length));else this._buffered-=smallerBuf.length,this._buffers.shift(),read.func.call(this,smallerBuf)};ChunkStream.prototype._processRead=function(read){this._reads.shift();let pos=0,count=0,data=Buffer.alloc(read.length);while(pos<read.length){let buf=this._buffers[count++],len=Math.min(buf.length,read.length-pos);if(buf.copy(data,pos,0,len),pos+=len,len!==buf.length)this._buffers[--count]=buf.slice(len)}if(count>0)this._buffers.splice(0,count);this._buffered-=read.length,read.func.call(this,data)};ChunkStream.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let read=this._reads[0];if(read.allowLess)this._processReadAllowingLess(read);else if(this._buffered>=read.length)this._processRead(read);else break}if(this._buffers&&!this.writable)this._end()}catch(ex){this.emit("error",ex)}}});var require_interlace=__commonJS(function(exports){var imagePasses=[{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]}];exports.getImagePasses=function(width,height){let images=[],xLeftOver=width%8,yLeftOver=height%8,xRepeats=(width-xLeftOver)/8,yRepeats=(height-yLeftOver)/8;for(let i=0;i<imagePasses.length;i++){let pass=imagePasses[i],passWidth=xRepeats*pass.x.length,passHeight=yRepeats*pass.y.length;for(let j=0;j<pass.x.length;j++)if(pass.x[j]<xLeftOver)passWidth++;else break;for(let j=0;j<pass.y.length;j++)if(pass.y[j]<yLeftOver)passHeight++;else break;if(passWidth>0&&passHeight>0)images.push({width:passWidth,height:passHeight,index:i})}return images};exports.getInterlaceIterator=function(width){return function(x,y,pass){let outerXLeftOver=x%imagePasses[pass].x.length,outerX=(x-outerXLeftOver)/imagePasses[pass].x.length*8+imagePasses[pass].x[outerXLeftOver],outerYLeftOver=y%imagePasses[pass].y.length,outerY=(y-outerYLeftOver)/imagePasses[pass].y.length*8+imagePasses[pass].y[outerYLeftOver];return outerX*4+outerY*width*4}}});var require_paeth_predictor=__commonJS(function(exports,module){module.exports=function(left,above,upLeft){let paeth=left+above-upLeft,pLeft=Math.abs(paeth-left),pAbove=Math.abs(paeth-above),pUpLeft=Math.abs(paeth-upLeft);if(pLeft<=pAbove&&pLeft<=pUpLeft)return left;if(pAbove<=pUpLeft)return above;return upLeft}});var require_filter_parse=__commonJS(function(exports,module){var interlaceUtils=require_interlace(),paethPredictor=require_paeth_predictor();function getByteWidth(width,bpp,depth){let byteWidth=width*bpp;if(depth!==8)byteWidth=Math.ceil(byteWidth/(8/depth));return byteWidth}var Filter=module.exports=function(bitmapInfo,dependencies){let{width,height,interlace,bpp,depth}=bitmapInfo;if(this.read=dependencies.read,this.write=dependencies.write,this.complete=dependencies.complete,this._imageIndex=0,this._images=[],interlace){let passes=interlaceUtils.getImagePasses(width,height);for(let i=0;i<passes.length;i++)this._images.push({byteWidth:getByteWidth(passes[i].width,bpp,depth),height:passes[i].height,lineIndex:0})}else this._images.push({byteWidth:getByteWidth(width,bpp,depth),height,lineIndex:0});if(depth===8)this._xComparison=bpp;else if(depth===16)this._xComparison=bpp*2;else this._xComparison=1};Filter.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};Filter.prototype._unFilterType1=function(rawData,unfilteredLine,byteWidth){let xComparison=this._xComparison,xBiggerThan=xComparison-1;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f1Left=x>xBiggerThan?unfilteredLine[x-xComparison]:0;unfilteredLine[x]=rawByte+f1Left}};Filter.prototype._unFilterType2=function(rawData,unfilteredLine,byteWidth){let lastLine=this._lastLine;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f2Up=lastLine?lastLine[x]:0;unfilteredLine[x]=rawByte+f2Up}};Filter.prototype._unFilterType3=function(rawData,unfilteredLine,byteWidth){let xComparison=this._xComparison,xBiggerThan=xComparison-1,lastLine=this._lastLine;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f3Up=lastLine?lastLine[x]:0,f3Left=x>xBiggerThan?unfilteredLine[x-xComparison]:0,f3Add=Math.floor((f3Left+f3Up)/2);unfilteredLine[x]=rawByte+f3Add}};Filter.prototype._unFilterType4=function(rawData,unfilteredLine,byteWidth){let xComparison=this._xComparison,xBiggerThan=xComparison-1,lastLine=this._lastLine;for(let x=0;x<byteWidth;x++){let rawByte=rawData[1+x],f4Up=lastLine?lastLine[x]:0,f4Left=x>xBiggerThan?unfilteredLine[x-xComparison]:0,f4UpLeft=x>xBiggerThan&&lastLine?lastLine[x-xComparison]:0,f4Add=paethPredictor(f4Left,f4Up,f4UpLeft);unfilteredLine[x]=rawByte+f4Add}};Filter.prototype._reverseFilterLine=function(rawData){let filter=rawData[0],unfilteredLine,currentImage=this._images[this._imageIndex],byteWidth=currentImage.byteWidth;if(filter===0)unfilteredLine=rawData.slice(1,byteWidth+1);else switch(unfilteredLine=Buffer.alloc(byteWidth),filter){case 1:this._unFilterType1(rawData,unfilteredLine,byteWidth);break;case 2:this._unFilterType2(rawData,unfilteredLine,byteWidth);break;case 3:this._unFilterType3(rawData,unfilteredLine,byteWidth);break;case 4:this._unFilterType4(rawData,unfilteredLine,byteWidth);break;default:throw Error("Unrecognised filter type - "+filter)}if(this.write(unfilteredLine),currentImage.lineIndex++,currentImage.lineIndex>=currentImage.height)this._lastLine=null,this._imageIndex++,currentImage=this._images[this._imageIndex];else this._lastLine=unfilteredLine;if(currentImage)this.read(currentImage.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var require_filter_parse_async=__commonJS(function(exports,module){var util=__require("util"),ChunkStream=require_chunkstream(),Filter=require_filter_parse(),FilterAsync=module.exports=function(bitmapInfo){ChunkStream.call(this);let buffers=[],that=this;this._filter=new Filter(bitmapInfo,{read:this.read.bind(this),write:function(buffer){buffers.push(buffer)},complete:function(){that.emit("complete",Buffer.concat(buffers))}}),this._filter.start()};util.inherits(FilterAsync,ChunkStream)});var require_constants=__commonJS(function(exports,module){module.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 require_crc=__commonJS(function(exports,module){var crcTable=[];(function(){for(let i=0;i<256;i++){let currentCrc=i;for(let j=0;j<8;j++)if(currentCrc&1)currentCrc=3988292384^currentCrc>>>1;else currentCrc=currentCrc>>>1;crcTable[i]=currentCrc}})();var CrcCalculator=module.exports=function(){this._crc=-1};CrcCalculator.prototype.write=function(data){for(let i=0;i<data.length;i++)this._crc=crcTable[(this._crc^data[i])&255]^this._crc>>>8;return!0};CrcCalculator.prototype.crc32=function(){return this._crc^-1};CrcCalculator.crc32=function(buf){let crc=-1;for(let i=0;i<buf.length;i++)crc=crcTable[(crc^buf[i])&255]^crc>>>8;return crc^-1}});var require_parser=__commonJS(function(exports,module){var constants=require_constants(),CrcCalculator=require_crc(),Parser=module.exports=function(options,dependencies){this._options=options,options.checkCRC=options.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[constants.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[constants.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[constants.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[constants.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[constants.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[constants.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=dependencies.read,this.error=dependencies.error,this.metadata=dependencies.metadata,this.gamma=dependencies.gamma,this.transColor=dependencies.transColor,this.palette=dependencies.palette,this.parsed=dependencies.parsed,this.inflateData=dependencies.inflateData,this.finished=dependencies.finished,this.simpleTransparency=dependencies.simpleTransparency,this.headersFinished=dependencies.headersFinished||function(){}};Parser.prototype.start=function(){this.read(constants.PNG_SIGNATURE.length,this._parseSignature.bind(this))};Parser.prototype._parseSignature=function(data){let signature=constants.PNG_SIGNATURE;for(let i=0;i<signature.length;i++)if(data[i]!==signature[i]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};Parser.prototype._parseChunkBegin=function(data){let length=data.readUInt32BE(0),type=data.readUInt32BE(4),name="";for(let i=4;i<8;i++)name+=String.fromCharCode(data[i]);let ancillary=Boolean(data[4]&32);if(!this._hasIHDR&&type!==constants.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new CrcCalculator,this._crc.write(Buffer.from(name)),this._chunks[type])return this._chunks[type](length);if(!ancillary){this.error(Error("Unsupported critical chunk type "+name));return}this.read(length+4,this._skipChunk.bind(this))};Parser.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};Parser.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};Parser.prototype._parseChunkEnd=function(data){let fileCrc=data.readInt32BE(0),calcCrc=this._crc.crc32();if(this._options.checkCRC&&calcCrc!==fileCrc){this.error(Error("Crc error - "+fileCrc+" - "+calcCrc));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};Parser.prototype._handleIHDR=function(length){this.read(length,this._parseIHDR.bind(this))};Parser.prototype._parseIHDR=function(data){this._crc.write(data);let width=data.readUInt32BE(0),height=data.readUInt32BE(4),depth=data[8],colorType=data[9],compr=data[10],filter=data[11],interlace=data[12];if(depth!==8&&depth!==4&&depth!==2&&depth!==1&&depth!==16){this.error(Error("Unsupported bit depth "+depth));return}if(!(colorType in constants.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(compr!==0){this.error(Error("Unsupported compression method"));return}if(filter!==0){this.error(Error("Unsupported filter method"));return}if(interlace!==0&&interlace!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=colorType;let bpp=constants.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width,height,depth,interlace:Boolean(interlace),palette:Boolean(colorType&constants.COLORTYPE_PALETTE),color:Boolean(colorType&constants.COLORTYPE_COLOR),alpha:Boolean(colorType&constants.COLORTYPE_ALPHA),bpp,colorType}),this._handleChunkEnd()};Parser.prototype._handlePLTE=function(length){this.read(length,this._parsePLTE.bind(this))};Parser.prototype._parsePLTE=function(data){this._crc.write(data);let entries=Math.floor(data.length/3);for(let i=0;i<entries;i++)this._palette.push([data[i*3],data[i*3+1],data[i*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};Parser.prototype._handleTRNS=function(length){this.simpleTransparency(),this.read(length,this._parseTRNS.bind(this))};Parser.prototype._parseTRNS=function(data){if(this._crc.write(data),this._colorType===constants.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(data.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let i=0;i<data.length;i++)this._palette[i][3]=data[i];this.palette(this._palette)}if(this._colorType===constants.COLORTYPE_GRAYSCALE)this.transColor([data.readUInt16BE(0)]);if(this._colorType===constants.COLORTYPE_COLOR)this.transColor([data.readUInt16BE(0),data.readUInt16BE(2),data.readUInt16BE(4)]);this._handleChunkEnd()};Parser.prototype._handleGAMA=function(length){this.read(length,this._parseGAMA.bind(this))};Parser.prototype._parseGAMA=function(data){this._crc.write(data),this.gamma(data.readUInt32BE(0)/constants.GAMMA_DIVISION),this._handleChunkEnd()};Parser.prototype._handleIDAT=function(length){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-length,this._parseIDAT.bind(this,length))};Parser.prototype._parseIDAT=function(length,data){if(this._crc.write(data),this._colorType===constants.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(data);let leftOverLength=length-data.length;if(leftOverLength>0)this._handleIDAT(leftOverLength);else this._handleChunkEnd()};Parser.prototype._handleIEND=function(length){this.read(length,this._parseIEND.bind(this))};Parser.prototype._parseIEND=function(data){if(this._crc.write(data),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var require_bitmapper=__commonJS(function(exports){var interlaceUtils=require_interlace(),pixelBppMapper=[function(){},function(pxData,data,pxPos,rawPos){if(rawPos===data.length)throw Error("Ran out of data");let pixel=data[rawPos];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=255},function(pxData,data,pxPos,rawPos){if(rawPos+1>=data.length)throw Error("Ran out of data");let pixel=data[rawPos];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=data[rawPos+1]},function(pxData,data,pxPos,rawPos){if(rawPos+2>=data.length)throw Error("Ran out of data");pxData[pxPos]=data[rawPos],pxData[pxPos+1]=data[rawPos+1],pxData[pxPos+2]=data[rawPos+2],pxData[pxPos+3]=255},function(pxData,data,pxPos,rawPos){if(rawPos+3>=data.length)throw Error("Ran out of data");pxData[pxPos]=data[rawPos],pxData[pxPos+1]=data[rawPos+1],pxData[pxPos+2]=data[rawPos+2],pxData[pxPos+3]=data[rawPos+3]}],pixelBppCustomMapper=[function(){},function(pxData,pixelData,pxPos,maxBit){let pixel=pixelData[0];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=maxBit},function(pxData,pixelData,pxPos){let pixel=pixelData[0];pxData[pxPos]=pixel,pxData[pxPos+1]=pixel,pxData[pxPos+2]=pixel,pxData[pxPos+3]=pixelData[1]},function(pxData,pixelData,pxPos,maxBit){pxData[pxPos]=pixelData[0],pxData[pxPos+1]=pixelData[1],pxData[pxPos+2]=pixelData[2],pxData[pxPos+3]=maxBit},function(pxData,pixelData,pxPos){pxData[pxPos]=pixelData[0],pxData[pxPos+1]=pixelData[1],pxData[pxPos+2]=pixelData[2],pxData[pxPos+3]=pixelData[3]}];function bitRetriever(data,depth){let leftOver=[],i=0;function split(){if(i===data.length)throw Error("Ran out of data");let byte=data[i];i++;let byte8,byte7,byte6,byte5,byte4,byte3,byte2,byte1;switch(depth){default:throw Error("unrecognised depth");case 16:byte2=data[i],i++,leftOver.push((byte<<8)+byte2);break;case 4:byte2=byte&15,byte1=byte>>4,leftOver.push(byte1,byte2);break;case 2:byte4=byte&3,byte3=byte>>2&3,byte2=byte>>4&3,byte1=byte>>6&3,leftOver.push(byte1,byte2,byte3,byte4);break;case 1:byte8=byte&1,byte7=byte>>1&1,byte6=byte>>2&1,byte5=byte>>3&1,byte4=byte>>4&1,byte3=byte>>5&1,byte2=byte>>6&1,byte1=byte>>7&1,leftOver.push(byte1,byte2,byte3,byte4,byte5,byte6,byte7,byte8);break}}return{get:function(count){while(leftOver.length<count)split();let returner=leftOver.slice(0,count);return leftOver=leftOver.slice(count),returner},resetAfterLine:function(){leftOver.length=0},end:function(){if(i!==data.length)throw Error("extra data found")}}}function mapImage8Bit(image,pxData,getPxPos,bpp,data,rawPos){let{width:imageWidth,height:imageHeight,index:imagePass}=image;for(let y=0;y<imageHeight;y++)for(let x=0;x<imageWidth;x++){let pxPos=getPxPos(x,y,imagePass);pixelBppMapper[bpp](pxData,data,pxPos,rawPos),rawPos+=bpp}return rawPos}function mapImageCustomBit(image,pxData,getPxPos,bpp,bits,maxBit){let{width:imageWidth,height:imageHeight,index:imagePass}=image;for(let y=0;y<imageHeight;y++){for(let x=0;x<imageWidth;x++){let pixelData=bits.get(bpp),pxPos=getPxPos(x,y,imagePass);pixelBppCustomMapper[bpp](pxData,pixelData,pxPos,maxBit)}bits.resetAfterLine()}}exports.dataToBitMap=function(data,bitmapInfo){let{width,height,depth,bpp,interlace}=bitmapInfo,bits;if(depth!==8)bits=bitRetriever(data,depth);let pxData;if(depth<=8)pxData=Buffer.alloc(width*height*4);else pxData=new Uint16Array(width*height*4);let maxBit=Math.pow(2,depth)-1,rawPos=0,images,getPxPos;if(interlace)images=interlaceUtils.getImagePasses(width,height),getPxPos=interlaceUtils.getInterlaceIterator(width,height);else{let nonInterlacedPxPos=0;getPxPos=function(){let returner=nonInterlacedPxPos;return nonInterlacedPxPos+=4,returner},images=[{width,height}]}for(let imageIndex=0;imageIndex<images.length;imageIndex++)if(depth===8)rawPos=mapImage8Bit(images[imageIndex],pxData,getPxPos,bpp,data,rawPos);else mapImageCustomBit(images[imageIndex],pxData,getPxPos,bpp,bits,maxBit);if(depth===8){if(rawPos!==data.length)throw Error("extra data found")}else bits.end();return pxData}});var require_format_normaliser=__commonJS(function(exports,module){function dePalette(indata,outdata,width,height,palette){let pxPos=0;for(let y=0;y<height;y++)for(let x=0;x<width;x++){let color=palette[indata[pxPos]];if(!color)throw Error("index "+indata[pxPos]+" not in palette");for(let i=0;i<4;i++)outdata[pxPos+i]=color[i];pxPos+=4}}function replaceTransparentColor(indata,outdata,width,height,transColor){let pxPos=0;for(let y=0;y<height;y++)for(let x=0;x<width;x++){let makeTrans=!1;if(transColor.length===1){if(transColor[0]===indata[pxPos])makeTrans=!0}else if(transColor[0]===indata[pxPos]&&transColor[1]===indata[pxPos+1]&&transColor[2]===indata[pxPos+2])makeTrans=!0;if(makeTrans)for(let i=0;i<4;i++)outdata[pxPos+i]=0;pxPos+=4}}function scaleDepth(indata,outdata,width,height,depth){let maxOutSample=255,maxInSample=Math.pow(2,depth)-1,pxPos=0;for(let y=0;y<height;y++)for(let x=0;x<width;x++){for(let i=0;i<4;i++)outdata[pxPos+i]=Math.floor(indata[pxPos+i]*maxOutSample/maxInSample+0.5);pxPos+=4}}module.exports=function(indata,imageData,skipRescale=!1){let{depth,width,height,colorType,transColor,palette}=imageData,outdata=indata;if(colorType===3)dePalette(indata,outdata,width,height,palette);else{if(transColor)replaceTransparentColor(indata,outdata,width,height,transColor);if(depth!==8&&!skipRescale){if(depth===16)outdata=Buffer.alloc(width*height*4);scaleDepth(indata,outdata,width,height,depth)}}return outdata}});var require_parser_async=__commonJS(function(exports,module){var util=__require("util"),zlib=__require("zlib"),ChunkStream=require_chunkstream(),FilterAsync=require_filter_parse_async(),Parser=require_parser(),bitmapper=require_bitmapper(),formatNormaliser=require_format_normaliser(),ParserAsync=module.exports=function(options){ChunkStream.call(this),this._parser=new Parser(options,{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=options,this.writable=!0,this._parser.start()};util.inherits(ParserAsync,ChunkStream);ParserAsync.prototype._handleError=function(err){if(this.emit("error",err),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};ParserAsync.prototype._inflateData=function(data){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=zlib.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 imageSize=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,chunkSize=Math.max(imageSize,zlib.Z_MIN_CHUNK);this._inflate=zlib.createInflate({chunkSize});let leftToInflate=imageSize,emitError=this.emit.bind(this,"error");this._inflate.on("error",function(err){if(!leftToInflate)return;emitError(err)}),this._filter.on("complete",this._complete.bind(this));let filterWrite=this._filter.write.bind(this._filter);this._inflate.on("data",function(chunk){if(!leftToInflate)return;if(chunk.length>leftToInflate)chunk=chunk.slice(0,leftToInflate);leftToInflate-=chunk.length,filterWrite(chunk)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(data)};ParserAsync.prototype._handleMetaData=function(metaData){this._metaData=metaData,this._bitmapInfo=Object.create(metaData),this._filter=new FilterAsync(this._bitmapInfo)};ParserAsync.prototype._handleTransColor=function(transColor){this._bitmapInfo.transColor=transColor};ParserAsync.prototype._handlePalette=function(palette){this._bitmapInfo.palette=palette};ParserAsync.prototype._simpleTransparency=function(){this._metaData.alpha=!0};ParserAsync.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};ParserAsync.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};ParserAsync.prototype._complete=function(filteredData){if(this.errord)return;let normalisedBitmapData;try{let bitmapData=bitmapper.dataToBitMap(filteredData,this._bitmapInfo);normalisedBitmapData=formatNormaliser(bitmapData,this._bitmapInfo,this._options.skipRescale),bitmapData=null}catch(ex){this._handleError(ex);return}this.emit("parsed",normalisedBitmapData)}});var require_bitpacker=__commonJS(function(exports,module){var constants=require_constants();module.exports=function(dataIn,width,height,options){let outHasAlpha=[constants.COLORTYPE_COLOR_ALPHA,constants.COLORTYPE_ALPHA].indexOf(options.colorType)!==-1;if(options.colorType===options.inputColorType){let bigEndian=function(){let buffer=new ArrayBuffer(2);return new DataView(buffer).setInt16(0,256,!0),new Int16Array(buffer)[0]!==256}();if(options.bitDepth===8||options.bitDepth===16&&bigEndian)return dataIn}let data=options.bitDepth!==16?dataIn:new Uint16Array(dataIn.buffer),maxValue=255,inBpp=constants.COLORTYPE_TO_BPP_MAP[options.inputColorType];if(inBpp===4&&!options.inputHasAlpha)inBpp=3;let outBpp=constants.COLORTYPE_TO_BPP_MAP[options.colorType];if(options.bitDepth===16)maxValue=65535,outBpp*=2;let outData=Buffer.alloc(width*height*outBpp),inIndex=0,outIndex=0,bgColor=options.bgColor||{};if(bgColor.red===void 0)bgColor.red=maxValue;if(bgColor.green===void 0)bgColor.green=maxValue;if(bgColor.blue===void 0)bgColor.blue=maxValue;function getRGBA(){let red,green,blue,alpha=maxValue;switch(options.inputColorType){case constants.COLORTYPE_COLOR_ALPHA:alpha=data[inIndex+3],red=data[inIndex],green=data[inIndex+1],blue=data[inIndex+2];break;case constants.COLORTYPE_COLOR:red=data[inIndex],green=data[inIndex+1],blue=data[inIndex+2];break;case constants.COLORTYPE_ALPHA:alpha=data[inIndex+1],red=data[inIndex],green=red,blue=red;break;case constants.COLORTYPE_GRAYSCALE:red=data[inIndex],green=red,blue=red;break;default:throw Error("input color type:"+options.inputColorType+" is not supported at present")}if(options.inputHasAlpha){if(!outHasAlpha)alpha/=maxValue,red=Math.min(Math.max(Math.round((1-alpha)*bgColor.red+alpha*red),0),maxValue),green=Math.min(Math.max(Math.round((1-alpha)*bgColor.green+alpha*green),0),maxValue),blue=Math.min(Math.max(Math.round((1-alpha)*bgColor.blue+alpha*blue),0),maxValue)}return{red,green,blue,alpha}}for(let y=0;y<height;y++)for(let x=0;x<width;x++){let rgba=getRGBA(data,inIndex);switch(options.colorType){case constants.COLORTYPE_COLOR_ALPHA:case constants.COLORTYPE_COLOR:if(options.bitDepth===8){if(outData[outIndex]=rgba.red,outData[outIndex+1]=rgba.green,outData[outIndex+2]=rgba.blue,outHasAlpha)outData[outIndex+3]=rgba.alpha}else if(outData.writeUInt16BE(rgba.red,outIndex),outData.writeUInt16BE(rgba.green,outIndex+2),outData.writeUInt16BE(rgba.blue,outIndex+4),outHasAlpha)outData.writeUInt16BE(rgba.alpha,outIndex+6);break;case constants.COLORTYPE_ALPHA:case constants.COLORTYPE_GRAYSCALE:{let grayscale=(rgba.red+rgba.green+rgba.blue)/3;if(options.bitDepth===8){if(outData[outIndex]=grayscale,outHasAlpha)outData[outIndex+1]=rgba.alpha}else if(outData.writeUInt16BE(grayscale,outIndex),outHasAlpha)outData.writeUInt16BE(rgba.alpha,outIndex+2);break}default:throw Error("unrecognised color Type "+options.colorType)}inIndex+=inBpp,outIndex+=outBpp}return outData}});var require_filter_pack=__commonJS(function(exports,module){var paethPredictor=require_paeth_predictor();function filterNone(pxData,pxPos,byteWidth,rawData,rawPos){for(let x=0;x<byteWidth;x++)rawData[rawPos+x]=pxData[pxPos+x]}function filterSumNone(pxData,pxPos,byteWidth){let sum=0,length=pxPos+byteWidth;for(let i=pxPos;i<length;i++)sum+=Math.abs(pxData[i]);return sum}function filterSub(pxData,pxPos,byteWidth,rawData,rawPos,bpp){for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,val=pxData[pxPos+x]-left;rawData[rawPos+x]=val}}function filterSumSub(pxData,pxPos,byteWidth,bpp){let sum=0;for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,val=pxData[pxPos+x]-left;sum+=Math.abs(val)}return sum}function filterUp(pxData,pxPos,byteWidth,rawData,rawPos){for(let x=0;x<byteWidth;x++){let up=pxPos>0?pxData[pxPos+x-byteWidth]:0,val=pxData[pxPos+x]-up;rawData[rawPos+x]=val}}function filterSumUp(pxData,pxPos,byteWidth){let sum=0,length=pxPos+byteWidth;for(let x=pxPos;x<length;x++){let up=pxPos>0?pxData[x-byteWidth]:0,val=pxData[x]-up;sum+=Math.abs(val)}return sum}function filterAvg(pxData,pxPos,byteWidth,rawData,rawPos,bpp){for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,val=pxData[pxPos+x]-(left+up>>1);rawData[rawPos+x]=val}}function filterSumAvg(pxData,pxPos,byteWidth,bpp){let sum=0;for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,val=pxData[pxPos+x]-(left+up>>1);sum+=Math.abs(val)}return sum}function filterPaeth(pxData,pxPos,byteWidth,rawData,rawPos,bpp){for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,upleft=pxPos>0&&x>=bpp?pxData[pxPos+x-(byteWidth+bpp)]:0,val=pxData[pxPos+x]-paethPredictor(left,up,upleft);rawData[rawPos+x]=val}}function filterSumPaeth(pxData,pxPos,byteWidth,bpp){let sum=0;for(let x=0;x<byteWidth;x++){let left=x>=bpp?pxData[pxPos+x-bpp]:0,up=pxPos>0?pxData[pxPos+x-byteWidth]:0,upleft=pxPos>0&&x>=bpp?pxData[pxPos+x-(byteWidth+bpp)]:0,val=pxData[pxPos+x]-paethPredictor(left,up,upleft);sum+=Math.abs(val)}return sum}var filters={0:filterNone,1:filterSub,2:filterUp,3:filterAvg,4:filterPaeth},filterSums={0:filterSumNone,1:filterSumSub,2:filterSumUp,3:filterSumAvg,4:filterSumPaeth};module.exports=function(pxData,width,height,options,bpp){let filterTypes;if(!("filterType"in options)||options.filterType===-1)filterTypes=[0,1,2,3,4];else if(typeof options.filterType==="number")filterTypes=[options.filterType];else throw Error("unrecognised filter types");if(options.bitDepth===16)bpp*=2;let byteWidth=width*bpp,rawPos=0,pxPos=0,rawData=Buffer.alloc((byteWidth+1)*height),sel=filterTypes[0];for(let y=0;y<height;y++){if(filterTypes.length>1){let min=1/0;for(let i=0;i<filterTypes.length;i++){let sum=filterSums[filterTypes[i]](pxData,pxPos,byteWidth,bpp);if(sum<min)sel=filterTypes[i],min=sum}}rawData[rawPos]=sel,rawPos++,filters[sel](pxData,pxPos,byteWidth,rawData,rawPos,bpp),rawPos+=byteWidth,pxPos+=byteWidth}return rawData}});var require_packer=__commonJS(function(exports,module){var constants=require_constants(),CrcStream=require_crc(),bitPacker=require_bitpacker(),filter=require_filter_pack(),zlib=__require("zlib"),Packer=module.exports=function(options){if(this._options=options,options.deflateChunkSize=options.deflateChunkSize||32768,options.deflateLevel=options.deflateLevel!=null?options.deflateLevel:9,options.deflateStrategy=options.deflateStrategy!=null?options.deflateStrategy:3,options.inputHasAlpha=options.inputHasAlpha!=null?options.inputHasAlpha:!0,options.deflateFactory=options.deflateFactory||zlib.createDeflate,options.bitDepth=options.bitDepth||8,options.colorType=typeof options.colorType==="number"?options.colorType:constants.COLORTYPE_COLOR_ALPHA,options.inputColorType=typeof options.inputColorType==="number"?options.inputColorType:constants.COLORTYPE_COLOR_ALPHA,[constants.COLORTYPE_GRAYSCALE,constants.COLORTYPE_COLOR,constants.COLORTYPE_COLOR_ALPHA,constants.COLORTYPE_ALPHA].indexOf(options.colorType)===-1)throw Error("option color type:"+options.colorType+" is not supported at present");if([constants.COLORTYPE_GRAYSCALE,constants.COLORTYPE_COLOR,constants.COLORTYPE_COLOR_ALPHA,constants.COLORTYPE_ALPHA].indexOf(options.inputColorType)===-1)throw Error("option input color type:"+options.inputColorType+" is not supported at present");if(options.bitDepth!==8&&options.bitDepth!==16)throw Error("option bit depth:"+options.bitDepth+" is not supported at present")};Packer.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Packer.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Packer.prototype.filterData=function(data,width,height){let packedData=bitPacker(data,width,height,this._options),bpp=constants.COLORTYPE_TO_BPP_MAP[this._options.colorType];return filter(packedData,width,height,this._options,bpp)};Packer.prototype._packChunk=function(type,data){let len=data?data.length:0,buf=Buffer.alloc(len+12);if(buf.writeUInt32BE(len,0),buf.writeUInt32BE(type,4),data)data.copy(buf,8);return buf.writeInt32BE(CrcStream.crc32(buf.slice(4,buf.length-4)),buf.length-4),buf};Packer.prototype.packGAMA=function(gamma){let buf=Buffer.alloc(4);return buf.writeUInt32BE(Math.floor(gamma*constants.GAMMA_DIVISION),0),this._packChunk(constants.TYPE_gAMA,buf)};Packer.prototype.packIHDR=function(width,height){let buf=Buffer.alloc(13);return buf.writeUInt32BE(width,0),buf.writeUInt32BE(height,4),buf[8]=this._options.bitDepth,buf[9]=this._options.colorType,buf[10]=0,buf[11]=0,buf[12]=0,this._packChunk(constants.TYPE_IHDR,buf)};Packer.prototype.packIDAT=function(data){return this._packChunk(constants.TYPE_IDAT,data)};Packer.prototype.packIEND=function(){return this._packChunk(constants.TYPE_IEND,null)}});var require_packer_async=__commonJS(function(exports,module){var util=__require("util"),Stream=__require("stream"),constants=require_constants(),Packer=require_packer(),PackerAsync=module.exports=function(opt){Stream.call(this);let options=opt||{};this._packer=new Packer(options),this._deflate=this._packer.createDeflate(),this.readable=!0};util.inherits(PackerAsync,Stream);PackerAsync.prototype.pack=function(data,width,height,gamma){if(this.emit("data",Buffer.from(constants.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(width,height)),gamma)this.emit("data",this._packer.packGAMA(gamma));let filteredData=this._packer.filterData(data,width,height);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(compressedData){this.emit("data",this._packer.packIDAT(compressedData))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(filteredData)}});var require_sync_inflate=__commonJS(function(exports,module){var assert=__require("assert").ok,zlib=__require("zlib"),util=__require("util"),kMaxLength=__require("buffer").kMaxLength;function Inflate(opts){if(!(this instanceof Inflate))return new Inflate(opts);if(opts&&opts.chunkSize<zlib.Z_MIN_CHUNK)opts.chunkSize=zlib.Z_MIN_CHUNK;if(zlib.Inflate.call(this,opts),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,opts&&opts.maxLength!=null)this._maxLength=opts.maxLength}function createInflate(opts){return new Inflate(opts)}function _close(engine,callback){if(callback)process.nextTick(callback);if(!engine._handle)return;engine._handle.close(),engine._handle=null}Inflate.prototype._processChunk=function(chunk,flushFlag,asyncCb){if(typeof asyncCb==="function")return zlib.Inflate._processChunk.call(this,chunk,flushFlag,asyncCb);let self=this,availInBefore=chunk&&chunk.length,availOutBefore=this._chunkSize-this._offset,leftToInflate=this._maxLength,inOff=0,buffers=[],nread=0,error;this.on("error",function(err){error=err});function handleChunk(availInAfter,availOutAfter){if(self._hadError)return;let have=availOutBefore-availOutAfter;if(assert(have>=0,"have should not go down"),have>0){let out=self._buffer.slice(self._offset,self._offset+have);if(self._offset+=have,out.length>leftToInflate)out=out.slice(0,leftToInflate);if(buffers.push(out),nread+=out.length,leftToInflate-=out.length,leftToInflate===0)return!1}if(availOutAfter===0||self._offset>=self._chunkSize)availOutBefore=self._chunkSize,self._offset=0,self._buffer=Buffer.allocUnsafe(self._chunkSize);if(availOutAfter===0)return inOff+=availInBefore-availInAfter,availInBefore=availInAfter,!0;return!1}assert(this._handle,"zlib binding closed");let res;do res=this._handle.writeSync(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore),res=res||this._writeState;while(!this._hadError&&handleChunk(res[0],res[1]));if(this._hadError)throw error;if(nread>=kMaxLength)throw _close(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+kMaxLength.toString(16)+" bytes");let buf=Buffer.concat(buffers,nread);return _close(this),buf};util.inherits(Inflate,zlib.Inflate);function zlibBufferSync(engine,buffer){if(typeof buffer==="string")buffer=Buffer.from(buffer);if(!(buffer instanceof Buffer))throw TypeError("Not a string or buffer");let flushFlag=engine._finishFlushFlag;if(flushFlag==null)flushFlag=zlib.Z_FINISH;return engine._processChunk(buffer,flushFlag)}function inflateSync(buffer,opts){return zlibBufferSync(new Inflate(opts),buffer)}module.exports=exports=inflateSync;exports.Inflate=Inflate;exports.createInflate=createInflate;exports.inflateSync=inflateSync});var require_sync_reader=__commonJS(function(exports,module){var SyncReader=module.exports=function(buffer){this._buffer=buffer,this._reads=[]};SyncReader.prototype.read=function(length,callback){this._reads.push({length:Math.abs(length),allowLess:length<0,func:callback})};SyncReader.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let read=this._reads[0];if(this._buffer.length&&(this._buffer.length>=read.length||read.allowLess)){this._reads.shift();let buf=this._buffer;this._buffer=buf.slice(read.length),read.func.call(this,buf.slice(0,read.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 require_filter_parse_sync=__commonJS(function(exports){var SyncReader=require_sync_reader(),Filter=require_filter_parse();exports.process=function(inBuffer,bitmapInfo){let outBuffers=[],reader=new SyncReader(inBuffer);return new Filter(bitmapInfo,{read:reader.read.bind(reader),write:function(bufferPart){outBuffers.push(bufferPart)},complete:function(){}}).start(),reader.process(),Buffer.concat(outBuffers)}});var require_parser_sync=__commonJS(function(exports,module){var hasSyncZlib=!0,zlib=__require("zlib"),inflateSync=require_sync_inflate();if(!zlib.deflateSync)hasSyncZlib=!1;var SyncReader=require_sync_reader(),FilterSync=require_filter_parse_sync(),Parser=require_parser(),bitmapper=require_bitmapper(),formatNormaliser=require_format_normaliser();module.exports=function(buffer,options){if(!hasSyncZlib)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let err;function handleError(_err_){err=_err_}let metaData;function handleMetaData(_metaData_){metaData=_metaData_}function handleTransColor(transColor){metaData.transColor=transColor}function handlePalette(palette){metaData.palette=palette}function handleSimpleTransparency(){metaData.alpha=!0}let gamma;function handleGamma(_gamma_){gamma=_gamma_}let inflateDataList=[];function handleInflateData(inflatedData){inflateDataList.push(inflatedData)}let reader=new SyncReader(buffer);if(new Parser(options,{read:reader.read.bind(reader),error:handleError,metadata:handleMetaData,gamma:handleGamma,palette:handlePalette,transColor:handleTransColor,inflateData:handleInflateData,simpleTransparency:handleSimpleTransparency}).start(),reader.process(),err)throw err;let inflateData=Buffer.concat(inflateDataList);inflateDataList.length=0;let inflatedData;if(metaData.interlace)inflatedData=zlib.inflateSync(inflateData);else{let imageSize=((metaData.width*metaData.bpp*metaData.depth+7>>3)+1)*metaData.height;inflatedData=inflateSync(inflateData,{chunkSize:imageSize,maxLength:imageSize})}if(inflateData=null,!inflatedData||!inflatedData.length)throw Error("bad png - invalid inflate data response");let unfilteredData=FilterSync.process(inflatedData,metaData);inflateData=null;let bitmapData=bitmapper.dataToBitMap(unfilteredData,metaData);unfilteredData=null;let normalisedBitmapData=formatNormaliser(bitmapData,metaData,options.skipRescale);return metaData.data=normalisedBitmapData,metaData.gamma=gamma||0,metaData}});var require_packer_sync=__commonJS(function(exports,module){var hasSyncZlib=!0,zlib=__require("zlib");if(!zlib.deflateSync)hasSyncZlib=!1;var constants=require_constants(),Packer=require_packer();module.exports=function(metaData,opt){if(!hasSyncZlib)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let packer=new Packer(opt||{}),chunks=[];if(chunks.push(Buffer.from(constants.PNG_SIGNATURE)),chunks.push(packer.packIHDR(metaData.width,metaData.height)),metaData.gamma)chunks.push(packer.packGAMA(metaData.gamma));let filteredData=packer.filterData(metaData.data,metaData.width,metaData.height),compressedData=zlib.deflateSync(filteredData,packer.getDeflateOptions());if(filteredData=null,!compressedData||!compressedData.length)throw Error("bad png - invalid compressed data response");return chunks.push(packer.packIDAT(compressedData)),chunks.push(packer.packIEND()),Buffer.concat(chunks)}});var require_png_sync=__commonJS(function(exports){var parse=require_parser_sync(),pack=require_packer_sync();exports.read=function(buffer,options){return parse(buffer,options||{})};exports.write=function(png,options){return pack(png,options)}});var require_png=__commonJS(function(exports){var util=__require("util"),Stream=__require("stream"),Parser=require_parser_async(),Packer=require_packer_async(),PNGSync=require_png_sync(),PNG=exports.PNG=function(options){if(Stream.call(this),options=options||{},this.width=options.width|0,this.height=options.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,options.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new Parser(options),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(data){this.data=data,this.emit("parsed",data)}.bind(this)),this._packer=new Packer(options),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"))};util.inherits(PNG,Stream);PNG.sync=PNGSync;PNG.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};PNG.prototype.parse=function(data,callback){if(callback){let onParsed,onError;onParsed=function(parsedData){this.removeListener("error",onError),this.data=parsedData,callback(null,this)}.bind(this),onError=function(err){this.removeListener("parsed",onParsed),callback(err,null)}.bind(this),this.once("parsed",onParsed),this.once("error",onError)}return this.end(data),this};PNG.prototype.write=function(data){return this._parser.write(data),!0};PNG.prototype.end=function(data){this._parser.end(data)};PNG.prototype._metadata=function(metadata){this.width=metadata.width,this.height=metadata.height,this.emit("metadata",metadata)};PNG.prototype._gamma=function(gamma){this.gamma=gamma};PNG.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};PNG.bitblt=function(src,dst,srcX,srcY,width,height,deltaX,deltaY){if(srcX|=0,srcY|=0,width|=0,height|=0,deltaX|=0,deltaY|=0,srcX>src.width||srcY>src.height||srcX+width>src.width||srcY+height>src.height)throw Error("bitblt reading outside image");if(deltaX>dst.width||deltaY>dst.height||deltaX+width>dst.width||deltaY+height>dst.height)throw Error("bitblt writing outside image");for(let y=0;y<height;y++)src.data.copy(dst.data,(deltaY+y)*dst.width+deltaX<<2,(srcY+y)*src.width+srcX<<2,(srcY+y)*src.width+srcX+width<<2)};PNG.prototype.bitblt=function(dst,srcX,srcY,width,height,deltaX,deltaY){return PNG.bitblt(this,dst,srcX,srcY,width,height,deltaX,deltaY),this};PNG.adjustGamma=function(src){if(src.gamma){for(let y=0;y<src.height;y++)for(let x=0;x<src.width;x++){let idx=src.width*y+x<<2;for(let i=0;i<3;i++){let sample=src.data[idx+i]/255;sample=Math.pow(sample,0.45454545454545453/src.gamma),src.data[idx+i]=Math.round(sample*255)}}src.gamma=0}};PNG.prototype.adjustGamma=function(){PNG.adjustGamma(this)}});var require_react_development=__commonJS(function(exports,module){(function(){function defineDeprecationWarning(methodName,info){Object.defineProperty(Component.prototype,methodName,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",info[0],info[1])}})}function getIteratorFn(maybeIterable){if(maybeIterable===null||typeof maybeIterable!=="object")return null;return maybeIterable=MAYBE_ITERATOR_SYMBOL&&maybeIterable[MAYBE_ITERATOR_SYMBOL]||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(props,context,updater){this.props=props,this.context=context,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}function ComponentDummy(){}function PureComponent(props,context,updater){this.props=props,this.context=context,this.refs=emptyObject,this.updater=updater||ReactNoopUpdateQueue}function noop(){}function testStringCoercion(value){return""+value}function checkKeyStringCoercion(value){try{testStringCoercion(value);var JSCompiler_inline_result=!1}catch(e){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:return"Fragment";case REACT_PROFILER_TYPE:return"Profiler";case REACT_STRICT_MODE_TYPE:return"StrictMode";case REACT_SUSPENSE_TYPE: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:return"Portal";case REACT_CONTEXT_TYPE:return type.displayName||"Context";case REACT_CONSUMER_TYPE:return(type._context.displayName||"Context")+".Consumer";case REACT_FORWARD_REF_TYPE:var innerType=type.render;return type=type.displayName,type||(type=innerType.displayName||innerType.name||"",type=type!==""?"ForwardRef("+type+")":"ForwardRef"),type;case REACT_MEMO_TYPE:return innerType=type.displayName||null,innerType!==null?innerType:getComponentNameFromType(type.type)||"Memo";case REACT_LAZY_TYPE:innerType=type._payload,type=type._init;try{return getComponentNameFromType(type(innerType))}catch(x){}}return null}function getTaskName(type){if(type===REACT_FRAGMENT_TYPE)return"<>";if(typeof type==="object"&&type!==null&&type.$$typeof===REACT_LAZY_TYPE)return"<...>";try{var name=getComponentNameFromType(type);return name?"<"+name+">":"<...>"}catch(x){return"<...>"}}function getOwner(){var dispatcher=ReactSharedInternals.A;return dispatcher===null?null:dispatcher.getOwner()}function UnknownOwner(){return Error("react-stack-top-frame")}function hasValidKey(config){if(hasOwnProperty.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?componentName:null}function ReactElement(type,key,props,owner,debugStack,debugTask){var refProp=props.ref;return type={$$typeof:REACT_ELEMENT_TYPE,type,key,props,_owner:owner},(refProp!==void 0?refProp:null)!==null?Object.defineProperty(type,"ref",{enumerable:!1,get:elementRefGetterWithDeprecationWarning}):Object.defineProperty(type,"ref",{enumerable:!1,value:null}),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(oldElement,newKey){return newKey=ReactElement(oldElement.type,newKey,oldElement.props,oldElement._owner,oldElement._debugStack,oldElement._debugTask),oldElement._store&&(newKey._store.validated=oldElement._store.validated),newKey}function validateChildKeys(node){isValidElement(node)?node._store&&(node._store.validated=1):typeof node==="object"&&node!==null&&node.$$typeof===REACT_LAZY_TYPE&&(node._payload.status==="fulfilled"?isValidElement(node._payload.value)&&node._payload.value._store&&(node._payload.value._store.validated=1):node._store&&(node._store.validated=1))}function isValidElement(object){return typeof object==="object"&&object!==null&&object.$$typeof===REACT_ELEMENT_TYPE}function escape(key){var escaperLookup={"=":"=0",":":"=2"};return"$"+key.replace(/[=:]/g,function(match){return escaperLookup[match]})}function getElementKey(element,index){return typeof element==="object"&&element!==null&&element.key!=null?(checkKeyStringCoercion(element.key),escape(""+element.key)):index.toString(36)}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,noop):(thenable.status="pending",thenable.then(function(fulfilledValue){thenable.status==="pending"&&(thenable.status="fulfilled",thenable.value=fulfilledValue)},function(error){thenable.status==="pending"&&(thenable.status="rejected",thenable.reason=error)})),thenable.status){case"fulfilled":return thenable.value;case"rejected":throw thenable.reason}}throw thenable}function mapIntoArray(children,array,escapedPrefix,nameSoFar,callback){var type=typeof children;if(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:case REACT_PORTAL_TYPE:invokeCallback=!0;break;case REACT_LAZY_TYPE:return invokeCallback=children._init,mapIntoArray(invokeCallback(children._payload),array,escapedPrefix,nameSoFar,callback)}}if(invokeCallback){invokeCallback=children,callback=callback(invokeCallback);var childKey=nameSoFar===""?"."+getElementKey(invokeCallback,0):nameSoFar;return isArrayImpl(callback)?(escapedPrefix="",childKey!=null&&(escapedPrefix=childKey.replace(userProvidedKeyEscapeRegex,"$&/")+"/"),mapIntoArray(callback,array,escapedPrefix,"",function(c){return c})):callback!=null&&(isValidElement(callback)&&(callback.key!=null&&(invokeCallback&&invokeCallback.key===callback.key||checkKeyStringCoercion(callback.key)),escapedPrefix=cloneAndReplaceKey(callback,escapedPrefix+(callback.key==null||invokeCallback&&invokeCallback.key===callback.key?"":(""+callback.key).replace(userProvidedKeyEscapeRegex,"$&/")+"/")+childKey),nameSoFar!==""&&invokeCallback!=null&&isValidElement(invokeCallback)&&invokeCallback.key==null&&invokeCallback._store&&!invokeCallback._store.validated&&(escapedPrefix._store.validated=2),callback=escapedPrefix),array.push(callback)),1}if(invokeCallback=0,childKey=nameSoFar===""?".":nameSoFar+":",isArrayImpl(children))for(var i=0;i<children.length;i++)nameSoFar=children[i],type=childKey+getElementKey(nameSoFar,i),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback);else if(i=getIteratorFn(children),typeof i==="function")for(i===children.entries&&(didWarnAboutMaps||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),didWarnAboutMaps=!0),children=i.call(children),i=0;!(nameSoFar=children.next()).done;)nameSoFar=nameSoFar.value,type=childKey+getElementKey(nameSoFar,i++),invokeCallback+=mapIntoArray(nameSoFar,array,escapedPrefix,type,callback);else if(type==="object"){if(typeof children.then==="function")return mapIntoArray(resolveThenable(children),array,escapedPrefix,nameSoFar,callback);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){if(children==null)return children;var result=[],count=0;return mapIntoArray(children,result,"","",function(child){return func.call(context,child,count++)}),result}function lazyInitializer(payload){if(payload._status===-1){var ioInfo=payload._ioInfo;ioInfo!=null&&(ioInfo.start=ioInfo.end=performance.now()),ioInfo=payload._result;var thenable=ioInfo();if(thenable.then(function(moduleObject){if(payload._status===0||payload._status===-1){payload._status=1,payload._result=moduleObject;var _ioInfo=payload._ioInfo;_ioInfo!=null&&(_ioInfo.end=performance.now()),thenable.status===void 0&&(thenable.status="fulfilled",thenable.value=moduleObject)}},function(error){if(payload._status===0||payload._status===-1){payload._status=2,payload._result=error;var _ioInfo2=payload._ioInfo;_ioInfo2!=null&&(_ioInfo2.end=performance.now()),thenable.status===void 0&&(thenable.status="rejected",thenable.reason=error)}}),ioInfo=payload._ioInfo,ioInfo!=null){ioInfo.value=thenable;var displayName=thenable.displayName;typeof displayName==="string"&&(ioInfo.name=displayName)}payload._status===-1&&(payload._status=0,payload._result=thenable)}if(payload._status===1)return ioInfo=payload._result,ioInfo===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
3
3
|
|
|
4
4
|
Your code should look like:
|
|
5
5
|
const MyComponent = lazy(() => import('./MyComponent'))
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-7a45tn73.js";import{localDesignOf}from"./chunk-qan5dnjt.js";import"./chunk-m1wp8cpt.js";import"./chunk-a9mgvspm.js";import"./chunk-80fjfyha.js";import{AGENT_IDS,PROJECT_AGENT_IDS,GLOBAL_AGENT_IDS,resolveProjectRoot,MANUAL_AGENT_ID,manualSetupText,askAgentWiring,localDesignScopeProblem,connect}from"./chunk-vjrn10xr.js";import"./chunk-zqtz23xk.js";import{DesignFolderFormatError,assertFolderFormatCurrent}from"./chunk-shac6bat.js";import{fail}from"./chunk-s23gtejf.js";import{createProgress}from"./chunk-pjtg3wnm.js";import{DESIGN_ARG_DESCRIPTION,resolveDesign}from"./chunk-dj1pp4e3.js";import"./chunk-6zr596r2.js";import{require_picocolors}from"./chunk-jrsknzjt.js";import{__toESM,defineCommand}from"./chunk-2smsg2ct.js";import{resolve}from"path";var import_picocolors=__toESM(require_picocolors(),1);var connect_default=defineCommand({meta:{name:"connect",description:"Wire the velloo MCP server into your AI coding agent's config"},args:{design:{type:"positional",required:!1,description:DESIGN_ARG_DESCRIPTION},agent:{type:"string",description:`Comma-separated agents: ${AGENT_IDS.join(", ")}, manual \u2014 print the config for any other agent (default ${PROJECT_AGENT_IDS.join(",")})`},projectRoot:{type:"string",description:"Where to write the config (default: the velloo.json root that registers the folder, else the nearest package.json above it)"},http:{type:"boolean",default:!1,description:"Wire the HTTP transport (agent dials a running server) instead of stdio"},mcpUrl:{type:"string",description:"MCP server URL for --http, as printed by `velloo mcp --http`"},skill:{type:"boolean",default:!0,description:"Install the velloo-design Claude Code skill into .claude/skills"}},async run({args}){let folder=await resolveDesign(args.design,"connect",{interactive:!0});try{assertFolderFormatCurrent(folder)}catch(err){if(!(err instanceof DesignFolderFormatError))throw err;console.log(import_picocolors.default.yellow(`\u26A0 ${err.message.slice(8)}`))}let interactive=Boolean(process.stdin.isTTY),agents,manual=!1,local=localDesignOf(folder)!==null;if(args.agent){agents=args.agent.split(",").map((s)=>s.trim()).filter(Boolean);let problem=localDesignScopeProblem(folder,agents);if(problem)fail("connect",problem)}else if(interactive){let wiring=await askAgentWiring({projectRoot:await resolveProjectRoot(folder),globalOnly:local});if(wiring===null)fail("connect","cancelled.");if(wiring.agents.length===0&&!wiring.manual){console.log(import_picocolors.default.dim("No agents selected \u2014 nothing wired."));return}manual=wiring.manual,agents=wiring.agents}else agents=local?GLOBAL_AGENT_IDS:PROJECT_AGENT_IDS;if(agents.includes(MANUAL_AGENT_ID))manual=!0,agents=agents.filter((id)=>id!==MANUAL_AGENT_ID);if(manual){console.log(""),console.log(import_picocolors.default.bold(" Manual MCP setup"));for(let line of manualSetupText().split(`
|
|
3
3
|
`))console.log(` ${line}`);console.log("")}if(agents.length===0)return;let progress=createProgress();progress.start("connecting agent");let result;try{result=await connect({designFolder:folder,agents,projectRoot:args.projectRoot?resolve(args.projectRoot):void 0,transport:args.http?"http":"stdio",mcpUrl:args.mcpUrl,installSkill:args.skill})}catch(error){throw progress.fail("agent connection failed"),error}if(result.unknownAgents.length>0)progress.fail("agent connection failed"),fail("connect",`unknown agent(s): ${result.unknownAgents.join(", ")}. Valid: ${AGENT_IDS.join(", ")}.`);progress.succeed("connected agent"),console.log(""),console.log(import_picocolors.default.green("\u2713 Connected velloo to your agent.")),console.log("");for(let c of result.configs)console.log(` ${c.action==="created"?"wrote ":"updated "} ${import_picocolors.default.cyan(c.path)}`);if(result.plugin)console.log(` plugin ${import_picocolors.default.cyan("velloo@velloo")} ${import_picocolors.default.dim(`(skills + commands + subagents \u2014 local marketplace at ${result.plugin.marketplaceDir})`)}`);for(let s of result.skills??[])console.log(` skill ${import_picocolors.default.cyan(s.path??s.name)}`);if(result.geminiExtension)console.log(` gemini ${import_picocolors.default.cyan(result.geminiExtension.dir)} ${result.geminiExtension.linked?import_picocolors.default.dim("(linked)"):import_picocolors.default.dim(`(link it: gemini extensions link ${result.geminiExtension.dir})`)}`);if(result.cursorRules?.installed&&result.cursorRules.path)console.log(` rule ${import_picocolors.default.cyan(result.cursorRules.path)}`);let designArg=args.design?` ${args.design}`:"";if(console.log(""),console.log(import_picocolors.default.bold(" Next")),result.transport==="http")console.log(` 1. ${import_picocolors.default.cyan(`velloo mcp --http${designArg}`)} ${import_picocolors.default.dim("\u2014 starts the MCP server your agent dials")}`),console.log(" 2. Restart your agent so it loads the new MCP config.");else console.log(` 1. Restart your agent so it loads the new MCP config ${import_picocolors.default.dim("\u2014 it starts velloo itself")}.`),console.log(` 2. ${import_picocolors.default.cyan(`velloo run${designArg}`)} ${import_picocolors.default.dim("\u2014 optional: open the canvas to watch")}`);console.log("")}});export{connect_default as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-m1wp8cpt.js";import"./chunk-7a45tn73.js";import{normalizeCloudUrl,loadCredential,listCredentials,deleteCredential,clearCredentials,revokeCredential}from"./chunk-ykdx12na.js";import{defaultCloudUrl}from"./chunk-6zr596r2.js";import{defineCommand}from"./chunk-2smsg2ct.js";var logout_default=defineCommand({meta:{name:"logout",description:"Log out of velloo-cloud (signs the CLI token out and removes it)"},args:{url:{type:"string",description:"velloo-cloud base URL (default: $VELLOO_CLOUD_URL or the built-in default)"},all:{type:"boolean",default:!1,description:"Remove saved credentials for every cloud"}},async run({args}){if(args.all){await Promise.all(Object.entries(await listCredentials()).map(([cloudUrl,credential])=>revokeCredential(cloudUrl,credential.token)));let count=await clearCredentials();console.log(count>0?`velloo logout: removed credentials for ${count} cloud${count===1?"":"s"}`:"velloo logout: no saved credentials");return}let cloudUrl=args.url?normalizeCloudUrl(args.url):defaultCloudUrl(),existing=await loadCredential(cloudUrl);if(existing)await revokeCredential(cloudUrl,existing.token);if(await deleteCredential(cloudUrl))console.log(`velloo logout: logged out of ${cloudUrl}${existing?.email?` (${existing.email})`:""}`);else console.log(`velloo logout: not logged in to ${cloudUrl}`)}});export{logout_default as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{CURRENT_SCHEMA_VERSION}from"./chunk-
|
|
2
|
+
import{CURRENT_SCHEMA_VERSION}from"./chunk-7a45tn73.js";import{localDesignOf,recordedDesignName}from"./chunk-qan5dnjt.js";import{AGENTS,designArgumentFor,agentRootCandidates,writeAgentConfig,refreshAgentArtifacts}from"./chunk-vjrn10xr.js";import{daemonRoot,readLock,isLive,stopDaemon}from"./chunk-shac6bat.js";import{fail}from"./chunk-s23gtejf.js";import{installedVellooBin,upgradeInstalledVelloo}from"./chunk-npsg7btt.js";import{createProgress}from"./chunk-pjtg3wnm.js";import{upgradeFolder}from"./chunk-rfrbnw8r.js";import{DESIGN_ARG_DESCRIPTION,resolveDesign,checkoutDesigns}from"./chunk-dj1pp4e3.js";import{require_picocolors}from"./chunk-jrsknzjt.js";import{__toESM,defineCommand}from"./chunk-2smsg2ct.js";import{resolve}from"path";var import_picocolors=__toESM(require_picocolors(),1);import{readFile}from"fs/promises";import{homedir}from"os";var isStrings=(value)=>Array.isArray(value)&&value.every((item)=>typeof item==="string");function asEntry(value){if(value===null||typeof value!=="object")return null;let{command,args}=value;return typeof command==="string"&&isStrings(args)?{command,args}:null}function readStdioEntry(content,format){try{switch(format){case"json":return asEntry(JSON.parse(content).mcpServers?.velloo);case"vscode-json":return asEntry(JSON.parse(content).servers?.velloo);case"opencode-json":{let command=JSON.parse(content).mcp?.velloo?.command;return isStrings(command)&&command[0]?{command:command[0],args:command.slice(1)}:null}case"codex-toml":return asEntry(Bun.TOML.parse(content).mcp_servers?.velloo);case"continue-block":return asEntry(Bun.YAML.parse(content).mcpServers?.[0]);case"continue-config":return null}}catch{return null}}async function repinAgentConfigs(opts){if(localDesignOf(opts.designFolder))return[];let homeDir=opts.homeDir??homedir(),names=new Set(opts.names),rewritten=[];for(let projectRoot of opts.projectRoots){let designArg=await designArgumentFor(projectRoot,opts.designFolder),desired=designArg?["mcp",designArg]:["mcp"];for(let agent of Object.values(AGENTS)){if(agent.scope!=="project"||agent.gui)continue;let path=agent.path(projectRoot,homeDir),content;try{content=await readFile(path,"utf8")}catch{continue}let entry=readStdioEntry(content,agent.format),pinned=entry?.args.length===2&&entry.args[0]==="mcp"?entry.args[1]:void 0;if(!entry||pinned===void 0||!names.has(pinned)||pinned===desired[1])continue;await writeAgentConfig(projectRoot,agent,{transport:"stdio",command:entry.command,args:desired},homeDir),rewritten.push(path)}}return rewritten}async function targetFolders(arg){if(arg)return[await resolveDesign(arg,"upgrade",{requireConfig:!0})];return checkoutDesigns(resolve("."))}var upgrade_default=defineCommand({meta:{name:"upgrade",description:"Upgrade Velloo and migrate designs to the current format \u2014 every design in this checkout, or the one named"},args:{design:{type:"positional",required:!1,description:DESIGN_ARG_DESCRIPTION},"dry-run":{type:"boolean",default:!1,description:"Show what would change without writing"},check:{type:"boolean",default:!1,description:"Check for a Velloo update without installing it"},"binary-only":{type:"boolean",default:!1,description:"Upgrade the Velloo installation and leave the designs alone"},"design-only":{type:"boolean",default:!1,description:"Migrate the designs with this Velloo, without self-upgrading first (same as `velloo design upgrade`)"},skills:{type:"boolean",default:!0,description:"Also refresh the installed agent skills / plugin / rules to this velloo's versions"}},async run({args}){let dryRun=args["dry-run"]||args.check,folders=args["binary-only"]?[]:await targetFolders(args.design),outcome=null;if(!(args["design-only"]||args["folder-only"]===!0))try{outcome=await upgradeInstalledVelloo({checkOnly:dryRun})}catch(error){let message=error instanceof Error?error.message:String(error);if(folders.length===0)fail("upgrade",message);console.log(import_picocolors.default.dim(`velloo: skipping the self-upgrade \u2014 ${message}`))}if(folders.length===0)return;if(outcome?.upgraded){let bin=installedVellooBin();if(bin){for(let folder of folders){let argv=[bin,"upgrade",folder,"--design-only",...args.skills?[]:["--no-skills"]];if(await Bun.spawn(argv,{stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...process.env,VELLOO_DISABLE_UPDATE_CHECK:"1"}}).exited!==0)fail("upgrade",`the upgraded velloo could not migrate ${folder}`)}return}console.log(import_picocolors.default.dim(`velloo: could not locate the upgraded velloo \u2014 run \`velloo upgrade\` again to migrate ${folders.length===1?"the design":"the designs"}.`));return}for(let folder of folders)await migrateFolder2(folder,{dryRun,skills:args.skills})}});async function migrateFolder2(folder,opts){let{dryRun}=opts,progress=createProgress();progress.start(dryRun?"checking upgrade":"preparing upgrade");let stopped=!1,result;try{if(!dryRun){let root=daemonRoot(folder),running=await readLock(root);if(running&&await isLive(running))progress.step("stopping running canvas");stopped=await stopDaemon(root)}progress.step(dryRun?"checking design folder":"upgrading design folder"),result=await upgradeFolder(folder,{dryRun})}catch(err){progress.fail("upgrade failed"),fail("upgrade",err instanceof Error?err.message:String(err))}let refreshed=[],repinned=[];try{let name=recordedDesignName(folder);if(!dryRun&&name)repinned=await repinAgentConfigs({projectRoots:await agentRootCandidates(folder),designFolder:folder,names:[name]});if(opts.skills&&!dryRun){progress.step("refreshing agent guidance");let projectRoots=await agentRootCandidates(folder);({refreshed}=await refreshAgentArtifacts({projectRoots,designFolder:folder}))}progress.succeed(dryRun?"upgrade check complete":"upgrade complete")}catch(error){throw progress.fail("upgrade failed"),error}if(stopped)console.log("velloo: stopped the running canvas for this folder.");if(result.applied.length===0){console.log(`velloo: ${folder} is already at schema version ${CURRENT_SCHEMA_VERSION}.`);for(let file of result.changedFiles)console.log(` ${dryRun?"~":"\u2713"} ${file} (designs list format)`)}else{console.log(`velloo: ${dryRun?"would migrate":"migrated"} ${folder} from schema version ${result.from} to ${result.to}:`);for(let step of result.applied)console.log(` - ${step}`);for(let file of result.changedFiles)console.log(` ${dryRun?"~":"\u2713"} ${file}`);if(!dryRun)console.log("velloo: folder validated against the current schemas.")}if(repinned.length>0){console.log(""),console.log(import_picocolors.default.green("\u2713 Agent MCP configs now find the design without naming it:"));for(let path of repinned)console.log(` ${import_picocolors.default.cyan(path)}`)}if(refreshed.length>0){console.log(""),console.log(import_picocolors.default.green("\u2713 Refreshed agent guidance to this velloo:"));for(let line of refreshed)console.log(` ${import_picocolors.default.cyan(line)}`)}}
|
|
3
3
|
export{repinAgentConfigs,upgrade_default,migrateFolder2};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{detectTailwindMajor}from"./chunk-
|
|
2
|
+
import{detectTailwindMajor}from"./chunk-qan5dnjt.js";import{existsSync,readFileSync}from"fs";import{join}from"path";function readJson(path){try{return JSON.parse(readFileSync(path,"utf8"))}catch{return null}}function depRange(deps,name){let v=deps[name];return typeof v==="string"?v:void 0}function detectHost(appRoot){let pkg=readJson(join(appRoot,"package.json"))??{},deps={...pkg.dependencies??{},...pkg.devDependencies??{}},tailwindMajor=detectTailwindMajor(appRoot),componentsJson=readJson(join(appRoot,"components.json")),shadcn=componentsJson!==null,shadcnStyle=typeof componentsJson?.style==="string"?componentsJson.style:void 0,uiLibrary=depRange(deps,"@mui/material")?"mui":depRange(deps,"antd")?"antd":depRange(deps,"@chakra-ui/react")?"chakra":shadcn?"shadcn":void 0,unsupportedUi=uiLibrary?void 0:detectUnsupportedUi(deps);return{shadcn,shadcnStyle,tailwindMajor,globalsCssPath:findGlobalsCss(appRoot,componentsJson),...uiLibrary?{uiLibrary}:{},...unsupportedUi?{unsupportedUi}:{}}}var COMPONENT_DIR_CANDIDATES=["src/components/ui","components/ui","app/components/ui","src/app/components/ui","src/components","components"];function findComponentsDir(appRoot){return COMPONENT_DIR_CANDIDATES.find((rel)=>existsSync(join(appRoot,rel)))}function detectUnsupportedUi(deps){let known=[["@mantine/core","Mantine"],["@nextui-org/react","NextUI"],["@heroui/react","HeroUI"],["react-bootstrap","React Bootstrap"],["@fluentui/react-components","Fluent UI"],["@untitledui/icons","Untitled UI"],["@untitledui/file-icons","Untitled UI"],["react-aria-components","React Aria"]];for(let[pkg,label]of known)if(depRange(deps,pkg))return label;return}function findGlobalsCss(appRoot,componentsJson){let candidates=[componentsJson&&typeof componentsJson.tailwind?.css==="string"?componentsJson.tailwind.css:void 0,"src/app/globals.css","app/globals.css","src/styles/globals.css","styles/globals.css","src/index.css","src/globals.css","src/app.css"].filter((c)=>Boolean(c));for(let rel of candidates){let abs=join(appRoot,rel);if(existsSync(abs))return abs}return}
|
|
3
3
|
export{detectHost,findComponentsDir};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{manifestPath}from"./chunk-cvn689d5.js";import{clsx,cn,Box,require_react_jsx_dev_runtime_development,Divider,Gradient,Heading,Icon,Image2,Layer,Placeholder,Prose,SVG,Text}from"./chunk-88eqqdk1.js";import{require_react_jsx_runtime_development}from"./chunk-c6hywdvq.js";import{require_react_development,require_react_dom}from"./chunk-c4fym47a.js";import{__toESM,__commonJS,__export}from"./chunk-2smsg2ct.js";var require_tslib=__commonJS(function(exports,module){var __extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter,__generator,__exportStar,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__createBinding,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension;(function(factory){var root=typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:{};if(typeof define==="function"&&define.amd)define("tslib",["exports"],function(exports2){factory(createExporter(root,createExporter(exports2)))});else if(typeof module==="object"&&typeof exports==="object")factory(createExporter(root,createExporter(exports)));else factory(createExporter(root));function createExporter(exports2,previous){if(exports2!==root)if(typeof Object.create==="function")Object.defineProperty(exports2,"__esModule",{value:!0});else exports2.__esModule=!0;return function(id,v){return exports2[id]=previous?previous(id,v):v}}})(function(exporter){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};__extends=function(d,b){if(typeof b!=="function"&&b!==null)throw TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)},__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t},__rest=function(s,e){var t={};for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0)t[p]=s[p];if(s!=null&&typeof Object.getOwnPropertySymbols==="function"){for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)if(e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i]))t[p[i]]=s[p[i]]}return t},__decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r},__param=function(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex)}},__esDecorate=function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!=="function")throw TypeError("Function expected");return f}var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1;for(var i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!=="object")throw TypeError("Object expected");if(_=accept(result.get))descriptor.get=_;if(_=accept(result.set))descriptor.set=_;if(_=accept(result.init))initializers.unshift(_)}else if(_=accept(result))if(kind==="field")initializers.unshift(_);else descriptor[key]=_}if(target)Object.defineProperty(target,contextIn.name,descriptor);done=!0},__runInitializers=function(thisArg,initializers,value){var useValue=arguments.length>2;for(var i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__propKey=function(x){return typeof x==="symbol"?x:"".concat(x)},__setFunctionName=function(f,name,prefix){if(typeof name==="symbol")name=name.description?"[".concat(name.description,"]"):"";return Object.defineProperty(f,"name",{configurable:!0,value:prefix?"".concat(prefix," ",name):name})},__metadata=function(metadataKey,metadataValue){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(metadataKey,metadataValue)},__awaiter=function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},__generator=function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g.throw=verb(1),g.return=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if((t=_.trys,!(t=t.length>0&&t[t.length-1]))&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}},__exportStar=function(m,o){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(o,p))__createBinding(o,m,p)},__createBinding=Object.create?function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))desc={enumerable:!0,get:function(){return m[k]}};Object.defineProperty(o,k2,desc)}:function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]},__values=function(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number")return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o}}};throw TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=function(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m)return o;var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-- >0)&&!(r=i.next()).done)ar.push(r.value)}catch(error){e={error}}finally{try{if(r&&!r.done&&(m=i.return))m.call(i)}finally{if(e)throw e.error}}return ar},__spread=function(){for(var ar=[],i=0;i<arguments.length;i++)ar=ar.concat(__read(arguments[i]));return ar},__spreadArrays=function(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;for(var r=Array(s),k=0,i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r},__spreadArray=function(to,from,pack){if(pack||arguments.length===2){for(var i=0,l=from.length,ar;i<l;i++)if(ar||!(i in from)){if(!ar)ar=Array.prototype.slice.call(from,0,i);ar[i]=from[i]}}return to.concat(ar||Array.prototype.slice.call(from))},__await=function(v){return this instanceof __await?(this.v=v,this):new __await(v)},__asyncGenerator=function(thisArg,_arguments,generator){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var g=generator.apply(thisArg,_arguments||[]),i,q=[];return i=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),verb("next"),verb("throw"),verb("return",awaitReturn),i[Symbol.asyncIterator]=function(){return this},i;function awaitReturn(f){return function(v){return Promise.resolve(v).then(f,reject)}}function verb(n,f){if(g[n]){if(i[n]=function(v){return new Promise(function(a,b){q.push([n,v,a,b])>1||resume(n,v)})},f)i[n]=f(i[n])}}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){if(f(v),q.shift(),q.length)resume(q[0][0],q[0][1])}},__asyncDelegator=function(o){var i,p;return i={},verb("next"),verb("throw",function(e){throw e}),verb("return"),i[Symbol.iterator]=function(){return this},i;function verb(n,f){i[n]=o[n]?function(v){return(p=!p)?{value:__await(o[n](v)),done:!1}:f?f(v):v}:f}},__asyncValues=function(o){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var m=o[Symbol.asyncIterator],i;return m?m.call(o):(o=typeof __values==="function"?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i);function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}},__makeTemplateObject=function(cooked,raw){if(Object.defineProperty)Object.defineProperty(cooked,"raw",{value:raw});else cooked.raw=raw;return cooked};var __setModuleDefault=Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v},ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o){var ar=[];for(var k in o)if(Object.prototype.hasOwnProperty.call(o,k))ar[ar.length]=k;return ar},ownKeys(o)};__importStar=function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null){for(var k=ownKeys(mod),i=0;i<k.length;i++)if(k[i]!=="default")__createBinding(result,mod,k[i])}return __setModuleDefault(result,mod),result},__importDefault=function(mod){return mod&&mod.__esModule?mod:{default:mod}},__classPrivateFieldGet=function(receiver,state,kind,f){if(kind==="a"&&!f)throw TypeError("Private accessor was defined without a getter");if(typeof state==="function"?receiver!==state||!f:!state.has(receiver))throw TypeError("Cannot read private member from an object whose class did not declare it");return kind==="m"?f:kind==="a"?f.call(receiver):f?f.value:state.get(receiver)},__classPrivateFieldSet=function(receiver,state,value,kind,f){if(kind==="m")throw TypeError("Private method is not writable");if(kind==="a"&&!f)throw TypeError("Private accessor was defined without a setter");if(typeof state==="function"?receiver!==state||!f:!state.has(receiver))throw TypeError("Cannot write private member to an object whose class did not declare it");return kind==="a"?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value},__classPrivateFieldIn=function(state,receiver){if(receiver===null||typeof receiver!=="object"&&typeof receiver!=="function")throw TypeError("Cannot use 'in' operator on non-object");return typeof state==="function"?receiver===state:state.has(receiver)},__addDisposableResource=function(env,value,async){if(value!==null&&value!==void 0){if(typeof value!=="object"&&typeof value!=="function")throw TypeError("Object expected.");var dispose,inner;if(async){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");dispose=value[Symbol.asyncDispose]}if(dispose===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(dispose=value[Symbol.dispose],async)inner=dispose}if(typeof dispose!=="function")throw TypeError("Object not disposable.");if(inner)dispose=function(){try{inner.call(this)}catch(e){return Promise.reject(e)}};env.stack.push({value,dispose,async})}else if(async)env.stack.push({async:!0});return value};var _SuppressedError=typeof SuppressedError==="function"?SuppressedError:function(error,suppressed,message){var e=Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};__disposeResources=function(env){function fail(e){env.error=env.hasError?new _SuppressedError(e,env.error,"An error was suppressed during disposal."):e,env.hasError=!0}var r,s=0;function next(){while(r=env.stack.pop())try{if(!r.async&&s===1)return s=0,env.stack.push(r),Promise.resolve().then(next);if(r.dispose){var result=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(result).then(next,function(e){return fail(e),next()})}else s|=1}catch(e){fail(e)}if(s===1)return env.hasError?Promise.reject(env.error):Promise.resolve();if(env.hasError)throw env.error}return next()},__rewriteRelativeImportExtension=function(path,preserveJsx){if(typeof path==="string"&&/^\.\.?\//.test(path))return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js"});return path},exporter("__extends",__extends),exporter("__assign",__assign),exporter("__rest",__rest),exporter("__decorate",__decorate),exporter("__param",__param),exporter("__esDecorate",__esDecorate),exporter("__runInitializers",__runInitializers),exporter("__propKey",__propKey),exporter("__setFunctionName",__setFunctionName),exporter("__metadata",__metadata),exporter("__awaiter",__awaiter),exporter("__generator",__generator),exporter("__exportStar",__exportStar),exporter("__createBinding",__createBinding),exporter("__values",__values),exporter("__read",__read),exporter("__spread",__spread),exporter("__spreadArrays",__spreadArrays),exporter("__spreadArray",__spreadArray),exporter("__await",__await),exporter("__asyncGenerator",__asyncGenerator),exporter("__asyncDelegator",__asyncDelegator),exporter("__asyncValues",__asyncValues),exporter("__makeTemplateObject",__makeTemplateObject),exporter("__importStar",__importStar),exporter("__importDefault",__importDefault),exporter("__classPrivateFieldGet",__classPrivateFieldGet),exporter("__classPrivateFieldSet",__classPrivateFieldSet),exporter("__classPrivateFieldIn",__classPrivateFieldIn),exporter("__addDisposableResource",__addDisposableResource),exporter("__disposeResources",__disposeResources),exporter("__rewriteRelativeImportExtension",__rewriteRelativeImportExtension)})});var require_tslib2=__commonJS(function(exports,module){/*! *****************************************************************************
|
|
2
|
+
import{manifestPath}from"./chunk-cvn689d5.js";import{clsx,cn,Box,require_react_jsx_dev_runtime_development,Divider,Gradient,Heading,Icon,Image2,Layer,Placeholder,Prose,SVG,Text}from"./chunk-qan5dnjt.js";import{require_react_jsx_runtime_development}from"./chunk-8t5phg0s.js";import{require_react_development,require_react_dom}from"./chunk-a9mgvspm.js";import{__toESM,__commonJS,__export}from"./chunk-2smsg2ct.js";var require_tslib=__commonJS(function(exports,module){var __extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter,__generator,__exportStar,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__createBinding,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension;(function(factory){var root=typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:{};if(typeof define==="function"&&define.amd)define("tslib",["exports"],function(exports2){factory(createExporter(root,createExporter(exports2)))});else if(typeof module==="object"&&typeof exports==="object")factory(createExporter(root,createExporter(exports)));else factory(createExporter(root));function createExporter(exports2,previous){if(exports2!==root)if(typeof Object.create==="function")Object.defineProperty(exports2,"__esModule",{value:!0});else exports2.__esModule=!0;return function(id,v){return exports2[id]=previous?previous(id,v):v}}})(function(exporter){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};__extends=function(d,b){if(typeof b!=="function"&&b!==null)throw TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)},__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t},__rest=function(s,e){var t={};for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0)t[p]=s[p];if(s!=null&&typeof Object.getOwnPropertySymbols==="function"){for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)if(e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i]))t[p[i]]=s[p[i]]}return t},__decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r},__param=function(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex)}},__esDecorate=function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!=="function")throw TypeError("Function expected");return f}var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1;for(var i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!=="object")throw TypeError("Object expected");if(_=accept(result.get))descriptor.get=_;if(_=accept(result.set))descriptor.set=_;if(_=accept(result.init))initializers.unshift(_)}else if(_=accept(result))if(kind==="field")initializers.unshift(_);else descriptor[key]=_}if(target)Object.defineProperty(target,contextIn.name,descriptor);done=!0},__runInitializers=function(thisArg,initializers,value){var useValue=arguments.length>2;for(var i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__propKey=function(x){return typeof x==="symbol"?x:"".concat(x)},__setFunctionName=function(f,name,prefix){if(typeof name==="symbol")name=name.description?"[".concat(name.description,"]"):"";return Object.defineProperty(f,"name",{configurable:!0,value:prefix?"".concat(prefix," ",name):name})},__metadata=function(metadataKey,metadataValue){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(metadataKey,metadataValue)},__awaiter=function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},__generator=function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g.throw=verb(1),g.return=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if((t=_.trys,!(t=t.length>0&&t[t.length-1]))&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}},__exportStar=function(m,o){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(o,p))__createBinding(o,m,p)},__createBinding=Object.create?function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))desc={enumerable:!0,get:function(){return m[k]}};Object.defineProperty(o,k2,desc)}:function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]},__values=function(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number")return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o}}};throw TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=function(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m)return o;var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-- >0)&&!(r=i.next()).done)ar.push(r.value)}catch(error){e={error}}finally{try{if(r&&!r.done&&(m=i.return))m.call(i)}finally{if(e)throw e.error}}return ar},__spread=function(){for(var ar=[],i=0;i<arguments.length;i++)ar=ar.concat(__read(arguments[i]));return ar},__spreadArrays=function(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;for(var r=Array(s),k=0,i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r},__spreadArray=function(to,from,pack){if(pack||arguments.length===2){for(var i=0,l=from.length,ar;i<l;i++)if(ar||!(i in from)){if(!ar)ar=Array.prototype.slice.call(from,0,i);ar[i]=from[i]}}return to.concat(ar||Array.prototype.slice.call(from))},__await=function(v){return this instanceof __await?(this.v=v,this):new __await(v)},__asyncGenerator=function(thisArg,_arguments,generator){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var g=generator.apply(thisArg,_arguments||[]),i,q=[];return i=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),verb("next"),verb("throw"),verb("return",awaitReturn),i[Symbol.asyncIterator]=function(){return this},i;function awaitReturn(f){return function(v){return Promise.resolve(v).then(f,reject)}}function verb(n,f){if(g[n]){if(i[n]=function(v){return new Promise(function(a,b){q.push([n,v,a,b])>1||resume(n,v)})},f)i[n]=f(i[n])}}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){if(f(v),q.shift(),q.length)resume(q[0][0],q[0][1])}},__asyncDelegator=function(o){var i,p;return i={},verb("next"),verb("throw",function(e){throw e}),verb("return"),i[Symbol.iterator]=function(){return this},i;function verb(n,f){i[n]=o[n]?function(v){return(p=!p)?{value:__await(o[n](v)),done:!1}:f?f(v):v}:f}},__asyncValues=function(o){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var m=o[Symbol.asyncIterator],i;return m?m.call(o):(o=typeof __values==="function"?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i);function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}},__makeTemplateObject=function(cooked,raw){if(Object.defineProperty)Object.defineProperty(cooked,"raw",{value:raw});else cooked.raw=raw;return cooked};var __setModuleDefault=Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v},ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o){var ar=[];for(var k in o)if(Object.prototype.hasOwnProperty.call(o,k))ar[ar.length]=k;return ar},ownKeys(o)};__importStar=function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null){for(var k=ownKeys(mod),i=0;i<k.length;i++)if(k[i]!=="default")__createBinding(result,mod,k[i])}return __setModuleDefault(result,mod),result},__importDefault=function(mod){return mod&&mod.__esModule?mod:{default:mod}},__classPrivateFieldGet=function(receiver,state,kind,f){if(kind==="a"&&!f)throw TypeError("Private accessor was defined without a getter");if(typeof state==="function"?receiver!==state||!f:!state.has(receiver))throw TypeError("Cannot read private member from an object whose class did not declare it");return kind==="m"?f:kind==="a"?f.call(receiver):f?f.value:state.get(receiver)},__classPrivateFieldSet=function(receiver,state,value,kind,f){if(kind==="m")throw TypeError("Private method is not writable");if(kind==="a"&&!f)throw TypeError("Private accessor was defined without a setter");if(typeof state==="function"?receiver!==state||!f:!state.has(receiver))throw TypeError("Cannot write private member to an object whose class did not declare it");return kind==="a"?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value},__classPrivateFieldIn=function(state,receiver){if(receiver===null||typeof receiver!=="object"&&typeof receiver!=="function")throw TypeError("Cannot use 'in' operator on non-object");return typeof state==="function"?receiver===state:state.has(receiver)},__addDisposableResource=function(env,value,async){if(value!==null&&value!==void 0){if(typeof value!=="object"&&typeof value!=="function")throw TypeError("Object expected.");var dispose,inner;if(async){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");dispose=value[Symbol.asyncDispose]}if(dispose===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(dispose=value[Symbol.dispose],async)inner=dispose}if(typeof dispose!=="function")throw TypeError("Object not disposable.");if(inner)dispose=function(){try{inner.call(this)}catch(e){return Promise.reject(e)}};env.stack.push({value,dispose,async})}else if(async)env.stack.push({async:!0});return value};var _SuppressedError=typeof SuppressedError==="function"?SuppressedError:function(error,suppressed,message){var e=Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};__disposeResources=function(env){function fail(e){env.error=env.hasError?new _SuppressedError(e,env.error,"An error was suppressed during disposal."):e,env.hasError=!0}var r,s=0;function next(){while(r=env.stack.pop())try{if(!r.async&&s===1)return s=0,env.stack.push(r),Promise.resolve().then(next);if(r.dispose){var result=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(result).then(next,function(e){return fail(e),next()})}else s|=1}catch(e){fail(e)}if(s===1)return env.hasError?Promise.reject(env.error):Promise.resolve();if(env.hasError)throw env.error}return next()},__rewriteRelativeImportExtension=function(path,preserveJsx){if(typeof path==="string"&&/^\.\.?\//.test(path))return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js"});return path},exporter("__extends",__extends),exporter("__assign",__assign),exporter("__rest",__rest),exporter("__decorate",__decorate),exporter("__param",__param),exporter("__esDecorate",__esDecorate),exporter("__runInitializers",__runInitializers),exporter("__propKey",__propKey),exporter("__setFunctionName",__setFunctionName),exporter("__metadata",__metadata),exporter("__awaiter",__awaiter),exporter("__generator",__generator),exporter("__exportStar",__exportStar),exporter("__createBinding",__createBinding),exporter("__values",__values),exporter("__read",__read),exporter("__spread",__spread),exporter("__spreadArrays",__spreadArrays),exporter("__spreadArray",__spreadArray),exporter("__await",__await),exporter("__asyncGenerator",__asyncGenerator),exporter("__asyncDelegator",__asyncDelegator),exporter("__asyncValues",__asyncValues),exporter("__makeTemplateObject",__makeTemplateObject),exporter("__importStar",__importStar),exporter("__importDefault",__importDefault),exporter("__classPrivateFieldGet",__classPrivateFieldGet),exporter("__classPrivateFieldSet",__classPrivateFieldSet),exporter("__classPrivateFieldIn",__classPrivateFieldIn),exporter("__addDisposableResource",__addDisposableResource),exporter("__disposeResources",__disposeResources),exporter("__rewriteRelativeImportExtension",__rewriteRelativeImportExtension)})});var require_tslib2=__commonJS(function(exports,module){/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{snapshotVersion2}from"./chunk-cvn689d5.js";import{BoardSchema,CURRENT_SCHEMA_VERSION,ConfigSchema,isComponentNode,ScreenSchema,SnippetSchema,ThemeSchema}from"./chunk-
|
|
2
|
+
import{snapshotVersion2}from"./chunk-cvn689d5.js";import{BoardSchema,CURRENT_SCHEMA_VERSION,ConfigSchema,isComponentNode,ScreenSchema,SnippetSchema,ThemeSchema}from"./chunk-7a45tn73.js";import{parseThemeCss,writeJsonAtomic,writeText,derivePalette}from"./chunk-qan5dnjt.js";import{CHROMIUM_INSTALL_CMD,chromiumExecutable}from"./chunk-a9mgvspm.js";import{TOOL_VERSION}from"./chunk-zqtz23xk.js";import{isCancel,confirm}from"./chunk-80fjfyha.js";import{BROWSER_PROMPT_DETAIL,BROWSER_PROMPT_SIZE,installChromiumInteractive}from"./chunk-2dm4x17z.js";import{detectShell,completionsInstalled,installCompletions}from"./chunk-ph94nrc8.js";import{require_picocolors}from"./chunk-jrsknzjt.js";import{__toESM}from"./chunk-2smsg2ct.js";import{noLibVersion}from"./chunk-cxe6jjwj.js";import{MUI_VERSION}from"./chunk-mzhdrawd.js";import{ANTD_VERSION}from"./chunk-0t68szgr.js";import{CHAKRA_VERSION}from"./chunk-nwx5700b.js";import{readdir,stat}from"fs/promises";import{join}from"path";async function*walkFiles(root){let entries;try{entries=await readdir(root)}catch{return}entries.sort((a,b)=>a.localeCompare(b));for(let name of entries){if(name.startsWith("."))continue;if(name==="node_modules"||name==="dist"||name===".next")continue;let full=join(root,name),s=await stat(full).catch(()=>null);if(!s)continue;if(s.isDirectory())yield*walkFiles(full);else if(s.isFile())yield full}}async function dirExists(path){return(await stat(path).catch(()=>null))?.isDirectory()??!1}import{relative as relative3,resolve as resolve2,sep as sep3}from"path";import{readdir as readdir3}from"fs/promises";import{homedir}from"os";import{delimiter,dirname as dirname3,join as join5,relative as relative2,resolve,sep as sep2}from"path";import{readFile as readFile3,stat as stat2}from"fs/promises";import{basename as basename3,dirname as dirname2,join as join4,relative,sep}from"path";import{readFile}from"fs/promises";import{basename,join as join2}from"path";function titleCaseFromSegment(segment){if(segment==="")return"Index";if(segment==="index")return"Index";let cleaned=segment.replace(/^[_[]+|[\]]+$/g,"").replace(/[-_]+/g," ");if(!cleaned)return segment;return cleaned.charAt(0).toUpperCase()+cleaned.slice(1)}function idFromRoutePath(routePath){if(routePath==="/"||routePath==="")return"index";return routePath.replace(/^\//,"").replace(/\//g,"-").replace(/[[\]()]/g,"").replace(/^_/,"").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()||"index"}function nameFromRoutePath(routePath){if(routePath==="/"||routePath==="")return"Home";return routePath.replace(/^\//,"").split("/").map(titleCaseFromSegment).join(" / ")}var MAX_FILES=400,MAX_FILE_BYTES=262144,MAX_ROUTES=200;function isNoiseFile(file){let base=basename(file);if(/\.(test|spec|stories)\.[jt]sx?$/.test(base))return!0;return/\/(__tests__|__mocks__|mocks|stories|e2e|tests)\//.test(file)}function looksLikeRouteConfig(content){if(/\bcreate(Browser|Hash|Memory)Router\s*\(/.test(content))return!0;if(/\bcreateRoutesFromElements\s*\(/.test(content))return!0;if(/<Route[\s/>]/.test(content))return!0;return/\bpath\s*:\s*["'`]/.test(content)&&/\b(element|Component)\s*:/.test(content)}function atPropertyPosition(src,i){for(let j=i-1;j>=0;j--){let c=src[j];if(c===" "||c==="\t"||c===`
|
|
3
3
|
`||c==="\r")continue;return c==="{"||c===","}return!0}function parseObjectRoutes(src){let roots=[],stack=[],i=0,n=src.length;while(i<n){let c=src[i];if(c==='"'||c==="'"||c==="`"){let quote=c;i++;while(i<n&&src[i]!==quote)i+=src[i]==="\\"?2:1;i++;continue}if(c==="/"&&src[i+1]==="/"){let nl=src.indexOf(`
|
|
4
4
|
`,i);i=nl===-1?n:nl+1;continue}if(c==="/"&&src[i+1]==="*"){let end=src.indexOf("*/",i+2);i=end===-1?n:end+2;continue}if(c==="{"){stack.push({children:[]}),i++;continue}if(c==="}"){let node=stack.pop();if(node){let parent=stack[stack.length-1];if(parent)parent.children.push(node);else roots.push(node)}i++;continue}let top=stack[stack.length-1];if(top&&c&&/[A-Za-z]/.test(c)&&atPropertyPosition(src,i)){let rest=src.slice(i,i+200),path=rest.match(/^path\s*:\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`)/),pathValue=path?path[1]??path[2]??path[3]:void 0;if(path&&pathValue!==void 0){top.path=pathValue,i+=path[0].length;continue}let index=rest.match(/^index\s*:\s*true/);if(index){top.index=!0,i+=index[0].length;continue}let element=rest.match(/^(?:element|Component)\s*:\s*\(?\s*<?\s*([A-Z][\w.]*)/);if(element?.[1]!==void 0){top.element=element[1],i+=element[0].length;continue}}i++}return roots}function parseJsxRoutes(src){let roots=[],stack=[],open=/<Route\b/g,close=/<\/Route\s*>/g,tags=[];for(let m of src.matchAll(open)){let start=m.index,i=start+m[0].length,depth=0,attrs="";while(i<src.length){let c=src[i];if(c==='"'||c==="'"){let q=c,from=i;i++;while(i<src.length&&src[i]!==q)i+=src[i]==="\\"?2:1;i++,attrs+=src.slice(from,i);continue}if(c==="{")depth++;if(c==="}")depth--;if(c===">"&&depth===0)break;attrs+=c,i++}let selfClosing=attrs.trimEnd().endsWith("/"),node={children:[]},path=attrs.match(/\bpath\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*(?:"([^"]*)"|'([^']*)')\s*\})/),pathAttr=path?path[1]??path[2]??path[3]??path[4]:void 0;if(pathAttr!==void 0)node.path=pathAttr;if(/\bindex\b(?!\s*=\s*\{?\s*false)/.test(attrs))node.index=!0;let element=attrs.match(/\b(?:element|Component)\s*=\s*\{?\s*<?\s*([A-Z][\w.]*)/);if(element?.[1]!==void 0)node.element=element[1];tags.push({at:start,kind:"open",node,selfClosing})}for(let m of src.matchAll(close))tags.push({at:m.index,kind:"close"});tags.sort((a,b)=>a.at-b.at);for(let tag of tags)if(tag.kind==="open"&&tag.node){let parent=stack[stack.length-1];if(parent)parent.children.push(tag.node);else roots.push(tag.node);if(!tag.selfClosing)stack.push(tag.node)}else if(tag.kind==="close")stack.pop();return roots}function normalizeParams(path){return path.replace(/:(\w+)\??/g,"[$1]").replace(/\?/g,"")}function joinPaths(base,path){if(path.startsWith("/"))return path;return`${base==="/"?"":base}/${path}`.replace(/\/+/g,"/").replace(/\/$/,"")||"/"}function collectPaths(nodes,base,out){for(let node of nodes){if(out.size>=MAX_ROUTES)return;let resolved=node.path?joinPaths(base,normalizeParams(node.path)):base;if(node.children.length>0){if(collectPaths(node.children,resolved,out),node.path&&node.element&&!node.children.some((c)=>c.index))addPath(node,resolved,out);continue}if(node.index)addPath(node,base,out);else if(node.path)addPath(node,resolved,out)}}function addPath(node,routePath,out){if(node.element==="Navigate")return;if(routePath.includes("*"))return;out.set(routePath,!0)}async function scanReactRouter(appRoot){let srcDir=join2(appRoot,"src"),root=await dirExists(srcDir)?srcDir:appRoot,paths=new Map,sources=new Map,seen=0;for await(let file of walkFiles(root)){if(seen>=MAX_FILES||paths.size>=MAX_ROUTES)break;if(!/\.[jt]sx?$/.test(file)||isNoiseFile(file))continue;seen++;let content=await readFile(file,"utf8").catch(()=>null);if(!content||content.length>MAX_FILE_BYTES||!looksLikeRouteConfig(content))continue;let before=paths.size;if(collectPaths(parseObjectRoutes(content),"/",paths),collectPaths(parseJsxRoutes(content),"/",paths),paths.size>before){for(let p of paths.keys())if(!sources.has(p))sources.set(p,file)}}if(paths.size===0)return null;let routes=[...paths.keys()].map((routePath)=>({id:idFromRoutePath(routePath),name:nameFromRoutePath(routePath),routePath,sourceFile:sources.get(routePath)??root})),dedupedIds=new Set,deduped=routes.filter((r)=>{if(dedupedIds.has(r.id))return!1;return dedupedIds.add(r.id),!0});return deduped.sort((a,b)=>{if(a.id==="index")return-1;if(b.id==="index")return 1;return a.id.localeCompare(b.id)}),{framework:"react-router",routes:deduped,routesRoot:root}}import{existsSync}from"fs";import{readdir as readdir2,readFile as readFile2}from"fs/promises";import{basename as basename2,dirname,join as join3}from"path";var SKIP_DIRS=new Set(["node_modules","venv","env","__pycache__","migrations","site-packages","vendor","storage","tmp","log"]);async function collectFiles(root,match,maxDepth=5,maxFiles=500){let out=[];async function recurse(dir,depth){if(out.length>=maxFiles)return;let entries=await readdir2(dir,{withFileTypes:!0}).catch(()=>null);if(!entries)return;entries.sort((a,b)=>a.name.localeCompare(b.name));for(let entry of entries){if(out.length>=maxFiles)return;if(entry.name.startsWith("."))continue;if(entry.isDirectory()){if(SKIP_DIRS.has(entry.name)||depth>=maxDepth)continue;await recurse(join3(dir,entry.name),depth+1)}else if(entry.isFile()&&match(entry.name))out.push(join3(dir,entry.name))}}return await recurse(root,0),out}function normalizeParams2(path){return path.replace(/<(?:\w+:)?(\w+)>/g,"[$1]").replace(/\{(\w+)\??\}/g,"[$1]")}function normalizePath(raw){let trimmed=(raw.startsWith("/")?raw:`/${raw}`).replace(/\/+$/,"");return trimmed===""?"/":trimmed}function isPageRoute(routePath){let first=routePath.split("/").filter(Boolean)[0]??"";return first!=="api"&&first!=="admin"&&first!=="static"&&first!=="media"}function toRoute(routePath,sourceFile){return{id:idFromRoutePath(routePath),name:nameFromRoutePath(routePath),routePath,sourceFile}}function dedupeAndSort(routes){let seen=new Set,out=[];for(let r of routes){if(seen.has(r.id))continue;seen.add(r.id),out.push(r)}return out.sort((a,b)=>{if(a.id==="index")return-1;if(b.id==="index")return 1;return a.id.localeCompare(b.id)}),out}async function scanDjango(appRoot){let files=await collectFiles(appRoot,(n)=>n==="urls.py"),routes=[];for(let file of files){let content=await readFile2(file,"utf8").catch(()=>null);if(!content)continue;let pkgDir=dirname(file),prefix=existsSync(join3(pkgDir,"settings.py"))||pkgDir===appRoot?"":`/${basename2(pkgDir)}`,entry=/\b(?:path|re_path|url)\(\s*r?["']([^"']*)["']/g;for(let m of content.matchAll(entry)){let rest=content.slice(m.index,content.indexOf(`
|
|
5
5
|
`,m.index));if(rest.includes("include(")||rest.includes("admin.site.urls"))continue;let raw=m[1]??"";if(raw=raw.replace(/^\^/,"").replace(/\$$/,""),raw=raw.replace(/\(\?P<(\w+)>[^)]*\)/g,"[$1]"),raw=normalizeParams2(raw),/[\\^$+*?()|]/.test(raw))continue;let routePath=normalizePath(`${prefix}/${raw}`.replace(/\/+/g,"/"));if(!isPageRoute(routePath))continue;routes.push(toRoute(routePath,file))}}return dedupeAndSort(routes)}async function scanPythonDecorators(appRoot){let files=await collectFiles(appRoot,(n)=>n.endsWith(".py")),routes=[];for(let file of files){let content=await readFile2(file,"utf8").catch(()=>null);if(!content)continue;let entry=/@\w+\.(route|get)\(\s*["']([^"']+)["']([^)\n]*)/g;for(let m of content.matchAll(entry)){let[,kind,raw,rest]=m;if(kind==="route"&&rest&&/methods\s*=/.test(rest)&&!/GET/.test(rest))continue;let routePath=normalizePath(normalizeParams2(raw??""));if(!isPageRoute(routePath))continue;routes.push(toRoute(routePath,file))}}return dedupeAndSort(routes)}async function scanRails(routesRb){let content=await readFile2(routesRb,"utf8").catch(()=>null);if(!content)return[];let routes=[];for(let line of content.split(`
|