@vercel/build-utils 14.11.0 → 14.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/prerender.d.ts +5 -1
- package/dist/prerender.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 14.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6e68e60: Add `onMiss` to `Prerender`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
onMiss?: 'sync' | 'dynamic';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Declares how a request is served when no prerendered output is available for
|
|
14
|
+
it yet. Absent means `sync`: block the response on rendering it. `dynamic`
|
|
15
|
+
serves the request dynamically while the static shell is regenerated in the
|
|
16
|
+
background. The value is carried unvalidated so an unknown mode cannot fail
|
|
17
|
+
a deploy.
|
|
18
|
+
|
|
3
19
|
## 14.11.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import FileFsRef from './file-fs-ref';
|
|
|
3
3
|
import FileRef from './file-ref';
|
|
4
4
|
import { Lambda, createLambda, getLambdaOptionsFromFunction, sanitizeConsumerName } from './lambda';
|
|
5
5
|
import { NodejsLambda, type NodejsLambdaOptions } from './nodejs-lambda';
|
|
6
|
-
import { Prerender, type PrerenderInitialMetadata } from './prerender';
|
|
6
|
+
import { Prerender, type PrerenderInitialMetadata, type PrerenderOnMiss } from './prerender';
|
|
7
7
|
import download, { downloadFile, type DownloadedFiles, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget } from './fs/download';
|
|
8
8
|
import getWriteableDirectory from './fs/get-writable-directory';
|
|
9
9
|
import glob, { type GlobOptions } from './fs/glob';
|
|
@@ -22,7 +22,7 @@ import { cloneEnv } from './clone-env';
|
|
|
22
22
|
import { hardLinkDir } from './hard-link-dir';
|
|
23
23
|
import { getNodeExecPath } from './get-node-exec-path';
|
|
24
24
|
import { validateNpmrc } from './validate-npmrc';
|
|
25
|
-
export type { NodejsLambdaOptions, PrerenderInitialMetadata };
|
|
25
|
+
export type { NodejsLambdaOptions, PrerenderInitialMetadata, PrerenderOnMiss };
|
|
26
26
|
export type { LambdaAffinity } from './lambda';
|
|
27
27
|
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, type DownloadedFiles, getWriteableDirectory, glob, type GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getNodeExecPath, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, getOrCreateBunBinary, detectPackageManager, runNpmInstall, type NpmInstallOutput, runBundleInstall, runPipInstall, type PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget, getLambdaOptionsFromFunction, sanitizeConsumerName, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, type CliType, };
|
|
28
28
|
export { EdgeFunction } from './edge-function';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ GFS4: `),console.error(m)});fs12[gracefulQueue]||(queue=global[gracefulQueue]||[
|
|
|
7
7
|
`,finalEOL=!0,replacer=null,spaces}={}){let EOF=finalEOL?EOL:"",str=JSON.stringify(obj,replacer,spaces);if(str===void 0)throw new TypeError(`Converting ${typeof obj} value to JSON is not supported`);return str.replace(/\n/g,EOL)+EOF}function stripBom(content){return Buffer.isBuffer(content)&&(content=content.toString("utf8")),content.replace(/^\uFEFF/,"")}module2.exports={stringify:stringify2,stripBom}}});var require_jsonfile=__commonJS({"../../node_modules/.pnpm/jsonfile@6.2.1/node_modules/jsonfile/index.js"(exports2,module2){var _fs;try{_fs=require_graceful_fs()}catch{_fs=require("fs")}var universalify=require_universalify(),{stringify:stringify2,stripBom}=require_utils2();async function _readFile(file,options={}){typeof options=="string"&&(options={encoding:options});let fs12=options.fs||_fs,shouldThrow="throws"in options?options.throws:!0,data=await universalify.fromCallback(fs12.readFile)(file,options);data=stripBom(data);let obj;try{obj=JSON.parse(data,options?options.reviver:null)}catch(err){if(shouldThrow)throw err.message=`${file}: ${err.message}`,err;return null}return obj}var readFile4=universalify.fromPromise(_readFile);function readFileSync(file,options={}){typeof options=="string"&&(options={encoding:options});let fs12=options.fs||_fs,shouldThrow="throws"in options?options.throws:!0;try{let content=fs12.readFileSync(file,options);return content=stripBom(content),JSON.parse(content,options.reviver)}catch(err){if(shouldThrow)throw err.message=`${file}: ${err.message}`,err;return null}}async function _writeFile(file,obj,options={}){let fs12=options.fs||_fs,str=stringify2(obj,options);await universalify.fromCallback(fs12.writeFile)(file,str,options)}var writeFile=universalify.fromPromise(_writeFile);function writeFileSync(file,obj,options={}){let fs12=options.fs||_fs,str=stringify2(obj,options);return fs12.writeFileSync(file,str,options)}module2.exports={readFile:readFile4,readFileSync,writeFile,writeFileSync}}});var require_jsonfile2=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/json/jsonfile.js"(exports2,module2){"use strict";var jsonFile=require_jsonfile();module2.exports={readJson:jsonFile.readFile,readJsonSync:jsonFile.readFileSync,writeJson:jsonFile.writeFile,writeJsonSync:jsonFile.writeFileSync}}});var require_output=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/output/index.js"(exports2,module2){"use strict";var u=require_universalify().fromCallback,fs12=require_graceful_fs(),path9=require("path"),mkdir=require_mkdirs(),pathExists=require_path_exists().pathExists;function outputFile(file,data,encoding,callback){typeof encoding=="function"&&(callback=encoding,encoding="utf8");let dir=path9.dirname(file);pathExists(dir,(err,itDoes)=>{if(err)return callback(err);if(itDoes)return fs12.writeFile(file,data,encoding,callback);mkdir.mkdirs(dir,err2=>{if(err2)return callback(err2);fs12.writeFile(file,data,encoding,callback)})})}function outputFileSync(file,...args){let dir=path9.dirname(file);if(fs12.existsSync(dir))return fs12.writeFileSync(file,...args);mkdir.mkdirsSync(dir),fs12.writeFileSync(file,...args)}module2.exports={outputFile:u(outputFile),outputFileSync}}});var require_output_json=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/json/output-json.js"(exports2,module2){"use strict";var{stringify:stringify2}=require_utils2(),{outputFile}=require_output();async function outputJson(file,data,options={}){let str=stringify2(data,options);await outputFile(file,str,options)}module2.exports=outputJson}});var require_output_json_sync=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/json/output-json-sync.js"(exports2,module2){"use strict";var{stringify:stringify2}=require_utils2(),{outputFileSync}=require_output();function outputJsonSync(file,data,options){let str=stringify2(data,options);outputFileSync(file,str,options)}module2.exports=outputJsonSync}});var require_json=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/json/index.js"(exports2,module2){"use strict";var u=require_universalify().fromPromise,jsonFile=require_jsonfile2();jsonFile.outputJson=u(require_output_json());jsonFile.outputJsonSync=require_output_json_sync();jsonFile.outputJSON=jsonFile.outputJson;jsonFile.outputJSONSync=jsonFile.outputJsonSync;jsonFile.writeJSON=jsonFile.writeJson;jsonFile.writeJSONSync=jsonFile.writeJsonSync;jsonFile.readJSON=jsonFile.readJson;jsonFile.readJSONSync=jsonFile.readJsonSync;module2.exports=jsonFile}});var require_move_sync=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/move-sync/move-sync.js"(exports2,module2){"use strict";var fs12=require_graceful_fs(),path9=require("path"),copySync=require_copy_sync2().copySync,removeSync=require_remove().removeSync,mkdirpSync=require_mkdirs().mkdirpSync,stat2=require_stat();function moveSync(src,dest,opts){opts=opts||{};let overwrite=opts.overwrite||opts.clobber||!1,{srcStat,isChangingCase=!1}=stat2.checkPathsSync(src,dest,"move",opts);return stat2.checkParentPathsSync(src,srcStat,dest,"move"),isParentRoot(dest)||mkdirpSync(path9.dirname(dest)),doRename(src,dest,overwrite,isChangingCase)}function isParentRoot(dest){let parent=path9.dirname(dest);return path9.parse(parent).root===parent}function doRename(src,dest,overwrite,isChangingCase){if(isChangingCase)return rename2(src,dest,overwrite);if(overwrite)return removeSync(dest),rename2(src,dest,overwrite);if(fs12.existsSync(dest))throw new Error("dest already exists.");return rename2(src,dest,overwrite)}function rename2(src,dest,overwrite){try{fs12.renameSync(src,dest)}catch(err){if(err.code!=="EXDEV")throw err;return moveAcrossDevice(src,dest,overwrite)}}function moveAcrossDevice(src,dest,overwrite){return copySync(src,dest,{overwrite,errorOnExist:!0}),removeSync(src)}module2.exports=moveSync}});var require_move_sync2=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/move-sync/index.js"(exports2,module2){"use strict";module2.exports={moveSync:require_move_sync()}}});var require_move=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/move/move.js"(exports2,module2){"use strict";var fs12=require_graceful_fs(),path9=require("path"),copy=require_copy2().copy,remove2=require_remove().remove,mkdirp3=require_mkdirs().mkdirp,pathExists=require_path_exists().pathExists,stat2=require_stat();function move(src,dest,opts,cb){typeof opts=="function"&&(cb=opts,opts={});let overwrite=opts.overwrite||opts.clobber||!1;stat2.checkPaths(src,dest,"move",opts,(err,stats)=>{if(err)return cb(err);let{srcStat,isChangingCase=!1}=stats;stat2.checkParentPaths(src,srcStat,dest,"move",err2=>{if(err2)return cb(err2);if(isParentRoot(dest))return doRename(src,dest,overwrite,isChangingCase,cb);mkdirp3(path9.dirname(dest),err3=>err3?cb(err3):doRename(src,dest,overwrite,isChangingCase,cb))})})}function isParentRoot(dest){let parent=path9.dirname(dest);return path9.parse(parent).root===parent}function doRename(src,dest,overwrite,isChangingCase,cb){if(isChangingCase)return rename2(src,dest,overwrite,cb);if(overwrite)return remove2(dest,err=>err?cb(err):rename2(src,dest,overwrite,cb));pathExists(dest,(err,destExists)=>err?cb(err):destExists?cb(new Error("dest already exists.")):rename2(src,dest,overwrite,cb))}function rename2(src,dest,overwrite,cb){fs12.rename(src,dest,err=>err?err.code!=="EXDEV"?cb(err):moveAcrossDevice(src,dest,overwrite,cb):cb())}function moveAcrossDevice(src,dest,overwrite,cb){copy(src,dest,{overwrite,errorOnExist:!0},err=>err?cb(err):remove2(src,cb))}module2.exports=move}});var require_move2=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/move/index.js"(exports2,module2){"use strict";var u=require_universalify().fromCallback;module2.exports={move:u(require_move())}}});var require_lib=__commonJS({"../../node_modules/.pnpm/fs-extra@10.0.0/node_modules/fs-extra/lib/index.js"(exports2,module2){"use strict";module2.exports={...require_fs(),...require_copy_sync2(),...require_copy2(),...require_empty(),...require_ensure(),...require_json(),...require_mkdirs(),...require_move_sync2(),...require_move2(),...require_output(),...require_path_exists(),...require_remove()}}});var require_multistream=__commonJS({"../../node_modules/.pnpm/multistream@2.1.1/node_modules/multistream/index.js"(exports2,module2){module2.exports=MultiStream;var inherits=require_inherits(),stream=require_readable();inherits(MultiStream,stream.Readable);function MultiStream(streams,opts){var self2=this;if(!(self2 instanceof MultiStream))return new MultiStream(streams,opts);stream.Readable.call(self2,opts),self2.destroyed=!1,self2._drained=!1,self2._forwarding=!1,self2._current=null,self2._toStreams2=opts&&opts.objectMode?toStreams2Obj:toStreams2Buf,typeof streams=="function"?self2._queue=streams:(self2._queue=streams.map(self2._toStreams2),self2._queue.forEach(function(stream2){typeof stream2!="function"&&self2._attachErrorListener(stream2)})),self2._next()}MultiStream.obj=function(streams){return new MultiStream(streams,{objectMode:!0,highWaterMark:16})};MultiStream.prototype._read=function(){this._drained=!0,this._forward()};MultiStream.prototype._forward=function(){if(!(this._forwarding||!this._drained||!this._current)){this._forwarding=!0;for(var chunk;(chunk=this._current.read())!==null;)this._drained=this.push(chunk);this._forwarding=!1}};MultiStream.prototype.destroy=function(err){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),typeof this._queue!="function"&&this._queue.forEach(function(stream2){stream2.destroy&&stream2.destroy()}),err&&this.emit("error",err),this.emit("close"))};MultiStream.prototype._next=function(){var self2=this;if(self2._current=null,typeof self2._queue=="function")self2._queue(function(err,stream3){if(err)return self2.destroy(err);stream3=self2._toStreams2(stream3),self2._attachErrorListener(stream3),self2._gotNextStream(stream3)});else{var stream2=self2._queue.shift();typeof stream2=="function"&&(stream2=self2._toStreams2(stream2()),self2._attachErrorListener(stream2)),self2._gotNextStream(stream2)}};MultiStream.prototype._gotNextStream=function(stream2){var self2=this;if(!stream2){self2.push(null),self2.destroy();return}self2._current=stream2,self2._forward(),stream2.on("readable",onReadable),stream2.once("end",onEnd),stream2.once("close",onClose);function onReadable(){self2._forward()}function onClose(){stream2._readableState.ended||self2.destroy()}function onEnd(){self2._current=null,stream2.removeListener("readable",onReadable),stream2.removeListener("end",onEnd),stream2.removeListener("close",onClose),self2._next()}};MultiStream.prototype._attachErrorListener=function(stream2){var self2=this;if(!stream2)return;stream2.once("error",onError);function onError(err){stream2.removeListener("error",onError),self2.destroy(err)}};function toStreams2Obj(s){return toStreams2(s,{objectMode:!0,highWaterMark:16})}function toStreams2Buf(s){return toStreams2(s)}function toStreams2(s,opts){if(!s||typeof s=="function"||s._readableState)return s;var wrap=new stream.Readable(opts).wrap(s);return s.destroy&&(wrap.destroy=s.destroy.bind(s)),wrap}}});var require_deque=__commonJS({"../../node_modules/.pnpm/double-ended-queue@2.1.0-0/node_modules/double-ended-queue/js/deque.js"(exports2,module2){"use strict";function Deque(capacity){if(this._capacity=getCapacity(capacity),this._length=0,this._front=0,isArray(capacity)){for(var len=capacity.length,i=0;i<len;++i)this[i]=capacity[i];this._length=len}}Deque.prototype.toArray=function(){for(var len=this._length,ret=new Array(len),front=this._front,capacity=this._capacity,j=0;j<len;++j)ret[j]=this[front+j&capacity-1];return ret};Deque.prototype.push=function(item){var argsLength=arguments.length,length=this._length;if(argsLength>1){var capacity=this._capacity;if(length+argsLength>capacity){for(var i=0;i<argsLength;++i){this._checkCapacity(length+1);var j=this._front+length&this._capacity-1;this[j]=arguments[i],length++,this._length=length}return length}else{for(var j=this._front,i=0;i<argsLength;++i)this[j+length&capacity-1]=arguments[i],j++;return this._length=length+argsLength,length+argsLength}}if(argsLength===0)return length;this._checkCapacity(length+1);var i=this._front+length&this._capacity-1;return this[i]=item,this._length=length+1,length+1};Deque.prototype.pop=function(){var length=this._length;if(length!==0){var i=this._front+length-1&this._capacity-1,ret=this[i];return this[i]=void 0,this._length=length-1,ret}};Deque.prototype.shift=function(){var length=this._length;if(length!==0){var front=this._front,ret=this[front];return this[front]=void 0,this._front=front+1&this._capacity-1,this._length=length-1,ret}};Deque.prototype.unshift=function(item){var length=this._length,argsLength=arguments.length;if(argsLength>1){var capacity=this._capacity;if(length+argsLength>capacity){for(var i=argsLength-1;i>=0;i--){this._checkCapacity(length+1);var capacity=this._capacity,j=(this._front-1&capacity-1^capacity)-capacity;this[j]=arguments[i],length++,this._length=length,this._front=j}return length}else{for(var front=this._front,i=argsLength-1;i>=0;i--){var j=(front-1&capacity-1^capacity)-capacity;this[j]=arguments[i],front=j}return this._front=front,this._length=length+argsLength,length+argsLength}}if(argsLength===0)return length;this._checkCapacity(length+1);var capacity=this._capacity,i=(this._front-1&capacity-1^capacity)-capacity;return this[i]=item,this._length=length+1,this._front=i,length+1};Deque.prototype.peekBack=function(){var length=this._length;if(length!==0){var index=this._front+length-1&this._capacity-1;return this[index]}};Deque.prototype.peekFront=function(){if(this._length!==0)return this[this._front]};Deque.prototype.get=function(index){var i=index;if(i===(i|0)){var len=this._length;if(i<0&&(i=i+len),!(i<0||i>=len))return this[this._front+i&this._capacity-1]}};Deque.prototype.isEmpty=function(){return this._length===0};Deque.prototype.clear=function(){for(var len=this._length,front=this._front,capacity=this._capacity,j=0;j<len;++j)this[front+j&capacity-1]=void 0;this._length=0,this._front=0};Deque.prototype.toString=function(){return this.toArray().toString()};Deque.prototype.valueOf=Deque.prototype.toString;Deque.prototype.removeFront=Deque.prototype.shift;Deque.prototype.removeBack=Deque.prototype.pop;Deque.prototype.insertFront=Deque.prototype.unshift;Deque.prototype.insertBack=Deque.prototype.push;Deque.prototype.enqueue=Deque.prototype.push;Deque.prototype.dequeue=Deque.prototype.shift;Deque.prototype.toJSON=Deque.prototype.toArray;Object.defineProperty(Deque.prototype,"length",{get:function(){return this._length},set:function(){throw new RangeError("")}});Deque.prototype._checkCapacity=function(size){this._capacity<size&&this._resizeTo(getCapacity(this._capacity*1.5+16))};Deque.prototype._resizeTo=function(capacity){var oldCapacity=this._capacity;this._capacity=capacity;var front=this._front,length=this._length;if(front+length>oldCapacity){var moveItemsCount=front+length&oldCapacity-1;arrayMove(this,0,this,oldCapacity,moveItemsCount)}};var isArray=Array.isArray;function arrayMove(src,srcIndex,dst,dstIndex,len){for(var j=0;j<len;++j)dst[j+dstIndex]=src[j+srcIndex],src[j+srcIndex]=void 0}function pow2AtLeast(n){return n=n>>>0,n=n-1,n=n|n>>1,n=n|n>>2,n=n|n>>4,n=n|n>>8,n=n|n>>16,n+1}function getCapacity(capacity){if(typeof capacity!="number")if(isArray(capacity))capacity=capacity.length;else return 16;return pow2AtLeast(Math.min(Math.max(16,capacity),1073741824))}module2.exports=Deque}});var require_async_sema=__commonJS({"../../node_modules/.pnpm/async-sema@2.1.4/node_modules/async-sema/index.js"(exports2,module2){var EventEmitter=require("events"),util=require("util"),Deque=require_deque(),ReleaseEmitter=class extends EventEmitter{};function isFn(x){return typeof x=="function"}function defaultInit(){return"1"}var Sema5=class{constructor(nr,{initFn=defaultInit,pauseFn,resumeFn,capacity=10}={}){if(isFn(pauseFn)^isFn(resumeFn))throw new Error("pauseFn and resumeFn must be both set for pausing");this.nrTokens=nr,this.free=new Deque(nr),this.waiting=new Deque(capacity),this.releaseEmitter=new ReleaseEmitter,this.noTokens=initFn===defaultInit,this.pauseFn=pauseFn,this.resumeFn=resumeFn,this.releaseEmitter.on("release",token=>{let p=this.waiting.shift();p?p.resolve(token):(this.resumeFn&&this.paused&&(this.paused=!1,this.resumeFn()),this.free.push(token))});for(let i=0;i<nr;i++)this.free.push(initFn())}async acquire(){let token=this.free.pop();return token||new Promise((resolve3,reject)=>{this.pauseFn&&!this.paused&&(this.paused=!0,this.pauseFn()),this.waiting.push({resolve:resolve3,reject})})}async v(){return this.acquire()}release(token){this.releaseEmitter.emit("release",this.noTokens?"1":token)}p(token){return this.release(token)}drain(){let a=new Array(this.nrTokens);for(let i=0;i<this.nrTokens;i++)a[i]=this.acquire();return Promise.all(a)}nrWaiting(){return this.waiting.length}};Sema5.prototype.v=util.deprecate(Sema5.prototype.v,"`v()` is deperecated; use `acquire()` instead");Sema5.prototype.p=util.deprecate(Sema5.prototype.p,"`p()` is deprecated; use `release()` instead");module2.exports=Sema5}});var file_fs_ref_exports={};__export(file_fs_ref_exports,{default:()=>file_fs_ref_default});var import_assert2,import_fs_extra,import_multistream,import_path,import_async_sema,semaToPreventEMFILE,FileFsRef,file_fs_ref_default,init_file_fs_ref=__esm({"src/file-fs-ref.ts"(){"use strict";import_assert2=__toESM(require("assert")),import_fs_extra=__toESM(require_lib()),import_multistream=__toESM(require_multistream()),import_path=__toESM(require("path")),import_async_sema=__toESM(require_async_sema()),semaToPreventEMFILE=new import_async_sema.default(20),FileFsRef=class _FileFsRef{constructor({mode=33188,contentType,fsPath,size}){(0,import_assert2.default)(typeof mode=="number"),(0,import_assert2.default)(typeof fsPath=="string"),this.type="FileFsRef",this.mode=mode,this.contentType=contentType,this.fsPath=fsPath,this.size=size}static async fromFsPath({mode,contentType,fsPath,size}){let m=mode,s=size;if(!m||typeof s>"u"){let stat2=await import_fs_extra.default.lstat(fsPath);m=stat2.mode,s=stat2.size}return new _FileFsRef({mode:m,contentType,fsPath,size:s})}static async fromStream({mode=33188,contentType,stream,fsPath}){return(0,import_assert2.default)(typeof mode=="number"),(0,import_assert2.default)(typeof stream.pipe=="function"),(0,import_assert2.default)(typeof fsPath=="string"),await import_fs_extra.default.mkdirp(import_path.default.dirname(fsPath)),await new Promise((resolve3,reject)=>{let dest=import_fs_extra.default.createWriteStream(fsPath,{mode:mode&511});stream.pipe(dest),stream.on("error",reject),dest.on("finish",resolve3),dest.on("error",reject)}),_FileFsRef.fromFsPath({mode,contentType,fsPath})}async toStreamAsync(){await semaToPreventEMFILE.acquire();let release=()=>semaToPreventEMFILE.release(),stream=import_fs_extra.default.createReadStream(this.fsPath);return stream.on("close",release),stream.on("error",release),stream}toStream(){let flag=!1;return(0,import_multistream.default)(cb=>{if(flag)return cb(null,null);flag=!0,this.toStreamAsync().then(stream=>{cb(null,stream)}).catch(error=>{cb(error,null)})})}},file_fs_ref_default=FileFsRef}});var require_retry_operation=__commonJS({"../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry_operation.js"(exports2,module2){function RetryOperation(timeouts,options){typeof options=="boolean"&&(options={forever:options}),this._originalTimeouts=JSON.parse(JSON.stringify(timeouts)),this._timeouts=timeouts,this._options=options||{},this._maxRetryTime=options&&options.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}module2.exports=RetryOperation;RetryOperation.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};RetryOperation.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};RetryOperation.prototype.retry=function(err){if(this._timeout&&clearTimeout(this._timeout),!err)return!1;var currentTime=new Date().getTime();if(err&¤tTime-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(err);var timeout=this._timeouts.shift();if(timeout===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),timeout=this._timeouts.shift();else return!1;var self2=this,timer=setTimeout(function(){self2._attempts++,self2._operationTimeoutCb&&(self2._timeout=setTimeout(function(){self2._operationTimeoutCb(self2._attempts)},self2._operationTimeout),self2._options.unref&&self2._timeout.unref()),self2._fn(self2._attempts)},timeout);return this._options.unref&&timer.unref(),!0};RetryOperation.prototype.attempt=function(fn,timeoutOps){this._fn=fn,timeoutOps&&(timeoutOps.timeout&&(this._operationTimeout=timeoutOps.timeout),timeoutOps.cb&&(this._operationTimeoutCb=timeoutOps.cb));var self2=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){self2._operationTimeoutCb()},self2._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};RetryOperation.prototype.try=function(fn){console.log("Using RetryOperation.try() is deprecated"),this.attempt(fn)};RetryOperation.prototype.start=function(fn){console.log("Using RetryOperation.start() is deprecated"),this.attempt(fn)};RetryOperation.prototype.start=RetryOperation.prototype.try;RetryOperation.prototype.errors=function(){return this._errors};RetryOperation.prototype.attempts=function(){return this._attempts};RetryOperation.prototype.mainError=function(){if(this._errors.length===0)return null;for(var counts={},mainError=null,mainErrorCount=0,i=0;i<this._errors.length;i++){var error=this._errors[i],message=error.message,count=(counts[message]||0)+1;counts[message]=count,count>=mainErrorCount&&(mainError=error,mainErrorCount=count)}return mainError}}});var require_retry=__commonJS({"../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry.js"(exports2){var RetryOperation=require_retry_operation();exports2.operation=function(options){var timeouts=exports2.timeouts(options);return new RetryOperation(timeouts,{forever:options&&options.forever,unref:options&&options.unref,maxRetryTime:options&&options.maxRetryTime})};exports2.timeouts=function(options){if(options instanceof Array)return[].concat(options);var opts={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var key in options)opts[key]=options[key];if(opts.minTimeout>opts.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var timeouts=[],i=0;i<opts.retries;i++)timeouts.push(this.createTimeout(i,opts));return options&&options.forever&&!timeouts.length&&timeouts.push(this.createTimeout(i,opts)),timeouts.sort(function(a,b){return a-b}),timeouts};exports2.createTimeout=function(attempt,opts){var random=opts.randomize?Math.random()+1:1,timeout=Math.round(random*opts.minTimeout*Math.pow(opts.factor,attempt));return timeout=Math.min(timeout,opts.maxTimeout),timeout};exports2.wrap=function(obj,options,methods){if(options instanceof Array&&(methods=options,options=null),!methods){methods=[];for(var key in obj)typeof obj[key]=="function"&&methods.push(key)}for(var i=0;i<methods.length;i++){var method=methods[i],original=obj[method];obj[method]=function(original2){var op=exports2.operation(options),args=Array.prototype.slice.call(arguments,1),callback=args.pop();args.push(function(err){op.retry(err)||(err&&(arguments[0]=op.mainError()),callback.apply(this,arguments))}),op.attempt(function(){original2.apply(obj,args)})}.bind(obj,original),obj[method].options=options}}}});var require_retry2=__commonJS({"../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/index.js"(exports2,module2){module2.exports=require_retry()}});var require_lib2=__commonJS({"../../node_modules/.pnpm/async-retry@1.2.3/node_modules/async-retry/lib/index.js"(exports2,module2){var retrier=require_retry2();function retry2(fn,opts){function run(resolve3,reject){var options=opts||{},op=retrier.operation(options);function bail(err){reject(err||new Error("Aborted"))}function onError(err,num){if(err.bail){bail(err);return}op.retry(err)?options.onRetry&&options.onRetry(err,num):reject(op.mainError())}function runAttempt(num){var val;try{val=fn(bail,num)}catch(err){onError(err,num);return}Promise.resolve(val).then(resolve3).catch(function(err){onError(err,num)})}op.attempt(runAttempt)}return new Promise(run)}module2.exports=retry2}});var file_ref_exports={};__export(file_ref_exports,{default:()=>FileRef});function getEnvAsUrlOrThrow(key){let value=process.env[key];if(value!==void 0)try{return new URL(value),value}catch(e){throw e instanceof TypeError&&"code"in e&&e.code==="ERR_INVALID_URL"?new Error(`A non-URL value was supplied to the ${key} environment variable`):e}}var import_assert3,import_stream,import_multistream2,import_async_retry,import_async_sema2,semaToDownloadFromS3,BailableError,FileRef,init_file_ref=__esm({"src/file-ref.ts"(){"use strict";import_assert3=__toESM(require("assert")),import_stream=require("stream"),import_multistream2=__toESM(require_multistream()),import_async_retry=__toESM(require_lib2()),import_async_sema2=__toESM(require_async_sema()),semaToDownloadFromS3=new import_async_sema2.default(5),BailableError=class extends Error{constructor(...args){super(...args);this.bail=!1}},FileRef=class{constructor({mode=33188,digest,contentType,mutable=!1}){(0,import_assert3.default)(typeof mode=="number"),(0,import_assert3.default)(typeof digest=="string"),this.type="FileRef",this.mode=mode,this.digest=digest,this.contentType=contentType,this.mutable=mutable}getNowFilesCloudfrontUrl(){return getEnvAsUrlOrThrow("NOW_FILES_CLOUDFRONT_URL")||"https://dmmcy0pwk6bqi.cloudfront.net"}getNowEphemeralFilesS3Url(){return getEnvAsUrlOrThrow("NOW_EPHEMERAL_FILES_S3_URL")||"https://now-ephemeral-files.s3.amazonaws.com"}getNowFilesS3Url(){return getEnvAsUrlOrThrow("NOW_FILES_S3_URL")||"https://now-files.s3.amazonaws.com"}async toStreamAsync(){let url="",[digestType,digestHash]=this.digest.split(":");if(digestType==="sha")url=this.mutable?`${this.getNowFilesS3Url()}/${digestHash}`:`${this.getNowFilesCloudfrontUrl()}/${digestHash}`;else if(digestType==="sha+ephemeral")url=`${this.getNowEphemeralFilesS3Url()}/${digestHash}`;else throw new Error("Expected digest to be sha");await semaToDownloadFromS3.acquire();try{return await(0,import_async_retry.default)(async()=>{let resp=await fetch(url);if(!resp.ok||!resp.body){let error=new BailableError(`download: ${resp.status} ${resp.statusText} for ${url}`);throw resp.status===403&&(error.bail=!0),await resp.body?.cancel().catch(()=>{}),error}return import_stream.Readable.fromWeb(resp.body)},{factor:1,retries:3})}finally{semaToDownloadFromS3.release()}}toStream(){let flag=!1;return(0,import_multistream2.default)(cb=>{if(flag)return cb(null,null);flag=!0,this.toStreamAsync().then(stream=>{cb(null,stream)}).catch(error=>{cb(error,null)})})}}}});function validateMaxConcurrency(value){value!==void 0&&(0,import_assert4.default)(Number.isInteger(value)&&value>=1&&value<=MAX_CONCURRENCY,'"maxConcurrency" must be an integer from 1 to 8192')}var import_assert4,MAX_CONCURRENCY,init_max_concurrency=__esm({"src/max-concurrency.ts"(){"use strict";import_assert4=__toESM(require("assert")),MAX_CONCURRENCY=8192}});var require_buffer_crc32=__commonJS({"../../node_modules/.pnpm/buffer-crc32@0.2.13/node_modules/buffer-crc32/index.js"(exports2,module2){var Buffer2=require("buffer").Buffer,CRC_TABLE=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(CRC_TABLE=new Int32Array(CRC_TABLE));function ensureBuffer(input){if(Buffer2.isBuffer(input))return input;var hasNewBufferAPI=typeof Buffer2.alloc=="function"&&typeof Buffer2.from=="function";if(typeof input=="number")return hasNewBufferAPI?Buffer2.alloc(input):new Buffer2(input);if(typeof input=="string")return hasNewBufferAPI?Buffer2.from(input):new Buffer2(input);throw new Error("input must be buffer, number, or string, received "+typeof input)}function bufferizeInt(num){var tmp=ensureBuffer(4);return tmp.writeInt32BE(num,0),tmp}function _crc32(buf,previous){buf=ensureBuffer(buf),Buffer2.isBuffer(previous)&&(previous=previous.readUInt32BE(0));for(var crc=~~previous^-1,n=0;n<buf.length;n++)crc=CRC_TABLE[(crc^buf[n])&255]^crc>>>8;return crc^-1}function crc32(){return bufferizeInt(_crc32.apply(null,arguments))}crc32.signed=function(){return _crc32.apply(null,arguments)};crc32.unsigned=function(){return _crc32.apply(null,arguments)>>>0};module2.exports=crc32}});var require_yazl=__commonJS({"../../node_modules/.pnpm/yazl@2.5.1/node_modules/yazl/index.js"(exports2){var fs12=require("fs"),Transform=require("stream").Transform,PassThrough=require("stream").PassThrough,zlib=require("zlib"),util=require("util"),EventEmitter=require("events").EventEmitter,crc32=require_buffer_crc32();exports2.ZipFile=ZipFile2;exports2.dateToDosDateTime=dateToDosDateTime;util.inherits(ZipFile2,EventEmitter);function ZipFile2(){this.outputStream=new PassThrough,this.entries=[],this.outputStreamCursor=0,this.ended=!1,this.allDone=!1,this.forceZip64Eocd=!1}ZipFile2.prototype.addFile=function(realPath,metadataPath,options){var self2=this;metadataPath=validateMetadataPath(metadataPath,!1),options==null&&(options={});var entry=new Entry(metadataPath,!1,options);self2.entries.push(entry),fs12.stat(realPath,function(err,stats){if(err)return self2.emit("error",err);if(!stats.isFile())return self2.emit("error",new Error("not a file: "+realPath));entry.uncompressedSize=stats.size,options.mtime==null&&entry.setLastModDate(stats.mtime),options.mode==null&&entry.setFileAttributesMode(stats.mode),entry.setFileDataPumpFunction(function(){var readStream=fs12.createReadStream(realPath);entry.state=Entry.FILE_DATA_IN_PROGRESS,readStream.on("error",function(err2){self2.emit("error",err2)}),pumpFileDataReadStream(self2,entry,readStream)}),pumpEntries(self2)})};ZipFile2.prototype.addReadStream=function(readStream,metadataPath,options){var self2=this;metadataPath=validateMetadataPath(metadataPath,!1),options==null&&(options={});var entry=new Entry(metadataPath,!1,options);self2.entries.push(entry),entry.setFileDataPumpFunction(function(){entry.state=Entry.FILE_DATA_IN_PROGRESS,pumpFileDataReadStream(self2,entry,readStream)}),pumpEntries(self2)};ZipFile2.prototype.addBuffer=function(buffer,metadataPath,options){var self2=this;if(metadataPath=validateMetadataPath(metadataPath,!1),buffer.length>1073741823)throw new Error("buffer too large: "+buffer.length+" > 1073741823");if(options==null&&(options={}),options.size!=null)throw new Error("options.size not allowed");var entry=new Entry(metadataPath,!1,options);entry.uncompressedSize=buffer.length,entry.crc32=crc32.unsigned(buffer),entry.crcAndFileSizeKnown=!0,self2.entries.push(entry),entry.compress?zlib.deflateRaw(buffer,function(err,compressedBuffer){setCompressedBuffer(compressedBuffer)}):setCompressedBuffer(buffer);function setCompressedBuffer(compressedBuffer){entry.compressedSize=compressedBuffer.length,entry.setFileDataPumpFunction(function(){writeToOutputStream(self2,compressedBuffer),writeToOutputStream(self2,entry.getDataDescriptor()),entry.state=Entry.FILE_DATA_DONE,setImmediate(function(){pumpEntries(self2)})}),pumpEntries(self2)}};ZipFile2.prototype.addEmptyDirectory=function(metadataPath,options){var self2=this;if(metadataPath=validateMetadataPath(metadataPath,!0),options==null&&(options={}),options.size!=null)throw new Error("options.size not allowed");if(options.compress!=null)throw new Error("options.compress not allowed");var entry=new Entry(metadataPath,!0,options);self2.entries.push(entry),entry.setFileDataPumpFunction(function(){writeToOutputStream(self2,entry.getDataDescriptor()),entry.state=Entry.FILE_DATA_DONE,pumpEntries(self2)}),pumpEntries(self2)};var eocdrSignatureBuffer=bufferFrom([80,75,5,6]);ZipFile2.prototype.end=function(options,finalSizeCallback){if(typeof options=="function"&&(finalSizeCallback=options,options=null),options==null&&(options={}),!this.ended){if(this.ended=!0,this.finalSizeCallback=finalSizeCallback,this.forceZip64Eocd=!!options.forceZip64Format,options.comment){if(typeof options.comment=="string"?this.comment=encodeCp437(options.comment):this.comment=options.comment,this.comment.length>65535)throw new Error("comment is too large");if(bufferIncludes(this.comment,eocdrSignatureBuffer))throw new Error("comment contains end of central directory record signature")}else this.comment=EMPTY_BUFFER;pumpEntries(this)}};function writeToOutputStream(self2,buffer){self2.outputStream.write(buffer),self2.outputStreamCursor+=buffer.length}function pumpFileDataReadStream(self2,entry,readStream){var crc32Watcher=new Crc32Watcher,uncompressedSizeCounter=new ByteCounter,compressor=entry.compress?new zlib.DeflateRaw:new PassThrough,compressedSizeCounter=new ByteCounter;readStream.pipe(crc32Watcher).pipe(uncompressedSizeCounter).pipe(compressor).pipe(compressedSizeCounter).pipe(self2.outputStream,{end:!1}),compressedSizeCounter.on("end",function(){if(entry.crc32=crc32Watcher.crc32,entry.uncompressedSize==null)entry.uncompressedSize=uncompressedSizeCounter.byteCount;else if(entry.uncompressedSize!==uncompressedSizeCounter.byteCount)return self2.emit("error",new Error("file data stream has unexpected number of bytes"));entry.compressedSize=compressedSizeCounter.byteCount,self2.outputStreamCursor+=entry.compressedSize,writeToOutputStream(self2,entry.getDataDescriptor()),entry.state=Entry.FILE_DATA_DONE,pumpEntries(self2)})}function pumpEntries(self2){if(self2.allDone)return;if(self2.ended&&self2.finalSizeCallback!=null){var finalSize=calculateFinalSize(self2);finalSize!=null&&(self2.finalSizeCallback(finalSize),self2.finalSizeCallback=null)}var entry=getFirstNotDoneEntry();function getFirstNotDoneEntry(){for(var i=0;i<self2.entries.length;i++){var entry2=self2.entries[i];if(entry2.state<Entry.FILE_DATA_DONE)return entry2}return null}if(entry!=null){if(entry.state<Entry.READY_TO_PUMP_FILE_DATA||entry.state===Entry.FILE_DATA_IN_PROGRESS)return;entry.relativeOffsetOfLocalHeader=self2.outputStreamCursor;var localFileHeader=entry.getLocalFileHeader();writeToOutputStream(self2,localFileHeader),entry.doFileDataPump()}else self2.ended&&(self2.offsetOfStartOfCentralDirectory=self2.outputStreamCursor,self2.entries.forEach(function(entry2){var centralDirectoryRecord=entry2.getCentralDirectoryRecord();writeToOutputStream(self2,centralDirectoryRecord)}),writeToOutputStream(self2,getEndOfCentralDirectoryRecord(self2)),self2.outputStream.end(),self2.allDone=!0)}function calculateFinalSize(self2){for(var pretendOutputCursor=0,centralDirectorySize=0,i=0;i<self2.entries.length;i++){var entry=self2.entries[i];if(entry.compress)return-1;if(entry.state>=Entry.READY_TO_PUMP_FILE_DATA){if(entry.uncompressedSize==null)return-1}else if(entry.uncompressedSize==null)return null;entry.relativeOffsetOfLocalHeader=pretendOutputCursor;var useZip64Format=entry.useZip64Format();pretendOutputCursor+=LOCAL_FILE_HEADER_FIXED_SIZE+entry.utf8FileName.length,pretendOutputCursor+=entry.uncompressedSize,entry.crcAndFileSizeKnown||(useZip64Format?pretendOutputCursor+=ZIP64_DATA_DESCRIPTOR_SIZE:pretendOutputCursor+=DATA_DESCRIPTOR_SIZE),centralDirectorySize+=CENTRAL_DIRECTORY_RECORD_FIXED_SIZE+entry.utf8FileName.length+entry.fileComment.length,useZip64Format&&(centralDirectorySize+=ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE)}var endOfCentralDirectorySize=0;return(self2.forceZip64Eocd||self2.entries.length>=65535||centralDirectorySize>=65535||pretendOutputCursor>=4294967295)&&(endOfCentralDirectorySize+=ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE+ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE),endOfCentralDirectorySize+=END_OF_CENTRAL_DIRECTORY_RECORD_SIZE+self2.comment.length,pretendOutputCursor+centralDirectorySize+endOfCentralDirectorySize}var ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE=56,ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE=20,END_OF_CENTRAL_DIRECTORY_RECORD_SIZE=22;function getEndOfCentralDirectoryRecord(self2,actuallyJustTellMeHowLongItWouldBe){var needZip64Format=!1,normalEntriesLength=self2.entries.length;(self2.forceZip64Eocd||self2.entries.length>=65535)&&(normalEntriesLength=65535,needZip64Format=!0);var sizeOfCentralDirectory=self2.outputStreamCursor-self2.offsetOfStartOfCentralDirectory,normalSizeOfCentralDirectory=sizeOfCentralDirectory;(self2.forceZip64Eocd||sizeOfCentralDirectory>=4294967295)&&(normalSizeOfCentralDirectory=4294967295,needZip64Format=!0);var normalOffsetOfStartOfCentralDirectory=self2.offsetOfStartOfCentralDirectory;if((self2.forceZip64Eocd||self2.offsetOfStartOfCentralDirectory>=4294967295)&&(normalOffsetOfStartOfCentralDirectory=4294967295,needZip64Format=!0),actuallyJustTellMeHowLongItWouldBe)return needZip64Format?ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE+ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE+END_OF_CENTRAL_DIRECTORY_RECORD_SIZE:END_OF_CENTRAL_DIRECTORY_RECORD_SIZE;var eocdrBuffer=bufferAlloc(END_OF_CENTRAL_DIRECTORY_RECORD_SIZE+self2.comment.length);if(eocdrBuffer.writeUInt32LE(101010256,0),eocdrBuffer.writeUInt16LE(0,4),eocdrBuffer.writeUInt16LE(0,6),eocdrBuffer.writeUInt16LE(normalEntriesLength,8),eocdrBuffer.writeUInt16LE(normalEntriesLength,10),eocdrBuffer.writeUInt32LE(normalSizeOfCentralDirectory,12),eocdrBuffer.writeUInt32LE(normalOffsetOfStartOfCentralDirectory,16),eocdrBuffer.writeUInt16LE(self2.comment.length,20),self2.comment.copy(eocdrBuffer,22),!needZip64Format)return eocdrBuffer;var zip64EocdrBuffer=bufferAlloc(ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE);zip64EocdrBuffer.writeUInt32LE(101075792,0),writeUInt64LE(zip64EocdrBuffer,ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE-12,4),zip64EocdrBuffer.writeUInt16LE(VERSION_MADE_BY,12),zip64EocdrBuffer.writeUInt16LE(VERSION_NEEDED_TO_EXTRACT_ZIP64,14),zip64EocdrBuffer.writeUInt32LE(0,16),zip64EocdrBuffer.writeUInt32LE(0,20),writeUInt64LE(zip64EocdrBuffer,self2.entries.length,24),writeUInt64LE(zip64EocdrBuffer,self2.entries.length,32),writeUInt64LE(zip64EocdrBuffer,sizeOfCentralDirectory,40),writeUInt64LE(zip64EocdrBuffer,self2.offsetOfStartOfCentralDirectory,48);var zip64EocdlBuffer=bufferAlloc(ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE);return zip64EocdlBuffer.writeUInt32LE(117853008,0),zip64EocdlBuffer.writeUInt32LE(0,4),writeUInt64LE(zip64EocdlBuffer,self2.outputStreamCursor,8),zip64EocdlBuffer.writeUInt32LE(1,16),Buffer.concat([zip64EocdrBuffer,zip64EocdlBuffer,eocdrBuffer])}function validateMetadataPath(metadataPath,isDirectory2){if(metadataPath==="")throw new Error("empty metadataPath");if(metadataPath=metadataPath.replace(/\\/g,"/"),/^[a-zA-Z]:/.test(metadataPath)||/^\//.test(metadataPath))throw new Error("absolute path: "+metadataPath);if(metadataPath.split("/").indexOf("..")!==-1)throw new Error("invalid relative path: "+metadataPath);var looksLikeDirectory=/\/$/.test(metadataPath);if(isDirectory2)looksLikeDirectory||(metadataPath+="/");else if(looksLikeDirectory)throw new Error("file path cannot end with '/': "+metadataPath);return metadataPath}var EMPTY_BUFFER=bufferAlloc(0);function Entry(metadataPath,isDirectory2,options){if(this.utf8FileName=bufferFrom(metadataPath),this.utf8FileName.length>65535)throw new Error("utf8 file name too long. "+utf8FileName.length+" > 65535");if(this.isDirectory=isDirectory2,this.state=Entry.WAITING_FOR_METADATA,this.setLastModDate(options.mtime!=null?options.mtime:new Date),options.mode!=null?this.setFileAttributesMode(options.mode):this.setFileAttributesMode(isDirectory2?16893:33204),isDirectory2?(this.crcAndFileSizeKnown=!0,this.crc32=0,this.uncompressedSize=0,this.compressedSize=0):(this.crcAndFileSizeKnown=!1,this.crc32=null,this.uncompressedSize=null,this.compressedSize=null,options.size!=null&&(this.uncompressedSize=options.size)),isDirectory2?this.compress=!1:(this.compress=!0,options.compress!=null&&(this.compress=!!options.compress)),this.forceZip64Format=!!options.forceZip64Format,options.fileComment){if(typeof options.fileComment=="string"?this.fileComment=bufferFrom(options.fileComment,"utf-8"):this.fileComment=options.fileComment,this.fileComment.length>65535)throw new Error("fileComment is too large")}else this.fileComment=EMPTY_BUFFER}Entry.WAITING_FOR_METADATA=0;Entry.READY_TO_PUMP_FILE_DATA=1;Entry.FILE_DATA_IN_PROGRESS=2;Entry.FILE_DATA_DONE=3;Entry.prototype.setLastModDate=function(date){var dosDateTime=dateToDosDateTime(date);this.lastModFileTime=dosDateTime.time,this.lastModFileDate=dosDateTime.date};Entry.prototype.setFileAttributesMode=function(mode){if((mode&65535)!==mode)throw new Error("invalid mode. expected: 0 <= "+mode+" <= 65535");this.externalFileAttributes=mode<<16>>>0};Entry.prototype.setFileDataPumpFunction=function(doFileDataPump){this.doFileDataPump=doFileDataPump,this.state=Entry.READY_TO_PUMP_FILE_DATA};Entry.prototype.useZip64Format=function(){return this.forceZip64Format||this.uncompressedSize!=null&&this.uncompressedSize>4294967294||this.compressedSize!=null&&this.compressedSize>4294967294||this.relativeOffsetOfLocalHeader!=null&&this.relativeOffsetOfLocalHeader>4294967294};var LOCAL_FILE_HEADER_FIXED_SIZE=30,VERSION_NEEDED_TO_EXTRACT_UTF8=20,VERSION_NEEDED_TO_EXTRACT_ZIP64=45,VERSION_MADE_BY=831,FILE_NAME_IS_UTF8=2048,UNKNOWN_CRC32_AND_FILE_SIZES=8;Entry.prototype.getLocalFileHeader=function(){var crc322=0,compressedSize=0,uncompressedSize=0;this.crcAndFileSizeKnown&&(crc322=this.crc32,compressedSize=this.compressedSize,uncompressedSize=this.uncompressedSize);var fixedSizeStuff=bufferAlloc(LOCAL_FILE_HEADER_FIXED_SIZE),generalPurposeBitFlag=FILE_NAME_IS_UTF8;return this.crcAndFileSizeKnown||(generalPurposeBitFlag|=UNKNOWN_CRC32_AND_FILE_SIZES),fixedSizeStuff.writeUInt32LE(67324752,0),fixedSizeStuff.writeUInt16LE(VERSION_NEEDED_TO_EXTRACT_UTF8,4),fixedSizeStuff.writeUInt16LE(generalPurposeBitFlag,6),fixedSizeStuff.writeUInt16LE(this.getCompressionMethod(),8),fixedSizeStuff.writeUInt16LE(this.lastModFileTime,10),fixedSizeStuff.writeUInt16LE(this.lastModFileDate,12),fixedSizeStuff.writeUInt32LE(crc322,14),fixedSizeStuff.writeUInt32LE(compressedSize,18),fixedSizeStuff.writeUInt32LE(uncompressedSize,22),fixedSizeStuff.writeUInt16LE(this.utf8FileName.length,26),fixedSizeStuff.writeUInt16LE(0,28),Buffer.concat([fixedSizeStuff,this.utf8FileName])};var DATA_DESCRIPTOR_SIZE=16,ZIP64_DATA_DESCRIPTOR_SIZE=24;Entry.prototype.getDataDescriptor=function(){if(this.crcAndFileSizeKnown)return EMPTY_BUFFER;if(this.useZip64Format()){var buffer=bufferAlloc(ZIP64_DATA_DESCRIPTOR_SIZE);return buffer.writeUInt32LE(134695760,0),buffer.writeUInt32LE(this.crc32,4),writeUInt64LE(buffer,this.compressedSize,8),writeUInt64LE(buffer,this.uncompressedSize,16),buffer}else{var buffer=bufferAlloc(DATA_DESCRIPTOR_SIZE);return buffer.writeUInt32LE(134695760,0),buffer.writeUInt32LE(this.crc32,4),buffer.writeUInt32LE(this.compressedSize,8),buffer.writeUInt32LE(this.uncompressedSize,12),buffer}};var CENTRAL_DIRECTORY_RECORD_FIXED_SIZE=46,ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE=28;Entry.prototype.getCentralDirectoryRecord=function(){var fixedSizeStuff=bufferAlloc(CENTRAL_DIRECTORY_RECORD_FIXED_SIZE),generalPurposeBitFlag=FILE_NAME_IS_UTF8;this.crcAndFileSizeKnown||(generalPurposeBitFlag|=UNKNOWN_CRC32_AND_FILE_SIZES);var normalCompressedSize=this.compressedSize,normalUncompressedSize=this.uncompressedSize,normalRelativeOffsetOfLocalHeader=this.relativeOffsetOfLocalHeader,versionNeededToExtract,zeiefBuffer;return this.useZip64Format()?(normalCompressedSize=4294967295,normalUncompressedSize=4294967295,normalRelativeOffsetOfLocalHeader=4294967295,versionNeededToExtract=VERSION_NEEDED_TO_EXTRACT_ZIP64,zeiefBuffer=bufferAlloc(ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE),zeiefBuffer.writeUInt16LE(1,0),zeiefBuffer.writeUInt16LE(ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE-4,2),writeUInt64LE(zeiefBuffer,this.uncompressedSize,4),writeUInt64LE(zeiefBuffer,this.compressedSize,12),writeUInt64LE(zeiefBuffer,this.relativeOffsetOfLocalHeader,20)):(versionNeededToExtract=VERSION_NEEDED_TO_EXTRACT_UTF8,zeiefBuffer=EMPTY_BUFFER),fixedSizeStuff.writeUInt32LE(33639248,0),fixedSizeStuff.writeUInt16LE(VERSION_MADE_BY,4),fixedSizeStuff.writeUInt16LE(versionNeededToExtract,6),fixedSizeStuff.writeUInt16LE(generalPurposeBitFlag,8),fixedSizeStuff.writeUInt16LE(this.getCompressionMethod(),10),fixedSizeStuff.writeUInt16LE(this.lastModFileTime,12),fixedSizeStuff.writeUInt16LE(this.lastModFileDate,14),fixedSizeStuff.writeUInt32LE(this.crc32,16),fixedSizeStuff.writeUInt32LE(normalCompressedSize,20),fixedSizeStuff.writeUInt32LE(normalUncompressedSize,24),fixedSizeStuff.writeUInt16LE(this.utf8FileName.length,28),fixedSizeStuff.writeUInt16LE(zeiefBuffer.length,30),fixedSizeStuff.writeUInt16LE(this.fileComment.length,32),fixedSizeStuff.writeUInt16LE(0,34),fixedSizeStuff.writeUInt16LE(0,36),fixedSizeStuff.writeUInt32LE(this.externalFileAttributes,38),fixedSizeStuff.writeUInt32LE(normalRelativeOffsetOfLocalHeader,42),Buffer.concat([fixedSizeStuff,this.utf8FileName,zeiefBuffer,this.fileComment])};Entry.prototype.getCompressionMethod=function(){var NO_COMPRESSION=0,DEFLATE_COMPRESSION=8;return this.compress?DEFLATE_COMPRESSION:NO_COMPRESSION};function dateToDosDateTime(jsDate){var date=0;date|=jsDate.getDate()&31,date|=(jsDate.getMonth()+1&15)<<5,date|=(jsDate.getFullYear()-1980&127)<<9;var time=0;return time|=Math.floor(jsDate.getSeconds()/2),time|=(jsDate.getMinutes()&63)<<5,time|=(jsDate.getHours()&31)<<11,{date,time}}function writeUInt64LE(buffer,n,offset){var high=Math.floor(n/4294967296),low=n%4294967296;buffer.writeUInt32LE(low,offset),buffer.writeUInt32LE(high,offset+4)}util.inherits(ByteCounter,Transform);function ByteCounter(options){Transform.call(this,options),this.byteCount=0}ByteCounter.prototype._transform=function(chunk,encoding,cb){this.byteCount+=chunk.length,cb(null,chunk)};util.inherits(Crc32Watcher,Transform);function Crc32Watcher(options){Transform.call(this,options),this.crc32=0}Crc32Watcher.prototype._transform=function(chunk,encoding,cb){this.crc32=crc32.unsigned(chunk,this.crc32),cb(null,chunk)};var cp437="\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\xB6\xA7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";if(cp437.length!==256)throw new Error("assertion failure");var reverseCp437=null;function encodeCp437(string){if(/^[\x20-\x7e]*$/.test(string))return bufferFrom(string,"utf-8");if(reverseCp437==null){reverseCp437={};for(var i=0;i<cp437.length;i++)reverseCp437[cp437[i]]=i}for(var result=bufferAlloc(string.length),i=0;i<string.length;i++){var b=reverseCp437[string[i]];if(b==null)throw new Error("character not encodable in CP437: "+JSON.stringify(string[i]));result[i]=b}return result}function bufferAlloc(size){bufferAlloc=modern;try{return bufferAlloc(size)}catch{return bufferAlloc=legacy,bufferAlloc(size)}function modern(size2){return Buffer.allocUnsafe(size2)}function legacy(size2){return new Buffer(size2)}}function bufferFrom(something,encoding){bufferFrom=modern;try{return bufferFrom(something,encoding)}catch{return bufferFrom=legacy,bufferFrom(something,encoding)}function modern(something2,encoding2){return Buffer.from(something2,encoding2)}function legacy(something2,encoding2){return new Buffer(something2,encoding2)}}function bufferIncludes(buffer,content){bufferIncludes=modern;try{return bufferIncludes(buffer,content)}catch{return bufferIncludes=legacy,bufferIncludes(buffer,content)}function modern(buffer2,content2){return buffer2.includes(content2)}function legacy(buffer2,content2){for(var i=0;i<=buffer2.length-content2.length;i++)for(var j=0;;j++){if(j===content2.length)return!0;if(buffer2[i+j]!==content2[j])break}return!1}}}});var require_concat_map=__commonJS({"../../node_modules/.pnpm/concat-map@0.0.1/node_modules/concat-map/index.js"(exports2,module2){module2.exports=function(xs,fn){for(var res=[],i=0;i<xs.length;i++){var x=fn(xs[i],i);isArray(x)?res.push.apply(res,x):res.push(x)}return res};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"}}});var require_balanced_match=__commonJS({"../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports2,module2){"use strict";module2.exports=balanced;function balanced(a,b,str){a instanceof RegExp&&(a=maybeMatch(a,str)),b instanceof RegExp&&(b=maybeMatch(b,str));var r=range(a,b,str);return r&&{start:r[0],end:r[1],pre:str.slice(0,r[0]),body:str.slice(r[0]+a.length,r[1]),post:str.slice(r[1]+b.length)}}function maybeMatch(reg,str){var m=str.match(reg);return m?m[0]:null}balanced.range=range;function range(a,b,str){var begs,beg,left,right,result,ai=str.indexOf(a),bi=str.indexOf(b,ai+1),i=ai;if(ai>=0&&bi>0){if(a===b)return[ai,bi];for(begs=[],left=str.length;i>=0&&!result;)i==ai?(begs.push(i),ai=str.indexOf(a,i+1)):begs.length==1?result=[begs.pop(),bi]:(beg=begs.pop(),beg<left&&(left=beg,right=bi),bi=str.indexOf(b,i+1)),i=ai<bi&&ai>=0?ai:bi;begs.length&&(result=[left,right])}return result}}});var require_brace_expansion=__commonJS({"../../node_modules/.pnpm/brace-expansion@1.1.15/node_modules/brace-expansion/index.js"(exports2,module2){var concatMap=require_concat_map(),balanced=require_balanced_match();module2.exports=expandTop;var escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(str){return parseInt(str,10)==str?parseInt(str,10):str.charCodeAt(0)}function escapeBraces(str){return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(str){return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(str){if(!str)return[""];var parts=[],m=balanced("{","}",str);if(!m)return str.split(",");var pre=m.pre,body=m.body,post=m.post,p=pre.split(",");p[p.length-1]+="{"+body+"}";var postParts=parseCommaParts(post);return post.length&&(p[p.length-1]+=postParts.shift(),p.push.apply(p,postParts)),parts.push.apply(parts,p),parts}function expandTop(str,options){if(!str)return[];options=options||{};var max=options.max==null?1/0:options.max;return str.substr(0,2)==="{}"&&(str="\\{\\}"+str.substr(2)),expand(escapeBraces(str),max,!0).map(unescapeBraces)}function embrace(str){return"{"+str+"}"}function isPadded(el){return/^-?0\d/.test(el)}function lte(i,y){return i<=y}function gte2(i,y){return i>=y}function expand(str,max,isTop){var expansions=[],m=balanced("{","}",str);if(!m||/\$$/.test(m.pre))return[str];var isNumericSequence=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body),isAlphaSequence=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body),isSequence=isNumericSequence||isAlphaSequence,isOptions=m.body.indexOf(",")>=0;if(!isSequence&&!isOptions)return m.post.match(/,(?!,).*\}/)?(str=m.pre+"{"+m.body+escClose+m.post,expand(str,max,!0)):[str];var n;if(isSequence)n=m.body.split(/\.\./);else if(n=parseCommaParts(m.body),n.length===1&&(n=expand(n[0],max,!1).map(embrace),n.length===1)){var post=m.post.length?expand(m.post,max,!1):[""];return post.map(function(p){return m.pre+n[0]+p})}var pre=m.pre,post=m.post.length?expand(m.post,max,!1):[""],N;if(isSequence){var x=numeric(n[0]),y=numeric(n[1]),width=Math.max(n[0].length,n[1].length),incr=n.length==3?Math.max(Math.abs(numeric(n[2])),1):1,test=lte,reverse=y<x;reverse&&(incr*=-1,test=gte2);var pad=n.some(isPadded);N=[];for(var i=x;test(i,y)&&N.length<max;i+=incr){var c;if(isAlphaSequence)c=String.fromCharCode(i),c==="\\"&&(c="");else if(c=String(i),pad){var need=width-c.length;if(need>0){var z=new Array(need+1).join("0");i<0?c="-"+z+c.slice(1):c=z+c}}N.push(c)}}else N=concatMap(n,function(el){return expand(el,max,!1)});for(var j=0;j<N.length;j++)for(var k=0;k<post.length&&expansions.length<max;k++){var expansion=pre+N[j]+post[k];(!isTop||isSequence||expansion)&&expansions.push(expansion)}return expansions}}});var require_minimatch=__commonJS({"../../node_modules/.pnpm/minimatch@3.1.2/node_modules/minimatch/minimatch.js"(exports2,module2){module2.exports=minimatch3;minimatch3.Minimatch=Minimatch;var path9=function(){try{return require("path")}catch{}}()||{sep:"/"};minimatch3.sep=path9.sep;var GLOBSTAR=minimatch3.GLOBSTAR=Minimatch.GLOBSTAR={},expand=require_brace_expansion(),plTypes={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},qmark="[^/]",star=qmark+"*?",twoStarDot="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",twoStarNoDot="(?:(?!(?:\\/|^)\\.).)*?",reSpecials=charSet("().*{}+?[]^$\\!");function charSet(s){return s.split("").reduce(function(set,c){return set[c]=!0,set},{})}var slashSplit=/\/+/;minimatch3.filter=filter;function filter(pattern,options){return options=options||{},function(p,i,list){return minimatch3(p,pattern,options)}}function ext(a,b){b=b||{};var t={};return Object.keys(a).forEach(function(k){t[k]=a[k]}),Object.keys(b).forEach(function(k){t[k]=b[k]}),t}minimatch3.defaults=function(def){if(!def||typeof def!="object"||!Object.keys(def).length)return minimatch3;var orig=minimatch3,m=function(p,pattern,options){return orig(p,pattern,ext(def,options))};return m.Minimatch=function(pattern,options){return new orig.Minimatch(pattern,ext(def,options))},m.Minimatch.defaults=function(options){return orig.defaults(ext(def,options)).Minimatch},m.filter=function(pattern,options){return orig.filter(pattern,ext(def,options))},m.defaults=function(options){return orig.defaults(ext(def,options))},m.makeRe=function(pattern,options){return orig.makeRe(pattern,ext(def,options))},m.braceExpand=function(pattern,options){return orig.braceExpand(pattern,ext(def,options))},m.match=function(list,pattern,options){return orig.match(list,pattern,ext(def,options))},m};Minimatch.defaults=function(def){return minimatch3.defaults(def).Minimatch};function minimatch3(p,pattern,options){return assertValidPattern(pattern),options||(options={}),!options.nocomment&&pattern.charAt(0)==="#"?!1:new Minimatch(pattern,options).match(p)}function Minimatch(pattern,options){if(!(this instanceof Minimatch))return new Minimatch(pattern,options);assertValidPattern(pattern),options||(options={}),pattern=pattern.trim(),!options.allowWindowsEscape&&path9.sep!=="/"&&(pattern=pattern.split(path9.sep).join("/")),this.options=options,this.set=[],this.pattern=pattern,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!options.partial,this.make()}Minimatch.prototype.debug=function(){};Minimatch.prototype.make=make;function make(){var pattern=this.pattern,options=this.options;if(!options.nocomment&&pattern.charAt(0)==="#"){this.comment=!0;return}if(!pattern){this.empty=!0;return}this.parseNegate();var set=this.globSet=this.braceExpand();options.debug&&(this.debug=function(){console.error.apply(console,arguments)}),this.debug(this.pattern,set),set=this.globParts=set.map(function(s){return s.split(slashSplit)}),this.debug(this.pattern,set),set=set.map(function(s,si,set2){return s.map(this.parse,this)},this),this.debug(this.pattern,set),set=set.filter(function(s){return s.indexOf(!1)===-1}),this.debug(this.pattern,set),this.set=set}Minimatch.prototype.parseNegate=parseNegate;function parseNegate(){var pattern=this.pattern,negate=!1,options=this.options,negateOffset=0;if(!options.nonegate){for(var i=0,l=pattern.length;i<l&&pattern.charAt(i)==="!";i++)negate=!negate,negateOffset++;negateOffset&&(this.pattern=pattern.substr(negateOffset)),this.negate=negate}}minimatch3.braceExpand=function(pattern,options){return braceExpand(pattern,options)};Minimatch.prototype.braceExpand=braceExpand;function braceExpand(pattern,options){return options||(this instanceof Minimatch?options=this.options:options={}),pattern=typeof pattern>"u"?this.pattern:pattern,assertValidPattern(pattern),options.nobrace||!/\{(?:(?!\{).)*\}/.test(pattern)?[pattern]:expand(pattern)}var MAX_PATTERN_LENGTH=1024*64,assertValidPattern=function(pattern){if(typeof pattern!="string")throw new TypeError("invalid pattern");if(pattern.length>MAX_PATTERN_LENGTH)throw new TypeError("pattern is too long")};Minimatch.prototype.parse=parse6;var SUBPARSE={};function parse6(pattern,isSub){assertValidPattern(pattern);var options=this.options;if(pattern==="**")if(options.noglobstar)pattern="*";else return GLOBSTAR;if(pattern==="")return"";var re="",hasMagic=!!options.nocase,escaping=!1,patternListStack=[],negativeLists=[],stateChar,inClass=!1,reClassStart=-1,classStart=-1,patternStart=pattern.charAt(0)==="."?"":options.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",self2=this;function clearStateChar(){if(stateChar){switch(stateChar){case"*":re+=star,hasMagic=!0;break;case"?":re+=qmark,hasMagic=!0;break;default:re+="\\"+stateChar;break}self2.debug("clearStateChar %j %j",stateChar,re),stateChar=!1}}for(var i=0,len=pattern.length,c;i<len&&(c=pattern.charAt(i));i++){if(this.debug("%s %s %s %j",pattern,i,re,c),escaping&&reSpecials[c]){re+="\\"+c,escaping=!1;continue}switch(c){case"/":return!1;case"\\":clearStateChar(),escaping=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",pattern,i,re,c),inClass){this.debug(" in class"),c==="!"&&i===classStart+1&&(c="^"),re+=c;continue}self2.debug("call clearStateChar %j",stateChar),clearStateChar(),stateChar=c,options.noext&&clearStateChar();continue;case"(":if(inClass){re+="(";continue}if(!stateChar){re+="\\(";continue}patternListStack.push({type:stateChar,start:i-1,reStart:re.length,open:plTypes[stateChar].open,close:plTypes[stateChar].close}),re+=stateChar==="!"?"(?:(?!(?:":"(?:",this.debug("plType %j %j",stateChar,re),stateChar=!1;continue;case")":if(inClass||!patternListStack.length){re+="\\)";continue}clearStateChar(),hasMagic=!0;var pl=patternListStack.pop();re+=pl.close,pl.type==="!"&&negativeLists.push(pl),pl.reEnd=re.length;continue;case"|":if(inClass||!patternListStack.length||escaping){re+="\\|",escaping=!1;continue}clearStateChar(),re+="|";continue;case"[":if(clearStateChar(),inClass){re+="\\"+c;continue}inClass=!0,classStart=i,reClassStart=re.length,re+=c;continue;case"]":if(i===classStart+1||!inClass){re+="\\"+c,escaping=!1;continue}var cs=pattern.substring(classStart+1,i);try{RegExp("["+cs+"]")}catch{var sp=this.parse(cs,SUBPARSE);re=re.substr(0,reClassStart)+"\\["+sp[0]+"\\]",hasMagic=hasMagic||sp[1],inClass=!1;continue}hasMagic=!0,inClass=!1,re+=c;continue;default:clearStateChar(),escaping?escaping=!1:reSpecials[c]&&!(c==="^"&&inClass)&&(re+="\\"),re+=c}}for(inClass&&(cs=pattern.substr(classStart+1),sp=this.parse(cs,SUBPARSE),re=re.substr(0,reClassStart)+"\\["+sp[0],hasMagic=hasMagic||sp[1]),pl=patternListStack.pop();pl;pl=patternListStack.pop()){var tail=re.slice(pl.reStart+pl.open.length);this.debug("setting tail",re,pl),tail=tail.replace(/((?:\\{2}){0,64})(\\?)\|/g,function(_,$1,$2){return $2||($2="\\"),$1+$1+$2+"|"}),this.debug(`tail=%j
|
|
8
8
|
%s`,tail,tail,pl,re);var t=pl.type==="*"?star:pl.type==="?"?qmark:"\\"+pl.type;hasMagic=!0,re=re.slice(0,pl.reStart)+t+"\\("+tail}clearStateChar(),escaping&&(re+="\\\\");var addPatternStart=!1;switch(re.charAt(0)){case"[":case".":case"(":addPatternStart=!0}for(var n=negativeLists.length-1;n>-1;n--){var nl=negativeLists[n],nlBefore=re.slice(0,nl.reStart),nlFirst=re.slice(nl.reStart,nl.reEnd-8),nlLast=re.slice(nl.reEnd-8,nl.reEnd),nlAfter=re.slice(nl.reEnd);nlLast+=nlAfter;var openParensBefore=nlBefore.split("(").length-1,cleanAfter=nlAfter;for(i=0;i<openParensBefore;i++)cleanAfter=cleanAfter.replace(/\)[+*?]?/,"");nlAfter=cleanAfter;var dollar="";nlAfter===""&&isSub!==SUBPARSE&&(dollar="$");var newRe=nlBefore+nlFirst+nlAfter+dollar+nlLast;re=newRe}if(re!==""&&hasMagic&&(re="(?=.)"+re),addPatternStart&&(re=patternStart+re),isSub===SUBPARSE)return[re,hasMagic];if(!hasMagic)return globUnescape(pattern);var flags=options.nocase?"i":"";try{var regExp=new RegExp("^"+re+"$",flags)}catch{return new RegExp("$.")}return regExp._glob=pattern,regExp._src=re,regExp}minimatch3.makeRe=function(pattern,options){return new Minimatch(pattern,options||{}).makeRe()};Minimatch.prototype.makeRe=makeRe;function makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;var set=this.set;if(!set.length)return this.regexp=!1,this.regexp;var options=this.options,twoStar=options.noglobstar?star:options.dot?twoStarDot:twoStarNoDot,flags=options.nocase?"i":"",re=set.map(function(pattern){return pattern.map(function(p){return p===GLOBSTAR?twoStar:typeof p=="string"?regExpEscape(p):p._src}).join("\\/")}).join("|");re="^(?:"+re+")$",this.negate&&(re="^(?!"+re+").*$");try{this.regexp=new RegExp(re,flags)}catch{this.regexp=!1}return this.regexp}minimatch3.match=function(list,pattern,options){options=options||{};var mm=new Minimatch(pattern,options);return list=list.filter(function(f){return mm.match(f)}),mm.options.nonull&&!list.length&&list.push(pattern),list};Minimatch.prototype.match=function(f,partial){if(typeof partial>"u"&&(partial=this.partial),this.debug("match",f,this.pattern),this.comment)return!1;if(this.empty)return f==="";if(f==="/"&&partial)return!0;var options=this.options;path9.sep!=="/"&&(f=f.split(path9.sep).join("/")),f=f.split(slashSplit),this.debug(this.pattern,"split",f);var set=this.set;this.debug(this.pattern,"set",set);var filename,i;for(i=f.length-1;i>=0&&(filename=f[i],!filename);i--);for(i=0;i<set.length;i++){var pattern=set[i],file=f;options.matchBase&&pattern.length===1&&(file=[filename]);var hit=this.matchOne(file,pattern,partial);if(hit)return options.flipNegate?!0:!this.negate}return options.flipNegate?!1:this.negate};Minimatch.prototype.matchOne=function(file,pattern,partial){var options=this.options;this.debug("matchOne",{this:this,file,pattern}),this.debug("matchOne",file.length,pattern.length);for(var fi=0,pi=0,fl=file.length,pl=pattern.length;fi<fl&&pi<pl;fi++,pi++){this.debug("matchOne loop");var p=pattern[pi],f=file[fi];if(this.debug(pattern,p,f),p===!1)return!1;if(p===GLOBSTAR){this.debug("GLOBSTAR",[pattern,p,f]);var fr=fi,pr=pi+1;if(pr===pl){for(this.debug("** at the end");fi<fl;fi++)if(file[fi]==="."||file[fi]===".."||!options.dot&&file[fi].charAt(0)===".")return!1;return!0}for(;fr<fl;){var swallowee=file[fr];if(this.debug(`
|
|
9
9
|
globstar while`,file,fr,pattern,pr,swallowee),this.matchOne(file.slice(fr),pattern.slice(pr),partial))return this.debug("globstar found match!",fr,fl,swallowee),!0;if(swallowee==="."||swallowee===".."||!options.dot&&swallowee.charAt(0)==="."){this.debug("dot detected!",file,fr,pattern,pr);break}this.debug("globstar swallow a segment, and continue"),fr++}return!!(partial&&(this.debug(`
|
|
10
|
-
>>> no match, partial?`,file,fr,pattern,pr),fr===fl))}var hit;if(typeof p=="string"?(hit=f===p,this.debug("string match",p,f,hit)):(hit=f.match(p),this.debug("pattern match",p,f,hit)),!hit)return!1}if(fi===fl&&pi===pl)return!0;if(fi===fl)return partial;if(pi===pl)return fi===fl-1&&file[fi]==="";throw new Error("wtf?")};function globUnescape(s){return s.replace(/\\(.)/g,"$1")}function regExpEscape(s){return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}}});var errors_exports={};__export(errors_exports,{NowBuildError:()=>NowBuildError,getPrettyError:()=>getPrettyError});function getPrettyError(obj){let docsUrl="https://vercel.com/docs/concepts/projects/project-configuration";try{let{dataPath,params,message:ajvMessage}=obj,prop=getTopLevelPropertyName(dataPath),message=dataPath&&dataPath.startsWith(".")?`\`${dataPath.slice(1)}\` `:"";if(params&&typeof params.additionalProperty=="string"){let suggestion=getSuggestion(prop,params.additionalProperty);message+=`should NOT have additional property \`${params.additionalProperty}\`. ${suggestion}`}else params&&typeof params.missingProperty=="string"?message+=`missing required property \`${params.missingProperty}\`.`:message+=`${ajvMessage}.`;return new NowBuildError({code:"INVALID_VERCEL_CONFIG",message,link:prop?`${docsUrl}#${prop.toLowerCase()}`:docsUrl,action:"View Documentation"})}catch{return new NowBuildError({code:"INVALID_VERCEL_CONFIG",message:"Failed to validate configuration.",link:docsUrl,action:"View Documentation"})}}function getTopLevelPropertyName(dataPath){if(dataPath&&dataPath.startsWith(".")){let lastIndex=dataPath.indexOf("[");return lastIndex>-1?dataPath.slice(1,lastIndex):dataPath.slice(1)}return""}function getSuggestion(topLevelProp,additionalProperty){let choices=mapTypoToSuggestion[topLevelProp],choice=choices?choices[additionalProperty]:void 0;return choice?`Did you mean \`${choice}\`?`:"Please remove it."}var NowBuildError,mapTypoToSuggestion,init_errors=__esm({"src/errors.ts"(){"use strict";NowBuildError=class extends Error{constructor({message,code,link,action}){super(message);this.hideStackTrace=!0;this.code=code,this.link=link,this.action=action}};mapTypoToSuggestion={"":{builder:"builds","build.env":'{ "build": { "env": {"name": "value"} } }',"builds.env":'{ "build": { "env": {"name": "value"} } }'},rewrites:{src:"source",dest:"destination"},redirects:{src:"source",dest:"destination",status:"statusCode"},headers:{src:"source",header:"headers"},routes:{header:"headers",method:"methods"}}}});var get_platform_env_exports={};__export(get_platform_env_exports,{getPlatformEnv:()=>getPlatformEnv});var getPlatformEnv,init_get_platform_env=__esm({"src/get-platform-env.ts"(){"use strict";init_errors();getPlatformEnv=name=>{let vName=`VERCEL_${name}`,nName=`NOW_${name}`,v=process.env[vName],n=process.env[nName];if(typeof v=="string"){if(typeof n=="string")throw new NowBuildError({code:"CONFLICTING_ENV_VAR_NAMES",message:`Both "${vName}" and "${nName}" env vars are defined. Please only define the "${vName}" env var.`,link:"https://vercel.link/combining-old-and-new-config"});return v}return n}}});var debug_exports={};__export(debug_exports,{default:()=>debug});function debug(message,...additional){getPlatformEnv("BUILDER_DEBUG")?console.log(message,...additional):process.env.VERCEL_DEBUG_PREFIX&&console.log(`${process.env.VERCEL_DEBUG_PREFIX}${message}`,...additional)}var init_debug=__esm({"src/debug.ts"(){"use strict";init_get_platform_env()}});var require_wrappy=__commonJS({"../../node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js"(exports2,module2){module2.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!="function")throw new TypeError("need wrapper function");return Object.keys(fn).forEach(function(k){wrapper[k]=fn[k]}),wrapper;function wrapper(){for(var args=new Array(arguments.length),i=0;i<args.length;i++)args[i]=arguments[i];var ret=fn.apply(this,args),cb2=args[args.length-1];return typeof ret=="function"&&ret!==cb2&&Object.keys(cb2).forEach(function(k){ret[k]=cb2[k]}),ret}}}});var require_once=__commonJS({"../../node_modules/.pnpm/once@1.4.0/node_modules/once/once.js"(exports2,module2){var wrappy=require_wrappy();module2.exports=wrappy(once);module2.exports.strict=wrappy(onceStrict);once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:!0})});function once(fn){var f=function(){return f.called?f.value:(f.called=!0,f.value=fn.apply(this,arguments))};return f.called=!1,f}function onceStrict(fn){var f=function(){if(f.called)throw new Error(f.onceError);return f.called=!0,f.value=fn.apply(this,arguments)},name=fn.name||"Function wrapped with `once`";return f.onceError=name+" shouldn't be called more than once",f.called=!1,f}}});var require_end_of_stream=__commonJS({"../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js"(exports2,module2){var once=require_once(),noop=function(){},isRequest=function(stream){return stream.setHeader&&typeof stream.abort=="function"},isChildProcess=function(stream){return stream.stdio&&Array.isArray(stream.stdio)&&stream.stdio.length===3},eos2=function(stream,opts,callback){if(typeof opts=="function")return eos2(stream,null,opts);opts||(opts={}),callback=once(callback||noop);var ws=stream._writableState,rs=stream._readableState,readable=opts.readable||opts.readable!==!1&&stream.readable,writable=opts.writable||opts.writable!==!1&&stream.writable,onlegacyfinish=function(){stream.writable||onfinish()},onfinish=function(){writable=!1,readable||callback.call(stream)},onend=function(){readable=!1,writable||callback.call(stream)},onexit=function(exitCode){callback.call(stream,exitCode?new Error("exited with error code: "+exitCode):null)},onerror=function(err){callback.call(stream,err)},onclose=function(){if(readable&&!(rs&&rs.ended))return callback.call(stream,new Error("premature close"));if(writable&&!(ws&&ws.ended))return callback.call(stream,new Error("premature close"))},onrequest=function(){stream.req.on("finish",onfinish)};return isRequest(stream)?(stream.on("complete",onfinish),stream.on("abort",onclose),stream.req?onrequest():stream.on("request",onrequest)):writable&&!ws&&(stream.on("end",onlegacyfinish),stream.on("close",onlegacyfinish)),isChildProcess(stream)&&stream.on("exit",onexit),stream.on("end",onend),stream.on("finish",onfinish),opts.error!==!1&&stream.on("error",onerror),stream.on("close",onclose),function(){stream.removeListener("complete",onfinish),stream.removeListener("abort",onclose),stream.removeListener("request",onrequest),stream.req&&stream.req.removeListener("finish",onfinish),stream.removeListener("end",onlegacyfinish),stream.removeListener("close",onlegacyfinish),stream.removeListener("finish",onfinish),stream.removeListener("exit",onexit),stream.removeListener("end",onend),stream.removeListener("error",onerror),stream.removeListener("close",onclose)}};module2.exports=eos2}});var stream_to_buffer_exports={};__export(stream_to_buffer_exports,{default:()=>streamToBuffer,streamToBufferChunks:()=>streamToBufferChunks});function streamToBuffer(stream){return new Promise((resolve3,reject)=>{let buffers=[];stream.on("data",chunk=>{let buffer=Buffer.isBuffer(chunk)?chunk:Buffer.from(chunk);buffers.push(Uint8Array.from(buffer))}),(0,import_end_of_stream.default)(stream,err=>{if(err){reject(err);return}try{switch(buffers.length){case 0:resolve3(Buffer.allocUnsafe(0));break;case 1:resolve3(Buffer.from(buffers[0]));break;default:resolve3(Buffer.concat(buffers))}}catch(concatErr){reject(concatErr)}})})}async function streamToBufferChunks(stream,chunkSize=100*MB){let chunks=[],currentChunk=[],currentSize=0;for await(let chunk of stream){let buffer=Buffer.isBuffer(chunk)?chunk:Buffer.from(chunk),offset=0;for(;offset<buffer.length;){let remainingSpace=chunkSize-currentSize,sliceSize=Math.min(remainingSpace,buffer.length-offset);currentChunk.push(Uint8Array.from(buffer.subarray(offset,offset+sliceSize))),currentSize+=sliceSize,offset+=sliceSize,currentSize>=chunkSize&&(chunks.push(Buffer.concat(currentChunk)),currentChunk=[],currentSize=0)}}return currentChunk.length>0&&chunks.push(Buffer.concat(currentChunk)),chunks}var import_end_of_stream,MB,init_stream_to_buffer=__esm({"src/fs/stream-to-buffer.ts"(){"use strict";import_end_of_stream=__toESM(require_end_of_stream());MB=1024*1024}});var download_exports={};__export(download_exports,{default:()=>download,downloadFile:()=>downloadFile,getSymlinkTarget:()=>getSymlinkTarget,isDirectory:()=>isDirectory,isExternalSymlink:()=>isExternalSymlink,isExternalSymlinkTarget:()=>isExternalSymlinkTarget,isSymbolicLink:()=>isSymbolicLink});function isDirectory(mode){return(mode&S_IFMT)===S_IFDIR}function isSymbolicLink(mode){return(mode&S_IFMT)===S_IFLNK}function isExternalSymlinkTarget(target){return target.startsWith("../")||target.startsWith("..\\")||import_path2.default.isAbsolute(target)}function getSymlinkTarget(file){if(!isSymbolicLink(file.mode))return null;if(file.type==="FileFsRef")try{return(0,import_fs_extra2.readlinkSync)(file.fsPath)}catch{return null}if(file.type==="FileBlob"){let{data}=file;return typeof data=="string"?data:data.toString("utf8")}return null}function isExternalSymlink(file){let target=getSymlinkTarget(file);return target!==null&&isExternalSymlinkTarget(target)}async function prepareSymlinkTarget(file,fsPath){let mkdirPromise=(0,import_fs_extra2.mkdirp)(import_path2.default.dirname(fsPath));if(file.type==="FileFsRef"){let[target]=await Promise.all([(0,import_fs_extra2.readlink)(file.fsPath),mkdirPromise]);return target}if(file.type==="FileRef"||file.type==="FileBlob"){let targetPathBufferPromise=streamToBuffer(await file.toStreamAsync()),[targetPathBuffer]=await Promise.all([targetPathBufferPromise,mkdirPromise]);return targetPathBuffer.toString("utf8")}throw new Error(`file.type "${file.type}" not supported for symlink`)}async function downloadFile(file,fsPath){let{mode}=file;if(isDirectory(mode))return await(0,import_fs_extra2.mkdirp)(fsPath),await(0,import_fs_extra2.chmod)(fsPath,mode),file_fs_ref_default.fromFsPath({mode,fsPath});if(isSymbolicLink(mode)){let target=await prepareSymlinkTarget(file,fsPath);try{await(0,import_fs_extra2.symlink)(target,fsPath)}catch(err){if(err.code==="EEXIST")await(0,import_fs_extra2.readlink)(fsPath)!==target&&(await(0,import_fs_extra2.remove)(fsPath),await(0,import_fs_extra2.symlink)(target,fsPath));else throw err}return file_fs_ref_default.fromFsPath({mode,fsPath})}let stream=file.toStream();return file_fs_ref_default.fromStream({mode,stream,fsPath})}async function removeFile(basePath,fileMatched){let file=import_path2.default.join(basePath,fileMatched);await(0,import_fs_extra2.remove)(file)}async function download(files,basePath,meta){let{isDev=!1,skipDownload=!1,filesChanged=null,filesRemoved=null}=meta||{};if(isDev||skipDownload)return files;debug("Downloading deployment source files...");let start=Date.now(),files2={},filenames=Object.keys(files);await Promise.all(filenames.map(async name=>{if(Array.isArray(filesRemoved)&&filesRemoved.includes(name)){await removeFile(basePath,name);return}if(Array.isArray(filesChanged)&&!filesChanged.includes(name))return;let parts=name.split("/");for(let i=1;i<parts.length;i++){let dir=parts.slice(0,i).join("/"),parent=files[dir];if(parent&&isSymbolicLink(parent.mode)&&!isExternalSymlink(parent)){console.warn(`Warning: file "${name}" is within a symlinked directory "${dir}" and will be ignored`);return}}let file=files[name],fsPath=import_path2.default.join(basePath,name);files2[name]=await downloadFile(file,fsPath)}));let duration=Date.now()-start;return debug(`Downloaded ${filenames.length} source files: ${duration}ms`),files2}var import_path2,import_fs_extra2,S_IFDIR,S_IFLNK,S_IFMT,init_download=__esm({"src/fs/download.ts"(){"use strict";import_path2=__toESM(require("path"));init_debug();init_file_fs_ref();import_fs_extra2=__toESM(require_lib());init_stream_to_buffer();S_IFDIR=16384,S_IFLNK=40960,S_IFMT=61440}});var lambda_exports={};__export(lambda_exports,{Lambda:()=>Lambda,createLambda:()=>createLambda,createZip:()=>createZip,getLambdaOptionsFromFunction:()=>getLambdaOptionsFromFunction,sanitizeConsumerName:()=>sanitizeConsumerName});function sanitizeConsumerName(functionPath){let result="";for(let char of functionPath)char==="_"?result+="__":char==="/"?result+="_S":char==="."?result+="_D":/[A-Za-z0-9-]/.test(char)?result+=char:result+="_"+char.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0");return result}function getDefaultLambdaArchitecture(architecture){if(architecture)return architecture;switch(process.arch){case"arm":case"arm64":return"arm64";default:return"x86_64"}}async function createLambda(opts){let lambda=new Lambda(opts);return lambda.zipBuffer=await lambda.createZip(),lambda}async function createZip(files){let names=Object.keys(files).sort(),symlinkTargets=new Map;for(let name of names){let file=files[name];if(file.mode&&isSymbolicLink(file.mode)&&file.type==="FileFsRef"){let symlinkTarget=await(0,import_fs_extra3.readlink)(file.fsPath);symlinkTargets.set(name,symlinkTarget)}}let zipFile=new import_yazl.ZipFile;return await new Promise((resolve3,reject)=>{for(let name of names){let file=files[name],opts={mode:file.mode,mtime},symlinkTarget=symlinkTargets.get(name);if(typeof symlinkTarget=="string")zipFile.addBuffer(Buffer.from(symlinkTarget,"utf8"),name,opts);else if(file.mode&&isDirectory(file.mode))zipFile.addEmptyDirectory(name,opts);else{let stream=file.toStream();stream.on("error",reject),zipFile.addReadStream(stream,name,opts)}}zipFile.end(),streamToBuffer(zipFile.outputStream).then(resolve3).catch(reject)})}async function getLambdaOptionsFromFunction({sourceFile,config,isScheduleEntrypoint=!1}){if(config?.functions){let serviceName=typeof config.serviceName=="string"&&config.serviceName!==""?config.serviceName:void 0;for(let[pattern,fn]of Object.entries(config.functions))if(sourceFile===pattern||(0,import_minimatch.default)(sourceFile,pattern)){let consumer=sanitizeConsumerName(serviceName?`${serviceName}~${pattern}`:pattern),experimentalTriggers=fn.experimentalTriggers?.map(trigger=>trigger.type==="queue/v2beta"?{...trigger,consumer}:trigger);if(experimentalTriggers&&experimentalTriggers.length>1&&experimentalTriggers.some(t=>t.type==="queue/v2beta"))throw new Error(`functions["${pattern}"].experimentalTriggers can only have one item for queue/v2beta`);if(isScheduleEntrypoint&&experimentalTriggers!==void 0&&!(experimentalTriggers.length===1&&experimentalTriggers[0]?.type==="schedule/v1beta"))throw new Error(`functions["${pattern}"].experimentalTriggers conflicts with the schedule entrypoint trigger`);return{architecture:fn.architecture,memory:fn.memory,maxDuration:fn.maxDuration,affinity:fn.affinity,maxConcurrency:fn.maxConcurrency,regions:fn.regions,functionFailoverRegions:fn.functionFailoverRegions,experimentalTriggers:isScheduleEntrypoint?[{type:"schedule/v1beta"}]:experimentalTriggers,supportsCancellation:fn.supportsCancellation}}}return isScheduleEntrypoint?{experimentalTriggers:[{type:"schedule/v1beta"}]}:{}}var import_assert5,import_async_sema3,import_yazl,import_minimatch,import_fs_extra3,Lambda,sema,mtime,init_lambda=__esm({"src/lambda.ts"(){"use strict";import_assert5=__toESM(require("assert"));init_max_concurrency();import_async_sema3=__toESM(require_async_sema()),import_yazl=__toESM(require_yazl()),import_minimatch=__toESM(require_minimatch()),import_fs_extra3=__toESM(require_lib());init_download();init_stream_to_buffer();Lambda=class{constructor(opts){let{handler,runtime,runtimeLanguage,maxDuration,affinity,maxConcurrency,architecture,memory,environment={},allowQuery,regions,functionFailoverRegions,supportsMultiPayloads,supportsWrapper,supportsResponseStreaming,experimentalResponseStreaming,operationType,framework,experimentalTriggers,supportsCancellation,shouldDisableAutomaticFetchInstrumentation}=opts;if("files"in opts&&(0,import_assert5.default)(typeof opts.files=="object",'"files" must be an object'),"zipBuffer"in opts&&(0,import_assert5.default)(Buffer.isBuffer(opts.zipBuffer),'"zipBuffer" must be a Buffer'),(0,import_assert5.default)(typeof handler=="string",'"handler" is not a string'),(0,import_assert5.default)(typeof runtime=="string",'"runtime" is not a string'),(0,import_assert5.default)(typeof environment=="object",'"environment" is not an object'),architecture!==void 0&&(0,import_assert5.default)(architecture==="x86_64"||architecture==="arm64",'"architecture" must be either "x86_64" or "arm64"'),runtimeLanguage!==void 0&&(0,import_assert5.default)(runtimeLanguage==="rust"||runtimeLanguage==="go",'"runtimeLanguage" is invalid. Valid options: "rust", "go"'),"experimentalAllowBundling"in opts&&opts.experimentalAllowBundling!==void 0&&(0,import_assert5.default)(typeof opts.experimentalAllowBundling=="boolean",'"experimentalAllowBundling" is not a boolean'),memory!==void 0&&(0,import_assert5.default)(typeof memory=="number",'"memory" is not a number'),maxDuration!==void 0&&(0,import_assert5.default)(typeof maxDuration=="number"||maxDuration==="max",'"maxDuration" is not a number or "max"'),affinity!==void 0&&(0,import_assert5.default)(typeof affinity=="object"&&affinity!==null&&affinity.mode==="strict"&&Object.keys(affinity).length===1,'"affinity" must be an object with only `mode: "strict"`'),validateMaxConcurrency(maxConcurrency),allowQuery!==void 0&&((0,import_assert5.default)(Array.isArray(allowQuery),'"allowQuery" is not an Array'),(0,import_assert5.default)(allowQuery.every(q=>typeof q=="string"),'"allowQuery" is not a string Array')),supportsMultiPayloads!==void 0&&(0,import_assert5.default)(typeof supportsMultiPayloads=="boolean",'"supportsMultiPayloads" is not a boolean'),supportsWrapper!==void 0&&(0,import_assert5.default)(typeof supportsWrapper=="boolean",'"supportsWrapper" is not a boolean'),regions!==void 0&&((0,import_assert5.default)(Array.isArray(regions),'"regions" is not an Array'),(0,import_assert5.default)(regions.every(r=>typeof r=="string"),'"regions" is not a string Array')),functionFailoverRegions!==void 0&&((0,import_assert5.default)(Array.isArray(functionFailoverRegions),'"functionFailoverRegions" is not an Array'),(0,import_assert5.default)(functionFailoverRegions.every(r=>typeof r=="string"),'"functionFailoverRegions" is not a string Array')),framework!==void 0&&((0,import_assert5.default)(typeof framework=="object",'"framework" is not an object'),(0,import_assert5.default)(typeof framework.slug=="string",'"framework.slug" is not a string'),framework.version!==void 0&&(0,import_assert5.default)(typeof framework.version=="string",'"framework.version" is not a string')),experimentalTriggers!==void 0){(0,import_assert5.default)(Array.isArray(experimentalTriggers),'"experimentalTriggers" is not an Array');for(let i=0;i<experimentalTriggers.length;i++){let trigger=experimentalTriggers[i],prefix=`"experimentalTriggers[${i}]"`;(0,import_assert5.default)(typeof trigger=="object"&&trigger!==null,`${prefix} is not an object`),(0,import_assert5.default)(trigger.type==="queue/v1beta"||trigger.type==="queue/v2beta"||trigger.type==="schedule/v1beta",`${prefix}.type must be "queue/v1beta", "queue/v2beta", or "schedule/v1beta"`),(trigger.type==="queue/v1beta"||trigger.type==="queue/v2beta")&&((0,import_assert5.default)(typeof trigger.topic=="string",`${prefix}.topic is required and must be a string`),(0,import_assert5.default)(trigger.topic.length>0,`${prefix}.topic cannot be empty`),(0,import_assert5.default)(typeof trigger.consumer=="string",`${prefix}.consumer is required and must be a string`),(0,import_assert5.default)(trigger.consumer.length>0,`${prefix}.consumer cannot be empty`),trigger.maxDeliveries!==void 0&&((0,import_assert5.default)(typeof trigger.maxDeliveries=="number",`${prefix}.maxDeliveries must be a number`),(0,import_assert5.default)(Number.isInteger(trigger.maxDeliveries)&&trigger.maxDeliveries>=1,`${prefix}.maxDeliveries must be at least 1`)),trigger.retryAfterSeconds!==void 0&&((0,import_assert5.default)(typeof trigger.retryAfterSeconds=="number",`${prefix}.retryAfterSeconds must be a number`),(0,import_assert5.default)(trigger.retryAfterSeconds>0,`${prefix}.retryAfterSeconds must be a positive number`)),trigger.initialDelaySeconds!==void 0&&((0,import_assert5.default)(typeof trigger.initialDelaySeconds=="number",`${prefix}.initialDelaySeconds must be a number`),(0,import_assert5.default)(trigger.initialDelaySeconds>=0,`${prefix}.initialDelaySeconds must be a non-negative number`)),trigger.maxConcurrency!==void 0&&((0,import_assert5.default)(typeof trigger.maxConcurrency=="number",`${prefix}.maxConcurrency must be a number`),(0,import_assert5.default)(Number.isInteger(trigger.maxConcurrency)&&trigger.maxConcurrency>=1,`${prefix}.maxConcurrency must be at least 1`)))}}supportsCancellation!==void 0&&(0,import_assert5.default)(typeof supportsCancellation=="boolean",'"supportsCancellation" is not a boolean'),this.type="Lambda",this.operationType=operationType,this.files="files"in opts?opts.files:void 0,this.handler=handler,this.runtime=runtime,this.runtimeLanguage=runtimeLanguage,this.architecture=getDefaultLambdaArchitecture(architecture),this.memory=memory,this.maxDuration=maxDuration,this.affinity=affinity,this.maxConcurrency=maxConcurrency,this.environment=environment,this.allowQuery=allowQuery,this.regions=regions,this.functionFailoverRegions=functionFailoverRegions,this.zipBuffer="zipBuffer"in opts?opts.zipBuffer:void 0,this.supportsMultiPayloads=supportsMultiPayloads,this.supportsWrapper=supportsWrapper,this.supportsResponseStreaming=supportsResponseStreaming??experimentalResponseStreaming,this.framework=framework,this.experimentalAllowBundling="experimentalAllowBundling"in opts?opts.experimentalAllowBundling:void 0,this.experimentalTriggers=experimentalTriggers,this.supportsCancellation=supportsCancellation,this.shouldDisableAutomaticFetchInstrumentation=shouldDisableAutomaticFetchInstrumentation}async createZip(){let{zipBuffer}=this;if(!zipBuffer){if(!this.files)throw new Error("`files` is not defined");await sema.acquire();try{zipBuffer=await createZip(this.files)}finally{sema.release()}}return zipBuffer}get experimentalResponseStreaming(){return this.supportsResponseStreaming}set experimentalResponseStreaming(v){this.supportsResponseStreaming=v}},sema=new import_async_sema3.default(10),mtime=new Date(154e10)}});var nodejs_lambda_exports={};__export(nodejs_lambda_exports,{NodejsLambda:()=>NodejsLambda});var NodejsLambda,init_nodejs_lambda=__esm({"src/nodejs-lambda.ts"(){"use strict";init_lambda();NodejsLambda=class extends Lambda{constructor({shouldAddHelpers,shouldAddSourcemapSupport,awsLambdaHandler,useWebApi,...opts}){super(opts);this.launcherType="Nodejs",this.shouldAddHelpers=shouldAddHelpers,this.shouldAddSourcemapSupport=shouldAddSourcemapSupport,this.awsLambdaHandler=awsLambdaHandler,this.useWebApi=useWebApi}}}});var prerender_exports={};__export(prerender_exports,{Prerender:()=>Prerender});var Prerender,init_prerender=__esm({"src/prerender.ts"(){"use strict";Prerender=class{constructor({expiration,staleExpiration,lambda,fallback,group,bypassToken,allowQuery,allowHeader,initialHeaders,initialStatus,passQuery,sourcePath,experimentalBypassFor,experimentalStreamingLambdaPath,chain,exposeErrBody,partialFallback,initialMetadata}){if(this.type="Prerender",this.expiration=expiration,this.staleExpiration=staleExpiration,this.sourcePath=sourcePath,this.initialMetadata=initialMetadata,this.lambda=lambda,this.lambda&&(this.lambda.operationType=this.lambda.operationType||"ISR"),typeof group<"u"&&(group<=0||!Number.isInteger(group)))throw new Error("The `group` argument for `Prerender` needs to be a natural number.");if(this.group=group,passQuery===!0)this.passQuery=!0;else if(typeof passQuery!="boolean"&&typeof passQuery<"u")throw new Error("The `passQuery` argument for `Prerender` must be a boolean.");if(bypassToken==null)this.bypassToken=null;else if(typeof bypassToken=="string"){if(bypassToken.length<32)throw new Error("The `bypassToken` argument for `Prerender` must be 32 characters or more.");this.bypassToken=bypassToken}else throw new Error("The `bypassToken` argument for `Prerender` must be a `string`.");if(experimentalBypassFor!==void 0){if(!Array.isArray(experimentalBypassFor)||experimentalBypassFor.some(field=>typeof field!="object"||typeof field.type!="string"||field.type==="host"&&"key"in field||field.type!=="host"&&typeof field.key!="string"||field.value!==void 0&&typeof field.value!="string"&&(typeof field.value!="object"||field.value===null||Array.isArray(field.value))))throw new Error("The `experimentalBypassFor` argument for `Prerender` must be Array of objects with fields `type`, `key` and optionally `value`.");this.experimentalBypassFor=experimentalBypassFor}if(typeof fallback>"u")throw new Error("The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null.");if(this.fallback=fallback,initialHeaders!==void 0){if(!initialHeaders||typeof initialHeaders!="object"||Object.entries(initialHeaders).some(([key,value])=>typeof key!="string"||typeof value!="string"))throw new Error("The `initialHeaders` argument for `Prerender` must be an object with string key/values");this.initialHeaders=initialHeaders}if(initialStatus!==void 0){if(initialStatus<=0||!Number.isInteger(initialStatus))throw new Error("The `initialStatus` argument for `Prerender` must be a natural number.");this.initialStatus=initialStatus}if(allowQuery!==void 0){if(!Array.isArray(allowQuery))throw new Error("The `allowQuery` argument for `Prerender` must be Array.");if(!allowQuery.every(q=>typeof q=="string"))throw new Error("The `allowQuery` argument for `Prerender` must be Array of strings.");this.allowQuery=allowQuery}if(allowHeader!==void 0){if(!Array.isArray(allowHeader))throw new Error("The `allowHeader` argument for `Prerender` must be Array.");if(!allowHeader.every(q=>typeof q=="string"))throw new Error("The `allowHeader` argument for `Prerender` must be Array of strings.");this.allowHeader=allowHeader}if(experimentalStreamingLambdaPath!==void 0){if(typeof experimentalStreamingLambdaPath!="string")throw new Error("The `experimentalStreamingLambdaPath` argument for `Prerender` must be a string.");this.experimentalStreamingLambdaPath=experimentalStreamingLambdaPath}if(chain!==void 0){if(typeof chain!="object")throw new Error("The `chain` argument for `Prerender` must be an object.");if(!chain.headers||typeof chain.headers!="object"||Object.entries(chain.headers).some(([key,value])=>typeof key!="string"||typeof value!="string"))throw new Error("The `chain.headers` argument for `Prerender` must be an object with string key/values");if(!chain.outputPath||typeof chain.outputPath!="string")throw new Error("The `chain.outputPath` argument for `Prerender` must be a string.");this.chain=chain}if(exposeErrBody===!0)this.exposeErrBody=!0;else if(typeof exposeErrBody!="boolean"&&typeof exposeErrBody<"u")throw new Error("The `exposeErrBody` argument for `Prerender` must be a boolean.");if(partialFallback===!0)this.partialFallback=!0;else if(typeof partialFallback!="boolean"&&typeof partialFallback<"u")throw new Error("The `partialFallback` argument for `Prerender` must be a boolean.")}}}});var get_writable_directory_exports={};__export(get_writable_directory_exports,{default:()=>getWritableDirectory});async function getWritableDirectory(){let name=Math.floor(Math.random()*2147483647).toString(16),directory=(0,import_path3.join)((0,import_os.tmpdir)(),name);return await(0,import_fs_extra4.mkdirp)(directory),directory}var import_path3,import_os,import_fs_extra4,init_get_writable_directory=__esm({"src/fs/get-writable-directory.ts"(){"use strict";import_path3=require("path"),import_os=require("os"),import_fs_extra4=__toESM(require_lib())}});var require_old=__commonJS({"../../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js"(exports2){var pathModule=require("path"),isWindows=process.platform==="win32",fs12=require("fs"),DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var callback;if(DEBUG){var backtrace=new Error;callback=debugCallback}else callback=missingCallback;return callback;function debugCallback(err){err&&(backtrace.message=err.message,err=backtrace,missingCallback(err))}function missingCallback(err){if(err){if(process.throwDeprecation)throw err;if(!process.noDeprecation){var msg="fs: missing callback "+(err.stack||err.message);process.traceDeprecation?console.trace(msg):console.error(msg)}}}}function maybeCallback(cb){return typeof cb=="function"?cb:rethrow()}var normalize=pathModule.normalize;isWindows?nextPartRe=/(.*?)(?:[\/\\]+|$)/g:nextPartRe=/(.*?)(?:[\/]+|$)/g;var nextPartRe;isWindows?splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/:splitRootRe=/^[\/]*/;var splitRootRe;exports2.realpathSync=function(p,cache){if(p=pathModule.resolve(p),cache&&Object.prototype.hasOwnProperty.call(cache,p))return cache[p];var original=p,seenLinks={},knownHard={},pos,current,base,previous;start();function start(){var m=splitRootRe.exec(p);pos=m[0].length,current=m[0],base=m[0],previous="",isWindows&&!knownHard[base]&&(fs12.lstatSync(base),knownHard[base]=!0)}for(;pos<p.length;){nextPartRe.lastIndex=pos;var result=nextPartRe.exec(p);if(previous=current,current+=result[0],base=previous+result[1],pos=nextPartRe.lastIndex,!(knownHard[base]||cache&&cache[base]===base)){var resolvedLink;if(cache&&Object.prototype.hasOwnProperty.call(cache,base))resolvedLink=cache[base];else{var stat2=fs12.lstatSync(base);if(!stat2.isSymbolicLink()){knownHard[base]=!0,cache&&(cache[base]=base);continue}var linkTarget=null;if(!isWindows){var id=stat2.dev.toString(32)+":"+stat2.ino.toString(32);seenLinks.hasOwnProperty(id)&&(linkTarget=seenLinks[id])}linkTarget===null&&(fs12.statSync(base),linkTarget=fs12.readlinkSync(base)),resolvedLink=pathModule.resolve(previous,linkTarget),cache&&(cache[base]=resolvedLink),isWindows||(seenLinks[id]=linkTarget)}p=pathModule.resolve(resolvedLink,p.slice(pos)),start()}}return cache&&(cache[original]=p),p};exports2.realpath=function(p,cache,cb){if(typeof cb!="function"&&(cb=maybeCallback(cache),cache=null),p=pathModule.resolve(p),cache&&Object.prototype.hasOwnProperty.call(cache,p))return process.nextTick(cb.bind(null,null,cache[p]));var original=p,seenLinks={},knownHard={},pos,current,base,previous;start();function start(){var m=splitRootRe.exec(p);pos=m[0].length,current=m[0],base=m[0],previous="",isWindows&&!knownHard[base]?fs12.lstat(base,function(err){if(err)return cb(err);knownHard[base]=!0,LOOP()}):process.nextTick(LOOP)}function LOOP(){if(pos>=p.length)return cache&&(cache[original]=p),cb(null,p);nextPartRe.lastIndex=pos;var result=nextPartRe.exec(p);return previous=current,current+=result[0],base=previous+result[1],pos=nextPartRe.lastIndex,knownHard[base]||cache&&cache[base]===base?process.nextTick(LOOP):cache&&Object.prototype.hasOwnProperty.call(cache,base)?gotResolvedLink(cache[base]):fs12.lstat(base,gotStat)}function gotStat(err,stat2){if(err)return cb(err);if(!stat2.isSymbolicLink())return knownHard[base]=!0,cache&&(cache[base]=base),process.nextTick(LOOP);if(!isWindows){var id=stat2.dev.toString(32)+":"+stat2.ino.toString(32);if(seenLinks.hasOwnProperty(id))return gotTarget(null,seenLinks[id],base)}fs12.stat(base,function(err2){if(err2)return cb(err2);fs12.readlink(base,function(err3,target){isWindows||(seenLinks[id]=target),gotTarget(err3,target)})})}function gotTarget(err,target,base2){if(err)return cb(err);var resolvedLink=pathModule.resolve(previous,target);cache&&(cache[base2]=resolvedLink),gotResolvedLink(resolvedLink)}function gotResolvedLink(resolvedLink){p=pathModule.resolve(resolvedLink,p.slice(pos)),start()}}}});var require_fs2=__commonJS({"../../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js"(exports2,module2){module2.exports=realpath;realpath.realpath=realpath;realpath.sync=realpathSync2;realpath.realpathSync=realpathSync2;realpath.monkeypatch=monkeypatch;realpath.unmonkeypatch=unmonkeypatch;var fs12=require("fs"),origRealpath=fs12.realpath,origRealpathSync=fs12.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version),old=require_old();function newError(er){return er&&er.syscall==="realpath"&&(er.code==="ELOOP"||er.code==="ENOMEM"||er.code==="ENAMETOOLONG")}function realpath(p,cache,cb){if(ok)return origRealpath(p,cache,cb);typeof cache=="function"&&(cb=cache,cache=null),origRealpath(p,cache,function(er,result){newError(er)?old.realpath(p,cache,cb):cb(er,result)})}function realpathSync2(p,cache){if(ok)return origRealpathSync(p,cache);try{return origRealpathSync(p,cache)}catch(er){if(newError(er))return old.realpathSync(p,cache);throw er}}function monkeypatch(){fs12.realpath=realpath,fs12.realpathSync=realpathSync2}function unmonkeypatch(){fs12.realpath=origRealpath,fs12.realpathSync=origRealpathSync}}});var require_path=__commonJS({"../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/lib/path.js"(exports2,module2){var isWindows=typeof process=="object"&&process&&process.platform==="win32";module2.exports=isWindows?{sep:"\\"}:{sep:"/"}}});var require_brace_expansion2=__commonJS({"../../node_modules/.pnpm/brace-expansion@2.1.1/node_modules/brace-expansion/index.js"(exports2,module2){var balanced=require_balanced_match();module2.exports=expandTop;var escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(str){return parseInt(str,10)==str?parseInt(str,10):str.charCodeAt(0)}function escapeBraces(str){return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(str){return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(str){if(!str)return[""];var parts=[],m=balanced("{","}",str);if(!m)return str.split(",");var pre=m.pre,body=m.body,post=m.post,p=pre.split(",");p[p.length-1]+="{"+body+"}";var postParts=parseCommaParts(post);return post.length&&(p[p.length-1]+=postParts.shift(),p.push.apply(p,postParts)),parts.push.apply(parts,p),parts}function expandTop(str,options){if(!str)return[];options=options||{};var max=options.max==null?1/0:options.max;return str.substr(0,2)==="{}"&&(str="\\{\\}"+str.substr(2)),expand(escapeBraces(str),max,!0).map(unescapeBraces)}function embrace(str){return"{"+str+"}"}function isPadded(el){return/^-?0\d/.test(el)}function lte(i,y){return i<=y}function gte2(i,y){return i>=y}function expand(str,max,isTop){var expansions=[],m=balanced("{","}",str);if(!m)return[str];var pre=m.pre,post=m.post.length?expand(m.post,max,!1):[""];if(/\$$/.test(m.pre))for(var k=0;k<post.length&&k<max;k++){var expansion=pre+"{"+m.body+"}"+post[k];expansions.push(expansion)}else{var isNumericSequence=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body),isAlphaSequence=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body),isSequence=isNumericSequence||isAlphaSequence,isOptions=m.body.indexOf(",")>=0;if(!isSequence&&!isOptions)return m.post.match(/,(?!,).*\}/)?(str=m.pre+"{"+m.body+escClose+m.post,expand(str,max,!0)):[str];var n;if(isSequence)n=m.body.split(/\.\./);else if(n=parseCommaParts(m.body),n.length===1&&(n=expand(n[0],max,!1).map(embrace),n.length===1))return post.map(function(p){return m.pre+n[0]+p});var N;if(isSequence){var x=numeric(n[0]),y=numeric(n[1]),width=Math.max(n[0].length,n[1].length),incr=n.length==3?Math.max(Math.abs(numeric(n[2])),1):1,test=lte,reverse=y<x;reverse&&(incr*=-1,test=gte2);var pad=n.some(isPadded);N=[];for(var i=x;test(i,y)&&N.length<max;i+=incr){var c;if(isAlphaSequence)c=String.fromCharCode(i),c==="\\"&&(c="");else if(c=String(i),pad){var need=width-c.length;if(need>0){var z=new Array(need+1).join("0");i<0?c="-"+z+c.slice(1):c=z+c}}N.push(c)}}else{N=[];for(var j=0;j<n.length;j++)N.push.apply(N,expand(n[j],max,!1))}for(var j=0;j<N.length;j++)for(var k=0;k<post.length&&expansions.length<max;k++){var expansion=pre+N[j]+post[k];(!isTop||isSequence||expansion)&&expansions.push(expansion)}}return expansions}}});var require_minimatch2=__commonJS({"../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/minimatch.js"(exports2,module2){var minimatch3=module2.exports=(p,pattern,options={})=>(assertValidPattern(pattern),!options.nocomment&&pattern.charAt(0)==="#"?!1:new Minimatch(pattern,options).match(p));module2.exports=minimatch3;var path9=require_path();minimatch3.sep=path9.sep;var GLOBSTAR=Symbol("globstar **");minimatch3.GLOBSTAR=GLOBSTAR;var expand=require_brace_expansion2(),plTypes={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},qmark="[^/]",star=qmark+"*?",twoStarDot="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",twoStarNoDot="(?:(?!(?:\\/|^)\\.).)*?",charSet=s=>s.split("").reduce((set,c)=>(set[c]=!0,set),{}),reSpecials=charSet("().*{}+?[]^$\\!"),addPatternStartSet=charSet("[.("),slashSplit=/\/+/;minimatch3.filter=(pattern,options={})=>(p,i,list)=>minimatch3(p,pattern,options);var ext=(a,b={})=>{let t={};return Object.keys(a).forEach(k=>t[k]=a[k]),Object.keys(b).forEach(k=>t[k]=b[k]),t};minimatch3.defaults=def=>{if(!def||typeof def!="object"||!Object.keys(def).length)return minimatch3;let orig=minimatch3,m=(p,pattern,options)=>orig(p,pattern,ext(def,options));return m.Minimatch=class extends orig.Minimatch{constructor(pattern,options){super(pattern,ext(def,options))}},m.Minimatch.defaults=options=>orig.defaults(ext(def,options)).Minimatch,m.filter=(pattern,options)=>orig.filter(pattern,ext(def,options)),m.defaults=options=>orig.defaults(ext(def,options)),m.makeRe=(pattern,options)=>orig.makeRe(pattern,ext(def,options)),m.braceExpand=(pattern,options)=>orig.braceExpand(pattern,ext(def,options)),m.match=(list,pattern,options)=>orig.match(list,pattern,ext(def,options)),m};minimatch3.braceExpand=(pattern,options)=>braceExpand(pattern,options);var braceExpand=(pattern,options={})=>(assertValidPattern(pattern),options.nobrace||!/\{(?:(?!\{).)*\}/.test(pattern)?[pattern]:expand(pattern)),MAX_PATTERN_LENGTH=1024*64,assertValidPattern=pattern=>{if(typeof pattern!="string")throw new TypeError("invalid pattern");if(pattern.length>MAX_PATTERN_LENGTH)throw new TypeError("pattern is too long")},SUBPARSE=Symbol("subparse");minimatch3.makeRe=(pattern,options)=>new Minimatch(pattern,options||{}).makeRe();minimatch3.match=(list,pattern,options={})=>{let mm=new Minimatch(pattern,options);return list=list.filter(f=>mm.match(f)),mm.options.nonull&&!list.length&&list.push(pattern),list};var globUnescape=s=>s.replace(/\\(.)/g,"$1"),regExpEscape=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Minimatch=class{constructor(pattern,options){assertValidPattern(pattern),options||(options={}),this.options=options,this.set=[],this.pattern=pattern,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!options.partial,this.make()}debug(){}make(){let pattern=this.pattern,options=this.options;if(!options.nocomment&&pattern.charAt(0)==="#"){this.comment=!0;return}if(!pattern){this.empty=!0;return}this.parseNegate();let set=this.globSet=this.braceExpand();options.debug&&(this.debug=(...args)=>console.error(...args)),this.debug(this.pattern,set),set=this.globParts=set.map(s=>s.split(slashSplit)),this.debug(this.pattern,set),set=set.map((s,si,set2)=>s.map(this.parse,this)),this.debug(this.pattern,set),set=set.filter(s=>s.indexOf(!1)===-1),this.debug(this.pattern,set),this.set=set}parseNegate(){if(this.options.nonegate)return;let pattern=this.pattern,negate=!1,negateOffset=0;for(let i=0;i<pattern.length&&pattern.charAt(i)==="!";i++)negate=!negate,negateOffset++;negateOffset&&(this.pattern=pattern.substr(negateOffset)),this.negate=negate}matchOne(file,pattern,partial){var options=this.options;this.debug("matchOne",{this:this,file,pattern}),this.debug("matchOne",file.length,pattern.length);for(var fi=0,pi=0,fl=file.length,pl=pattern.length;fi<fl&&pi<pl;fi++,pi++){this.debug("matchOne loop");var p=pattern[pi],f=file[fi];if(this.debug(pattern,p,f),p===!1)return!1;if(p===GLOBSTAR){this.debug("GLOBSTAR",[pattern,p,f]);var fr=fi,pr=pi+1;if(pr===pl){for(this.debug("** at the end");fi<fl;fi++)if(file[fi]==="."||file[fi]===".."||!options.dot&&file[fi].charAt(0)===".")return!1;return!0}for(;fr<fl;){var swallowee=file[fr];if(this.debug(`
|
|
10
|
+
>>> no match, partial?`,file,fr,pattern,pr),fr===fl))}var hit;if(typeof p=="string"?(hit=f===p,this.debug("string match",p,f,hit)):(hit=f.match(p),this.debug("pattern match",p,f,hit)),!hit)return!1}if(fi===fl&&pi===pl)return!0;if(fi===fl)return partial;if(pi===pl)return fi===fl-1&&file[fi]==="";throw new Error("wtf?")};function globUnescape(s){return s.replace(/\\(.)/g,"$1")}function regExpEscape(s){return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}}});var errors_exports={};__export(errors_exports,{NowBuildError:()=>NowBuildError,getPrettyError:()=>getPrettyError});function getPrettyError(obj){let docsUrl="https://vercel.com/docs/concepts/projects/project-configuration";try{let{dataPath,params,message:ajvMessage}=obj,prop=getTopLevelPropertyName(dataPath),message=dataPath&&dataPath.startsWith(".")?`\`${dataPath.slice(1)}\` `:"";if(params&&typeof params.additionalProperty=="string"){let suggestion=getSuggestion(prop,params.additionalProperty);message+=`should NOT have additional property \`${params.additionalProperty}\`. ${suggestion}`}else params&&typeof params.missingProperty=="string"?message+=`missing required property \`${params.missingProperty}\`.`:message+=`${ajvMessage}.`;return new NowBuildError({code:"INVALID_VERCEL_CONFIG",message,link:prop?`${docsUrl}#${prop.toLowerCase()}`:docsUrl,action:"View Documentation"})}catch{return new NowBuildError({code:"INVALID_VERCEL_CONFIG",message:"Failed to validate configuration.",link:docsUrl,action:"View Documentation"})}}function getTopLevelPropertyName(dataPath){if(dataPath&&dataPath.startsWith(".")){let lastIndex=dataPath.indexOf("[");return lastIndex>-1?dataPath.slice(1,lastIndex):dataPath.slice(1)}return""}function getSuggestion(topLevelProp,additionalProperty){let choices=mapTypoToSuggestion[topLevelProp],choice=choices?choices[additionalProperty]:void 0;return choice?`Did you mean \`${choice}\`?`:"Please remove it."}var NowBuildError,mapTypoToSuggestion,init_errors=__esm({"src/errors.ts"(){"use strict";NowBuildError=class extends Error{constructor({message,code,link,action}){super(message);this.hideStackTrace=!0;this.code=code,this.link=link,this.action=action}};mapTypoToSuggestion={"":{builder:"builds","build.env":'{ "build": { "env": {"name": "value"} } }',"builds.env":'{ "build": { "env": {"name": "value"} } }'},rewrites:{src:"source",dest:"destination"},redirects:{src:"source",dest:"destination",status:"statusCode"},headers:{src:"source",header:"headers"},routes:{header:"headers",method:"methods"}}}});var get_platform_env_exports={};__export(get_platform_env_exports,{getPlatformEnv:()=>getPlatformEnv});var getPlatformEnv,init_get_platform_env=__esm({"src/get-platform-env.ts"(){"use strict";init_errors();getPlatformEnv=name=>{let vName=`VERCEL_${name}`,nName=`NOW_${name}`,v=process.env[vName],n=process.env[nName];if(typeof v=="string"){if(typeof n=="string")throw new NowBuildError({code:"CONFLICTING_ENV_VAR_NAMES",message:`Both "${vName}" and "${nName}" env vars are defined. Please only define the "${vName}" env var.`,link:"https://vercel.link/combining-old-and-new-config"});return v}return n}}});var debug_exports={};__export(debug_exports,{default:()=>debug});function debug(message,...additional){getPlatformEnv("BUILDER_DEBUG")?console.log(message,...additional):process.env.VERCEL_DEBUG_PREFIX&&console.log(`${process.env.VERCEL_DEBUG_PREFIX}${message}`,...additional)}var init_debug=__esm({"src/debug.ts"(){"use strict";init_get_platform_env()}});var require_wrappy=__commonJS({"../../node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js"(exports2,module2){module2.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!="function")throw new TypeError("need wrapper function");return Object.keys(fn).forEach(function(k){wrapper[k]=fn[k]}),wrapper;function wrapper(){for(var args=new Array(arguments.length),i=0;i<args.length;i++)args[i]=arguments[i];var ret=fn.apply(this,args),cb2=args[args.length-1];return typeof ret=="function"&&ret!==cb2&&Object.keys(cb2).forEach(function(k){ret[k]=cb2[k]}),ret}}}});var require_once=__commonJS({"../../node_modules/.pnpm/once@1.4.0/node_modules/once/once.js"(exports2,module2){var wrappy=require_wrappy();module2.exports=wrappy(once);module2.exports.strict=wrappy(onceStrict);once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:!0})});function once(fn){var f=function(){return f.called?f.value:(f.called=!0,f.value=fn.apply(this,arguments))};return f.called=!1,f}function onceStrict(fn){var f=function(){if(f.called)throw new Error(f.onceError);return f.called=!0,f.value=fn.apply(this,arguments)},name=fn.name||"Function wrapped with `once`";return f.onceError=name+" shouldn't be called more than once",f.called=!1,f}}});var require_end_of_stream=__commonJS({"../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js"(exports2,module2){var once=require_once(),noop=function(){},isRequest=function(stream){return stream.setHeader&&typeof stream.abort=="function"},isChildProcess=function(stream){return stream.stdio&&Array.isArray(stream.stdio)&&stream.stdio.length===3},eos2=function(stream,opts,callback){if(typeof opts=="function")return eos2(stream,null,opts);opts||(opts={}),callback=once(callback||noop);var ws=stream._writableState,rs=stream._readableState,readable=opts.readable||opts.readable!==!1&&stream.readable,writable=opts.writable||opts.writable!==!1&&stream.writable,onlegacyfinish=function(){stream.writable||onfinish()},onfinish=function(){writable=!1,readable||callback.call(stream)},onend=function(){readable=!1,writable||callback.call(stream)},onexit=function(exitCode){callback.call(stream,exitCode?new Error("exited with error code: "+exitCode):null)},onerror=function(err){callback.call(stream,err)},onclose=function(){if(readable&&!(rs&&rs.ended))return callback.call(stream,new Error("premature close"));if(writable&&!(ws&&ws.ended))return callback.call(stream,new Error("premature close"))},onrequest=function(){stream.req.on("finish",onfinish)};return isRequest(stream)?(stream.on("complete",onfinish),stream.on("abort",onclose),stream.req?onrequest():stream.on("request",onrequest)):writable&&!ws&&(stream.on("end",onlegacyfinish),stream.on("close",onlegacyfinish)),isChildProcess(stream)&&stream.on("exit",onexit),stream.on("end",onend),stream.on("finish",onfinish),opts.error!==!1&&stream.on("error",onerror),stream.on("close",onclose),function(){stream.removeListener("complete",onfinish),stream.removeListener("abort",onclose),stream.removeListener("request",onrequest),stream.req&&stream.req.removeListener("finish",onfinish),stream.removeListener("end",onlegacyfinish),stream.removeListener("close",onlegacyfinish),stream.removeListener("finish",onfinish),stream.removeListener("exit",onexit),stream.removeListener("end",onend),stream.removeListener("error",onerror),stream.removeListener("close",onclose)}};module2.exports=eos2}});var stream_to_buffer_exports={};__export(stream_to_buffer_exports,{default:()=>streamToBuffer,streamToBufferChunks:()=>streamToBufferChunks});function streamToBuffer(stream){return new Promise((resolve3,reject)=>{let buffers=[];stream.on("data",chunk=>{let buffer=Buffer.isBuffer(chunk)?chunk:Buffer.from(chunk);buffers.push(Uint8Array.from(buffer))}),(0,import_end_of_stream.default)(stream,err=>{if(err){reject(err);return}try{switch(buffers.length){case 0:resolve3(Buffer.allocUnsafe(0));break;case 1:resolve3(Buffer.from(buffers[0]));break;default:resolve3(Buffer.concat(buffers))}}catch(concatErr){reject(concatErr)}})})}async function streamToBufferChunks(stream,chunkSize=100*MB){let chunks=[],currentChunk=[],currentSize=0;for await(let chunk of stream){let buffer=Buffer.isBuffer(chunk)?chunk:Buffer.from(chunk),offset=0;for(;offset<buffer.length;){let remainingSpace=chunkSize-currentSize,sliceSize=Math.min(remainingSpace,buffer.length-offset);currentChunk.push(Uint8Array.from(buffer.subarray(offset,offset+sliceSize))),currentSize+=sliceSize,offset+=sliceSize,currentSize>=chunkSize&&(chunks.push(Buffer.concat(currentChunk)),currentChunk=[],currentSize=0)}}return currentChunk.length>0&&chunks.push(Buffer.concat(currentChunk)),chunks}var import_end_of_stream,MB,init_stream_to_buffer=__esm({"src/fs/stream-to-buffer.ts"(){"use strict";import_end_of_stream=__toESM(require_end_of_stream());MB=1024*1024}});var download_exports={};__export(download_exports,{default:()=>download,downloadFile:()=>downloadFile,getSymlinkTarget:()=>getSymlinkTarget,isDirectory:()=>isDirectory,isExternalSymlink:()=>isExternalSymlink,isExternalSymlinkTarget:()=>isExternalSymlinkTarget,isSymbolicLink:()=>isSymbolicLink});function isDirectory(mode){return(mode&S_IFMT)===S_IFDIR}function isSymbolicLink(mode){return(mode&S_IFMT)===S_IFLNK}function isExternalSymlinkTarget(target){return target.startsWith("../")||target.startsWith("..\\")||import_path2.default.isAbsolute(target)}function getSymlinkTarget(file){if(!isSymbolicLink(file.mode))return null;if(file.type==="FileFsRef")try{return(0,import_fs_extra2.readlinkSync)(file.fsPath)}catch{return null}if(file.type==="FileBlob"){let{data}=file;return typeof data=="string"?data:data.toString("utf8")}return null}function isExternalSymlink(file){let target=getSymlinkTarget(file);return target!==null&&isExternalSymlinkTarget(target)}async function prepareSymlinkTarget(file,fsPath){let mkdirPromise=(0,import_fs_extra2.mkdirp)(import_path2.default.dirname(fsPath));if(file.type==="FileFsRef"){let[target]=await Promise.all([(0,import_fs_extra2.readlink)(file.fsPath),mkdirPromise]);return target}if(file.type==="FileRef"||file.type==="FileBlob"){let targetPathBufferPromise=streamToBuffer(await file.toStreamAsync()),[targetPathBuffer]=await Promise.all([targetPathBufferPromise,mkdirPromise]);return targetPathBuffer.toString("utf8")}throw new Error(`file.type "${file.type}" not supported for symlink`)}async function downloadFile(file,fsPath){let{mode}=file;if(isDirectory(mode))return await(0,import_fs_extra2.mkdirp)(fsPath),await(0,import_fs_extra2.chmod)(fsPath,mode),file_fs_ref_default.fromFsPath({mode,fsPath});if(isSymbolicLink(mode)){let target=await prepareSymlinkTarget(file,fsPath);try{await(0,import_fs_extra2.symlink)(target,fsPath)}catch(err){if(err.code==="EEXIST")await(0,import_fs_extra2.readlink)(fsPath)!==target&&(await(0,import_fs_extra2.remove)(fsPath),await(0,import_fs_extra2.symlink)(target,fsPath));else throw err}return file_fs_ref_default.fromFsPath({mode,fsPath})}let stream=file.toStream();return file_fs_ref_default.fromStream({mode,stream,fsPath})}async function removeFile(basePath,fileMatched){let file=import_path2.default.join(basePath,fileMatched);await(0,import_fs_extra2.remove)(file)}async function download(files,basePath,meta){let{isDev=!1,skipDownload=!1,filesChanged=null,filesRemoved=null}=meta||{};if(isDev||skipDownload)return files;debug("Downloading deployment source files...");let start=Date.now(),files2={},filenames=Object.keys(files);await Promise.all(filenames.map(async name=>{if(Array.isArray(filesRemoved)&&filesRemoved.includes(name)){await removeFile(basePath,name);return}if(Array.isArray(filesChanged)&&!filesChanged.includes(name))return;let parts=name.split("/");for(let i=1;i<parts.length;i++){let dir=parts.slice(0,i).join("/"),parent=files[dir];if(parent&&isSymbolicLink(parent.mode)&&!isExternalSymlink(parent)){console.warn(`Warning: file "${name}" is within a symlinked directory "${dir}" and will be ignored`);return}}let file=files[name],fsPath=import_path2.default.join(basePath,name);files2[name]=await downloadFile(file,fsPath)}));let duration=Date.now()-start;return debug(`Downloaded ${filenames.length} source files: ${duration}ms`),files2}var import_path2,import_fs_extra2,S_IFDIR,S_IFLNK,S_IFMT,init_download=__esm({"src/fs/download.ts"(){"use strict";import_path2=__toESM(require("path"));init_debug();init_file_fs_ref();import_fs_extra2=__toESM(require_lib());init_stream_to_buffer();S_IFDIR=16384,S_IFLNK=40960,S_IFMT=61440}});var lambda_exports={};__export(lambda_exports,{Lambda:()=>Lambda,createLambda:()=>createLambda,createZip:()=>createZip,getLambdaOptionsFromFunction:()=>getLambdaOptionsFromFunction,sanitizeConsumerName:()=>sanitizeConsumerName});function sanitizeConsumerName(functionPath){let result="";for(let char of functionPath)char==="_"?result+="__":char==="/"?result+="_S":char==="."?result+="_D":/[A-Za-z0-9-]/.test(char)?result+=char:result+="_"+char.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0");return result}function getDefaultLambdaArchitecture(architecture){if(architecture)return architecture;switch(process.arch){case"arm":case"arm64":return"arm64";default:return"x86_64"}}async function createLambda(opts){let lambda=new Lambda(opts);return lambda.zipBuffer=await lambda.createZip(),lambda}async function createZip(files){let names=Object.keys(files).sort(),symlinkTargets=new Map;for(let name of names){let file=files[name];if(file.mode&&isSymbolicLink(file.mode)&&file.type==="FileFsRef"){let symlinkTarget=await(0,import_fs_extra3.readlink)(file.fsPath);symlinkTargets.set(name,symlinkTarget)}}let zipFile=new import_yazl.ZipFile;return await new Promise((resolve3,reject)=>{for(let name of names){let file=files[name],opts={mode:file.mode,mtime},symlinkTarget=symlinkTargets.get(name);if(typeof symlinkTarget=="string")zipFile.addBuffer(Buffer.from(symlinkTarget,"utf8"),name,opts);else if(file.mode&&isDirectory(file.mode))zipFile.addEmptyDirectory(name,opts);else{let stream=file.toStream();stream.on("error",reject),zipFile.addReadStream(stream,name,opts)}}zipFile.end(),streamToBuffer(zipFile.outputStream).then(resolve3).catch(reject)})}async function getLambdaOptionsFromFunction({sourceFile,config,isScheduleEntrypoint=!1}){if(config?.functions){let serviceName=typeof config.serviceName=="string"&&config.serviceName!==""?config.serviceName:void 0;for(let[pattern,fn]of Object.entries(config.functions))if(sourceFile===pattern||(0,import_minimatch.default)(sourceFile,pattern)){let consumer=sanitizeConsumerName(serviceName?`${serviceName}~${pattern}`:pattern),experimentalTriggers=fn.experimentalTriggers?.map(trigger=>trigger.type==="queue/v2beta"?{...trigger,consumer}:trigger);if(experimentalTriggers&&experimentalTriggers.length>1&&experimentalTriggers.some(t=>t.type==="queue/v2beta"))throw new Error(`functions["${pattern}"].experimentalTriggers can only have one item for queue/v2beta`);if(isScheduleEntrypoint&&experimentalTriggers!==void 0&&!(experimentalTriggers.length===1&&experimentalTriggers[0]?.type==="schedule/v1beta"))throw new Error(`functions["${pattern}"].experimentalTriggers conflicts with the schedule entrypoint trigger`);return{architecture:fn.architecture,memory:fn.memory,maxDuration:fn.maxDuration,affinity:fn.affinity,maxConcurrency:fn.maxConcurrency,regions:fn.regions,functionFailoverRegions:fn.functionFailoverRegions,experimentalTriggers:isScheduleEntrypoint?[{type:"schedule/v1beta"}]:experimentalTriggers,supportsCancellation:fn.supportsCancellation}}}return isScheduleEntrypoint?{experimentalTriggers:[{type:"schedule/v1beta"}]}:{}}var import_assert5,import_async_sema3,import_yazl,import_minimatch,import_fs_extra3,Lambda,sema,mtime,init_lambda=__esm({"src/lambda.ts"(){"use strict";import_assert5=__toESM(require("assert"));init_max_concurrency();import_async_sema3=__toESM(require_async_sema()),import_yazl=__toESM(require_yazl()),import_minimatch=__toESM(require_minimatch()),import_fs_extra3=__toESM(require_lib());init_download();init_stream_to_buffer();Lambda=class{constructor(opts){let{handler,runtime,runtimeLanguage,maxDuration,affinity,maxConcurrency,architecture,memory,environment={},allowQuery,regions,functionFailoverRegions,supportsMultiPayloads,supportsWrapper,supportsResponseStreaming,experimentalResponseStreaming,operationType,framework,experimentalTriggers,supportsCancellation,shouldDisableAutomaticFetchInstrumentation}=opts;if("files"in opts&&(0,import_assert5.default)(typeof opts.files=="object",'"files" must be an object'),"zipBuffer"in opts&&(0,import_assert5.default)(Buffer.isBuffer(opts.zipBuffer),'"zipBuffer" must be a Buffer'),(0,import_assert5.default)(typeof handler=="string",'"handler" is not a string'),(0,import_assert5.default)(typeof runtime=="string",'"runtime" is not a string'),(0,import_assert5.default)(typeof environment=="object",'"environment" is not an object'),architecture!==void 0&&(0,import_assert5.default)(architecture==="x86_64"||architecture==="arm64",'"architecture" must be either "x86_64" or "arm64"'),runtimeLanguage!==void 0&&(0,import_assert5.default)(runtimeLanguage==="rust"||runtimeLanguage==="go",'"runtimeLanguage" is invalid. Valid options: "rust", "go"'),"experimentalAllowBundling"in opts&&opts.experimentalAllowBundling!==void 0&&(0,import_assert5.default)(typeof opts.experimentalAllowBundling=="boolean",'"experimentalAllowBundling" is not a boolean'),memory!==void 0&&(0,import_assert5.default)(typeof memory=="number",'"memory" is not a number'),maxDuration!==void 0&&(0,import_assert5.default)(typeof maxDuration=="number"||maxDuration==="max",'"maxDuration" is not a number or "max"'),affinity!==void 0&&(0,import_assert5.default)(typeof affinity=="object"&&affinity!==null&&affinity.mode==="strict"&&Object.keys(affinity).length===1,'"affinity" must be an object with only `mode: "strict"`'),validateMaxConcurrency(maxConcurrency),allowQuery!==void 0&&((0,import_assert5.default)(Array.isArray(allowQuery),'"allowQuery" is not an Array'),(0,import_assert5.default)(allowQuery.every(q=>typeof q=="string"),'"allowQuery" is not a string Array')),supportsMultiPayloads!==void 0&&(0,import_assert5.default)(typeof supportsMultiPayloads=="boolean",'"supportsMultiPayloads" is not a boolean'),supportsWrapper!==void 0&&(0,import_assert5.default)(typeof supportsWrapper=="boolean",'"supportsWrapper" is not a boolean'),regions!==void 0&&((0,import_assert5.default)(Array.isArray(regions),'"regions" is not an Array'),(0,import_assert5.default)(regions.every(r=>typeof r=="string"),'"regions" is not a string Array')),functionFailoverRegions!==void 0&&((0,import_assert5.default)(Array.isArray(functionFailoverRegions),'"functionFailoverRegions" is not an Array'),(0,import_assert5.default)(functionFailoverRegions.every(r=>typeof r=="string"),'"functionFailoverRegions" is not a string Array')),framework!==void 0&&((0,import_assert5.default)(typeof framework=="object",'"framework" is not an object'),(0,import_assert5.default)(typeof framework.slug=="string",'"framework.slug" is not a string'),framework.version!==void 0&&(0,import_assert5.default)(typeof framework.version=="string",'"framework.version" is not a string')),experimentalTriggers!==void 0){(0,import_assert5.default)(Array.isArray(experimentalTriggers),'"experimentalTriggers" is not an Array');for(let i=0;i<experimentalTriggers.length;i++){let trigger=experimentalTriggers[i],prefix=`"experimentalTriggers[${i}]"`;(0,import_assert5.default)(typeof trigger=="object"&&trigger!==null,`${prefix} is not an object`),(0,import_assert5.default)(trigger.type==="queue/v1beta"||trigger.type==="queue/v2beta"||trigger.type==="schedule/v1beta",`${prefix}.type must be "queue/v1beta", "queue/v2beta", or "schedule/v1beta"`),(trigger.type==="queue/v1beta"||trigger.type==="queue/v2beta")&&((0,import_assert5.default)(typeof trigger.topic=="string",`${prefix}.topic is required and must be a string`),(0,import_assert5.default)(trigger.topic.length>0,`${prefix}.topic cannot be empty`),(0,import_assert5.default)(typeof trigger.consumer=="string",`${prefix}.consumer is required and must be a string`),(0,import_assert5.default)(trigger.consumer.length>0,`${prefix}.consumer cannot be empty`),trigger.maxDeliveries!==void 0&&((0,import_assert5.default)(typeof trigger.maxDeliveries=="number",`${prefix}.maxDeliveries must be a number`),(0,import_assert5.default)(Number.isInteger(trigger.maxDeliveries)&&trigger.maxDeliveries>=1,`${prefix}.maxDeliveries must be at least 1`)),trigger.retryAfterSeconds!==void 0&&((0,import_assert5.default)(typeof trigger.retryAfterSeconds=="number",`${prefix}.retryAfterSeconds must be a number`),(0,import_assert5.default)(trigger.retryAfterSeconds>0,`${prefix}.retryAfterSeconds must be a positive number`)),trigger.initialDelaySeconds!==void 0&&((0,import_assert5.default)(typeof trigger.initialDelaySeconds=="number",`${prefix}.initialDelaySeconds must be a number`),(0,import_assert5.default)(trigger.initialDelaySeconds>=0,`${prefix}.initialDelaySeconds must be a non-negative number`)),trigger.maxConcurrency!==void 0&&((0,import_assert5.default)(typeof trigger.maxConcurrency=="number",`${prefix}.maxConcurrency must be a number`),(0,import_assert5.default)(Number.isInteger(trigger.maxConcurrency)&&trigger.maxConcurrency>=1,`${prefix}.maxConcurrency must be at least 1`)))}}supportsCancellation!==void 0&&(0,import_assert5.default)(typeof supportsCancellation=="boolean",'"supportsCancellation" is not a boolean'),this.type="Lambda",this.operationType=operationType,this.files="files"in opts?opts.files:void 0,this.handler=handler,this.runtime=runtime,this.runtimeLanguage=runtimeLanguage,this.architecture=getDefaultLambdaArchitecture(architecture),this.memory=memory,this.maxDuration=maxDuration,this.affinity=affinity,this.maxConcurrency=maxConcurrency,this.environment=environment,this.allowQuery=allowQuery,this.regions=regions,this.functionFailoverRegions=functionFailoverRegions,this.zipBuffer="zipBuffer"in opts?opts.zipBuffer:void 0,this.supportsMultiPayloads=supportsMultiPayloads,this.supportsWrapper=supportsWrapper,this.supportsResponseStreaming=supportsResponseStreaming??experimentalResponseStreaming,this.framework=framework,this.experimentalAllowBundling="experimentalAllowBundling"in opts?opts.experimentalAllowBundling:void 0,this.experimentalTriggers=experimentalTriggers,this.supportsCancellation=supportsCancellation,this.shouldDisableAutomaticFetchInstrumentation=shouldDisableAutomaticFetchInstrumentation}async createZip(){let{zipBuffer}=this;if(!zipBuffer){if(!this.files)throw new Error("`files` is not defined");await sema.acquire();try{zipBuffer=await createZip(this.files)}finally{sema.release()}}return zipBuffer}get experimentalResponseStreaming(){return this.supportsResponseStreaming}set experimentalResponseStreaming(v){this.supportsResponseStreaming=v}},sema=new import_async_sema3.default(10),mtime=new Date(154e10)}});var nodejs_lambda_exports={};__export(nodejs_lambda_exports,{NodejsLambda:()=>NodejsLambda});var NodejsLambda,init_nodejs_lambda=__esm({"src/nodejs-lambda.ts"(){"use strict";init_lambda();NodejsLambda=class extends Lambda{constructor({shouldAddHelpers,shouldAddSourcemapSupport,awsLambdaHandler,useWebApi,...opts}){super(opts);this.launcherType="Nodejs",this.shouldAddHelpers=shouldAddHelpers,this.shouldAddSourcemapSupport=shouldAddSourcemapSupport,this.awsLambdaHandler=awsLambdaHandler,this.useWebApi=useWebApi}}}});var prerender_exports={};__export(prerender_exports,{Prerender:()=>Prerender});var Prerender,init_prerender=__esm({"src/prerender.ts"(){"use strict";Prerender=class{constructor({expiration,staleExpiration,lambda,fallback,group,bypassToken,allowQuery,allowHeader,initialHeaders,initialStatus,passQuery,sourcePath,experimentalBypassFor,experimentalStreamingLambdaPath,chain,exposeErrBody,partialFallback,initialMetadata,onMiss}){if(this.type="Prerender",this.expiration=expiration,this.staleExpiration=staleExpiration,this.sourcePath=sourcePath,this.initialMetadata=initialMetadata,this.onMiss=onMiss,this.lambda=lambda,this.lambda&&(this.lambda.operationType=this.lambda.operationType||"ISR"),typeof group<"u"&&(group<=0||!Number.isInteger(group)))throw new Error("The `group` argument for `Prerender` needs to be a natural number.");if(this.group=group,passQuery===!0)this.passQuery=!0;else if(typeof passQuery!="boolean"&&typeof passQuery<"u")throw new Error("The `passQuery` argument for `Prerender` must be a boolean.");if(bypassToken==null)this.bypassToken=null;else if(typeof bypassToken=="string"){if(bypassToken.length<32)throw new Error("The `bypassToken` argument for `Prerender` must be 32 characters or more.");this.bypassToken=bypassToken}else throw new Error("The `bypassToken` argument for `Prerender` must be a `string`.");if(experimentalBypassFor!==void 0){if(!Array.isArray(experimentalBypassFor)||experimentalBypassFor.some(field=>typeof field!="object"||typeof field.type!="string"||field.type==="host"&&"key"in field||field.type!=="host"&&typeof field.key!="string"||field.value!==void 0&&typeof field.value!="string"&&(typeof field.value!="object"||field.value===null||Array.isArray(field.value))))throw new Error("The `experimentalBypassFor` argument for `Prerender` must be Array of objects with fields `type`, `key` and optionally `value`.");this.experimentalBypassFor=experimentalBypassFor}if(typeof fallback>"u")throw new Error("The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null.");if(this.fallback=fallback,initialHeaders!==void 0){if(!initialHeaders||typeof initialHeaders!="object"||Object.entries(initialHeaders).some(([key,value])=>typeof key!="string"||typeof value!="string"))throw new Error("The `initialHeaders` argument for `Prerender` must be an object with string key/values");this.initialHeaders=initialHeaders}if(initialStatus!==void 0){if(initialStatus<=0||!Number.isInteger(initialStatus))throw new Error("The `initialStatus` argument for `Prerender` must be a natural number.");this.initialStatus=initialStatus}if(allowQuery!==void 0){if(!Array.isArray(allowQuery))throw new Error("The `allowQuery` argument for `Prerender` must be Array.");if(!allowQuery.every(q=>typeof q=="string"))throw new Error("The `allowQuery` argument for `Prerender` must be Array of strings.");this.allowQuery=allowQuery}if(allowHeader!==void 0){if(!Array.isArray(allowHeader))throw new Error("The `allowHeader` argument for `Prerender` must be Array.");if(!allowHeader.every(q=>typeof q=="string"))throw new Error("The `allowHeader` argument for `Prerender` must be Array of strings.");this.allowHeader=allowHeader}if(experimentalStreamingLambdaPath!==void 0){if(typeof experimentalStreamingLambdaPath!="string")throw new Error("The `experimentalStreamingLambdaPath` argument for `Prerender` must be a string.");this.experimentalStreamingLambdaPath=experimentalStreamingLambdaPath}if(chain!==void 0){if(typeof chain!="object")throw new Error("The `chain` argument for `Prerender` must be an object.");if(!chain.headers||typeof chain.headers!="object"||Object.entries(chain.headers).some(([key,value])=>typeof key!="string"||typeof value!="string"))throw new Error("The `chain.headers` argument for `Prerender` must be an object with string key/values");if(!chain.outputPath||typeof chain.outputPath!="string")throw new Error("The `chain.outputPath` argument for `Prerender` must be a string.");this.chain=chain}if(exposeErrBody===!0)this.exposeErrBody=!0;else if(typeof exposeErrBody!="boolean"&&typeof exposeErrBody<"u")throw new Error("The `exposeErrBody` argument for `Prerender` must be a boolean.");if(partialFallback===!0)this.partialFallback=!0;else if(typeof partialFallback!="boolean"&&typeof partialFallback<"u")throw new Error("The `partialFallback` argument for `Prerender` must be a boolean.")}}}});var get_writable_directory_exports={};__export(get_writable_directory_exports,{default:()=>getWritableDirectory});async function getWritableDirectory(){let name=Math.floor(Math.random()*2147483647).toString(16),directory=(0,import_path3.join)((0,import_os.tmpdir)(),name);return await(0,import_fs_extra4.mkdirp)(directory),directory}var import_path3,import_os,import_fs_extra4,init_get_writable_directory=__esm({"src/fs/get-writable-directory.ts"(){"use strict";import_path3=require("path"),import_os=require("os"),import_fs_extra4=__toESM(require_lib())}});var require_old=__commonJS({"../../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js"(exports2){var pathModule=require("path"),isWindows=process.platform==="win32",fs12=require("fs"),DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var callback;if(DEBUG){var backtrace=new Error;callback=debugCallback}else callback=missingCallback;return callback;function debugCallback(err){err&&(backtrace.message=err.message,err=backtrace,missingCallback(err))}function missingCallback(err){if(err){if(process.throwDeprecation)throw err;if(!process.noDeprecation){var msg="fs: missing callback "+(err.stack||err.message);process.traceDeprecation?console.trace(msg):console.error(msg)}}}}function maybeCallback(cb){return typeof cb=="function"?cb:rethrow()}var normalize=pathModule.normalize;isWindows?nextPartRe=/(.*?)(?:[\/\\]+|$)/g:nextPartRe=/(.*?)(?:[\/]+|$)/g;var nextPartRe;isWindows?splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/:splitRootRe=/^[\/]*/;var splitRootRe;exports2.realpathSync=function(p,cache){if(p=pathModule.resolve(p),cache&&Object.prototype.hasOwnProperty.call(cache,p))return cache[p];var original=p,seenLinks={},knownHard={},pos,current,base,previous;start();function start(){var m=splitRootRe.exec(p);pos=m[0].length,current=m[0],base=m[0],previous="",isWindows&&!knownHard[base]&&(fs12.lstatSync(base),knownHard[base]=!0)}for(;pos<p.length;){nextPartRe.lastIndex=pos;var result=nextPartRe.exec(p);if(previous=current,current+=result[0],base=previous+result[1],pos=nextPartRe.lastIndex,!(knownHard[base]||cache&&cache[base]===base)){var resolvedLink;if(cache&&Object.prototype.hasOwnProperty.call(cache,base))resolvedLink=cache[base];else{var stat2=fs12.lstatSync(base);if(!stat2.isSymbolicLink()){knownHard[base]=!0,cache&&(cache[base]=base);continue}var linkTarget=null;if(!isWindows){var id=stat2.dev.toString(32)+":"+stat2.ino.toString(32);seenLinks.hasOwnProperty(id)&&(linkTarget=seenLinks[id])}linkTarget===null&&(fs12.statSync(base),linkTarget=fs12.readlinkSync(base)),resolvedLink=pathModule.resolve(previous,linkTarget),cache&&(cache[base]=resolvedLink),isWindows||(seenLinks[id]=linkTarget)}p=pathModule.resolve(resolvedLink,p.slice(pos)),start()}}return cache&&(cache[original]=p),p};exports2.realpath=function(p,cache,cb){if(typeof cb!="function"&&(cb=maybeCallback(cache),cache=null),p=pathModule.resolve(p),cache&&Object.prototype.hasOwnProperty.call(cache,p))return process.nextTick(cb.bind(null,null,cache[p]));var original=p,seenLinks={},knownHard={},pos,current,base,previous;start();function start(){var m=splitRootRe.exec(p);pos=m[0].length,current=m[0],base=m[0],previous="",isWindows&&!knownHard[base]?fs12.lstat(base,function(err){if(err)return cb(err);knownHard[base]=!0,LOOP()}):process.nextTick(LOOP)}function LOOP(){if(pos>=p.length)return cache&&(cache[original]=p),cb(null,p);nextPartRe.lastIndex=pos;var result=nextPartRe.exec(p);return previous=current,current+=result[0],base=previous+result[1],pos=nextPartRe.lastIndex,knownHard[base]||cache&&cache[base]===base?process.nextTick(LOOP):cache&&Object.prototype.hasOwnProperty.call(cache,base)?gotResolvedLink(cache[base]):fs12.lstat(base,gotStat)}function gotStat(err,stat2){if(err)return cb(err);if(!stat2.isSymbolicLink())return knownHard[base]=!0,cache&&(cache[base]=base),process.nextTick(LOOP);if(!isWindows){var id=stat2.dev.toString(32)+":"+stat2.ino.toString(32);if(seenLinks.hasOwnProperty(id))return gotTarget(null,seenLinks[id],base)}fs12.stat(base,function(err2){if(err2)return cb(err2);fs12.readlink(base,function(err3,target){isWindows||(seenLinks[id]=target),gotTarget(err3,target)})})}function gotTarget(err,target,base2){if(err)return cb(err);var resolvedLink=pathModule.resolve(previous,target);cache&&(cache[base2]=resolvedLink),gotResolvedLink(resolvedLink)}function gotResolvedLink(resolvedLink){p=pathModule.resolve(resolvedLink,p.slice(pos)),start()}}}});var require_fs2=__commonJS({"../../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js"(exports2,module2){module2.exports=realpath;realpath.realpath=realpath;realpath.sync=realpathSync2;realpath.realpathSync=realpathSync2;realpath.monkeypatch=monkeypatch;realpath.unmonkeypatch=unmonkeypatch;var fs12=require("fs"),origRealpath=fs12.realpath,origRealpathSync=fs12.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version),old=require_old();function newError(er){return er&&er.syscall==="realpath"&&(er.code==="ELOOP"||er.code==="ENOMEM"||er.code==="ENAMETOOLONG")}function realpath(p,cache,cb){if(ok)return origRealpath(p,cache,cb);typeof cache=="function"&&(cb=cache,cache=null),origRealpath(p,cache,function(er,result){newError(er)?old.realpath(p,cache,cb):cb(er,result)})}function realpathSync2(p,cache){if(ok)return origRealpathSync(p,cache);try{return origRealpathSync(p,cache)}catch(er){if(newError(er))return old.realpathSync(p,cache);throw er}}function monkeypatch(){fs12.realpath=realpath,fs12.realpathSync=realpathSync2}function unmonkeypatch(){fs12.realpath=origRealpath,fs12.realpathSync=origRealpathSync}}});var require_path=__commonJS({"../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/lib/path.js"(exports2,module2){var isWindows=typeof process=="object"&&process&&process.platform==="win32";module2.exports=isWindows?{sep:"\\"}:{sep:"/"}}});var require_brace_expansion2=__commonJS({"../../node_modules/.pnpm/brace-expansion@2.1.1/node_modules/brace-expansion/index.js"(exports2,module2){var balanced=require_balanced_match();module2.exports=expandTop;var escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(str){return parseInt(str,10)==str?parseInt(str,10):str.charCodeAt(0)}function escapeBraces(str){return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(str){return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(str){if(!str)return[""];var parts=[],m=balanced("{","}",str);if(!m)return str.split(",");var pre=m.pre,body=m.body,post=m.post,p=pre.split(",");p[p.length-1]+="{"+body+"}";var postParts=parseCommaParts(post);return post.length&&(p[p.length-1]+=postParts.shift(),p.push.apply(p,postParts)),parts.push.apply(parts,p),parts}function expandTop(str,options){if(!str)return[];options=options||{};var max=options.max==null?1/0:options.max;return str.substr(0,2)==="{}"&&(str="\\{\\}"+str.substr(2)),expand(escapeBraces(str),max,!0).map(unescapeBraces)}function embrace(str){return"{"+str+"}"}function isPadded(el){return/^-?0\d/.test(el)}function lte(i,y){return i<=y}function gte2(i,y){return i>=y}function expand(str,max,isTop){var expansions=[],m=balanced("{","}",str);if(!m)return[str];var pre=m.pre,post=m.post.length?expand(m.post,max,!1):[""];if(/\$$/.test(m.pre))for(var k=0;k<post.length&&k<max;k++){var expansion=pre+"{"+m.body+"}"+post[k];expansions.push(expansion)}else{var isNumericSequence=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body),isAlphaSequence=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body),isSequence=isNumericSequence||isAlphaSequence,isOptions=m.body.indexOf(",")>=0;if(!isSequence&&!isOptions)return m.post.match(/,(?!,).*\}/)?(str=m.pre+"{"+m.body+escClose+m.post,expand(str,max,!0)):[str];var n;if(isSequence)n=m.body.split(/\.\./);else if(n=parseCommaParts(m.body),n.length===1&&(n=expand(n[0],max,!1).map(embrace),n.length===1))return post.map(function(p){return m.pre+n[0]+p});var N;if(isSequence){var x=numeric(n[0]),y=numeric(n[1]),width=Math.max(n[0].length,n[1].length),incr=n.length==3?Math.max(Math.abs(numeric(n[2])),1):1,test=lte,reverse=y<x;reverse&&(incr*=-1,test=gte2);var pad=n.some(isPadded);N=[];for(var i=x;test(i,y)&&N.length<max;i+=incr){var c;if(isAlphaSequence)c=String.fromCharCode(i),c==="\\"&&(c="");else if(c=String(i),pad){var need=width-c.length;if(need>0){var z=new Array(need+1).join("0");i<0?c="-"+z+c.slice(1):c=z+c}}N.push(c)}}else{N=[];for(var j=0;j<n.length;j++)N.push.apply(N,expand(n[j],max,!1))}for(var j=0;j<N.length;j++)for(var k=0;k<post.length&&expansions.length<max;k++){var expansion=pre+N[j]+post[k];(!isTop||isSequence||expansion)&&expansions.push(expansion)}}return expansions}}});var require_minimatch2=__commonJS({"../../node_modules/.pnpm/minimatch@5.0.1/node_modules/minimatch/minimatch.js"(exports2,module2){var minimatch3=module2.exports=(p,pattern,options={})=>(assertValidPattern(pattern),!options.nocomment&&pattern.charAt(0)==="#"?!1:new Minimatch(pattern,options).match(p));module2.exports=minimatch3;var path9=require_path();minimatch3.sep=path9.sep;var GLOBSTAR=Symbol("globstar **");minimatch3.GLOBSTAR=GLOBSTAR;var expand=require_brace_expansion2(),plTypes={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},qmark="[^/]",star=qmark+"*?",twoStarDot="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",twoStarNoDot="(?:(?!(?:\\/|^)\\.).)*?",charSet=s=>s.split("").reduce((set,c)=>(set[c]=!0,set),{}),reSpecials=charSet("().*{}+?[]^$\\!"),addPatternStartSet=charSet("[.("),slashSplit=/\/+/;minimatch3.filter=(pattern,options={})=>(p,i,list)=>minimatch3(p,pattern,options);var ext=(a,b={})=>{let t={};return Object.keys(a).forEach(k=>t[k]=a[k]),Object.keys(b).forEach(k=>t[k]=b[k]),t};minimatch3.defaults=def=>{if(!def||typeof def!="object"||!Object.keys(def).length)return minimatch3;let orig=minimatch3,m=(p,pattern,options)=>orig(p,pattern,ext(def,options));return m.Minimatch=class extends orig.Minimatch{constructor(pattern,options){super(pattern,ext(def,options))}},m.Minimatch.defaults=options=>orig.defaults(ext(def,options)).Minimatch,m.filter=(pattern,options)=>orig.filter(pattern,ext(def,options)),m.defaults=options=>orig.defaults(ext(def,options)),m.makeRe=(pattern,options)=>orig.makeRe(pattern,ext(def,options)),m.braceExpand=(pattern,options)=>orig.braceExpand(pattern,ext(def,options)),m.match=(list,pattern,options)=>orig.match(list,pattern,ext(def,options)),m};minimatch3.braceExpand=(pattern,options)=>braceExpand(pattern,options);var braceExpand=(pattern,options={})=>(assertValidPattern(pattern),options.nobrace||!/\{(?:(?!\{).)*\}/.test(pattern)?[pattern]:expand(pattern)),MAX_PATTERN_LENGTH=1024*64,assertValidPattern=pattern=>{if(typeof pattern!="string")throw new TypeError("invalid pattern");if(pattern.length>MAX_PATTERN_LENGTH)throw new TypeError("pattern is too long")},SUBPARSE=Symbol("subparse");minimatch3.makeRe=(pattern,options)=>new Minimatch(pattern,options||{}).makeRe();minimatch3.match=(list,pattern,options={})=>{let mm=new Minimatch(pattern,options);return list=list.filter(f=>mm.match(f)),mm.options.nonull&&!list.length&&list.push(pattern),list};var globUnescape=s=>s.replace(/\\(.)/g,"$1"),regExpEscape=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Minimatch=class{constructor(pattern,options){assertValidPattern(pattern),options||(options={}),this.options=options,this.set=[],this.pattern=pattern,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!options.partial,this.make()}debug(){}make(){let pattern=this.pattern,options=this.options;if(!options.nocomment&&pattern.charAt(0)==="#"){this.comment=!0;return}if(!pattern){this.empty=!0;return}this.parseNegate();let set=this.globSet=this.braceExpand();options.debug&&(this.debug=(...args)=>console.error(...args)),this.debug(this.pattern,set),set=this.globParts=set.map(s=>s.split(slashSplit)),this.debug(this.pattern,set),set=set.map((s,si,set2)=>s.map(this.parse,this)),this.debug(this.pattern,set),set=set.filter(s=>s.indexOf(!1)===-1),this.debug(this.pattern,set),this.set=set}parseNegate(){if(this.options.nonegate)return;let pattern=this.pattern,negate=!1,negateOffset=0;for(let i=0;i<pattern.length&&pattern.charAt(i)==="!";i++)negate=!negate,negateOffset++;negateOffset&&(this.pattern=pattern.substr(negateOffset)),this.negate=negate}matchOne(file,pattern,partial){var options=this.options;this.debug("matchOne",{this:this,file,pattern}),this.debug("matchOne",file.length,pattern.length);for(var fi=0,pi=0,fl=file.length,pl=pattern.length;fi<fl&&pi<pl;fi++,pi++){this.debug("matchOne loop");var p=pattern[pi],f=file[fi];if(this.debug(pattern,p,f),p===!1)return!1;if(p===GLOBSTAR){this.debug("GLOBSTAR",[pattern,p,f]);var fr=fi,pr=pi+1;if(pr===pl){for(this.debug("** at the end");fi<fl;fi++)if(file[fi]==="."||file[fi]===".."||!options.dot&&file[fi].charAt(0)===".")return!1;return!0}for(;fr<fl;){var swallowee=file[fr];if(this.debug(`
|
|
11
11
|
globstar while`,file,fr,pattern,pr,swallowee),this.matchOne(file.slice(fr),pattern.slice(pr),partial))return this.debug("globstar found match!",fr,fl,swallowee),!0;if(swallowee==="."||swallowee===".."||!options.dot&&swallowee.charAt(0)==="."){this.debug("dot detected!",file,fr,pattern,pr);break}this.debug("globstar swallow a segment, and continue"),fr++}return!!(partial&&(this.debug(`
|
|
12
12
|
>>> no match, partial?`,file,fr,pattern,pr),fr===fl))}var hit;if(typeof p=="string"?(hit=f===p,this.debug("string match",p,f,hit)):(hit=f.match(p),this.debug("pattern match",p,f,hit)),!hit)return!1}if(fi===fl&&pi===pl)return!0;if(fi===fl)return partial;if(pi===pl)return fi===fl-1&&file[fi]==="";throw new Error("wtf?")}braceExpand(){return braceExpand(this.pattern,this.options)}parse(pattern,isSub){assertValidPattern(pattern);let options=this.options;if(pattern==="**")if(options.noglobstar)pattern="*";else return GLOBSTAR;if(pattern==="")return"";let re="",hasMagic=!!options.nocase,escaping=!1,patternListStack=[],negativeLists=[],stateChar,inClass=!1,reClassStart=-1,classStart=-1,cs,pl,sp,patternStart=pattern.charAt(0)==="."?"":options.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",clearStateChar=()=>{if(stateChar){switch(stateChar){case"*":re+=star,hasMagic=!0;break;case"?":re+=qmark,hasMagic=!0;break;default:re+="\\"+stateChar;break}this.debug("clearStateChar %j %j",stateChar,re),stateChar=!1}};for(let i=0,c;i<pattern.length&&(c=pattern.charAt(i));i++){if(this.debug("%s %s %s %j",pattern,i,re,c),escaping){if(c==="/")return!1;reSpecials[c]&&(re+="\\"),re+=c,escaping=!1;continue}switch(c){case"/":return!1;case"\\":clearStateChar(),escaping=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",pattern,i,re,c),inClass){this.debug(" in class"),c==="!"&&i===classStart+1&&(c="^"),re+=c;continue}this.debug("call clearStateChar %j",stateChar),clearStateChar(),stateChar=c,options.noext&&clearStateChar();continue;case"(":if(inClass){re+="(";continue}if(!stateChar){re+="\\(";continue}patternListStack.push({type:stateChar,start:i-1,reStart:re.length,open:plTypes[stateChar].open,close:plTypes[stateChar].close}),re+=stateChar==="!"?"(?:(?!(?:":"(?:",this.debug("plType %j %j",stateChar,re),stateChar=!1;continue;case")":if(inClass||!patternListStack.length){re+="\\)";continue}clearStateChar(),hasMagic=!0,pl=patternListStack.pop(),re+=pl.close,pl.type==="!"&&negativeLists.push(pl),pl.reEnd=re.length;continue;case"|":if(inClass||!patternListStack.length){re+="\\|";continue}clearStateChar(),re+="|";continue;case"[":if(clearStateChar(),inClass){re+="\\"+c;continue}inClass=!0,classStart=i,reClassStart=re.length,re+=c;continue;case"]":if(i===classStart+1||!inClass){re+="\\"+c;continue}cs=pattern.substring(classStart+1,i);try{RegExp("["+cs+"]")}catch{sp=this.parse(cs,SUBPARSE),re=re.substr(0,reClassStart)+"\\["+sp[0]+"\\]",hasMagic=hasMagic||sp[1],inClass=!1;continue}hasMagic=!0,inClass=!1,re+=c;continue;default:clearStateChar(),reSpecials[c]&&!(c==="^"&&inClass)&&(re+="\\"),re+=c;break}}for(inClass&&(cs=pattern.substr(classStart+1),sp=this.parse(cs,SUBPARSE),re=re.substr(0,reClassStart)+"\\["+sp[0],hasMagic=hasMagic||sp[1]),pl=patternListStack.pop();pl;pl=patternListStack.pop()){let tail;tail=re.slice(pl.reStart+pl.open.length),this.debug("setting tail",re,pl),tail=tail.replace(/((?:\\{2}){0,64})(\\?)\|/g,(_,$1,$2)=>($2||($2="\\"),$1+$1+$2+"|")),this.debug(`tail=%j
|
|
13
13
|
%s`,tail,tail,pl,re);let t=pl.type==="*"?star:pl.type==="?"?qmark:"\\"+pl.type;hasMagic=!0,re=re.slice(0,pl.reStart)+t+"\\("+tail}clearStateChar(),escaping&&(re+="\\\\");let addPatternStart=addPatternStartSet[re.charAt(0)];for(let n=negativeLists.length-1;n>-1;n--){let nl=negativeLists[n],nlBefore=re.slice(0,nl.reStart),nlFirst=re.slice(nl.reStart,nl.reEnd-8),nlAfter=re.slice(nl.reEnd),nlLast=re.slice(nl.reEnd-8,nl.reEnd)+nlAfter,openParensBefore=nlBefore.split("(").length-1,cleanAfter=nlAfter;for(let i=0;i<openParensBefore;i++)cleanAfter=cleanAfter.replace(/\)[+*?]?/,"");nlAfter=cleanAfter;let dollar=nlAfter===""&&isSub!==SUBPARSE?"$":"";re=nlBefore+nlFirst+nlAfter+dollar+nlLast}if(re!==""&&hasMagic&&(re="(?=.)"+re),addPatternStart&&(re=patternStart+re),isSub===SUBPARSE)return[re,hasMagic];if(!hasMagic)return globUnescape(pattern);let flags=options.nocase?"i":"";try{return Object.assign(new RegExp("^"+re+"$",flags),{_glob:pattern,_src:re})}catch{return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let set=this.set;if(!set.length)return this.regexp=!1,this.regexp;let options=this.options,twoStar=options.noglobstar?star:options.dot?twoStarDot:twoStarNoDot,flags=options.nocase?"i":"",re=set.map(pattern=>(pattern=pattern.map(p=>typeof p=="string"?regExpEscape(p):p===GLOBSTAR?GLOBSTAR:p._src).reduce((set2,p)=>(set2[set2.length-1]===GLOBSTAR&&p===GLOBSTAR||set2.push(p),set2),[]),pattern.forEach((p,i)=>{p!==GLOBSTAR||pattern[i-1]===GLOBSTAR||(i===0?pattern.length>1?pattern[i+1]="(?:\\/|"+twoStar+"\\/)?"+pattern[i+1]:pattern[i]=twoStar:i===pattern.length-1?pattern[i-1]+="(?:\\/|"+twoStar+")?":(pattern[i-1]+="(?:\\/|\\/"+twoStar+"\\/)"+pattern[i+1],pattern[i+1]=GLOBSTAR))}),pattern.filter(p=>p!==GLOBSTAR).join("/"))).join("|");re="^(?:"+re+")$",this.negate&&(re="^(?!"+re+").*$");try{this.regexp=new RegExp(re,flags)}catch{this.regexp=!1}return this.regexp}match(f,partial=this.partial){if(this.debug("match",f,this.pattern),this.comment)return!1;if(this.empty)return f==="";if(f==="/"&&partial)return!0;let options=this.options;path9.sep!=="/"&&(f=f.split(path9.sep).join("/")),f=f.split(slashSplit),this.debug(this.pattern,"split",f);let set=this.set;this.debug(this.pattern,"set",set);let filename;for(let i=f.length-1;i>=0&&(filename=f[i],!filename);i--);for(let i=0;i<set.length;i++){let pattern=set[i],file=f;if(options.matchBase&&pattern.length===1&&(file=[filename]),this.matchOne(file,pattern,partial))return options.flipNegate?!0:!this.negate}return options.flipNegate?!1:this.negate}static defaults(def){return minimatch3.defaults(def).Minimatch}};minimatch3.Minimatch=Minimatch}});var require_common=__commonJS({"../../node_modules/.pnpm/glob@8.0.3/node_modules/glob/common.js"(exports2){exports2.setopts=setopts;exports2.ownProp=ownProp;exports2.makeAbs=makeAbs;exports2.finish=finish;exports2.mark=mark;exports2.isIgnored=isIgnored;exports2.childrenIgnored=childrenIgnored;function ownProp(obj,field){return Object.prototype.hasOwnProperty.call(obj,field)}var fs12=require("fs"),path9=require("path"),minimatch3=require_minimatch2(),isAbsolute=require("path").isAbsolute,Minimatch=minimatch3.Minimatch;function alphasort(a,b){return a.localeCompare(b,"en")}function setupIgnores(self2,options){self2.ignore=options.ignore||[],Array.isArray(self2.ignore)||(self2.ignore=[self2.ignore]),self2.ignore.length&&(self2.ignore=self2.ignore.map(ignoreMap))}function ignoreMap(pattern){var gmatcher=null;if(pattern.slice(-3)==="/**"){var gpattern=pattern.replace(/(\/\*\*)+$/,"");gmatcher=new Minimatch(gpattern,{dot:!0})}return{matcher:new Minimatch(pattern,{dot:!0}),gmatcher}}function setopts(self2,pattern,options){if(options||(options={}),options.matchBase&&pattern.indexOf("/")===-1){if(options.noglobstar)throw new Error("base matching requires globstar");pattern="**/"+pattern}self2.silent=!!options.silent,self2.pattern=pattern,self2.strict=options.strict!==!1,self2.realpath=!!options.realpath,self2.realpathCache=options.realpathCache||Object.create(null),self2.follow=!!options.follow,self2.dot=!!options.dot,self2.mark=!!options.mark,self2.nodir=!!options.nodir,self2.nodir&&(self2.mark=!0),self2.sync=!!options.sync,self2.nounique=!!options.nounique,self2.nonull=!!options.nonull,self2.nosort=!!options.nosort,self2.nocase=!!options.nocase,self2.stat=!!options.stat,self2.noprocess=!!options.noprocess,self2.absolute=!!options.absolute,self2.fs=options.fs||fs12,self2.maxLength=options.maxLength||1/0,self2.cache=options.cache||Object.create(null),self2.statCache=options.statCache||Object.create(null),self2.symlinks=options.symlinks||Object.create(null),setupIgnores(self2,options),self2.changedCwd=!1;var cwd=process.cwd();ownProp(options,"cwd")?(self2.cwd=path9.resolve(options.cwd),self2.changedCwd=self2.cwd!==cwd):self2.cwd=path9.resolve(cwd),self2.root=options.root||path9.resolve(self2.cwd,"/"),self2.root=path9.resolve(self2.root),self2.cwdAbs=isAbsolute(self2.cwd)?self2.cwd:makeAbs(self2,self2.cwd),self2.nomount=!!options.nomount,process.platform==="win32"&&(self2.root=self2.root.replace(/\\/g,"/"),self2.cwd=self2.cwd.replace(/\\/g,"/"),self2.cwdAbs=self2.cwdAbs.replace(/\\/g,"/")),options.nonegate=!0,options.nocomment=!0,options.allowWindowsEscape=!0,self2.minimatch=new Minimatch(pattern,options),self2.options=self2.minimatch.options}function finish(self2){for(var nou=self2.nounique,all=nou?[]:Object.create(null),i=0,l=self2.matches.length;i<l;i++){var matches=self2.matches[i];if(!matches||Object.keys(matches).length===0){if(self2.nonull){var literal=self2.minimatch.globSet[i];nou?all.push(literal):all[literal]=!0}}else{var m=Object.keys(matches);nou?all.push.apply(all,m):m.forEach(function(m2){all[m2]=!0})}}if(nou||(all=Object.keys(all)),self2.nosort||(all=all.sort(alphasort)),self2.mark){for(var i=0;i<all.length;i++)all[i]=self2._mark(all[i]);self2.nodir&&(all=all.filter(function(e){var notDir=!/\/$/.test(e),c=self2.cache[e]||self2.cache[makeAbs(self2,e)];return notDir&&c&&(notDir=c!=="DIR"&&!Array.isArray(c)),notDir}))}self2.ignore.length&&(all=all.filter(function(m2){return!isIgnored(self2,m2)})),self2.found=all}function mark(self2,p){var abs=makeAbs(self2,p),c=self2.cache[abs],m=p;if(c){var isDir=c==="DIR"||Array.isArray(c),slash=p.slice(-1)==="/";if(isDir&&!slash?m+="/":!isDir&&slash&&(m=m.slice(0,-1)),m!==p){var mabs=makeAbs(self2,m);self2.statCache[mabs]=self2.statCache[abs],self2.cache[mabs]=self2.cache[abs]}}return m}function makeAbs(self2,f){var abs=f;return f.charAt(0)==="/"?abs=path9.join(self2.root,f):isAbsolute(f)||f===""?abs=f:self2.changedCwd?abs=path9.resolve(self2.cwd,f):abs=path9.resolve(f),process.platform==="win32"&&(abs=abs.replace(/\\/g,"/")),abs}function isIgnored(self2,path10){return self2.ignore.length?self2.ignore.some(function(item){return item.matcher.match(path10)||!!(item.gmatcher&&item.gmatcher.match(path10))}):!1}function childrenIgnored(self2,path10){return self2.ignore.length?self2.ignore.some(function(item){return!!(item.gmatcher&&item.gmatcher.match(path10))}):!1}}});var require_sync=__commonJS({"../../node_modules/.pnpm/glob@8.0.3/node_modules/glob/sync.js"(exports2,module2){module2.exports=globSync;globSync.GlobSync=GlobSync;var rp=require_fs2(),minimatch3=require_minimatch2(),Minimatch=minimatch3.Minimatch,Glob=require_glob().Glob,util=require("util"),path9=require("path"),assert9=require("assert"),isAbsolute=require("path").isAbsolute,common=require_common(),setopts=common.setopts,ownProp=common.ownProp,childrenIgnored=common.childrenIgnored,isIgnored=common.isIgnored;function globSync(pattern,options){if(typeof options=="function"||arguments.length===3)throw new TypeError(`callback provided to sync glob
|
package/dist/prerender.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface PrerenderInitialMetadata {
|
|
|
22
22
|
*/
|
|
23
23
|
htmlSize?: number;
|
|
24
24
|
}
|
|
25
|
+
export type PrerenderOnMiss = 'sync' | 'dynamic';
|
|
25
26
|
interface PrerenderOptions {
|
|
26
27
|
expiration: number | false;
|
|
27
28
|
staleExpiration?: number;
|
|
@@ -41,6 +42,7 @@ interface PrerenderOptions {
|
|
|
41
42
|
exposeErrBody?: boolean;
|
|
42
43
|
partialFallback?: boolean;
|
|
43
44
|
initialMetadata?: PrerenderInitialMetadata;
|
|
45
|
+
onMiss?: PrerenderOnMiss;
|
|
44
46
|
}
|
|
45
47
|
export declare class Prerender {
|
|
46
48
|
type: 'Prerender';
|
|
@@ -77,6 +79,8 @@ export declare class Prerender {
|
|
|
77
79
|
* from frameworks that predate the field carry none.
|
|
78
80
|
*/
|
|
79
81
|
initialMetadata?: PrerenderInitialMetadata;
|
|
80
|
-
|
|
82
|
+
/** Serving mode when no prerendered output exists yet. Absent means `sync`. Interpreted by the proxy; carried unvalidated. */
|
|
83
|
+
onMiss?: PrerenderOnMiss;
|
|
84
|
+
constructor({ expiration, staleExpiration, lambda, fallback, group, bypassToken, allowQuery, allowHeader, initialHeaders, initialStatus, passQuery, sourcePath, experimentalBypassFor, experimentalStreamingLambdaPath, chain, exposeErrBody, partialFallback, initialMetadata, onMiss, }: PrerenderOptions);
|
|
81
85
|
}
|
|
82
86
|
export {};
|
package/dist/prerender.js
CHANGED
|
@@ -40,13 +40,15 @@ class Prerender {
|
|
|
40
40
|
chain,
|
|
41
41
|
exposeErrBody,
|
|
42
42
|
partialFallback,
|
|
43
|
-
initialMetadata
|
|
43
|
+
initialMetadata,
|
|
44
|
+
onMiss
|
|
44
45
|
}) {
|
|
45
46
|
this.type = "Prerender";
|
|
46
47
|
this.expiration = expiration;
|
|
47
48
|
this.staleExpiration = staleExpiration;
|
|
48
49
|
this.sourcePath = sourcePath;
|
|
49
50
|
this.initialMetadata = initialMetadata;
|
|
51
|
+
this.onMiss = onMiss;
|
|
50
52
|
this.lambda = lambda;
|
|
51
53
|
if (this.lambda) {
|
|
52
54
|
this.lambda.operationType = this.lambda.operationType || "ISR";
|