@reddb-io/red-skills 4.1.16 → 4.1.18
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/dist/code-nav.bundle.min.mjs +1 -1
- package/dist/opencode-host.bundle.min.mjs +1 -1
- package/dist/redskilled-mcp.bundle.min.mjs +171 -171
- package/dist/redskilled.bundle.min.mjs +255 -247
- package/dist/release.bundle.min.mjs +9 -9
- package/dist/rsp-core.bundle.min.mjs +188 -188
- package/dist/rsp.bundle.min.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
-
var pf=Object.create;var Ea=Object.defineProperty;var ff=Object.getOwnPropertyDescriptor;var hf=Object.getOwnPropertyNames;var mf=Object.getPrototypeOf,gf=Object.prototype.hasOwnProperty;var Tr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var yf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of hf(t))!gf.call(e,s)&&s!==r&&Ea(e,s,{get:()=>t[s],enumerable:!(n=ff(t,s))||n.enumerable});return e};var At=(e,t,r)=>(r=e!=null?pf(mf(e)):{},yf(t||!e||!e.__esModule?Ea(r,"default",{value:e,enumerable:!0}):r,e));var ic=P(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.format=gh;Pr.parse=yh;var fh=/^[\u0009\u0020-\u007e\u0080-\u00ff]*$/,ec=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,hh=/[\\"]/g,mh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,tc=(()=>{let e=function(){};return e.prototype=Object.create(null),e})();function gh(e){let{type:t,parameters:r}=e;if(!t||!mh.test(t))throw new TypeError(`Invalid type: ${t}`);let n=t;if(r)for(let s of Object.keys(r)){if(!ec.test(s))throw new TypeError(`Invalid parameter name: ${s}`);n+=`; ${s}=${Th(r[s])}`}return n}function yh(e,t){let r=e.length,n=_s(e,0,r),s=n;n=Ts(e,n,r);let i=ks(e,s,n),o=e.slice(s,i).toLowerCase(),a=t?.parameters===!1?new tc:Eh(e,n,r);return{type:o,parameters:a}}var rc=32,nc=9,sc=59,bh=61,Za=34,wh=92;function Eh(e,t,r){let n=new tc;e:for(;t<r;){t=_s(e,t+1,r);let s=t;for(;t<r;){let i=e.charCodeAt(t);if(i===sc)continue e;if(i===bh){let o=ks(e,s,t),a=e.slice(s,o).toLowerCase();if(t=_s(e,t+1,r),t<r&&e.charCodeAt(t)===Za){t++;let l="";for(;t<r;){let d=e.charCodeAt(t++);if(d===Za){t=Ts(e,t,r),n[a]===void 0&&(n[a]=l);break}if(d===wh&&t<r){l+=e[t++];continue}l+=String.fromCharCode(d)}continue e}let c=t;if(t=Ts(e,t,r),n[a]===void 0){let l=ks(e,c,t);n[a]=e.slice(c,l)}continue e}t++}}return n}function Ts(e,t,r){for(;t<r&&e.charCodeAt(t)!==sc;)t++;return t}function _s(e,t,r){for(;t<r;){let n=e.charCodeAt(t);if(n!==rc&&n!==nc)break;t++}return t}function ks(e,t,r){for(;r>t;){let n=e.charCodeAt(r-1);if(n!==rc&&n!==nc)break;r--}return r}function Th(e){if(ec.test(e))return e;if(fh.test(e))return`"${e.replace(hh,"\\$&")}"`;throw new TypeError(`Invalid parameter value: ${e}`)}});var Ds=P((Ls,qs)=>{(function(e,t){typeof Ls=="object"&&typeof qs<"u"?qs.exports=t():typeof define=="function"&&define.amd?define(t):e.Bottleneck=t()})(Ls,function(){"use strict";var e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function t(x){return x&&x.default||x}var r=function(x,g,u={}){var b,E,T;for(b in g)T=g[b],u[b]=(E=x[b])!=null?E:T;return u},n=function(x,g,u={}){var b,E;for(b in x)E=x[b],g[b]!==void 0&&(u[b]=E);return u},s={load:r,overwrite:n},i;i=class{constructor(g,u){this.incr=g,this.decr=u,this._first=null,this._last=null,this.length=0}push(g){var u;this.length++,typeof this.incr=="function"&&this.incr(),u={value:g,prev:this._last,next:null},this._last!=null?(this._last.next=u,this._last=u):this._first=this._last=u}shift(){var g;if(this._first!=null)return this.length--,typeof this.decr=="function"&&this.decr(),g=this._first.value,(this._first=this._first.next)!=null?this._first.prev=null:this._last=null,g}first(){if(this._first!=null)return this._first.value}getArray(){var g,u,b;for(g=this._first,b=[];g!=null;)b.push((u=g,g=g.next,u.value));return b}forEachShift(g){var u;for(u=this.shift();u!=null;)g(u),u=this.shift()}debug(){var g,u,b,E,T;for(g=this._first,T=[];g!=null;)T.push((u=g,g=g.next,{value:u.value,prev:(b=u.prev)!=null?b.value:void 0,next:(E=u.next)!=null?E.value:void 0}));return T}};var o=i,a;a=class{constructor(g){if(this.instance=g,this._events={},this.instance.on!=null||this.instance.once!=null||this.instance.removeAllListeners!=null)throw new Error("An Emitter already exists for this object");this.instance.on=(u,b)=>this._addListener(u,"many",b),this.instance.once=(u,b)=>this._addListener(u,"once",b),this.instance.removeAllListeners=(u=null)=>u!=null?delete this._events[u]:this._events={}}_addListener(g,u,b){var E;return(E=this._events)[g]==null&&(E[g]=[]),this._events[g].push({cb:b,status:u}),this.instance}listenerCount(g){return this._events[g]!=null?this._events[g].length:0}async trigger(g,...u){var b,E;try{return g!=="debug"&&this.trigger("debug",`Event triggered: ${g}`,u),this._events[g]==null?void 0:(this._events[g]=this._events[g].filter(function(T){return T.status!=="none"}),E=this._events[g].map(async T=>{var G,$;if(T.status!=="none"){T.status==="once"&&(T.status="none");try{return $=typeof T.cb=="function"?T.cb(...u):void 0,typeof $?.then=="function"?await $:$}catch(F){return G=F,this.trigger("error",G),null}}}),(await Promise.all(E)).find(function(T){return T!=null}))}catch(T){return b=T,this.trigger("error",b),null}}};var c=a,l,d,p;l=o,d=c,p=class{constructor(g){var u;this.Events=new d(this),this._length=0,this._lists=function(){var b,E,T;for(T=[],u=b=1,E=g;1<=E?b<=E:b>=E;u=1<=E?++b:--b)T.push(new l(()=>this.incr(),()=>this.decr()));return T}.call(this)}incr(){if(this._length++===0)return this.Events.trigger("leftzero")}decr(){if(--this._length===0)return this.Events.trigger("zero")}push(g){return this._lists[g.options.priority].push(g)}queued(g){return g!=null?this._lists[g].length:this._length}shiftAll(g){return this._lists.forEach(function(u){return u.forEachShift(g)})}getFirst(g=this._lists){var u,b,E;for(u=0,b=g.length;u<b;u++)if(E=g[u],E.length>0)return E;return[]}shiftLastFrom(g){return this.getFirst(this._lists.slice(g).reverse()).shift()}};var f=p,h;h=class extends Error{};var w=h,m,y,R,O,_;O=10,y=5,_=s,m=w,R=class{constructor(g,u,b,E,T,G,$,F){this.task=g,this.args=u,this.rejectOnDrop=T,this.Events=G,this._states=$,this.Promise=F,this.options=_.load(b,E),this.options.priority=this._sanitizePriority(this.options.priority),this.options.id===E.id&&(this.options.id=`${this.options.id}-${this._randomIndex()}`),this.promise=new this.Promise((K,z)=>{this._resolve=K,this._reject=z}),this.retryCount=0}_sanitizePriority(g){var u;return u=~~g!==g?y:g,u<0?0:u>O-1?O-1:u}_randomIndex(){return Math.random().toString(36).slice(2)}doDrop({error:g,message:u="This job has been dropped by Bottleneck"}={}){return this._states.remove(this.options.id)?(this.rejectOnDrop&&this._reject(g??new m(u)),this.Events.trigger("dropped",{args:this.args,options:this.options,task:this.task,promise:this.promise}),!0):!1}_assertStatus(g){var u;if(u=this._states.jobStatus(this.options.id),!(u===g||g==="DONE"&&u===null))throw new m(`Invalid job status ${u}, expected ${g}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`)}doReceive(){return this._states.start(this.options.id),this.Events.trigger("received",{args:this.args,options:this.options})}doQueue(g,u){return this._assertStatus("RECEIVED"),this._states.next(this.options.id),this.Events.trigger("queued",{args:this.args,options:this.options,reachedHWM:g,blocked:u})}doRun(){return this.retryCount===0?(this._assertStatus("QUEUED"),this._states.next(this.options.id)):this._assertStatus("EXECUTING"),this.Events.trigger("scheduled",{args:this.args,options:this.options})}async doExecute(g,u,b,E){var T,G,$;this.retryCount===0?(this._assertStatus("RUNNING"),this._states.next(this.options.id)):this._assertStatus("EXECUTING"),G={args:this.args,options:this.options,retryCount:this.retryCount},this.Events.trigger("executing",G);try{if($=await(g!=null?g.schedule(this.options,this.task,...this.args):this.task(...this.args)),u())return this.doDone(G),await E(this.options,G),this._assertStatus("DONE"),this._resolve($)}catch(F){return T=F,this._onFailure(T,G,u,b,E)}}doExpire(g,u,b){var E,T;return this._states.jobStatus(this.options.id==="RUNNING")&&this._states.next(this.options.id),this._assertStatus("EXECUTING"),T={args:this.args,options:this.options,retryCount:this.retryCount},E=new m(`This job timed out after ${this.options.expiration} ms.`),this._onFailure(E,T,g,u,b)}async _onFailure(g,u,b,E,T){var G,$;if(b())return G=await this.Events.trigger("failed",g,u),G!=null?($=~~G,this.Events.trigger("retry",`Retrying ${this.options.id} after ${$} ms`,u),this.retryCount++,E($)):(this.doDone(u),await T(this.options,u),this._assertStatus("DONE"),this._reject(g))}doDone(g){return this._assertStatus("EXECUTING"),this._states.next(this.options.id),this.Events.trigger("done",g)}};var k=R,S,A,C;C=s,S=w,A=class{constructor(g,u,b){this.instance=g,this.storeOptions=u,this.clientId=this.instance._randomIndex(),C.load(b,b,this),this._nextRequest=this._lastReservoirRefresh=this._lastReservoirIncrease=Date.now(),this._running=0,this._done=0,this._unblockTime=0,this.ready=this.Promise.resolve(),this.clients={},this._startHeartbeat()}_startHeartbeat(){var g;return this.heartbeat==null&&(this.storeOptions.reservoirRefreshInterval!=null&&this.storeOptions.reservoirRefreshAmount!=null||this.storeOptions.reservoirIncreaseInterval!=null&&this.storeOptions.reservoirIncreaseAmount!=null)?typeof(g=this.heartbeat=setInterval(()=>{var u,b,E,T,G;if(T=Date.now(),this.storeOptions.reservoirRefreshInterval!=null&&T>=this._lastReservoirRefresh+this.storeOptions.reservoirRefreshInterval&&(this._lastReservoirRefresh=T,this.storeOptions.reservoir=this.storeOptions.reservoirRefreshAmount,this.instance._drainAll(this.computeCapacity())),this.storeOptions.reservoirIncreaseInterval!=null&&T>=this._lastReservoirIncrease+this.storeOptions.reservoirIncreaseInterval&&({reservoirIncreaseAmount:u,reservoirIncreaseMaximum:E,reservoir:G}=this.storeOptions,this._lastReservoirIncrease=T,b=E!=null?Math.min(u,E-G):u,b>0))return this.storeOptions.reservoir+=b,this.instance._drainAll(this.computeCapacity())},this.heartbeatInterval)).unref=="function"?g.unref():void 0:clearInterval(this.heartbeat)}async __publish__(g){return await this.yieldLoop(),this.instance.Events.trigger("message",g.toString())}async __disconnect__(g){return await this.yieldLoop(),clearInterval(this.heartbeat),this.Promise.resolve()}yieldLoop(g=0){return new this.Promise(function(u,b){return setTimeout(u,g)})}computePenalty(){var g;return(g=this.storeOptions.penalty)!=null?g:15*this.storeOptions.minTime||5e3}async __updateSettings__(g){return await this.yieldLoop(),C.overwrite(g,g,this.storeOptions),this._startHeartbeat(),this.instance._drainAll(this.computeCapacity()),!0}async __running__(){return await this.yieldLoop(),this._running}async __queued__(){return await this.yieldLoop(),this.instance.queued()}async __done__(){return await this.yieldLoop(),this._done}async __groupCheck__(g){return await this.yieldLoop(),this._nextRequest+this.timeout<g}computeCapacity(){var g,u;return{maxConcurrent:g,reservoir:u}=this.storeOptions,g!=null&&u!=null?Math.min(g-this._running,u):g!=null?g-this._running:u??null}conditionsCheck(g){var u;return u=this.computeCapacity(),u==null||g<=u}async __incrementReservoir__(g){var u;return await this.yieldLoop(),u=this.storeOptions.reservoir+=g,this.instance._drainAll(this.computeCapacity()),u}async __currentReservoir__(){return await this.yieldLoop(),this.storeOptions.reservoir}isBlocked(g){return this._unblockTime>=g}check(g,u){return this.conditionsCheck(g)&&this._nextRequest-u<=0}async __check__(g){var u;return await this.yieldLoop(),u=Date.now(),this.check(g,u)}async __register__(g,u,b){var E,T;return await this.yieldLoop(),E=Date.now(),this.conditionsCheck(u)?(this._running+=u,this.storeOptions.reservoir!=null&&(this.storeOptions.reservoir-=u),T=Math.max(this._nextRequest-E,0),this._nextRequest=E+T+this.storeOptions.minTime,{success:!0,wait:T,reservoir:this.storeOptions.reservoir}):{success:!1}}strategyIsBlock(){return this.storeOptions.strategy===3}async __submit__(g,u){var b,E,T;if(await this.yieldLoop(),this.storeOptions.maxConcurrent!=null&&u>this.storeOptions.maxConcurrent)throw new S(`Impossible to add a job having a weight of ${u} to a limiter having a maxConcurrent setting of ${this.storeOptions.maxConcurrent}`);return E=Date.now(),T=this.storeOptions.highWater!=null&&g===this.storeOptions.highWater&&!this.check(u,E),b=this.strategyIsBlock()&&(T||this.isBlocked(E)),b&&(this._unblockTime=E+this.computePenalty(),this._nextRequest=this._unblockTime+this.storeOptions.minTime,this.instance._dropAllQueued()),{reachedHWM:T,blocked:b,strategy:this.storeOptions.strategy}}async __free__(g,u){return await this.yieldLoop(),this._running-=u,this._done+=u,this.instance._drainAll(this.computeCapacity()),{running:this._running}}};var v=A,I,N;I=w,N=class{constructor(g){this.status=g,this._jobs={},this.counts=this.status.map(function(){return 0})}next(g){var u,b;if(u=this._jobs[g],b=u+1,u!=null&&b<this.status.length)return this.counts[u]--,this.counts[b]++,this._jobs[g]++;if(u!=null)return this.counts[u]--,delete this._jobs[g]}start(g){var u;return u=0,this._jobs[g]=u,this.counts[u]++}remove(g){var u;return u=this._jobs[g],u!=null&&(this.counts[u]--,delete this._jobs[g]),u!=null}jobStatus(g){var u;return(u=this.status[this._jobs[g]])!=null?u:null}statusJobs(g){var u,b,E,T,G;if(g!=null){if(b=this.status.indexOf(g),b<0)throw new I(`status must be one of ${this.status.join(", ")}`);E=this._jobs,T=[];for(u in E)G=E[u],G===b&&T.push(u);return T}else return Object.keys(this._jobs)}statusCounts(){return this.counts.reduce((g,u,b)=>(g[this.status[b]]=u,g),{})}};var Q=N,D,je;D=o,je=class{constructor(g,u){this.schedule=this.schedule.bind(this),this.name=g,this.Promise=u,this._running=0,this._queue=new D}isEmpty(){return this._queue.length===0}async _tryToRun(){var g,u,b,E,T,G,$;if(this._running<1&&this._queue.length>0)return this._running++,{task:$,args:g,resolve:T,reject:E}=this._queue.shift(),u=await async function(){try{return G=await $(...g),function(){return T(G)}}catch(F){return b=F,function(){return E(b)}}}(),this._running--,this._tryToRun(),u()}schedule(g,...u){var b,E,T;return T=E=null,b=new this.Promise(function(G,$){return T=G,E=$}),this._queue.push({task:g,args:u,resolve:T,reject:E}),this._tryToRun(),b}};var Be=je,Ue="2.19.5",Zn={version:Ue},de=Object.freeze({version:Ue,default:Zn}),wr=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),ra=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),sf=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),na,sa,ia,oa,aa,Er;Er=s,na=c,oa=wr,ia=ra,aa=sf,sa=function(){class x{constructor(u={}){this.deleteKey=this.deleteKey.bind(this),this.limiterOptions=u,Er.load(this.limiterOptions,this.defaults,this),this.Events=new na(this),this.instances={},this.Bottleneck=ba,this._startAutoCleanup(),this.sharedConnection=this.connection!=null,this.connection==null&&(this.limiterOptions.datastore==="redis"?this.connection=new oa(Object.assign({},this.limiterOptions,{Events:this.Events})):this.limiterOptions.datastore==="ioredis"&&(this.connection=new ia(Object.assign({},this.limiterOptions,{Events:this.Events}))))}key(u=""){var b;return(b=this.instances[u])!=null?b:(()=>{var E;return E=this.instances[u]=new this.Bottleneck(Object.assign(this.limiterOptions,{id:`${this.id}-${u}`,timeout:this.timeout,connection:this.connection})),this.Events.trigger("created",E,u),E})()}async deleteKey(u=""){var b,E;return E=this.instances[u],this.connection&&(b=await this.connection.__runCommand__(["del",...aa.allKeys(`${this.id}-${u}`)])),E!=null&&(delete this.instances[u],await E.disconnect()),E!=null||b>0}limiters(){var u,b,E,T;b=this.instances,E=[];for(u in b)T=b[u],E.push({key:u,limiter:T});return E}keys(){return Object.keys(this.instances)}async clusterKeys(){var u,b,E,T,G,$,F,K,z;if(this.connection==null)return this.Promise.resolve(this.keys());for($=[],u=null,z=`b_${this.id}-`.length,b=9;u!==0;)for([K,E]=await this.connection.__runCommand__(["scan",u??0,"match",`b_${this.id}-*_settings`,"count",1e4]),u=~~K,T=0,F=E.length;T<F;T++)G=E[T],$.push(G.slice(z,-b));return $}_startAutoCleanup(){var u;return clearInterval(this.interval),typeof(u=this.interval=setInterval(async()=>{var b,E,T,G,$,F;$=Date.now(),T=this.instances,G=[];for(E in T){F=T[E];try{await F._store.__groupCheck__($)?G.push(this.deleteKey(E)):G.push(void 0)}catch(K){b=K,G.push(F.Events.trigger("error",b))}}return G},this.timeout/2)).unref=="function"?u.unref():void 0}updateSettings(u={}){if(Er.overwrite(u,this.defaults,this),Er.overwrite(u,u,this.limiterOptions),u.timeout!=null)return this._startAutoCleanup()}disconnect(u=!0){var b;if(!this.sharedConnection)return(b=this.connection)!=null?b.disconnect(u):void 0}}return x.prototype.defaults={timeout:1e3*60*5,connection:null,Promise,id:"group-key"},x}.call(e);var of=sa,ca,la,ua;ua=s,la=c,ca=function(){class x{constructor(u={}){this.options=u,ua.load(this.options,this.defaults,this),this.Events=new la(this),this._arr=[],this._resetPromise(),this._lastFlush=Date.now()}_resetPromise(){return this._promise=new this.Promise((u,b)=>this._resolve=u)}_flush(){return clearTimeout(this._timeout),this._lastFlush=Date.now(),this._resolve(),this.Events.trigger("batch",this._arr),this._arr=[],this._resetPromise()}add(u){var b;return this._arr.push(u),b=this._promise,this._arr.length===this.maxSize?this._flush():this.maxTime!=null&&this._arr.length===1&&(this._timeout=setTimeout(()=>this._flush(),this.maxTime)),b}}return x.prototype.defaults={maxTime:null,maxSize:null,Promise},x}.call(e);var af=ca,cf=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),lf=t(de),da,pa,es,ts,fa,rs,ha,ma,ga,ns,ye,ya=[].splice;rs=10,pa=5,ye=s,ha=f,ts=k,fa=v,ma=cf,es=c,ga=Q,ns=Be,da=function(){class x{constructor(u={},...b){var E,T;this._addToQueue=this._addToQueue.bind(this),this._validateOptions(u,b),ye.load(u,this.instanceDefaults,this),this._queues=new ha(rs),this._scheduled={},this._states=new ga(["RECEIVED","QUEUED","RUNNING","EXECUTING"].concat(this.trackDoneStatus?["DONE"]:[])),this._limiter=null,this.Events=new es(this),this._submitLock=new ns("submit",this.Promise),this._registerLock=new ns("register",this.Promise),T=ye.load(u,this.storeDefaults,{}),this._store=function(){if(this.datastore==="redis"||this.datastore==="ioredis"||this.connection!=null)return E=ye.load(u,this.redisStoreDefaults,{}),new ma(this,T,E);if(this.datastore==="local")return E=ye.load(u,this.localStoreDefaults,{}),new fa(this,T,E);throw new x.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`)}.call(this),this._queues.on("leftzero",()=>{var G;return(G=this._store.heartbeat)!=null&&typeof G.ref=="function"?G.ref():void 0}),this._queues.on("zero",()=>{var G;return(G=this._store.heartbeat)!=null&&typeof G.unref=="function"?G.unref():void 0})}_validateOptions(u,b){if(!(u!=null&&typeof u=="object"&&b.length===0))throw new x.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.")}ready(){return this._store.ready}clients(){return this._store.clients}channel(){return`b_${this.id}`}channel_client(){return`b_${this.id}_${this._store.clientId}`}publish(u){return this._store.__publish__(u)}disconnect(u=!0){return this._store.__disconnect__(u)}chain(u){return this._limiter=u,this}queued(u){return this._queues.queued(u)}clusterQueued(){return this._store.__queued__()}empty(){return this.queued()===0&&this._submitLock.isEmpty()}running(){return this._store.__running__()}done(){return this._store.__done__()}jobStatus(u){return this._states.jobStatus(u)}jobs(u){return this._states.statusJobs(u)}counts(){return this._states.statusCounts()}_randomIndex(){return Math.random().toString(36).slice(2)}check(u=1){return this._store.__check__(u)}_clearGlobalState(u){return this._scheduled[u]!=null?(clearTimeout(this._scheduled[u].expiration),delete this._scheduled[u],!0):!1}async _free(u,b,E,T){var G,$;try{if({running:$}=await this._store.__free__(u,E.weight),this.Events.trigger("debug",`Freed ${E.id}`,T),$===0&&this.empty())return this.Events.trigger("idle")}catch(F){return G=F,this.Events.trigger("error",G)}}_run(u,b,E){var T,G,$;return b.doRun(),T=this._clearGlobalState.bind(this,u),$=this._run.bind(this,u,b),G=this._free.bind(this,u,b),this._scheduled[u]={timeout:setTimeout(()=>b.doExecute(this._limiter,T,$,G),E),expiration:b.options.expiration!=null?setTimeout(function(){return b.doExpire(T,$,G)},E+b.options.expiration):void 0,job:b}}_drainOne(u){return this._registerLock.schedule(()=>{var b,E,T,G,$;return this.queued()===0?this.Promise.resolve(null):($=this._queues.getFirst(),{options:G,args:b}=T=$.first(),u!=null&&G.weight>u?this.Promise.resolve(null):(this.Events.trigger("debug",`Draining ${G.id}`,{args:b,options:G}),E=this._randomIndex(),this._store.__register__(E,G.weight,G.expiration).then(({success:F,wait:K,reservoir:z})=>{var Rt;return this.Events.trigger("debug",`Drained ${G.id}`,{success:F,args:b,options:G}),F?($.shift(),Rt=this.empty(),Rt&&this.Events.trigger("empty"),z===0&&this.Events.trigger("depleted",Rt),this._run(E,T,K),this.Promise.resolve(G.weight)):this.Promise.resolve(null)})))})}_drainAll(u,b=0){return this._drainOne(u).then(E=>{var T;return E!=null?(T=u!=null?u-E:u,this._drainAll(T,b+E)):this.Promise.resolve(b)}).catch(E=>this.Events.trigger("error",E))}_dropAllQueued(u){return this._queues.shiftAll(function(b){return b.doDrop({message:u})})}stop(u={}){var b,E;return u=ye.load(u,this.stopDefaults),E=T=>{var G;return G=()=>{var $;return $=this._states.counts,$[0]+$[1]+$[2]+$[3]===T},new this.Promise(($,F)=>G()?$():this.on("done",()=>{if(G())return this.removeAllListeners("done"),$()}))},b=u.dropWaitingJobs?(this._run=function(T,G){return G.doDrop({message:u.dropErrorMessage})},this._drainOne=()=>this.Promise.resolve(null),this._registerLock.schedule(()=>this._submitLock.schedule(()=>{var T,G,$;G=this._scheduled;for(T in G)$=G[T],this.jobStatus($.job.options.id)==="RUNNING"&&(clearTimeout($.timeout),clearTimeout($.expiration),$.job.doDrop({message:u.dropErrorMessage}));return this._dropAllQueued(u.dropErrorMessage),E(0)}))):this.schedule({priority:rs-1,weight:0},()=>E(1)),this._receive=function(T){return T._reject(new x.prototype.BottleneckError(u.enqueueErrorMessage))},this.stop=()=>this.Promise.reject(new x.prototype.BottleneckError("stop() has already been called")),b}async _addToQueue(u){var b,E,T,G,$,F,K;({args:b,options:G}=u);try{({reachedHWM:$,blocked:E,strategy:K}=await this._store.__submit__(this.queued(),G.weight))}catch(z){return T=z,this.Events.trigger("debug",`Could not queue ${G.id}`,{args:b,options:G,error:T}),u.doDrop({error:T}),!1}return E?(u.doDrop(),!0):$&&(F=K===x.prototype.strategy.LEAK?this._queues.shiftLastFrom(G.priority):K===x.prototype.strategy.OVERFLOW_PRIORITY?this._queues.shiftLastFrom(G.priority+1):K===x.prototype.strategy.OVERFLOW?u:void 0,F?.doDrop(),F==null||K===x.prototype.strategy.OVERFLOW)?(F==null&&u.doDrop(),$):(u.doQueue($,E),this._queues.push(u),await this._drainAll(),$)}_receive(u){return this._states.jobStatus(u.options.id)!=null?(u._reject(new x.prototype.BottleneckError(`A job with the same id already exists (id=${u.options.id})`)),!1):(u.doReceive(),this._submitLock.schedule(this._addToQueue,u))}submit(...u){var b,E,T,G,$,F,K;return typeof u[0]=="function"?($=u,[E,...u]=$,[b]=ya.call(u,-1),G=ye.load({},this.jobDefaults)):(F=u,[G,E,...u]=F,[b]=ya.call(u,-1),G=ye.load(G,this.jobDefaults)),K=(...z)=>new this.Promise(function(Rt,df){return E(...z,function(...wa){return(wa[0]!=null?df:Rt)(wa)})}),T=new ts(K,u,G,this.jobDefaults,this.rejectOnDrop,this.Events,this._states,this.Promise),T.promise.then(function(z){return typeof b=="function"?b(...z):void 0}).catch(function(z){return Array.isArray(z)?typeof b=="function"?b(...z):void 0:typeof b=="function"?b(z):void 0}),this._receive(T)}schedule(...u){var b,E,T;return typeof u[0]=="function"?([T,...u]=u,E={}):[E,T,...u]=u,b=new ts(T,u,E,this.jobDefaults,this.rejectOnDrop,this.Events,this._states,this.Promise),this._receive(b),b.promise}wrap(u){var b,E;return b=this.schedule.bind(this),E=function(...T){return b(u.bind(this),...T)},E.withOptions=function(T,...G){return b(T,u,...G)},E}async updateSettings(u={}){return await this._store.__updateSettings__(ye.overwrite(u,this.storeDefaults)),ye.overwrite(u,this.instanceDefaults,this),this}currentReservoir(){return this._store.__currentReservoir__()}incrementReservoir(u=0){return this._store.__incrementReservoir__(u)}}return x.default=x,x.Events=es,x.version=x.prototype.version=lf.version,x.strategy=x.prototype.strategy={LEAK:1,OVERFLOW:2,OVERFLOW_PRIORITY:4,BLOCK:3},x.BottleneckError=x.prototype.BottleneckError=w,x.Group=x.prototype.Group=of,x.RedisConnection=x.prototype.RedisConnection=wr,x.IORedisConnection=x.prototype.IORedisConnection=ra,x.Batcher=x.prototype.Batcher=af,x.prototype.jobDefaults={priority:pa,weight:1,expiration:null,id:"<no-id>"},x.prototype.storeDefaults={maxConcurrent:null,minTime:0,highWater:null,strategy:x.prototype.strategy.LEAK,penalty:null,reservoir:null,reservoirRefreshInterval:null,reservoirRefreshAmount:null,reservoirIncreaseInterval:null,reservoirIncreaseAmount:null,reservoirIncreaseMaximum:null},x.prototype.localStoreDefaults={Promise,timeout:null,heartbeatInterval:250},x.prototype.redisStoreDefaults={Promise,timeout:null,heartbeatInterval:5e3,clientTimeout:1e4,Redis:null,clientOptions:{},clusterNodes:null,clearDatastore:!1,connection:null},x.prototype.instanceDefaults={datastore:"local",connection:null,id:"<no-id>",rejectOnDrop:!0,trackDoneStatus:!1,Promise},x.prototype.stopDefaults={enqueueErrorMessage:"This limiter has been stopped and cannot accept new jobs.",dropWaitingJobs:!0,dropErrorMessage:"This limiter has been stopped."},x}.call(e);var ba=da,uf=ba;return uf})});var L=P(W=>{"use strict";var ri=Symbol.for("yaml.alias"),Al=Symbol.for("yaml.document"),zr=Symbol.for("yaml.map"),Gl=Symbol.for("yaml.pair"),ni=Symbol.for("yaml.scalar"),Jr=Symbol.for("yaml.seq"),_e=Symbol.for("yaml.node.type"),Sg=e=>!!e&&typeof e=="object"&&e[_e]===ri,Rg=e=>!!e&&typeof e=="object"&&e[_e]===Al,Ag=e=>!!e&&typeof e=="object"&&e[_e]===zr,Gg=e=>!!e&&typeof e=="object"&&e[_e]===Gl,Ol=e=>!!e&&typeof e=="object"&&e[_e]===ni,Og=e=>!!e&&typeof e=="object"&&e[_e]===Jr;function Pl(e){if(e&&typeof e=="object")switch(e[_e]){case zr:case Jr:return!0}return!1}function Pg(e){if(e&&typeof e=="object")switch(e[_e]){case ri:case zr:case ni:case Jr:return!0}return!1}var Cg=e=>(Ol(e)||Pl(e))&&!!e.anchor;W.ALIAS=ri;W.DOC=Al;W.MAP=zr;W.NODE_TYPE=_e;W.PAIR=Gl;W.SCALAR=ni;W.SEQ=Jr;W.hasAnchor=Cg;W.isAlias=Sg;W.isCollection=Pl;W.isDocument=Rg;W.isMap=Ag;W.isNode=Pg;W.isPair=Gg;W.isScalar=Ol;W.isSeq=Og});var Nt=P(si=>{"use strict";var V=L(),re=Symbol("break visit"),Cl=Symbol("skip children"),we=Symbol("remove node");function Yr(e,t){let r=$l(t);V.isDocument(e)?ht(null,e.contents,r,Object.freeze([e]))===we&&(e.contents=null):ht(null,e,r,Object.freeze([]))}Yr.BREAK=re;Yr.SKIP=Cl;Yr.REMOVE=we;function ht(e,t,r,n){let s=xl(e,t,r,n);if(V.isNode(s)||V.isPair(s))return Il(e,n,s),ht(e,s,r,n);if(typeof s!="symbol"){if(V.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=ht(i,t.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===re)return re;o===we&&(t.items.splice(i,1),i-=1)}}}else if(V.isPair(t)){n=Object.freeze(n.concat(t));let i=ht("key",t.key,r,n);if(i===re)return re;i===we&&(t.key=null);let o=ht("value",t.value,r,n);if(o===re)return re;o===we&&(t.value=null)}}return s}async function Qr(e,t){let r=$l(t);V.isDocument(e)?await mt(null,e.contents,r,Object.freeze([e]))===we&&(e.contents=null):await mt(null,e,r,Object.freeze([]))}Qr.BREAK=re;Qr.SKIP=Cl;Qr.REMOVE=we;async function mt(e,t,r,n){let s=await xl(e,t,r,n);if(V.isNode(s)||V.isPair(s))return Il(e,n,s),mt(e,s,r,n);if(typeof s!="symbol"){if(V.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=await mt(i,t.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===re)return re;o===we&&(t.items.splice(i,1),i-=1)}}}else if(V.isPair(t)){n=Object.freeze(n.concat(t));let i=await mt("key",t.key,r,n);if(i===re)return re;i===we&&(t.key=null);let o=await mt("value",t.value,r,n);if(o===re)return re;o===we&&(t.value=null)}}return s}function $l(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function xl(e,t,r,n){if(typeof r=="function")return r(e,t,n);if(V.isMap(t))return r.Map?.(e,t,n);if(V.isSeq(t))return r.Seq?.(e,t,n);if(V.isPair(t))return r.Pair?.(e,t,n);if(V.isScalar(t))return r.Scalar?.(e,t,n);if(V.isAlias(t))return r.Alias?.(e,t,n)}function Il(e,t,r){let n=t[t.length-1];if(V.isCollection(n))n.items[e]=r;else if(V.isPair(n))e==="key"?n.key=r:n.value=r;else if(V.isDocument(n))n.contents=r;else{let s=V.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}si.visit=Yr;si.visitAsync=Qr});var ii=P(Ll=>{"use strict";var Nl=L(),$g=Nt(),xg={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ig=e=>e.replace(/[!,[\]{}]/g,t=>xg[t]),Lt=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let n=t.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[i,o]=n;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return r(6,`Unsupported YAML version ${i}`,o),!1}}default:return r(0,`Unknown directive ${s}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,n,s]=t.match(/^(.*!)([^!]*)$/s);s||r(`The ${t} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(s)}catch(o){return r(String(o)),null}return n==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,n]of Object.entries(this.tags))if(t.startsWith(n))return r+Ig(t.substring(n.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),s;if(t&&n.length>0&&Nl.isNode(t.contents)){let i={};$g.visit(t.contents,(o,a)=>{Nl.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of n)i==="!!"&&o==="tag:yaml.org,2002:"||(!t||s.some(a=>a.startsWith(o)))&&r.push(`%TAG ${i} ${o}`);return r.join(`
|
|
4
|
-
`)}};Lt.defaultYaml={explicit:!1,version:"1.2"};Lt.defaultTags={"!!":"tag:yaml.org,2002:"};Ll.Directives=Lt});var Xr=P(qt=>{"use strict";var ql=L(),Ng=Nt();function Lg(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function Dl(e){let t=new Set;return Ng.visit(e,{Value(r,n){n.anchor&&t.add(n.anchor)}}),t}function Fl(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function qg(e,t){let r=[],n=new Map,s=null;return{onAnchor:i=>{r.push(i),s??(s=Dl(e));let o=Fl(t,s);return s.add(o),o},setAnchors:()=>{for(let i of r){let o=n.get(i);if(typeof o=="object"&&o.anchor&&(ql.isScalar(o.node)||ql.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}qt.anchorIsValid=Lg;qt.anchorNames=Dl;qt.createNodeAnchors=qg;qt.findNewAnchor=Fl});var oi=P(jl=>{"use strict";function Dt(e,t,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0,i=n.length;s<i;++s){let o=n[s],a=Dt(e,n,String(s),o);a===void 0?delete n[s]:a!==o&&(n[s]=a)}else if(n instanceof Map)for(let s of Array.from(n.keys())){let i=n.get(s),o=Dt(e,n,s,i);o===void 0?n.delete(s):o!==i&&n.set(s,o)}else if(n instanceof Set)for(let s of Array.from(n)){let i=Dt(e,n,s,s);i===void 0?n.delete(s):i!==s&&(n.delete(s),n.add(i))}else for(let[s,i]of Object.entries(n)){let o=Dt(e,n,s,i);o===void 0?delete n[s]:o!==i&&(n[s]=o)}return e.call(t,r,n)}jl.applyReviver=Dt});var Oe=P(Ul=>{"use strict";var Dg=L();function Bl(e,t,r){if(Array.isArray(e))return e.map((n,s)=>Bl(n,String(s),r));if(e&&typeof e.toJSON=="function"){if(!r||!Dg.hasAnchor(e))return e.toJSON(t,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(e,n),r.onCreate=i=>{n.res=i,delete r.onCreate};let s=e.toJSON(t,r);return r.onCreate&&r.onCreate(s),s}return typeof e=="bigint"&&!r?.keep?Number(e):e}Ul.toJS=Bl});var Zr=P(Vl=>{"use strict";var Fg=oi(),Ml=L(),jg=Oe(),ai=class{constructor(t){Object.defineProperty(this,Ml.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:n,onAnchor:s,reviver:i}={}){if(!Ml.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=jg.toJS(this,"",o);if(typeof s=="function")for(let{count:c,res:l}of o.anchors.values())s(l,c);return typeof i=="function"?Fg.applyReviver(i,{"":a},"",a):a}};Vl.NodeBase=ai});var Ft=P(Hl=>{"use strict";var Bg=Xr(),Ug=Nt(),gt=L(),Mg=Zr(),Vg=Oe(),ci=class extends Mg.NodeBase{constructor(t){super(gt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],Ug.visit(t,{Node:(i,o)=>{(gt.isAlias(o)||gt.hasAnchor(o))&&n.push(o)}}),r&&(r.aliasResolveCache=n));let s;for(let i of n){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(t,r){if(!r)return{source:this.source};let{anchors:n,doc:s,maxAliasCount:i}=r,o=this.resolve(s,r);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=n.get(o);if(a||(Vg.toJS(o,null,r),a=n.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=en(s,o,n)),a.count*a.aliasCount>i)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(t,r,n){let s=`*${this.source}`;if(t){if(Bg.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(t.implicitKey)return`${s} `}return s}};function en(e,t,r){if(gt.isAlias(t)){let n=t.resolve(e),s=r&&n&&r.get(n);return s?s.count*s.aliasCount:0}else if(gt.isCollection(t)){let n=0;for(let s of t.items){let i=en(e,s,r);i>n&&(n=i)}return n}else if(gt.isPair(t)){let n=en(e,t.key,r),s=en(e,t.value,r);return Math.max(n,s)}return 1}Hl.Alias=ci});var U=P(li=>{"use strict";var Hg=L(),Kg=Zr(),Wg=Oe(),zg=e=>!e||typeof e!="function"&&typeof e!="object",Pe=class extends Kg.NodeBase{constructor(t){super(Hg.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:Wg.toJS(this.value,t,r)}toString(){return String(this.value)}};Pe.BLOCK_FOLDED="BLOCK_FOLDED";Pe.BLOCK_LITERAL="BLOCK_LITERAL";Pe.PLAIN="PLAIN";Pe.QUOTE_DOUBLE="QUOTE_DOUBLE";Pe.QUOTE_SINGLE="QUOTE_SINGLE";li.Scalar=Pe;li.isScalarValue=zg});var jt=P(Wl=>{"use strict";var Jg=Ft(),Je=L(),Kl=U(),Yg="tag:yaml.org,2002:";function Qg(e,t,r){if(t){let n=r.filter(i=>i.tag===t),s=n.find(i=>!i.format)??n[0];if(!s)throw new Error(`Tag ${t} not found`);return s}return r.find(n=>n.identify?.(e)&&!n.format)}function Xg(e,t,r){if(Je.isDocument(e)&&(e=e.contents),Je.isNode(e))return e;if(Je.isPair(e)){let p=r.schema[Je.MAP].createNode?.(r.schema,null,r);return p.items.push(e),p}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=r,c;if(n&&e&&typeof e=="object"){if(c=a.get(e),c)return c.anchor??(c.anchor=s(e)),new Jg.Alias(c.anchor);c={anchor:null,node:null},a.set(e,c)}t?.startsWith("!!")&&(t=Yg+t.slice(2));let l=Qg(e,t,o.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let p=new Kl.Scalar(e);return c&&(c.node=p),p}l=e instanceof Map?o[Je.MAP]:Symbol.iterator in Object(e)?o[Je.SEQ]:o[Je.MAP]}i&&(i(l),delete r.onTagObj);let d=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,e,r):new Kl.Scalar(e);return t?d.tag=t:l.default||(d.tag=l.tag),c&&(c.node=d),d}Wl.createNode=Xg});var rn=P(tn=>{"use strict";var Zg=jt(),
|
|
3
|
+
var pf=Object.create;var Ea=Object.defineProperty;var ff=Object.getOwnPropertyDescriptor;var hf=Object.getOwnPropertyNames;var mf=Object.getPrototypeOf,gf=Object.prototype.hasOwnProperty;var Tr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var yf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of hf(t))!gf.call(e,s)&&s!==r&&Ea(e,s,{get:()=>t[s],enumerable:!(n=ff(t,s))||n.enumerable});return e};var At=(e,t,r)=>(r=e!=null?pf(mf(e)):{},yf(t||!e||!e.__esModule?Ea(r,"default",{value:e,enumerable:!0}):r,e));var ic=P(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.format=gh;Pr.parse=yh;var fh=/^[\u0009\u0020-\u007e\u0080-\u00ff]*$/,ec=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,hh=/[\\"]/g,mh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,tc=(()=>{let e=function(){};return e.prototype=Object.create(null),e})();function gh(e){let{type:t,parameters:r}=e;if(!t||!mh.test(t))throw new TypeError(`Invalid type: ${t}`);let n=t;if(r)for(let s of Object.keys(r)){if(!ec.test(s))throw new TypeError(`Invalid parameter name: ${s}`);n+=`; ${s}=${Th(r[s])}`}return n}function yh(e,t){let r=e.length,n=_s(e,0,r),s=n;n=Ts(e,n,r);let i=ks(e,s,n),o=e.slice(s,i).toLowerCase(),a=t?.parameters===!1?new tc:Eh(e,n,r);return{type:o,parameters:a}}var rc=32,nc=9,sc=59,bh=61,Za=34,wh=92;function Eh(e,t,r){let n=new tc;e:for(;t<r;){t=_s(e,t+1,r);let s=t;for(;t<r;){let i=e.charCodeAt(t);if(i===sc)continue e;if(i===bh){let o=ks(e,s,t),a=e.slice(s,o).toLowerCase();if(t=_s(e,t+1,r),t<r&&e.charCodeAt(t)===Za){t++;let l="";for(;t<r;){let d=e.charCodeAt(t++);if(d===Za){t=Ts(e,t,r),n[a]===void 0&&(n[a]=l);break}if(d===wh&&t<r){l+=e[t++];continue}l+=String.fromCharCode(d)}continue e}let c=t;if(t=Ts(e,t,r),n[a]===void 0){let l=ks(e,c,t);n[a]=e.slice(c,l)}continue e}t++}}return n}function Ts(e,t,r){for(;t<r&&e.charCodeAt(t)!==sc;)t++;return t}function _s(e,t,r){for(;t<r;){let n=e.charCodeAt(t);if(n!==rc&&n!==nc)break;t++}return t}function ks(e,t,r){for(;r>t;){let n=e.charCodeAt(r-1);if(n!==rc&&n!==nc)break;r--}return r}function Th(e){if(ec.test(e))return e;if(fh.test(e))return`"${e.replace(hh,"\\$&")}"`;throw new TypeError(`Invalid parameter value: ${e}`)}});var Ds=P((Ls,qs)=>{(function(e,t){typeof Ls=="object"&&typeof qs<"u"?qs.exports=t():typeof define=="function"&&define.amd?define(t):e.Bottleneck=t()})(Ls,function(){"use strict";var e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function t(x){return x&&x.default||x}var r=function(x,g,u={}){var b,E,T;for(b in g)T=g[b],u[b]=(E=x[b])!=null?E:T;return u},n=function(x,g,u={}){var b,E;for(b in x)E=x[b],g[b]!==void 0&&(u[b]=E);return u},s={load:r,overwrite:n},i;i=class{constructor(g,u){this.incr=g,this.decr=u,this._first=null,this._last=null,this.length=0}push(g){var u;this.length++,typeof this.incr=="function"&&this.incr(),u={value:g,prev:this._last,next:null},this._last!=null?(this._last.next=u,this._last=u):this._first=this._last=u}shift(){var g;if(this._first!=null)return this.length--,typeof this.decr=="function"&&this.decr(),g=this._first.value,(this._first=this._first.next)!=null?this._first.prev=null:this._last=null,g}first(){if(this._first!=null)return this._first.value}getArray(){var g,u,b;for(g=this._first,b=[];g!=null;)b.push((u=g,g=g.next,u.value));return b}forEachShift(g){var u;for(u=this.shift();u!=null;)g(u),u=this.shift()}debug(){var g,u,b,E,T;for(g=this._first,T=[];g!=null;)T.push((u=g,g=g.next,{value:u.value,prev:(b=u.prev)!=null?b.value:void 0,next:(E=u.next)!=null?E.value:void 0}));return T}};var o=i,a;a=class{constructor(g){if(this.instance=g,this._events={},this.instance.on!=null||this.instance.once!=null||this.instance.removeAllListeners!=null)throw new Error("An Emitter already exists for this object");this.instance.on=(u,b)=>this._addListener(u,"many",b),this.instance.once=(u,b)=>this._addListener(u,"once",b),this.instance.removeAllListeners=(u=null)=>u!=null?delete this._events[u]:this._events={}}_addListener(g,u,b){var E;return(E=this._events)[g]==null&&(E[g]=[]),this._events[g].push({cb:b,status:u}),this.instance}listenerCount(g){return this._events[g]!=null?this._events[g].length:0}async trigger(g,...u){var b,E;try{return g!=="debug"&&this.trigger("debug",`Event triggered: ${g}`,u),this._events[g]==null?void 0:(this._events[g]=this._events[g].filter(function(T){return T.status!=="none"}),E=this._events[g].map(async T=>{var G,$;if(T.status!=="none"){T.status==="once"&&(T.status="none");try{return $=typeof T.cb=="function"?T.cb(...u):void 0,typeof $?.then=="function"?await $:$}catch(F){return G=F,this.trigger("error",G),null}}}),(await Promise.all(E)).find(function(T){return T!=null}))}catch(T){return b=T,this.trigger("error",b),null}}};var c=a,l,d,p;l=o,d=c,p=class{constructor(g){var u;this.Events=new d(this),this._length=0,this._lists=function(){var b,E,T;for(T=[],u=b=1,E=g;1<=E?b<=E:b>=E;u=1<=E?++b:--b)T.push(new l(()=>this.incr(),()=>this.decr()));return T}.call(this)}incr(){if(this._length++===0)return this.Events.trigger("leftzero")}decr(){if(--this._length===0)return this.Events.trigger("zero")}push(g){return this._lists[g.options.priority].push(g)}queued(g){return g!=null?this._lists[g].length:this._length}shiftAll(g){return this._lists.forEach(function(u){return u.forEachShift(g)})}getFirst(g=this._lists){var u,b,E;for(u=0,b=g.length;u<b;u++)if(E=g[u],E.length>0)return E;return[]}shiftLastFrom(g){return this.getFirst(this._lists.slice(g).reverse()).shift()}};var f=p,h;h=class extends Error{};var w=h,m,y,R,O,_;O=10,y=5,_=s,m=w,R=class{constructor(g,u,b,E,T,G,$,F){this.task=g,this.args=u,this.rejectOnDrop=T,this.Events=G,this._states=$,this.Promise=F,this.options=_.load(b,E),this.options.priority=this._sanitizePriority(this.options.priority),this.options.id===E.id&&(this.options.id=`${this.options.id}-${this._randomIndex()}`),this.promise=new this.Promise((K,z)=>{this._resolve=K,this._reject=z}),this.retryCount=0}_sanitizePriority(g){var u;return u=~~g!==g?y:g,u<0?0:u>O-1?O-1:u}_randomIndex(){return Math.random().toString(36).slice(2)}doDrop({error:g,message:u="This job has been dropped by Bottleneck"}={}){return this._states.remove(this.options.id)?(this.rejectOnDrop&&this._reject(g??new m(u)),this.Events.trigger("dropped",{args:this.args,options:this.options,task:this.task,promise:this.promise}),!0):!1}_assertStatus(g){var u;if(u=this._states.jobStatus(this.options.id),!(u===g||g==="DONE"&&u===null))throw new m(`Invalid job status ${u}, expected ${g}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`)}doReceive(){return this._states.start(this.options.id),this.Events.trigger("received",{args:this.args,options:this.options})}doQueue(g,u){return this._assertStatus("RECEIVED"),this._states.next(this.options.id),this.Events.trigger("queued",{args:this.args,options:this.options,reachedHWM:g,blocked:u})}doRun(){return this.retryCount===0?(this._assertStatus("QUEUED"),this._states.next(this.options.id)):this._assertStatus("EXECUTING"),this.Events.trigger("scheduled",{args:this.args,options:this.options})}async doExecute(g,u,b,E){var T,G,$;this.retryCount===0?(this._assertStatus("RUNNING"),this._states.next(this.options.id)):this._assertStatus("EXECUTING"),G={args:this.args,options:this.options,retryCount:this.retryCount},this.Events.trigger("executing",G);try{if($=await(g!=null?g.schedule(this.options,this.task,...this.args):this.task(...this.args)),u())return this.doDone(G),await E(this.options,G),this._assertStatus("DONE"),this._resolve($)}catch(F){return T=F,this._onFailure(T,G,u,b,E)}}doExpire(g,u,b){var E,T;return this._states.jobStatus(this.options.id==="RUNNING")&&this._states.next(this.options.id),this._assertStatus("EXECUTING"),T={args:this.args,options:this.options,retryCount:this.retryCount},E=new m(`This job timed out after ${this.options.expiration} ms.`),this._onFailure(E,T,g,u,b)}async _onFailure(g,u,b,E,T){var G,$;if(b())return G=await this.Events.trigger("failed",g,u),G!=null?($=~~G,this.Events.trigger("retry",`Retrying ${this.options.id} after ${$} ms`,u),this.retryCount++,E($)):(this.doDone(u),await T(this.options,u),this._assertStatus("DONE"),this._reject(g))}doDone(g){return this._assertStatus("EXECUTING"),this._states.next(this.options.id),this.Events.trigger("done",g)}};var k=R,S,A,C;C=s,S=w,A=class{constructor(g,u,b){this.instance=g,this.storeOptions=u,this.clientId=this.instance._randomIndex(),C.load(b,b,this),this._nextRequest=this._lastReservoirRefresh=this._lastReservoirIncrease=Date.now(),this._running=0,this._done=0,this._unblockTime=0,this.ready=this.Promise.resolve(),this.clients={},this._startHeartbeat()}_startHeartbeat(){var g;return this.heartbeat==null&&(this.storeOptions.reservoirRefreshInterval!=null&&this.storeOptions.reservoirRefreshAmount!=null||this.storeOptions.reservoirIncreaseInterval!=null&&this.storeOptions.reservoirIncreaseAmount!=null)?typeof(g=this.heartbeat=setInterval(()=>{var u,b,E,T,G;if(T=Date.now(),this.storeOptions.reservoirRefreshInterval!=null&&T>=this._lastReservoirRefresh+this.storeOptions.reservoirRefreshInterval&&(this._lastReservoirRefresh=T,this.storeOptions.reservoir=this.storeOptions.reservoirRefreshAmount,this.instance._drainAll(this.computeCapacity())),this.storeOptions.reservoirIncreaseInterval!=null&&T>=this._lastReservoirIncrease+this.storeOptions.reservoirIncreaseInterval&&({reservoirIncreaseAmount:u,reservoirIncreaseMaximum:E,reservoir:G}=this.storeOptions,this._lastReservoirIncrease=T,b=E!=null?Math.min(u,E-G):u,b>0))return this.storeOptions.reservoir+=b,this.instance._drainAll(this.computeCapacity())},this.heartbeatInterval)).unref=="function"?g.unref():void 0:clearInterval(this.heartbeat)}async __publish__(g){return await this.yieldLoop(),this.instance.Events.trigger("message",g.toString())}async __disconnect__(g){return await this.yieldLoop(),clearInterval(this.heartbeat),this.Promise.resolve()}yieldLoop(g=0){return new this.Promise(function(u,b){return setTimeout(u,g)})}computePenalty(){var g;return(g=this.storeOptions.penalty)!=null?g:15*this.storeOptions.minTime||5e3}async __updateSettings__(g){return await this.yieldLoop(),C.overwrite(g,g,this.storeOptions),this._startHeartbeat(),this.instance._drainAll(this.computeCapacity()),!0}async __running__(){return await this.yieldLoop(),this._running}async __queued__(){return await this.yieldLoop(),this.instance.queued()}async __done__(){return await this.yieldLoop(),this._done}async __groupCheck__(g){return await this.yieldLoop(),this._nextRequest+this.timeout<g}computeCapacity(){var g,u;return{maxConcurrent:g,reservoir:u}=this.storeOptions,g!=null&&u!=null?Math.min(g-this._running,u):g!=null?g-this._running:u??null}conditionsCheck(g){var u;return u=this.computeCapacity(),u==null||g<=u}async __incrementReservoir__(g){var u;return await this.yieldLoop(),u=this.storeOptions.reservoir+=g,this.instance._drainAll(this.computeCapacity()),u}async __currentReservoir__(){return await this.yieldLoop(),this.storeOptions.reservoir}isBlocked(g){return this._unblockTime>=g}check(g,u){return this.conditionsCheck(g)&&this._nextRequest-u<=0}async __check__(g){var u;return await this.yieldLoop(),u=Date.now(),this.check(g,u)}async __register__(g,u,b){var E,T;return await this.yieldLoop(),E=Date.now(),this.conditionsCheck(u)?(this._running+=u,this.storeOptions.reservoir!=null&&(this.storeOptions.reservoir-=u),T=Math.max(this._nextRequest-E,0),this._nextRequest=E+T+this.storeOptions.minTime,{success:!0,wait:T,reservoir:this.storeOptions.reservoir}):{success:!1}}strategyIsBlock(){return this.storeOptions.strategy===3}async __submit__(g,u){var b,E,T;if(await this.yieldLoop(),this.storeOptions.maxConcurrent!=null&&u>this.storeOptions.maxConcurrent)throw new S(`Impossible to add a job having a weight of ${u} to a limiter having a maxConcurrent setting of ${this.storeOptions.maxConcurrent}`);return E=Date.now(),T=this.storeOptions.highWater!=null&&g===this.storeOptions.highWater&&!this.check(u,E),b=this.strategyIsBlock()&&(T||this.isBlocked(E)),b&&(this._unblockTime=E+this.computePenalty(),this._nextRequest=this._unblockTime+this.storeOptions.minTime,this.instance._dropAllQueued()),{reachedHWM:T,blocked:b,strategy:this.storeOptions.strategy}}async __free__(g,u){return await this.yieldLoop(),this._running-=u,this._done+=u,this.instance._drainAll(this.computeCapacity()),{running:this._running}}};var v=A,I,N;I=w,N=class{constructor(g){this.status=g,this._jobs={},this.counts=this.status.map(function(){return 0})}next(g){var u,b;if(u=this._jobs[g],b=u+1,u!=null&&b<this.status.length)return this.counts[u]--,this.counts[b]++,this._jobs[g]++;if(u!=null)return this.counts[u]--,delete this._jobs[g]}start(g){var u;return u=0,this._jobs[g]=u,this.counts[u]++}remove(g){var u;return u=this._jobs[g],u!=null&&(this.counts[u]--,delete this._jobs[g]),u!=null}jobStatus(g){var u;return(u=this.status[this._jobs[g]])!=null?u:null}statusJobs(g){var u,b,E,T,G;if(g!=null){if(b=this.status.indexOf(g),b<0)throw new I(`status must be one of ${this.status.join(", ")}`);E=this._jobs,T=[];for(u in E)G=E[u],G===b&&T.push(u);return T}else return Object.keys(this._jobs)}statusCounts(){return this.counts.reduce((g,u,b)=>(g[this.status[b]]=u,g),{})}};var Q=N,D,je;D=o,je=class{constructor(g,u){this.schedule=this.schedule.bind(this),this.name=g,this.Promise=u,this._running=0,this._queue=new D}isEmpty(){return this._queue.length===0}async _tryToRun(){var g,u,b,E,T,G,$;if(this._running<1&&this._queue.length>0)return this._running++,{task:$,args:g,resolve:T,reject:E}=this._queue.shift(),u=await async function(){try{return G=await $(...g),function(){return T(G)}}catch(F){return b=F,function(){return E(b)}}}(),this._running--,this._tryToRun(),u()}schedule(g,...u){var b,E,T;return T=E=null,b=new this.Promise(function(G,$){return T=G,E=$}),this._queue.push({task:g,args:u,resolve:T,reject:E}),this._tryToRun(),b}};var Be=je,Ue="2.19.5",Zn={version:Ue},de=Object.freeze({version:Ue,default:Zn}),wr=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),ra=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),sf=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),na,sa,ia,oa,aa,Er;Er=s,na=c,oa=wr,ia=ra,aa=sf,sa=function(){class x{constructor(u={}){this.deleteKey=this.deleteKey.bind(this),this.limiterOptions=u,Er.load(this.limiterOptions,this.defaults,this),this.Events=new na(this),this.instances={},this.Bottleneck=ba,this._startAutoCleanup(),this.sharedConnection=this.connection!=null,this.connection==null&&(this.limiterOptions.datastore==="redis"?this.connection=new oa(Object.assign({},this.limiterOptions,{Events:this.Events})):this.limiterOptions.datastore==="ioredis"&&(this.connection=new ia(Object.assign({},this.limiterOptions,{Events:this.Events}))))}key(u=""){var b;return(b=this.instances[u])!=null?b:(()=>{var E;return E=this.instances[u]=new this.Bottleneck(Object.assign(this.limiterOptions,{id:`${this.id}-${u}`,timeout:this.timeout,connection:this.connection})),this.Events.trigger("created",E,u),E})()}async deleteKey(u=""){var b,E;return E=this.instances[u],this.connection&&(b=await this.connection.__runCommand__(["del",...aa.allKeys(`${this.id}-${u}`)])),E!=null&&(delete this.instances[u],await E.disconnect()),E!=null||b>0}limiters(){var u,b,E,T;b=this.instances,E=[];for(u in b)T=b[u],E.push({key:u,limiter:T});return E}keys(){return Object.keys(this.instances)}async clusterKeys(){var u,b,E,T,G,$,F,K,z;if(this.connection==null)return this.Promise.resolve(this.keys());for($=[],u=null,z=`b_${this.id}-`.length,b=9;u!==0;)for([K,E]=await this.connection.__runCommand__(["scan",u??0,"match",`b_${this.id}-*_settings`,"count",1e4]),u=~~K,T=0,F=E.length;T<F;T++)G=E[T],$.push(G.slice(z,-b));return $}_startAutoCleanup(){var u;return clearInterval(this.interval),typeof(u=this.interval=setInterval(async()=>{var b,E,T,G,$,F;$=Date.now(),T=this.instances,G=[];for(E in T){F=T[E];try{await F._store.__groupCheck__($)?G.push(this.deleteKey(E)):G.push(void 0)}catch(K){b=K,G.push(F.Events.trigger("error",b))}}return G},this.timeout/2)).unref=="function"?u.unref():void 0}updateSettings(u={}){if(Er.overwrite(u,this.defaults,this),Er.overwrite(u,u,this.limiterOptions),u.timeout!=null)return this._startAutoCleanup()}disconnect(u=!0){var b;if(!this.sharedConnection)return(b=this.connection)!=null?b.disconnect(u):void 0}}return x.prototype.defaults={timeout:1e3*60*5,connection:null,Promise,id:"group-key"},x}.call(e);var of=sa,ca,la,ua;ua=s,la=c,ca=function(){class x{constructor(u={}){this.options=u,ua.load(this.options,this.defaults,this),this.Events=new la(this),this._arr=[],this._resetPromise(),this._lastFlush=Date.now()}_resetPromise(){return this._promise=new this.Promise((u,b)=>this._resolve=u)}_flush(){return clearTimeout(this._timeout),this._lastFlush=Date.now(),this._resolve(),this.Events.trigger("batch",this._arr),this._arr=[],this._resetPromise()}add(u){var b;return this._arr.push(u),b=this._promise,this._arr.length===this.maxSize?this._flush():this.maxTime!=null&&this._arr.length===1&&(this._timeout=setTimeout(()=>this._flush(),this.maxTime)),b}}return x.prototype.defaults={maxTime:null,maxSize:null,Promise},x}.call(e);var af=ca,cf=()=>console.log("You must import the full version of Bottleneck in order to use this feature."),lf=t(de),da,pa,es,ts,fa,rs,ha,ma,ga,ns,ye,ya=[].splice;rs=10,pa=5,ye=s,ha=f,ts=k,fa=v,ma=cf,es=c,ga=Q,ns=Be,da=function(){class x{constructor(u={},...b){var E,T;this._addToQueue=this._addToQueue.bind(this),this._validateOptions(u,b),ye.load(u,this.instanceDefaults,this),this._queues=new ha(rs),this._scheduled={},this._states=new ga(["RECEIVED","QUEUED","RUNNING","EXECUTING"].concat(this.trackDoneStatus?["DONE"]:[])),this._limiter=null,this.Events=new es(this),this._submitLock=new ns("submit",this.Promise),this._registerLock=new ns("register",this.Promise),T=ye.load(u,this.storeDefaults,{}),this._store=function(){if(this.datastore==="redis"||this.datastore==="ioredis"||this.connection!=null)return E=ye.load(u,this.redisStoreDefaults,{}),new ma(this,T,E);if(this.datastore==="local")return E=ye.load(u,this.localStoreDefaults,{}),new fa(this,T,E);throw new x.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`)}.call(this),this._queues.on("leftzero",()=>{var G;return(G=this._store.heartbeat)!=null&&typeof G.ref=="function"?G.ref():void 0}),this._queues.on("zero",()=>{var G;return(G=this._store.heartbeat)!=null&&typeof G.unref=="function"?G.unref():void 0})}_validateOptions(u,b){if(!(u!=null&&typeof u=="object"&&b.length===0))throw new x.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.")}ready(){return this._store.ready}clients(){return this._store.clients}channel(){return`b_${this.id}`}channel_client(){return`b_${this.id}_${this._store.clientId}`}publish(u){return this._store.__publish__(u)}disconnect(u=!0){return this._store.__disconnect__(u)}chain(u){return this._limiter=u,this}queued(u){return this._queues.queued(u)}clusterQueued(){return this._store.__queued__()}empty(){return this.queued()===0&&this._submitLock.isEmpty()}running(){return this._store.__running__()}done(){return this._store.__done__()}jobStatus(u){return this._states.jobStatus(u)}jobs(u){return this._states.statusJobs(u)}counts(){return this._states.statusCounts()}_randomIndex(){return Math.random().toString(36).slice(2)}check(u=1){return this._store.__check__(u)}_clearGlobalState(u){return this._scheduled[u]!=null?(clearTimeout(this._scheduled[u].expiration),delete this._scheduled[u],!0):!1}async _free(u,b,E,T){var G,$;try{if({running:$}=await this._store.__free__(u,E.weight),this.Events.trigger("debug",`Freed ${E.id}`,T),$===0&&this.empty())return this.Events.trigger("idle")}catch(F){return G=F,this.Events.trigger("error",G)}}_run(u,b,E){var T,G,$;return b.doRun(),T=this._clearGlobalState.bind(this,u),$=this._run.bind(this,u,b),G=this._free.bind(this,u,b),this._scheduled[u]={timeout:setTimeout(()=>b.doExecute(this._limiter,T,$,G),E),expiration:b.options.expiration!=null?setTimeout(function(){return b.doExpire(T,$,G)},E+b.options.expiration):void 0,job:b}}_drainOne(u){return this._registerLock.schedule(()=>{var b,E,T,G,$;return this.queued()===0?this.Promise.resolve(null):($=this._queues.getFirst(),{options:G,args:b}=T=$.first(),u!=null&&G.weight>u?this.Promise.resolve(null):(this.Events.trigger("debug",`Draining ${G.id}`,{args:b,options:G}),E=this._randomIndex(),this._store.__register__(E,G.weight,G.expiration).then(({success:F,wait:K,reservoir:z})=>{var Rt;return this.Events.trigger("debug",`Drained ${G.id}`,{success:F,args:b,options:G}),F?($.shift(),Rt=this.empty(),Rt&&this.Events.trigger("empty"),z===0&&this.Events.trigger("depleted",Rt),this._run(E,T,K),this.Promise.resolve(G.weight)):this.Promise.resolve(null)})))})}_drainAll(u,b=0){return this._drainOne(u).then(E=>{var T;return E!=null?(T=u!=null?u-E:u,this._drainAll(T,b+E)):this.Promise.resolve(b)}).catch(E=>this.Events.trigger("error",E))}_dropAllQueued(u){return this._queues.shiftAll(function(b){return b.doDrop({message:u})})}stop(u={}){var b,E;return u=ye.load(u,this.stopDefaults),E=T=>{var G;return G=()=>{var $;return $=this._states.counts,$[0]+$[1]+$[2]+$[3]===T},new this.Promise(($,F)=>G()?$():this.on("done",()=>{if(G())return this.removeAllListeners("done"),$()}))},b=u.dropWaitingJobs?(this._run=function(T,G){return G.doDrop({message:u.dropErrorMessage})},this._drainOne=()=>this.Promise.resolve(null),this._registerLock.schedule(()=>this._submitLock.schedule(()=>{var T,G,$;G=this._scheduled;for(T in G)$=G[T],this.jobStatus($.job.options.id)==="RUNNING"&&(clearTimeout($.timeout),clearTimeout($.expiration),$.job.doDrop({message:u.dropErrorMessage}));return this._dropAllQueued(u.dropErrorMessage),E(0)}))):this.schedule({priority:rs-1,weight:0},()=>E(1)),this._receive=function(T){return T._reject(new x.prototype.BottleneckError(u.enqueueErrorMessage))},this.stop=()=>this.Promise.reject(new x.prototype.BottleneckError("stop() has already been called")),b}async _addToQueue(u){var b,E,T,G,$,F,K;({args:b,options:G}=u);try{({reachedHWM:$,blocked:E,strategy:K}=await this._store.__submit__(this.queued(),G.weight))}catch(z){return T=z,this.Events.trigger("debug",`Could not queue ${G.id}`,{args:b,options:G,error:T}),u.doDrop({error:T}),!1}return E?(u.doDrop(),!0):$&&(F=K===x.prototype.strategy.LEAK?this._queues.shiftLastFrom(G.priority):K===x.prototype.strategy.OVERFLOW_PRIORITY?this._queues.shiftLastFrom(G.priority+1):K===x.prototype.strategy.OVERFLOW?u:void 0,F?.doDrop(),F==null||K===x.prototype.strategy.OVERFLOW)?(F==null&&u.doDrop(),$):(u.doQueue($,E),this._queues.push(u),await this._drainAll(),$)}_receive(u){return this._states.jobStatus(u.options.id)!=null?(u._reject(new x.prototype.BottleneckError(`A job with the same id already exists (id=${u.options.id})`)),!1):(u.doReceive(),this._submitLock.schedule(this._addToQueue,u))}submit(...u){var b,E,T,G,$,F,K;return typeof u[0]=="function"?($=u,[E,...u]=$,[b]=ya.call(u,-1),G=ye.load({},this.jobDefaults)):(F=u,[G,E,...u]=F,[b]=ya.call(u,-1),G=ye.load(G,this.jobDefaults)),K=(...z)=>new this.Promise(function(Rt,df){return E(...z,function(...wa){return(wa[0]!=null?df:Rt)(wa)})}),T=new ts(K,u,G,this.jobDefaults,this.rejectOnDrop,this.Events,this._states,this.Promise),T.promise.then(function(z){return typeof b=="function"?b(...z):void 0}).catch(function(z){return Array.isArray(z)?typeof b=="function"?b(...z):void 0:typeof b=="function"?b(z):void 0}),this._receive(T)}schedule(...u){var b,E,T;return typeof u[0]=="function"?([T,...u]=u,E={}):[E,T,...u]=u,b=new ts(T,u,E,this.jobDefaults,this.rejectOnDrop,this.Events,this._states,this.Promise),this._receive(b),b.promise}wrap(u){var b,E;return b=this.schedule.bind(this),E=function(...T){return b(u.bind(this),...T)},E.withOptions=function(T,...G){return b(T,u,...G)},E}async updateSettings(u={}){return await this._store.__updateSettings__(ye.overwrite(u,this.storeDefaults)),ye.overwrite(u,this.instanceDefaults,this),this}currentReservoir(){return this._store.__currentReservoir__()}incrementReservoir(u=0){return this._store.__incrementReservoir__(u)}}return x.default=x,x.Events=es,x.version=x.prototype.version=lf.version,x.strategy=x.prototype.strategy={LEAK:1,OVERFLOW:2,OVERFLOW_PRIORITY:4,BLOCK:3},x.BottleneckError=x.prototype.BottleneckError=w,x.Group=x.prototype.Group=of,x.RedisConnection=x.prototype.RedisConnection=wr,x.IORedisConnection=x.prototype.IORedisConnection=ra,x.Batcher=x.prototype.Batcher=af,x.prototype.jobDefaults={priority:pa,weight:1,expiration:null,id:"<no-id>"},x.prototype.storeDefaults={maxConcurrent:null,minTime:0,highWater:null,strategy:x.prototype.strategy.LEAK,penalty:null,reservoir:null,reservoirRefreshInterval:null,reservoirRefreshAmount:null,reservoirIncreaseInterval:null,reservoirIncreaseAmount:null,reservoirIncreaseMaximum:null},x.prototype.localStoreDefaults={Promise,timeout:null,heartbeatInterval:250},x.prototype.redisStoreDefaults={Promise,timeout:null,heartbeatInterval:5e3,clientTimeout:1e4,Redis:null,clientOptions:{},clusterNodes:null,clearDatastore:!1,connection:null},x.prototype.instanceDefaults={datastore:"local",connection:null,id:"<no-id>",rejectOnDrop:!0,trackDoneStatus:!1,Promise},x.prototype.stopDefaults={enqueueErrorMessage:"This limiter has been stopped and cannot accept new jobs.",dropWaitingJobs:!0,dropErrorMessage:"This limiter has been stopped."},x}.call(e);var ba=da,uf=ba;return uf})});var L=P(W=>{"use strict";var ri=Symbol.for("yaml.alias"),Al=Symbol.for("yaml.document"),zr=Symbol.for("yaml.map"),Gl=Symbol.for("yaml.pair"),ni=Symbol.for("yaml.scalar"),Jr=Symbol.for("yaml.seq"),_e=Symbol.for("yaml.node.type"),Sg=e=>!!e&&typeof e=="object"&&e[_e]===ri,Rg=e=>!!e&&typeof e=="object"&&e[_e]===Al,Ag=e=>!!e&&typeof e=="object"&&e[_e]===zr,Gg=e=>!!e&&typeof e=="object"&&e[_e]===Gl,Ol=e=>!!e&&typeof e=="object"&&e[_e]===ni,Og=e=>!!e&&typeof e=="object"&&e[_e]===Jr;function Pl(e){if(e&&typeof e=="object")switch(e[_e]){case zr:case Jr:return!0}return!1}function Pg(e){if(e&&typeof e=="object")switch(e[_e]){case ri:case zr:case ni:case Jr:return!0}return!1}var Cg=e=>(Ol(e)||Pl(e))&&!!e.anchor;W.ALIAS=ri;W.DOC=Al;W.MAP=zr;W.NODE_TYPE=_e;W.PAIR=Gl;W.SCALAR=ni;W.SEQ=Jr;W.hasAnchor=Cg;W.isAlias=Sg;W.isCollection=Pl;W.isDocument=Rg;W.isMap=Ag;W.isNode=Pg;W.isPair=Gg;W.isScalar=Ol;W.isSeq=Og});var Nt=P(si=>{"use strict";var V=L(),re=Symbol("break visit"),Cl=Symbol("skip children"),Ee=Symbol("remove node");function Yr(e,t){let r=$l(t);V.isDocument(e)?ht(null,e.contents,r,Object.freeze([e]))===Ee&&(e.contents=null):ht(null,e,r,Object.freeze([]))}Yr.BREAK=re;Yr.SKIP=Cl;Yr.REMOVE=Ee;function ht(e,t,r,n){let s=xl(e,t,r,n);if(V.isNode(s)||V.isPair(s))return Il(e,n,s),ht(e,s,r,n);if(typeof s!="symbol"){if(V.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=ht(i,t.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===re)return re;o===Ee&&(t.items.splice(i,1),i-=1)}}}else if(V.isPair(t)){n=Object.freeze(n.concat(t));let i=ht("key",t.key,r,n);if(i===re)return re;i===Ee&&(t.key=null);let o=ht("value",t.value,r,n);if(o===re)return re;o===Ee&&(t.value=null)}}return s}async function Qr(e,t){let r=$l(t);V.isDocument(e)?await mt(null,e.contents,r,Object.freeze([e]))===Ee&&(e.contents=null):await mt(null,e,r,Object.freeze([]))}Qr.BREAK=re;Qr.SKIP=Cl;Qr.REMOVE=Ee;async function mt(e,t,r,n){let s=await xl(e,t,r,n);if(V.isNode(s)||V.isPair(s))return Il(e,n,s),mt(e,s,r,n);if(typeof s!="symbol"){if(V.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=await mt(i,t.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===re)return re;o===Ee&&(t.items.splice(i,1),i-=1)}}}else if(V.isPair(t)){n=Object.freeze(n.concat(t));let i=await mt("key",t.key,r,n);if(i===re)return re;i===Ee&&(t.key=null);let o=await mt("value",t.value,r,n);if(o===re)return re;o===Ee&&(t.value=null)}}return s}function $l(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function xl(e,t,r,n){if(typeof r=="function")return r(e,t,n);if(V.isMap(t))return r.Map?.(e,t,n);if(V.isSeq(t))return r.Seq?.(e,t,n);if(V.isPair(t))return r.Pair?.(e,t,n);if(V.isScalar(t))return r.Scalar?.(e,t,n);if(V.isAlias(t))return r.Alias?.(e,t,n)}function Il(e,t,r){let n=t[t.length-1];if(V.isCollection(n))n.items[e]=r;else if(V.isPair(n))e==="key"?n.key=r:n.value=r;else if(V.isDocument(n))n.contents=r;else{let s=V.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}si.visit=Yr;si.visitAsync=Qr});var ii=P(Ll=>{"use strict";var Nl=L(),$g=Nt(),xg={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ig=e=>e.replace(/[!,[\]{}]/g,t=>xg[t]),Lt=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let n=t.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[i,o]=n;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return r(6,`Unsupported YAML version ${i}`,o),!1}}default:return r(0,`Unknown directive ${s}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,n,s]=t.match(/^(.*!)([^!]*)$/s);s||r(`The ${t} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(s)}catch(o){return r(String(o)),null}return n==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,n]of Object.entries(this.tags))if(t.startsWith(n))return r+Ig(t.substring(n.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),s;if(t&&n.length>0&&Nl.isNode(t.contents)){let i={};$g.visit(t.contents,(o,a)=>{Nl.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of n)i==="!!"&&o==="tag:yaml.org,2002:"||(!t||s.some(a=>a.startsWith(o)))&&r.push(`%TAG ${i} ${o}`);return r.join(`
|
|
4
|
+
`)}};Lt.defaultYaml={explicit:!1,version:"1.2"};Lt.defaultTags={"!!":"tag:yaml.org,2002:"};Ll.Directives=Lt});var Xr=P(qt=>{"use strict";var ql=L(),Ng=Nt();function Lg(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function Dl(e){let t=new Set;return Ng.visit(e,{Value(r,n){n.anchor&&t.add(n.anchor)}}),t}function Fl(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function qg(e,t){let r=[],n=new Map,s=null;return{onAnchor:i=>{r.push(i),s??(s=Dl(e));let o=Fl(t,s);return s.add(o),o},setAnchors:()=>{for(let i of r){let o=n.get(i);if(typeof o=="object"&&o.anchor&&(ql.isScalar(o.node)||ql.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}qt.anchorIsValid=Lg;qt.anchorNames=Dl;qt.createNodeAnchors=qg;qt.findNewAnchor=Fl});var oi=P(jl=>{"use strict";function Dt(e,t,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0,i=n.length;s<i;++s){let o=n[s],a=Dt(e,n,String(s),o);a===void 0?delete n[s]:a!==o&&(n[s]=a)}else if(n instanceof Map)for(let s of Array.from(n.keys())){let i=n.get(s),o=Dt(e,n,s,i);o===void 0?n.delete(s):o!==i&&n.set(s,o)}else if(n instanceof Set)for(let s of Array.from(n)){let i=Dt(e,n,s,s);i===void 0?n.delete(s):i!==s&&(n.delete(s),n.add(i))}else for(let[s,i]of Object.entries(n)){let o=Dt(e,n,s,i);o===void 0?delete n[s]:o!==i&&(n[s]=o)}return e.call(t,r,n)}jl.applyReviver=Dt});var Oe=P(Ul=>{"use strict";var Dg=L();function Bl(e,t,r){if(Array.isArray(e))return e.map((n,s)=>Bl(n,String(s),r));if(e&&typeof e.toJSON=="function"){if(!r||!Dg.hasAnchor(e))return e.toJSON(t,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(e,n),r.onCreate=i=>{n.res=i,delete r.onCreate};let s=e.toJSON(t,r);return r.onCreate&&r.onCreate(s),s}return typeof e=="bigint"&&!r?.keep?Number(e):e}Ul.toJS=Bl});var Zr=P(Vl=>{"use strict";var Fg=oi(),Ml=L(),jg=Oe(),ai=class{constructor(t){Object.defineProperty(this,Ml.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:n,onAnchor:s,reviver:i}={}){if(!Ml.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=jg.toJS(this,"",o);if(typeof s=="function")for(let{count:c,res:l}of o.anchors.values())s(l,c);return typeof i=="function"?Fg.applyReviver(i,{"":a},"",a):a}};Vl.NodeBase=ai});var Ft=P(Hl=>{"use strict";var Bg=Xr(),Ug=Nt(),gt=L(),Mg=Zr(),Vg=Oe(),ci=class extends Mg.NodeBase{constructor(t){super(gt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],Ug.visit(t,{Node:(i,o)=>{(gt.isAlias(o)||gt.hasAnchor(o))&&n.push(o)}}),r&&(r.aliasResolveCache=n));let s;for(let i of n){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(t,r){if(!r)return{source:this.source};let{anchors:n,doc:s,maxAliasCount:i}=r,o=this.resolve(s,r);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=n.get(o);if(a||(Vg.toJS(o,null,r),a=n.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=en(s,o,n)),a.count*a.aliasCount>i)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(t,r,n){let s=`*${this.source}`;if(t){if(Bg.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(t.implicitKey)return`${s} `}return s}};function en(e,t,r){if(gt.isAlias(t)){let n=t.resolve(e),s=r&&n&&r.get(n);return s?s.count*s.aliasCount:0}else if(gt.isCollection(t)){let n=0;for(let s of t.items){let i=en(e,s,r);i>n&&(n=i)}return n}else if(gt.isPair(t)){let n=en(e,t.key,r),s=en(e,t.value,r);return Math.max(n,s)}return 1}Hl.Alias=ci});var U=P(li=>{"use strict";var Hg=L(),Kg=Zr(),Wg=Oe(),zg=e=>!e||typeof e!="function"&&typeof e!="object",Pe=class extends Kg.NodeBase{constructor(t){super(Hg.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:Wg.toJS(this.value,t,r)}toString(){return String(this.value)}};Pe.BLOCK_FOLDED="BLOCK_FOLDED";Pe.BLOCK_LITERAL="BLOCK_LITERAL";Pe.PLAIN="PLAIN";Pe.QUOTE_DOUBLE="QUOTE_DOUBLE";Pe.QUOTE_SINGLE="QUOTE_SINGLE";li.Scalar=Pe;li.isScalarValue=zg});var jt=P(Wl=>{"use strict";var Jg=Ft(),Je=L(),Kl=U(),Yg="tag:yaml.org,2002:";function Qg(e,t,r){if(t){let n=r.filter(i=>i.tag===t),s=n.find(i=>!i.format)??n[0];if(!s)throw new Error(`Tag ${t} not found`);return s}return r.find(n=>n.identify?.(e)&&!n.format)}function Xg(e,t,r){if(Je.isDocument(e)&&(e=e.contents),Je.isNode(e))return e;if(Je.isPair(e)){let p=r.schema[Je.MAP].createNode?.(r.schema,null,r);return p.items.push(e),p}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=r,c;if(n&&e&&typeof e=="object"){if(c=a.get(e),c)return c.anchor??(c.anchor=s(e)),new Jg.Alias(c.anchor);c={anchor:null,node:null},a.set(e,c)}t?.startsWith("!!")&&(t=Yg+t.slice(2));let l=Qg(e,t,o.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let p=new Kl.Scalar(e);return c&&(c.node=p),p}l=e instanceof Map?o[Je.MAP]:Symbol.iterator in Object(e)?o[Je.SEQ]:o[Je.MAP]}i&&(i(l),delete r.onTagObj);let d=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,e,r):new Kl.Scalar(e);return t?d.tag=t:l.default||(d.tag=l.tag),c&&(c.node=d),d}Wl.createNode=Xg});var rn=P(tn=>{"use strict";var Zg=jt(),Te=L(),ey=Zr();function ui(e,t,r){let n=r;for(let s=t.length-1;s>=0;--s){let i=t[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=n,n=o}else n=new Map([[i,n]])}return Zg.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var zl=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,di=class extends ey.NodeBase{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(n=>Te.isNode(n)||Te.isPair(n)?n.clone(t):n),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(zl(t))this.add(r);else{let[n,...s]=t,i=this.get(n,!0);if(Te.isCollection(i))i.addIn(s,r);else if(i===void 0&&this.schema)this.set(n,ui(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}deleteIn(t){let[r,...n]=t;if(n.length===0)return this.delete(r);let s=this.get(r,!0);if(Te.isCollection(s))return s.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(t,r){let[n,...s]=t,i=this.get(n,!0);return s.length===0?!r&&Te.isScalar(i)?i.value:i:Te.isCollection(i)?i.getIn(s,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!Te.isPair(r))return!1;let n=r.value;return n==null||t&&Te.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(t){let[r,...n]=t;if(n.length===0)return this.has(r);let s=this.get(r,!0);return Te.isCollection(s)?s.hasIn(n):!1}setIn(t,r){let[n,...s]=t;if(s.length===0)this.set(n,r);else{let i=this.get(n,!0);if(Te.isCollection(i))i.setIn(s,r);else if(i===void 0&&this.schema)this.set(n,ui(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}};tn.Collection=di;tn.collectionFromPath=ui;tn.isEmptyPath=zl});var Bt=P(nn=>{"use strict";var ty=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function pi(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var ry=(e,t,r)=>e.endsWith(`
|
|
5
5
|
`)?pi(r,t):r.includes(`
|
|
6
6
|
`)?`
|
|
7
7
|
`+pi(r,t):(e.endsWith(" ")?"":" ")+r;nn.indentComment=pi;nn.lineComment=ry;nn.stringifyComment=ty});var Yl=P(Ut=>{"use strict";var ny="flow",fi="block",sn="quoted";function sy(e,t,r="flow",{indentAtStart:n,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return e;s<i&&(i=0);let c=Math.max(1+i,1+s-t.length);if(e.length<=c)return e;let l=[],d={},p=s-t.length;typeof n=="number"&&(n>s-Math.max(2,i)?l.push(0):p=s-n);let f,h,w=!1,m=-1,y=-1,R=-1;r===fi&&(m=Jl(e,m,t.length),m!==-1&&(p=m+c));for(let _;_=e[m+=1];){if(r===sn&&_==="\\"){switch(y=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}R=m}if(_===`
|
|
@@ -138,15 +138,15 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
|
|
|
138
138
|
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
|
139
139
|
`,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,t.indent)){let s=t.items[t.items.length-2]?.value?.end;if(Array.isArray(s)){Hn(s,r.start),s.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let n=!this.onKeyLine&&this.indent===t.indent,s=n&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&r.sep&&!r.value){let o=[];for(let a=0;a<r.sep.length;++a){let c=r.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||r.value?(i.push(this.sourceToken),t.items.push({start:i}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):s||r.value?(i.push(this.sourceToken),t.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(qe(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(ap(r.key)&&!qe(r.sep,"newline")){let o=vt(r.start),a=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:c}]})}else i.length>0?r.sep=r.sep.concat(i,this.sourceToken):r.sep.push(this.sourceToken);else if(qe(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=vt(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||s?t.items.push({start:i,key:null,sep:[this.sourceToken]}):qe(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||r.value?(t.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!qe(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&t.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let r=t.items[t.items.length-1];switch(this.type){case"newline":if(r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,t.indent)){let s=t.items[t.items.length-2]?.value?.end;if(Array.isArray(s)){Hn(s,r.start),s.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;r.value||qe(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let n=this.startBlockValue(t);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let r=t.items[t.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?t.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!r||r.value?t.items.push({start:[],key:s,sep:[]}):r.sep?this.stack.push(s):Object.assign(r,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let n=this.startBlockValue(t);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===t.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let s=Vn(n),i=vt(s);op(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let r=this.source.indexOf(`
|
|
140
140
|
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
|
141
|
-
`,r)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Vn(t),n=vt(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=Vn(t),n=vt(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};cp.Parser=Io});var fp=P(ur=>{"use strict";var lp=To(),xE=tr(),lr=sr(),IE=bi(),NE=L(),LE=xo(),up=No();function dp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new LE.LineCounter||null,prettyErrors:t}}function qE(e,t={}){let{lineCounter:r,prettyErrors:n}=dp(t),s=new up.Parser(r?.addNewLine),i=new lp.Composer(t),o=Array.from(i.compose(s.parse(e)));if(n&&r)for(let a of o)a.errors.forEach(lr.prettifyError(e,r)),a.warnings.forEach(lr.prettifyError(e,r));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function pp(e,t={}){let{lineCounter:r,prettyErrors:n}=dp(t),s=new up.Parser(r?.addNewLine),i=new lp.Composer(t),o=null;for(let a of i.compose(s.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new lr.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(o.errors.forEach(lr.prettifyError(e,r)),o.warnings.forEach(lr.prettifyError(e,r))),o}function DE(e,t,r){let n;typeof t=="function"?n=t:r===void 0&&t&&typeof t=="object"&&(r=t);let s=pp(e,r);if(!s)return null;if(s.warnings.forEach(i=>IE.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:n},r))}function FE(e,t,r){let n=null;if(typeof t=="function"||Array.isArray(t)?n=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let s=Math.round(r);r=s<1?void 0:s>8?{indent:8}:{indent:s}}if(e===void 0){let{keepUndefined:s}=r??t??{};if(!s)return}return NE.isDocument(e)&&!n?e.toString(r):new xE.Document(e,n,r).toString(r)}ur.parse=DE;ur.parseAllDocuments=qE;ur.parseDocument=pp;ur.stringify=FE});var qo=P(q=>{"use strict";var jE=To(),BE=tr(),UE=eo(),Lo=sr(),ME=Ft(),De=L(),VE=xe(),HE=U(),KE=Ne(),WE=Le(),zE=Un(),JE=Co(),YE=xo(),QE=No(),Kn=fp(),hp=Nt();q.Composer=jE.Composer;q.Document=BE.Document;q.Schema=UE.Schema;q.YAMLError=Lo.YAMLError;q.YAMLParseError=Lo.YAMLParseError;q.YAMLWarning=Lo.YAMLWarning;q.Alias=ME.Alias;q.isAlias=De.isAlias;q.isCollection=De.isCollection;q.isDocument=De.isDocument;q.isMap=De.isMap;q.isNode=De.isNode;q.isPair=De.isPair;q.isScalar=De.isScalar;q.isSeq=De.isSeq;q.Pair=VE.Pair;q.Scalar=HE.Scalar;q.YAMLMap=KE.YAMLMap;q.YAMLSeq=WE.YAMLSeq;q.CST=zE;q.Lexer=JE.Lexer;q.LineCounter=YE.LineCounter;q.Parser=QE.Parser;q.parse=Kn.parse;q.parseAllDocuments=Kn.parseAllDocuments;q.parseDocument=Kn.parseDocument;q.stringify=Kn.stringify;q.visit=hp.visit;q.visitAsync=hp.visitAsync});import{readFileSync as ef}from"node:fs";import{join as tf,resolve as ta}from"node:path";function Ta(e){let t={app:e,version:bf(it("__RED_BUILD_VERSION__",()=>"4.1.16")??"0.0.0-dev"),gitSha:it("__RED_BUILD_GIT_SHA__",()=>"a2ca233fe19ae7e0e0a16b5148298c054a2e2b9a")??"unknown",buildTime:it("__RED_BUILD_TIME__",()=>"2026-08-21T03:14:27-03:00")??"unknown",bundleAsset:it("__RED_BUNDLE_ASSET__",()=>"release.bundle.min.mjs")??"unknown"},r=it("__REDDB_SDK_VERSION__",()=>""),n=it("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function bf(e){return e.startsWith("v")?e.slice(1):e}function _a(e){return`${e.app} ${e.version} ${e.gitSha}`}function it(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}function ka(e){return e==="single-object"?"rest":"graphql"}function va(e,t){return e==="stable-poll"?"rest":ka(t)}function Z(e){return{none:e}}function M(e,t,r,n,s,i,o){let a=typeof s=="string"?{fallback:s}:{fallback:null,noFallbackBecause:s.none};return{key:e,kind:"read",cardinality:t,volatility:r,surface:o??va(r,t),budget:n,...a,...o?{only:o}:{},why:i}}function ee(e,t,r,n,s){let i=typeof s=="string"?{fallback:s}:{fallback:null,noFallbackBecause:s.none};return{key:e,kind:"write",cardinality:"single-object",surface:t,budget:r,...i,why:n}}var Sa=[M("issue view","single-object","stable-poll","rest","graphql","one issue by number, repeatedly polled while usually unchanged; REST answers in one request"),M("pr view","single-object","stable-poll","rest","graphql","one pull request by number, polled per Worker per iteration"),M("repo view","single-object","stable-poll","rest","graphql","one repository's own metadata, repeatedly read while usually unchanged"),M("run view","single-object","stable-poll","rest",Z("Actions runs have no GraphQL resource"),"one Actions run repeatedly polled to terminal"),M("release view","single-object","stable-poll","rest",Z("release lookup has no GraphQL client method"),"one release by tag, repeatedly checked while usually absent or unchanged"),M("pr diff","single-object","one-shot","rest",Z("the complete diff is exposed as a REST media type"),"one pull request's diff, read once for review"),M("issue list","multi-node","stable-poll","rest","graphql","a repeatedly polled, usually-unchanged issue collection; REST can make an unchanged poll free"),M("pr list","multi-node","stable-poll","rest","graphql","a repeatedly polled, usually-unchanged pull-request collection; REST can make an unchanged poll free"),M("pr checks","multi-node","stable-poll","rest","graphql","check contexts are repeatedly polled while awaiting terminal state"),M("release list","multi-node","stable-poll","rest",Z("Releases has no GraphQL collection client method"),"release waits poll a usually-unchanged list"),M("run list","multi-node","stable-poll","rest",Z("Actions has no GraphQL collection client method"),"run waits poll a usually-unchanged list"),M("label list","multi-node","one-shot","graphql","rest","a label connection loaded once for the current operation"),M("issue list (search)","multi-node","stable-poll","search",Z("search is ineligible for diverted traffic"),"queue discovery polls usually-unchanged search results through the 30/min search connection"),M("pr list (search)","multi-node","stable-poll","search",Z("search is ineligible for diverted traffic"),"PR discovery polls usually-unchanged search results through the 30/min search connection"),M("search issues","multi-repository","one-shot","search",Z("search is ineligible for diverted traffic"),"a one-shot cross-repository read through the REST search endpoint, metered 30/min","rest"),M("search prs","multi-repository","one-shot","search",Z("search is ineligible for diverted traffic"),"a one-shot cross-repository read through the REST search endpoint, metered 30/min","rest"),M("search repos","multi-repository","one-shot","search",Z("search is ineligible for diverted traffic"),"a one-shot cross-repository read through the REST search endpoint, metered 30/min","rest"),M("api graphql","multi-node","one-shot","graphql",Z("the caller explicitly chose GraphQL"),"the caller supplies one explicit GraphQL query rather than a routed poll"),M("api rest","single-object","one-shot","rest",Z("the caller explicitly chose REST"),"the caller supplies one explicit REST path rather than a routed poll"),ee("issue create","rest","rest","the write plan POSTs to `repos/{o}/{r}/issues`; GraphQL exposes createIssue","graphql"),ee("issue edit","rest","rest","the write plan PATCHes labels and body; GraphQL exposes updateIssue","graphql"),ee("issue close","rest","rest","the write plan PATCHes issue state; GraphQL exposes closeIssue","graphql"),ee("issue reopen","graphql","graphql","gh uses reopenIssue; REST can PATCH the issue state to open","rest"),ee("issue comment","rest","rest","the write plan POSTs an issue comment; GraphQL exposes addComment","graphql"),ee("issue develop","graphql","graphql","linked-branch creation is a GraphQL mutation",Z("linked-branch creation has no REST mutation")),ee("pr create","rest","rest","the write plan POSTs a pull request; GraphQL exposes createPullRequest","graphql"),ee("pr comment","rest","rest","a pull request comment is an issue comment; GraphQL exposes addComment","graphql"),ee("pr merge","rest","rest","the default plan PUTs the merge; GraphQL exposes mergePullRequest","graphql"),ee("pr close","graphql","graphql","gh uses closePullRequest; REST can PATCH the pull request state","rest"),ee("pr edit","graphql","graphql","gh uses GraphQL mutations; REST can PATCH pull-request fields and issue labels","rest"),ee("pr ready","graphql","graphql","marking ready-for-review is a GraphQL mutation",Z("GitHub exposes no REST ready-for-review mutation")),ee("pr update-branch","rest","rest","the write plan PUTs update-branch; GraphQL exposes updatePullRequestBranch","graphql"),ee("label create","rest","rest","the write plan POSTs a label; GraphQL exposes createLabel","graphql")],q_=new Map(Sa.map(e=>[e.key,e]));var ss="RED_GITHUB_REQUEST_TIMEOUT_MS",ot=class extends Error{subject;timeoutMs;constructor(t,r,n){super(`GitHub ${t} passed its ${r}ms deadline and was abandoned; raise ${ss} if this host is genuinely this slow`,n),this.name="GithubTimeoutError",this.subject=t,this.timeoutMs=r}};function Ra(e){return e instanceof ot}function _r(e=process.env){let t=e[ss];if(t===void 0||t.trim()==="")return 3e4;let r=Number(t);return!Number.isFinite(r)||r<0?3e4:Math.trunc(r)}async function kr(e,t,r){if(!Number.isFinite(t)||t<=0)return await r();let n,s=new Promise((o,a)=>{n=setTimeout(()=>a(new ot(e,t)),t),n.unref?.()}),i=Promise.resolve().then(r);i.catch(()=>{});try{return await Promise.race([i,s])}finally{n!==void 0&&clearTimeout(n)}}function is(e={}){let t=e.fetchImpl??fetch,r=e.timeoutMs??_r();return!Number.isFinite(r)||r<=0?t:async(n,s)=>{let i=AbortSignal.timeout(r),o=s?.signal??null,a=o==null?i:AbortSignal.any([o,i]),c=wf(n);try{return await kr(c,r,async()=>await t(n,{...s??{},signal:a}))}catch(l){throw Ra(l)?l:i.aborted&&o?.aborted!==!0?new ot(c,r,{cause:l}):l}}}function wf(e){let t=typeof e=="string"?e:e instanceof URL?e.href:typeof e.url=="string"?e.url:"request";try{return new URL(t).pathname}catch{return t}}var vr="off";var Aa="RED_GITHUB_BUDGET_GATE";function Ga(e){if(e===!0)return"on";if(typeof e!="string")return vr;let t=e.trim().toLowerCase();return t==="on"||t==="enabled"||t==="true"?"on":vr}function os(e){return(e??vr)==="on"}function as(e=process.env){return Ga(e[Aa])}import{execFile as Yf}from"node:child_process";import{promisify as Qf}from"node:util";var at=class extends SyntaxError{line;source;reason;constructor(t,r,n={}){super(t===0?r:`line ${t}: ${r}`,n.cause===void 0?void 0:{cause:n.cause}),this.name="ToonError",this.line=t,this.source=n.source,this.reason=r}};function ve(e,t,r={}){return new at(e,t,r)}var Ef=/(?:^\uFEFF?|\n) *#/,cs=class{value;constructor(t){if(Ef.test(t))throw new TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(t)}`);this.value=t}};function Me(e){return e instanceof cs}function Tf(e){return/^[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(e)}function _f(e){if(Object.is(e,-0))return"0";if(!Number.isFinite(e))throw ve(0,"number is not representable in TOON");return String(e)}function Sr(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"}function te(e,t){if(Me(e))return e.value;if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return _f(e);if(typeof e=="string")return vf(e,t);throw ve(0,"not a primitive")}function kf(e){return/^[A-Za-z_][A-Za-z0-9_.]*$/.test(e)}function X(e){return kf(e)?e:Rr(e)}function vf(e,t){return ls(e,t)?Rr(e):e}function ls(e,t){return e===""||/^[ \t]|[ \t]$/.test(e)||e==="true"||e==="false"||e==="null"||Tf(e)||/[:"\\[\]{}]/.test(e)||/[\u0000-\u001f]/.test(e)||e.includes(t)||e.startsWith("-")||e.startsWith("#")}var Oa=/["\\\u0000-\u001f]/g;function Rr(e){return`"${Pa(e)}"`}function Pa(e){let t="",r=0;Oa.lastIndex=0;let n;for(;(n=Oa.exec(e))!==null;){let s=e.charCodeAt(n.index),i;s===34?i='\\"':s===92?i="\\\\":s===10?i="\\n":s===13?i="\\r":s===9?i="\\t":i=`\\u${s.toString(16).padStart(4,"0")}`,t+=e.slice(r,n.index)+i,r=n.index+1}return`${t}${e.slice(r)}`}var Ca={comma:",",tab:" ",pipe:"|"},Sf=Ca.comma;var Ar=1e3,$a=["type","kind","event"],Ve="|";var tk=Symbol("need line");var Of=/[\uD800-\uDFFF]/;function be(e){if(e===null)return null;if(Me(e))return e;if(typeof e=="object"&&e!==null&&"toJSON"in e&&typeof e.toJSON=="function"){let t=e.toJSON();if(t!==e)return be(t)}if(typeof e=="string")return Na(e,"string value"),e;if(typeof e=="boolean")return e;if(typeof e=="number")return Object.is(e,-0)?0:Number.isFinite(e)?e:null;if(typeof e=="bigint")return e>=Number.MIN_SAFE_INTEGER&&e<=Number.MAX_SAFE_INTEGER?Number(e):e.toString();if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(be);if(e instanceof Set)return Array.from(e,be);if(e instanceof Map){let t={};for(let[r,n]of e)Gt(t,String(r),be(n));return t}if(J(e)){let t={};for(let r of Object.keys(e))Na(r,"object key"),Gt(t,r,be(e[r]));return t}return null}function Na(e,t){if(Of.test(e))for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n<55296||n>57343)continue;let s=e.charCodeAt(r+1);if(n<=56319&&s>=56320&&s<=57343){r+=1;continue}throw new TypeError(`Cannot encode ${t} containing an unpaired surrogate U+${n.toString(16).toUpperCase()} at index ${r}`)}}function J(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function ce(e){return e===null||Me(e)||["string","number","boolean"].includes(typeof e)}function Gt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function La(e){return encodeURIComponent(e)}function Da(e){if(!J(e))return;let t=Object.entries(e);if(t.length===0)return;let r=[];for(let[s,i]of t){let o=Cf(i);if(o===void 0)return;r.push([s,o])}let n=[];for(let[s,i]of r)Nf(n,s,i);return n.join("")}function Cf(e){if(!Array.isArray(e)||e.length===0||!e.every(J))return;let t=$f(e);if(t===void 0)return;let r=e.map(a=>a[t]),n=xf(r);if(n===void 0)return;let s=If(e,t),i=new Map;for(let a of e){let c=a[t];i.has(c)||i.set(c,[]);let l={};for(let[d,p]of Object.entries(a))if(d!==t&&!s.includes(d)&&!us(p,d,l))return;i.get(c).push(l)}let o=[];for(let a of n.cycle){let c=i.get(a),l=qf(c);if(l===void 0||l.length===0)return;o.push({fields:l,label:a,rows:c})}return{common:s,commonRows:e.map(a=>Object.fromEntries(s.map(c=>[c,a[c]]))),discriminator:t,groups:o,order:n,rows:e}}function $f(e){return $a.find(t=>e.every(r=>typeof r[t]=="string"))}function xf(e){if(!(e.length<12))for(let t=2;t<=Math.min(8,Math.floor(e.length/3));t+=1){if(e.length%t!==0)continue;let r=e.slice(0,t);if(new Set(r).size<2||!e.every((o,a)=>o===r[a%t]))continue;let n=e.length/t;if(n<3)continue;let s=e.map(La).join(","),i=`cycle(${r.map(La).join(",")})*${n}`;if(i.length<=s.length*.4)return{cycle:r,encoded:i,repeats:n}}}function If(e,t){let r=[],n=Object.keys(e[0]),s=n.indexOf(t)+1;for(let i of n.slice(s).filter(o=>o!==t)){if(!Lf(i)||!e.every(o=>Object.prototype.hasOwnProperty.call(o,i))||!e.every(o=>Sr(o[i])))break;r.push(i)}return r}function Nf(e,t,r){e.push(X(t),`:
|
|
141
|
+
`,r)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Vn(t),n=vt(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=Vn(t),n=vt(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};cp.Parser=Io});var fp=P(ur=>{"use strict";var lp=To(),xE=tr(),lr=sr(),IE=bi(),NE=L(),LE=xo(),up=No();function dp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new LE.LineCounter||null,prettyErrors:t}}function qE(e,t={}){let{lineCounter:r,prettyErrors:n}=dp(t),s=new up.Parser(r?.addNewLine),i=new lp.Composer(t),o=Array.from(i.compose(s.parse(e)));if(n&&r)for(let a of o)a.errors.forEach(lr.prettifyError(e,r)),a.warnings.forEach(lr.prettifyError(e,r));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function pp(e,t={}){let{lineCounter:r,prettyErrors:n}=dp(t),s=new up.Parser(r?.addNewLine),i=new lp.Composer(t),o=null;for(let a of i.compose(s.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new lr.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(o.errors.forEach(lr.prettifyError(e,r)),o.warnings.forEach(lr.prettifyError(e,r))),o}function DE(e,t,r){let n;typeof t=="function"?n=t:r===void 0&&t&&typeof t=="object"&&(r=t);let s=pp(e,r);if(!s)return null;if(s.warnings.forEach(i=>IE.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:n},r))}function FE(e,t,r){let n=null;if(typeof t=="function"||Array.isArray(t)?n=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let s=Math.round(r);r=s<1?void 0:s>8?{indent:8}:{indent:s}}if(e===void 0){let{keepUndefined:s}=r??t??{};if(!s)return}return NE.isDocument(e)&&!n?e.toString(r):new xE.Document(e,n,r).toString(r)}ur.parse=DE;ur.parseAllDocuments=qE;ur.parseDocument=pp;ur.stringify=FE});var qo=P(q=>{"use strict";var jE=To(),BE=tr(),UE=eo(),Lo=sr(),ME=Ft(),De=L(),VE=xe(),HE=U(),KE=Ne(),WE=Le(),zE=Un(),JE=Co(),YE=xo(),QE=No(),Kn=fp(),hp=Nt();q.Composer=jE.Composer;q.Document=BE.Document;q.Schema=UE.Schema;q.YAMLError=Lo.YAMLError;q.YAMLParseError=Lo.YAMLParseError;q.YAMLWarning=Lo.YAMLWarning;q.Alias=ME.Alias;q.isAlias=De.isAlias;q.isCollection=De.isCollection;q.isDocument=De.isDocument;q.isMap=De.isMap;q.isNode=De.isNode;q.isPair=De.isPair;q.isScalar=De.isScalar;q.isSeq=De.isSeq;q.Pair=VE.Pair;q.Scalar=HE.Scalar;q.YAMLMap=KE.YAMLMap;q.YAMLSeq=WE.YAMLSeq;q.CST=zE;q.Lexer=JE.Lexer;q.LineCounter=YE.LineCounter;q.Parser=QE.Parser;q.parse=Kn.parse;q.parseAllDocuments=Kn.parseAllDocuments;q.parseDocument=Kn.parseDocument;q.stringify=Kn.stringify;q.visit=hp.visit;q.visitAsync=hp.visitAsync});import{readFileSync as ef}from"node:fs";import{join as tf,resolve as ta}from"node:path";function Ta(e){let t={app:e,version:bf(it("__RED_BUILD_VERSION__",()=>"4.1.18")??"0.0.0-dev"),gitSha:it("__RED_BUILD_GIT_SHA__",()=>"58e5f9e840fdc765140bda1632fecb43717d57bf")??"unknown",buildTime:it("__RED_BUILD_TIME__",()=>"2026-08-21T04:08:28-03:00")??"unknown",bundleAsset:it("__RED_BUNDLE_ASSET__",()=>"release.bundle.min.mjs")??"unknown"},r=it("__REDDB_SDK_VERSION__",()=>""),n=it("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function bf(e){return e.startsWith("v")?e.slice(1):e}function _a(e){return`${e.app} ${e.version} ${e.gitSha}`}function it(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}function ka(e){return e==="single-object"?"rest":"graphql"}function va(e,t){return e==="stable-poll"?"rest":ka(t)}function Z(e){return{none:e}}function M(e,t,r,n,s,i,o){let a=typeof s=="string"?{fallback:s}:{fallback:null,noFallbackBecause:s.none};return{key:e,kind:"read",cardinality:t,volatility:r,surface:o??va(r,t),budget:n,...a,...o?{only:o}:{},why:i}}function ee(e,t,r,n,s){let i=typeof s=="string"?{fallback:s}:{fallback:null,noFallbackBecause:s.none};return{key:e,kind:"write",cardinality:"single-object",surface:t,budget:r,...i,why:n}}var Sa=[M("issue view","single-object","stable-poll","rest","graphql","one issue by number, repeatedly polled while usually unchanged; REST answers in one request"),M("pr view","single-object","stable-poll","rest","graphql","one pull request by number, polled per Worker per iteration"),M("repo view","single-object","stable-poll","rest","graphql","one repository's own metadata, repeatedly read while usually unchanged"),M("run view","single-object","stable-poll","rest",Z("Actions runs have no GraphQL resource"),"one Actions run repeatedly polled to terminal"),M("release view","single-object","stable-poll","rest",Z("release lookup has no GraphQL client method"),"one release by tag, repeatedly checked while usually absent or unchanged"),M("pr diff","single-object","one-shot","rest",Z("the complete diff is exposed as a REST media type"),"one pull request's diff, read once for review"),M("issue list","multi-node","stable-poll","rest","graphql","a repeatedly polled, usually-unchanged issue collection; REST can make an unchanged poll free"),M("pr list","multi-node","stable-poll","rest","graphql","a repeatedly polled, usually-unchanged pull-request collection; REST can make an unchanged poll free"),M("pr checks","multi-node","stable-poll","rest","graphql","check contexts are repeatedly polled while awaiting terminal state"),M("release list","multi-node","stable-poll","rest",Z("Releases has no GraphQL collection client method"),"release waits poll a usually-unchanged list"),M("run list","multi-node","stable-poll","rest",Z("Actions has no GraphQL collection client method"),"run waits poll a usually-unchanged list"),M("label list","multi-node","one-shot","graphql","rest","a label connection loaded once for the current operation"),M("issue list (search)","multi-node","stable-poll","search",Z("search is ineligible for diverted traffic"),"queue discovery polls usually-unchanged search results through the 30/min search connection"),M("pr list (search)","multi-node","stable-poll","search",Z("search is ineligible for diverted traffic"),"PR discovery polls usually-unchanged search results through the 30/min search connection"),M("search issues","multi-repository","one-shot","search",Z("search is ineligible for diverted traffic"),"a one-shot cross-repository read through the REST search endpoint, metered 30/min","rest"),M("search prs","multi-repository","one-shot","search",Z("search is ineligible for diverted traffic"),"a one-shot cross-repository read through the REST search endpoint, metered 30/min","rest"),M("search repos","multi-repository","one-shot","search",Z("search is ineligible for diverted traffic"),"a one-shot cross-repository read through the REST search endpoint, metered 30/min","rest"),M("api graphql","multi-node","one-shot","graphql",Z("the caller explicitly chose GraphQL"),"the caller supplies one explicit GraphQL query rather than a routed poll"),M("api rest","single-object","one-shot","rest",Z("the caller explicitly chose REST"),"the caller supplies one explicit REST path rather than a routed poll"),ee("issue create","rest","rest","the write plan POSTs to `repos/{o}/{r}/issues`; GraphQL exposes createIssue","graphql"),ee("issue edit","rest","rest","the write plan PATCHes labels and body; GraphQL exposes updateIssue","graphql"),ee("issue close","rest","rest","the write plan PATCHes issue state; GraphQL exposes closeIssue","graphql"),ee("issue reopen","graphql","graphql","gh uses reopenIssue; REST can PATCH the issue state to open","rest"),ee("issue comment","rest","rest","the write plan POSTs an issue comment; GraphQL exposes addComment","graphql"),ee("issue develop","graphql","graphql","linked-branch creation is a GraphQL mutation",Z("linked-branch creation has no REST mutation")),ee("pr create","rest","rest","the write plan POSTs a pull request; GraphQL exposes createPullRequest","graphql"),ee("pr comment","rest","rest","a pull request comment is an issue comment; GraphQL exposes addComment","graphql"),ee("pr merge","rest","rest","the default plan PUTs the merge; GraphQL exposes mergePullRequest","graphql"),ee("pr close","graphql","graphql","gh uses closePullRequest; REST can PATCH the pull request state","rest"),ee("pr edit","graphql","graphql","gh uses GraphQL mutations; REST can PATCH pull-request fields and issue labels","rest"),ee("pr ready","graphql","graphql","marking ready-for-review is a GraphQL mutation",Z("GitHub exposes no REST ready-for-review mutation")),ee("pr update-branch","rest","rest","the write plan PUTs update-branch; GraphQL exposes updatePullRequestBranch","graphql"),ee("label create","rest","rest","the write plan POSTs a label; GraphQL exposes createLabel","graphql")],q_=new Map(Sa.map(e=>[e.key,e]));var ss="RED_GITHUB_REQUEST_TIMEOUT_MS",ot=class extends Error{subject;timeoutMs;constructor(t,r,n){super(`GitHub ${t} passed its ${r}ms deadline and was abandoned; raise ${ss} if this host is genuinely this slow`,n),this.name="GithubTimeoutError",this.subject=t,this.timeoutMs=r}};function Ra(e){return e instanceof ot}function _r(e=process.env){let t=e[ss];if(t===void 0||t.trim()==="")return 3e4;let r=Number(t);return!Number.isFinite(r)||r<0?3e4:Math.trunc(r)}async function kr(e,t,r){if(!Number.isFinite(t)||t<=0)return await r();let n,s=new Promise((o,a)=>{n=setTimeout(()=>a(new ot(e,t)),t),n.unref?.()}),i=Promise.resolve().then(r);i.catch(()=>{});try{return await Promise.race([i,s])}finally{n!==void 0&&clearTimeout(n)}}function is(e={}){let t=e.fetchImpl??fetch,r=e.timeoutMs??_r();return!Number.isFinite(r)||r<=0?t:async(n,s)=>{let i=AbortSignal.timeout(r),o=s?.signal??null,a=o==null?i:AbortSignal.any([o,i]),c=wf(n);try{return await kr(c,r,async()=>await t(n,{...s??{},signal:a}))}catch(l){throw Ra(l)?l:i.aborted&&o?.aborted!==!0?new ot(c,r,{cause:l}):l}}}function wf(e){let t=typeof e=="string"?e:e instanceof URL?e.href:typeof e.url=="string"?e.url:"request";try{return new URL(t).pathname}catch{return t}}var vr="off";var Aa="RED_GITHUB_BUDGET_GATE";function Ga(e){if(e===!0)return"on";if(typeof e!="string")return vr;let t=e.trim().toLowerCase();return t==="on"||t==="enabled"||t==="true"?"on":vr}function os(e){return(e??vr)==="on"}function as(e=process.env){return Ga(e[Aa])}import{execFile as Yf}from"node:child_process";import{promisify as Qf}from"node:util";var at=class extends SyntaxError{line;source;reason;constructor(t,r,n={}){super(t===0?r:`line ${t}: ${r}`,n.cause===void 0?void 0:{cause:n.cause}),this.name="ToonError",this.line=t,this.source=n.source,this.reason=r}};function ve(e,t,r={}){return new at(e,t,r)}var Ef=/(?:^\uFEFF?|\n) *#/,cs=class{value;constructor(t){if(Ef.test(t))throw new TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(t)}`);this.value=t}};function Me(e){return e instanceof cs}function Tf(e){return/^[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(e)}function _f(e){if(Object.is(e,-0))return"0";if(!Number.isFinite(e))throw ve(0,"number is not representable in TOON");return String(e)}function Sr(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"}function te(e,t){if(Me(e))return e.value;if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return _f(e);if(typeof e=="string")return vf(e,t);throw ve(0,"not a primitive")}function kf(e){return/^[A-Za-z_][A-Za-z0-9_.]*$/.test(e)}function X(e){return kf(e)?e:Rr(e)}function vf(e,t){return ls(e,t)?Rr(e):e}function ls(e,t){return e===""||/^[ \t]|[ \t]$/.test(e)||e==="true"||e==="false"||e==="null"||Tf(e)||/[:"\\[\]{}]/.test(e)||/[\u0000-\u001f]/.test(e)||e.includes(t)||e.startsWith("-")||e.startsWith("#")}var Oa=/["\\\u0000-\u001f]/g;function Rr(e){return`"${Pa(e)}"`}function Pa(e){let t="",r=0;Oa.lastIndex=0;let n;for(;(n=Oa.exec(e))!==null;){let s=e.charCodeAt(n.index),i;s===34?i='\\"':s===92?i="\\\\":s===10?i="\\n":s===13?i="\\r":s===9?i="\\t":i=`\\u${s.toString(16).padStart(4,"0")}`,t+=e.slice(r,n.index)+i,r=n.index+1}return`${t}${e.slice(r)}`}var Ca={comma:",",tab:" ",pipe:"|"},Sf=Ca.comma;var Ar=1e3,$a=["type","kind","event"],Ve="|";var tk=Symbol("need line");var Of=/[\uD800-\uDFFF]/;function be(e){if(e===null)return null;if(Me(e))return e;if(typeof e=="object"&&e!==null&&"toJSON"in e&&typeof e.toJSON=="function"){let t=e.toJSON();if(t!==e)return be(t)}if(typeof e=="string")return Na(e,"string value"),e;if(typeof e=="boolean")return e;if(typeof e=="number")return Object.is(e,-0)?0:Number.isFinite(e)?e:null;if(typeof e=="bigint")return e>=Number.MIN_SAFE_INTEGER&&e<=Number.MAX_SAFE_INTEGER?Number(e):e.toString();if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(be);if(e instanceof Set)return Array.from(e,be);if(e instanceof Map){let t={};for(let[r,n]of e)Gt(t,String(r),be(n));return t}if(J(e)){let t={};for(let r of Object.keys(e))Na(r,"object key"),Gt(t,r,be(e[r]));return t}return null}function Na(e,t){if(Of.test(e))for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n<55296||n>57343)continue;let s=e.charCodeAt(r+1);if(n<=56319&&s>=56320&&s<=57343){r+=1;continue}throw new TypeError(`Cannot encode ${t} containing an unpaired surrogate U+${n.toString(16).toUpperCase()} at index ${r}`)}}function J(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function le(e){return e===null||Me(e)||["string","number","boolean"].includes(typeof e)}function Gt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function La(e){return encodeURIComponent(e)}function Da(e){if(!J(e))return;let t=Object.entries(e);if(t.length===0)return;let r=[];for(let[s,i]of t){let o=Cf(i);if(o===void 0)return;r.push([s,o])}let n=[];for(let[s,i]of r)Nf(n,s,i);return n.join("")}function Cf(e){if(!Array.isArray(e)||e.length===0||!e.every(J))return;let t=$f(e);if(t===void 0)return;let r=e.map(a=>a[t]),n=xf(r);if(n===void 0)return;let s=If(e,t),i=new Map;for(let a of e){let c=a[t];i.has(c)||i.set(c,[]);let l={};for(let[d,p]of Object.entries(a))if(d!==t&&!s.includes(d)&&!us(p,d,l))return;i.get(c).push(l)}let o=[];for(let a of n.cycle){let c=i.get(a),l=qf(c);if(l===void 0||l.length===0)return;o.push({fields:l,label:a,rows:c})}return{common:s,commonRows:e.map(a=>Object.fromEntries(s.map(c=>[c,a[c]]))),discriminator:t,groups:o,order:n,rows:e}}function $f(e){return $a.find(t=>e.every(r=>typeof r[t]=="string"))}function xf(e){if(!(e.length<12))for(let t=2;t<=Math.min(8,Math.floor(e.length/3));t+=1){if(e.length%t!==0)continue;let r=e.slice(0,t);if(new Set(r).size<2||!e.every((o,a)=>o===r[a%t]))continue;let n=e.length/t;if(n<3)continue;let s=e.map(La).join(","),i=`cycle(${r.map(La).join(",")})*${n}`;if(i.length<=s.length*.4)return{cycle:r,encoded:i,repeats:n}}}function If(e,t){let r=[],n=Object.keys(e[0]),s=n.indexOf(t)+1;for(let i of n.slice(s).filter(o=>o!==t)){if(!Lf(i)||!e.every(o=>Object.prototype.hasOwnProperty.call(o,i))||!e.every(o=>Sr(o[i])))break;r.push(i)}return r}function Nf(e,t,r){e.push(X(t),`:
|
|
142
142
|
`),e.push(" order: ",te(r.order.encoded,Ve),`
|
|
143
143
|
`),e.push(" discriminator: ",te(r.discriminator,Ve),`
|
|
144
144
|
`),e.push(" rows: ",String(r.rows.length),`
|
|
145
145
|
`),r.common.length>0&&qa(e,"common",r.common,r.commonRows);for(let n of r.groups)qa(e,n.label,n.fields,n.rows)}function qa(e,t,r,n){e.push(" ",X(t),"[",String(n.length),Ve,"]{",r.map(X).join(Ve),`}:
|
|
146
146
|
`);for(let s of n)e.push(" ",r.map(i=>te(s[i],Ve)).join(Ve),`
|
|
147
|
-
`)}function Lf(e){return e!==""&&ds(e)}function us(e,t,r,n=new Set){if(!ds(t))return!1;if(Sr(e))return r[t]=e,!0;if(Array.isArray(e)){if(n.has(e))return!1;n.add(e),r[`${t}.length`]=e.length;let s=e.every((i,o)=>us(i,`${t}.${o}`,r,n));return n.delete(e),s}if(J(e)){if(n.has(e))return!1;n.add(e);let s=Object.entries(e).every(([i,o])=>!i.includes(".")&&us(o,`${t}.${i}`,r,n));return n.delete(e),s}return!1}function qf(e){let t=Object.keys(e[0]??{});if(e.every(r=>Df(Object.keys(r),t)))return t.every(ds)?t:void 0}function Df(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function ds(e){return e.split(".").every(t=>/^[A-Za-z_][A-Za-z0-9_]*$|^(?:0|[1-9][0-9]*)$/.test(t))}var bk=Symbol("unset");function Fa(e,t){let r=t("",e,[]);return r===void 0?ps(e,t,[]):fs(e,r,t,[])}function fs(e,t,r,n){return Me(t)&&(Array.isArray(e)||J(e))?ps(e,r,n):ps(be(t),r,n)}function ps(e,t,r){return Array.isArray(e)?Bf(e,t,r):J(e)?jf(e,t,r):e}function jf(e,t,r){let n={};for(let[s,i]of Object.entries(e)){let o=[...r,s],a=t(s,i,o);a!==void 0&&Gt(n,s,fs(i,a,t,o))}return n}function Bf(e,t,r){let n=[];for(let s=0;s<e.length;s+=1){let i=[...r,s],o=t(String(s),e[s],i);o!==void 0&&n.push(fs(e[s],o,t,i))}return n}function ct(e,t={}){if(t.objectArrayColumns===!0){let s=ja(e);if(s!==void 0)return[{name:"values",fixedLength:s,self:!0}]}let r=Object.keys(e[0]??{});if(r.length===0)return;for(let s of e)if(!J(s)||Object.keys(s).length!==r.length||r.some(i=>!Object.prototype.hasOwnProperty.call(s,i)))return;let n=[];for(let s of r){let i=e.map(a=>a[s]);if(i.every(
|
|
147
|
+
`)}function Lf(e){return e!==""&&ds(e)}function us(e,t,r,n=new Set){if(!ds(t))return!1;if(Sr(e))return r[t]=e,!0;if(Array.isArray(e)){if(n.has(e))return!1;n.add(e),r[`${t}.length`]=e.length;let s=e.every((i,o)=>us(i,`${t}.${o}`,r,n));return n.delete(e),s}if(J(e)){if(n.has(e))return!1;n.add(e);let s=Object.entries(e).every(([i,o])=>!i.includes(".")&&us(o,`${t}.${i}`,r,n));return n.delete(e),s}return!1}function qf(e){let t=Object.keys(e[0]??{});if(e.every(r=>Df(Object.keys(r),t)))return t.every(ds)?t:void 0}function Df(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function ds(e){return e.split(".").every(t=>/^[A-Za-z_][A-Za-z0-9_]*$|^(?:0|[1-9][0-9]*)$/.test(t))}var bk=Symbol("unset");function Fa(e,t){let r=t("",e,[]);return r===void 0?ps(e,t,[]):fs(e,r,t,[])}function fs(e,t,r,n){return Me(t)&&(Array.isArray(e)||J(e))?ps(e,r,n):ps(be(t),r,n)}function ps(e,t,r){return Array.isArray(e)?Bf(e,t,r):J(e)?jf(e,t,r):e}function jf(e,t,r){let n={};for(let[s,i]of Object.entries(e)){let o=[...r,s],a=t(s,i,o);a!==void 0&&Gt(n,s,fs(i,a,t,o))}return n}function Bf(e,t,r){let n=[];for(let s=0;s<e.length;s+=1){let i=[...r,s],o=t(String(s),e[s],i);o!==void 0&&n.push(fs(e[s],o,t,i))}return n}function ct(e,t={}){if(t.objectArrayColumns===!0){let s=ja(e);if(s!==void 0)return[{name:"values",fixedLength:s,self:!0}]}let r=Object.keys(e[0]??{});if(r.length===0)return;for(let s of e)if(!J(s)||Object.keys(s).length!==r.length||r.some(i=>!Object.prototype.hasOwnProperty.call(s,i)))return;let n=[];for(let s of r){let i=e.map(a=>a[s]);if(i.every(le)){n.push({name:s});continue}if(t.primitiveArrayColumns===!0&&i.every(a=>Array.isArray(a)&&a.every(le))){n.push({name:s,listDelimiter:";"});continue}if(t.objectArrayColumns===!0&&i.every(Array.isArray)){let a=ja(i);if(a!==void 0){n.push({name:s,fixedLength:a});continue}let c=i.flat(),l=ct(c,t);if(l!==void 0){n.push({name:s,children:l,childTable:!0});continue}}if(!i.every(a=>J(a)&&Object.keys(a).length>0))return;let o=ct(i,t);if(o===void 0)return;n.push({name:s,children:o})}return n}function Gr(e,t={}){let r=Object.values(e);if(!(r.length<2)&&r.every(n=>J(n)&&Object.keys(n).length>0))return ct(r,t)}function ja(e){let t=Array.isArray(e[0])?e[0].length:0;if(t!==0)return e.every(r=>Array.isArray(r)&&r.length===t&&r.every(le))?t:void 0}function He(e,t={}){return Array.from(Ba(e,t)).join(`
|
|
148
148
|
`)}function Ba(e,t={}){let r=t.delimiter??",";if(![",","|"," "].includes(r))throw new TypeError("invalid delimiter");let n=t.indentSize??t.indent??2,s=t.maxDepth??Ar,i=s===Number.POSITIVE_INFINITY?0:Math.max(0,Math.floor(s)),o=be(e),a=t.replacer?Fa(o,t.replacer):o,c={delimiter:r,indentSize:n,maxDepth:i,primitiveArrayColumns:t.primitiveArrayColumns===!0,objectArrayColumns:t.objectArrayColumns===!0};if(t.cyclicDiscriminatedArrays===!0){let l=Da(a);if(l!==void 0)return l.trimEnd().split(`
|
|
149
|
-
`)}return Uf(a,c)}function Uf(e,t){if(ce(e))return[te(e,t.delimiter)];if(Array.isArray(e))return Ma(void 0,e,0,t);let r=Gr(e,t);return r===void 0?Or(e,0,t):Ua(void 0,e,r,0,t)}function Or(e,t,r){return ut(t,r),Object.entries(e).flatMap(([n,s])=>Mf(n,s,t,r))}function Mf(e,t,r,n){let s=H(r,n)+X(e);if(ce(t))return[`${s}: ${te(t,n.delimiter)}`];if(Array.isArray(t))return Ma(e,t,r,n);let i=Gr(t,n);if(i!==void 0)return Ua(e,t,i,r,n);let o=[`${s}:`];return Object.keys(t).length>0&&o.push(...Or(t,r+1,n)),o}function Ua(e,t,r,n,s){ut(n,s);let i=Object.entries(t);Ot(r,n+1,s);let o=[H(n,s)+pe(e,i.length,r,s.delimiter,!0)];for(let[a,c]of i){let l=lt(c,r,n+2,s);o.push(H(n+1,s)+X(a)+": "+l.cells),o.push(...l.children)}return o}function Ma(e,t,r,n){ut(r,n);let s=H(r,n);if(t.length===0)return[e===void 0?`${s}[]`:`${s}${X(e)}: []`];if(t.every(ce))return[s+pe(e,t.length,void 0,n.delimiter)+" "+ms(t,n.delimiter)];let i=ct(t,n);if(i!==void 0)return Vf(e,t,i,r,n);let o=[s+pe(e,t.length,void 0,n.delimiter)];for(let a of t)o.push(...hs(a,r+1,n));return o}function Vf(e,t,r,n,s){Ot(r,n+1,s);let i=[H(n,s)+pe(e,t.length,r,s.delimiter)];for(let o of t){let a=lt(o,r,n+2,s);i.push(H(n+1,s)+a.cells),i.push(...a.children)}return i}function hs(e,t,r){ut(t,r);let n=H(t,r)+"-";if(ce(e))return[`${n} ${te(e,r.delimiter)}`];if(Array.isArray(e)){if(e.length===0)return[`${n} ${pe(void 0,0,void 0,r.delimiter)}`];if(e.every(ce))return[`${n} ${pe(void 0,e.length,void 0,r.delimiter)} ${ms(e,r.delimiter)}`];let s=[`${n} ${pe(void 0,e.length,void 0,r.delimiter)}`];for(let i of e)s.push(...hs(i,t+1,r));return s}return Hf(e,t,r)}function Hf(e,t,r){ut(t,r);let n=Object.entries(e);if(n.length===0)return[H(t,r)+"-"];let[[s,i],...o]=n,a=Kf(s,i,t,r),c;if(a!==void 0)c=a;else if(ce(i))c=[H(t,r)+"- "+X(s)+": "+te(i,r.delimiter)];else if(Array.isArray(i))if(i.length===0)c=[H(t,r)+"- "+X(s)+": []"];else{c=[H(t,r)+"- "+pe(s,i.length,void 0,r.delimiter)];for(let l of i)c.push(...hs(l,t+2,r))}else c=[H(t,r)+"- "+X(s)+":"],Object.keys(i).length>0&&c.push(...Or(i,t+2,r));return o.length>0&&c.push(...Or(Object.fromEntries(o),t+1,r)),c}function Kf(e,t,r,n){if(Array.isArray(t)&&t.length>0&&t.every(ce))return[H(r,n)+"- "+pe(e,t.length,void 0,n.delimiter)+" "+ms(t,n.delimiter)];if(Array.isArray(t)&&t.every(J)){let s=ct(t,n);if(s!==void 0){Ot(s,r+1,n);let i=[H(r,n)+"- "+pe(e,t.length,s,n.delimiter)];for(let o of t){let a=lt(o,s,r+3,n);i.push(H(r+2,n)+a.cells),i.push(...a.children)}return i}}if(J(t)){let s=Gr(t,n);if(s!==void 0){Ot(s,r+1,n);let i=Object.entries(t),o=[H(r,n)+"- "+pe(e,i.length,s,n.delimiter,!0)];for(let[a,c]of i){let l=lt(c,s,r+3,n);o.push(H(r+2,n)+X(a)+": "+l.cells),o.push(...l.children)}return o}}}function pe(e,t,r,n,s=!1){let i=e===void 0?"":X(e),o=s?":":"",a=n===","?"":n,c=r===void 0?"":`{${Va(r,n)}}`;return`${i}[${t}${o}${a}]${c}:`}function Va(e,t){return e.map(r=>{let n=X(r.name);if(r.listDelimiter!==void 0)return`${n}[${r.listDelimiter}]`;if(r.fixedLength!==void 0){let s=t===","?"":t;return`${n}[${r.fixedLength}${s}]`}return n+(r.children===void 0?"":`{${Va(r.children,t)}}`)}).join(t)}function lt(e,t,r,n){let s=[],i=[];for(let o of t){let a=o.self===!0?e:e[o.name];if(o.childTable===!0){s.push(String(a.length));for(let c of a){let l=lt(c,o.children??[],r+1,n);i.push(H(r,n)+l.cells,...l.children)}}else if(o.fixedLength!==void 0)s.push(...a.map(c=>te(c,n.delimiter)));else if(o.listDelimiter!==void 0)s.push(a.map(c=>Wf(c,n.delimiter,o.listDelimiter)).join(o.listDelimiter));else if(o.children!==void 0){let c=lt(a,o.children,r,n);s.push(c.cells),i.push(...c.children)}else s.push(te(a,n.delimiter))}return{cells:s.join(n.delimiter),children:i}}function Wf(e,t,r){return typeof e!="string"?te(e,t):ls(e,t)||e.includes(r)?Rr(e):e}function ms(e,t){return e.map(r=>te(r,t)).join(t)}function H(e,t){return" ".repeat(e*t.indentSize)}function ut(e,t){if(t.maxDepth!==0&&e>t.maxDepth)throw ve(0,`maximum nesting depth exceeded (maxDepth ${t.maxDepth})`)}function Ot(e,t,r){ut(t,r);for(let n of e)n.children!==void 0&&Ot(n.children,t+1,r)}var Wk=new TextEncoder,zk=new TextDecoder;var Dv=Qf(Yf),le=.5;var Fv=256*1024*1024,Te=1024*1024,Ha=14*24*60*60*1e3,bs={"process-deaths":{maxBytes:4*Te,maxAgeMs:Ha,targetRatio:le},"github-spend":{maxBytes:8*Te,targetRatio:le},"github-balance":{maxBytes:64*1024,targetRatio:le},"github-balance-history":{maxBytes:2*Te,targetRatio:le},"castle-singleton-events":{maxBytes:2*Te,targetRatio:le},"redskilled-events":{maxBytes:4*Te,targetRatio:le},"rsp-telemetry-spool":{maxBytes:8*Te,targetRatio:le},"rsp-telemetry-corrections":{maxBytes:Te,targetRatio:le},"death-attributions":{maxBytes:Te,maxAgeMs:Ha,targetRatio:le},"worker-log":{maxLines:5e4,targetRatio:le},"worker-liveness":{maxBytes:Te,targetRatio:le},"castle-history":{maxLines:1e4,targetRatio:le}};function Y(){return typeof navigator=="object"&&"userAgent"in navigator?navigator.userAgent:typeof process=="object"&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:"<environment undetectable>"}var eh="0.0.0-development",th=`octokit-endpoint.js/${eh} ${Y()}`,rh={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":th},mediaType:{format:""}};function nh(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function sh(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function za(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{sh(t[n])?n in e?r[n]=za(e[n],t[n]):Object.assign(r,{[n]:t[n]}):Object.assign(r,{[n]:t[n]})}),r}function Ka(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Es(e,t,r){if(typeof t=="string"){let[s,i]=t.split(" ");r=Object.assign(i?{method:s,url:i}:{url:s},r)}else r=Object.assign({},t);r.headers=nh(r.headers),Ka(r),Ka(r.headers);let n=za(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(n.mediaType.previews=e.mediaType.previews.filter(s=>!n.mediaType.previews.includes(s)).concat(n.mediaType.previews)),n.mediaType.previews=(n.mediaType.previews||[]).map(s=>s.replace(/-preview/,""))),n}function ih(e,t){let r=/\?/.test(e)?"&":"?",n=Object.keys(t);return n.length===0?e:e+r+n.map(s=>s==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${s}=${encodeURIComponent(t[s])}`).join("&")}var oh=/\{[^{}}]+\}/g;function ah(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function ch(e){let t=e.match(oh);return t?t.map(ah).reduce((r,n)=>r.concat(n),[]):[]}function Wa(e,t){let r={__proto__:null};for(let n of Object.keys(e))t.indexOf(n)===-1&&(r[n]=e[n]);return r}function Ja(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function pt(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Pt(e,t,r){return t=e==="+"||e==="#"?Ja(t):pt(t),r?pt(r)+"="+t:t}function dt(e){return e!=null}function ws(e){return e===";"||e==="&"||e==="?"}function lh(e,t,r,n){var s=e[r],i=[];if(dt(s)&&s!=="")if(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||typeof s=="boolean")s=s.toString(),n&&n!=="*"&&(s=s.substring(0,parseInt(n,10))),i.push(Pt(t,s,ws(t)?r:""));else if(n==="*")Array.isArray(s)?s.filter(dt).forEach(function(o){i.push(Pt(t,o,ws(t)?r:""))}):Object.keys(s).forEach(function(o){dt(s[o])&&i.push(Pt(t,s[o],o))});else{let o=[];Array.isArray(s)?s.filter(dt).forEach(function(a){o.push(Pt(t,a))}):Object.keys(s).forEach(function(a){dt(s[a])&&(o.push(pt(a)),o.push(Pt(t,s[a].toString())))}),ws(t)?i.push(pt(r)+"="+o.join(",")):o.length!==0&&i.push(o.join(","))}else t===";"?dt(s)&&i.push(pt(r)):s===""&&(t==="&"||t==="?")?i.push(pt(r)+"="):s===""&&i.push("");return i}function uh(e){return{expand:dh.bind(null,e)}}function dh(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(n,s,i){if(s){let a="",c=[];if(r.indexOf(s.charAt(0))!==-1&&(a=s.charAt(0),s=s.substr(1)),s.split(/,/g).forEach(function(l){var d=/([^:\*]*)(?::(\d+)|(\*))?/.exec(l);c.push(lh(t,a,d[1],d[2]||d[3]))}),a&&a!=="+"){var o=",";return a==="?"?o="&":a!=="#"&&(o=a),(c.length!==0?a:"")+c.join(o)}else return c.join(",")}else return Ja(i)}),e==="/"?e:e.replace(/\/$/,"")}function Ya(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),n=Object.assign({},e.headers),s,i=Wa(e,["method","baseUrl","url","headers","request","mediaType"]),o=ch(r);r=uh(r).expand(i),/^http/.test(r)||(r=e.baseUrl+r);let a=Object.keys(e).filter(d=>o.includes(d)).concat("baseUrl"),c=Wa(i,a);if(!/application\/octet-stream/i.test(n.accept)&&(e.mediaType.format&&(n.accept=n.accept.split(/,/).map(d=>d.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let d=n.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];n.accept=d.concat(e.mediaType.previews).map(p=>{let f=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${p}-preview${f}`}).join(",")}return["GET","HEAD"].includes(t)?r=ih(r,c):"data"in c?s=c.data:Object.keys(c).length&&(s=c),!n["content-type"]&&typeof s<"u"&&(n["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof s>"u"&&(s=""),Object.assign({method:t,url:r,headers:n},typeof s<"u"?{body:s}:null,e.request?{request:e.request}:null)}function ph(e,t,r){return Ya(Es(e,t,r))}function Qa(e,t){let r=Es(e,t),n=ph.bind(null,r);return Object.assign(n,{DEFAULTS:r,defaults:Qa.bind(null,r),merge:Es.bind(null,r),parse:Ya})}var Xa=Qa(null,rh);var gc=At(ic(),1);var _h=/^-?\d+$/,$r=/^-?\d+n+$/,Se=JSON.stringify,vs=JSON.parse,uc=/^-?\d+n$/,oc=/([\[:])?"(-?\d+)n"($|\s*[,\}\]])/g,ac=/([\[:])?("-?\d+n+)n("$|"\s*[,\}\]])/g,Ss=e=>e===void 0||typeof e=="function"||typeof e=="symbol",Rs=e=>e!==null&&typeof e=="object"&&e.constructor&&e.constructor.name==="RawJSON",kh=(e,t,r)=>{let n="";typeof r=="number"?n=" ".repeat(Math.min(10,Math.max(0,Math.floor(r)))):typeof r=="string"&&(n=r.slice(0,10));let s=typeof t=="function",i=Array.isArray(t)?new Set(t.map(String)):null,o=(w,m,y)=>(y!==null&&typeof y=="object"&&typeof y.toJSON=="function"&&(y=y.toJSON(m)),typeof y=="string"&&$r.test(y)?y+"n":typeof y=="bigint"?"rawJSON"in JSON?JSON.rawJSON(y.toString()):y.toString()+"n":(s&&(y=t.call(w,m,y)),y!==null&&typeof y=="object"&&(y instanceof Number||y instanceof String||y instanceof Boolean)&&(y=y.valueOf()),y)),a=o({"":e},"",e);if(Ss(a))return;let c=a===null||typeof a!="object",l=Rs(a);if(c||l)return Se(a);let d=[],p=0,f=[{parent:{"":a},key:"",val:a,isArray:Array.isArray(a),keys:Array.isArray(a)?null:Object.keys(a),index:0,first:!0}],h=new WeakSet([a]);for(;f.length>0;){let w=f[f.length-1];w.index===0&&(d.push(w.isArray?"[":"{"),p++);let m=!1;if(w.isArray)if(w.index<w.val.length){w.first||d.push(","),n&&d.push(`
|
|
149
|
+
`)}return Uf(a,c)}function Uf(e,t){if(le(e))return[te(e,t.delimiter)];if(Array.isArray(e))return Ma(void 0,e,0,t);let r=Gr(e,t);return r===void 0?Or(e,0,t):Ua(void 0,e,r,0,t)}function Or(e,t,r){return ut(t,r),Object.entries(e).flatMap(([n,s])=>Mf(n,s,t,r))}function Mf(e,t,r,n){let s=H(r,n)+X(e);if(le(t))return[`${s}: ${te(t,n.delimiter)}`];if(Array.isArray(t))return Ma(e,t,r,n);let i=Gr(t,n);if(i!==void 0)return Ua(e,t,i,r,n);let o=[`${s}:`];return Object.keys(t).length>0&&o.push(...Or(t,r+1,n)),o}function Ua(e,t,r,n,s){ut(n,s);let i=Object.entries(t);Ot(r,n+1,s);let o=[H(n,s)+pe(e,i.length,r,s.delimiter,!0)];for(let[a,c]of i){let l=lt(c,r,n+2,s);o.push(H(n+1,s)+X(a)+": "+l.cells),o.push(...l.children)}return o}function Ma(e,t,r,n){ut(r,n);let s=H(r,n);if(t.length===0)return[e===void 0?`${s}[]`:`${s}${X(e)}: []`];if(t.every(le))return[s+pe(e,t.length,void 0,n.delimiter)+" "+ms(t,n.delimiter)];let i=ct(t,n);if(i!==void 0)return Vf(e,t,i,r,n);let o=[s+pe(e,t.length,void 0,n.delimiter)];for(let a of t)o.push(...hs(a,r+1,n));return o}function Vf(e,t,r,n,s){Ot(r,n+1,s);let i=[H(n,s)+pe(e,t.length,r,s.delimiter)];for(let o of t){let a=lt(o,r,n+2,s);i.push(H(n+1,s)+a.cells),i.push(...a.children)}return i}function hs(e,t,r){ut(t,r);let n=H(t,r)+"-";if(le(e))return[`${n} ${te(e,r.delimiter)}`];if(Array.isArray(e)){if(e.length===0)return[`${n} ${pe(void 0,0,void 0,r.delimiter)}`];if(e.every(le))return[`${n} ${pe(void 0,e.length,void 0,r.delimiter)} ${ms(e,r.delimiter)}`];let s=[`${n} ${pe(void 0,e.length,void 0,r.delimiter)}`];for(let i of e)s.push(...hs(i,t+1,r));return s}return Hf(e,t,r)}function Hf(e,t,r){ut(t,r);let n=Object.entries(e);if(n.length===0)return[H(t,r)+"-"];let[[s,i],...o]=n,a=Kf(s,i,t,r),c;if(a!==void 0)c=a;else if(le(i))c=[H(t,r)+"- "+X(s)+": "+te(i,r.delimiter)];else if(Array.isArray(i))if(i.length===0)c=[H(t,r)+"- "+X(s)+": []"];else{c=[H(t,r)+"- "+pe(s,i.length,void 0,r.delimiter)];for(let l of i)c.push(...hs(l,t+2,r))}else c=[H(t,r)+"- "+X(s)+":"],Object.keys(i).length>0&&c.push(...Or(i,t+2,r));return o.length>0&&c.push(...Or(Object.fromEntries(o),t+1,r)),c}function Kf(e,t,r,n){if(Array.isArray(t)&&t.length>0&&t.every(le))return[H(r,n)+"- "+pe(e,t.length,void 0,n.delimiter)+" "+ms(t,n.delimiter)];if(Array.isArray(t)&&t.every(J)){let s=ct(t,n);if(s!==void 0){Ot(s,r+1,n);let i=[H(r,n)+"- "+pe(e,t.length,s,n.delimiter)];for(let o of t){let a=lt(o,s,r+3,n);i.push(H(r+2,n)+a.cells),i.push(...a.children)}return i}}if(J(t)){let s=Gr(t,n);if(s!==void 0){Ot(s,r+1,n);let i=Object.entries(t),o=[H(r,n)+"- "+pe(e,i.length,s,n.delimiter,!0)];for(let[a,c]of i){let l=lt(c,s,r+3,n);o.push(H(r+2,n)+X(a)+": "+l.cells),o.push(...l.children)}return o}}}function pe(e,t,r,n,s=!1){let i=e===void 0?"":X(e),o=s?":":"",a=n===","?"":n,c=r===void 0?"":`{${Va(r,n)}}`;return`${i}[${t}${o}${a}]${c}:`}function Va(e,t){return e.map(r=>{let n=X(r.name);if(r.listDelimiter!==void 0)return`${n}[${r.listDelimiter}]`;if(r.fixedLength!==void 0){let s=t===","?"":t;return`${n}[${r.fixedLength}${s}]`}return n+(r.children===void 0?"":`{${Va(r.children,t)}}`)}).join(t)}function lt(e,t,r,n){let s=[],i=[];for(let o of t){let a=o.self===!0?e:e[o.name];if(o.childTable===!0){s.push(String(a.length));for(let c of a){let l=lt(c,o.children??[],r+1,n);i.push(H(r,n)+l.cells,...l.children)}}else if(o.fixedLength!==void 0)s.push(...a.map(c=>te(c,n.delimiter)));else if(o.listDelimiter!==void 0)s.push(a.map(c=>Wf(c,n.delimiter,o.listDelimiter)).join(o.listDelimiter));else if(o.children!==void 0){let c=lt(a,o.children,r,n);s.push(c.cells),i.push(...c.children)}else s.push(te(a,n.delimiter))}return{cells:s.join(n.delimiter),children:i}}function Wf(e,t,r){return typeof e!="string"?te(e,t):ls(e,t)||e.includes(r)?Rr(e):e}function ms(e,t){return e.map(r=>te(r,t)).join(t)}function H(e,t){return" ".repeat(e*t.indentSize)}function ut(e,t){if(t.maxDepth!==0&&e>t.maxDepth)throw ve(0,`maximum nesting depth exceeded (maxDepth ${t.maxDepth})`)}function Ot(e,t,r){ut(t,r);for(let n of e)n.children!==void 0&&Ot(n.children,t+1,r)}var Wk=new TextEncoder,zk=new TextDecoder;var Dv=Qf(Yf),oe=.5;var Fv=256*1024*1024,we=1024*1024,Ha=14*24*60*60*1e3,bs={"process-deaths":{maxBytes:4*we,maxAgeMs:Ha,targetRatio:oe},"github-spend":{maxBytes:8*we,targetRatio:oe},"github-balance":{maxBytes:64*1024,targetRatio:oe},"github-balance-history":{maxBytes:2*we,targetRatio:oe},"castle-singleton-events":{maxBytes:2*we,targetRatio:oe},"redskilled-events":{maxBytes:4*we,targetRatio:oe},"rsp-telemetry-spool":{maxBytes:8*we,targetRatio:oe},"rsp-telemetry-corrections":{maxBytes:we,targetRatio:oe},"death-attributions":{maxBytes:we,maxAgeMs:Ha,targetRatio:oe},"worker-log":{maxLines:5e4,targetRatio:oe},"worker-liveness":{maxBytes:we,targetRatio:oe},"castle-history":{maxLines:1e4,targetRatio:oe},verdicts:{maxBytes:4*we,targetRatio:oe}};function Y(){return typeof navigator=="object"&&"userAgent"in navigator?navigator.userAgent:typeof process=="object"&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:"<environment undetectable>"}var eh="0.0.0-development",th=`octokit-endpoint.js/${eh} ${Y()}`,rh={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":th},mediaType:{format:""}};function nh(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function sh(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function za(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{sh(t[n])?n in e?r[n]=za(e[n],t[n]):Object.assign(r,{[n]:t[n]}):Object.assign(r,{[n]:t[n]})}),r}function Ka(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Es(e,t,r){if(typeof t=="string"){let[s,i]=t.split(" ");r=Object.assign(i?{method:s,url:i}:{url:s},r)}else r=Object.assign({},t);r.headers=nh(r.headers),Ka(r),Ka(r.headers);let n=za(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(n.mediaType.previews=e.mediaType.previews.filter(s=>!n.mediaType.previews.includes(s)).concat(n.mediaType.previews)),n.mediaType.previews=(n.mediaType.previews||[]).map(s=>s.replace(/-preview/,""))),n}function ih(e,t){let r=/\?/.test(e)?"&":"?",n=Object.keys(t);return n.length===0?e:e+r+n.map(s=>s==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${s}=${encodeURIComponent(t[s])}`).join("&")}var oh=/\{[^{}}]+\}/g;function ah(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function ch(e){let t=e.match(oh);return t?t.map(ah).reduce((r,n)=>r.concat(n),[]):[]}function Wa(e,t){let r={__proto__:null};for(let n of Object.keys(e))t.indexOf(n)===-1&&(r[n]=e[n]);return r}function Ja(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function pt(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Pt(e,t,r){return t=e==="+"||e==="#"?Ja(t):pt(t),r?pt(r)+"="+t:t}function dt(e){return e!=null}function ws(e){return e===";"||e==="&"||e==="?"}function lh(e,t,r,n){var s=e[r],i=[];if(dt(s)&&s!=="")if(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||typeof s=="boolean")s=s.toString(),n&&n!=="*"&&(s=s.substring(0,parseInt(n,10))),i.push(Pt(t,s,ws(t)?r:""));else if(n==="*")Array.isArray(s)?s.filter(dt).forEach(function(o){i.push(Pt(t,o,ws(t)?r:""))}):Object.keys(s).forEach(function(o){dt(s[o])&&i.push(Pt(t,s[o],o))});else{let o=[];Array.isArray(s)?s.filter(dt).forEach(function(a){o.push(Pt(t,a))}):Object.keys(s).forEach(function(a){dt(s[a])&&(o.push(pt(a)),o.push(Pt(t,s[a].toString())))}),ws(t)?i.push(pt(r)+"="+o.join(",")):o.length!==0&&i.push(o.join(","))}else t===";"?dt(s)&&i.push(pt(r)):s===""&&(t==="&"||t==="?")?i.push(pt(r)+"="):s===""&&i.push("");return i}function uh(e){return{expand:dh.bind(null,e)}}function dh(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(n,s,i){if(s){let a="",c=[];if(r.indexOf(s.charAt(0))!==-1&&(a=s.charAt(0),s=s.substr(1)),s.split(/,/g).forEach(function(l){var d=/([^:\*]*)(?::(\d+)|(\*))?/.exec(l);c.push(lh(t,a,d[1],d[2]||d[3]))}),a&&a!=="+"){var o=",";return a==="?"?o="&":a!=="#"&&(o=a),(c.length!==0?a:"")+c.join(o)}else return c.join(",")}else return Ja(i)}),e==="/"?e:e.replace(/\/$/,"")}function Ya(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),n=Object.assign({},e.headers),s,i=Wa(e,["method","baseUrl","url","headers","request","mediaType"]),o=ch(r);r=uh(r).expand(i),/^http/.test(r)||(r=e.baseUrl+r);let a=Object.keys(e).filter(d=>o.includes(d)).concat("baseUrl"),c=Wa(i,a);if(!/application\/octet-stream/i.test(n.accept)&&(e.mediaType.format&&(n.accept=n.accept.split(/,/).map(d=>d.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let d=n.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];n.accept=d.concat(e.mediaType.previews).map(p=>{let f=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${p}-preview${f}`}).join(",")}return["GET","HEAD"].includes(t)?r=ih(r,c):"data"in c?s=c.data:Object.keys(c).length&&(s=c),!n["content-type"]&&typeof s<"u"&&(n["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof s>"u"&&(s=""),Object.assign({method:t,url:r,headers:n},typeof s<"u"?{body:s}:null,e.request?{request:e.request}:null)}function ph(e,t,r){return Ya(Es(e,t,r))}function Qa(e,t){let r=Es(e,t),n=ph.bind(null,r);return Object.assign(n,{DEFAULTS:r,defaults:Qa.bind(null,r),merge:Es.bind(null,r),parse:Ya})}var Xa=Qa(null,rh);var gc=At(ic(),1);var _h=/^-?\d+$/,$r=/^-?\d+n+$/,Se=JSON.stringify,vs=JSON.parse,uc=/^-?\d+n$/,oc=/([\[:])?"(-?\d+)n"($|\s*[,\}\]])/g,ac=/([\[:])?("-?\d+n+)n("$|"\s*[,\}\]])/g,Ss=e=>e===void 0||typeof e=="function"||typeof e=="symbol",Rs=e=>e!==null&&typeof e=="object"&&e.constructor&&e.constructor.name==="RawJSON",kh=(e,t,r)=>{let n="";typeof r=="number"?n=" ".repeat(Math.min(10,Math.max(0,Math.floor(r)))):typeof r=="string"&&(n=r.slice(0,10));let s=typeof t=="function",i=Array.isArray(t)?new Set(t.map(String)):null,o=(w,m,y)=>(y!==null&&typeof y=="object"&&typeof y.toJSON=="function"&&(y=y.toJSON(m)),typeof y=="string"&&$r.test(y)?y+"n":typeof y=="bigint"?"rawJSON"in JSON?JSON.rawJSON(y.toString()):y.toString()+"n":(s&&(y=t.call(w,m,y)),y!==null&&typeof y=="object"&&(y instanceof Number||y instanceof String||y instanceof Boolean)&&(y=y.valueOf()),y)),a=o({"":e},"",e);if(Ss(a))return;let c=a===null||typeof a!="object",l=Rs(a);if(c||l)return Se(a);let d=[],p=0,f=[{parent:{"":a},key:"",val:a,isArray:Array.isArray(a),keys:Array.isArray(a)?null:Object.keys(a),index:0,first:!0}],h=new WeakSet([a]);for(;f.length>0;){let w=f[f.length-1];w.index===0&&(d.push(w.isArray?"[":"{"),p++);let m=!1;if(w.isArray)if(w.index<w.val.length){w.first||d.push(","),n&&d.push(`
|
|
150
150
|
`+n.repeat(p));let y=w.val[w.index],R=o(w.val,String(w.index),y);if(Ss(R))d.push("null"),w.first=!1,w.index++;else{let O=R!==null&&typeof R=="object",_=Rs(R);if(O&&!_){if(h.has(R))throw new TypeError("Converting circular structure to JSON");h.add(R),f.push({parent:w.val,key:String(w.index),val:R,isArray:Array.isArray(R),keys:Array.isArray(R)?null:Object.keys(R),index:0,first:!0}),w.first=!1,w.index++}else d.push(Se(R)),w.first=!1,w.index++}}else m=!0;else{for(;w.index<w.keys.length;){let R=w.keys[w.index++];if(i&&!i.has(R))continue;let _=w.val[R],k=o(w.val,R,_);if(Ss(k))continue;w.first||d.push(","),n?d.push(`
|
|
151
151
|
`+n.repeat(p)+Se(R)+": "):d.push(Se(R)+":");let S=k!==null&&typeof k=="object",A=Rs(k);if(S&&!A){if(h.has(k))throw new TypeError("Converting circular structure to JSON");h.add(k),f.push({parent:w.val,key:R,val:k,isArray:Array.isArray(k),keys:Array.isArray(k)?null:Object.keys(k),index:0,first:!0}),w.first=!1;break}else d.push(Se(k)),w.first=!1}w.index>=w.keys.length&&f[f.length-1]===w&&(m=!0)}m&&(p--,!w.first&&n&&d.push(`
|
|
152
152
|
`+n.repeat(p)),d.push(w.isArray?"]":"}"),h.delete(w.val),f.pop())}return d.join("")},dc=(e,t,r)=>{try{return"rawJSON"in JSON?Se(e,(a,c)=>typeof c=="bigint"?JSON.rawJSON(c.toString()):typeof t=="function"?t(a,c):(Array.isArray(t)&&t.includes(a),c),r):e?Se(e,(a,c)=>typeof c=="string"&&$r.test(c)||typeof c=="bigint"?c.toString()+"n":typeof t=="function"?t(a,c):(Array.isArray(t)&&t.includes(a),c),r).replace(oc,"$1$2$3").replace(ac,"$1$2$3"):Se(e,t,r)}catch(n){if(n instanceof RangeError){let s=kh(e,t,r);return s===void 0?void 0:"rawJSON"in JSON?s:s.replace(oc,"$1$2$3").replace(ac,"$1$2$3")}throw n}},Cr=new Map,vh=()=>{let e=JSON.parse.toString();if(Cr.has(e))return Cr.get(e);try{let t=JSON.parse("1",(r,n,s)=>!!s?.source&&s.source==="1");return Cr.set(e,t),t}catch{return Cr.set(e,!1),!1}},Sh=(e,t,r,n)=>typeof t=="string"&&uc.test(t)?BigInt(t.slice(0,-1)):typeof t=="string"&&$r.test(t)?t.slice(0,-1):typeof n=="function"?n(e,t,r):t,Rh=(e,t)=>JSON.parse(e,(r,n,s)=>{let i=typeof n=="number",o=n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER,a=i&&o,c=s&&_h.test(s.source);return a&&c?BigInt(s.source):typeof t=="function"?t(r,n,s):n}),pc=Number.MAX_SAFE_INTEGER.toString(),cc=pc.length,Ah=/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g,Gh=/^"-?\d+n+"$/,Oh=(e,t)=>{let r={"":e},n=[{parent:r,key:"",visited:!1}];for(;n.length>0;){let s=n[n.length-1];if(s.visited){let{parent:i,key:o}=s,a=i[o];typeof a=="string"&&(uc.test(a)?a=BigInt(a.slice(0,-1)):$r.test(a)&&(a=a.slice(0,-1))),typeof t=="function"&&(a=t.call(i,o,a)),a===void 0?delete i[o]:i[o]=a,n.pop()}else{s.visited=!0;let i=s.parent[s.key];if(i!==null&&typeof i=="object"){let a=Object.keys(i);for(let c=a.length-1;c>=0;c--)n.push({parent:i,key:a[c],visited:!1})}}}return r[""]},lc=e=>e.replace(Ah,(t,r,n,s)=>{let i=t[0]==='"';if(i&&Gh.test(t))return t.substring(0,t.length-1)+'n"';let a=n||s,c=r&&(r.length<cc||r.length===cc&&r<=pc);return i||a||c?t:'"'+t+'n"'}),fc=(e,t)=>{if(!e)return vs(e,t);try{if(vh())return Rh(e,t);let r=lc(e);return vs(r,(n,s,i)=>Sh(n,s,i,t))}catch(r){if(r instanceof RangeError){let n=lc(e),s=vs(n);return Oh(s,t)}throw r}};var fe=class extends Error{name;status;request;response;constructor(t,r,n){super(t,{cause:n.cause}),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0);"response"in n&&(this.response=n.response);let s=Object.assign({},n.request);n.request.headers.authorization&&(s.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),s.url=s.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=s}};var Ph="10.0.13",Ch={headers:{"user-agent":`octokit-request.js/${Ph} ${Y()}`}};function $h(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}var hc=()=>"";async function mc(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,n=e.request?.parseSuccessResponseBody!==!1,s=$h(e.body)||Array.isArray(e.body)?dc(e.body):e.body,i=Object.fromEntries(Object.entries(e.headers).map(([p,f])=>[p,String(f)])),o;try{o=await t(e.url,{method:e.method,body:s,redirect:e.request?.redirect,headers:i,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(p){let f="Unknown Error";if(p instanceof Error){if(p.name==="AbortError")throw p.status=500,p;f=p.message,p.name==="TypeError"&&"cause"in p&&(p.cause instanceof Error?f=p.cause.message:typeof p.cause=="string"&&(f=p.cause))}let h=new fe(f,500,{request:e});throw h.cause=p,h}let a=o.status,c=o.url,l={};for(let[p,f]of o.headers)l[p]=f;let d={url:c,status:a,headers:l,data:""};if("deprecation"in l){let p=l.link&&l.link.match(/<([^<>]+)>; rel="deprecation"/),f=p&&p.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${l.sunset}${f?`. See ${f}`:""}`)}if(a===204||a===205)return d;if(e.method==="HEAD"){if(a<400)return d;throw new fe(o.statusText,a,{response:d,request:e})}if(a===304)throw d.data=await As(o),new fe("Not modified",a,{response:d,request:e});if(a>=400)throw d.data=await As(o),new fe(Ih(d.data),a,{response:d,request:e});return d.data=n?await As(o):o.body,d}async function As(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(hc);let r=(0,gc.parse)(t);if(xh(r)){let n="";try{return n=await e.text(),fc(n)}catch{return n}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"&&r.type!=="application/octet-stream"?e.text().catch(hc):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function xh(e){return e.type==="application/json"||e.type==="application/scim+json"}function Ih(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if(typeof e=="object"&&e!==null&&"message"in e){let t=e,r="documentation_url"in t?` - ${t.documentation_url}`:"";return Array.isArray(t.errors)?`${t.message}: ${t.errors.map(n=>JSON.stringify(n)).join(", ")}${r}`:`${t.message}${r}`}return`Unknown error: ${JSON.stringify(e)}`}function Gs(e,t){let r=e.defaults(t);return Object.assign(function(s,i){let o=r.merge(s,i);if(!o.request||!o.request.hook)return mc(r.parse(o));let a=(c,l)=>mc(r.parse(r.merge(c,l)));return Object.assign(a,{endpoint:r,defaults:Gs.bind(null,r)}),o.request.hook(a,o)},{endpoint:r,defaults:Gs.bind(null,r)})}var j=Gs(Xa,Ch);function Nh(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?"https://github.com":/^https:\/\/api\..*\.ghe\.com$/.test(t.baseUrl)?t.baseUrl.replace("api.",""):t.baseUrl.replace("/api/v3","")}async function xr(e,t,r){let n={baseUrl:Nh(e),headers:{accept:"application/json"},...r},s=await e(t,n);if("error"in s.data){let i=new fe(`${s.data.error_description} (${s.data.error}, ${s.data.error_uri})`,400,{request:e.endpoint.merge(t,n)});throw i.response=s,i}return s}async function Ec(e){let t=e.request||j,r=await xr(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,code:e.code,redirect_uri:e.redirectUrl}),n={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if(e.clientType==="github-app"){if("refresh_token"in r.data){let s=new Date(r.headers.date).getTime();n.refreshToken=r.data.refresh_token,n.expiresAt=yc(s,r.data.expires_in),n.refreshTokenExpiresAt=yc(s,r.data.refresh_token_expires_in)}delete n.scopes}return{...r,authentication:n}}function yc(e,t){return new Date(e+t*1e3).toISOString()}async function Tc(e){let t=e.request||j,r={client_id:e.clientId};return"scopes"in e&&Array.isArray(e.scopes)&&(r.scope=e.scopes.join(" ")),xr(t,"POST /login/device/code",r)}async function Os(e){let t=e.request||j,r=await xr(t,"POST /login/oauth/access_token",{client_id:e.clientId,device_code:e.code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),n={clientType:e.clientType,clientId:e.clientId,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if("clientSecret"in e&&(n.clientSecret=e.clientSecret),e.clientType==="github-app"){if("refresh_token"in r.data){let s=new Date(r.headers.date).getTime();n.refreshToken=r.data.refresh_token,n.expiresAt=bc(s,r.data.expires_in),n.refreshTokenExpiresAt=bc(s,r.data.refresh_token_expires_in)}delete n.scopes}return{...r,authentication:n}}function bc(e,t){return new Date(e+t*1e3).toISOString()}async function _c(e){let r=await(e.request||j)("POST /applications/{client_id}/token",{headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`},client_id:e.clientId,access_token:e.token}),n={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.token,scopes:r.data.scopes};return r.data.expires_at&&(n.expiresAt=r.data.expires_at),e.clientType==="github-app"&&delete n.scopes,{...r,authentication:n}}async function kc(e){let t=e.request||j,r=await xr(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,grant_type:"refresh_token",refresh_token:e.refreshToken}),n=new Date(r.headers.date).getTime(),s={clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,refreshToken:r.data.refresh_token,expiresAt:wc(n,r.data.expires_in),refreshTokenExpiresAt:wc(n,r.data.refresh_token_expires_in)};return{...r,authentication:s}}function wc(e,t){return new Date(e+t*1e3).toISOString()}async function vc(e){let t=e.request||j,r=btoa(`${e.clientId}:${e.clientSecret}`),n=await t("PATCH /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token}),s={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:n.data.token,scopes:n.data.scopes};return n.data.expires_at&&(s.expiresAt=n.data.expires_at),e.clientType==="github-app"&&delete s.scopes,{...n,authentication:s}}async function Sc(e){let t=e.request||j,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function Rc(e){let t=e.request||j,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/grant",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function Gc(e,t){let r=Lh(e,t.auth);if(r)return r;let{data:n}=await Tc({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(n);let s=await Ps(t.request||e.request,e.clientId,e.clientType,n);return e.authentication=s,s}function Lh(e,t){if(t.refresh===!0||!e.authentication)return!1;if(e.clientType==="github-app")return e.authentication;let r=e.authentication,n=("scopes"in t&&t.scopes||e.scopes).join(" "),s=r.scopes.join(" ");return n===s?r:!1}async function Ac(e){await new Promise(t=>setTimeout(t,e*1e3))}async function Ps(e,t,r,n){try{let s={clientId:t,request:e,code:n.device_code},{authentication:i}=r==="oauth-app"?await Os({...s,clientType:"oauth-app"}):await Os({...s,clientType:"github-app"});return{type:"token",tokenType:"oauth",...i}}catch(s){if(!s.response)throw s;let i=s.response.data.error;if(i==="authorization_pending")return await Ac(n.interval),Ps(e,t,r,n);if(i==="slow_down")return await Ac(n.interval+7),Ps(e,t,r,n);throw s}}async function qh(e,t){return Gc(e,{auth:t})}async function Dh(e,t,r,n){let s=t.endpoint.merge(r,n);if(/\/login\/(oauth\/access_token|device\/code)$/.test(s.url))return t(s);let{token:i}=await Gc(e,{request:t,auth:{type:"oauth"}});return s.headers.authorization=`token ${i}`,t(s)}var Fh="0.0.0-development";function Oc(e){let t=e.request||j.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${Fh} ${Y()}`}}),{request:r=t,...n}=e,s=e.clientType==="github-app"?{...n,clientType:"github-app",request:r}:{...n,clientType:"oauth-app",request:r,scopes:e.scopes||[]};if(!e.clientId)throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');if(!e.onVerification)throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');return Object.assign(qh.bind(null,s),{hook:Dh.bind(null,s)})}var Cc="0.0.0-development";async function Pc(e){if("code"in e.strategyOptions){let{authentication:t}=await Ec({clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request});return{type:"token",tokenType:"oauth",...t}}if("onVerification"in e.strategyOptions){let r=await Oc({clientType:e.clientType,clientId:e.clientId,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request})({type:"oauth"});return{clientSecret:e.clientSecret,...r}}if("token"in e.strategyOptions)return{type:"token",tokenType:"oauth",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions};throw new Error("[@octokit/auth-oauth-user] Invalid strategy options")}async function Cs(e,t={}){if(e.authentication||(e.authentication=e.clientType==="oauth-app"?await Pc(e):await Pc(e)),e.authentication.invalid)throw new Error("[@octokit/auth-oauth-user] Token is invalid");let r=e.authentication;if("expiresAt"in r&&(t.type==="refresh"||new Date(r.expiresAt)<new Date)){let{authentication:n}=await kc({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:r.refreshToken,request:e.request});e.authentication={tokenType:"oauth",type:"token",...n}}if(t.type==="refresh"){if(e.clientType==="oauth-app")throw new Error("[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens");if(!r.hasOwnProperty("expiresAt"))throw new Error("[@octokit/auth-oauth-user] Refresh token missing");await e.onTokenCreated?.(e.authentication,{type:t.type})}if(t.type==="check"||t.type==="reset"){let n=t.type==="check"?_c:vc;try{let{authentication:s}=await n({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request});return e.authentication={tokenType:"oauth",type:"token",...s},t.type==="reset"&&await e.onTokenCreated?.(e.authentication,{type:t.type}),e.authentication}catch(s){throw s.status===404&&(s.message="[@octokit/auth-oauth-user] Token is invalid",e.authentication.invalid=!0),s}}if(t.type==="delete"||t.type==="deleteAuthorization"){let n=t.type==="delete"?Sc:Rc;try{await n({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request})}catch(s){if(s.status!==404)throw s}return e.authentication.invalid=!0,e.authentication}return e.authentication}var jh=/\/applications\/[^/]+\/(token|grant)s?/;function Ct(e){return e&&jh.test(e)}async function Bh(e,t,r,n={}){let s=t.endpoint.merge(r,n);if(/\/login\/(oauth\/access_token|device\/code)$/.test(s.url))return t(s);if(Ct(s.url)){let o=btoa(`${e.clientId}:${e.clientSecret}`);return s.headers.authorization=`basic ${o}`,t(s)}let{token:i}=e.clientType==="oauth-app"?await Cs({...e,request:t}):await Cs({...e,request:t});return s.headers.authorization="token "+i,t(s)}function Ir({clientId:e,clientSecret:t,clientType:r="oauth-app",request:n=j.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${Cc} ${Y()}`}}),onTokenCreated:s,...i}){let o=Object.assign({clientType:r,clientId:e,clientSecret:t,onTokenCreated:s,strategyOptions:i,request:n});return Object.assign(Cs.bind(null,o),{hook:Bh.bind(null,o)})}Ir.VERSION=Cc;async function Uh(e,t){if(t.type==="oauth-app")return{type:"oauth-app",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`}};if("factory"in t){let{type:s,...i}={...t,...e};return t.factory(i)}let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.request,...t};return(e.clientType==="oauth-app"?await Ir({...r,clientType:e.clientType}):await Ir({...r,clientType:e.clientType}))()}async function Mh(e,t,r,n){let s=t.endpoint.merge(r,n);if(/\/login\/(oauth\/access_token|device\/code)$/.test(s.url))return t(s);if(e.clientType==="github-app"&&!Ct(s.url))throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${s.method} ${s.url}" is not supported.`);let i=btoa(`${e.clientId}:${e.clientSecret}`);s.headers.authorization=`basic ${i}`;try{return await t(s)}catch(o){throw o.status!==401||(o.message=`[@octokit/auth-oauth-app] "${s.method} ${s.url}" does not support clientId/clientSecret basic authentication.`),o}}var Vh="0.0.0-development";function $c(e){let t=Object.assign({request:j.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${Vh} ${Y()}`}}),clientType:"oauth-app"},e);return Object.assign(Uh.bind(null,t),{hook:Mh.bind(null,t)})}function Nr(e){return e.includes("-----BEGIN RSA PRIVATE KEY-----")}function Ic(e){return e.includes("-----BEGIN OPENSSH PRIVATE KEY-----")}function $s(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let n=0,s=e.length;n<s;n++)r[n]=e.charCodeAt(n);return t}function Nc(e){let t=e.trim().split(`
|
|
@@ -173,9 +173,9 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
|
|
|
173
173
|
`))}t.push(B("newline",`
|
|
174
174
|
`))}if(e.options&&Object.keys(e.options).length>0){t.push(B("section-header","Options:"),B("newline",`
|
|
175
175
|
`));let n=ug(e.options);t.push(...n)}return t}function cg(e,t){let r=ag(e);return og(r,t)}function lg(e){let t=["[options]"];if(e.positional)for(let r of e.positional)r.variadic?t.push(r.required?`<${r.name}...>`:`[${r.name}...]`):t.push(r.required?`<${r.name}>`:`[${r.name}]`);return t.join(" ")}function ug(e,t=!1){let r=[],n=[],s=t?"global-option-flag":"option-flag",i=t?"global-option-type":"option-type",o=t?"global-option-default":"option-default",a=t?"global-option-description":"option-description";for(let[l,d]of Object.entries(e)){if(d.hidden)continue;let p=[],f=m=>{p.includes(m)||p.push(m)};d.short&&f(`-${d.short}`),f(`--${l}`);for(let m of d.aliases??[])m.length===1?f(`-${m}`):f(`--${m}`);let h=p.join(", "),w=d.type&&d.type!=="boolean"?`<${d.type}>`:void 0;n.push({flags:h,type:w,desc:d.description??"",default:d.default!==void 0?String(d.default):void 0})}let c=Math.max(...n.map(l=>l.flags.length+(l.type?l.type.length+1:0)),20);for(let l of n){let d=l.flags.length+(l.type?l.type.length+1:0),p=" ".repeat(c-d+2);r.push(B("indent"," ")),r.push(B(s,l.flags)),l.type&&(r.push(B("text"," ")),r.push(B(i,l.type))),r.push(B("text",p)),r.push(B(a,l.desc)),l.default!==void 0&&(r.push(B("text"," ")),r.push(B(o,`(default: ${l.default})`))),r.push(B("newline",`
|
|
176
|
-
`))}return r}function Rl(e){let t=yg(e.options??{},e.autoShort??!1),r=rg(e.separators??vl);return{schema:e,parse(n){return dg(n,e,t,r)},help(){return cg(e,e.formatter)}}}function dg(e,t,r,n){let s={positional:{},options:{},errors:[],rest:[]},i=new Set(n.map(d=>d.to));for(let d of i)s[d]={};let o=0,a=t.positional??[],c=0,l=!1;for(;c<e.length;){let d=e[c];if(t.stopEarly&&o>0){s.rest=e.slice(c);break}if(d==="--"&&!l){l=!0,c++;continue}if(l){if(o<a.length){let f=a[o];if(f.variadic){let h=[];for(;c<e.length;){let w=e[c];h.push(f.type?ze(w,f.type):w),c++}s.positional[f.name]=h,o++}else{let h=f.type?ze(d,f.type):d;s.positional[f.name]=h,o++,c++}}else t.allowUnknown!==!1&&(s.rest=s.rest??[],s.rest.push(d)),c++;continue}if(d.startsWith("--")){c=mg(d,c,e,s,r,t);continue}if(d.startsWith("-")&&d.length>1&&!_g(d)){c=gg(d,c,e,s,r,t);continue}let p=pg(d,n);if(p){let{key:f,value:h,config:w}=p,m=s,y=m[w.to]??(m[w.to]={});y[f]=w.typed?Sl(h):Ge(h),c++;continue}if(o<a.length){let f=a[o];if(f.variadic){let w=[];for(;c<e.length&&!e[c].startsWith("-");){let m=e[c];w.push(f.type?ze(m,f.type):m),c++}s.positional[f.name]=w,o++;continue}let h=f.type?ze(d,f.type):d;s.positional[f.name]=h,o++}else t.allowUnknown!==!1?s.rest.push(d):s.errors.push(`Unexpected positional argument: ${d}`);c++}return wg(s,t,r),Eg(s,t,a),Tg(s,t,r),s}function pg(e,t){if(eg.test(e))return null;for(let r of t){if(r.prefix&&e.startsWith(r.separator)){let s=e.slice(r.separator.length),i=s.indexOf(":");if(i>0){let o=s.slice(0,i),a=s.slice(i+1);if(fg(o))return{key:o,value:a,config:r}}continue}let n=e.indexOf(r.separator);if(n>0){let s=e.slice(0,n),i=e.slice(n+r.separator.length);if(hg(s,i,r))return{key:s,value:i,config:r}}}return null}function fg(e){return e?/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e):!1}function hg(e,t,r){return e?r.separator===":"?e.includes("/")||e.includes(".")||/^\d+$/.test(t)?!1:/^[A-Z][a-zA-Z0-9-]*$/.test(e):!((r.separator==="="||r.separator===":=")&&e.includes("/")):!1}function mg(e,t,r,n,s,i){let o=e.slice(2);if(o.startsWith("no-")){let c=o.slice(3),l=s.get(c);if(l?.negatable!==!1&&l?.type==="boolean")return n.options[l.name]=!1,t+1}if(o.includes("=")){let c=o.indexOf("="),l=o.slice(0,c),d=o.slice(c+1);return Wr(l,d,t+1,n,s,i)}let a=s.get(o);if(a){if(a.type!=="boolean"){let c=r[t+1];return It(c)?Wr(a.name,c,t+2,n,s,i):(n.errors.push(`Option --${o} requires a value`),t+1)}return n.options[a.name]=!0,t+1}return i.strict?n.errors.push(`Unknown option: --${o}`):i.allowUnknown!==!1&&(n.options[o]=!0),t+1}function gg(e,t,r,n,s,i){let o=e.slice(1);if(o.includes("=")){let a=o.indexOf("="),c=o.slice(0,a),l=o.slice(a+1),d=Zs(c,s);return d?Wr(d.name,l,t+1,n,s,i):(i.strict?n.errors.push(`Unknown option: -${c}`):i.allowUnknown!==!1&&(n.options[c]=Kr(Ge(l))),t+1)}if(o.length===1){let a=Zs(o,s);if(a){if(a.type!=="boolean"){let c=r[t+1];return It(c)?Wr(a.name,c,t+2,n,s,i):(n.errors.push(`Option -${o} requires a value`),t+1)}return n.options[a.name]=!0,t+1}if(i.strict)n.errors.push(`Unknown option: -${o}`);else if(i.allowUnknown!==!1){let c=r[t+1];if(It(c))return n.options[o]=Kr(Ge(c)),t+2;n.options[o]=!0}return t+1}for(let a of o){let c=Zs(a,s);c?c.type==="boolean"?n.options[c.name]=!0:n.errors.push(`Option -${a} requires a value`):i.strict?n.errors.push(`Unknown option: -${a}`):i.allowUnknown!==!1&&(n.options[a]=!0)}return t+1}function Wr(e,t,r,n,s,i){let o=s.get(e);if(o){if(o.choices){let c=o.type?ze(Ge(t),o.type):Ge(t);if(!o.choices.includes(c))return n.errors.push(`Invalid value for '${e}': '${t}'. Allowed: ${o.choices.join(", ")}`),r}let a=o.type?ze(Ge(t),o.type):Ge(t);if(o.type==="array"){let c=n.options[e];Array.isArray(c)?c.push(...a):n.options[e]=a}else n.options[e]=a}else i.strict?n.errors.push(`Unknown option: --${e}`):i.allowUnknown!==!1&&(n.options[e]=Kr(Ge(t)));return r}function yg(e,t=!1){let r=new Map,n=Object.entries(e).sort(([i],[o])=>i.localeCompare(o)),s=new Set;for(let[,i]of n)i.short&&s.add(i.short);for(let[i,o]of n){let a=o.short??"";t&&!a&&(a=bg(i,s),a&&s.add(a));let c={name:i,short:a,aliases:o.aliases??[],type:o.type??"string",description:o.description??"",required:o.required??!1,hidden:o.hidden??!1,negatable:o.negatable??!0,default:o.default,choices:o.choices,env:o.env,validate:o.validate};r.set(i,c);for(let l of c.aliases)r.set(l,c)}return r}function bg(e,t){for(let r of e){if(!/[a-zA-Z]/.test(r))continue;let n=r.toLowerCase();if(!t.has(n))return n;let s=r.toUpperCase();if(!t.has(s))return s}return""}function Zs(e,t){for(let r of t.values())if(r.short===e||r.aliases.includes(e))return r}function wg(e,t,r){for(let n of r.values())if(e.options[n.name]===void 0)if(n.env&&process.env[n.env]!==void 0){let s=process.env[n.env];e.options[n.name]=n.type?ze(s,n.type):s}else n.default!==void 0&&(e.options[n.name]=n.default);for(let n of t.positional??[])e.positional[n.name]===void 0&&n.default!==void 0&&(e.positional[n.name]=n.default)}function Eg(e,t,r){if(t.options)for(let[n,s]of Object.entries(t.options))s.required&&e.options[n]===void 0&&e.errors.push(`Missing required option: --${n}`);for(let n of r)n.required&&e.positional[n.name]===void 0&&e.errors.push(`Missing required argument: <${n.name}>`)}function Tg(e,t,r){for(let n of r.values()){let s=e.options[n.name];if(n.validate&&s!==void 0){let i=n.validate(s);i!==!0&&e.errors.push(i)}}for(let n of t.positional??[]){let s=e.positional[n.name];if(n.validate&&s!==void 0){let i=n.validate(s);i!==!0&&e.errors.push(i)}}}function _g(e){return/^-\d+(\.\d+)?$/.test(e)}var ei=class extends Error{flag;known;constructor(t,r){super(`unknown flag '${t}'; expected one of: ${r.join(", ")}`),this.name="UnknownFlagError",this.flag=t,this.known=r}};function kg(e){let t={};for(let[r,n]of Object.entries(e))t[r]={type:n.kind==="boolean"?"boolean":"string",...r.length===1?{short:r}:{},...n.aliases===void 0?{}:{aliases:n.aliases}};return t}function vg(e,t){let r=new Map;for(let[s,i]of Object.entries(t))if(!(i.kind!=="value"||i.type!=="array")){r.set(s,s);for(let o of i.aliases??[])r.set(o,s)}let n=new Map;for(let s=0;s<e.length;s+=1){let i=e[s];if(i==="--")break;let o=i.match(/^--([^=]+)(?:=(.*))?$/)??i.match(/^-([^=])(?:=(.*))?$/);if(o===null)continue;let a=r.get(o[1]);if(a===void 0)continue;let c=o[2];if(c===void 0&&It(e[s+1])&&(c=e[s+1],s+=1),c===void 0)continue;let l=n.get(a)??[];l.push(c),n.set(a,l)}return n}function ti(e,t,r={}){let s=Rl({options:kg(t),separators:{},allowUnknown:!0}).parse([...e]),i={},o=vg(e,t),a=s.errors.find(c=>/^Option --?\S+ requires a value$/.test(c));if(a!==void 0)throw new Error(a.replace(/^Option /,""));if(s.errors.length>0)throw new Error(s.errors[0]);if(r.unknownFlags==="error"){let c=new Set(Object.keys(t));for(let l of Object.keys(s.options))if(!c.has(l))throw new ei(l.length===1?`-${l}`:`--${l}`,Object.keys(t).map(d=>d.length===1?`-${d}`:`--${d}`))}for(let[c,l]of Object.entries(t)){let d=s.options[c];d!==void 0&&(l.kind==="boolean"?i[c]=d:l.type==="array"?i[c]=(o.get(c)??[]).map(p=>l.coerce(p)):i[c]=l.coerce(String(d)))}return{values:i,positionals:s.rest}}var gp=At(qo(),1);import{readFileSync as XE,readdirSync as ZE}from"node:fs";import{basename as eT,join as tT}from"node:path";var Fe=class extends Error{file;constructor(t,r){super(`${t}: ${r}`),this.name="ChangesetParseError",this.file=t}},mp={patch:0,minor:1,major:2};function Wn(e){let t;try{t=ZE(e).filter(s=>s.endsWith(".md")&&s!=="README.md").sort((s,i)=>s.localeCompare(i))}catch(s){if(oT(s))return nT();throw s}let r=t.map(s=>rT(s,XE(tT(e,s),"utf8"))),n={major:0,minor:0,patch:0};for(let s of r)n[s.impact]+=1;return{changes:r,pending:n}}function rT(e,t){let r=eT(e),n=/^---[\t ]*\r?\n([\s\S]*?)\r?\n---[\t ]*(?:\r?\n|$)([\s\S]*)$/.exec(t.replace(/^\uFEFF/,""));if(n===null)throw new Fe(r,"expected YAML frontmatter between --- delimiters");let s;try{s=(0,gp.parse)(n[1],{uniqueKeys:!0})}catch(l){throw new Fe(r,`invalid YAML frontmatter: ${aT(l)}`)}if(!iT(s)||Object.keys(s).length===0)throw new Fe(r,"frontmatter must name at least one package");let i=[];for(let[l,d]of Object.entries(s)){if(l.trim()==="")throw new Fe(r,"frontmatter contains an empty package name");if(!sT(d))throw new Fe(r,`package ${JSON.stringify(l)} has invalid impact ${JSON.stringify(d)}; expected major, minor, or patch`);i.push({packageName:l,impact:d})}let o=n[2].trim();if(o==="")throw new Fe(r,"markdown body must not be empty");let a=o.split(/\r?\n/,1)[0].trim(),c=i.reduce((l,d)=>mp[d.impact]>mp[l]?d.impact:l,"patch");return{file:r,summary:a,body:o,impact:c,releases:i}}function nT(){return{changes:[],pending:{major:0,minor:0,patch:0}}}function sT(e){return e==="major"||e==="minor"||e==="patch"}function iT(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oT(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function aT(e){return e instanceof Error?e.message:String(e)}var cT={key:"release view",budget:"rest"},lT={key:"release create",budget:"rest"},uT={key:"release asset upload",budget:"rest"},dT={key:"release version-pr list",budget:"rest"},pT={key:"release version-pr create",budget:"rest"},fT={key:"release version-pr update",budget:"rest"},hT={key:"release version-pr view",budget:"rest"};function Ep(e){let t=bp(e.owner,"GitHub owner"),r=bp(e.repository,"GitHub repository"),n=e.actor??"release-engine",s=`${t}/${r}`;return{async upsertVersionPullRequest(i){let o=await e.client.conditionalRest({cacheKey:`release-version-pr-list:${s}:${i.base}:${i.head}`,route:"GET /repos/{owner}/{repo}/pulls",parameters:{owner:t,repo:r,state:"open",base:i.base,head:`${t}:${i.head}`,per_page:2},operation:dT,actor:n}),a=mT(o.data);if(a.length>1)throw new Error(`repository has multiple open Version PRs for ${i.head}`);if(a.length===1){let l=a[0],d=await e.client.conditionalRest({cacheKey:`release-version-pr-update:${s}:${l.number}`,route:"PATCH /repos/{owner}/{repo}/pulls/{pull_number}",parameters:{owner:t,repo:r,pull_number:l.number,title:i.title,body:i.body},operation:fT,actor:n});return{number:Do(d.data).number,created:!1}}let c=await e.client.conditionalRest({cacheKey:`release-version-pr-create:${s}:${i.head}`,route:"POST /repos/{owner}/{repo}/pulls",parameters:{owner:t,repo:r,title:i.title,body:i.body,head:i.head,base:i.base},operation:pT,actor:n});return{number:Do(c.data).number,created:!0}},async findVersionPullRequest(i){try{let o=await e.client.conditionalRest({cacheKey:`release-version-pr:${s}:${i}`,route:"GET /repos/{owner}/{repo}/pulls/{pull_number}",parameters:{owner:t,repo:r,pull_number:i},operation:hT,actor:n});return Do(o.data)}catch(o){if(wp(o)===404)return null;throw o}},async findByTag(i){try{let o=await e.client.conditionalRest({cacheKey:`release:${s}:${i}`,route:"GET /repos/{owner}/{repo}/releases/tags/{tag}",parameters:{owner:t,repo:r,tag:i},operation:cT,actor:n});return yp(o.data)}catch(o){if(wp(o)===404)return null;throw o}},async create(i){let o=await e.client.conditionalRest({cacheKey:`release-create:${s}:${i.tag}`,route:"POST /repos/{owner}/{repo}/releases",parameters:{owner:t,repo:r,tag_name:i.tag,target_commitish:i.targetCommitish,name:i.name,body:i.body,draft:!1,prerelease:i.prerelease},operation:lT,actor:n});return yp(o.data)},async uploadAsset(i){await e.client.conditionalRest({cacheKey:`release-asset:${s}:${i.releaseId}:${i.name}`,route:gT(i.uploadUrl),parameters:{name:i.name,data:i.data,headers:{"content-type":i.contentType,"content-length":i.data.byteLength}},operation:uT,actor:n})}}}function mT(e){if(!Array.isArray(e))throw new Error("GitHub returned an invalid Version PR list");return e.map(t=>{if(!St(t)||!zn(t.number))throw new Error("GitHub returned an invalid Version PR list");return{number:t.number}})}function Do(e){if(!St(e)||!zn(e.number)||!St(e.head))throw new Error("GitHub returned an invalid Version PR payload");if(typeof e.body!="string"||typeof e.head.sha!="string"||typeof e.merged!="boolean")throw new Error("GitHub returned an invalid Version PR payload");let t=e.merge_commit_sha;if(t!==null&&typeof t!="string")throw new Error("GitHub returned an invalid Version PR merge commit");return{number:e.number,body:e.body,headCommit:e.head.sha,merged:e.merged,mergeCommit:t}}function yp(e){if(!St(e)||!zn(e.id))throw new Error("GitHub returned an invalid Release payload");if(typeof e.prerelease!="boolean")throw new Error("GitHub returned an invalid Release prerelease marking");let t=Array.isArray(e.assets)?e.assets.map(r=>{if(!St(r)||!zn(r.id)||typeof r.name!="string")throw new Error("GitHub returned an invalid Release asset payload");return{id:r.id,name:r.name}}):[];return{id:e.id,tag:dr(e,"tag_name"),targetCommitish:dr(e,"target_commitish"),name:dr(e,"name"),body:dr(e,"body"),prerelease:e.prerelease,assets:t,uploadUrl:dr(e,"upload_url")}}function gT(e){let t=e.split("{")[0]??"";if(!/^https?:\/\/\S+\/assets$/.test(t))throw new Error(`GitHub returned an unusable Release upload_url: ${e}`);return`POST ${t}{?name}`}function dr(e,t){let r=e[t];if(typeof r!="string")throw new Error(`GitHub Release payload has no ${t}`);return r}function bp(e,t){let r=e.trim();if(r==="")throw new Error(`${t} must not be empty`);return r}function zn(e){return Number.isSafeInteger(e)&&e>0}function wp(e){return St(e)&&typeof e.status=="number"?e.status:void 0}function St(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var jo="<!-- red-release-wait:v1 -->",Tp={key:"release wait read",budget:"rest"},Fo={key:"release wait write",budget:"rest"},yT={key:"release wait alert search",budget:"search"};function vp(e){let t=kp(e.owner,"GitHub owner"),r=kp(e.repository,"GitHub repository"),n=e.actor??"release-wait",s=`${t}/${r}`,i=(o,a,c,l=Tp)=>e.client.conditionalRest({cacheKey:o,route:a,parameters:c,operation:l,actor:n});return{async findOpenVersionPullRequest(){let o=await i(`release-wait-pr:${s}`,"GET /repos/{owner}/{repo}/pulls",{owner:t,repo:r,state:"open",base:"main",head:`${t}:red-release/version-pr`,per_page:2});if(!Array.isArray(o.data)||o.data.length===0)return null;if(o.data.length>1)throw new Error("repository has multiple open Version PRs");let a=fr(o.data[0],"number"),c=await i(`release-wait-pr:${s}:${a}`,"GET /repos/{owner}/{repo}/pulls/{pull_number}",{owner:t,repo:r,pull_number:a});return bT(c.data)},async listActionRequiredRuns(o){return(await e.client.conditionalPaginate({cacheKey:`release-wait-runs:${s}:${o.headCommit}`,route:"GET /repos/{owner}/{repo}/actions/runs",parameters:{owner:t,repo:r,branch:o.head,head_sha:o.headCommit,status:"action_required"},operation:Tp,actor:n})).data.map(wT)},async listRequiredContexts(o){try{let a=await i(`release-wait-required:${s}:${o.base}`,"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks",{owner:t,repo:r,branch:o.base});if(!Bo(a.data))throw new Error("GitHub returned invalid required checks");let c=kT(a.data.contexts),l=Array.isArray(a.data.checks)?a.data.checks.map(d=>se(oe(d,"required check"),"context")):[];return[...new Set([...c,...l])]}catch(a){if(vT(a)===404)return[];throw a}},async listChecks(o){let[a,c]=await Promise.all([i(`release-wait-check-runs:${s}:${o.headCommit}`,"GET /repos/{owner}/{repo}/commits/{ref}/check-runs",{owner:t,repo:r,ref:o.headCommit,per_page:100}),i(`release-wait-statuses:${s}:${o.headCommit}`,"GET /repos/{owner}/{repo}/commits/{ref}/status",{owner:t,repo:r,ref:o.headCommit,per_page:100})]),l=oe(a.data,"check-runs response"),d=oe(c.data,"status response"),p=Array.isArray(l.check_runs)?l.check_runs:[],f=Array.isArray(d.statuses)?d.statuses:[];return[...p.map(ET),...f.map(TT)]},async findOpenAlert(){let o=await i(`release-wait-alert:${s}`,"GET /search/issues",{q:`repo:${s} is:issue is:open in:title "Release wait:"`,per_page:2},yT),a=oe(o.data,"release alert search"),l=(Array.isArray(a.items)?a.items:[]).filter(d=>{let p=oe(d,"release alert");return typeof p.body=="string"&&p.body.includes(jo)});if(l.length>1)throw new Error("repository has multiple open release-wait alerts");return l.length===0?null:_T(l[0])},async openAlert(o){let a=await i(`release-wait-alert-create:${s}`,"POST /repos/{owner}/{repo}/issues",{owner:t,repo:r,title:o.title,body:o.body},Fo);return{number:fr(a.data,"number")}},async updateAlert(o,a){await i(`release-wait-alert-update:${s}:${o}`,"PATCH /repos/{owner}/{repo}/issues/{issue_number}",{owner:t,repo:r,issue_number:o,title:a.title,body:a.body},Fo)},async closeAlert(o){await i(`release-wait-alert-close:${s}:${o}`,"PATCH /repos/{owner}/{repo}/issues/{issue_number}",{owner:t,repo:r,issue_number:o,state:"closed"},Fo)}}}async function Sp(e){let t=await e.github.findOpenVersionPullRequest();if(t===null)return{state:"no-version-pr",signal:await pr(e.github)};let r=(await e.github.listActionRequiredRuns(t)).filter(h=>h.headCommit===t.headCommit);if(r.length>0){let h=r.reduce((R,O)=>Date.parse(O.createdAt)<Date.parse(R.createdAt)?O:R),w=`Release wait: workflow approval needed for Version PR #${t.number}`,m=[jo,"## Human action required","",`${r.length} workflow runs are waiting for approval on Version PR #${t.number}.`,`The oldest has waited since ${new Date(h.createdAt).toISOString()}.`,"","Approve the pending workflow runs from the Actions page. The approval gate remains enabled.",""].join(`
|
|
176
|
+
`))}return r}function Rl(e){let t=yg(e.options??{},e.autoShort??!1),r=rg(e.separators??vl);return{schema:e,parse(n){return dg(n,e,t,r)},help(){return cg(e,e.formatter)}}}function dg(e,t,r,n){let s={positional:{},options:{},errors:[],rest:[]},i=new Set(n.map(d=>d.to));for(let d of i)s[d]={};let o=0,a=t.positional??[],c=0,l=!1;for(;c<e.length;){let d=e[c];if(t.stopEarly&&o>0){s.rest=e.slice(c);break}if(d==="--"&&!l){l=!0,c++;continue}if(l){if(o<a.length){let f=a[o];if(f.variadic){let h=[];for(;c<e.length;){let w=e[c];h.push(f.type?ze(w,f.type):w),c++}s.positional[f.name]=h,o++}else{let h=f.type?ze(d,f.type):d;s.positional[f.name]=h,o++,c++}}else t.allowUnknown!==!1&&(s.rest=s.rest??[],s.rest.push(d)),c++;continue}if(d.startsWith("--")){c=mg(d,c,e,s,r,t);continue}if(d.startsWith("-")&&d.length>1&&!_g(d)){c=gg(d,c,e,s,r,t);continue}let p=pg(d,n);if(p){let{key:f,value:h,config:w}=p,m=s,y=m[w.to]??(m[w.to]={});y[f]=w.typed?Sl(h):Ge(h),c++;continue}if(o<a.length){let f=a[o];if(f.variadic){let w=[];for(;c<e.length&&!e[c].startsWith("-");){let m=e[c];w.push(f.type?ze(m,f.type):m),c++}s.positional[f.name]=w,o++;continue}let h=f.type?ze(d,f.type):d;s.positional[f.name]=h,o++}else t.allowUnknown!==!1?s.rest.push(d):s.errors.push(`Unexpected positional argument: ${d}`);c++}return wg(s,t,r),Eg(s,t,a),Tg(s,t,r),s}function pg(e,t){if(eg.test(e))return null;for(let r of t){if(r.prefix&&e.startsWith(r.separator)){let s=e.slice(r.separator.length),i=s.indexOf(":");if(i>0){let o=s.slice(0,i),a=s.slice(i+1);if(fg(o))return{key:o,value:a,config:r}}continue}let n=e.indexOf(r.separator);if(n>0){let s=e.slice(0,n),i=e.slice(n+r.separator.length);if(hg(s,i,r))return{key:s,value:i,config:r}}}return null}function fg(e){return e?/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e):!1}function hg(e,t,r){return e?r.separator===":"?e.includes("/")||e.includes(".")||/^\d+$/.test(t)?!1:/^[A-Z][a-zA-Z0-9-]*$/.test(e):!((r.separator==="="||r.separator===":=")&&e.includes("/")):!1}function mg(e,t,r,n,s,i){let o=e.slice(2);if(o.startsWith("no-")){let c=o.slice(3),l=s.get(c);if(l?.negatable!==!1&&l?.type==="boolean")return n.options[l.name]=!1,t+1}if(o.includes("=")){let c=o.indexOf("="),l=o.slice(0,c),d=o.slice(c+1);return Wr(l,d,t+1,n,s,i)}let a=s.get(o);if(a){if(a.type!=="boolean"){let c=r[t+1];return It(c)?Wr(a.name,c,t+2,n,s,i):(n.errors.push(`Option --${o} requires a value`),t+1)}return n.options[a.name]=!0,t+1}return i.strict?n.errors.push(`Unknown option: --${o}`):i.allowUnknown!==!1&&(n.options[o]=!0),t+1}function gg(e,t,r,n,s,i){let o=e.slice(1);if(o.includes("=")){let a=o.indexOf("="),c=o.slice(0,a),l=o.slice(a+1),d=Zs(c,s);return d?Wr(d.name,l,t+1,n,s,i):(i.strict?n.errors.push(`Unknown option: -${c}`):i.allowUnknown!==!1&&(n.options[c]=Kr(Ge(l))),t+1)}if(o.length===1){let a=Zs(o,s);if(a){if(a.type!=="boolean"){let c=r[t+1];return It(c)?Wr(a.name,c,t+2,n,s,i):(n.errors.push(`Option -${o} requires a value`),t+1)}return n.options[a.name]=!0,t+1}if(i.strict)n.errors.push(`Unknown option: -${o}`);else if(i.allowUnknown!==!1){let c=r[t+1];if(It(c))return n.options[o]=Kr(Ge(c)),t+2;n.options[o]=!0}return t+1}for(let a of o){let c=Zs(a,s);c?c.type==="boolean"?n.options[c.name]=!0:n.errors.push(`Option -${a} requires a value`):i.strict?n.errors.push(`Unknown option: -${a}`):i.allowUnknown!==!1&&(n.options[a]=!0)}return t+1}function Wr(e,t,r,n,s,i){let o=s.get(e);if(o){if(o.choices){let c=o.type?ze(Ge(t),o.type):Ge(t);if(!o.choices.includes(c))return n.errors.push(`Invalid value for '${e}': '${t}'. Allowed: ${o.choices.join(", ")}`),r}let a=o.type?ze(Ge(t),o.type):Ge(t);if(o.type==="array"){let c=n.options[e];Array.isArray(c)?c.push(...a):n.options[e]=a}else n.options[e]=a}else i.strict?n.errors.push(`Unknown option: --${e}`):i.allowUnknown!==!1&&(n.options[e]=Kr(Ge(t)));return r}function yg(e,t=!1){let r=new Map,n=Object.entries(e).sort(([i],[o])=>i.localeCompare(o)),s=new Set;for(let[,i]of n)i.short&&s.add(i.short);for(let[i,o]of n){let a=o.short??"";t&&!a&&(a=bg(i,s),a&&s.add(a));let c={name:i,short:a,aliases:o.aliases??[],type:o.type??"string",description:o.description??"",required:o.required??!1,hidden:o.hidden??!1,negatable:o.negatable??!0,default:o.default,choices:o.choices,env:o.env,validate:o.validate};r.set(i,c);for(let l of c.aliases)r.set(l,c)}return r}function bg(e,t){for(let r of e){if(!/[a-zA-Z]/.test(r))continue;let n=r.toLowerCase();if(!t.has(n))return n;let s=r.toUpperCase();if(!t.has(s))return s}return""}function Zs(e,t){for(let r of t.values())if(r.short===e||r.aliases.includes(e))return r}function wg(e,t,r){for(let n of r.values())if(e.options[n.name]===void 0)if(n.env&&process.env[n.env]!==void 0){let s=process.env[n.env];e.options[n.name]=n.type?ze(s,n.type):s}else n.default!==void 0&&(e.options[n.name]=n.default);for(let n of t.positional??[])e.positional[n.name]===void 0&&n.default!==void 0&&(e.positional[n.name]=n.default)}function Eg(e,t,r){if(t.options)for(let[n,s]of Object.entries(t.options))s.required&&e.options[n]===void 0&&e.errors.push(`Missing required option: --${n}`);for(let n of r)n.required&&e.positional[n.name]===void 0&&e.errors.push(`Missing required argument: <${n.name}>`)}function Tg(e,t,r){for(let n of r.values()){let s=e.options[n.name];if(n.validate&&s!==void 0){let i=n.validate(s);i!==!0&&e.errors.push(i)}}for(let n of t.positional??[]){let s=e.positional[n.name];if(n.validate&&s!==void 0){let i=n.validate(s);i!==!0&&e.errors.push(i)}}}function _g(e){return/^-\d+(\.\d+)?$/.test(e)}var ei=class extends Error{flag;known;constructor(t,r){super(`unknown flag '${t}'; expected one of: ${r.join(", ")}`),this.name="UnknownFlagError",this.flag=t,this.known=r}};function kg(e){let t={};for(let[r,n]of Object.entries(e))t[r]={type:n.kind==="boolean"?"boolean":"string",...r.length===1?{short:r}:{},...n.aliases===void 0?{}:{aliases:n.aliases}};return t}function vg(e,t){let r=new Map;for(let[s,i]of Object.entries(t))if(!(i.kind!=="value"||i.type!=="array")){r.set(s,s);for(let o of i.aliases??[])r.set(o,s)}let n=new Map;for(let s=0;s<e.length;s+=1){let i=e[s];if(i==="--")break;let o=i.match(/^--([^=]+)(?:=(.*))?$/)??i.match(/^-([^=])(?:=(.*))?$/);if(o===null)continue;let a=r.get(o[1]);if(a===void 0)continue;let c=o[2];if(c===void 0&&It(e[s+1])&&(c=e[s+1],s+=1),c===void 0)continue;let l=n.get(a)??[];l.push(c),n.set(a,l)}return n}function ti(e,t,r={}){let s=Rl({options:kg(t),separators:{},allowUnknown:!0}).parse([...e]),i={},o=vg(e,t),a=s.errors.find(c=>/^Option --?\S+ requires a value$/.test(c));if(a!==void 0)throw new Error(a.replace(/^Option /,""));if(s.errors.length>0)throw new Error(s.errors[0]);if(r.unknownFlags==="error"){let c=new Set(Object.keys(t));for(let l of Object.keys(s.options))if(!c.has(l))throw new ei(l.length===1?`-${l}`:`--${l}`,Object.keys(t).map(d=>d.length===1?`-${d}`:`--${d}`))}for(let[c,l]of Object.entries(t)){let d=s.options[c];d!==void 0&&(l.kind==="boolean"?i[c]=d:l.type==="array"?i[c]=(o.get(c)??[]).map(p=>l.coerce(p)):i[c]=l.coerce(String(d)))}return{values:i,positionals:s.rest}}var gp=At(qo(),1);import{readFileSync as XE,readdirSync as ZE}from"node:fs";import{basename as eT,join as tT}from"node:path";var Fe=class extends Error{file;constructor(t,r){super(`${t}: ${r}`),this.name="ChangesetParseError",this.file=t}},mp={patch:0,minor:1,major:2};function Wn(e){let t;try{t=ZE(e).filter(s=>s.endsWith(".md")&&s!=="README.md").sort((s,i)=>s.localeCompare(i))}catch(s){if(oT(s))return nT();throw s}let r=t.map(s=>rT(s,XE(tT(e,s),"utf8"))),n={major:0,minor:0,patch:0};for(let s of r)n[s.impact]+=1;return{changes:r,pending:n}}function rT(e,t){let r=eT(e),n=/^---[\t ]*\r?\n([\s\S]*?)\r?\n---[\t ]*(?:\r?\n|$)([\s\S]*)$/.exec(t.replace(/^\uFEFF/,""));if(n===null)throw new Fe(r,"expected YAML frontmatter between --- delimiters");let s;try{s=(0,gp.parse)(n[1],{uniqueKeys:!0})}catch(l){throw new Fe(r,`invalid YAML frontmatter: ${aT(l)}`)}if(!iT(s)||Object.keys(s).length===0)throw new Fe(r,"frontmatter must name at least one package");let i=[];for(let[l,d]of Object.entries(s)){if(l.trim()==="")throw new Fe(r,"frontmatter contains an empty package name");if(!sT(d))throw new Fe(r,`package ${JSON.stringify(l)} has invalid impact ${JSON.stringify(d)}; expected major, minor, or patch`);i.push({packageName:l,impact:d})}let o=n[2].trim();if(o==="")throw new Fe(r,"markdown body must not be empty");let a=o.split(/\r?\n/,1)[0].trim(),c=i.reduce((l,d)=>mp[d.impact]>mp[l]?d.impact:l,"patch");return{file:r,summary:a,body:o,impact:c,releases:i}}function nT(){return{changes:[],pending:{major:0,minor:0,patch:0}}}function sT(e){return e==="major"||e==="minor"||e==="patch"}function iT(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oT(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function aT(e){return e instanceof Error?e.message:String(e)}var cT={key:"release view",budget:"rest"},lT={key:"release create",budget:"rest"},uT={key:"release asset upload",budget:"rest"},dT={key:"release version-pr list",budget:"rest"},pT={key:"release version-pr create",budget:"rest"},fT={key:"release version-pr update",budget:"rest"},hT={key:"release version-pr view",budget:"rest"};function Ep(e){let t=bp(e.owner,"GitHub owner"),r=bp(e.repository,"GitHub repository"),n=e.actor??"release-engine",s=`${t}/${r}`;return{async upsertVersionPullRequest(i){let o=await e.client.conditionalRest({cacheKey:`release-version-pr-list:${s}:${i.base}:${i.head}`,route:"GET /repos/{owner}/{repo}/pulls",parameters:{owner:t,repo:r,state:"open",base:i.base,head:`${t}:${i.head}`,per_page:2},operation:dT,actor:n}),a=mT(o.data);if(a.length>1)throw new Error(`repository has multiple open Version PRs for ${i.head}`);if(a.length===1){let l=a[0],d=await e.client.conditionalRest({cacheKey:`release-version-pr-update:${s}:${l.number}`,route:"PATCH /repos/{owner}/{repo}/pulls/{pull_number}",parameters:{owner:t,repo:r,pull_number:l.number,title:i.title,body:i.body},operation:fT,actor:n});return{number:Do(d.data).number,created:!1}}let c=await e.client.conditionalRest({cacheKey:`release-version-pr-create:${s}:${i.head}`,route:"POST /repos/{owner}/{repo}/pulls",parameters:{owner:t,repo:r,title:i.title,body:i.body,head:i.head,base:i.base},operation:pT,actor:n});return{number:Do(c.data).number,created:!0}},async findVersionPullRequest(i){try{let o=await e.client.conditionalRest({cacheKey:`release-version-pr:${s}:${i}`,route:"GET /repos/{owner}/{repo}/pulls/{pull_number}",parameters:{owner:t,repo:r,pull_number:i},operation:hT,actor:n});return Do(o.data)}catch(o){if(wp(o)===404)return null;throw o}},async findByTag(i){try{let o=await e.client.conditionalRest({cacheKey:`release:${s}:${i}`,route:"GET /repos/{owner}/{repo}/releases/tags/{tag}",parameters:{owner:t,repo:r,tag:i},operation:cT,actor:n});return yp(o.data)}catch(o){if(wp(o)===404)return null;throw o}},async create(i){let o=await e.client.conditionalRest({cacheKey:`release-create:${s}:${i.tag}`,route:"POST /repos/{owner}/{repo}/releases",parameters:{owner:t,repo:r,tag_name:i.tag,target_commitish:i.targetCommitish,name:i.name,body:i.body,draft:!1,prerelease:i.prerelease},operation:lT,actor:n});return yp(o.data)},async uploadAsset(i){await e.client.conditionalRest({cacheKey:`release-asset:${s}:${i.releaseId}:${i.name}`,route:gT(i.uploadUrl),parameters:{name:i.name,data:i.data,headers:{"content-type":i.contentType,"content-length":i.data.byteLength}},operation:uT,actor:n})}}}function mT(e){if(!Array.isArray(e))throw new Error("GitHub returned an invalid Version PR list");return e.map(t=>{if(!St(t)||!zn(t.number))throw new Error("GitHub returned an invalid Version PR list");return{number:t.number}})}function Do(e){if(!St(e)||!zn(e.number)||!St(e.head))throw new Error("GitHub returned an invalid Version PR payload");if(typeof e.body!="string"||typeof e.head.sha!="string"||typeof e.merged!="boolean")throw new Error("GitHub returned an invalid Version PR payload");let t=e.merge_commit_sha;if(t!==null&&typeof t!="string")throw new Error("GitHub returned an invalid Version PR merge commit");return{number:e.number,body:e.body,headCommit:e.head.sha,merged:e.merged,mergeCommit:t}}function yp(e){if(!St(e)||!zn(e.id))throw new Error("GitHub returned an invalid Release payload");if(typeof e.prerelease!="boolean")throw new Error("GitHub returned an invalid Release prerelease marking");let t=Array.isArray(e.assets)?e.assets.map(r=>{if(!St(r)||!zn(r.id)||typeof r.name!="string")throw new Error("GitHub returned an invalid Release asset payload");return{id:r.id,name:r.name}}):[];return{id:e.id,tag:dr(e,"tag_name"),targetCommitish:dr(e,"target_commitish"),name:dr(e,"name"),body:dr(e,"body"),prerelease:e.prerelease,assets:t,uploadUrl:dr(e,"upload_url")}}function gT(e){let t=e.split("{")[0]??"";if(!/^https?:\/\/\S+\/assets$/.test(t))throw new Error(`GitHub returned an unusable Release upload_url: ${e}`);return`POST ${t}{?name}`}function dr(e,t){let r=e[t];if(typeof r!="string")throw new Error(`GitHub Release payload has no ${t}`);return r}function bp(e,t){let r=e.trim();if(r==="")throw new Error(`${t} must not be empty`);return r}function zn(e){return Number.isSafeInteger(e)&&e>0}function wp(e){return St(e)&&typeof e.status=="number"?e.status:void 0}function St(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var jo="<!-- red-release-wait:v1 -->",Tp={key:"release wait read",budget:"rest"},Fo={key:"release wait write",budget:"rest"},yT={key:"release wait alert search",budget:"search"};function vp(e){let t=kp(e.owner,"GitHub owner"),r=kp(e.repository,"GitHub repository"),n=e.actor??"release-wait",s=`${t}/${r}`,i=(o,a,c,l=Tp)=>e.client.conditionalRest({cacheKey:o,route:a,parameters:c,operation:l,actor:n});return{async findOpenVersionPullRequest(){let o=await i(`release-wait-pr:${s}`,"GET /repos/{owner}/{repo}/pulls",{owner:t,repo:r,state:"open",base:"main",head:`${t}:red-release/version-pr`,per_page:2});if(!Array.isArray(o.data)||o.data.length===0)return null;if(o.data.length>1)throw new Error("repository has multiple open Version PRs");let a=fr(o.data[0],"number"),c=await i(`release-wait-pr:${s}:${a}`,"GET /repos/{owner}/{repo}/pulls/{pull_number}",{owner:t,repo:r,pull_number:a});return bT(c.data)},async listActionRequiredRuns(o){return(await e.client.conditionalPaginate({cacheKey:`release-wait-runs:${s}:${o.headCommit}`,route:"GET /repos/{owner}/{repo}/actions/runs",parameters:{owner:t,repo:r,branch:o.head,head_sha:o.headCommit,status:"action_required"},operation:Tp,actor:n})).data.map(wT)},async listRequiredContexts(o){try{let a=await i(`release-wait-required:${s}:${o.base}`,"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks",{owner:t,repo:r,branch:o.base});if(!Bo(a.data))throw new Error("GitHub returned invalid required checks");let c=kT(a.data.contexts),l=Array.isArray(a.data.checks)?a.data.checks.map(d=>se(ae(d,"required check"),"context")):[];return[...new Set([...c,...l])]}catch(a){if(vT(a)===404)return[];throw a}},async listChecks(o){let[a,c]=await Promise.all([i(`release-wait-check-runs:${s}:${o.headCommit}`,"GET /repos/{owner}/{repo}/commits/{ref}/check-runs",{owner:t,repo:r,ref:o.headCommit,per_page:100}),i(`release-wait-statuses:${s}:${o.headCommit}`,"GET /repos/{owner}/{repo}/commits/{ref}/status",{owner:t,repo:r,ref:o.headCommit,per_page:100})]),l=ae(a.data,"check-runs response"),d=ae(c.data,"status response"),p=Array.isArray(l.check_runs)?l.check_runs:[],f=Array.isArray(d.statuses)?d.statuses:[];return[...p.map(ET),...f.map(TT)]},async findOpenAlert(){let o=await i(`release-wait-alert:${s}`,"GET /search/issues",{q:`repo:${s} is:issue is:open in:title "Release wait:"`,per_page:2},yT),a=ae(o.data,"release alert search"),l=(Array.isArray(a.items)?a.items:[]).filter(d=>{let p=ae(d,"release alert");return typeof p.body=="string"&&p.body.includes(jo)});if(l.length>1)throw new Error("repository has multiple open release-wait alerts");return l.length===0?null:_T(l[0])},async openAlert(o){let a=await i(`release-wait-alert-create:${s}`,"POST /repos/{owner}/{repo}/issues",{owner:t,repo:r,title:o.title,body:o.body},Fo);return{number:fr(a.data,"number")}},async updateAlert(o,a){await i(`release-wait-alert-update:${s}:${o}`,"PATCH /repos/{owner}/{repo}/issues/{issue_number}",{owner:t,repo:r,issue_number:o,title:a.title,body:a.body},Fo)},async closeAlert(o){await i(`release-wait-alert-close:${s}:${o}`,"PATCH /repos/{owner}/{repo}/issues/{issue_number}",{owner:t,repo:r,issue_number:o,state:"closed"},Fo)}}}async function Sp(e){let t=await e.github.findOpenVersionPullRequest();if(t===null)return{state:"no-version-pr",signal:await pr(e.github)};let r=(await e.github.listActionRequiredRuns(t)).filter(h=>h.headCommit===t.headCommit);if(r.length>0){let h=r.reduce((R,O)=>Date.parse(O.createdAt)<Date.parse(R.createdAt)?O:R),w=`Release wait: workflow approval needed for Version PR #${t.number}`,m=[jo,"## Human action required","",`${r.length} workflow runs are waiting for approval on Version PR #${t.number}.`,`The oldest has waited since ${new Date(h.createdAt).toISOString()}.`,"","Approve the pending workflow runs from the Actions page. The approval gate remains enabled.",""].join(`
|
|
177
177
|
`);return{state:"awaiting-approval",signal:await _p(e.github,{title:w,body:m}),pullRequest:t.number,runCount:r.length}}let n=await e.github.listRequiredContexts(t),s=await e.github.listChecks(t),i=new Set(s.map(h=>h.name)),o=n.filter(h=>!i.has(h)),a=new Set(n),c=s.filter(h=>a.has(h.name)&&h.status==="failure").map(h=>h.name),l=s.filter(h=>a.has(h.name)&&h.status==="pending").map(h=>h.name);if(o.length===0&&c.length>0)return{state:"checks-failed",signal:await pr(e.github),pullRequest:t.number,failedContexts:c};if(o.length===0&&l.length>0)return{state:"checks-pending",signal:await pr(e.github),pullRequest:t.number,pendingContexts:l};if(o.length===0&&t.mergeState.toLowerCase()==="behind")return{state:"behind-base",signal:await pr(e.github),pullRequest:t.number};if(o.length===0)return{state:"clear",signal:await pr(e.github),pullRequest:t.number};let d=`Release wait: checks never started for Version PR #${t.number}`,p=[jo,"## Release checks never started","",`Version PR #${t.number} has no result for required contexts: ${o.join(", ")}.`,"No workflow run is awaiting approval, so this is distinct from an approval-held release.",""].join(`
|
|
178
|
-
`);return{state:"required-contexts-missing",signal:await _p(e.github,{title:d,body:p}),pullRequest:t.number,missingContexts:o}}async function _p(e,t){let r=await e.findOpenAlert();return r===null?(await e.openAlert(t),"opened"):(await e.updateAlert(r.number,t),"updated")}async function pr(e){let t=await e.findOpenAlert();return t===null?"none":(await e.closeAlert(t.number),"resolved")}function bT(e){let t=
|
|
178
|
+
`);return{state:"required-contexts-missing",signal:await _p(e.github,{title:d,body:p}),pullRequest:t.number,missingContexts:o}}async function _p(e,t){let r=await e.findOpenAlert();return r===null?(await e.openAlert(t),"opened"):(await e.updateAlert(r.number,t),"updated")}async function pr(e){let t=await e.findOpenAlert();return t===null?"none":(await e.closeAlert(t.number),"resolved")}function bT(e){let t=ae(e,"Version PR"),r=ae(t.base,"Version PR base"),n=ae(t.head,"Version PR head");return{number:fr(t,"number"),base:se(r,"ref"),head:se(n,"ref"),headCommit:se(n,"sha"),mergeState:se(t,"mergeable_state")}}function wT(e){let t=ae(e,"workflow run");return{id:fr(t,"id"),name:se(t,"name"),headCommit:se(t,"head_sha"),createdAt:se(t,"created_at")}}function ET(e){let t=ae(e,"check run"),r=se(t,"status"),n=typeof t.conclusion=="string"?t.conclusion:null;return{name:se(t,"name"),status:r!=="completed"?"pending":n==="success"||n==="neutral"||n==="skipped"?"success":"failure"}}function TT(e){let t=ae(e,"commit status"),r=se(t,"state");return{name:se(t,"context"),status:r==="success"?"success":r==="pending"?"pending":"failure"}}function _T(e){let t=ae(e,"release alert");return{number:fr(t,"number"),title:se(t,"title"),body:se(t,"body")}}function ae(e,t){if(!Bo(e))throw new Error(`GitHub returned an invalid ${t}`);return e}function se(e,t){let r=e[t];if(typeof r!="string")throw new Error(`GitHub payload has no ${t}`);return r}function fr(e,t){let n=ae(e,"payload")[t];if(!Number.isSafeInteger(n)||n<=0)throw new Error(`GitHub payload has no ${t}`);return n}function kT(e){if(e===void 0)return[];if(!Array.isArray(e)||e.some(t=>typeof t!="string"))throw new Error("GitHub returned invalid required check contexts");return e}function kp(e,t){let r=e.trim();if(r==="")throw new Error(`${t} must not be empty`);return r}function vT(e){return Bo(e)&&typeof e.status=="number"?e.status:void 0}function Bo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{execFileSync as y_}from"node:child_process";import{mkdtempSync as Bp,readFileSync as Up,rmSync as Xo}from"node:fs";import{tmpdir as Mp}from"node:os";import{join as st}from"node:path";import{existsSync as ST,mkdirSync as RT,mkdtempSync as AT,renameSync as GT,rmSync as OT,writeFileSync as Uo}from"node:fs";import{basename as PT,dirname as CT,join as tt,resolve as $T}from"node:path";var Vo=["major","minor","patch"],xT={major:"Major (breaking changes)",minor:"Minor changes",patch:"Patch changes"};function IT(e){let t=NT(e);return{manifest:t,notes:LT(t),json:`${JSON.stringify(t,null,2)}
|
|
179
179
|
`,toon:jT(He(t))}}function Ho(e){let t=IT(e),r=$T(e.outputDirectory);if(ST(r))throw new Error(`release artifact directory already exists: ${e.outputDirectory}`);let n=CT(r);RT(n,{recursive:!0});let s=AT(tt(n,`.${PT(r)}-`));try{Uo(tt(s,"release-notes.md"),t.notes,"utf8"),Uo(tt(s,"release-manifest.json"),`${JSON.stringify(t.manifest,null,2)}
|
|
180
180
|
`,"utf8"),Uo(tt(s,"release-manifest.toon"),t.toon,"utf8"),GT(s,r)}catch(i){throw OT(s,{recursive:!0,force:!0}),i}return{directory:r,notesPath:tt(r,"release-notes.md"),jsonManifestPath:tt(r,"release-manifest.json"),toonManifestPath:tt(r,"release-manifest.toon")}}function NT(e){if(e.version.trim()==="")throw new Error("release version must not be empty");FT(e.date);let t={major:[],minor:[],patch:[]};for(let r of[...e.changes].sort(qT)){let n=Mo(r.authors,`${r.file} author`),s=Rp(r.pullRequests,r.file),i=Mo(r.releases.map(o=>o.packageName),`${r.file} package`);t[r.impact].push({file:r.file,summary:r.summary,body:r.body,packages:i,authors:n,pullRequests:s})}return{version:e.version,date:e.date,changes:t,authors:Mo(e.changes.flatMap(r=>r.authors),"release author"),pullRequests:Rp(e.changes.flatMap(r=>r.pullRequests),"release")}}function LT(e){let t=[`# Release ${e.version}`,"",`Released ${e.date}.`];for(let r of Vo){let n=e.changes[r];if(n.length!==0){t.push("",`## ${xT[r]}`,"");for(let s of n){let i=[s.pullRequests.map(a=>`#${a}`).join(", "),s.authors.join(", ")].filter(a=>a!=="").join(" \u2014 ");t.push(`- **${s.summary}**${i===""?"":` (${i})`}`);let o=DT(s.body,s.summary);o!==""&&t.push("",...o.split(`
|
|
181
181
|
`).map(a=>` ${a}`))}}}return`${t.join(`
|
|
@@ -188,10 +188,10 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
|
|
|
188
188
|
`)?`\r
|
|
189
189
|
`:`
|
|
190
190
|
`;return`${JSON.stringify(n,null,s).replaceAll(`
|
|
191
|
-
`,i)}${i}`}function c_(e,t,r){let n=!1,s=Cp(t,"package",r,()=>{n=!0}),i=Cp(s,"workspace.package",r,()=>{n=!0});if(!n)throw new Error(`Cargo version surface ${e} has no string version`);return i}function Cp(e,t,r,n){let s=Qn(e,t);if(s===void 0)return e;let o=e.slice(s.start,s.end).replace(/^(\s*version\s*=\s*)(["'])([^"'\r\n]+)\2/m,(a,c,l)=>(n(),`${c}${l}${r}${l}`));return`${e.slice(0,s.start)}${o}${e.slice(s.end)}`}function l_(e,t,r){let n=XT(t,{cwd:e,shell:!0,encoding:"utf8",env:{...process.env,RED_RELEASE_VERSION:r}});if(n.error!==void 0)throw new Error(`release sync command failed: ${n.error.message}`);if(n.status!==0){let s=n.stderr.trim()||n.stdout.trim()||`exit ${n.status??"unknown"}`;throw new Error(`release sync command failed: ${s}`)}}function u_(e){let t=e.workspaces;return Ip(t)?t:rt(t)&&Ip(t.packages)?t.packages:[]}function d_(e){let t=Qn(e,"workspace");if(t===void 0)return[];let r=e.slice(t.start,t.end),n=/(?:^|\n)\s*members\s*=\s*\[([\s\S]*?)\]/m.exec(r);if(n===null)return[];let s=[];for(let i of n[1].matchAll(/["']([^"']+)["']/g))s.push(i[1]);return s}function Dp(e,t,r){if(t.startsWith("!"))return[];let n=t.replaceAll("\\","/").replace(/\/$/,"");return YT(`${n}/${r}`,{cwd:e,exclude:["**/node_modules/**","**/target/**"]}).map(s=>s.replaceAll(t_,"/"))}function p_(e){return $p(e,"package")||$p(e,"workspace.package")}function $p(e,t){let r=Qn(e,t);return r===void 0?!1:/^\s*version\s*=\s*["'][^"'\r\n]+["']/m.test(e.slice(r.start,r.end))}function f_(e){let t=Qn(e,"package");if(t!==void 0)return/^\s*name\s*=\s*["']([^"'\r\n]+)["']/m.exec(e.slice(t.start,t.end))?.[1]}function Qn(e,t){let r=new RegExp(`^\\s*\\[${g_(t)}\\]\\s*(?:#.*)?$`,"m").exec(e);if(r===null||r.index===void 0)return;let n=r.index+r[0].length,s=/^\s*\[[^\]]+\]\s*(?:#.*)?$/m.exec(e.slice(n));return{start:n,end:s===null?e.length:n+s.index}}function xp(e,t){try{let r=JSON.parse(mr(e,"utf8"));if(!rt(r))throw new Error("manifest must be an object");return r}catch(r){throw new Error(`cannot parse workspace manifest ${t}: ${Xn(r)}`)}}function h_(e,t){if(typeof e!="string"||e.trim()==="")throw ie(`${t} must be a non-empty string`);if(ZT(e))throw ie(`${t} must be relative to the repository`);let r=e.replaceAll("\\","/").replace(/^\.\//,""),n=Yn("/repo",r);if(e_("/repo",n).startsWith(".."))throw ie(`${t} must stay inside the repository`);return r}function Fp(e,t=""){let r=[];for(let[n,s]of Object.entries(e)){let i=t===""?n:`${t}.${n}`;r.push(i),rt(s)&&r.push(...Fp(s,i))}return r}function m_(e){if(Pp.has(e))return!0;for(let t of Pp)if(e.startsWith(`${t}.`))return!0;return!1}function ie(e){return new Error(`invalid release config: ${e}`)}function Ip(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function rt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function g_(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jp(e,t){return e<t?-1:e>t?1:0}function Xn(e){return e instanceof Error?e.message:String(e)}var Vp="red-skills-release[bot]",b_="41898282+github-actions[bot]@users.noreply.github.com",gr="red-release/version-pr",Hp="red-release-plan:v1";async function Kp(e){if(e.event.kind==="push"&&e.event.commitAuthor===Vp)return{kind:"ignored",reason:"release-bump"};let t=Qo(e.repoRoot);if(e.event.kind==="release-candidate"){if(!t.prerelease)throw new Error("RC graduation is disabled by release.prerelease");if(t.trigger!=="version-pr")throw new Error("RC graduation requires the version-pr release trigger");return __(e,e.event.number)}if(e.event.kind==="version-pr-merged")return T_(e,e.event.number);let r=Wn(st(e.repoRoot,".changeset"));if(r.changes.length===0)return{kind:"idle",reason:"empty-queue"};let n=w_(e,r,t.scheme);if(t.trigger==="auto")return Wp(e.repoRoot,n,r),
|
|
191
|
+
`,i)}${i}`}function c_(e,t,r){let n=!1,s=Cp(t,"package",r,()=>{n=!0}),i=Cp(s,"workspace.package",r,()=>{n=!0});if(!n)throw new Error(`Cargo version surface ${e} has no string version`);return i}function Cp(e,t,r,n){let s=Qn(e,t);if(s===void 0)return e;let o=e.slice(s.start,s.end).replace(/^(\s*version\s*=\s*)(["'])([^"'\r\n]+)\2/m,(a,c,l)=>(n(),`${c}${l}${r}${l}`));return`${e.slice(0,s.start)}${o}${e.slice(s.end)}`}function l_(e,t,r){let n=XT(t,{cwd:e,shell:!0,encoding:"utf8",env:{...process.env,RED_RELEASE_VERSION:r}});if(n.error!==void 0)throw new Error(`release sync command failed: ${n.error.message}`);if(n.status!==0){let s=n.stderr.trim()||n.stdout.trim()||`exit ${n.status??"unknown"}`;throw new Error(`release sync command failed: ${s}`)}}function u_(e){let t=e.workspaces;return Ip(t)?t:rt(t)&&Ip(t.packages)?t.packages:[]}function d_(e){let t=Qn(e,"workspace");if(t===void 0)return[];let r=e.slice(t.start,t.end),n=/(?:^|\n)\s*members\s*=\s*\[([\s\S]*?)\]/m.exec(r);if(n===null)return[];let s=[];for(let i of n[1].matchAll(/["']([^"']+)["']/g))s.push(i[1]);return s}function Dp(e,t,r){if(t.startsWith("!"))return[];let n=t.replaceAll("\\","/").replace(/\/$/,"");return YT(`${n}/${r}`,{cwd:e,exclude:["**/node_modules/**","**/target/**"]}).map(s=>s.replaceAll(t_,"/"))}function p_(e){return $p(e,"package")||$p(e,"workspace.package")}function $p(e,t){let r=Qn(e,t);return r===void 0?!1:/^\s*version\s*=\s*["'][^"'\r\n]+["']/m.test(e.slice(r.start,r.end))}function f_(e){let t=Qn(e,"package");if(t!==void 0)return/^\s*name\s*=\s*["']([^"'\r\n]+)["']/m.exec(e.slice(t.start,t.end))?.[1]}function Qn(e,t){let r=new RegExp(`^\\s*\\[${g_(t)}\\]\\s*(?:#.*)?$`,"m").exec(e);if(r===null||r.index===void 0)return;let n=r.index+r[0].length,s=/^\s*\[[^\]]+\]\s*(?:#.*)?$/m.exec(e.slice(n));return{start:n,end:s===null?e.length:n+s.index}}function xp(e,t){try{let r=JSON.parse(mr(e,"utf8"));if(!rt(r))throw new Error("manifest must be an object");return r}catch(r){throw new Error(`cannot parse workspace manifest ${t}: ${Xn(r)}`)}}function h_(e,t){if(typeof e!="string"||e.trim()==="")throw ie(`${t} must be a non-empty string`);if(ZT(e))throw ie(`${t} must be relative to the repository`);let r=e.replaceAll("\\","/").replace(/^\.\//,""),n=Yn("/repo",r);if(e_("/repo",n).startsWith(".."))throw ie(`${t} must stay inside the repository`);return r}function Fp(e,t=""){let r=[];for(let[n,s]of Object.entries(e)){let i=t===""?n:`${t}.${n}`;r.push(i),rt(s)&&r.push(...Fp(s,i))}return r}function m_(e){if(Pp.has(e))return!0;for(let t of Pp)if(e.startsWith(`${t}.`))return!0;return!1}function ie(e){return new Error(`invalid release config: ${e}`)}function Ip(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function rt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function g_(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jp(e,t){return e<t?-1:e>t?1:0}function Xn(e){return e instanceof Error?e.message:String(e)}var Vp="red-skills-release[bot]",b_="41898282+github-actions[bot]@users.noreply.github.com",gr="red-release/version-pr",Hp="red-release-plan:v1";async function Kp(e){if(e.event.kind==="push"&&e.event.commitAuthor===Vp)return{kind:"ignored",reason:"release-bump"};let t=Qo(e.repoRoot);if(e.event.kind==="release-candidate"){if(!t.prerelease)throw new Error("RC graduation is disabled by release.prerelease");if(t.trigger!=="version-pr")throw new Error("RC graduation requires the version-pr release trigger");return __(e,e.event.number)}if(e.event.kind==="version-pr-merged")return T_(e,e.event.number);let r=Wn(st(e.repoRoot,".changeset"));if(r.changes.length===0)return{kind:"idle",reason:"empty-queue"};let n=w_(e,r,t.scheme);if(t.trigger==="auto")return Wp(e.repoRoot,n,r),ce(e.repoRoot,"push",e.remote??"origin",`HEAD:refs/heads/${e.baseBranch??"main"}`),Zo(e,n);E_(e,n,r);let s=await e.github.upsertVersionPullRequest({base:e.baseBranch??"main",head:gr,title:`chore(release): ${n.version}`,body:v_(n)});return{kind:"version-pr",action:s.created?"created":"updated",number:s.number,version:n.version}}function w_(e,t,r){return{version:Jn({currentVersion:R_(e.repoRoot),pending:t.pending,scheme:r,clock:e.clock}),date:e.date??new Date().toISOString().slice(0,10),changes:t.changes}}function E_(e,t,r){let n=ce(e.repoRoot,"branch","--show-current");if(n==="")throw new Error("release engine requires a named checkout branch");let s=ce(e.repoRoot,"rev-parse","HEAD");try{ce(e.repoRoot,"checkout","-B",gr,s),Wp(e.repoRoot,t,r),ce(e.repoRoot,"push","--force-with-lease",e.remote??"origin",`HEAD:refs/heads/${gr}`)}finally{ce(e.repoRoot,"checkout",n)}}function Wp(e,t,r){qp({repoRoot:e,nextVersion:t.version});for(let n of r.changes)Xo(st(e,".changeset",n.file));return ce(e,"add","--all"),ce(e,"-c",`user.name=${Vp}`,"-c",`user.email=${b_}`,"commit","-m",`chore(release): ${t.version}`),ce(e,"rev-parse","HEAD")}async function T_(e,t){let r=await e.github.findVersionPullRequest(t);if(r===null)throw new Error(`Version PR #${t} was not found`);if(!r.merged||r.mergeCommit===null)throw new Error(`Version PR #${t} has not merged`);let n=ce(e.repoRoot,"rev-parse","HEAD");if(n!==r.mergeCommit)throw new Error(`Version PR #${t} merged as ${r.mergeCommit}, but checkout is ${n}`);let s=zp(r.body);return Zo(e,s)}async function __(e,t){let r=await e.github.findVersionPullRequest(t);if(r===null)throw new Error(`Version PR #${t} was not found`);if(r.merged)throw new Error(`Version PR #${t} has already merged`);let n=e.remote??"origin";ce(e.repoRoot,"fetch",n,`refs/heads/${gr}`);let s=ce(e.repoRoot,"rev-parse","FETCH_HEAD");if(s!==r.headCommit)throw new Error(`Version PR #${t} names ${r.headCommit}, but ${gr} is ${s}`);let i=zp(r.body),o=k_(e.repoRoot,n,i.version);return Zo(e,{...i,version:o},r.headCommit,!0)}async function Zo(e,t,r,n=!1){let s=Bp(st(Mp(),"red-release-artifacts-"));try{let i=Ho({outputDirectory:st(s,"release"),version:t.version,date:t.date,changes:t.changes.map(a=>({...a,authors:[],pullRequests:[]}))}),o=await Op({repoRoot:e.repoRoot,version:t.version,artifacts:i,github:e.github,remote:e.remote,commit:r,prerelease:n});return{kind:"published",version:t.version,tag:o.tag,commit:o.commit}}finally{Xo(s,{recursive:!0,force:!0})}}function k_(e,t,r){let n=`refs/tags/v${r}-rc.`,s=ce(e,"ls-remote","--tags","--refs",t,`${n}*`),i=0;for(let o of s.split(`
|
|
192
192
|
`)){if(o==="")continue;let a=o.split(/\s+/,2)[1];if(a===void 0||!a.startsWith(n))continue;let c=Number(a.slice(n.length));Number.isSafeInteger(c)&&c>i&&(i=c)}return`${r}-rc.${i+1}`}function v_(e){let t=S_(e),r=Buffer.from(JSON.stringify(e),"utf8").toString("base64url");return`${t}
|
|
193
193
|
<!-- ${Hp} ${r} -->
|
|
194
|
-
`}function S_(e){let t=Bp(st(Mp(),"red-release-preview-"));try{let r=Ho({outputDirectory:st(t,"release"),version:e.version,date:e.date,changes:e.changes.map(n=>({...n,authors:[],pullRequests:[]}))});return Up(r.notesPath,"utf8").trimEnd()}finally{Xo(t,{recursive:!0,force:!0})}}function zp(e){let t=new RegExp(`<!-- ${Hp} ([A-Za-z0-9_-]+) -->`).exec(e);if(t===null)throw new Error("Version PR has no release plan metadata");let r;try{r=JSON.parse(Buffer.from(t[1],"base64url").toString("utf8"))}catch(n){throw new Error(`Version PR has invalid release plan metadata: ${Jp(n)}`)}if(!A_(r))throw new Error("Version PR has invalid release plan metadata");return r}function R_(e){let t;try{t=JSON.parse(Up(st(e,"package.json"),"utf8"))}catch(r){throw new Error(`cannot read current version from package.json: ${Jp(r)}`)}if(!ea(t)||typeof t.version!="string"||t.version==="")throw new Error("cannot read current version: package.json has no version");return t.version}function A_(e){return ea(e)&&typeof e.version=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(String(e.date))&&Array.isArray(e.changes)}function ea(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jp(e){return e instanceof Error?e.message:String(e)}function
|
|
194
|
+
`}function S_(e){let t=Bp(st(Mp(),"red-release-preview-"));try{let r=Ho({outputDirectory:st(t,"release"),version:e.version,date:e.date,changes:e.changes.map(n=>({...n,authors:[],pullRequests:[]}))});return Up(r.notesPath,"utf8").trimEnd()}finally{Xo(t,{recursive:!0,force:!0})}}function zp(e){let t=new RegExp(`<!-- ${Hp} ([A-Za-z0-9_-]+) -->`).exec(e);if(t===null)throw new Error("Version PR has no release plan metadata");let r;try{r=JSON.parse(Buffer.from(t[1],"base64url").toString("utf8"))}catch(n){throw new Error(`Version PR has invalid release plan metadata: ${Jp(n)}`)}if(!A_(r))throw new Error("Version PR has invalid release plan metadata");return r}function R_(e){let t;try{t=JSON.parse(Up(st(e,"package.json"),"utf8"))}catch(r){throw new Error(`cannot read current version from package.json: ${Jp(r)}`)}if(!ea(t)||typeof t.version!="string"||t.version==="")throw new Error("cannot read current version: package.json has no version");return t.version}function A_(e){return ea(e)&&typeof e.version=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(String(e.date))&&Array.isArray(e.changes)}function ea(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jp(e){return e instanceof Error?e.message:String(e)}function ce(e,...t){try{return y_("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch(r){let n=ea(r)&&typeof r.stderr=="string"?r.stderr.trim():"";throw new Error(`git ${t[0]??"command"} failed${n===""?"":`: ${n}`}`)}}function Yp(e){return e.queue.changes.length===0?{outcome:"no-release",currentVersion:e.currentVersion,changes:[]}:{outcome:"pending-release",currentVersion:e.currentVersion,nextVersion:Jn({currentVersion:e.currentVersion,pending:e.queue.pending,scheme:e.scheme,clock:e.clock}),changes:e.queue.changes}}function Qp(e){let t=["Release status",`Current version: ${e.currentVersion}`];if(e.outcome==="no-release")return t.push("Outcome: no release","Pending changes: 0"),`${t.join(`
|
|
195
195
|
`)}
|
|
196
196
|
`;t.push(`Next version: ${e.nextVersion}`,`Pending changes: ${e.changes.length}`,"Changes:");for(let r of e.changes){let n=r.releases.map(s=>s.packageName).join(", ");t.push(` - ${r.impact}: ${r.file} \u2014 ${r.summary} [${n}]`)}return`${t.join(`
|
|
197
197
|
`)}
|