@aventurevc/mcp-server 0.8.151 → 0.8.155

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{A as e,M as t,N as n,O as r,_ as i,c as a,d as o,j as s,k as c,l,n as u,t as d,y as f}from"../chunks/esm-kgyHmk-Q.js";import{t as p}from"../chunks/commander-BB7CDPLs.js";import{A as m,B as h,C as g,E as _,F as v,I as y,N as b,O as x,P as S,R as C,S as w,T,_ as ee,a as E,b as D,d as O,f as k,g as A,h as te,i as j,j as M,k as ne,l as re,m as ie,o as N,p as ae,s as oe,t as se,u as ce,v as le,w as ue,y as de}from"../chunks/logging-sKoOD-tO.js";import{A as fe,D as pe,E as P,S as F,T as I,_ as L,b as R,c as me,d as he,f as ge,g as z,h as _e,i as ve,k as ye,l as B,m as be,o as V,p as xe,r as Se,s as Ce,u as H,v as U,w as W,x as we,y as G}from"../chunks/person-owner-BJgNYLKX.js";import{$ as Te,$n as Ee,$t as De,A as Oe,An as ke,Ar as Ae,At as je,B as Me,Bn as Ne,Bt as Pe,C as Fe,Cn as Ie,Cr as Le,Ct as Re,D as ze,Dn as Be,Dr as Ve,Dt as He,E as Ue,En as We,Er as Ge,Et as Ke,F as qe,Fn as Je,Fr as Ye,Ft as Xe,G as Ze,Gn as Qe,Gt as $e,H as et,Hn as tt,Ht as nt,I as rt,In as it,Ir as at,It as ot,J as st,Jn as ct,Jt as lt,K as ut,Kn as dt,Kt as ft,L as pt,Ln as mt,Lt as ht,Mn as gt,Mt as _t,N as vt,Nn as yt,Nr as bt,Nt as xt,O as St,On as Ct,Ot as wt,P as Tt,Pn as Et,Pr as Dt,Pt as Ot,Q as kt,Qn as At,Qt as jt,R as Mt,Rn as Nt,Rr as Pt,Rt as Ft,S as It,Sn as Lt,Sr as Rt,St as zt,T as Bt,Tn as Vt,Tr as Ht,Tt as Ut,U as Wt,Un as Gt,Ut as Kt,V as qt,Vn as Jt,Vt as Yt,W as Xt,Wn as Zt,Wt as Qt,X as $t,Xn as en,Xt as tn,Y as nn,Yn as rn,Yt as an,Z as on,Zn as sn,Zt as cn,_ as ln,_n as un,_r as dn,_t as fn,a as pn,an as mn,ar as hn,at as gn,b as _n,bn as vn,br as yn,bt as bn,c as xn,cn as Sn,cr as Cn,ct as wn,d as Tn,dn as En,dr as Dn,dt as On,en as kn,er as An,et as jn,f as Mn,fn as Nn,fr as Pn,ft as Fn,g as In,gn as Ln,gr as Rn,h as zn,hn as Bn,hr as Vn,ht as Hn,i as Un,in as Wn,ir as Gn,it as Kn,j as qn,jn as Jn,jr as Yn,jt as Xn,k as Zn,kn as Qn,kr as $n,kt as er,l as tr,ln as nr,lr as rr,lt as ir,m as ar,mn as or,mr as sr,mt as cr,n as lr,nn as ur,nr as dr,nt as fr,o as pr,on as mr,or as hr,ot as gr,p as _r,pn as vr,pr as yr,pt as br,q as xr,qn as Sr,qt as Cr,r as wr,rn as Tr,rr as Er,rt as Dr,s as Or,sn as kr,sr as Ar,st as jr,t as Mr,tn as Nr,tr as Pr,tt as Fr,u as Ir,un as Lr,ur as Rr,ut as zr,v as Br,vn as Vr,vr as Hr,vt as Ur,w as Wr,wn as Gr,wr as Kr,wt as qr,x as Jr,xn as Yr,xr as Xr,xt as Zr,y as Qr,yn as $r,yr as ei,yt as ti,z as ni,zn as ri,zt as ii}from"../chunks/dist-Di4hxilB.js";import{c as ai,n as oi,r as si,s as ci,u as li}from"../chunks/result-envelope-DTzTOcab.js";import{l as ui,n as di,t as fi}from"../chunks/env-ClsLmXWa.js";import{a as pi}from"../chunks/package-DPDX5zmx.js";import{t as mi}from"../chunks/provider-catalog-7akuaOeA.js";import{C as hi,E as gi,S as _i,T as vi,h as yi,p as bi,u as xi}from"../chunks/tool-policy-XDNFtgnS.js";import{_ as Si,b as Ci,g as wi,h as Ti,i as Ei,m as Di,p as Oi,r as ki,t as Ai,v as ji,x as Mi,y as Ni}from"../chunks/contract-7P1f8pdV.js";import{n as Pi,t as Fi}from"../chunks/mcp-generation-contract-CbYroncj.js";import Ii from"crypto";import{Readable as Li}from"stream";import{Buffer as Ri}from"node:buffer";import{fileURLToPath as zi}from"node:url";import{isIP as Bi,isIPv4 as Vi,isIPv6 as Hi}from"node:net";import{createHash as Ui,randomUUID as Wi,timingSafeEqual as Gi}from"node:crypto";var Ki={name:`metric_data_point`,countItems:e=>{let t=0;for(let n of e.scopeMetrics)for(let e of n.metrics)t+=e.dataPoints.length;return t}},qi,Ji=c((()=>{(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`})(qi||={})})),K,Yi,Xi=c((()=>{(function(e){e.COUNTER=`COUNTER`,e.GAUGE=`GAUGE`,e.HISTOGRAM=`HISTOGRAM`,e.UP_DOWN_COUNTER=`UP_DOWN_COUNTER`,e.OBSERVABLE_COUNTER=`OBSERVABLE_COUNTER`,e.OBSERVABLE_GAUGE=`OBSERVABLE_GAUGE`,e.OBSERVABLE_UP_DOWN_COUNTER=`OBSERVABLE_UP_DOWN_COUNTER`})(K||={}),(function(e){e[e.HISTOGRAM=0]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=1]=`EXPONENTIAL_HISTOGRAM`,e[e.GAUGE=2]=`GAUGE`,e[e.SUM=3]=`SUM`})(Yi||={})}));function Zi(e){let t=Object.keys(e);return t.length===0?``:(t=t.sort(),JSON.stringify(t.map(t=>[t,e[t]])))}function Qi(e){return`${e.name}:${e.version??``}:${e.schemaUrl??``}`}function $i(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new ra(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}function ea(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ta(e,t){let n=0,r=e.length-1,i=e.length;for(;r>=n;){let a=n+Math.trunc((r-n)/2);e[a]<t?n=a+1:(i=a,r=a-1)}return i}function na(e,t){return e.toLowerCase()===t.toLowerCase()}var ra,ia=c((()=>{ra=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}}})),aa,oa=c((()=>{(function(e){e[e.DROP=0]=`DROP`,e[e.SUM=1]=`SUM`,e[e.LAST_VALUE=2]=`LAST_VALUE`,e[e.HISTOGRAM=3]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=4]=`EXPONENTIAL_HISTOGRAM`})(aa||={})})),sa,ca=c((()=>{oa(),sa=class{kind=aa.DROP;createAccumulation(){}merge(e,t){}diff(e,t){}toMetricData(e,t,n,r){}}}));function la(e){let t=e.map(()=>0);return t.push(0),{buckets:{boundaries:e,counts:t},sum:0,count:0,hasMinMax:!1,min:1/0,max:-1/0}}var ua,da,fa=c((()=>{oa(),Xi(),ia(),ua=class{startTime;_boundaries;_recordMinMax;_current;constructor(e,t,n=!0,r=la(t)){this.startTime=e,this._boundaries=t,this._recordMinMax=n,this._current=r}record(e){if(Number.isNaN(e))return;this._current.count+=1,this._current.sum+=e,this._recordMinMax&&(this._current.min=Math.min(e,this._current.min),this._current.max=Math.max(e,this._current.max),this._current.hasMinMax=!0);let t=ta(this._boundaries,e);this._current.buckets.counts[t]+=1}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},da=class{kind=aa.HISTOGRAM;_boundaries;_recordMinMax;constructor(e,t){this._boundaries=e,this._recordMinMax=t}createAccumulation(e){return new ua(e,this._boundaries,this._recordMinMax)}merge(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=i[e]+a[e];let s=1/0,c=-1/0;return this._recordMinMax&&(n.hasMinMax&&r.hasMinMax?(s=Math.min(n.min,r.min),c=Math.max(n.max,r.max)):n.hasMinMax?(s=n.min,c=n.max):r.hasMinMax&&(s=r.min,c=r.max)),new ua(e.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:n.count+r.count,sum:n.sum+r.sum,hasMinMax:this._recordMinMax&&(n.hasMinMax||r.hasMinMax),min:s,max:c})}diff(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=a[e]-i[e];return new ua(t.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:r.count-n.count,sum:r.sum-n.sum,hasMinMax:!1,min:1/0,max:-1/0})}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:Yi.HISTOGRAM,dataPoints:n.map(([t,n])=>{let i=n.toPointValue(),a=e.type===K.GAUGE||e.type===K.UP_DOWN_COUNTER||e.type===K.OBSERVABLE_GAUGE||e.type===K.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:t,startTime:n.startTime,endTime:r,value:{min:i.hasMinMax?i.min:void 0,max:i.hasMinMax?i.max:void 0,sum:a?void 0:i.sum,buckets:i.buckets,count:i.count}}})}}}})),pa,ma,ha=c((()=>{pa=class e{backing;indexBase;indexStart;indexEnd;constructor(e=new ma,t=0,n=0,r=0){this.backing=e,this.indexBase=t,this.indexStart=n,this.indexEnd=r}get offset(){return this.indexStart}get length(){return this.backing.length===0||this.indexEnd===this.indexStart&&this.at(0)===0?0:this.indexEnd-this.indexStart+1}counts(){return Array.from({length:this.length},(e,t)=>this.at(t))}at(e){let t=this.indexBase-this.indexStart;return e<t&&(e+=this.backing.length),e-=t,this.backing.countAt(e)}incrementBucket(e,t){this.backing.increment(e,t)}decrementBucket(e,t){this.backing.decrement(e,t)}trim(){for(let e=0;e<this.length;e++)if(this.at(e)!==0){this.indexStart+=e;break}else if(e===this.length-1){this.indexStart=this.indexEnd=this.indexBase=0;return}for(let e=this.length-1;e>=0;e--)if(this.at(e)!==0){this.indexEnd-=this.length-e-1;break}this._rotate()}downscale(e){this._rotate();let t=1+this.indexEnd-this.indexStart,n=1<<e,r=0,i=0;for(let e=this.indexStart;e<=this.indexEnd;){let a=e%n;a<0&&(a+=n);for(let o=a;o<n&&r<t;o++)this._relocateBucket(i,r),r++,e++;i++}this.indexStart>>=e,this.indexEnd>>=e,this.indexBase=this.indexStart}clone(){return new e(this.backing.clone(),this.indexBase,this.indexStart,this.indexEnd)}_rotate(){let e=this.indexBase-this.indexStart;e!==0&&(e>0?(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,e),this.backing.reverse(e,this.backing.length)):(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,this.backing.length+e)),this.indexBase=this.indexStart)}_relocateBucket(e,t){e!==t&&this.incrementBucket(e,this.backing.emptyBucket(t))}},ma=class e{_counts;constructor(e=[0]){this._counts=e}get length(){return this._counts.length}countAt(e){return this._counts[e]}growTo(e,t,n){let r=Array(e).fill(0);r.splice(n,this._counts.length-t,...this._counts.slice(t)),r.splice(0,t,...this._counts.slice(0,t)),this._counts=r}reverse(e,t){let n=Math.floor((e+t)/2)-e;for(let r=0;r<n;r++){let n=this._counts[e+r];this._counts[e+r]=this._counts[t-r-1],this._counts[t-r-1]=n}}emptyBucket(e){let t=this._counts[e];return this._counts[e]=0,t}increment(e,t){this._counts[e]+=t}decrement(e,t){this._counts[e]>=t?this._counts[e]-=t:this._counts[e]=0}clone(){return new e([...this._counts])}}}));function ga(e){return Ta.setFloat64(0,e),{hi:Ta.getUint32(0),lo:Ta.getUint32(4)}}function _a(e){let{hi:t}=ga(e);return((t&ya)>>20)-xa}function va(e){let{hi:t,lo:n}=ga(e);return(t&ba)===0&&n===0}var ya,ba,xa,Sa,Ca,wa,Ta,Ea=c((()=>{ya=2146435072,ba=1048575,xa=1023,Sa=-1022,Ca=xa,wa=2**-1022,Ta=new DataView(new ArrayBuffer(8))}));function Da(e,t){return e===0||e===1/0||e===-1/0||Number.isNaN(e)?e:e*2**t}function Oa(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}var ka=c((()=>{})),Aa,ja=c((()=>{Aa=class extends Error{}})),Ma,Na=c((()=>{Ea(),ka(),ja(),Ma=class{_shift;constructor(e){this._shift=-e}mapToIndex(e){return e<wa?this._minNormalLowerBoundaryIndex():_a(e)+(va(e)?-1:0)>>this._shift}lowerBoundary(e){let t=this._minNormalLowerBoundaryIndex();if(e<t)throw new Aa(`underflow: ${e} is < minimum lower boundary: ${t}`);let n=this._maxNormalLowerBoundaryIndex();if(e>n)throw new Aa(`overflow: ${e} is > maximum lower boundary: ${n}`);return Da(1,e<<this._shift)}get scale(){return this._shift===0?0:-this._shift}_minNormalLowerBoundaryIndex(){let e=Sa>>this._shift;return this._shift<2&&e--,e}_maxNormalLowerBoundaryIndex(){return Ca>>this._shift}}})),Pa,Fa=c((()=>{Ea(),ka(),ja(),Pa=class{_scale;_scaleFactor;_inverseFactor;constructor(e){this._scale=e,this._scaleFactor=Da(Math.LOG2E,e),this._inverseFactor=Da(Math.LN2,-e)}mapToIndex(e){if(e<=wa)return this._minNormalLowerBoundaryIndex()-1;if(va(e))return(_a(e)<<this._scale)-1;let t=Math.floor(Math.log(e)*this._scaleFactor),n=this._maxNormalLowerBoundaryIndex();return t>=n?n:t}lowerBoundary(e){let t=this._maxNormalLowerBoundaryIndex();if(e>=t){if(e===t)return 2*Math.exp((e-(1<<this._scale))/this._scaleFactor);throw new Aa(`overflow: ${e} is > maximum lower boundary: ${t}`)}let n=this._minNormalLowerBoundaryIndex();if(e<=n){if(e===n)return wa;if(e===n-1)return Math.exp((e+(1<<this._scale))/this._scaleFactor)/2;throw new Aa(`overflow: ${e} is < minimum lower boundary: ${n}`)}return Math.exp(e*this._inverseFactor)}get scale(){return this._scale}_minNormalLowerBoundaryIndex(){return Sa<<this._scale}_maxNormalLowerBoundaryIndex(){return(Ca+1<<this._scale)-1}}}));function Ia(e){if(e>Ra||e<La)throw new Aa(`expected scale >= ${La} && <= ${Ra}, got: ${e}`);return za[e+10]}var La,Ra,za,Ba=c((()=>{Na(),Fa(),ja(),La=-10,Ra=20,za=Array.from({length:31},(e,t)=>t>10?new Pa(t-10):new Ma(t-10))})),Va,Ha,Ua,Wa,Ga,Ka,qa=c((()=>{oa(),Xi(),u(),ha(),Ba(),ka(),Va=class e{static combine(t,n){return new e(Math.min(t.low,n.low),Math.max(t.high,n.high))}low;high;constructor(e,t){this.low=e,this.high=t}},Ha=20,Ua=160,Wa=2,Ga=class e{startTime;_maxSize;_recordMinMax;_sum;_count;_zeroCount;_min;_max;_positive;_negative;_mapping;constructor(e,t=Ua,n=!0,r=0,i=0,a=0,o=1/0,s=-1/0,c=new pa,u=new pa,d=Ia(Ha)){this.startTime=e,this._maxSize=t,this._recordMinMax=n,this._sum=r,this._count=i,this._zeroCount=a,this._min=o,this._max=s,this._positive=c,this._negative=u,this._mapping=d,this._maxSize<Wa&&(l.warn(`Exponential Histogram Max Size set to ${this._maxSize}, \
2
+ import{A as e,M as t,N as n,O as r,_ as i,c as a,d as o,j as s,k as c,l,n as u,t as d,y as f}from"../chunks/esm-kgyHmk-Q.js";import{t as p}from"../chunks/commander-BB7CDPLs.js";import{A as m,B as h,C as g,E as _,F as v,I as y,N as b,O as x,P as S,R as C,S as w,T,_ as ee,a as E,b as D,d as O,f as k,g as A,h as te,i as j,j as M,k as ne,l as re,m as ie,o as N,p as ae,s as oe,t as se,u as ce,v as le,w as ue,y as de}from"../chunks/logging-CbfQVbNI.js";import{A as fe,D as pe,E as P,S as F,T as I,_ as L,b as R,c as me,d as he,f as ge,g as z,h as _e,i as ve,k as ye,l as B,m as be,o as V,p as xe,r as Se,s as Ce,u as H,v as U,w as W,x as we,y as G}from"../chunks/person-owner-BJgNYLKX.js";import{$ as Te,$n as Ee,$t as De,A as Oe,An as ke,Ar as Ae,At as je,B as Me,Bn as Ne,Bt as Pe,C as Fe,Cn as Ie,Cr as Le,Ct as Re,D as ze,Dn as Be,Dr as Ve,Dt as He,E as Ue,En as We,Er as Ge,Et as Ke,F as qe,Fn as Je,Fr as Ye,Ft as Xe,G as Ze,Gn as Qe,Gt as $e,H as et,Hn as tt,Ht as nt,I as rt,In as it,Ir as at,It as ot,J as st,Jn as ct,Jt as lt,K as ut,Kn as dt,Kt as ft,L as pt,Ln as mt,Lt as ht,Mn as gt,Mt as _t,N as vt,Nn as yt,Nr as bt,Nt as xt,O as St,On as Ct,Ot as wt,P as Tt,Pn as Et,Pr as Dt,Pt as Ot,Q as kt,Qn as At,Qt as jt,R as Mt,Rn as Nt,Rr as Pt,Rt as Ft,S as It,Sn as Lt,Sr as Rt,St as zt,T as Bt,Tn as Vt,Tr as Ht,Tt as Ut,U as Wt,Un as Gt,Ut as Kt,V as qt,Vn as Jt,Vt as Yt,W as Xt,Wn as Zt,Wt as Qt,X as $t,Xn as en,Xt as tn,Y as nn,Yn as rn,Yt as an,Z as on,Zn as sn,Zt as cn,_ as ln,_n as un,_r as dn,_t as fn,a as pn,an as mn,ar as hn,at as gn,b as _n,bn as vn,br as yn,bt as bn,c as xn,cn as Sn,cr as Cn,ct as wn,d as Tn,dn as En,dr as Dn,dt as On,en as kn,er as An,et as jn,f as Mn,fn as Nn,fr as Pn,ft as Fn,g as In,gn as Ln,gr as Rn,h as zn,hn as Bn,hr as Vn,ht as Hn,i as Un,in as Wn,ir as Gn,it as Kn,j as qn,jn as Jn,jr as Yn,jt as Xn,k as Zn,kn as Qn,kr as $n,kt as er,l as tr,ln as nr,lr as rr,lt as ir,m as ar,mn as or,mr as sr,mt as cr,n as lr,nn as ur,nr as dr,nt as fr,o as pr,on as mr,or as hr,ot as gr,p as _r,pn as vr,pr as yr,pt as br,q as xr,qn as Sr,qt as Cr,r as wr,rn as Tr,rr as Er,rt as Dr,s as Or,sn as kr,sr as Ar,st as jr,t as Mr,tn as Nr,tr as Pr,tt as Fr,u as Ir,un as Lr,ur as Rr,ut as zr,v as Br,vn as Vr,vr as Hr,vt as Ur,w as Wr,wn as Gr,wr as Kr,wt as qr,x as Jr,xn as Yr,xr as Xr,xt as Zr,y as Qr,yn as $r,yr as ei,yt as ti,z as ni,zn as ri,zt as ii}from"../chunks/dist-JXapqWON.js";import{c as ai,n as oi,r as si,s as ci,u as li}from"../chunks/result-envelope-Fdcw8qTG.js";import{l as ui,n as di,t as fi}from"../chunks/env-DCiVOwWC.js";import{a as pi}from"../chunks/package-DPDX5zmx.js";import{t as mi}from"../chunks/provider-catalog-CwzYkNhG.js";import{C as hi,D as gi,E as _i,h as vi,p as yi,u as bi,w as xi}from"../chunks/tool-policy-whKq-oHX.js";import{_ as Si,b as Ci,g as wi,h as Ti,i as Ei,m as Di,p as Oi,r as ki,t as Ai,v as ji,x as Mi,y as Ni}from"../chunks/contract-CKU1CnbR.js";import{n as Pi,t as Fi}from"../chunks/mcp-generation-contract-w-3v3hhH.js";import Ii from"crypto";import{Readable as Li}from"stream";import{Buffer as Ri}from"node:buffer";import{fileURLToPath as zi}from"node:url";import{isIP as Bi,isIPv4 as Vi,isIPv6 as Hi}from"node:net";import{createHash as Ui,randomUUID as Wi,timingSafeEqual as Gi}from"node:crypto";var Ki={name:`metric_data_point`,countItems:e=>{let t=0;for(let n of e.scopeMetrics)for(let e of n.metrics)t+=e.dataPoints.length;return t}},qi,Ji=c((()=>{(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`})(qi||={})})),K,Yi,Xi=c((()=>{(function(e){e.COUNTER=`COUNTER`,e.GAUGE=`GAUGE`,e.HISTOGRAM=`HISTOGRAM`,e.UP_DOWN_COUNTER=`UP_DOWN_COUNTER`,e.OBSERVABLE_COUNTER=`OBSERVABLE_COUNTER`,e.OBSERVABLE_GAUGE=`OBSERVABLE_GAUGE`,e.OBSERVABLE_UP_DOWN_COUNTER=`OBSERVABLE_UP_DOWN_COUNTER`})(K||={}),(function(e){e[e.HISTOGRAM=0]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=1]=`EXPONENTIAL_HISTOGRAM`,e[e.GAUGE=2]=`GAUGE`,e[e.SUM=3]=`SUM`})(Yi||={})}));function Zi(e){let t=Object.keys(e);return t.length===0?``:(t=t.sort(),JSON.stringify(t.map(t=>[t,e[t]])))}function Qi(e){return`${e.name}:${e.version??``}:${e.schemaUrl??``}`}function $i(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new ra(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}function ea(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ta(e,t){let n=0,r=e.length-1,i=e.length;for(;r>=n;){let a=n+Math.trunc((r-n)/2);e[a]<t?n=a+1:(i=a,r=a-1)}return i}function na(e,t){return e.toLowerCase()===t.toLowerCase()}var ra,ia=c((()=>{ra=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}}})),aa,oa=c((()=>{(function(e){e[e.DROP=0]=`DROP`,e[e.SUM=1]=`SUM`,e[e.LAST_VALUE=2]=`LAST_VALUE`,e[e.HISTOGRAM=3]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=4]=`EXPONENTIAL_HISTOGRAM`})(aa||={})})),sa,ca=c((()=>{oa(),sa=class{kind=aa.DROP;createAccumulation(){}merge(e,t){}diff(e,t){}toMetricData(e,t,n,r){}}}));function la(e){let t=e.map(()=>0);return t.push(0),{buckets:{boundaries:e,counts:t},sum:0,count:0,hasMinMax:!1,min:1/0,max:-1/0}}var ua,da,fa=c((()=>{oa(),Xi(),ia(),ua=class{startTime;_boundaries;_recordMinMax;_current;constructor(e,t,n=!0,r=la(t)){this.startTime=e,this._boundaries=t,this._recordMinMax=n,this._current=r}record(e){if(Number.isNaN(e))return;this._current.count+=1,this._current.sum+=e,this._recordMinMax&&(this._current.min=Math.min(e,this._current.min),this._current.max=Math.max(e,this._current.max),this._current.hasMinMax=!0);let t=ta(this._boundaries,e);this._current.buckets.counts[t]+=1}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},da=class{kind=aa.HISTOGRAM;_boundaries;_recordMinMax;constructor(e,t){this._boundaries=e,this._recordMinMax=t}createAccumulation(e){return new ua(e,this._boundaries,this._recordMinMax)}merge(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=i[e]+a[e];let s=1/0,c=-1/0;return this._recordMinMax&&(n.hasMinMax&&r.hasMinMax?(s=Math.min(n.min,r.min),c=Math.max(n.max,r.max)):n.hasMinMax?(s=n.min,c=n.max):r.hasMinMax&&(s=r.min,c=r.max)),new ua(e.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:n.count+r.count,sum:n.sum+r.sum,hasMinMax:this._recordMinMax&&(n.hasMinMax||r.hasMinMax),min:s,max:c})}diff(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=a[e]-i[e];return new ua(t.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:r.count-n.count,sum:r.sum-n.sum,hasMinMax:!1,min:1/0,max:-1/0})}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:Yi.HISTOGRAM,dataPoints:n.map(([t,n])=>{let i=n.toPointValue(),a=e.type===K.GAUGE||e.type===K.UP_DOWN_COUNTER||e.type===K.OBSERVABLE_GAUGE||e.type===K.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:t,startTime:n.startTime,endTime:r,value:{min:i.hasMinMax?i.min:void 0,max:i.hasMinMax?i.max:void 0,sum:a?void 0:i.sum,buckets:i.buckets,count:i.count}}})}}}})),pa,ma,ha=c((()=>{pa=class e{backing;indexBase;indexStart;indexEnd;constructor(e=new ma,t=0,n=0,r=0){this.backing=e,this.indexBase=t,this.indexStart=n,this.indexEnd=r}get offset(){return this.indexStart}get length(){return this.backing.length===0||this.indexEnd===this.indexStart&&this.at(0)===0?0:this.indexEnd-this.indexStart+1}counts(){return Array.from({length:this.length},(e,t)=>this.at(t))}at(e){let t=this.indexBase-this.indexStart;return e<t&&(e+=this.backing.length),e-=t,this.backing.countAt(e)}incrementBucket(e,t){this.backing.increment(e,t)}decrementBucket(e,t){this.backing.decrement(e,t)}trim(){for(let e=0;e<this.length;e++)if(this.at(e)!==0){this.indexStart+=e;break}else if(e===this.length-1){this.indexStart=this.indexEnd=this.indexBase=0;return}for(let e=this.length-1;e>=0;e--)if(this.at(e)!==0){this.indexEnd-=this.length-e-1;break}this._rotate()}downscale(e){this._rotate();let t=1+this.indexEnd-this.indexStart,n=1<<e,r=0,i=0;for(let e=this.indexStart;e<=this.indexEnd;){let a=e%n;a<0&&(a+=n);for(let o=a;o<n&&r<t;o++)this._relocateBucket(i,r),r++,e++;i++}this.indexStart>>=e,this.indexEnd>>=e,this.indexBase=this.indexStart}clone(){return new e(this.backing.clone(),this.indexBase,this.indexStart,this.indexEnd)}_rotate(){let e=this.indexBase-this.indexStart;e!==0&&(e>0?(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,e),this.backing.reverse(e,this.backing.length)):(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,this.backing.length+e)),this.indexBase=this.indexStart)}_relocateBucket(e,t){e!==t&&this.incrementBucket(e,this.backing.emptyBucket(t))}},ma=class e{_counts;constructor(e=[0]){this._counts=e}get length(){return this._counts.length}countAt(e){return this._counts[e]}growTo(e,t,n){let r=Array(e).fill(0);r.splice(n,this._counts.length-t,...this._counts.slice(t)),r.splice(0,t,...this._counts.slice(0,t)),this._counts=r}reverse(e,t){let n=Math.floor((e+t)/2)-e;for(let r=0;r<n;r++){let n=this._counts[e+r];this._counts[e+r]=this._counts[t-r-1],this._counts[t-r-1]=n}}emptyBucket(e){let t=this._counts[e];return this._counts[e]=0,t}increment(e,t){this._counts[e]+=t}decrement(e,t){this._counts[e]>=t?this._counts[e]-=t:this._counts[e]=0}clone(){return new e([...this._counts])}}}));function ga(e){return Ta.setFloat64(0,e),{hi:Ta.getUint32(0),lo:Ta.getUint32(4)}}function _a(e){let{hi:t}=ga(e);return((t&ya)>>20)-xa}function va(e){let{hi:t,lo:n}=ga(e);return(t&ba)===0&&n===0}var ya,ba,xa,Sa,Ca,wa,Ta,Ea=c((()=>{ya=2146435072,ba=1048575,xa=1023,Sa=-1022,Ca=xa,wa=2**-1022,Ta=new DataView(new ArrayBuffer(8))}));function Da(e,t){return e===0||e===1/0||e===-1/0||Number.isNaN(e)?e:e*2**t}function Oa(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}var ka=c((()=>{})),Aa,ja=c((()=>{Aa=class extends Error{}})),Ma,Na=c((()=>{Ea(),ka(),ja(),Ma=class{_shift;constructor(e){this._shift=-e}mapToIndex(e){return e<wa?this._minNormalLowerBoundaryIndex():_a(e)+(va(e)?-1:0)>>this._shift}lowerBoundary(e){let t=this._minNormalLowerBoundaryIndex();if(e<t)throw new Aa(`underflow: ${e} is < minimum lower boundary: ${t}`);let n=this._maxNormalLowerBoundaryIndex();if(e>n)throw new Aa(`overflow: ${e} is > maximum lower boundary: ${n}`);return Da(1,e<<this._shift)}get scale(){return this._shift===0?0:-this._shift}_minNormalLowerBoundaryIndex(){let e=Sa>>this._shift;return this._shift<2&&e--,e}_maxNormalLowerBoundaryIndex(){return Ca>>this._shift}}})),Pa,Fa=c((()=>{Ea(),ka(),ja(),Pa=class{_scale;_scaleFactor;_inverseFactor;constructor(e){this._scale=e,this._scaleFactor=Da(Math.LOG2E,e),this._inverseFactor=Da(Math.LN2,-e)}mapToIndex(e){if(e<=wa)return this._minNormalLowerBoundaryIndex()-1;if(va(e))return(_a(e)<<this._scale)-1;let t=Math.floor(Math.log(e)*this._scaleFactor),n=this._maxNormalLowerBoundaryIndex();return t>=n?n:t}lowerBoundary(e){let t=this._maxNormalLowerBoundaryIndex();if(e>=t){if(e===t)return 2*Math.exp((e-(1<<this._scale))/this._scaleFactor);throw new Aa(`overflow: ${e} is > maximum lower boundary: ${t}`)}let n=this._minNormalLowerBoundaryIndex();if(e<=n){if(e===n)return wa;if(e===n-1)return Math.exp((e+(1<<this._scale))/this._scaleFactor)/2;throw new Aa(`overflow: ${e} is < minimum lower boundary: ${n}`)}return Math.exp(e*this._inverseFactor)}get scale(){return this._scale}_minNormalLowerBoundaryIndex(){return Sa<<this._scale}_maxNormalLowerBoundaryIndex(){return(Ca+1<<this._scale)-1}}}));function Ia(e){if(e>Ra||e<La)throw new Aa(`expected scale >= ${La} && <= ${Ra}, got: ${e}`);return za[e+10]}var La,Ra,za,Ba=c((()=>{Na(),Fa(),ja(),La=-10,Ra=20,za=Array.from({length:31},(e,t)=>t>10?new Pa(t-10):new Ma(t-10))})),Va,Ha,Ua,Wa,Ga,Ka,qa=c((()=>{oa(),Xi(),u(),ha(),Ba(),ka(),Va=class e{static combine(t,n){return new e(Math.min(t.low,n.low),Math.max(t.high,n.high))}low;high;constructor(e,t){this.low=e,this.high=t}},Ha=20,Ua=160,Wa=2,Ga=class e{startTime;_maxSize;_recordMinMax;_sum;_count;_zeroCount;_min;_max;_positive;_negative;_mapping;constructor(e,t=Ua,n=!0,r=0,i=0,a=0,o=1/0,s=-1/0,c=new pa,u=new pa,d=Ia(Ha)){this.startTime=e,this._maxSize=t,this._recordMinMax=n,this._sum=r,this._count=i,this._zeroCount=a,this._min=o,this._max=s,this._positive=c,this._negative=u,this._mapping=d,this._maxSize<Wa&&(l.warn(`Exponential Histogram Max Size set to ${this._maxSize}, \
3
3
  changing to the minimum size of: ${Wa}`),this._maxSize=Wa)}record(e){this.updateByIncrement(e,1)}setStartTime(e){this.startTime=e}toPointValue(){return{hasMinMax:this._recordMinMax,min:this.min,max:this.max,sum:this.sum,positive:{offset:this.positive.offset,bucketCounts:this.positive.counts()},negative:{offset:this.negative.offset,bucketCounts:this.negative.counts()},count:this.count,scale:this.scale,zeroCount:this.zeroCount}}get sum(){return this._sum}get min(){return this._min}get max(){return this._max}get count(){return this._count}get zeroCount(){return this._zeroCount}get scale(){return this._count===this._zeroCount?0:this._mapping.scale}get positive(){return this._positive}get negative(){return this._negative}updateByIncrement(e,t){if(Number.isFinite(e)){if(e>this._max&&(this._max=e),e<this._min&&(this._min=e),this._count+=t,e===0){this._zeroCount+=t;return}this._sum+=e*t,e>0?this._updateBuckets(this._positive,e,t):this._updateBuckets(this._negative,-e,t)}}merge(e){this._count===0?(this._min=e.min,this._max=e.max):e.count!==0&&(e.min<this.min&&(this._min=e.min),e.max>this.max&&(this._max=e.max)),this.startTime=e.startTime,this._sum+=e.sum,this._count+=e.count,this._zeroCount+=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._mergeBuckets(this.positive,e,e.positive,t),this._mergeBuckets(this.negative,e,e.negative,t)}diff(e){this._min=1/0,this._max=-1/0,this._sum-=e.sum,this._count-=e.count,this._zeroCount-=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._diffBuckets(this.positive,e,e.positive,t),this._diffBuckets(this.negative,e,e.negative,t)}clone(){return new e(this.startTime,this._maxSize,this._recordMinMax,this._sum,this._count,this._zeroCount,this._min,this._max,this.positive.clone(),this.negative.clone(),this._mapping)}_updateBuckets(e,t,n){let r=this._mapping.mapToIndex(t),i=!1,a=0,o=0;if(e.length===0?(e.indexStart=r,e.indexEnd=e.indexStart,e.indexBase=e.indexStart):r<e.indexStart&&e.indexEnd-r>=this._maxSize?(i=!0,o=r,a=e.indexEnd):r>e.indexEnd&&r-e.indexStart>=this._maxSize&&(i=!0,o=e.indexStart,a=r),i){let e=this._changeScale(a,o);this._downscale(e),r=this._mapping.mapToIndex(t)}this._incrementIndexBy(e,r,n)}_incrementIndexBy(e,t,n){if(n===0)return;if(e.length===0&&(e.indexStart=e.indexEnd=e.indexBase=t),t<e.indexStart){let n=e.indexEnd-t;n>=e.backing.length&&this._grow(e,n+1),e.indexStart=t}else if(t>e.indexEnd){let n=t-e.indexStart;n>=e.backing.length&&this._grow(e,n+1),e.indexEnd=t}let r=t-e.indexBase;r<0&&(r+=e.backing.length),e.incrementBucket(r,n)}_grow(e,t){let n=e.backing.length,r=e.indexBase-e.indexStart,i=n-r,a=Oa(t);a>this._maxSize&&(a=this._maxSize);let o=a-r;e.backing.growTo(a,i,o)}_changeScale(e,t){let n=0;for(;e-t>=this._maxSize;)e>>=1,t>>=1,n++;return n}_downscale(e){if(e===0)return;if(e<0)throw Error(`impossible change of scale: ${this.scale}`);let t=this._mapping.scale-e;this._positive.downscale(e),this._negative.downscale(e),this._mapping=Ia(t)}_minScale(e){let t=Math.min(this.scale,e.scale),n=Va.combine(this._highLowAtScale(this.positive,this.scale,t),this._highLowAtScale(e.positive,e.scale,t)),r=Va.combine(this._highLowAtScale(this.negative,this.scale,t),this._highLowAtScale(e.negative,e.scale,t));return Math.min(t-this._changeScale(n.high,n.low),t-this._changeScale(r.high,r.low))}_highLowAtScale(e,t,n){if(e.length===0)return new Va(0,-1);let r=t-n;return new Va(e.indexStart>>r,e.indexEnd>>r)}_mergeBuckets(e,t,n,r){let i=n.offset,a=t.scale-r;for(let t=0;t<n.length;t++)this._incrementIndexBy(e,i+t>>a,n.at(t))}_diffBuckets(e,t,n,r){let i=n.offset,a=t.scale-r;for(let t=0;t<n.length;t++){let r=(i+t>>a)-e.indexBase;r<0&&(r+=e.backing.length),e.decrementBucket(r,n.at(t))}e.trim()}},Ka=class{kind=aa.EXPONENTIAL_HISTOGRAM;_maxSize;_recordMinMax;constructor(e,t){this._maxSize=e,this._recordMinMax=t}createAccumulation(e){return new Ga(e,this._maxSize,this._recordMinMax)}merge(e,t){let n=t.clone();return n.merge(e),n}diff(e,t){let n=t.clone();return n.diff(e),n}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:Yi.EXPONENTIAL_HISTOGRAM,dataPoints:n.map(([t,n])=>{let i=n.toPointValue(),a=e.type===K.GAUGE||e.type===K.UP_DOWN_COUNTER||e.type===K.OBSERVABLE_GAUGE||e.type===K.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:t,startTime:n.startTime,endTime:r,value:{min:i.hasMinMax?i.min:void 0,max:i.hasMinMax?i.max:void 0,sum:a?void 0:i.sum,positive:{offset:i.positive.offset,bucketCounts:i.positive.bucketCounts},negative:{offset:i.negative.offset,bucketCounts:i.negative.bucketCounts},count:i.count,scale:i.scale,zeroCount:i.zeroCount}}})}}}})),Ja,Ya,Xa=c((()=>{oa(),ue(),Xi(),Ja=class{startTime;_current;sampleTime;constructor(e,t=0,n=[0,0]){this.startTime=e,this._current=t,this.sampleTime=n}record(e){this._current=e,this.sampleTime=b(Date.now())}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},Ya=class{kind=aa.LAST_VALUE;createAccumulation(e){return new Ja(e)}merge(e,t){let n=m(t.sampleTime)>=m(e.sampleTime)?t:e;return new Ja(e.startTime,n.toPointValue(),n.sampleTime)}diff(e,t){let n=m(t.sampleTime)>=m(e.sampleTime)?t:e;return new Ja(t.startTime,n.toPointValue(),n.sampleTime)}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:Yi.GAUGE,dataPoints:n.map(([e,t])=>({attributes:e,startTime:t.startTime,endTime:r,value:t.toPointValue()}))}}}})),Za,Qa,$a=c((()=>{oa(),Xi(),Za=class{startTime;monotonic;_current;reset;constructor(e,t,n=0,r=!1){this.startTime=e,this.monotonic=t,this._current=n,this.reset=r}record(e){this.monotonic&&e<0||(this._current+=e)}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},Qa=class{kind=aa.SUM;monotonic;constructor(e){this.monotonic=e}createAccumulation(e){return new Za(e,this.monotonic)}merge(e,t){let n=e.toPointValue(),r=t.toPointValue();return t.reset?new Za(t.startTime,this.monotonic,r,t.reset):new Za(e.startTime,this.monotonic,n+r)}diff(e,t){let n=e.toPointValue(),r=t.toPointValue();return this.monotonic&&n>r?new Za(t.startTime,this.monotonic,r,!0):new Za(t.startTime,this.monotonic,r-n)}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:Yi.SUM,dataPoints:n.map(([e,t])=>({attributes:e,startTime:t.startTime,endTime:r,value:t.toPointValue()})),isMonotonic:this.monotonic}}}})),eo=c((()=>{ca(),fa(),qa(),Xa(),$a()})),to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo=c((()=>{u(),eo(),Xi(),to=class e{static DEFAULT_INSTANCE=new sa;createAggregator(t){return e.DEFAULT_INSTANCE}},no=class e{static MONOTONIC_INSTANCE=new Qa(!0);static NON_MONOTONIC_INSTANCE=new Qa(!1);createAggregator(t){switch(t.type){case K.COUNTER:case K.OBSERVABLE_COUNTER:case K.HISTOGRAM:return e.MONOTONIC_INSTANCE;default:return e.NON_MONOTONIC_INSTANCE}}},ro=class e{static DEFAULT_INSTANCE=new Ya;createAggregator(t){return e.DEFAULT_INSTANCE}},io=class e{static DEFAULT_INSTANCE=new da([0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4],!0);createAggregator(t){return e.DEFAULT_INSTANCE}},ao=class{_boundaries;_recordMinMax;constructor(e,t=!0){if(e==null)throw Error(`ExplicitBucketHistogramAggregation should be created with explicit boundaries, if a single bucket histogram is required, please pass an empty array`);e=e.concat(),e=e.sort((e,t)=>e-t);let n=e.lastIndexOf(-1/0),r=e.indexOf(1/0);r===-1&&(r=void 0),this._boundaries=e.slice(n+1,r),this._recordMinMax=t}createAggregator(e){return new da(this._boundaries,this._recordMinMax)}},oo=class{_maxSize;_recordMinMax;constructor(e=160,t=!0){this._maxSize=e,this._recordMinMax=t}createAggregator(e){return new Ka(this._maxSize,this._recordMinMax)}},so=class{_resolve(e){switch(e.type){case K.COUNTER:case K.UP_DOWN_COUNTER:case K.OBSERVABLE_COUNTER:case K.OBSERVABLE_UP_DOWN_COUNTER:return lo;case K.GAUGE:case K.OBSERVABLE_GAUGE:return uo;case K.HISTOGRAM:return e.advice.explicitBucketBoundaries?new ao(e.advice.explicitBucketBoundaries):fo}return l.warn(`Unable to recognize instrument type: ${e.type}`),co}createAggregator(e){return this._resolve(e).createAggregator(e)}},co=new to,lo=new no,uo=new ro,fo=new io,new oo,po=new so}));function ho(e){switch(e.type){case go.DEFAULT:return po;case go.DROP:return co;case go.SUM:return lo;case go.LAST_VALUE:return uo;case go.EXPONENTIAL_HISTOGRAM:{let t=e;return new oo(t.options?.maxSize,t.options?.recordMinMax)}case go.EXPLICIT_BUCKET_HISTOGRAM:{let t=e;return t.options==null?fo:new ao(t.options?.boundaries,t.options?.recordMinMax)}default:throw Error(`Unsupported Aggregation`)}}var go,_o=c((()=>{mo(),(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.DROP=1]=`DROP`,e[e.SUM=2]=`SUM`,e[e.LAST_VALUE=3]=`LAST_VALUE`,e[e.EXPLICIT_BUCKET_HISTOGRAM=4]=`EXPLICIT_BUCKET_HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=5]=`EXPONENTIAL_HISTOGRAM`})(go||={})})),vo,yo,bo=c((()=>{Ji(),_o(),vo=e=>({type:go.DEFAULT}),yo=e=>qi.CUMULATIVE})),xo,So,Co,wo,To,Eo=c((()=>{xo=`otel.component.name`,So=`otel.component.type`,Co=`periodic_metric_reader`,wo=`otel.sdk.metric_reader.collection.duration`,To=`error.type`})),Do,Oo,ko=c((()=>{Eo(),Do=new Map,Oo=class{collectionDuration;standardAttrs;constructor(e,t){let n=Do.get(e)??0;Do.set(e,n+1),this.standardAttrs={[So]:e,[xo]:`${e}/${n}`},this.collectionDuration=t.createHistogram(wo,{unit:`s`,description:`The duration of the collect operation of the metric reader.`,advice:{explicitBucketBoundaries:[]}})}recordCollection(e,t){let n=t?{...this.standardAttrs,[To]:t}:this.standardAttrs;this.collectionDuration.record(e,n)}}})),Ao,jo=c((()=>{Ao=`2.11.0`})),Mo,No=c((()=>{u(),ia(),bo(),ko(),jo(),ue(),Mo=class{_shutdown=!1;_metricProducers;_sdkMetricProducer;_selfObsMetrics;_aggregationTemporalitySelector;_aggregationSelector;_cardinalitySelector;_otelComponentType;constructor(e){this._aggregationSelector=e?.aggregationSelector??vo,this._aggregationTemporalitySelector=e?.aggregationTemporalitySelector??yo,this._metricProducers=e?.metricProducers??[],this._cardinalitySelector=e?.cardinalitySelector,this._otelComponentType=e?.otelComponentType??this.constructor.name,this._selfObsMetrics=new Oo(this._otelComponentType,f())}setMetricProducer(e){if(this._sdkMetricProducer)throw Error(`MetricReader can not be bound to a MeterProvider again.`);this._sdkMetricProducer=e,this.onInitialized()}_setSelfObsMeterProvider(e){let t=e.getMeter(`@opentelemetry/sdk-metrics`,Ao);this._selfObsMetrics=new Oo(this._otelComponentType,t)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}selectCardinalityLimit(e){return this._cardinalitySelector?this._cardinalitySelector(e):2e3}onInitialized(){}async collect(e){if(this._sdkMetricProducer===void 0)throw Error(`MetricReader is not bound to a MetricProducer`);if(this._shutdown)throw Error(`MetricReader is shutdown`);let t=x(),[n,...r]=await Promise.all([this._sdkMetricProducer.collect({timeoutMillis:e?.timeoutMillis}),...this._metricProducers.map(t=>t.collect({timeoutMillis:e?.timeoutMillis}))]),i=x(),a=n.errors.concat(r.flatMap(e=>e.errors)),o=M(ne(t,i));return this._selfObsMetrics.recordCollection(o,a.length>0?a[0].name??`collect_error`:void 0),{resourceMetrics:{resource:n.resourceMetrics.resource,scopeMetrics:n.resourceMetrics.scopeMetrics.concat(r.flatMap(e=>e.resourceMetrics.scopeMetrics))},errors:a}}async shutdown(e){if(this._shutdown){l.error(`Cannot call shutdown twice.`);return}e?.timeoutMillis==null?await this.onShutdown():await $i(this.onShutdown(),e.timeoutMillis),this._shutdown=!0}async forceFlush(e){if(this._shutdown){l.warn(`Cannot forceFlush on already shutdown MetricReader.`);return}if(e?.timeoutMillis==null){await this.onForceFlush();return}await $i(this.onForceFlush(),e.timeoutMillis)}}}));function Po(e,t){if(!Number.isInteger(t)||t<=0)throw Error(`maxExportBatchSize must be a positive integer`);let n=[],r=0,i=[];function a(){i.length>0&&(n.push({resource:e.resource,scopeMetrics:i}),i=[],r=0)}for(let n of e.scopeMetrics){let e=null;for(let o of n.metrics){let s=o.dataPoints;if(s.length===0){e||(e={scope:n.scope,metrics:[]},i.push(e)),e.metrics.push(o);continue}let c=0;for(;c<s.length;){let l=t-r,u=Math.min(l,s.length-c);e||(e={scope:n.scope,metrics:[]},i.push(e));let d={...o,dataPoints:s.slice(c,c+u)};e.metrics.push(d),c+=u,r+=u,r===t&&(a(),e=null)}}}return a(),n}var Fo=c((()=>{})),Io,Lo=c((()=>{u(),ue(),No(),ia(),Xi(),Fo(),Eo(),Io=class extends Mo{_interval;_exporter;_exportInterval;_exportTimeout;_maxExportBatchSize;_ongoingExportPromise=null;constructor(e){let{exporter:t,exportIntervalMillis:n=6e4,metricProducers:r,cardinalityLimits:i,maxExportBatchSize:a}=e,{exportTimeoutMillis:o=3e4}=e;if(super({aggregationSelector:t.selectAggregation?.bind(t),aggregationTemporalitySelector:t.selectAggregationTemporality?.bind(t),otelComponentType:Co,metricProducers:r,cardinalitySelector:e=>{let t={default:2e3,...i};switch(e){case K.COUNTER:return t.counter??t.default;case K.GAUGE:return t.gauge??t.default;case K.HISTOGRAM:return t.histogram??t.default;case K.OBSERVABLE_COUNTER:return t.observableCounter??t.default;case K.OBSERVABLE_UP_DOWN_COUNTER:return t.observableUpDownCounter??t.default;case K.OBSERVABLE_GAUGE:return t.observableGauge??t.default;case K.UP_DOWN_COUNTER:return t.upDownCounter??t.default;default:return t.default}}}),n<=0)throw Error(`exportIntervalMillis must be greater than 0`);if(o<=0)throw Error(`exportTimeoutMillis must be greater than 0`);if(a!==void 0&&(!Number.isInteger(a)||a<=0))throw Error(`maxExportBatchSize must be a positive integer`);if(n<o){if(`exportIntervalMillis`in e&&`exportTimeoutMillis`in e)throw Error(`exportIntervalMillis must be greater than or equal to exportTimeoutMillis`);l.info(`Timeout of ${o} exceeds the interval of ${n}. Clamping timeout to interval duration.`),o=n}this._exportInterval=n,this._exportTimeout=o,this._exporter=t,this._maxExportBatchSize=a}async _runOnce(){try{await this._doRun()}catch(e){C(e)}}async _doRun(){if(this._ongoingExportPromise){l.debug(`PeriodicExportingMetricReader: export already in progress, skipping`);return}let e=async()=>{let{resourceMetrics:e,errors:t}=await this.collect({timeoutMillis:this._exportTimeout});if(t.length>0&&l.error(`PeriodicExportingMetricReader: metrics collection errors`,...t),e.resource.asyncAttributesPending)try{await e.resource.waitForAsyncAttributes?.()}catch(e){l.debug(`Error while resolving async portion of resource: `,e),C(e)}if(e.scopeMetrics.length===0)return;let n=this._maxExportBatchSize?Po(e,this._maxExportBatchSize):[e],r=null;for(let e of n)try{let t=await $i(T._export(this._exporter,e),this._exportTimeout);t.code!==_.SUCCESS&&(r=Error(`PeriodicExportingMetricReader: metrics export failed (error ${t.error})`))}catch(e){if(e instanceof ra){l.error(`PeriodicExportingMetricReader: metrics export timed out after ${this._exportTimeout}ms`);break}l.error(`PeriodicExportingMetricReader: metrics export threw error`,e),r=e instanceof Error?e:Error(String(e))}if(r)throw r};this._ongoingExportPromise=e();try{await this._ongoingExportPromise}finally{this._ongoingExportPromise=null}}onInitialized(){this._interval=setInterval(()=>{this._runOnce()},this._exportInterval),typeof this._interval!=`number`&&this._interval.unref()}async onForceFlush(){await this._awaitOngoingExport(),this._ongoingExportPromise?await this._awaitOngoingExport():await this._runOnce(),await this._exporter.forceFlush()}async _awaitOngoingExport(){if(this._ongoingExportPromise){l.debug(`PeriodicExportingMetricReader: export already in progress, awaiting ongoing export`);try{await this._ongoingExportPromise}catch{}}}async onShutdown(){this._interval&&clearInterval(this._interval),await this.onForceFlush(),await this._exporter.shutdown()}}})),Ro,zo=c((()=>{ue(),Ro=class{_shutdown=!1;_aggregationTemporality;_metrics=[];constructor(e){this._aggregationTemporality=e}export(e,t){if(this._shutdown){setTimeout(()=>t({code:_.FAILED}),0);return}this._metrics.push(e),setTimeout(()=>t({code:_.SUCCESS}),0)}getMetrics(){return this._metrics}forceFlush(){return Promise.resolve()}reset(){this._metrics=[]}selectAggregationTemporality(e){return this._aggregationTemporality}shutdown(){return this._shutdown=!0,Promise.resolve()}}})),Bo,Vo=c((()=>{ue(),bo(),Bo=class e{_shutdown=!1;_temporalitySelector;constructor(e){this._temporalitySelector=e?.temporalitySelector??yo}export(t,n){if(this._shutdown){n({code:_.FAILED});return}return e._sendMetrics(t,n)}forceFlush(){return Promise.resolve()}selectAggregationTemporality(e){return this._temporalitySelector(e)}shutdown(){return this._shutdown=!0,Promise.resolve()}static _sendMetrics(e,t){for(let t of e.scopeMetrics)for(let e of t.metrics)console.dir({descriptor:e.descriptor,dataPointType:e.dataPointType,dataPoints:e.dataPoints},{depth:null});t({code:_.SUCCESS})}}})),Ho,Uo=c((()=>{Ho=class{_registeredViews=[];addView(e){this._registeredViews.push(e)}findViews(e,t){return this._registeredViews.filter(n=>this._matchInstrument(n.instrumentSelector,e)&&this._matchMeter(n.meterSelector,t))}_matchInstrument(e,t){return(e.getType()===void 0||t.type===e.getType())&&e.getNameFilter().match(t.name)&&e.getUnitFilter().match(t.unit)}_matchMeter(e,t){return e.getNameFilter().match(t.name)&&(t.version===void 0||e.getVersionFilter().match(t.version))&&(t.schemaUrl===void 0||e.getSchemaUrlFilter().match(t.schemaUrl))}}}));function Wo(e,t,n){return qo(e)||l.warn(`Invalid metric name: "${e}". The metric name should be a ASCII string with a length no greater than 255 characters.`),{name:e,type:t,description:n?.description??``,unit:n?.unit??``,valueType:n?.valueType??i.DOUBLE,advice:n?.advice??{}}}function Go(e,t){return{name:e.name??t.name,description:e.description??t.description,type:t.type,unit:t.unit,valueType:t.valueType,advice:t.advice}}function Ko(e,t){return na(e.name,t.name)&&e.unit===t.unit&&e.type===t.type&&e.valueType===t.valueType}function qo(e){return Jo.test(e)}var Jo,Yo=c((()=>{u(),ia(),Jo=/^[a-z][a-z0-9_.\-/]{0,254}$/i}));function Xo(e){return e instanceof ns}var Zo,Qo,$o,es,ts,ns,rs,is,as,os=c((()=>{u(),Zo=class{_writableMetricStorage;_descriptor;constructor(e,t){this._writableMetricStorage=e,this._descriptor=t}_record(e,t={},n){if(typeof e!=`number`){l.warn(`non-number value provided to metric ${this._descriptor.name}: ${e}`);return}this._descriptor.valueType===i.INT&&!Number.isInteger(e)&&(l.warn(`INT value type cannot accept a floating-point value for ${this._descriptor.name}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._writableMetricStorage.record(e,t,n,Date.now())}},Qo=class extends Zo{add(e,t,n){this._record(e,t,n)}},$o=class extends Zo{add(e,t,n){if(e<0){l.warn(`negative value provided to counter ${this._descriptor.name}: ${e}`);return}this._record(e,t,n)}},es=class extends Zo{record(e,t,n){this._record(e,t,n)}},ts=class extends Zo{record(e,t,n){if(e<0){l.warn(`negative value provided to histogram ${this._descriptor.name}: ${e}`);return}this._record(e,t,n)}},ns=class{_metricStorages;_descriptor;_observableRegistry;constructor(e,t,n){this._descriptor=e,this._metricStorages=t,this._observableRegistry=n}addCallback(e){this._observableRegistry.addCallback(e,this)}removeCallback(e){this._observableRegistry.removeCallback(e,this)}},rs=class extends ns{},is=class extends ns{},as=class extends ns{}})),ss,cs=c((()=>{Yo(),os(),Xi(),ss=class{_meterSharedState;constructor(e){this._meterSharedState=e}createGauge(e,t){let n=Wo(e,K.GAUGE,t),r=this._meterSharedState.registerMetricStorage(n);return new es(r,n)}createHistogram(e,t){let n=Wo(e,K.HISTOGRAM,t),r=this._meterSharedState.registerMetricStorage(n);return new ts(r,n)}createCounter(e,t){let n=Wo(e,K.COUNTER,t),r=this._meterSharedState.registerMetricStorage(n);return new $o(r,n)}createUpDownCounter(e,t){let n=Wo(e,K.UP_DOWN_COUNTER,t),r=this._meterSharedState.registerMetricStorage(n);return new Qo(r,n)}createObservableGauge(e,t){let n=Wo(e,K.OBSERVABLE_GAUGE,t),r=this._meterSharedState.registerAsyncMetricStorage(n);return new is(n,r,this._meterSharedState.observableRegistry)}createObservableCounter(e,t){let n=Wo(e,K.OBSERVABLE_COUNTER,t),r=this._meterSharedState.registerAsyncMetricStorage(n);return new rs(n,r,this._meterSharedState.observableRegistry)}createObservableUpDownCounter(e,t){let n=Wo(e,K.OBSERVABLE_UP_DOWN_COUNTER,t),r=this._meterSharedState.registerAsyncMetricStorage(n);return new as(n,r,this._meterSharedState.observableRegistry)}addBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.addBatchCallback(e,t)}removeBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.removeBatchCallback(e,t)}}})),ls,us=c((()=>{Yo(),ls=class{_instrumentDescriptor;constructor(e){this._instrumentDescriptor=e}getInstrumentDescriptor(){return this._instrumentDescriptor}updateDescription(e){this._instrumentDescriptor=Wo(this._instrumentDescriptor.name,this._instrumentDescriptor.type,{description:e,valueType:this._instrumentDescriptor.valueType,unit:this._instrumentDescriptor.unit,advice:this._instrumentDescriptor.advice})}}})),ds,fs,ps=c((()=>{ia(),ds=class{_valueMap=new Map;_keyMap=new Map;_hash;constructor(e){this._hash=e}get(e,t){return t??=this._hash(e),this._valueMap.get(t)}getOrDefault(e,t){let n=this._hash(e);if(this._valueMap.has(n))return this._valueMap.get(n);let r=t();return this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,r),r}set(e,t,n){n??=this._hash(e),this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,t)}has(e,t){return t??=this._hash(e),this._valueMap.has(t)}*keys(){let e=this._keyMap.entries(),t=e.next();for(;t.done!==!0;)yield[t.value[1],t.value[0]],t=e.next()}*entries(){let e=this._valueMap.entries(),t=e.next();for(;t.done!==!0;)yield[this._keyMap.get(t.value[0]),t.value[1],t.value[0]],t=e.next()}get size(){return this._valueMap.size}},fs=class extends ds{constructor(){super(Zi)}}})),ms,hs=c((()=>{ue(),ia(),ps(),ms=class{_activeCollectionStorage=new fs;_cumulativeMemoStorage=new fs;_cardinalityLimit;_overflowAttributes={"otel.metric.overflow":!0};_overflowHashCode;_aggregator;constructor(e,t){this._aggregator=e,this._cardinalityLimit=(t??2e3)-1,this._overflowHashCode=Zi(this._overflowAttributes)}record(e,t,n){let r=this._activeCollectionStorage.get(t);if(!r){let i=b(n);if(this._activeCollectionStorage.size>=this._cardinalityLimit){this._activeCollectionStorage.getOrDefault(this._overflowAttributes,()=>this._aggregator.createAccumulation(i))?.record(e);return}r=this._aggregator.createAccumulation(i),this._activeCollectionStorage.set(t,r)}r?.record(e)}batchCumulate(e,t){for(let[n,r,i]of e.entries()){let e=n,a=i,o=this._aggregator.createAccumulation(t);o?.record(r);let s=o;if(this._cumulativeMemoStorage.has(e,a)){let t=this._cumulativeMemoStorage.get(e,a);s=this._aggregator.diff(t,o)}else if(this._cumulativeMemoStorage.size>=this._cardinalityLimit&&(e=this._overflowAttributes,a=this._overflowHashCode,this._cumulativeMemoStorage.has(e,a))){let t=this._cumulativeMemoStorage.get(e,a);s=this._aggregator.diff(t,o)}if(this._activeCollectionStorage.has(e,a)){let t=this._activeCollectionStorage.get(e,a);s=this._aggregator.merge(t,s)}this._cumulativeMemoStorage.set(e,o,a),this._activeCollectionStorage.set(e,s,a)}}collect(){let e=this._activeCollectionStorage;return this._activeCollectionStorage=new fs,e}}}));function gs(e){return Array.from(e.entries())}var _s,vs=c((()=>{Ji(),ps(),_s=class e{_aggregator;_unreportedAccumulations=new Map;_reportHistory=new Map;constructor(e,t){this._aggregator=e,t.forEach(e=>{this._unreportedAccumulations.set(e,[])})}buildMetrics(t,n,r,i){this._stashAccumulations(r);let a=this._getMergedUnreportedAccumulations(t),o=a,s;if(this._reportHistory.has(t)){let n=this._reportHistory.get(t),r=n.collectionTime;s=n.aggregationTemporality,o=s===qi.CUMULATIVE?e.merge(n.accumulations,a,this._aggregator):e.calibrateStartTime(n.accumulations,a,r)}else s=t.selectAggregationTemporality(n.type);this._reportHistory.set(t,{accumulations:o,collectionTime:i,aggregationTemporality:s});let c=gs(o);if(c.length!==0)return this._aggregator.toMetricData(n,s,c,i)}_stashAccumulations(e){let t=this._unreportedAccumulations.keys();for(let n of t){let t=this._unreportedAccumulations.get(n);t===void 0&&(t=[],this._unreportedAccumulations.set(n,t)),t.push(e)}}_getMergedUnreportedAccumulations(t){let n=new fs,r=this._unreportedAccumulations.get(t);if(this._unreportedAccumulations.set(t,[]),r===void 0)return n;for(let t of r)n=e.merge(n,t,this._aggregator);return n}static merge(e,t,n){let r=e,i=t.entries(),a=i.next();for(;a.done!==!0;){let[t,o,s]=a.value;if(e.has(t,s)){let i=e.get(t,s),a=n.merge(i,o);r.set(t,a,s)}else r.set(t,o,s);a=i.next()}return r}static calibrateStartTime(e,t,n){for(let[r,i]of e.keys())t.get(r,i)?.setStartTime(n);return t}}})),ys,bs=c((()=>{us(),hs(),vs(),ps(),ys=class extends ls{_aggregationCardinalityLimit;_deltaMetricStorage;_temporalMetricStorage;_attributesProcessor;constructor(e,t,n,r,i){super(e),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new ms(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new _s(t,r),this._attributesProcessor=n}record(e,t){if(this._attributesProcessor===void 0){this._deltaMetricStorage.batchCumulate(e,t);return}let n=new fs;for(let[t,r]of e.entries())n.set(this._attributesProcessor.process(t),r);this._deltaMetricStorage.batchCumulate(n,t)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}}}));function xs(e,t){let n=``;return e.unit!==t.unit&&(n+=`\t- Unit '${e.unit}' does not match '${t.unit}'\n`),e.type!==t.type&&(n+=`\t- Type '${e.type}' does not match '${t.type}'\n`),e.valueType!==t.valueType&&(n+=`\t- Value Type '${e.valueType}' does not match '${t.valueType}'\n`),e.description!==t.description&&(n+=`\t- Description '${e.description}' does not match '${t.description}'\n`),n}function Ss(e,t){return`\t- use valueType '${e.valueType}' on instrument creation or use an instrument name other than '${t.name}'`}function Cs(e,t){return`\t- use unit '${e.unit}' on instrument creation or use an instrument name other than '${t.name}'`}function ws(e,t){let n={name:t.name,type:t.type,unit:t.unit},r=JSON.stringify(n);return`\t- create a new view with a name other than '${e.name}' and InstrumentSelector '${r}'`}function Ts(e,t){let n={name:t.name,type:t.type,unit:t.unit},r=JSON.stringify(n);return`\t- create a new view with a name other than '${e.name}' and InstrumentSelector '${r}'
4
4
  \t- OR - create a new view with the name ${e.name} and description '${e.description}' and InstrumentSelector ${r}
5
5
  \t- OR - create a new view with the name ${t.name} and description '${e.description}' and InstrumentSelector ${r}`}function Es(e,t){return e.valueType===t.valueType?e.unit===t.unit?e.type===t.type?e.description===t.description?``:Ts(e,t):ws(e,t):Cs(e,t):Ss(e,t)}var Ds=c((()=>{})),Os,ks=c((()=>{Yo(),u(),Ds(),Os=class e{_sharedRegistry=new Map;_perCollectorRegistry=new Map;static create(){return new e}getStorages(e){let t=[];for(let e of this._sharedRegistry.values())t=t.concat(e);let n=this._perCollectorRegistry.get(e);if(n!=null)for(let e of n.values())t=t.concat(e);return t}register(e){this._registerStorage(e,this._sharedRegistry)}registerForCollector(e,t){let n=this._perCollectorRegistry.get(e);n??(n=new Map,this._perCollectorRegistry.set(e,n)),this._registerStorage(t,n)}findOrUpdateCompatibleStorage(e){let t=this._sharedRegistry.get(e.name);return t===void 0?null:this._findOrUpdateCompatibleStorage(e,t)}findOrUpdateCompatibleCollectorStorage(e,t){let n=this._perCollectorRegistry.get(e);if(n===void 0)return null;let r=n.get(t.name);return r===void 0?null:this._findOrUpdateCompatibleStorage(t,r)}_registerStorage(e,t){let n=e.getInstrumentDescriptor(),r=t.get(n.name);if(r===void 0){t.set(n.name,[e]);return}r.push(e)}_findOrUpdateCompatibleStorage(e,t){let n=null;for(let r of t){let t=r.getInstrumentDescriptor();Ko(t,e)?(t.description!==e.description&&(e.description.length>t.description.length&&r.updateDescription(e.description),l.warn(`A view or instrument with the name `,e.name,` has already been registered, but has a different description and is incompatible with another registered view.
@@ -8,7 +8,7 @@ import{A as e,M as t,N as n,O as r,_ as i,c as a,d as o,j as s,k as c,l,n as u,t
8
8
  To resolve the conflict:`,Es(t,e))),n=r):l.warn(`A view or instrument with the name `,e.name,` has already been registered and is incompatible with another registered view.
9
9
  `,`Details:
10
10
  `,xs(t,e),`To resolve the conflict:
11
- `,Es(t,e))}return n}}})),As,js=c((()=>{u(),As=class{_backingStorages;hasAttributeProcessor;constructor(e){this._backingStorages=e,this.hasAttributeProcessor=e.some(e=>e.hasAttributeProcessor)}record(e,t,n,r){this.hasAttributeProcessor&&n===void 0&&(n=o.active());let i=this._backingStorages;for(let a=0;a<i.length;a++)i[a].record(e,t,n,r)}}})),Ms,Ns,Ps=c((()=>{u(),ps(),os(),Ms=class{_buffer=new fs;_instrumentName;_valueType;constructor(e,t){this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){l.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===i.INT&&!Number.isInteger(e)&&(l.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(t,e)}},Ns=class{_buffer=new Map;observe(e,t,n={}){if(!Xo(e))return;let r=this._buffer.get(e);if(r??(r=new fs,this._buffer.set(e,r)),typeof t!=`number`){l.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===i.INT&&!Number.isInteger(t)&&(l.warn(`INT value type cannot accept a floating-point value for ${e._descriptor.name}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||r.set(n,t)}}})),Fs,Is=c((()=>{u(),os(),Ps(),ia(),Fs=class{_callbacks=[];_batchCallbacks=[];addCallback(e,t){this._findCallback(e,t)>=0||this._callbacks.push({callback:e,instrument:t})}removeCallback(e,t){let n=this._findCallback(e,t);n<0||this._callbacks.splice(n,1)}addBatchCallback(e,t){let n=new Set(t.filter(Xo));if(n.size===0){l.error(`BatchObservableCallback is not associated with valid instruments`,t);return}this._findBatchCallback(e,n)>=0||this._batchCallbacks.push({callback:e,instruments:n})}removeBatchCallback(e,t){let n=new Set(t.filter(Xo)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}async observe(e,t){let n=this._observeCallbacks(e,t),r=this._observeBatchCallbacks(e,t);return(await Promise.allSettled([...n,...r])).filter(e=>e.status===`rejected`).map(e=>e.reason)}_observeCallbacks(e,t){return this._callbacks.map(async({callback:n,instrument:r})=>{let i=new Ms(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=$i(a,t)),await a,r._metricStorages.forEach(t=>{t.record(i._buffer,e)})})}_observeBatchCallbacks(e,t){return this._batchCallbacks.map(async({callback:n,instruments:r})=>{let i=new Ns,a=Promise.resolve(n(i));t!=null&&(a=$i(a,t)),await a,r.forEach(t=>{let n=i._buffer.get(t);n!=null&&t._metricStorages.forEach(t=>{t.record(n,e)})})})}_findCallback(e,t){return this._callbacks.findIndex(n=>n.callback===e&&n.instrument===t)}_findBatchCallback(e,t){return this._batchCallbacks.findIndex(n=>n.callback===e&&ea(n.instruments,t))}}})),Ls,Rs=c((()=>{u(),us(),hs(),vs(),Ls=class extends ls{_aggregationCardinalityLimit;_deltaMetricStorage;_temporalMetricStorage;_attributesProcessor;constructor(e,t,n,r,i){super(e),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new ms(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new _s(t,r),this._attributesProcessor=n,this.hasAttributeProcessor=n!==void 0}hasAttributeProcessor;record(e,t,n,r){this._attributesProcessor!==void 0&&(t=this._attributesProcessor.process(t,n??o.active())),this._deltaMetricStorage.record(e,t,r)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}}})),zs,Bs=c((()=>{Yo(),cs(),bs(),ks(),js(),Is(),Rs(),zs=class{metricStorageRegistry=new Os;observableRegistry=new Fs;meter;_meterProviderSharedState;_instrumentationScope;constructor(e,t){this.meter=new ss(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,Ls);return t.length===1?t[0]:new As(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,ys)}async collect(e,t,n){let r=await this.observableRegistry.observe(t,n?.timeoutMillis),i=this.metricStorageRegistry.getStorages(e);if(i.length===0)return null;let a=[];return i.forEach(n=>{let r=n.collect(e,t);r!=null&&a.push(r)}),a.length===0?{errors:r}:{scopeMetrics:{scope:this._instrumentationScope,metrics:a},errors:r}}_registerMetricStorage(e,t){let n=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope).map(n=>{let r=Go(n,e),i=this.metricStorageRegistry.findOrUpdateCompatibleStorage(r);if(i!=null)return i;let a=new t(r,n.aggregation.createAggregator(r),n.attributesProcessor,this._meterProviderSharedState.metricCollectors,n.aggregationCardinalityLimit);return this.metricStorageRegistry.register(a),a});if(n.length===0){let r=this._meterProviderSharedState.selectAggregations(e.type).map(([n,r])=>{let i=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(n,e);if(i!=null)return i;let a=r.createAggregator(e),o=n.selectCardinalityLimit(e.type),s=new t(e,a,void 0,[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}}})),Vs,Hs=c((()=>{ia(),Uo(),Bs(),_o(),Vs=class{viewRegistry=new Ho;metricCollectors=[];meterSharedStates=new Map;resource;constructor(e){this.resource=e}getMeterSharedState(e){let t=Qi(e),n=this.meterSharedStates.get(t);return n??(n=new zs(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,ho(n.selectAggregation(e))]);return t}}})),Us,Ws=c((()=>{ue(),Us=class{_sharedState;_metricReader;constructor(e,t){this._sharedState=e,this._metricReader=t}async collect(e){let t=b(Date.now()),n=[],r=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(async i=>{let a=await i.collect(this,t,e);a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&r.push(...a.errors)});return await Promise.all(i),{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:r}}async forceFlush(e){await this._metricReader.forceFlush(e)}async shutdown(e){await this._metricReader.shutdown(e)}selectAggregationTemporality(e){return this._metricReader.selectAggregationTemporality(e)}selectAggregation(e){return this._metricReader.selectAggregation(e)}selectCardinalityLimit(e){return this._metricReader.selectCardinalityLimit?.(e)??2e3}}})),Gs,Ks,qs,Js=c((()=>{Gs=/[\^$\\.+?()[\]{}|]/g,Ks=class e{_matchAll;_regexp;constructor(t){t===`*`?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t)))}match(e){return this._matchAll?!0:this._regexp.test(e)}static escapePattern(e){return`^${e.replace(Gs,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},qs=class{_matchAll;_pattern;constructor(e){this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}}}));function Ys(){return rc}function Xs(e){return new ec(e)}function Zs(e){return new tc(e)}function Qs(e){return new nc(e)}var $s,ec,tc,nc,rc,ic=c((()=>{$s=class{process(e,t){return e}},ec=class{_processors;constructor(e){this._processors=e}process(e,t){let n=e;for(let e of this._processors)n=e.process(n,t);return n}},tc=class{_allowedAttributeNames;constructor(e){this._allowedAttributeNames=new Set(e)}process(e,t){let n={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._allowedAttributeNames.has(t)&&(n[t]=e[t]);return n}},nc=class{_deniedAttributeNames;constructor(e){this._deniedAttributeNames=new Set(e)}process(e,t){let n={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&!this._deniedAttributeNames.has(t)&&(n[t]=e[t]);return n}},rc=new $s})),ac,oc=c((()=>{Js(),ac=class{_nameFilter;_type;_unitFilter;constructor(e){this._nameFilter=new Ks(e?.name??`*`),this._type=e?.type,this._unitFilter=new qs(e?.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}}})),sc,cc=c((()=>{Js(),sc=class{_nameFilter;_versionFilter;_schemaUrlFilter;constructor(e){this._nameFilter=new qs(e?.name),this._versionFilter=new qs(e?.version),this._schemaUrlFilter=new qs(e?.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}}}));function lc(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function uc(e){if(lc(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&(e?.instrumentName==null||Ks.hasWildcard(e.instrumentName)))throw Error(`Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.`)}var dc,fc=c((()=>{Js(),ic(),oc(),cc(),_o(),dc=class{name;description;aggregation;attributesProcessor;instrumentSelector;meterSelector;aggregationCardinalityLimit;constructor(e){uc(e),this.attributesProcessor=e.attributesProcessors==null?Ys():Xs(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=ho(e.aggregation??{type:go.DEFAULT}),this.instrumentSelector=new ac({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new sc({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}}})),pc,mc=c((()=>{u(),de(),No(),Hs(),Ws(),fc(),pc=class{_sharedState;_shutdown=!1;constructor(e){if(this._sharedState=new Vs(e?.resource??D()),e?.views!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new dc(t));if(e?.readers!=null&&e.readers.length>0)for(let t of e.readers){let n=new Us(this._sharedState,t);t.setMetricProducer(n),this._sharedState.metricCollectors.push(n),e.sdkMetricsEnabled&&t instanceof Mo&&t._setSelfObsMeterProvider(this)}}getMeter(e,t=``,n={}){return this._shutdown?(l.warn(`A shutdown MeterProvider cannot provide a Meter`),f()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}async shutdown(e){if(this._shutdown){l.warn(`shutdown may only be called once per MeterProvider`);return}this._shutdown=!0,await Promise.all(this._sharedState.metricCollectors.map(t=>t.shutdown(e)))}async forceFlush(e){if(this._shutdown){l.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}await Promise.all(this._sharedState.metricCollectors.map(t=>t.forceFlush(e)))}}})),hc=e({AggregationTemporality:()=>qi,AggregationType:()=>go,ConsoleMetricExporter:()=>Bo,DataPointType:()=>Yi,InMemoryMetricExporter:()=>Ro,InstrumentType:()=>K,MeterProvider:()=>pc,MetricReader:()=>Mo,PeriodicExportingMetricReader:()=>Io,TimeoutError:()=>ra,createAllowListAttributesProcessor:()=>Zs,createDenyListAttributesProcessor:()=>Qs}),gc=c((()=>{Ji(),Xi(),No(),Lo(),zo(),Vo(),mc(),_o(),ic(),ia()})),_c;(function(e){e[e.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]=`AGGREGATION_TEMPORALITY_UNSPECIFIED`,e[e.AGGREGATION_TEMPORALITY_DELTA=1]=`AGGREGATION_TEMPORALITY_DELTA`,e[e.AGGREGATION_TEMPORALITY_CUMULATIVE=2]=`AGGREGATION_TEMPORALITY_CUMULATIVE`})(_c||={}),u(),gc();function vc(e,t){let n=ee(e.resource,t);return{resource:n,schemaUrl:n.schemaUrl,scopeMetrics:yc(e.scopeMetrics,t)}}function yc(e,t){return Array.from(e.map(e=>({scope:A(e.scope,t),metrics:e.metrics.map(e=>bc(e,t)),schemaUrl:e.scope.schemaUrl})))}function bc(e,t){let n={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},r=Tc(e.aggregationTemporality);switch(e.dataPointType){case Yi.SUM:n.sum={aggregationTemporality:r,isMonotonic:e.isMonotonic,dataPoints:Sc(e,t)};break;case Yi.GAUGE:n.gauge={dataPoints:Sc(e,t)};break;case Yi.HISTOGRAM:n.histogram={aggregationTemporality:r,dataPoints:Cc(e,t)};break;case Yi.EXPONENTIAL_HISTOGRAM:n.exponentialHistogram={aggregationTemporality:r,dataPoints:wc(e,t)}}return n}function xc(e,t,n){let r={attributes:le(e.attributes,n),startTimeUnixNano:n.encodeHrTime(e.startTime),timeUnixNano:n.encodeHrTime(e.endTime)};switch(t){case i.INT:r.asInt=e.value;break;case i.DOUBLE:r.asDouble=e.value}return r}function Sc(e,t){return e.dataPoints.map(n=>xc(n,e.descriptor.valueType,t))}function Cc(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:le(e.attributes,t),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function wc(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:le(e.attributes,t),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function Tc(e){switch(e){case qi.DELTA:return _c.AGGREGATION_TEMPORALITY_DELTA;case qi.CUMULATIVE:return _c.AGGREGATION_TEMPORALITY_CUMULATIVE}}function Ec(e,t){return{resourceMetrics:e.map(e=>vc(e,t))}}u();var Dc={serializeRequest:e=>{let t=Ec([e],te);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return l.warn(`Failed to parse metrics export response: ${e.message}. Returning empty response`),{}}}};function Oc(){let e,t;return async()=>(e===void 0&&(e=await(t??=kc().finally(()=>{t=void 0}))),e)}async function kc(){let e=`getAuthProviderCatalog`,t=await Pt(ui(),{method:`GET`,path:Ve(e,{}),headers:{},operationId:e},mi).catch(e=>{N({component:`aventure-mcp-server`,event:`oauth_catalog_unavailable`,message:se(e),fields:{requestId:hi()},error:e})});if(t===void 0)return;if(!t.ok||t.redirect){N({component:`aventure-mcp-server`,event:`oauth_catalog_unavailable`,message:`the API did not return an OAuth provider catalog`,fields:{requestId:hi()}});return}let n=t.data.oauthClient;if(n==null){N({component:`aventure-mcp-server`,event:`oauth_discovery_disabled`,message:`the API published no OAuth client; retrying on the next request that needs one`,fields:{requestId:hi()}});return}let r=n.mcpResource;if(r==null){N({component:`aventure-mcp-server`,event:`oauth_discovery_disabled`,message:`the API published an OAuth client without an MCP resource indicator, so this server has no resource to advertise or audience to verify; retrying on the next request that needs one`,fields:{requestId:hi()}});return}if(!URL.canParse(r)){N({component:`aventure-mcp-server`,event:`oauth_discovery_disabled`,message:`the API published an unusable MCP resource indicator: ${r}`,fields:{requestId:hi()}});return}let i=new URL(r);return E({component:`aventure-mcp-server`,event:`oauth_discovery_ready`,fields:{requestId:hi(),resource:i.href,authorizationServer:n.authorizationServer}}),{client:n,resourceUrl:i}}var Ac=2e3,jc={userInfo:!1,cookies:!1,httpHeaders:{request:!1,response:!1},httpBodies:[],urlQueryParams:!1,graphQL:{document:!1,variables:!1},genAI:{inputs:!1,outputs:!1},databaseQueryData:!1,stackFrameVariables:!1,frameContextLines:0},Mc;async function Nc(){let e=Ic(process.env.SENTRY_DSN),t=Ic(process.env.SENTRY_RELEASE);if(e===void 0||t===void 0)return;let n=await import(`../chunks/esm-BjPDrmO6.js`);n.init({dsn:e,environment:oe()[`deployment.environment.name`],release:t,dataCollection:jc,beforeBreadcrumb:()=>null,beforeSend:e=>{let t=e.tags?.failure;return delete e.request,delete e.user,delete e.breadcrumbs,delete e.contexts,delete e.extra,delete e.transaction,delete e.tags,(t===`authentication_unavailable`||t===`server_start_failed`||t===`transport_error`)&&(e.tags={failure:t}),e}}),Mc=n}function Pc(e,t){Mc?.captureException(e,{tags:{failure:t}})}async function Fc(){let e=Mc;Mc=void 0,e!==void 0&&await e.close(Ac)}function Ic(e){return e?.trim()||void 0}var Lc=r(((e,t)=>{var n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function a(e){if(e==null)throw TypeError(`Object.assign cannot be called with null or undefined`);return Object(e)}function o(){try{if(!Object.assign)return!1;var e=new String(`abc`);if(e[5]=`de`,Object.getOwnPropertyNames(e)[0]===`5`)return!1;for(var t={},n=0;n<10;n++)t[`_`+String.fromCharCode(n)]=n;if(Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(``)!==`0123456789`)return!1;var r={};return`abcdefghijklmnopqrst`.split(``).forEach(function(e){r[e]=e}),Object.keys(Object.assign({},r)).join(``)===`abcdefghijklmnopqrst`}catch{return!1}}t.exports=o()?Object.assign:function(e,t){for(var o,s=a(e),c,l=1;l<arguments.length;l++){for(var u in o=Object(arguments[l]),o)r.call(o,u)&&(s[u]=o[u]);if(n){c=n(o);for(var d=0;d<c.length;d++)i.call(o,c[d])&&(s[c[d]]=o[c[d]])}}return s}})),Rc=r(((e,t)=>{t.exports=a,t.exports.append=r;var n=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function r(e,t){if(typeof e!=`string`)throw TypeError(`header argument is required`);if(!t)throw TypeError(`field argument is required`);for(var r=Array.isArray(t)?t:i(String(t)),a=0;a<r.length;a++)if(!n.test(r[a]))throw TypeError(`field argument contains an invalid header name`);if(e===`*`)return e;var o=e,s=i(e.toLowerCase());if(r.indexOf(`*`)!==-1||s.indexOf(`*`)!==-1)return`*`;for(var c=0;c<r.length;c++){var l=r[c].toLowerCase();s.indexOf(l)===-1&&(s.push(l),o=o?o+`, `+r[c]:r[c])}return o}function i(e){for(var t=0,n=[],r=0,i=0,a=e.length;i<a;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1}return n.push(e.substring(r,t)),n}function a(e,t){if(!e||!e.getHeader||!e.setHeader)throw TypeError(`res argument is required`);var n=e.getHeader(`Vary`)||``;(n=r(Array.isArray(n)?n.join(`, `):String(n),t))&&e.setHeader(`Vary`,n)}})),zc=r(((e,t)=>{(function(){var e=Lc(),n=Rc(),r={origin:`*`,methods:`GET,HEAD,PUT,PATCH,POST,DELETE`,preflightContinue:!1,optionsSuccessStatus:204};function i(e){return typeof e==`string`||e instanceof String}function a(e,t){if(Array.isArray(t)){for(var n=0;n<t.length;++n)if(a(e,t[n]))return!0;return!1}return i(t)?e===t:t instanceof RegExp?t.test(e):!!t}function o(e,t){var n=t.headers.origin,r=[],o;return!e.origin||e.origin===`*`?r.push([{key:`Access-Control-Allow-Origin`,value:`*`}]):i(e.origin)?(r.push([{key:`Access-Control-Allow-Origin`,value:e.origin}]),r.push([{key:`Vary`,value:`Origin`}])):(o=a(n,e.origin),r.push([{key:`Access-Control-Allow-Origin`,value:o?n:!1}]),r.push([{key:`Vary`,value:`Origin`}])),r}function s(e){var t=e.methods;return t.join&&(t=e.methods.join(`,`)),{key:`Access-Control-Allow-Methods`,value:t}}function c(e){return e.credentials===!0?{key:`Access-Control-Allow-Credentials`,value:`true`}:null}function l(e,t){var n=e.allowedHeaders||e.headers,r=[];return n?n.join&&(n=n.join(`,`)):(n=t.headers[`access-control-request-headers`],r.push([{key:`Vary`,value:`Access-Control-Request-Headers`}])),n&&n.length&&r.push([{key:`Access-Control-Allow-Headers`,value:n}]),r}function u(e){var t=e.exposedHeaders;if(t)t.join&&(t=t.join(`,`));else return null;return t&&t.length?{key:`Access-Control-Expose-Headers`,value:t}:null}function d(e){var t=(typeof e.maxAge==`number`||e.maxAge)&&e.maxAge.toString();return t&&t.length?{key:`Access-Control-Max-Age`,value:t}:null}function f(e,t){for(var r=0,i=e.length;r<i;r++){var a=e[r];a&&(Array.isArray(a)?f(a,t):a.key===`Vary`&&a.value?n(t,a.value):a.value&&t.setHeader(a.key,a.value))}}function p(e,t,n,r){var i=[];(t.method&&t.method.toUpperCase&&t.method.toUpperCase())===`OPTIONS`?(i.push(o(e,t)),i.push(c(e)),i.push(s(e)),i.push(l(e,t)),i.push(d(e)),i.push(u(e)),f(i,n),e.preflightContinue?r():(n.statusCode=e.optionsSuccessStatus,n.setHeader(`Content-Length`,`0`),n.end())):(i.push(o(e,t)),i.push(c(e)),i.push(u(e)),f(i,n),r())}function m(t){var n=null;return n=typeof t==`function`?t:function(e,n){n(null,t)},function(t,i,a){n(t,function(n,o){if(n)a(n);else{var s=e({},r,o),c=null;s.origin&&typeof s.origin==`function`?c=s.origin:s.origin&&(c=function(e,t){t(null,s.origin)}),c?c(t.headers.origin,function(e,n){e||!n?a(e):(s.origin=n,p(s,t,i,a))}):a()}})}}t.exports=m})()})),Bc=r(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),Vc=r(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=Bc(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),Hc=r(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=Vc()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),Uc=r(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),Wc=r(((e,t)=>{var n=s(`os`),r=s(`tty`),i=Uc(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1);function c(){if(`FORCE_COLOR`in a)return a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(a.FORCE_COLOR,10),3)}function l(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function u(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let s=c();s!==void 0&&(o=s);let l=r?o:s;if(l===0)return 0;if(r){if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2}if(e&&!t&&l===void 0)return 0;let u=l||0;if(a.TERM===`dumb`)return u;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`,`DRONE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:u;if(`TEAMCITY_VERSION`in a)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION);if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=Number.parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:u}function d(e,t={}){return l(u(e,{streamIsTTY:e&&e.isTTY,...t}))}t.exports={supportsColor:d,stdout:d({isTTY:r.isatty(1)}),stderr:d({isTTY:r.isatty(2)})}})),Gc=r(((e,t)=>{var n=s(`tty`),r=s(`util`);e.init=d,e.log=c,e.formatArgs=a,e.save=l,e.load=u,e.useColors=i,e.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{let t=Wc();t&&(t.stderr||t).level>=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}e.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function i(){return`colors`in e.inspectOpts?!!e.inspectOpts.colors:n.isatty(process.stderr.fd)}function a(e){let{namespace:n,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${n} \u001B[0m`;e[0]=a+e[0].split(`
11
+ `,Es(t,e))}return n}}})),As,js=c((()=>{u(),As=class{_backingStorages;hasAttributeProcessor;constructor(e){this._backingStorages=e,this.hasAttributeProcessor=e.some(e=>e.hasAttributeProcessor)}record(e,t,n,r){this.hasAttributeProcessor&&n===void 0&&(n=o.active());let i=this._backingStorages;for(let a=0;a<i.length;a++)i[a].record(e,t,n,r)}}})),Ms,Ns,Ps=c((()=>{u(),ps(),os(),Ms=class{_buffer=new fs;_instrumentName;_valueType;constructor(e,t){this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){l.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===i.INT&&!Number.isInteger(e)&&(l.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(t,e)}},Ns=class{_buffer=new Map;observe(e,t,n={}){if(!Xo(e))return;let r=this._buffer.get(e);if(r??(r=new fs,this._buffer.set(e,r)),typeof t!=`number`){l.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===i.INT&&!Number.isInteger(t)&&(l.warn(`INT value type cannot accept a floating-point value for ${e._descriptor.name}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||r.set(n,t)}}})),Fs,Is=c((()=>{u(),os(),Ps(),ia(),Fs=class{_callbacks=[];_batchCallbacks=[];addCallback(e,t){this._findCallback(e,t)>=0||this._callbacks.push({callback:e,instrument:t})}removeCallback(e,t){let n=this._findCallback(e,t);n<0||this._callbacks.splice(n,1)}addBatchCallback(e,t){let n=new Set(t.filter(Xo));if(n.size===0){l.error(`BatchObservableCallback is not associated with valid instruments`,t);return}this._findBatchCallback(e,n)>=0||this._batchCallbacks.push({callback:e,instruments:n})}removeBatchCallback(e,t){let n=new Set(t.filter(Xo)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}async observe(e,t){let n=this._observeCallbacks(e,t),r=this._observeBatchCallbacks(e,t);return(await Promise.allSettled([...n,...r])).filter(e=>e.status===`rejected`).map(e=>e.reason)}_observeCallbacks(e,t){return this._callbacks.map(async({callback:n,instrument:r})=>{let i=new Ms(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=$i(a,t)),await a,r._metricStorages.forEach(t=>{t.record(i._buffer,e)})})}_observeBatchCallbacks(e,t){return this._batchCallbacks.map(async({callback:n,instruments:r})=>{let i=new Ns,a=Promise.resolve(n(i));t!=null&&(a=$i(a,t)),await a,r.forEach(t=>{let n=i._buffer.get(t);n!=null&&t._metricStorages.forEach(t=>{t.record(n,e)})})})}_findCallback(e,t){return this._callbacks.findIndex(n=>n.callback===e&&n.instrument===t)}_findBatchCallback(e,t){return this._batchCallbacks.findIndex(n=>n.callback===e&&ea(n.instruments,t))}}})),Ls,Rs=c((()=>{u(),us(),hs(),vs(),Ls=class extends ls{_aggregationCardinalityLimit;_deltaMetricStorage;_temporalMetricStorage;_attributesProcessor;constructor(e,t,n,r,i){super(e),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new ms(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new _s(t,r),this._attributesProcessor=n,this.hasAttributeProcessor=n!==void 0}hasAttributeProcessor;record(e,t,n,r){this._attributesProcessor!==void 0&&(t=this._attributesProcessor.process(t,n??o.active())),this._deltaMetricStorage.record(e,t,r)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}}})),zs,Bs=c((()=>{Yo(),cs(),bs(),ks(),js(),Is(),Rs(),zs=class{metricStorageRegistry=new Os;observableRegistry=new Fs;meter;_meterProviderSharedState;_instrumentationScope;constructor(e,t){this.meter=new ss(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,Ls);return t.length===1?t[0]:new As(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,ys)}async collect(e,t,n){let r=await this.observableRegistry.observe(t,n?.timeoutMillis),i=this.metricStorageRegistry.getStorages(e);if(i.length===0)return null;let a=[];return i.forEach(n=>{let r=n.collect(e,t);r!=null&&a.push(r)}),a.length===0?{errors:r}:{scopeMetrics:{scope:this._instrumentationScope,metrics:a},errors:r}}_registerMetricStorage(e,t){let n=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope).map(n=>{let r=Go(n,e),i=this.metricStorageRegistry.findOrUpdateCompatibleStorage(r);if(i!=null)return i;let a=new t(r,n.aggregation.createAggregator(r),n.attributesProcessor,this._meterProviderSharedState.metricCollectors,n.aggregationCardinalityLimit);return this.metricStorageRegistry.register(a),a});if(n.length===0){let r=this._meterProviderSharedState.selectAggregations(e.type).map(([n,r])=>{let i=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(n,e);if(i!=null)return i;let a=r.createAggregator(e),o=n.selectCardinalityLimit(e.type),s=new t(e,a,void 0,[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}}})),Vs,Hs=c((()=>{ia(),Uo(),Bs(),_o(),Vs=class{viewRegistry=new Ho;metricCollectors=[];meterSharedStates=new Map;resource;constructor(e){this.resource=e}getMeterSharedState(e){let t=Qi(e),n=this.meterSharedStates.get(t);return n??(n=new zs(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,ho(n.selectAggregation(e))]);return t}}})),Us,Ws=c((()=>{ue(),Us=class{_sharedState;_metricReader;constructor(e,t){this._sharedState=e,this._metricReader=t}async collect(e){let t=b(Date.now()),n=[],r=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(async i=>{let a=await i.collect(this,t,e);a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&r.push(...a.errors)});return await Promise.all(i),{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:r}}async forceFlush(e){await this._metricReader.forceFlush(e)}async shutdown(e){await this._metricReader.shutdown(e)}selectAggregationTemporality(e){return this._metricReader.selectAggregationTemporality(e)}selectAggregation(e){return this._metricReader.selectAggregation(e)}selectCardinalityLimit(e){return this._metricReader.selectCardinalityLimit?.(e)??2e3}}})),Gs,Ks,qs,Js=c((()=>{Gs=/[\^$\\.+?()[\]{}|]/g,Ks=class e{_matchAll;_regexp;constructor(t){t===`*`?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t)))}match(e){return this._matchAll?!0:this._regexp.test(e)}static escapePattern(e){return`^${e.replace(Gs,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},qs=class{_matchAll;_pattern;constructor(e){this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}}}));function Ys(){return rc}function Xs(e){return new ec(e)}function Zs(e){return new tc(e)}function Qs(e){return new nc(e)}var $s,ec,tc,nc,rc,ic=c((()=>{$s=class{process(e,t){return e}},ec=class{_processors;constructor(e){this._processors=e}process(e,t){let n=e;for(let e of this._processors)n=e.process(n,t);return n}},tc=class{_allowedAttributeNames;constructor(e){this._allowedAttributeNames=new Set(e)}process(e,t){let n={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._allowedAttributeNames.has(t)&&(n[t]=e[t]);return n}},nc=class{_deniedAttributeNames;constructor(e){this._deniedAttributeNames=new Set(e)}process(e,t){let n={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&!this._deniedAttributeNames.has(t)&&(n[t]=e[t]);return n}},rc=new $s})),ac,oc=c((()=>{Js(),ac=class{_nameFilter;_type;_unitFilter;constructor(e){this._nameFilter=new Ks(e?.name??`*`),this._type=e?.type,this._unitFilter=new qs(e?.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}}})),sc,cc=c((()=>{Js(),sc=class{_nameFilter;_versionFilter;_schemaUrlFilter;constructor(e){this._nameFilter=new qs(e?.name),this._versionFilter=new qs(e?.version),this._schemaUrlFilter=new qs(e?.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}}}));function lc(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function uc(e){if(lc(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&(e?.instrumentName==null||Ks.hasWildcard(e.instrumentName)))throw Error(`Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.`)}var dc,fc=c((()=>{Js(),ic(),oc(),cc(),_o(),dc=class{name;description;aggregation;attributesProcessor;instrumentSelector;meterSelector;aggregationCardinalityLimit;constructor(e){uc(e),this.attributesProcessor=e.attributesProcessors==null?Ys():Xs(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=ho(e.aggregation??{type:go.DEFAULT}),this.instrumentSelector=new ac({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new sc({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}}})),pc,mc=c((()=>{u(),de(),No(),Hs(),Ws(),fc(),pc=class{_sharedState;_shutdown=!1;constructor(e){if(this._sharedState=new Vs(e?.resource??D()),e?.views!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new dc(t));if(e?.readers!=null&&e.readers.length>0)for(let t of e.readers){let n=new Us(this._sharedState,t);t.setMetricProducer(n),this._sharedState.metricCollectors.push(n),e.sdkMetricsEnabled&&t instanceof Mo&&t._setSelfObsMeterProvider(this)}}getMeter(e,t=``,n={}){return this._shutdown?(l.warn(`A shutdown MeterProvider cannot provide a Meter`),f()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}async shutdown(e){if(this._shutdown){l.warn(`shutdown may only be called once per MeterProvider`);return}this._shutdown=!0,await Promise.all(this._sharedState.metricCollectors.map(t=>t.shutdown(e)))}async forceFlush(e){if(this._shutdown){l.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}await Promise.all(this._sharedState.metricCollectors.map(t=>t.forceFlush(e)))}}})),hc=e({AggregationTemporality:()=>qi,AggregationType:()=>go,ConsoleMetricExporter:()=>Bo,DataPointType:()=>Yi,InMemoryMetricExporter:()=>Ro,InstrumentType:()=>K,MeterProvider:()=>pc,MetricReader:()=>Mo,PeriodicExportingMetricReader:()=>Io,TimeoutError:()=>ra,createAllowListAttributesProcessor:()=>Zs,createDenyListAttributesProcessor:()=>Qs}),gc=c((()=>{Ji(),Xi(),No(),Lo(),zo(),Vo(),mc(),_o(),ic(),ia()})),_c;(function(e){e[e.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]=`AGGREGATION_TEMPORALITY_UNSPECIFIED`,e[e.AGGREGATION_TEMPORALITY_DELTA=1]=`AGGREGATION_TEMPORALITY_DELTA`,e[e.AGGREGATION_TEMPORALITY_CUMULATIVE=2]=`AGGREGATION_TEMPORALITY_CUMULATIVE`})(_c||={}),u(),gc();function vc(e,t){let n=ee(e.resource,t);return{resource:n,schemaUrl:n.schemaUrl,scopeMetrics:yc(e.scopeMetrics,t)}}function yc(e,t){return Array.from(e.map(e=>({scope:A(e.scope,t),metrics:e.metrics.map(e=>bc(e,t)),schemaUrl:e.scope.schemaUrl})))}function bc(e,t){let n={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},r=Tc(e.aggregationTemporality);switch(e.dataPointType){case Yi.SUM:n.sum={aggregationTemporality:r,isMonotonic:e.isMonotonic,dataPoints:Sc(e,t)};break;case Yi.GAUGE:n.gauge={dataPoints:Sc(e,t)};break;case Yi.HISTOGRAM:n.histogram={aggregationTemporality:r,dataPoints:Cc(e,t)};break;case Yi.EXPONENTIAL_HISTOGRAM:n.exponentialHistogram={aggregationTemporality:r,dataPoints:wc(e,t)}}return n}function xc(e,t,n){let r={attributes:le(e.attributes,n),startTimeUnixNano:n.encodeHrTime(e.startTime),timeUnixNano:n.encodeHrTime(e.endTime)};switch(t){case i.INT:r.asInt=e.value;break;case i.DOUBLE:r.asDouble=e.value}return r}function Sc(e,t){return e.dataPoints.map(n=>xc(n,e.descriptor.valueType,t))}function Cc(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:le(e.attributes,t),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function wc(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:le(e.attributes,t),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function Tc(e){switch(e){case qi.DELTA:return _c.AGGREGATION_TEMPORALITY_DELTA;case qi.CUMULATIVE:return _c.AGGREGATION_TEMPORALITY_CUMULATIVE}}function Ec(e,t){return{resourceMetrics:e.map(e=>vc(e,t))}}u();var Dc={serializeRequest:e=>{let t=Ec([e],te);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return l.warn(`Failed to parse metrics export response: ${e.message}. Returning empty response`),{}}}};function Oc(){let e,t;return async()=>(e===void 0&&(e=await(t??=kc().finally(()=>{t=void 0}))),e)}async function kc(){let e=`getAuthProviderCatalog`,t=await Pt(ui(),{method:`GET`,path:Ve(e,{}),headers:{},operationId:e},mi).catch(e=>{N({component:`aventure-mcp-server`,event:`oauth_catalog_unavailable`,message:se(e),fields:{requestId:xi()},error:e})});if(t===void 0)return;if(!t.ok||t.redirect){N({component:`aventure-mcp-server`,event:`oauth_catalog_unavailable`,message:`the API did not return an OAuth provider catalog`,fields:{requestId:xi()}});return}let n=t.data.oauthClient;if(n==null){N({component:`aventure-mcp-server`,event:`oauth_discovery_disabled`,message:`the API published no OAuth client; retrying on the next request that needs one`,fields:{requestId:xi()}});return}let r=n.mcpResource;if(r==null){N({component:`aventure-mcp-server`,event:`oauth_discovery_disabled`,message:`the API published an OAuth client without an MCP resource indicator, so this server has no resource to advertise or audience to verify; retrying on the next request that needs one`,fields:{requestId:xi()}});return}if(!URL.canParse(r)){N({component:`aventure-mcp-server`,event:`oauth_discovery_disabled`,message:`the API published an unusable MCP resource indicator: ${r}`,fields:{requestId:xi()}});return}let i=new URL(r);return E({component:`aventure-mcp-server`,event:`oauth_discovery_ready`,fields:{requestId:xi(),resource:i.href,authorizationServer:n.authorizationServer}}),{client:n,resourceUrl:i}}var Ac=2e3,jc={userInfo:!1,cookies:!1,httpHeaders:{request:!1,response:!1},httpBodies:[],urlQueryParams:!1,graphQL:{document:!1,variables:!1},genAI:{inputs:!1,outputs:!1},databaseQueryData:!1,stackFrameVariables:!1,frameContextLines:0},Mc;async function Nc(){let e=Ic(process.env.SENTRY_DSN),t=Ic(process.env.SENTRY_RELEASE);if(e===void 0||t===void 0)return;let n=await import(`../chunks/esm-BjPDrmO6.js`);n.init({dsn:e,environment:oe()[`deployment.environment.name`],release:t,dataCollection:jc,beforeBreadcrumb:()=>null,beforeSend:e=>{let t=e.tags?.failure;return delete e.request,delete e.user,delete e.breadcrumbs,delete e.contexts,delete e.extra,delete e.transaction,delete e.tags,(t===`authentication_unavailable`||t===`server_start_failed`||t===`transport_error`)&&(e.tags={failure:t}),e}}),Mc=n}function Pc(e,t){Mc?.captureException(e,{tags:{failure:t}})}async function Fc(){let e=Mc;Mc=void 0,e!==void 0&&await e.close(Ac)}function Ic(e){return e?.trim()||void 0}var Lc=r(((e,t)=>{var n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function a(e){if(e==null)throw TypeError(`Object.assign cannot be called with null or undefined`);return Object(e)}function o(){try{if(!Object.assign)return!1;var e=new String(`abc`);if(e[5]=`de`,Object.getOwnPropertyNames(e)[0]===`5`)return!1;for(var t={},n=0;n<10;n++)t[`_`+String.fromCharCode(n)]=n;if(Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(``)!==`0123456789`)return!1;var r={};return`abcdefghijklmnopqrst`.split(``).forEach(function(e){r[e]=e}),Object.keys(Object.assign({},r)).join(``)===`abcdefghijklmnopqrst`}catch{return!1}}t.exports=o()?Object.assign:function(e,t){for(var o,s=a(e),c,l=1;l<arguments.length;l++){for(var u in o=Object(arguments[l]),o)r.call(o,u)&&(s[u]=o[u]);if(n){c=n(o);for(var d=0;d<c.length;d++)i.call(o,c[d])&&(s[c[d]]=o[c[d]])}}return s}})),Rc=r(((e,t)=>{t.exports=a,t.exports.append=r;var n=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function r(e,t){if(typeof e!=`string`)throw TypeError(`header argument is required`);if(!t)throw TypeError(`field argument is required`);for(var r=Array.isArray(t)?t:i(String(t)),a=0;a<r.length;a++)if(!n.test(r[a]))throw TypeError(`field argument contains an invalid header name`);if(e===`*`)return e;var o=e,s=i(e.toLowerCase());if(r.indexOf(`*`)!==-1||s.indexOf(`*`)!==-1)return`*`;for(var c=0;c<r.length;c++){var l=r[c].toLowerCase();s.indexOf(l)===-1&&(s.push(l),o=o?o+`, `+r[c]:r[c])}return o}function i(e){for(var t=0,n=[],r=0,i=0,a=e.length;i<a;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1}return n.push(e.substring(r,t)),n}function a(e,t){if(!e||!e.getHeader||!e.setHeader)throw TypeError(`res argument is required`);var n=e.getHeader(`Vary`)||``;(n=r(Array.isArray(n)?n.join(`, `):String(n),t))&&e.setHeader(`Vary`,n)}})),zc=r(((e,t)=>{(function(){var e=Lc(),n=Rc(),r={origin:`*`,methods:`GET,HEAD,PUT,PATCH,POST,DELETE`,preflightContinue:!1,optionsSuccessStatus:204};function i(e){return typeof e==`string`||e instanceof String}function a(e,t){if(Array.isArray(t)){for(var n=0;n<t.length;++n)if(a(e,t[n]))return!0;return!1}return i(t)?e===t:t instanceof RegExp?t.test(e):!!t}function o(e,t){var n=t.headers.origin,r=[],o;return!e.origin||e.origin===`*`?r.push([{key:`Access-Control-Allow-Origin`,value:`*`}]):i(e.origin)?(r.push([{key:`Access-Control-Allow-Origin`,value:e.origin}]),r.push([{key:`Vary`,value:`Origin`}])):(o=a(n,e.origin),r.push([{key:`Access-Control-Allow-Origin`,value:o?n:!1}]),r.push([{key:`Vary`,value:`Origin`}])),r}function s(e){var t=e.methods;return t.join&&(t=e.methods.join(`,`)),{key:`Access-Control-Allow-Methods`,value:t}}function c(e){return e.credentials===!0?{key:`Access-Control-Allow-Credentials`,value:`true`}:null}function l(e,t){var n=e.allowedHeaders||e.headers,r=[];return n?n.join&&(n=n.join(`,`)):(n=t.headers[`access-control-request-headers`],r.push([{key:`Vary`,value:`Access-Control-Request-Headers`}])),n&&n.length&&r.push([{key:`Access-Control-Allow-Headers`,value:n}]),r}function u(e){var t=e.exposedHeaders;if(t)t.join&&(t=t.join(`,`));else return null;return t&&t.length?{key:`Access-Control-Expose-Headers`,value:t}:null}function d(e){var t=(typeof e.maxAge==`number`||e.maxAge)&&e.maxAge.toString();return t&&t.length?{key:`Access-Control-Max-Age`,value:t}:null}function f(e,t){for(var r=0,i=e.length;r<i;r++){var a=e[r];a&&(Array.isArray(a)?f(a,t):a.key===`Vary`&&a.value?n(t,a.value):a.value&&t.setHeader(a.key,a.value))}}function p(e,t,n,r){var i=[];(t.method&&t.method.toUpperCase&&t.method.toUpperCase())===`OPTIONS`?(i.push(o(e,t)),i.push(c(e)),i.push(s(e)),i.push(l(e,t)),i.push(d(e)),i.push(u(e)),f(i,n),e.preflightContinue?r():(n.statusCode=e.optionsSuccessStatus,n.setHeader(`Content-Length`,`0`),n.end())):(i.push(o(e,t)),i.push(c(e)),i.push(u(e)),f(i,n),r())}function m(t){var n=null;return n=typeof t==`function`?t:function(e,n){n(null,t)},function(t,i,a){n(t,function(n,o){if(n)a(n);else{var s=e({},r,o),c=null;s.origin&&typeof s.origin==`function`?c=s.origin:s.origin&&(c=function(e,t){t(null,s.origin)}),c?c(t.headers.origin,function(e,n){e||!n?a(e):(s.origin=n,p(s,t,i,a))}):a()}})}}t.exports=m})()})),Bc=r(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),Vc=r(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=Bc(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),Hc=r(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=Vc()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),Uc=r(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),Wc=r(((e,t)=>{var n=s(`os`),r=s(`tty`),i=Uc(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1);function c(){if(`FORCE_COLOR`in a)return a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(a.FORCE_COLOR,10),3)}function l(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function u(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let s=c();s!==void 0&&(o=s);let l=r?o:s;if(l===0)return 0;if(r){if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2}if(e&&!t&&l===void 0)return 0;let u=l||0;if(a.TERM===`dumb`)return u;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`,`DRONE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:u;if(`TEAMCITY_VERSION`in a)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION);if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=Number.parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:u}function d(e,t={}){return l(u(e,{streamIsTTY:e&&e.isTTY,...t}))}t.exports={supportsColor:d,stdout:d({isTTY:r.isatty(1)}),stderr:d({isTTY:r.isatty(2)})}})),Gc=r(((e,t)=>{var n=s(`tty`),r=s(`util`);e.init=d,e.log=c,e.formatArgs=a,e.save=l,e.load=u,e.useColors=i,e.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{let t=Wc();t&&(t.stderr||t).level>=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}e.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function i(){return`colors`in e.inspectOpts?!!e.inspectOpts.colors:n.isatty(process.stderr.fd)}function a(e){let{namespace:n,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${n} \u001B[0m`;e[0]=a+e[0].split(`
12
12
  `).join(`
13
13
  `+a),e.push(i+`m+`+t.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=o()+n+` `+e[0]}function o(){return e.inspectOpts.hideDate?``:new Date().toISOString()+` `}function c(...t){return process.stderr.write(r.formatWithOptions(e.inspectOpts,...t)+`
14
14
  `)}function l(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function u(){return process.env.DEBUG}function d(t){t.inspectOpts={};let n=Object.keys(e.inspectOpts);for(let r=0;r<n.length;r++)t.inspectOpts[n[r]]=e.inspectOpts[n[r]]}t.exports=Vc()(e);var{formatters:f}=t.exports;f.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split(`
@@ -141,7 +141,7 @@ Profile on interface`)}catch(e){return e.status===1&&e.stdout.includes(`AutoConf
141
141
  `),a=(t&&t[0]?t[0]:``).split(` via `);a&&a[1]&&(a=a[1].split(` `),i=a[0]),e&&e(i),r(i)}})}catch{e&&e(i),r(i)}if(d){let t=`route -n get default`;try{n(t,{maxBuffer:104857600},(a,o)=>{if(!a){let e=o.toString().split(`
142
142
  `).map(e=>e.trim());i=c.getValue(e,`gateway`)}i?(e&&e(i),r(i)):(t=`netstat -rn | awk '/default/ {print $2}'`,n(t,{maxBuffer:104857600},(t,n)=>{i=n.toString().split(`
143
143
  `).map(e=>e.trim()).find(e=>/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e)),e&&e(i),r(i)}))})}catch{e&&e(i),r(i)}}if(f)try{n(`netstat -r`,c.execOptsWin,(n,a)=>{a.toString().split(t.EOL).forEach(e=>{if(e=e.replace(/\s+/g,` `).trim(),e.indexOf(`0.0.0.0 0.0.0.0`)>-1&&!/[a-zA-Z]/.test(e)){let t=e.split(` `);t.length>=5&&t[t.length-3].indexOf(`.`)>-1&&(i=t[t.length-3])}}),i?(e&&e(i),r(i)):c.powerShell(`Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq '0.0.0.0' -and $_.Mask -eq '0.0.0.0' }`).then(t=>{let n=t.toString().split(`\r
144
- `);n.length>1&&!i&&(i=c.getValue(n,`NextHop`),e&&e(i),r(i))})})}catch{e&&e(i),r(i)}})})}e.networkGatewayDefault=me})),cb=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getNetworkData=void 0;var t=sb();function n(){return new Promise(e=>{(0,t.networkStats)().then(e).catch(()=>{e([])})})}e.getNetworkData=n})),lb=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HostMetrics=void 0;var t=rb(),n=ib(),r=ab(),i=cb();e.HostMetrics=class extends t.BaseMetrics{_batchUpdateCpuUsages(e,t){for(let r=0,i=t.length;r<i;r++){let i=t[r];e.observe(this._cpuTime,i.user,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_USER,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.system,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_SYSTEM,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.idle,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_IDLE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.interrupt,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_INTERRUPT,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.nice,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_NICE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.userP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_USER,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.systemP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_SYSTEM,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.idleP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_IDLE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.interruptP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_INTERRUPT,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.niceP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_NICE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber})}}_batchUpdateProcessCpuUsages(e,t){e.observe(this._processCpuTime,t.user,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_USER}),e.observe(this._processCpuTime,t.system,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_SYSTEM}),e.observe(this._processCpuUtilization,t.userP,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_USER}),e.observe(this._processCpuUtilization,t.systemP,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_SYSTEM})}_batchUpdateMemUsages(e,t){e.observe(this._memoryUsage,t.used,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_USED}),e.observe(this._memoryUsage,t.free,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_FREE}),e.observe(this._memoryUtilization,t.usedP,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_USED}),e.observe(this._memoryUtilization,t.freeP,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_FREE})}_batchUpdateProcessMemUsage(e,t){e.observe(this._processMemoryUsage,t)}_batchUpdateNetworkData(e,t){for(let r=0,i=t.length;r<i;r++){let i=t[r];e.observe(this._networkDropped,i.rx_dropped,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_RECEIVE}),e.observe(this._networkDropped,i.tx_dropped,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_TRANSMIT}),e.observe(this._networkErrors,i.rx_errors,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_RECEIVE}),e.observe(this._networkErrors,i.tx_errors,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_TRANSMIT}),e.observe(this._networkIo,i.rx_bytes,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_RECEIVE}),e.observe(this._networkIo,i.tx_bytes,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_TRANSMIT})}}_createMetrics(){let e=[],t=!this._metricGroups||this._metricGroups.includes(`system.cpu`),a=!this._metricGroups||this._metricGroups.includes(`system.memory`),o=!this._metricGroups||this._metricGroups.includes(`system.network`),s=!this._metricGroups||this._metricGroups.includes(`process.cpu`),c=!this._metricGroups||this._metricGroups.includes(`process.memory`);t&&(this._cpuTime=this._meter.createObservableCounter(n.METRIC_SYSTEM_CPU_TIME,{description:`Cpu time in seconds`,unit:`s`}),e.push(this._cpuTime),this._cpuUtilization=this._meter.createObservableGauge(n.METRIC_SYSTEM_CPU_UTILIZATION,{description:`Cpu usage time 0-1`}),e.push(this._cpuUtilization)),a&&(this._memoryUsage=this._meter.createObservableGauge(n.METRIC_SYSTEM_MEMORY_USAGE,{description:`Memory usage in bytes`}),e.push(this._memoryUsage),this._memoryUtilization=this._meter.createObservableGauge(n.METRIC_SYSTEM_MEMORY_UTILIZATION,{description:`Memory usage 0-1`}),e.push(this._memoryUtilization)),o&&(this._networkDropped=this._meter.createObservableCounter(`system.network.dropped`,{description:`Network dropped packets`}),e.push(this._networkDropped),this._networkErrors=this._meter.createObservableCounter(n.METRIC_SYSTEM_NETWORK_ERRORS,{description:`Network errors counter`}),e.push(this._networkErrors),this._networkIo=this._meter.createObservableCounter(n.METRIC_SYSTEM_NETWORK_IO,{description:`Network transmit and received bytes`}),e.push(this._networkIo)),s&&(this._processCpuTime=this._meter.createObservableCounter(n.METRIC_PROCESS_CPU_TIME,{description:`Process Cpu time in seconds`,unit:`s`}),e.push(this._processCpuTime),this._processCpuUtilization=this._meter.createObservableGauge(n.METRIC_PROCESS_CPU_UTILIZATION,{description:`Process Cpu usage time 0-1`}),e.push(this._processCpuUtilization)),c&&(this._processMemoryUsage=this._meter.createObservableGauge(n.METRIC_PROCESS_MEMORY_USAGE,{description:`Process Memory usage in bytes`}),e.push(this._processMemoryUsage)),this._meter.addBatchObservableCallback(async e=>{if(t){let t=(0,r.getCpuUsageData)();this._batchUpdateCpuUsages(e,t)}if(a){let t=(0,r.getMemoryData)();this._batchUpdateMemUsages(e,t)}if(s){let t=(0,r.getProcessCpuUsageData)();this._batchUpdateProcessCpuUsages(e,t)}if(c){let t=(0,r.getProcessMemoryData)();this._batchUpdateProcessMemUsage(e,t)}if(o){let t=await(0,i.getNetworkData)();this._batchUpdateNetworkData(e,t)}},e)}start(){this._createMetrics()}_cpuTime;_cpuUtilization;_memoryUsage;_memoryUtilization;_processCpuTime;_processCpuUtilization;_processMemoryUsage;_networkDropped;_networkErrors;_networkIo}})),ub=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HostMetrics=e.BaseMetrics=void 0;var t=rb();Object.defineProperty(e,"BaseMetrics",{enumerable:!0,get:function(){return t.BaseMetrics}});var n=lb();Object.defineProperty(e,"HostMetrics",{enumerable:!0,get:function(){return n.HostMetrics}})})),db=Wy(),fb=ub(),pb=`bearer `,mb=4096;function hb(e){if(e===void 0||e.length>mb||e.slice(0,7).toLowerCase()!==pb)return;let t=e.slice(7).trim();return t.length>0?t:void 0}u(),de(),gc();var gb=`aventure-mcp-server`,_b=`http_server_requests_seconds`,vb=[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],yb,bb,xb,Sb,Cb;function wb(e,t){if(bb!==void 0)return;let n=e?new db.PrometheusExporter({preventServerStart:!0}):void 0,r=new pc({resource:w({...oe(),"service.version":process.env.GIT_SHA??process.env.SENTRY_RELEASE??pi().version}),readers:[...n===void 0?[]:[n],...t===void 0?[]:[new Io({exporter:new tb({url:t}),exportIntervalMillis:1e4,exportTimeoutMillis:5e3})]]});a.setGlobalMeterProvider(r),bb=r,yb=n;let i=new fb.HostMetrics({meterProvider:r,name:gb});i.start(),Cb=i}function Tb(){return xb===void 0&&(xb=bb?.getMeter(gb)),xb}function Eb(e,t,n,r,{rpcMethod:i,toolName:a}){let o=Tb();o!==void 0&&(Sb===void 0&&(Sb=o.createHistogram(_b,{description:`HTTP server request latency in seconds, partitioned by method/route/status/rpc_method/tool.`,unit:`s`,advice:{explicitBucketBoundaries:vb}})),Sb.record(r/1e3,{method:e.toUpperCase(),route:t,status:String(n),rpc_method:i,tool:a}))}function Db(e,t){let n=pi().registry===``&&!!t,r=process.env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT?.trim()||void 0;if(!n&&r===void 0)return;wb(n,r);let i=yb;if(!n||t===void 0||i===void 0)return;let a=Ui(`sha256`).update(t).digest();e.get(`/metrics`,(e,t,n)=>{if(!kb(e.headers.authorization,a)){t.status(401).type(`text/plain`).send(`Unauthorized`);return}n()},(e,t)=>{i.getMetricsRequestHandler(e,t)})}async function Ob(){let e=bb;Cb!==void 0&&(Cb=void 0),bb=void 0,yb=void 0,xb=void 0,Sb=void 0,e!==void 0&&await e.shutdown()}function kb(e,t){let n=hb(e);if(n===void 0)return!1;let r=Ui(`sha256`).update(n).digest();return r.length===t.length&&Gi(r,t)}var Ab=`#/components/schemas/`,jb=/"#\/components\/schemas\/([^"]+)"/g,Mb=-32011,Nb=-32012,Pb=-32013,Fb=-32015;function Ib(e){let t=bt().components.schemas[e];if(t===void 0)throw Error(`OpenAPI has no component ${e}`);return t}function Lb(e){let t=xi(e?.content?.[`application/json`]?.schema);return t===void 0?void 0:Ib(t)}function Rb(e){let t=Object.keys(e).length===1?xi(e):void 0,n=t===void 0?e:Ib(t),r={},i=e=>{for(let[,t]of JSON.stringify(e).matchAll(jb))t===void 0||t in r||(r[t]=Ib(t),i(r[t]))};i(n);let a=Object.keys(r).length===0?n:{...n,$defs:r},o=li.safeParse(JSON.parse(JSON.stringify(a).replaceAll(`"${Ab}`,`"#/$defs/`)));if(!o.success)throw Error(`Event schema is not JSON: ${o.error}`);return o.data}function zb(e,t){let n=Object.entries(bt().paths).find(([,n])=>Lb(n[e]?.requestBody)?.properties?.name?.$ref===t);if(n===void 0)throw Error(`OpenAPI has no ${e} operation for ${t}`);return n[0]}var Bb=new Map(Object.entries(bt().webhooks??{}).map(([e,t])=>{let n=Lb(t.post.requestBody),r=n?.properties?.name?.$ref,i=n?.properties?.data;if(r===void 0||i===void 0)throw Error(`Webhook ${e} body must carry a name enum $ref and a data schema`);let a=zb(`put`,r),o=Lb(bt().paths[a]?.put?.requestBody)?.properties?.arguments;if(o===void 0)throw Error(`Subscribe body for ${e} must carry an arguments schema`);return[e,{descriptor:{name:e,description:t.post.description,delivery:[`webhook`],inputSchema:Rb(o),payloadSchema:Rb(i)},subscribePath:a,unsubscribePath:zb(`delete`,r)}]})),Vb=G({name:W()}).catchall(li),Hb=F(W(),li);function Ub(e){let t=Bb.get(e);if(t===void 0)throw new Z(Mb,`Unknown event ${e}`);return t}async function Wb(e,t,n){let{_meta:r,...i}=n,a=await Ae({method:e,path:t,body:i,auth:`auto`});if(a.ok){let e=Hb.safeParse(a.data!==null&&typeof a.data==`object`&&`response`in a.data?a.data.response??{}:{});if(e.success)return e.data;throw new Z(X.InternalError,`${t} answered a non-object body`)}let o=Gb(a.problem?.code);throw o===void 0?a.problem?.code===`news_subscription_limit`?new Z(Pb,a.summary,{limit:`subscriptions`}):new Z(Kb(a.httpStatus),a.summary,a.problem):new Z(Fb,`CallbackEndpointError`,{reason:o})}function Gb(e){switch(e){case`callback_connection_refused`:return`connection_refused`;case`callback_timeout`:return`timeout`;case`callback_tls_error`:return`tls_error`;case`callback_http_4xx`:return`http_4xx`;case`callback_http_5xx`:return`http_5xx`;case`callback_challenge_failed`:return`challenge_failed`;default:return}}function Kb(e){switch(e){case 400:case 422:return X.InvalidParams;case 401:case 403:return Nb;case 404:return Mb;default:return X.InternalError}}function qb(e){if(Bb.size===0)return;let t=[...Bb.values()].map(e=>e.descriptor);e.server.setRequestHandler(`events/list`,{params:G({})},()=>({events:t})),e.server.setRequestHandler(`events/subscribe`,{params:Vb},e=>Wb(`PUT`,Ub(e.name).subscribePath,e)),e.server.setRequestHandler(`events/unsubscribe`,{params:Vb},e=>Wb(`DELETE`,Ub(e.name).unsubscribePath,e))}async function Jb(e){try{return await Ae(e)}catch(t){return j({component:`aventure-mcp-server`,event:`tool_request_failed`,fields:{requestId:hi(),method:e.method},error:t}),si(se(t))}}var Yb=3,Xb=200,Zb=80;function Qb(e,t){let{operationId:n}=e;if(n===void 0)return null;let r=t.find(e=>e.operationId===n);if(r!==void 0)return $b(r,e,t);let i=rx(n,t),a=ji(i.noun),o=ax(e),s=Di([...a,...o.flatMap(({word:e})=>e)].join(` `),t,Oi).map(({item:e,score:t})=>({item:e,score:t+ix(e,a,o.map(({key:e})=>e))})).toSorted((e,t)=>Number(e.item.deprecated===!0)-Number(t.item.deprecated===!0)||Number(i.intent.has(t.item.intent))-Number(i.intent.has(e.item.intent))||Number(i.method.has(t.item.method))-Number(i.method.has(e.item.method))||t.score-e.score).slice(0,Yb).map(({item:e})=>Ci(e,!1)),c=s.map(e=>`${e.operationId} (${e.method} ${e.path})`);return si(`Operation ${n} is not in the MCP catalog.${c.length===0?``:` Closest operations: ${c.join(`, `)}.`}`,s.map(e=>`Use operationId ${e.operationId} with aventure_${e.intent}: ${e.method} ${e.path}; required inputs: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}.`))}function $b(e,t,n){let r=t.pathParams??{},i=e.parameter.filter(({in:e,required:t,name:n,legacyName:i})=>e===`path`&&t&&r[n]==null&&(i===void 0||r[i]==null)).map(({name:e})=>e);if(i.length===0)return null;let a=JSON.stringify({operationId:e.operationId,pathParams:{...r,...Object.fromEntries(i.map(e=>[e,`<${e}>`]))},...t.query===void 0?{}:{query:t.query}}),o=i.flatMap(t=>ex(e.path,t,n).map(e=>{let n=e.parameter.filter(e=>e.in===`query`&&e.schemaEnum===void 0),r=n.filter(e=>e.required),i=r.length>0?r:n.filter(e=>e.schemaType===`string`&&e.name!==`cursor`).slice(0,1),a=n.filter(e=>e.schemaType===`string`);return` Get ${t} from ${e.operationId} (${e.method} ${e.path}): aventure_${e.intent} ${JSON.stringify({operationId:e.operationId,...i.length===0?{}:{query:Object.fromEntries(i.map(e=>[e.name,`<${e.name}>`]))}})} returns the record whose id goes in pathParams.${t}${a.length===0?``:`; its query takes ${a.map(e=>e.name).join(`, `)}`}.`}));return si(`Missing path parameter${i.length===1?``:`s`} ${i.map(e=>`'${e}'`).join(`, `)} for ${e.operationId}. Path parameters go in pathParams: aventure_${e.intent} ${a}.${o.join(``)}`)}function ex(e,t,n){let r=`{${t}}`,i=e.slice(0,e.indexOf(r)+r.length),a=n.find(e=>e.method===`GET`&&e.path===i),o=a===void 0?void 0:nx(a);return o===void 0?[]:n.filter(e=>e.method===`GET`&&e.deprecated!==!0&&e.parameter.every(e=>e.in!==`path`)&&nx(e)===o).toSorted((e,t)=>Number(tx(t))-Number(tx(e)))}function tx(e){return e.intent===`lookup`||/lookup/iu.test(e.operationId)}function nx(e){let t=yi(bt().paths,e.operationId)?.operation.responses??{},n=new Set(Object.entries(t).filter(([e])=>e.startsWith(`2`)).map(([,e])=>e.content?.[`application/json`]?.schema?.$ref));return n.size===1?[...n][0]:void 0}function rx(e,t){let[n=``,...r]=Ni(e).split(` `),i=t.filter(e=>Ni(e.operationId).startsWith(`${n} `));return i.length>0&&r.length>0?{noun:r.join(` `),intent:new Set(i.map(e=>e.intent)),method:new Set(i.map(e=>e.method))}:{noun:e,intent:new Set,method:new Set}}function ix(e,t,n){let r=`${e.operationId} ${e.summary}`,i=new Set(ji(r)),a=Si(Ni(r)),o=t.reduce((e,t)=>e+(i.has(t)?2:+!!a.has(t)),0),s=new Set([...e.parameter,...(e.requestBody??[]).flatMap(e=>e.parameter)].map(({name:e})=>e)),c=n.filter(e=>s.has(e)).length,l=Si(t.join(` `)),u=ji(e.operationId).slice(1).filter(e=>!l.has(e)).length;return(o+2*c-u)*Zb}function ax(e){let t=e.body,n=typeof t==`object`&&t&&!Array.isArray(t)?Object.entries(t):[];return[...Object.entries(e.pathParams??{}),...Object.entries(e.query??{}),...n].map(([e,t])=>({key:e,word:typeof t==`string`&&t.length<=Xb?[e,t]:[e]}))}function ox({contract:e,input:t,intent:n,contracts:r,catalog:i}){let{operationId:a}=e;if(!n.includes(e.intent))return si(`Operation ${a} has intent=${e.intent}; call aventure_${e.intent} ${JSON.stringify({operationId:a,pathParams:t.pathParams,query:t.query,body:t.body})}.`);let o=i.find(e=>e.operationId===a)??e,s=o.parameter.filter(e=>e.in===`query`),c=Object.entries(t.query??{}),l=c.filter(([e])=>!Dt.includes(e)&&!s.some(t=>sx(t,e))),u=e.requestBody??[],d=u[0]?.schemaType===`array`,f=new Set((o.requestBody??[]).flatMap(e=>e.parameter.map(({name:e})=>e))),p=d?[]:l.filter(([e])=>f.has(e)),m=t.body===void 0&&u.some(e=>e.required&&e.kind!==`multipart`);if(l.length===0&&!m)return null;let h=typeof t.body==`object`&&t.body!==null&&!Array.isArray(t.body)?t.body:void 0,g=u[0]?.parameter??[],_=m?g.filter(({name:e,required:t})=>t&&!p.some(([t])=>t===e)).map(({name:e})=>e):[],v=d||t.body!==void 0&&h===void 0?t.body??[]:{...Object.fromEntries(_.map(e=>[e,`<${e}>`])),...h,...Object.fromEntries(p)},y=c.filter(([e])=>!l.some(([t])=>t===e)),b=JSON.stringify({operationId:a,...t.pathParams===void 0?{}:{pathParams:t.pathParams},...y.length===0?{}:{query:Object.fromEntries(y)},...u.length===0?{}:{body:v}}),x=e.parameter.filter(e=>e.in===`query`).map(({name:e})=>e),S=l.length===0?``:`${a} declares no query parameter ${lx(l)}; ${x.length===0?`it takes no query`:`its query takes ${x.join(`, `)}`}.`,C=p.length>0?` ${lx(p)} ${p.length===1?`is a request body field`:`are request body fields`}: send ${p.length===1?`it`:`them`} in body.`:m?` ${a} requires a request body: send it in body${g.length===0?``:`; its fields are ${g.map(({name:e})=>e).join(`, `)}`}.`:``;return si(`${S}${C} Call aventure_${e.intent} ${b}.${ux(e,r)}`.trim())}function sx(e,t){if(t===e.name||t===e.legacyName)return!0;let n=Number(/^\[(?<index>\d+)\]/u.exec(t.slice(e.name.length))?.groups?.index),r=Mi(e.name,0,``);return t.startsWith(e.name)&&Number.isInteger(n)&&(e.itemProperty??[]).some(i=>t===Mi(e.name,n,i.name.slice(r.length)))}var cx=/\b(?<method>GET|POST|PUT|PATCH|DELETE) (?<path>\/[^\s?),]*[^\s?),.])/u;function lx(e){return e.map(([e])=>`'${e}'`).join(`, `)}function ux(e,t){if(e.deprecated!==!0)return``;let n=/^Deprecated: (?<advice>.*?\.)(?=\s|$)/su.exec(e.description)?.groups?.advice;if(n===void 0)return` ${e.operationId} is deprecated.`;let r=cx.exec(n)?.groups,i=t.find(e=>e.method===r?.method&&e.path===r?.path);return` ${e.operationId} is deprecated: ${n}${i===void 0?``:` Its replacement is ${i.operationId}: call aventure_${i.intent} {"operationId":"${i.operationId}"}.`}`}function dx(e,t){return t?e:e.map(fx)}function fx(e){let t=e.parameter.flatMap(mx),n=px(e.requestBody);return gx(t,e.parameter)&&n===e.requestBody?e:{...e,parameter:t,...n===void 0?{}:{requestBody:n}}}function px(e){if(e===void 0)return;let t=e.map(e=>{let t=e.parameter.flatMap(mx);return gx(t,e.parameter)?e:{...e,parameter:t}});return t.every((t,n)=>t===e[n])?e:t}function mx(e){if(!hx(e))return[];let t=e.itemProperty?.filter(hx);return gx(t,e.itemProperty)?[e]:[{...e,...t===void 0||t.length===0?{}:{itemProperty:t}}]}var hx=e=>e.visibility!==`private`;function gx(e,t){return e===t?!0:e?.length!==t?.length||e===void 0||t===void 0?!1:e.every((e,n)=>e===t[n])}new RegExp(di.join(`|`),`i`);var _x;function vx(e){let t=_x??=Ai([...Pi,...Fi]),n=yx(oi(e,ki(e,t))),r=Ei(t,n.data,n.summary)??JSON.stringify(n);return{isError:!n.ok,structuredContent:n,content:[{type:`text`,text:r}]}}function yx(e){let{omitted:t,ids:n,counts:r,references:i,warnings:a,...o}=e;return{...o,...t.length>0?{omitted:t}:{},...n.length>0?{ids:n}:{},...Object.keys(r).length>0?{counts:r}:{},...i.length>0?{references:i}:{},...a.length>0?{warnings:a}:{}}}var bx=`aventure_status`,xx=`aventure_help`,Sx=`aventure_read`,Cx=`aventure_lookup`,wx=`aventure_search`,Tx=`aventure_write`,Ex=`aventure_delete`,Dx=[bx,xx,Sx,Cx,wx,Tx,Ex],Ox=I([W(),U(),H()]),kx=F(W(),I([W(),U()])).optional(),Ax=F(W(),I([Ox,B(Ox)])).optional(),jx=F(W(),W()).optional(),Mx=V([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`]),Nx=I([Ox,Ce(),B(me()),F(W(),me())]).optional().describe(`JSON request body. For multipart/form-data operations, pass an object keyed by form part name; binary part values are http(s) URLs.`),Px=G({operationId:W().optional().describe(`Exact OpenAPI operationId, as listed by aventure_help. Takes precedence over method and path.`),method:Mx.optional().describe(`HTTP method when resolving by method+path.`),path:W().optional().describe(`OpenAPI route template or concrete API path.`),pathParams:kx.describe(`Values for route template parameters.`),query:Ax.describe(`Query parameters.`),headers:jx.describe(`Headers declared by the selected OpenAPI operation.`),contentType:W().optional().describe(`Declared request media type; omit for the first supported descriptor.`),responseFormat:V([`auto`,`json`,`text`]).optional().describe(`Response format for endpoints that offer both JSON and text/plain.`)}),Fx=G({q:W().optional().describe(`Plain-English task text, ranked against operationId, path, CLI command, summary, description, and query-parameter enum values. This tool reads no argument named query. Omitting q returns the catalog head unranked.`),root:W().optional().describe(`Filter by resource or first CLI segment.`),method:Mx.optional().describe(`Filter by HTTP method.`),scope:V([`read`,`write`]).optional().describe(`Filter by required MCP auth scope.`),limit:xe().min(1).max(100).default(20).describe(`Maximum rows to return.`),resolve:H().default(!1).describe(`Resolve q to one operation with the server resolver (requires sign-in): operation advice with an mcpCall skeleton, a clarification between candidate operations, or an abstention. scope narrows it; root, method, and limit do not apply.`)}),Ix=Px.extend({body:Nx});async function Lx(e,t,n){let r=Pi.find(e=>e.intent===`status`&&e.resource===`status`);if(r===void 0)return si(`No system status operation exists in the generated catalog.`);let i;try{i=ui().host}catch(e){return si(e.message)}let a=await Jb({method:r.method,path:r.path,auth:r.projection.auth,requesterScope:e,signal:n});return{...a,data:{transportScope:e,permissionGrant:t?.permissionGrant,host:i,status:a.data}}}var Rx=(e,t)=>dx(Pi,t?.operationAccess===`ADMIN`||t===void 0&&e===`write`).filter(n=>(t===void 0?e===`write`||n.projection.scope===`read`&&(n.projection.auth===`read`||n.projection.auth===`none`):t.operationAccess!==`READ`||n.projection.scope===`read`||n.projection.visibility!==`private`)&&(t===void 0||t.operation.some(e=>e.operationId===n.operationId&&e.method===n.method&&e.path===n.path)));async function zx(e,t,n,r,i,a){let o=Qb(e,r)??$n(e);if(!o.ok)return si(o.summary,o.warnings);if(o.data===null)return si(`OpenAPI operation resolution returned no data.`);let{method:s,operation:c,path:l,template:u}=o.data,d=c.operationId,f=r.find(e=>e.operationId===d&&e.method.toLowerCase()===s&&e.path===u);if(f===void 0)return si(`Operation `+d+` is not in the MCP catalog.`);let p=ox({contract:f,input:e,intent:t,contracts:r,catalog:Pi});if(p!==null)return p;let m=_i(f.requestBody??[],e.contentType);if(!m.ok||m.data===null)return si(m.summary,m.warnings);let h=m.data;return f.intent===`delete`&&h===void 0&&e.body!==void 0?si(d+` does not accept a request body.`):await Jb({method:f.method,path:l,searchParams:e.query,headers:e.headers,body:e.body,contentType:e.contentType,auth:f.projection.auth,requesterScope:n,responseFormat:e.responseFormat,clientInfo:i,signal:a})}function Bx(e,t,n){let r=Rx(t,n),i=()=>e.server.getClientVersion();e.registerTool(bx,{title:`aVenture status`,annotations:{readOnlyHint:!0},description:`Return API status, host, MCP auth scope, and your role and permission grant. Scope write means some write is callable, not every write; aventure_help with scope write lists the writes this grant allows.`,inputSchema:G({})},async(e,r)=>vx(await Lx(t,n,r?.mcpReq.signal))),e.registerTool(xx,{title:`aVenture help`,annotations:{readOnlyHint:!0},description:`Lists the aVenture API operations this connection may call. Each row gives operationId, method, path, CLI command, intent (the aventure_<intent> tool that runs it), required scope, request body shape, and arguments. q ranks rows against a plain-English task without calling the API. resolve asks the server to resolve q to one operation and returns the aventure_<intent> call to run it.`,inputSchema:Fx},async(e,n)=>{if(e.resolve)return vx(await wi(t===`read`?{...e,scope:`read`}:e,r,Pi,(e,r)=>Jb({method:e.method,path:Ve(e.operationId,{}),body:r.body,auth:e.projection.auth,requesterScope:t,responseFormat:`json`,clientInfo:i(),signal:n?.mcpReq.signal})));let{summary:a,data:o,counts:s}=Ti(e,r);return vx(ci(a,o,{counts:s}))}),e.registerTool(Sx,{title:`aVenture read`,annotations:{readOnlyHint:!0},description:`Runs one catalog operation whose intent is read: fetch a record by id or slug, list the records attached to it, or list a collection. Put route values in pathParams and URL query values in query. Example for an aventure.vc profile URL, slug, website, or domain: {"operationId":"getEntityLookup","query":{"url":"https://aventure.vc/investors/firms/<slug>"}}. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`read`],t,r,i(),n?.mcpReq.signal))),e.registerTool(Cx,{title:`aVenture lookup`,annotations:{readOnlyHint:!1},description:`Runs one catalog operation whose intent is lookup: identify a record from a name plus clues (such as lookupRecord), resolve a ticker or other identifier, or run a batch, preview, or duplicate check. Most lookups are POST operations that take a JSON body. An exact aventure.vc profile URL, slug, website, or domain is a read, not a lookup: call aventure_read with operationId getEntityLookup (or getPersonLookup) and query {url} or {slug}. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`lookup`],t,r,i(),n?.mcpReq.signal))),e.registerTool(wx,{title:`aVenture search`,annotations:{readOnlyHint:!1,destructiveHint:!1},description:`Runs one catalog operation whose intent is search: search or filter companies, people, news, publications, content, links, or the web, or answer a question. It has no free-text argument of its own: pass search text and filters where the chosen operation declares them, in query or body. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`search`],t,r,i(),n?.mcpReq.signal))),r.some(e=>e.intent===`write`)&&e.registerTool(Tx,{title:`aVenture write`,annotations:{readOnlyHint:!1,destructiveHint:!0},description:`Runs one catalog operation whose intent is write, limited to the writes your grant allows: create or change records in the shared aVenture corpus where your grant permits curation, or submit an account or enrichment request such as a billing checkout, plan change, portal session, or entity or person enrichment; aventure_help with scope write lists your writes, and each takes effect immediately. Pass the body the operation declares. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`write`],t,r,i(),n?.mcpReq.signal))),r.some(e=>e.intent===`delete`)&&e.registerTool(Ex,{title:`aVenture delete`,annotations:{readOnlyHint:!1,destructiveHint:!0},description:`Runs one catalog operation whose intent is delete: remove one record, one link between records, or a named batch of links, from the shared aVenture corpus. Pass the body the operation declares, such as the list of links a batch delete names; a body sent to an operation that declares none is refused. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`delete`],t,r,i(),n?.mcpReq.signal)))}var Vx=pi().version,Hx={tools:{},events:{}};function Ux(e,t){let n=new Hv({name:`aventure-mcp-server`,title:`aVenture MCP Server`,version:Vx},{capabilities:Hx,instructions:bt().info?.description});return Bx(n,e,t),qb(n),n}var Wx=new Set([...Br.options,...ln.options].map(e=>e.shape.method.value)),Gx=new Set(Dx);function Kx(e){let t=typeof e==`object`&&e?Reflect.get(e,`method`):void 0,n=typeof e==`object`&&e?Reflect.get(e,`params`):void 0,r=typeof n==`object`&&n?Reflect.get(n,`name`):void 0;return{rpcMethod:typeof t==`string`&&Wx.has(t)?t:`other`,toolName:typeof r==`string`&&Gx.has(r)?r:`none`}}var qx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AddressError=void 0,e.AddressError=class extends Error{constructor(e,t){super(e),this.name=`AddressError`,this.parseMessage=t}}})),Jx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isInSubnet=n,e.isHostInSubnet=r,e.isGloballyReachable=i,e.offsetBigInt=a,e.isCorrect=o,e.prefixLengthFromMask=s,e.assertByteArray=c,e.numberToPaddedHex=l,e.stringToPaddedHex=u,e.testBit=d;var t=qx();function n(e){return this.subnetMask<e.subnetMask?!1:r.call(this,e)}function r(e){return this.binaryZeroPad().length===e.binaryZeroPad().length&&this.mask(e.subnetMask)===e.mask()}function i(e){let t=null;for(let n=0;n<e.length;n++){let i=e[n];i.reachable!==null&&r.call(this,i.subnet)&&(t===null||i.subnet.subnetMask>t.subnet.subnetMask)&&(t=i)}return t===null||t.reachable}function a(e,n,r,i){if(typeof n==`number`&&!Number.isSafeInteger(n)||typeof n!=`number`&&typeof n!=`bigint`)throw new t.AddressError(`${i} offset must be an integer`);let a=e+BigInt(n);if(a<BigInt(0)||a>(BigInt(1)<<BigInt(r))-BigInt(1))throw new t.AddressError(`${i} offset leaves the address space`);return a}function o(e){return function(){return this.addressMinusSuffix===this.correctForm()?this.subnetMask===e&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask):!1}}function s(e,n){let r=e.toString(2).padStart(n,`0`);if(r.length>n)throw new t.AddressError(`Invalid subnet mask.`);let i=r.indexOf(`0`);if(i===-1)return n;if(r.slice(i).includes(`1`))throw new t.AddressError(`Invalid subnet mask.`);return i}function c(e,n,r,i){if(e.length!==n)throw new t.AddressError(`${r} addresses require exactly ${n} bytes`);for(let n=0;n<e.length;n++)if(!Number.isInteger(e[n])||e[n]<i||e[n]>255)throw new t.AddressError(`All bytes must be integers between ${i} and 255`)}function l(e){return e.toString(16).padStart(2,`0`)}function u(e){return l(parseInt(e,10))}function d(e,t){let{length:n}=e;if(t>n)return!1;let r=n-t;return e.substring(r,r+1)===`1`}})),Yx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_SUBNET_STRING=e.RE_ADDRESS=e.GROUPS=e.BITS=void 0,e.BITS=32,e.GROUPS=4,e.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g,e.RE_SUBNET_STRING=/\/\d{1,2}$/,e.SPECIAL_PURPOSE=[[`0.0.0.0/8`,`This network`,!1],[`0.0.0.0/32`,`This host on this network`,!1],[`10.0.0.0/8`,`Private-Use`,!1],[`100.64.0.0/10`,`Shared Address Space`,!1],[`127.0.0.0/8`,`Loopback`,!1],[`169.254.0.0/16`,`Link Local`,!1],[`172.16.0.0/12`,`Private-Use`,!1],[`192.0.0.0/24`,`IETF Protocol Assignments`,!1],[`192.0.0.0/29`,`IPv4 Service Continuity Prefix`,!1],[`192.0.0.8/32`,`IPv4 dummy address`,!1],[`192.0.0.9/32`,`Port Control Protocol Anycast`,!0],[`192.0.0.10/32`,`Traversal Using Relays around NAT Anycast`,!0],[`192.0.0.170/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.0.171/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.2.0/24`,`Documentation (TEST-NET-1)`,!1],[`192.31.196.0/24`,`AS112-v4`,!0],[`192.52.193.0/24`,`AMT`,!0],[`192.88.99.0/24`,`Deprecated (6to4 Relay Anycast)`,null],[`192.88.99.2/32`,`6a44-relay anycast address`,!1],[`192.168.0.0/16`,`Private-Use`,!1],[`192.175.48.0/24`,`Direct Delegation AS112 Service`,!0],[`198.18.0.0/15`,`Benchmarking`,!1],[`198.51.100.0/24`,`Documentation (TEST-NET-2)`,!1],[`203.0.113.0/24`,`Documentation (TEST-NET-3)`,!1],[`240.0.0.0/4`,`Reserved`,!1],[`255.255.255.255/32`,`Limited Broadcast`,!1]]})),Xx=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Address4=void 0;var i=r(Jx()),a=r(Yx()),o=qx(),s=i.isCorrect(a.BITS),c=class e{constructor(e){this.addressMinusSuffix=``,this.groups=a.GROUPS,this.parsedAddress=[],this.parsedSubnet=``,this.subnet=`/32`,this.subnetMask=32,this.v4=!0,this.isCorrect=s,this.isInSubnet=i.isInSubnet,this.isHostInSubnet=i.isHostInSubnet,this.address=e;let t=a.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>a.BITS)throw new o.AddressError(`Invalid subnet mask.`);e=e.replace(a.RE_SUBNET_STRING,``)}let n=a.GROUPS*4-1;if(e.length>n)throw new o.AddressError(`IPv4 addresses are at most ${n} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}static isValid(t){try{return new e(t),!0}catch{return!1}}parse(e){let t=e.split(`.`);if(t.some(e=>/^0\d/.test(e)))throw new o.AddressError(`IPv4 addresses can't have leading zeroes.`);if(!e.match(a.RE_ADDRESS))throw new o.AddressError(`Invalid IPv4 address.`);return t}correctForm(){return this.parsedAddress.map(e=>parseInt(e,10)).join(`.`)}static fromAddressAndMask(t,n){let r=i.prefixLengthFromMask(new e(n).bigInt(),a.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(a.BITS))-BigInt(1),o=i.prefixLengthFromMask(r,a.BITS);return new e(`${t}/${o}`)}static fromWildcard(t){let n=t.split(`.`);if(n.length!==a.GROUPS)throw new o.AddressError(`Wildcard pattern must have 4 octets`);let r=-1;for(let e=0;e<n.length;e++)if(n[e]===`*`)r===-1&&(r=e);else if(r!==-1)throw new o.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");let i=r===-1?0:n.length-r,s=n.map(e=>e===`*`?`0`:e),c=a.BITS-i*8;return new e(`${s.join(`.`)}/${c}`)}static fromHex(t){let n=t.replace(/:/g,``);if(!/^[0-9a-fA-F]{8}$/.test(n))throw new o.AddressError(`IPv4 hex must be exactly 8 hex digits`);let r=[];for(let e=0;e<8;e+=2)r.push(parseInt(n.slice(e,e+2),16));return new e(r.join(`.`))}static fromInteger(t){if(!Number.isInteger(t)||t<0||t>4294967295)throw new o.AddressError(`IPv4 integer must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.?$/i,``).split(`.`).reverse().join(`.`);return new e(n)}toHex(){return this.parsedAddress.map(e=>i.stringToPaddedHex(e)).join(`:`)}toArray(){return this.parsedAddress.map(e=>parseInt(e,10))}toGroup6(){let e=[],t=0;for(;t<a.GROUPS;t+=2)e.push(`${i.stringToPaddedHex(this.parsedAddress[t])}${i.stringToPaddedHex(this.parsedAddress[t+1])}`);return e.join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(e=>i.stringToPaddedHex(e)).join(``)}`)}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(a.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}offset(t){return e.fromBigInt(i.offsetBigInt(this.bigInt(),t,a.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(i.offsetBigInt(this._endAddress(),1,a.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(a.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(a.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(a.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}static fromBigInt(t){if(t<BigInt(0)||t>BigInt(4294967295))throw new o.AddressError(`IPv4 BigInt must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromByteArray(e){return i.assertByteArray(e,4,`IPv4`,0),this.fromUnsignedByteArray(e)}static fromUnsignedByteArray(t){if(t.length!==4)throw new o.AddressError(`IPv4 addresses require exactly 4 bytes`);let n=t.join(`.`);return new e(n)}mask(e){return e===void 0&&(e=this.subnetMask),this.getBitsBase2(0,e)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}reverseForm(e){e||={};let t=this.correctForm().split(`.`).reverse().join(`.`);return e.omitSuffix?t:`${t}.in-addr.arpa.`}isMulticast(){return this.isHostInSubnet(l)}isPrivate(){return u.some(e=>this.isHostInSubnet(e))}isLoopback(){return this.isHostInSubnet(d)}isLinkLocal(){return this.isHostInSubnet(f)}isUnspecified(){return this.isHostInSubnet(p)}isBroadcast(){return this.isHostInSubnet(m)}isCGNAT(){return this.isHostInSubnet(h)}isDocumentation(){return g.some(e=>this.isHostInSubnet(e))}isBenchmarking(){return this.isHostInSubnet(_)}isReserved(){return this.isHostInSubnet(v)}isGlobal(){return!this.isMulticast()&&i.isGloballyReachable.call(this,y)}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(a.BITS,`0`)),this._binaryZeroPad}groupForV6(){let e=this.parsedAddress;return this.correctForm().replace(a.RE_ADDRESS,`<span class="hover-group group-v4 group-6">${e.slice(0,2).join(`.`)}</span>.<span class="hover-group group-v4 group-7">${e.slice(2,4).join(`.`)}</span>`)}};e.Address4=c;var l=new c(`224.0.0.0/4`),u=[new c(`10.0.0.0/8`),new c(`172.16.0.0/12`),new c(`192.168.0.0/16`)],d=new c(`127.0.0.0/8`),f=new c(`169.254.0.0/16`),p=new c(`0.0.0.0/32`),m=new c(`255.255.255.255/32`),h=new c(`100.64.0.0/10`),g=[new c(`192.0.2.0/24`),new c(`198.51.100.0/24`),new c(`203.0.113.0/24`)],_=new c(`198.18.0.0/15`),v=new c(`240.0.0.0/4`),y=a.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new c(e),reachable:t}))})),Zx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_URL_WITH_PORT=e.RE_URL=e.RE_ZONE_STRING=e.RE_SUBNET_STRING=e.RE_BAD_ADDRESS=e.RE_BAD_CHARACTERS=e.TYPES=e.SCOPES=e.GROUPS=e.BITS=void 0,e.BITS=128,e.GROUPS=8,e.SCOPES={0:`Reserved`,1:`Interface local`,2:`Link local`,4:`Admin local`,5:`Site local`,8:`Organization local`,14:`Global`,15:`Reserved`},e.TYPES={"ff01::1/128":`Multicast (All nodes on this interface)`,"ff01::2/128":`Multicast (All routers on this interface)`,"ff02::1/128":`Multicast (All nodes on this link)`,"ff02::2/128":`Multicast (All routers on this link)`,"ff05::2/128":`Multicast (All routers in this site)`,"ff02::5/128":`Multicast (OSPFv3 AllSPF routers)`,"ff02::6/128":`Multicast (OSPFv3 AllDR routers)`,"ff02::9/128":`Multicast (RIP routers)`,"ff02::a/128":`Multicast (EIGRP routers)`,"ff02::d/128":`Multicast (PIM routers)`,"ff02::16/128":`Multicast (MLDv2 reports)`,"ff01::fb/128":`Multicast (mDNSv6)`,"ff02::fb/128":`Multicast (mDNSv6)`,"ff05::fb/128":`Multicast (mDNSv6)`,"ff02::1:2/128":`Multicast (All DHCP servers and relay agents on this link)`,"ff05::1:2/128":`Multicast (All DHCP servers and relay agents in this site)`,"ff02::1:3/128":`Multicast (All DHCP servers on this link)`,"ff05::1:3/128":`Multicast (All DHCP servers in this site)`,"::/128":`Unspecified`,"::1/128":`Loopback`,"::ffff:0:0/96":`IPv4-mapped`,"ff00::/8":`Multicast`,"fe80::/10":`Link-local unicast`,"fc00::/7":`Unique local`,"2001::/32":`Teredo`,"2001:2::/48":`Benchmarking`,"2002::/16":`6to4`,"2001:db8::/32":`Documentation`,"3fff::/20":`Documentation`,"100::/64":`Discard-only`,"fec0::/10":`Site-local unicast (deprecated)`,"::/96":`IPv4-compatible (deprecated)`,"64:ff9b::/96":`NAT64 (well-known)`,"64:ff9b:1::/48":`NAT64 (local-use)`},e.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi,e.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,e.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,e.RE_ZONE_STRING=/%.*$/,e.RE_URL=/^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i,e.RE_URL_WITH_PORT=/^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i,e.SPECIAL_PURPOSE=[[`::1/128`,`Loopback Address`,!1],[`::/128`,`Unspecified Address`,!1],[`::ffff:0:0/96`,`IPv4-mapped Address`,!1],[`64:ff9b::/96`,`IPv4-IPv6 Translat.`,!0],[`64:ff9b:1::/48`,`IPv4-IPv6 Translat.`,!1],[`100::/64`,`Discard-Only Address Block`,!1],[`100:0:0:1::/64`,`Dummy IPv6 Prefix`,!1],[`2001::/23`,`IETF Protocol Assignments`,!1],[`2001::/32`,`TEREDO`,!1],[`2001:1::1/128`,`Port Control Protocol Anycast`,!0],[`2001:1::2/128`,`Traversal Using Relays around NAT Anycast`,!0],[`2001:1::3/128`,`DNS-SD Service Registration Protocol Anycast`,!0],[`2001:2::/48`,`Benchmarking`,!1],[`2001:3::/32`,`AMT`,!0],[`2001:4:112::/48`,`AS112-v6`,!0],[`2001:10::/28`,`Deprecated (previously ORCHID)`,null],[`2001:20::/28`,`ORCHIDv2`,!0],[`2001:30::/28`,`Drone Remote ID Protocol Entity Tags (DETs) Prefix`,!0],[`2001:db8::/32`,`Documentation`,!1],[`2002::/16`,`6to4`,!1],[`2620:4f:8000::/48`,`Direct Delegation AS112 Service`,!0],[`3fff::/20`,`Documentation`,!1],[`5f00::/16`,`Segment Routing (SRv6) SIDs`,!1],[`fc00::/7`,`Unique-Local`,!1],[`fe80::/10`,`Link-Local Unicast`,!1]]})),Qx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.escapeHtml=t,e.spanAllZeroes=n,e.spanAll=r,e.spanLeadingZeroes=a,e.simpleGroup=o;function t(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function n(e){return t(e).replace(/(0+)/g,`<span class="zero">$1</span>`)}function r(e,r=0){return e.split(``).map((e,i)=>`<span class="digit value-${t(e)} position-${i+r}">${n(e)}</span>`).join(``)}function i(e){return t(e).replace(/^(0+)/,`<span class="zero">$1</span>`)}function a(e){return e.split(`:`).map(e=>i(e)).join(`:`)}function o(e,t=0){return e.split(`:`).map((e,n)=>/group-v4/.test(e)?e:`<span class="hover-group group-${n+t}">${i(e)}</span>`)}})),$x=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.ADDRESS_BOUNDARY=void 0,e.groupPossibilities=a,e.padGroup=o,e.simpleRegularExpression=s,e.possibleElisions=c;var i=r(Zx());function a(e){return`(${e.join(`|`)})`}function o(e){return e.length<4?`0{0,${4-e.length}}${e}`:e}e.ADDRESS_BOUNDARY=`[^A-Fa-f0-9:]`;function s(e){let t=[];e.forEach((e,n)=>{parseInt(e,16)===0&&t.push(n)});let n=t.map(t=>e.map((e,n)=>{if(n===t){let t=n===0||n===i.GROUPS-1?`:`:``;return a([o(e),t])}return o(e)}).join(`:`));return n.push(e.map(o).join(`:`)),a(n)}function c(e,t,n){let r=t?``:`:`,i=n?``:`:`,o=[];!t&&!n&&o.push(`::`),t&&n&&o.push(``),(n&&!t||!n&&t)&&o.push(`:`),o.push(`${r}(:0{1,4}){1,${e-1}}`),o.push(`(0{1,4}:){1,${e-1}}${i}`),o.push(`(0{1,4}:){${e-1}}0{1,4}`);for(let t=1;t<e-1;t++)for(let n=1;n<e-t;n++)o.push(`(0{1,4}:){${n}}:(0{1,4}:){${e-n-t-1}}0{1,4}`);return a(o)}})),eS=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Address6=void 0;var i=r(Jx()),a=r(Yx()),o=r(Zx()),s=r(Qx()),c=Xx(),l=$x(),u=qx(),d=Jx(),f=i.isCorrect(o.BITS);function p(e){if(!e)throw Error(`Assertion failed.`)}function m(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,`$1,$2`);return e}function h(e){return e=e.replace(/^(0{1,})([1-9]+)$/,`<span class="parse-error">$1</span>$2`),e=e.replace(/^(0{1,})(0)$/,`<span class="parse-error">$1</span>$2`),e}function g(e,t){let n=[],r=[],i=0;for(;i<e.length;i++)i<t[0]?n.push(e[i]):i>t[1]&&r.push(e[i]);return n.concat([`compact`]).concat(r)}function _(e){return parseInt(e,16).toString(16).padStart(4,`0`)}function v(e){return e&255}var y=class e{constructor(e,t){this.addressMinusSuffix=``,this.parsedSubnet=``,this.subnet=`/128`,this.subnetMask=128,this.v4=!1,this.zone=``,this.isInSubnet=i.isInSubnet,this.isHostInSubnet=i.isHostInSubnet,this.isCorrect=f,this.groups=t===void 0?o.GROUPS:t,this.address=e;let n=o.RE_SUBNET_STRING.exec(e);if(n){if(this.parsedSubnet=n[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>o.BITS)throw new u.AddressError(`Invalid subnet mask.`);e=e.replace(o.RE_SUBNET_STRING,``)}if(/\//.test(e))throw new u.AddressError(`Invalid subnet mask.`);let r=o.RE_ZONE_STRING.exec(e);r&&(this.zone=r[0],e=e.replace(o.RE_ZONE_STRING,``));let a=this.groups*5+5;if(e.length>a)throw new u.AddressError(`IPv6 addresses are at most ${a} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new e(t),!0}catch{return!1}}static fromBigInt(t){if(t<BigInt(0)||t>(BigInt(1)<<BigInt(o.BITS))-BigInt(1))throw new u.AddressError(`IPv6 BigInt must be in the range 0 to 2**128 - 1`);let n=t.toString(16).padStart(32,`0`),r=[];for(let e=0;e<o.GROUPS;e++)r.push(n.slice(e*4,(e+1)*4));return new e(r.join(`:`))}static fromURL(t){let n,r=null,i,a,s=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``);if(s.indexOf(`[`)!==-1&&s.indexOf(`]:`)!==-1){if(a=`failed to parse address with port`,i=o.RE_URL_WITH_PORT.exec(s),i===null)return{error:a,address:null,port:null};n=i[1],r=i[2]}else{if(a=`failed to parse address from URL`,i=o.RE_URL.exec(s),i===null)return{error:a,address:null,port:null};n=i[1]??i[2]}r?(r=parseInt(r,10),(r<0||r>65535)&&(r=null)):r=null;let c;try{c=new e(n)}catch{return{error:a,address:null,port:null}}return{address:c,port:r}}static fromAddressAndMask(t,n){let r=i.prefixLengthFromMask(new e(n).bigInt(),o.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(o.BITS))-BigInt(1),a=i.prefixLengthFromMask(r,o.BITS);return new e(`${t}/${a}`)}static fromWildcard(t){if(t.includes(`%`)||t.includes(`/`))throw new u.AddressError(`Wildcard pattern must not include a zone or CIDR suffix`);let n=t.split(`::`);if(n.length>2)throw new u.AddressError(`Wildcard pattern cannot contain more than one '::'`);let r;if(n.length===2){let e=n[0]===``?[]:n[0].split(`:`),t=n[1]===``?[]:n[1].split(`:`),i=o.GROUPS-e.length-t.length;if(i<1)throw new u.AddressError(`Wildcard pattern with '::' has too many groups`);r=[...e,...Array(i).fill(`0`),...t]}else r=t.split(`:`);if(r.length!==o.GROUPS)throw new u.AddressError(`Wildcard pattern must have 8 groups`);let i=-1;for(let e=0;e<r.length;e++)if(r[e]===`*`)i===-1&&(i=e);else if(i!==-1)throw new u.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");let a=i===-1?0:r.length-i,s=r.map(e=>e===`*`?`0`:e),c=o.BITS-a*16;return new e(`${s.join(`:`)}/${c}`)}static fromAddress4(t){let n=new c.Address4(t),r=o.BITS-(a.BITS-n.subnetMask);return new e(`::ffff:${n.correctForm()}/${r}`)}static fromArpa(t){let n=t.replace(/(\.ip6\.arpa)?\.?$/i,``);if(!/^[0-9a-f](\.[0-9a-f]){0,31}$/i.test(n))throw new u.AddressError(`Invalid 'ip6.arpa' form.`);let r=n.split(`.`).reverse(),i=r.length*4,a=r.join(``).padEnd(32,`0`),s=[];for(let e=0;e<o.GROUPS;e++)s.push(a.slice(e*4,(e+1)*4));return new e(`${s.join(`:`)}/${i}`)}microsoftTranscription(){return`${this.correctForm().replace(/:/g,`-`)}.ipv6-literal.net`}mask(e=this.subnetMask){return this.getBitsBase2(0,e)}possibleSubnets(e=128){let t=o.BITS-this.subnetMask-Math.abs(e-o.BITS);return t<0?`0`:m((BigInt(`2`)**BigInt(t)).toString(10))}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(o.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(o.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}offset(t){return e.fromBigInt(i.offsetBigInt(this.bigInt(),t,o.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(i.offsetBigInt(this._endAddress(),1,o.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(o.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(o.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}getScope(){let e=this.getType();return e===`Multicast`||e.startsWith(`Multicast `)?o.SCOPES[parseInt(this.getBits(12,16).toString(10),10)]||`Unknown`:e===`Link-local unicast`||e===`Loopback`?`Link local`:e===`Unspecified`?`Unknown`:`Global`}getType(){for(let e=0;e<b.length;e++){let t=b[e];if(this.isHostInSubnet(t[0]))return t[1]}return`Global unicast`}getBits(e,t){return BigInt(`0b${this.getBitsBase2(e,t)}`)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}getBitsBase16(e,t){let n=t-e;if(n%4!=0)throw Error(`Length of bits to retrieve must be divisible by four`);return this.getBits(e,t).toString(16).padStart(n/4,`0`)}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,o.BITS)}reverseForm(e){e||={};let t=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,``).split(``).slice(0,t).reverse().join(`.`);return t>0?e.omitSuffix?n:`${n}.ip6.arpa.`:e.omitSuffix?``:`ip6.arpa.`}correctForm(){let e,t=[],n=0,r=[];for(e=0;e<this.parsedAddress.length;e++){let t=parseInt(this.parsedAddress[e],16);t===0&&n++,t!==0&&n>0&&(n>1&&r.push([e-n,e-1]),n=0)}n>1&&r.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let i=r.map(e=>e[1]-e[0]+1);if(r.length>0){let e=i.indexOf(Math.max(...i));t=g(this.parsedAddress,r[e])}else t=this.parsedAddress;for(e=0;e<t.length;e++)t[e]!==`compact`&&(t[e]=parseInt(t[e],16).toString(16));let a=t.join(`:`);return a=a.replace(/^compact$/,`::`),a=a.replace(/(^compact)|(compact$)/,`:`),a=a.replace(/compact/,``),a}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(o.BITS,`0`)),this._binaryZeroPad}parse4in6(e){if(e.indexOf(`.`)===-1)return e;let t=e.split(`:`),n=t.slice(-1)[0],r=n.split(`.`);if(r.length===a.GROUPS&&r.every(e=>/^\d{1,3}$/.test(e))&&r.some(e=>/^0\d/.test(e))){let e=r.map(h).join(`.`),n=t.slice(0,-1).map(s.escapeHtml).join(`:`),i=t.length>1?`:`:``;throw new u.AddressError(`IPv4 addresses can't have leading zeroes.`,`${n}${i}${e}`)}let i=n.match(a.RE_ADDRESS);if(i){this.parsedAddress4=i[0];let n=this.subnetMask>=96?`/${this.subnetMask-96}`:``;this.address4=new c.Address4(`${this.parsedAddress4}${n}`),this.v4=!0,t[t.length-1]=this.address4.toGroup6(),e=t.join(`:`)}return e}parse(e){e=this.parse4in6(e);let t=e.match(o.RE_BAD_CHARACTERS);if(t)throw new u.AddressError(`Bad character${t.length>1?`s`:``} detected in address: ${t.join(``)}`,e.replace(o.RE_BAD_CHARACTERS,`<span class="parse-error">$1</span>`));let n=e.match(o.RE_BAD_ADDRESS);if(n)throw new u.AddressError(`Address failed regex: ${n.join(``)}`,e.replace(o.RE_BAD_ADDRESS,`<span class="parse-error">$1</span>`));let r=[],i=e.split(`::`);if(i.length===2){let e=i[0].split(`:`),t=i[1].split(`:`);e.length===1&&e[0]===``&&(e=[]),t.length===1&&t[0]===``&&(t=[]);let n=this.groups-(e.length+t.length);if(!n)throw new u.AddressError(`Error parsing groups`);this.elidedGroups=n,this.elisionBegin=e.length,this.elisionEnd=e.length+this.elidedGroups,r=r.concat(e);for(let e=0;e<n;e++)r.push(`0`);r=r.concat(t)}else if(i.length===1)r=e.split(`:`),this.elidedGroups=0;else throw new u.AddressError(`Too many :: groups found`);if(r=r.map(e=>parseInt(e,16).toString(16)),r.length!==this.groups)throw new u.AddressError(`Incorrect number of groups found`);return r}canonicalForm(){return this.parsedAddress.map(_).join(`:`)}decimal(){return this.parsedAddress.map(e=>parseInt(e,16).toString(10).padStart(5,`0`)).join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(_).join(``)}`)}to4(){let e=this.binaryZeroPad().split(``),t=BigInt(`0b${e.slice(96,128).join(``)}`).toString(16).padStart(8,`0`);if(this.subnetMask>=96){let e=this.subnetMask-96,n=[];for(let e=0;e<8;e+=2)n.push(parseInt(t.slice(e,e+2),16));return new c.Address4(`${n.join(`.`)}/${e}`)}return c.Address4.fromHex(t)}to4in6(){let t=this.to4(),n=new e(this.parsedAddress.slice(0,6).join(`:`),6).correctForm(),r=``;return/:$/.test(n)||(r=`:`),n+r+t.correctForm()}inspectTeredo(){let e=this.getBitsBase16(0,32),t=(this.getBits(80,96)^BigInt(`0xffff`)).toString(),n=c.Address4.fromHex(this.getBitsBase16(32,64)),r=this.getBits(96,128),i=c.Address4.fromHex((r^BigInt(`0xffffffff`)).toString(16).padStart(8,`0`)),a=this.getBitsBase2(64,80),o=(0,d.testBit)(a,15),s=(0,d.testBit)(a,14),l=(0,d.testBit)(a,8),u=(0,d.testBit)(a,9),f=BigInt(`0b${a.slice(2,6)+a.slice(8,16)}`).toString(10);return{prefix:`${e.slice(0,4)}:${e.slice(4,8)}`,server4:n.address,client4:i.address,flags:a,coneNat:o,microsoft:{reserved:s,universalLocal:u,groupIndividual:l,nonce:f},udpPort:t}}inspect6to4(){let e=this.getBitsBase16(0,16),t=c.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:e.slice(0,4),gateway:t.address}}to6to4(){if(!this.is4())return null;let t=[`2002`,this.getBitsBase16(96,112),this.getBitsBase16(112,128),``,`/16`].join(`:`);return new e(t)}static fromAddress4Nat64(t,n=`64:ff9b::/96`){let r=new c.Address4(t),i=new e(n),a=i.subnetMask;if(a!==32&&a!==40&&a!==48&&a!==56&&a!==64&&a!==96)throw new u.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);let o=i.binaryZeroPad(),s=r.binaryZeroPad(),l;if(a===96)l=o.slice(0,96)+s;else{let e=64-a;l=[o.slice(0,a),s.slice(0,e),`00000000`,s.slice(e),`0`.repeat(56-(32-e))].join(``)}let d=BigInt(`0b${l}`).toString(16).padStart(32,`0`),f=[];for(let e=0;e<8;e++)f.push(d.slice(e*4,(e+1)*4));return new e(f.join(`:`))}toAddress4Nat64(t=`64:ff9b::/96`){let n=new e(t),r=n.subnetMask;if(r!==32&&r!==40&&r!==48&&r!==56&&r!==64&&r!==96)throw new u.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);if(!this.isHostInSubnet(n))return null;let i=this.binaryZeroPad(),a;if(r===96)a=i.slice(96,128);else{let e=64-r;a=i.slice(r,r+e)+i.slice(72,72+(32-e))}let o=[];for(let e=0;e<4;e++)o.push(parseInt(a.slice(e*8,(e+1)*8),2).toString());return new c.Address4(o.join(`.`))}toByteArray(){let e=this.bigInt().toString(16).padStart(o.BITS/4,`0`),t=[];for(let n=0,r=e.length;n<r;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}toUnsignedByteArray(){return this.toByteArray().map(v)}static fromByteArray(e){return i.assertByteArray(e,16,`IPv6`,-128),this.fromUnsignedByteArray(e.map(v))}static fromUnsignedByteArray(t){i.assertByteArray(t,16,`IPv6`,0);let n=BigInt(`256`),r=BigInt(`0`),a=BigInt(`1`);for(let e=t.length-1;e>=0;e--)r+=a*BigInt(t[e].toString(10)),a*=n;return e.fromBigInt(r)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){let e=this.embeddedIPv4();return e?e.isLinkLocal():this.isHostInSubnet(w)}isMulticast(){let e=this.embeddedIPv4();if(e)return e.isMulticast();let t=this.getType();return t===`Multicast`||t.startsWith(`Multicast `)}is4(){return this.v4}isMapped4(){return this.isHostInSubnet(O)}embeddedIPv4(){return this.isMapped4()||this.isHostInSubnet(k)?this.to4():null}isTeredo(){return this.isHostInSubnet(x)}is6to4(){return this.isHostInSubnet(S)}isLoopback(){let e=this.embeddedIPv4();return e?e.isLoopback():this.getType()===`Loopback`}isULA(){return this.isHostInSubnet(C)}isPrivate(){let e=this.embeddedIPv4();return e?e.isPrivate():this.isULA()||this.isHostInSubnet(A)}isCGNAT(){let e=this.embeddedIPv4();return e?e.isCGNAT():!1}isBroadcast(){let e=this.embeddedIPv4();return e?e.isBroadcast():!1}isUnspecified(){let e=this.embeddedIPv4();return e?e.isUnspecified():this.getType()===`Unspecified`}isDocumentation(){return T.some(e=>this.isHostInSubnet(e))}isBenchmarking(){let e=this.embeddedIPv4();return e?e.isBenchmarking():this.isHostInSubnet(ee)}isGlobal(){let e=this.embeddedIPv4();return e?e.isGlobal():this.isHostInSubnet(E)&&i.isGloballyReachable.call(this,D)}href(e){return e=e===void 0?``:`:${e}`,`http://[${this.correctForm()}]${e}/`}link(e){e||={},e.className===void 0&&(e.className=``),e.prefix===void 0&&(e.prefix=`/#address=`),e.v4===void 0&&(e.v4=!1);let t=this.correctForm;e.v4&&(t=this.to4in6);let n=t.call(this),r=s.escapeHtml(`${e.prefix}${n}`),i=s.escapeHtml(n);return e.className?`<a href="${r}" class="${s.escapeHtml(e.className)}">${i}</a>`:`<a href="${r}">${i}</a>`}group(){if(this.elidedGroups===0)return s.simpleGroup(this.addressMinusSuffix).join(`:`);p(typeof this.elidedGroups==`number`),p(typeof this.elisionBegin==`number`);let e=[],[t,n]=this.addressMinusSuffix.split(`::`);t.length?e.push(...s.simpleGroup(t)):e.push(``);let r=[`hover-group`];for(let e=this.elisionBegin;e<this.elisionBegin+this.elidedGroups;e++)r.push(`group-${e}`);return e.push(`<span class="${r.join(` `)}"></span>`),n.length?e.push(...s.simpleGroup(n,this.elisionEnd)):e.push(``),this.is4()&&(p(this.address4 instanceof c.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(`:`)}regularExpressionString(t=!1){let n=[],r=new e(this.correctForm());if(r.elidedGroups===0)n.push((0,l.simpleRegularExpression)(r.parsedAddress));else if(r.elidedGroups===o.GROUPS)n.push((0,l.possibleElisions)(o.GROUPS));else{let e=r.address.split(`::`);e[0].length&&n.push((0,l.simpleRegularExpression)(e[0].split(`:`))),p(typeof r.elidedGroups==`number`),n.push((0,l.possibleElisions)(r.elidedGroups,e[0].length!==0,e[1].length!==0)),e[1].length&&n.push((0,l.simpleRegularExpression)(e[1].split(`:`))),n=[n.join(`:`)]}return t||(n=[`(?=^|`,l.ADDRESS_BOUNDARY,`|[^\\w\\:])(`,...n,`)(?=[^\\w\\:]|`,l.ADDRESS_BOUNDARY,`|$)`]),n.join(``)}regularExpression(e=!1){return new RegExp(this.regularExpressionString(e),`i`)}};e.Address6=y;var b=Object.keys(o.TYPES).map(e=>[new y(e),o.TYPES[e]]),x=new y(`2001::/32`),S=new y(`2002::/16`),C=new y(`fc00::/7`),w=new y(`fe80::/10`),T=[new y(`2001:db8::/32`),new y(`3fff::/20`)],ee=new y(`2001:2::/48`),E=new y(`2000::/3`),D=o.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new y(e),reachable:t})),O=new y(`::ffff:0:0/96`),k=new y(`64:ff9b::/96`),A=new y(`64:ff9b:1::/48`)})),tS=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.v6=e.AddressError=e.Address6=e.Address4=void 0;var i=Xx();Object.defineProperty(e,"Address4",{enumerable:!0,get:function(){return i.Address4}});var a=eS();Object.defineProperty(e,"Address6",{enumerable:!0,get:function(){return a.Address6}});var o=qx();Object.defineProperty(e,"AddressError",{enumerable:!0,get:function(){return o.AddressError}}),e.v6={helpers:r(Qx())}}))(),nS=n(Kc(),1),rS=new tS.Address6(`::/96`);function iS(e,t=56){if(Hi(e)){let n=new tS.Address6(e);if(n.isMapped4()||n.is4()&&n.isInSubnet(rS))return n.to4().correctForm();if(t)return new tS.Address6(`${e}/${t}`).networkForm()}return e}var aS=class{constructor(e){this.validations=e,this.previous=new Map,this.current=new Map,this.localKeys=!0}init(e){this.windowMs=e.windowMs,this.validations?.windowMs(this.windowMs),this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.clearExpired()},this.windowMs),this.interval.unref?.()}async get(e){return this.current.get(e)??this.previous.get(e)}async increment(e){let t=this.getClient(e),n=Date.now();return t.resetTime.getTime()<=n&&this.resetClient(t,n),t.totalHits++,t}async decrement(e){let t=this.getClient(e);t.totalHits>0&&t.totalHits--}async resetKey(e){this.current.delete(e),this.previous.delete(e)}async resetAll(){this.current.clear(),this.previous.clear()}shutdown(){clearInterval(this.interval),this.resetAll()}resetClient(e,t=Date.now()){return e.totalHits=0,e.resetTime.setTime(t+this.windowMs),e}getClient(e){if(this.current.has(e))return this.current.get(e);let t;return this.previous.has(e)?(t=this.previous.get(e),this.previous.delete(e)):(t={totalHits:0,resetTime:new Date},this.resetClient(t)),this.current.set(e,t),t}clearExpired(){this.previous=this.current,this.current=new Map}},oS={warn(...e){console.warn(...e.reverse())},error(...e){console.error(...e.reverse())}},sS=[`draft-6`,`draft-7`,`draft-8`],cS=(e,t)=>{let n;if(t){let e=Math.ceil((t.getTime()-Date.now())/1e3);n=Math.max(0,e)}else n=Math.ceil(e/1e3);return n},lS=e=>{let t=Ui(`sha256`);t.update(e);let n=t.digest(`hex`).slice(0,12);return Ri.from(n).toString(`base64`)},uS=(e,t)=>{e.headersSent||(e.setHeader(`X-RateLimit-Limit`,t.limit.toString()),e.setHeader(`X-RateLimit-Remaining`,t.remaining.toString()),t.resetTime instanceof Date&&(e.setHeader(`Date`,new Date().toUTCString()),e.setHeader(`X-RateLimit-Reset`,Math.ceil(t.resetTime.getTime()/1e3).toString())))},dS=(e,t,n)=>{if(e.headersSent)return;let r=Math.ceil(n/1e3),i=cS(n,t.resetTime);e.setHeader(`RateLimit-Policy`,`${t.limit};w=${r}`),e.setHeader(`RateLimit-Limit`,t.limit.toString()),e.setHeader(`RateLimit-Remaining`,t.remaining.toString()),typeof i==`number`&&e.setHeader(`RateLimit-Reset`,i.toString())},fS=(e,t,n)=>{if(e.headersSent)return;let r=Math.ceil(n/1e3),i=cS(n,t.resetTime);e.setHeader(`RateLimit-Policy`,`${t.limit};w=${r}`),e.setHeader(`RateLimit`,`limit=${t.limit}, remaining=${t.remaining}, reset=${i}`)},pS=(e,t,n,r,i)=>{if(e.headersSent)return;let a=Math.ceil(n/1e3),o=cS(n,t.resetTime),s=lS(i),c=`r=${t.remaining}; t=${o}`,l=`q=${t.limit}; w=${a}; pk=:${s}:`;e.append(`RateLimit`,`"${r}"; ${c}`),e.append(`RateLimit-Policy`,`"${r}"; ${l}`)},mS=(e,t,n,r)=>{if(e.headersSent)return;let i=r??cS(n,t.resetTime);e.setHeader(`Retry-After`,i.toString())},hS=e=>{let t={};for(let n of Object.keys(e)){let r=n;e[r]!==void 0&&(t[r]=e[r])}return t},gS=class extends Error{constructor(e,t){let n=`https://express-rate-limit.github.io/${e}/`;super(`${t} See ${n} for more information.`),this.name=this.constructor.name,this.code=e,this.help=n}},_S=class extends gS{},vS=new Set,yS=new WeakMap,bS={enabled:{default:!0},disable(){for(let e of Object.keys(this.enabled))this.enabled[e]=!1},ip(e){if(e===void 0)throw new gS(`ERR_ERL_UNDEFINED_IP_ADDRESS`,`An undefined 'request.ip' was detected. This might indicate a misconfiguration or the connection being destroyed prematurely.`);if(!Bi(e))throw new gS(`ERR_ERL_INVALID_IP_ADDRESS`,`An invalid 'request.ip' (${e}) was detected. Consider passing a custom 'keyGenerator' function to the rate limiter.`)},trustProxy(e){if(e.app.get(`trust proxy`)===!0)throw new gS(`ERR_ERL_PERMISSIVE_TRUST_PROXY`,`The Express 'trust proxy' setting is true, which allows anyone to trivially bypass IP-based rate limiting.`)},xForwardedForHeader(e){if(e.headers[`x-forwarded-for`]&&e.app.get(`trust proxy`)===!1)throw new gS(`ERR_ERL_UNEXPECTED_X_FORWARDED_FOR`,`The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users.`)},forwardedHeader(e){if(e.headers.forwarded&&e.ip===e.socket?.remoteAddress)throw new gS(`ERR_ERL_FORWARDED_HEADER`,`The 'Forwarded' header (standardized X-Forwarded-For) is set but currently being ignored. Add a custom keyGenerator to use a value from this header.`)},positiveHits(e){if(typeof e!=`number`||e<1||e!==Math.round(e))throw new gS(`ERR_ERL_INVALID_HITS`,`The totalHits value returned from the store must be a positive integer, got ${e}`)},unsharedStore(e){if(vS.has(e)){let t=e?.localKeys?``:` (with a unique prefix)`;throw new gS(`ERR_ERL_STORE_REUSE`,`A Store instance must not be shared across multiple rate limiters. Create a new instance of ${e.constructor.name}${t} for each limiter instead.`)}vS.add(e)},singleCount(e,t,n){let r=yS.get(e);r||(r=new Map,yS.set(e,r));let i=t.localKeys?t:t.constructor.name,a=r.get(i);a||(a=[],r.set(i,a));let o=`${t.prefix??``}${n}`;if(a.includes(o))throw new gS(`ERR_ERL_DOUBLE_COUNT`,`The hit count for ${n} was incremented more than once for a single request.`);a.push(o)},limit(e){if(e===0)throw new _S(`WRN_ERL_MAX_ZERO`,`Setting limit or max to 0 disables rate limiting in express-rate-limit v6 and older, but will cause all requests to be blocked in v7`)},draftPolliHeaders(e){if(e)throw new _S(`WRN_ERL_DEPRECATED_DRAFT_POLLI_HEADERS`,`The draft_polli_ratelimit_headers configuration option is deprecated and has been removed in express-rate-limit v7, please set standardHeaders: 'draft-6' instead.`)},onLimitReached(e){if(e)throw new _S(`WRN_ERL_DEPRECATED_ON_LIMIT_REACHED`,`The onLimitReached configuration option is deprecated and has been removed in express-rate-limit v7.`)},headersDraftVersion(e){if(typeof e!=`string`||!sS.includes(e))throw new gS(`ERR_ERL_HEADERS_UNSUPPORTED_DRAFT_VERSION`,`standardHeaders: only the following versions of the IETF draft specification are supported: ${sS.join(`, `)}.`)},headersResetTime(e){if(!e)throw new gS(`ERR_ERL_HEADERS_NO_RESET`,`standardHeaders: 'draft-7' requires a 'resetTime', but the store did not provide one. The 'windowMs' value will be used instead, which may cause clients to wait longer than necessary.`)},knownOptions(e){if(!e)return;let t=Object.keys({windowMs:!0,limit:!0,message:!0,statusCode:!0,legacyHeaders:!0,standardHeaders:!0,identifier:!0,retryAfter:!0,requestPropertyName:!0,skipFailedRequests:!0,skipSuccessfulRequests:!0,keyGenerator:!0,ipv6Subnet:!0,handler:!0,skip:!0,requestWasSuccessful:!0,store:!0,validate:!0,headers:!0,max:!0,passOnStoreError:!0,logger:!0}).concat(`draft_polli_ratelimit_headers`,`delayAfter`,`delayMs`,`maxDelayMs`);for(let n of Object.keys(e))if(!t.includes(n))throw new gS(`ERR_ERL_UNKNOWN_OPTION`,`Unexpected configuration option: ${n}`)},validationsConfig(){let e=Object.keys(this).filter(e=>![`enabled`,`disable`].includes(e));e.push(`default`);for(let t of Object.keys(this.enabled))if(!e.includes(t))throw new gS(`ERR_ERL_UNKNOWN_VALIDATION`,`options.validate.${t} is not recognized. Supported validate options are: ${e.join(`, `)}.`)},creationStack(e){let{stack:t}=Error(`express-rate-limit validation check (set options.validate.creationStack=false to disable)`);if(t?.includes(`Layer.handle [as handle_request]`)||t?.includes(`Layer.handleRequest`))throw e.localKeys?new gS(`ERR_ERL_CREATED_IN_REQUEST_HANDLER`,`express-rate-limit instance should be created at app initialization, not when responding to a request.`):new gS(`ERR_ERL_CREATED_IN_REQUEST_HANDLER`,`express-rate-limit instance should *usually* be created at app initialization, not when responding to a request.`)},ipv6Subnet(e){if(e!==!1&&(!Number.isInteger(e)||e<32||e>64))throw new gS(`ERR_ERL_IPV6_SUBNET`,`Unexpected ipv6Subnet value: ${e}. Expected an integer between 32 and 64 (usually 48-64).`)},ipv6SubnetOrKeyGenerator(e){if(e.ipv6Subnet!==void 0&&e.keyGenerator)throw new gS(`ERR_ERL_IPV6SUBNET_OR_KEYGENERATOR`,`Incompatible options: the 'ipv6Subnet' option is ignored when a custom 'keyGenerator' function is also set.`)},keyGeneratorIpFallback(e){if(!e)return;let t=e.toString();if((t.includes(`req.ip`)||t.includes(`request.ip`))&&!t.includes(`ipKeyGenerator`))throw new gS(`ERR_ERL_KEY_GEN_IPV6`,`Custom keyGenerator appears to use request IP without calling the ipKeyGenerator helper function for IPv6 addresses. This could allow IPv6 users to bypass limits.`)},windowMs(e){let t=2**31-1;if(typeof e!=`number`||Number.isNaN(e)||e<1||e>t)throw new gS(`ERR_ERL_WINDOW_MS`,`Invalid windowMs value: ${e}${typeof e==`number`?``:` (${typeof e})`}, must be a number between 1 and ${t} when using the default MemoryStore`)}};function xS(e){if(typeof e!=`object`||typeof e.error!=`function`||typeof e.warn!=`function`)throw TypeError(`Provided logger does not implement the Logger interface`)}var SS=(e,t)=>{xS(t);let n;n=typeof e==`boolean`?{default:e}:{default:!0,...e};let r={enabled:n};for(let[e,i]of Object.entries(bS))typeof i==`function`&&(r[e]=(...a)=>{if(n[e]??n.default){n[e]=!1;try{i.apply(r,a)}catch(e){e instanceof _S?t.warn(e):t.error(e)}}});let i=Symbol.for(`nodejs.util.inspect.custom`);return i&&(r[i]=()=>r.enabled),r},CS=e=>typeof e.incr==`function`&&typeof e.increment!=`function`,wS=e=>{if(!CS(e))return e;let t=e;class n{async increment(e){return new Promise((n,r)=>{t.incr(e,(e,t,i)=>{e&&r(e),n({totalHits:t,resetTime:i})})})}async decrement(e){return t.decrement(e)}async resetKey(e){return t.resetKey(e)}async resetAll(){if(typeof t.resetAll==`function`)return t.resetAll()}}return new n},TS=e=>{let{validations:t,...n}=e;return{...n,validate:t.enabled}},ES=e=>{let t=hS(e),n=e.logger??oS,r=SS(t?.validate??!0,n);r.validationsConfig(),r.knownOptions(e),r.draftPolliHeaders(t.draft_polli_ratelimit_headers),r.onLimitReached(t.onLimitReached),t.ipv6Subnet!==void 0&&typeof t.ipv6Subnet!=`function`&&r.ipv6Subnet(t.ipv6Subnet),r.keyGeneratorIpFallback(t.keyGenerator),r.ipv6SubnetOrKeyGenerator(t);let i=t.standardHeaders??!1;i===!0&&(i=`draft-6`);let a={windowMs:6e4,limit:e.max??5,message:`Too many requests, please try again later.`,statusCode:429,legacyHeaders:e.headers??!0,identifier(e,t){let n=``,{limit:r}=e[a.requestPropertyName],i=a.windowMs/1e3,o=a.windowMs/6e4,s=a.windowMs/36e5,c=a.windowMs/864e5;return n=i<60?`${i}sec`:o<60?`${o}min`:s<24?`${s}hr${s>1?`s`:``}`:`${c}day${c>1?`s`:``}`,`${r}-in-${n}`},requestPropertyName:`rateLimit`,skipFailedRequests:!1,skipSuccessfulRequests:!1,requestWasSuccessful:(e,t)=>t.statusCode<400,skip:(e,t)=>!1,async keyGenerator(e,t){r.ip(e.ip),r.trustProxy(e),r.xForwardedForHeader(e),r.forwardedHeader(e);let n=e.ip,i=56;return Hi(n)&&(i=typeof a.ipv6Subnet==`function`?await a.ipv6Subnet(e,t):a.ipv6Subnet,typeof a.ipv6Subnet==`function`&&r.ipv6Subnet(i)),iS(n,i)},ipv6Subnet:56,async handler(e,t,n,r){t.status(a.statusCode);let i=typeof a.message==`function`?await a.message(e,t):a.message;t.writableEnded||t.send(i)},passOnStoreError:!1,...t,standardHeaders:i,store:wS(t.store??new aS(r)),validations:r,logger:n};if(typeof a.store.increment!=`function`||typeof a.store.decrement!=`function`||typeof a.store.resetKey!=`function`||a.store.resetAll!==void 0&&typeof a.store.resetAll!=`function`||a.store.init!==void 0&&typeof a.store.init!=`function`)throw TypeError("An invalid store was passed. Please ensure that the store is a class that implements the `Store` interface.");return a},DS=e=>async(t,n,r)=>{try{await Promise.resolve(e(t,n,r)).catch(r)}catch(e){r(e)}},OS=e=>{let t=ES(e??{}),n=TS(t),r=(0,nS.default)(`express-rate-limit`);r(`creating new rate limiter with %o`,t.store.constructor.name);for(let[e,n]of Object.entries(t))r(`set %s to %o`,e,n);if(t.validations.creationStack(t.store),t.validations.unsharedStore(t.store),typeof t.store.init==`function`){r(`executing init for store`);try{let e=t.store.init(n);e instanceof Promise&&e.catch(e=>t.logger.error(e,`express-rate-limit: async error during store initialization.`))}catch(e){t.logger.error(e,`express-rate-limit: error during store initialization.`)}}let i=DS(async(e,i,a)=>{let o=t.skipFailedRequests&&new Promise(e=>i.once(`close`,e)),s=(t.skipFailedRequests||t.skipSuccessfulRequests)&&new Promise(e=>i.once(`finish`,e)),c=t.skipFailedRequests&&new Promise(e=>i.once(`error`,e));if(r(`requested %o`,e.originalUrl),r(`request from ip %o`,e.ip),await t.skip(e,i)){r(`skipping request`),a();return}let l=e,u=await t.keyGenerator(e,i);r(`computed key %o`,u),r(`incrementing count`);let d=0,f;try{let e=await t.store.increment(u);d=e.totalHits,f=e.resetTime}catch(e){if(t.passOnStoreError){t.logger.error(e,`express-rate-limit: error from store, allowing request without rate-limiting.`),a();return}throw e}t.validations.positiveHits(d),t.validations.singleCount(e,t.store,u);let p=await(typeof t.limit==`function`?t.limit(e,i):t.limit);t.validations.limit(p);let m={limit:p,used:d,remaining:Math.max(p-d,0),resetTime:f,key:u};for(let[e,n]of Object.entries(m))r(`set request.%s.%s to be %o`,t.requestPropertyName,e,n);if(Object.defineProperty(m,"current",{configurable:!1,enumerable:!1,value:d}),l[t.requestPropertyName]=m,t.legacyHeaders&&!i.headersSent&&(r(`set legacy headers`),uS(i,m)),t.standardHeaders&&!i.headersSent)switch(t.standardHeaders){case`draft-6`:r(`set ietf draft 6 headers`),dS(i,m,t.windowMs);break;case`draft-7`:r(`set ietf draft 7 headers`),t.validations.headersResetTime(m.resetTime),fS(i,m,t.windowMs);break;case`draft-8`:{let n=await(typeof t.identifier==`function`?t.identifier(e,i):t.identifier);r(`set ietf draft 8 headers`),r(`set name to %o`,n),t.validations.headersResetTime(m.resetTime),pS(i,m,t.windowMs,n,u);break}default:t.validations.headersDraftVersion(t.standardHeaders)}if(t.skipFailedRequests||t.skipSuccessfulRequests){let n=!1,a=async()=>{if(!n){if(f&&Date.now()>=f.getTime())return;r(`decrementing count`),await t.store.decrement(u),n=!0}};t.skipFailedRequests&&(s&&s.then(async()=>{let n=await t.requestWasSuccessful(e,i);r(`computed requestWasSuccessful as %o`,n),n||await a()}),o&&o.then(async()=>{i.writableEnded||await a()}),c&&c.then(async()=>{await a()})),t.skipSuccessfulRequests&&s&&s.then(async()=>{let n=await t.requestWasSuccessful(e,i);r(`computed requestWasSuccessful as %o`,n),n&&await a()})}if(d>p){if(r(`limit exceeded`),t.legacyHeaders||t.standardHeaders){r(`set retry-after header`);let n=await(typeof t.retryAfter==`function`?t.retryAfter(e,i):t.retryAfter);mS(i,m,t.windowMs,n)}t.handler(e,i,a,n);return}a()});return i.resetKey=t.store.resetKey.bind(t.store),i.getKey=typeof t.store.get==`function`?t.store.get.bind(t.store):()=>{throw Error(`The current store does not support the get/getKey method`)},i},kS=Pi.map(({operationId:e,method:t,path:n,parameter:r})=>({operationId:e,method:t,path:n,authorizationPath:bi(n,Object.fromEntries(r.filter(e=>e.in===`path`).map(e=>e.schemaEnum?.[0]===void 0?e.schemaFormat===`uuid`?[e.name,Wi()]:e.schemaType===`integer`||e.schemaType===`number`?[e.name,1]:[e.name,`authorization-probe`]:[e.name,e.schemaEnum[0]])),e)})),AS={ttlMs:6e4,maxEntries:128,verificationDeadlineMs:1e4,maxConcurrentVerifications:16,maxOverBudgetVerifications:2},jS=()=>new Ge({status:429,title:`Too Many Requests`,type:`about:blank`,detail:`Too many credential verifications are in progress; retry shortly.`,retryAfterSeconds:1});function MS(e){if(!e.includes(`.`))return 1/0;try{let{exp:t}=Ye(e);return t===void 0?1/0:t*1e3}catch(e){if(!(e instanceof at))throw e;return 1/0}}var NS=(e,t)=>`${Ui(`sha256`).update(e).digest(`hex`)} ${t?.href??``}`;function PS(e=AS){let t=new Map,n={limit:e.maxConcurrentVerifications,inFlight:0},r={limit:e.maxOverBudgetVerifications,inFlight:0},i=(i,a,o)=>{let s=NS(i,a),c=t.get(s);if(c!==void 0&&c.expiresAt>Date.now())return t.delete(s),t.set(s,c),c.verification;let l=o?[n,r]:[n];if(l.some(({inFlight:e,limit:t})=>e>=t))return Promise.reject(jS());t.delete(s);for(let e of l)e.inFlight+=1;let u=()=>{for(let e of l)--e.inFlight},d=Yn(i,a,kS,AbortSignal.timeout(e.verificationDeadlineMs)),f={verification:d,expiresAt:1/0};t.set(s,f);for(let n of t.keys()){if(t.size<=e.maxEntries)break;t.delete(n)}let p=()=>{t.get(s)===f&&t.delete(s)};return d.then(t=>{u(),t===null||t===`forbidden`?p():f.expiresAt=Math.min(Date.now()+e.ttlMs,MS(i))},()=>{u(),p()}),d},a=(e,n)=>{let r=hb(e.header(`authorization`));if(r===void 0)return!1;let i=t.get(NS(r,n))?.expiresAt;return i!==void 0&&Number.isFinite(i)&&i>Date.now()},o=async(e,t,n)=>{let r=hb(e.header(`authorization`));if(r===void 0)return{ok:!1,reason:`missing_credential`,hasAuthorization:!1};try{let e=await i(r,t,n);if(e===`forbidden`)return{ok:!1,reason:`forbidden`,hasAuthorization:!0};if(e!==null)return{ok:!0,scope:e.operationAccess===`READ`?`read`:`write`,userBearerToken:r,authorization:e}}catch(e){if(!(e instanceof at))throw e;N({component:`aventure-mcp-server`,event:`invalid_bearer_jwt`,fields:{requestId:hi()},error:e})}return{ok:!1,reason:`credential_mismatch`,hasAuthorization:!0}},s=new WeakMap,c=(e,t,n=!1)=>{let r=s.get(e);if(r!==void 0&&r.resourceHref===t?.href)return r.decision;let i=o(e,t,n);return s.set(e,{resourceHref:t?.href,decision:i}),i};return Object.assign((e,t)=>c(e,t),{holdsGrant:a,admitsOverBudget:(e,t)=>hb(e.header(`authorization`))===void 0?Promise.resolve(!1):c(e,t,!0).then(e=>e.ok,()=>!1)})}function FS(e,t){let n=new WeakMap;return[OS({windowMs:6e4,limit:120,skipSuccessfulRequests:!0,skip:async n=>e.holdsGrant(n,await t()),handler:(...[e,,t,r])=>{n.set(e,r),t()}}),async(r,i,a)=>{let o=n.get(r);o===void 0||await e.admitsOverBudget(r,await t())?a():i.status(o.statusCode).send(o.message)},OS({windowMs:6e4,limit:120,keyGenerator:IS})]}function IS(e){let t=hb(e.header(`authorization`));return t===void 0?iS(e.ip??``):Ui(`sha256`).update(t).digest(`base64url`)}function LS(e,t){let n=`an API key from https://aventure.vc/settings/api-keys as Authorization: Bearer <key>`,r=t?`Sign in with OAuth through the authorization server in this server's resource metadata; a client that cannot register itself needs the OAuth client ID at https://docs.aventure.vc/mcp. Or send ${n}.`:`Send ${n}. This server advertises no OAuth authorization server.`;return e===`forbidden`?`The supplied credential is valid, but its account may not use this MCP server.`:e===`missing_credential`?r:`The supplied credential was rejected or expired; reconnect this server in the MCP client to sign in again. ${r}`}var RS=1024,zS=RS*RS,BS=1,VS=2,HS=`b`,US=`kb`,WS=`mb`,GS=/^(\d+(?:\.\d+)?)\s*(b|kb|mb)?$/u;function KS(e){let t=JS(e.limit),n=qS(e.path);return(r,i,a)=>{if(t===void 0||r.method!==`POST`||qS(r.path)!==n){a();return}let o=YS(r.header(`content-length`));if(o===void 0||o<=t){a();return}i.setHeader(`Connection`,`close`),e.reject(i)}}function qS(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;return t===``?`/`:t}function JS(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=0?e:void 0;let t=GS.exec(e.trim().toLowerCase());if(t===null)return;let n=Number(t[BS]);if(Number.isFinite(n))switch(t[VS]??HS){case WS:return Math.floor(n*zS);case US:return Math.floor(n*RS);case HS:return Math.floor(n)}}function YS(e){if(e===void 0)return;let t=Number(e);return Number.isInteger(t)&&t>=0?t:void 0}var XS=400,ZS=400,QS=413,$S=`10mb`,eC=`127.0.0.1`,tC=/^[\w.:/-]{1,128}$/,nC=`0.0.0.0`;async function rC(e){let t=e.jsonBodyLimit??$S,n=PS(),r=e.host??eC,i=r!==nC,a=(t,n)=>{let r=`${t.protocol}://${t.host}`;return URL.canParse(e.path,r)&&new URL(e.path,r).href===n?.resourceUrl.href?n:void 0},o=(0,Hd.default)();o.disable(`x-powered-by`),o.set(`trust proxy`,1),o.use((e,t,n)=>{let r=e.get(`x-client-request-id`)??``,i=tC.test(r)?r:Wi(),a=performance.now(),o={requestId:i,method:e.method,path:e.path,host:e.hostname,userAgent:e.get(`user-agent`)},s=oC(e);s||E({component:`aventure-mcp-server`,event:`http_request`,fields:o}),t.on(`finish`,()=>{let n=Math.round(performance.now()-a),r=e.route,i=typeof r==`object`&&r?Reflect.get(r,`path`):null,c=Kx(e.body);Eb(e.method,typeof i==`string`?i:`unmatched`,t.statusCode,n,c),(t.statusCode>=XS&&!s?N:E)({component:`aventure-mcp-server`,event:`http_response`,fields:{...o,...c,status:t.statusCode,durationMs:n}})}),vi(i,()=>n())}),o.use(i?(0,Vd.default)({origin:aC}):(0,Vd.default)()),o.use(KS({path:e.path,limit:t,reject:e=>sC(e,QS,`Payload Too Large`,`Request JSON body exceeds the MCP transport size limit.`)})),o.use(Hd.json({limit:t})),o.get(`/health`,(...e)=>{let t=e[1],n=process.env.GIT_SHA?.trim();t.setHeader(`X-Aventure-Revision`,n&&/^[0-9a-f]{40}$/i.test(n)?n.slice(0,7):`unknown`),t.status(200).json({status:`UP`})}),o.get([`/.well-known/oauth-protected-resource`,`/.well-known/oauth-protected-resource${e.path}`],(0,Vd.default)(),async(t,n,r)=>{let i=await e.resolveOAuthDiscovery();if(i===void 0){sC(n,503,`Service Unavailable`,`OAuth discovery is unavailable: the API published no OAuth resource indicator for this server.`);return}let o=a(t,i);if(o===void 0){r();return}n.status(200).json({resource:o.resourceUrl.href,authorization_servers:[o.client.authorizationServer],scopes_supported:o.client.scope})}),Db(o,e.metricsScrapeSecret),o.get(`/`,(...t)=>{t[1].status(200).json({name:`aventure-mcp-server`,mcp:e.path,health:`/health`,transport:`streamable-http`,method:`POST`})}),o.get(`/favicon.ico`,(...e)=>e[1].status(204).end());let s=FS(n,async()=>(await e.resolveOAuthDiscovery())?.resourceUrl);return o.post(e.path,s,async(t,r)=>{let o=hi(),s=t.header(`origin`);if(i&&!iC(s)){N({component:`aventure-mcp-server`,event:`foreign_origin_rejected`,fields:{requestId:o,method:t.method,path:t.path,origin:s}}),sC(r,403,`Forbidden`,`A self-hosted MCP transport accepts loopback browser origins only.`);return}let c,l;try{let r=await e.resolveOAuthDiscovery();l=a(t,r),c=await n(t,r?.resourceUrl)}catch(e){Pc(e,`authentication_unavailable`),j({component:`aventure-mcp-server`,event:`authentication_unavailable`,fields:{requestId:o,method:t.method,path:t.path},error:e});let n=e instanceof Ge&&(e.problem.status===429||ai(e.problem.status))?e.problem:void 0;n===void 0?sC(r,503,`Service Unavailable`,`Authentication service is temporarily unavailable.`):(typeof n.retryAfterSeconds==`number`&&r.set(`Retry-After`,String(n.retryAfterSeconds)),cC(r,n));return}if(!c.ok){N({component:`aventure-mcp-server`,event:`unauthorized_request`,fields:{requestId:o,method:t.method,path:t.path,reason:c.reason,hasAuthorization:c.hasAuthorization}});let e=[l===void 0?void 0:`resource_metadata="${hv(l.resourceUrl)}"`,l===void 0?void 0:`scope="${l.client.scope.join(` `)}"`,c.reason===`credential_mismatch`?`error="invalid_token"`:void 0,c.reason===`credential_mismatch`?`error_description="The bearer token is invalid or expired"`:void 0,c.reason===`forbidden`?`error="insufficient_scope"`:void 0].filter(e=>e!==void 0);r.set(`WWW-Authenticate`,e.length===0?`Bearer`:`Bearer ${e.join(`, `)}`);let n=c.reason===`forbidden`;sC(r,n?403:401,n?`Forbidden`:`Unauthorized`,LS(c.reason,l!==void 0));return}let u=t.header(`accept`)??`*/*`;if(!u.includes(`*/*`)&&(!u.includes(`application/json`)||!u.includes(`text/event-stream`))){sC(r,406,`Not Acceptable`,`MCP Streamable HTTP requires Accept: application/json, text/event-stream.`);return}E({component:`aventure-mcp-server`,event:`mcp_request_authorized`,fields:{requestId:o,method:t.method,path:t.path,scope:c.scope}});let d=[],f=e=>{Pc(e,`transport_error`),j({component:`aventure-mcp-server`,event:`transport_error`,message:se(e),fields:{requestId:o,method:t.method,path:t.path},error:e})},p=gy(()=>Ux(c.scope,c.authorization),{onerror:e=>d.push(e),maxSubscriptions:0}),m=async()=>{await Iy(p,{onerror:f})(t,r,t.body);for(let e of d)ai(r.statusCode)?f(e):(r.statusCode<XS?E:N)({component:`aventure-mcp-server`,event:`mcp_request_rejected`,message:se(e),fields:{requestId:o,method:t.method,path:t.path,status:r.statusCode}})};c.userBearerToken===void 0?await m():await gi(c.userBearerToken,m)}),o.all(e.path,(...e)=>sC(e[1],405,`Method Not Allowed`,`MCP transport accepts POST requests only.`)),o.use((e,t,n,r)=>{if(n.headersSent){r(e);return}let i=lC(e);if(i===void 0){r(e);return}N({component:`aventure-mcp-server`,event:`json_body_rejected`,message:i.message,fields:{requestId:hi(),method:t.method,path:t.path,status:i.status}}),sC(n,i.status,i.status===QS?`Payload Too Large`:`Bad Request`,i.status===QS?`Request JSON body exceeds the MCP transport size limit.`:`Request body must be valid JSON.`)}),await new Promise((t,n)=>{let i;i=o.listen(e.port,r,()=>{t({server:i,close:async()=>{await new Promise((e,t)=>{i.close(n=>n?t(n):e()),i.closeIdleConnections()}),await Ob()}})}),i.on(`error`,n)})}function iC(e){if(e===void 0)return!0;if(!URL.canParse(e))return!1;let{hostname:t}=new URL(e);return t===`localhost`?!0:t.startsWith(`[`)?t===`[::1]`:Vi(t)&&t.startsWith(`127.`)}var aC=(e,t)=>t(null,iC(e)),oC=e=>e.method===`GET`&&/^\/robots\.txt\/?$/iu.test(e.path);function sC(e,t,n,r){cC(e,{type:`about:blank`,title:n,status:t,detail:r})}function cC(e,t){e.status(t.status).type(`application/problem+json`).json(t)}function lC(e){if(typeof e!=`object`||!e||!(`type`in e)||!(`status`in e))return;let t=e.type===`entity.too.large`?QS:e.type===`entity.parse.failed`?ZS:e.status===QS||e.status===ZS?e.status:void 0;return t===void 0?void 0:{status:t,message:`message`in e&&typeof e.message==`string`?e.message:`JSON body rejected`}}var uC=65535,dC=55e3,fC=pi(zi(import.meta.url)),{host:pC}=(await new p().name(fC.bin[0]).description(`Serve aVenture tools over MCP Streamable HTTP.`).version(fC.version).option(`--host <address>`,`Bind this address instead of 127.0.0.1; 0.0.0.0 exposes the server to the network.`).addHelpText(`after`,`
144
+ `);n.length>1&&!i&&(i=c.getValue(n,`NextHop`),e&&e(i),r(i))})})}catch{e&&e(i),r(i)}})})}e.networkGatewayDefault=me})),cb=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getNetworkData=void 0;var t=sb();function n(){return new Promise(e=>{(0,t.networkStats)().then(e).catch(()=>{e([])})})}e.getNetworkData=n})),lb=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HostMetrics=void 0;var t=rb(),n=ib(),r=ab(),i=cb();e.HostMetrics=class extends t.BaseMetrics{_batchUpdateCpuUsages(e,t){for(let r=0,i=t.length;r<i;r++){let i=t[r];e.observe(this._cpuTime,i.user,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_USER,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.system,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_SYSTEM,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.idle,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_IDLE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.interrupt,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_INTERRUPT,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuTime,i.nice,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_NICE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.userP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_USER,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.systemP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_SYSTEM,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.idleP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_IDLE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.interruptP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_INTERRUPT,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber}),e.observe(this._cpuUtilization,i.niceP,{[n.ATTR_SYSTEM_CPU_STATE]:n.SYSTEM_CPU_STATE_VALUE_NICE,[n.ATTR_SYSTEM_CPU_LOGICAL_NUMBER]:i.cpuNumber})}}_batchUpdateProcessCpuUsages(e,t){e.observe(this._processCpuTime,t.user,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_USER}),e.observe(this._processCpuTime,t.system,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_SYSTEM}),e.observe(this._processCpuUtilization,t.userP,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_USER}),e.observe(this._processCpuUtilization,t.systemP,{[n.ATTR_PROCESS_CPU_STATE]:n.PROCESS_CPU_STATE_VALUE_SYSTEM})}_batchUpdateMemUsages(e,t){e.observe(this._memoryUsage,t.used,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_USED}),e.observe(this._memoryUsage,t.free,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_FREE}),e.observe(this._memoryUtilization,t.usedP,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_USED}),e.observe(this._memoryUtilization,t.freeP,{[n.ATTR_SYSTEM_MEMORY_STATE]:n.SYSTEM_MEMORY_STATE_VALUE_FREE})}_batchUpdateProcessMemUsage(e,t){e.observe(this._processMemoryUsage,t)}_batchUpdateNetworkData(e,t){for(let r=0,i=t.length;r<i;r++){let i=t[r];e.observe(this._networkDropped,i.rx_dropped,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_RECEIVE}),e.observe(this._networkDropped,i.tx_dropped,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_TRANSMIT}),e.observe(this._networkErrors,i.rx_errors,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_RECEIVE}),e.observe(this._networkErrors,i.tx_errors,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_TRANSMIT}),e.observe(this._networkIo,i.rx_bytes,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_RECEIVE}),e.observe(this._networkIo,i.tx_bytes,{[n.ATTR_SYSTEM_DEVICE]:i.iface,[n.ATTR_NETWORK_IO_DIRECTION]:n.NETWORK_IO_DIRECTION_VALUE_TRANSMIT})}}_createMetrics(){let e=[],t=!this._metricGroups||this._metricGroups.includes(`system.cpu`),a=!this._metricGroups||this._metricGroups.includes(`system.memory`),o=!this._metricGroups||this._metricGroups.includes(`system.network`),s=!this._metricGroups||this._metricGroups.includes(`process.cpu`),c=!this._metricGroups||this._metricGroups.includes(`process.memory`);t&&(this._cpuTime=this._meter.createObservableCounter(n.METRIC_SYSTEM_CPU_TIME,{description:`Cpu time in seconds`,unit:`s`}),e.push(this._cpuTime),this._cpuUtilization=this._meter.createObservableGauge(n.METRIC_SYSTEM_CPU_UTILIZATION,{description:`Cpu usage time 0-1`}),e.push(this._cpuUtilization)),a&&(this._memoryUsage=this._meter.createObservableGauge(n.METRIC_SYSTEM_MEMORY_USAGE,{description:`Memory usage in bytes`}),e.push(this._memoryUsage),this._memoryUtilization=this._meter.createObservableGauge(n.METRIC_SYSTEM_MEMORY_UTILIZATION,{description:`Memory usage 0-1`}),e.push(this._memoryUtilization)),o&&(this._networkDropped=this._meter.createObservableCounter(`system.network.dropped`,{description:`Network dropped packets`}),e.push(this._networkDropped),this._networkErrors=this._meter.createObservableCounter(n.METRIC_SYSTEM_NETWORK_ERRORS,{description:`Network errors counter`}),e.push(this._networkErrors),this._networkIo=this._meter.createObservableCounter(n.METRIC_SYSTEM_NETWORK_IO,{description:`Network transmit and received bytes`}),e.push(this._networkIo)),s&&(this._processCpuTime=this._meter.createObservableCounter(n.METRIC_PROCESS_CPU_TIME,{description:`Process Cpu time in seconds`,unit:`s`}),e.push(this._processCpuTime),this._processCpuUtilization=this._meter.createObservableGauge(n.METRIC_PROCESS_CPU_UTILIZATION,{description:`Process Cpu usage time 0-1`}),e.push(this._processCpuUtilization)),c&&(this._processMemoryUsage=this._meter.createObservableGauge(n.METRIC_PROCESS_MEMORY_USAGE,{description:`Process Memory usage in bytes`}),e.push(this._processMemoryUsage)),this._meter.addBatchObservableCallback(async e=>{if(t){let t=(0,r.getCpuUsageData)();this._batchUpdateCpuUsages(e,t)}if(a){let t=(0,r.getMemoryData)();this._batchUpdateMemUsages(e,t)}if(s){let t=(0,r.getProcessCpuUsageData)();this._batchUpdateProcessCpuUsages(e,t)}if(c){let t=(0,r.getProcessMemoryData)();this._batchUpdateProcessMemUsage(e,t)}if(o){let t=await(0,i.getNetworkData)();this._batchUpdateNetworkData(e,t)}},e)}start(){this._createMetrics()}_cpuTime;_cpuUtilization;_memoryUsage;_memoryUtilization;_processCpuTime;_processCpuUtilization;_processMemoryUsage;_networkDropped;_networkErrors;_networkIo}})),ub=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HostMetrics=e.BaseMetrics=void 0;var t=rb();Object.defineProperty(e,"BaseMetrics",{enumerable:!0,get:function(){return t.BaseMetrics}});var n=lb();Object.defineProperty(e,"HostMetrics",{enumerable:!0,get:function(){return n.HostMetrics}})})),db=Wy(),fb=ub(),pb=`bearer `,mb=4096;function hb(e){if(e===void 0||e.length>mb||e.slice(0,7).toLowerCase()!==pb)return;let t=e.slice(7).trim();return t.length>0?t:void 0}u(),de(),gc();var gb=`aventure-mcp-server`,_b=`http_server_requests_seconds`,vb=[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],yb,bb,xb,Sb,Cb;function wb(e,t){if(bb!==void 0)return;let n=e?new db.PrometheusExporter({preventServerStart:!0}):void 0,r=new pc({resource:w({...oe(),"service.version":process.env.GIT_SHA??process.env.SENTRY_RELEASE??pi().version}),readers:[...n===void 0?[]:[n],...t===void 0?[]:[new Io({exporter:new tb({url:t}),exportIntervalMillis:1e4,exportTimeoutMillis:5e3})]]});a.setGlobalMeterProvider(r),bb=r,yb=n;let i=new fb.HostMetrics({meterProvider:r,name:gb});i.start(),Cb=i}function Tb(){return xb===void 0&&(xb=bb?.getMeter(gb)),xb}function Eb(e,t,n,r,{rpcMethod:i,toolName:a}){let o=Tb();o!==void 0&&(Sb===void 0&&(Sb=o.createHistogram(_b,{description:`HTTP server request latency in seconds, partitioned by method/route/status/rpc_method/tool.`,unit:`s`,advice:{explicitBucketBoundaries:vb}})),Sb.record(r/1e3,{method:e.toUpperCase(),route:t,status:String(n),rpc_method:i,tool:a}))}function Db(e,t){let n=pi().registry===``&&!!t,r=process.env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT?.trim()||void 0;if(!n&&r===void 0)return;wb(n,r);let i=yb;if(!n||t===void 0||i===void 0)return;let a=Ui(`sha256`).update(t).digest();e.get(`/metrics`,(e,t,n)=>{if(!kb(e.headers.authorization,a)){t.status(401).type(`text/plain`).send(`Unauthorized`);return}n()},(e,t)=>{i.getMetricsRequestHandler(e,t)})}async function Ob(){let e=bb;Cb!==void 0&&(Cb=void 0),bb=void 0,yb=void 0,xb=void 0,Sb=void 0,e!==void 0&&await e.shutdown()}function kb(e,t){let n=hb(e);if(n===void 0)return!1;let r=Ui(`sha256`).update(n).digest();return r.length===t.length&&Gi(r,t)}var Ab=`#/components/schemas/`,jb=/"#\/components\/schemas\/([^"]+)"/g,Mb=-32011,Nb=-32012,Pb=-32013,Fb=-32015;function Ib(e){let t=bt().components.schemas[e];if(t===void 0)throw Error(`OpenAPI has no component ${e}`);return t}function Lb(e){let t=bi(e?.content?.[`application/json`]?.schema);return t===void 0?void 0:Ib(t)}function Rb(e){let t=Object.keys(e).length===1?bi(e):void 0,n=t===void 0?e:Ib(t),r={},i=e=>{for(let[,t]of JSON.stringify(e).matchAll(jb))t===void 0||t in r||(r[t]=Ib(t),i(r[t]))};i(n);let a=Object.keys(r).length===0?n:{...n,$defs:r},o=li.safeParse(JSON.parse(JSON.stringify(a).replaceAll(`"${Ab}`,`"#/$defs/`)));if(!o.success)throw Error(`Event schema is not JSON: ${o.error}`);return o.data}function zb(e,t){let n=Object.entries(bt().paths).find(([,n])=>Lb(n[e]?.requestBody)?.properties?.name?.$ref===t);if(n===void 0)throw Error(`OpenAPI has no ${e} operation for ${t}`);return n[0]}var Bb=new Map(Object.entries(bt().webhooks??{}).map(([e,t])=>{let n=Lb(t.post.requestBody),r=n?.properties?.name?.$ref,i=n?.properties?.data;if(r===void 0||i===void 0)throw Error(`Webhook ${e} body must carry a name enum $ref and a data schema`);let a=zb(`put`,r),o=Lb(bt().paths[a]?.put?.requestBody)?.properties?.arguments;if(o===void 0)throw Error(`Subscribe body for ${e} must carry an arguments schema`);return[e,{descriptor:{name:e,description:t.post.description,delivery:[`webhook`],inputSchema:Rb(o),payloadSchema:Rb(i)},subscribePath:a,unsubscribePath:zb(`delete`,r)}]})),Vb=G({name:W()}).catchall(li),Hb=F(W(),li);function Ub(e){let t=Bb.get(e);if(t===void 0)throw new Z(Mb,`Unknown event ${e}`);return t}async function Wb(e,t,n){let{_meta:r,...i}=n,a=await Ae({method:e,path:t,body:i,auth:`auto`});if(a.ok){let e=Hb.safeParse(a.data!==null&&typeof a.data==`object`&&`response`in a.data?a.data.response??{}:{});if(e.success)return e.data;throw new Z(X.InternalError,`${t} answered a non-object body`)}let o=Gb(a.problem?.code);throw o===void 0?a.problem?.code===`news_subscription_limit`?new Z(Pb,a.summary,{limit:`subscriptions`}):new Z(Kb(a.httpStatus),a.summary,a.problem):new Z(Fb,`CallbackEndpointError`,{reason:o})}function Gb(e){switch(e){case`callback_connection_refused`:return`connection_refused`;case`callback_timeout`:return`timeout`;case`callback_tls_error`:return`tls_error`;case`callback_http_4xx`:return`http_4xx`;case`callback_http_5xx`:return`http_5xx`;case`callback_challenge_failed`:return`challenge_failed`;default:return}}function Kb(e){switch(e){case 400:case 422:return X.InvalidParams;case 401:case 403:return Nb;case 404:return Mb;default:return X.InternalError}}function qb(e){if(Bb.size===0)return;let t=[...Bb.values()].map(e=>e.descriptor);e.server.setRequestHandler(`events/list`,{params:G({})},()=>({events:t})),e.server.setRequestHandler(`events/subscribe`,{params:Vb},e=>Wb(`PUT`,Ub(e.name).subscribePath,e)),e.server.setRequestHandler(`events/unsubscribe`,{params:Vb},e=>Wb(`DELETE`,Ub(e.name).unsubscribePath,e))}async function Jb(e){try{return await Ae(e)}catch(t){return j({component:`aventure-mcp-server`,event:`tool_request_failed`,fields:{requestId:xi(),method:e.method},error:t}),si(se(t))}}var Yb=3,Xb=200,Zb=80;function Qb(e,t){let{operationId:n}=e;if(n===void 0)return null;let r=t.find(e=>e.operationId===n);if(r!==void 0)return $b(r,e,t);let i=rx(n,t),a=ji(i.noun),o=ax(e),s=Di([...a,...o.flatMap(({word:e})=>e)].join(` `),t,Oi).map(({item:e,score:t})=>({item:e,score:t+ix(e,a,o.map(({key:e})=>e))})).toSorted((e,t)=>Number(e.item.deprecated===!0)-Number(t.item.deprecated===!0)||Number(i.intent.has(t.item.intent))-Number(i.intent.has(e.item.intent))||Number(i.method.has(t.item.method))-Number(i.method.has(e.item.method))||t.score-e.score).slice(0,Yb).map(({item:e})=>Ci(e,!1)),c=s.map(e=>`${e.operationId} (${e.method} ${e.path})`);return si(`Operation ${n} is not in the MCP catalog.${c.length===0?``:` Closest operations: ${c.join(`, `)}.`}`,s.map(e=>`Use operationId ${e.operationId} with aventure_${e.intent}: ${e.method} ${e.path}; required inputs: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}.`))}function $b(e,t,n){let r=t.pathParams??{},i=e.parameter.filter(({in:e,required:t,name:n,legacyName:i})=>e===`path`&&t&&r[n]==null&&(i===void 0||r[i]==null)).map(({name:e})=>e);if(i.length===0)return null;let a=JSON.stringify({operationId:e.operationId,pathParams:{...r,...Object.fromEntries(i.map(e=>[e,`<${e}>`]))},...t.query===void 0?{}:{query:t.query}}),o=i.flatMap(t=>ex(e.path,t,n).map(e=>{let n=e.parameter.filter(e=>e.in===`query`&&e.schemaEnum===void 0),r=n.filter(e=>e.required),i=r.length>0?r:n.filter(e=>e.schemaType===`string`&&e.name!==`cursor`).slice(0,1),a=n.filter(e=>e.schemaType===`string`);return` Get ${t} from ${e.operationId} (${e.method} ${e.path}): aventure_${e.intent} ${JSON.stringify({operationId:e.operationId,...i.length===0?{}:{query:Object.fromEntries(i.map(e=>[e.name,`<${e.name}>`]))}})} returns the record whose id goes in pathParams.${t}${a.length===0?``:`; its query takes ${a.map(e=>e.name).join(`, `)}`}.`}));return si(`Missing path parameter${i.length===1?``:`s`} ${i.map(e=>`'${e}'`).join(`, `)} for ${e.operationId}. Path parameters go in pathParams: aventure_${e.intent} ${a}.${o.join(``)}`)}function ex(e,t,n){let r=`{${t}}`,i=e.slice(0,e.indexOf(r)+r.length),a=n.find(e=>e.method===`GET`&&e.path===i),o=a===void 0?void 0:nx(a);return o===void 0?[]:n.filter(e=>e.method===`GET`&&e.deprecated!==!0&&e.parameter.every(e=>e.in!==`path`)&&nx(e)===o).toSorted((e,t)=>Number(tx(t))-Number(tx(e)))}function tx(e){return e.intent===`lookup`||/lookup/iu.test(e.operationId)}function nx(e){let t=vi(bt().paths,e.operationId)?.operation.responses??{},n=new Set(Object.entries(t).filter(([e])=>e.startsWith(`2`)).map(([,e])=>e.content?.[`application/json`]?.schema?.$ref));return n.size===1?[...n][0]:void 0}function rx(e,t){let[n=``,...r]=Ni(e).split(` `),i=t.filter(e=>Ni(e.operationId).startsWith(`${n} `));return i.length>0&&r.length>0?{noun:r.join(` `),intent:new Set(i.map(e=>e.intent)),method:new Set(i.map(e=>e.method))}:{noun:e,intent:new Set,method:new Set}}function ix(e,t,n){let r=`${e.operationId} ${e.summary}`,i=new Set(ji(r)),a=Si(Ni(r)),o=t.reduce((e,t)=>e+(i.has(t)?2:+!!a.has(t)),0),s=new Set([...e.parameter,...(e.requestBody??[]).flatMap(e=>e.parameter)].map(({name:e})=>e)),c=n.filter(e=>s.has(e)).length,l=Si(t.join(` `)),u=ji(e.operationId).slice(1).filter(e=>!l.has(e)).length;return(o+2*c-u)*Zb}function ax(e){let t=e.body,n=typeof t==`object`&&t&&!Array.isArray(t)?Object.entries(t):[];return[...Object.entries(e.pathParams??{}),...Object.entries(e.query??{}),...n].map(([e,t])=>({key:e,word:typeof t==`string`&&t.length<=Xb?[e,t]:[e]}))}function ox({contract:e,input:t,intent:n,contracts:r,catalog:i}){let{operationId:a}=e;if(!n.includes(e.intent))return si(`Operation ${a} has intent=${e.intent}; call aventure_${e.intent} ${JSON.stringify({operationId:a,pathParams:t.pathParams,query:t.query,body:t.body})}.`);let o=i.find(e=>e.operationId===a)??e,s=o.parameter.filter(e=>e.in===`query`),c=Object.entries(t.query??{}),l=c.filter(([e])=>!Dt.includes(e)&&!s.some(t=>sx(t,e))),u=e.requestBody??[],d=u[0]?.schemaType===`array`,f=new Set((o.requestBody??[]).flatMap(e=>e.parameter.map(({name:e})=>e))),p=d?[]:l.filter(([e])=>f.has(e)),m=t.body===void 0&&u.some(e=>e.required&&e.kind!==`multipart`);if(l.length===0&&!m)return null;let h=typeof t.body==`object`&&t.body!==null&&!Array.isArray(t.body)?t.body:void 0,g=u[0]?.parameter??[],_=m?g.filter(({name:e,required:t})=>t&&!p.some(([t])=>t===e)).map(({name:e})=>e):[],v=d||t.body!==void 0&&h===void 0?t.body??[]:{...Object.fromEntries(_.map(e=>[e,`<${e}>`])),...h,...Object.fromEntries(p)},y=c.filter(([e])=>!l.some(([t])=>t===e)),b=JSON.stringify({operationId:a,...t.pathParams===void 0?{}:{pathParams:t.pathParams},...y.length===0?{}:{query:Object.fromEntries(y)},...u.length===0?{}:{body:v}}),x=e.parameter.filter(e=>e.in===`query`).map(({name:e})=>e),S=l.length===0?``:`${a} declares no query parameter ${lx(l)}; ${x.length===0?`it takes no query`:`its query takes ${x.join(`, `)}`}.`,C=p.length>0?` ${lx(p)} ${p.length===1?`is a request body field`:`are request body fields`}: send ${p.length===1?`it`:`them`} in body.`:m?` ${a} requires a request body: send it in body${g.length===0?``:`; its fields are ${g.map(({name:e})=>e).join(`, `)}`}.`:``;return si(`${S}${C} Call aventure_${e.intent} ${b}.${ux(e,r)}`.trim())}function sx(e,t){if(t===e.name||t===e.legacyName)return!0;let n=Number(/^\[(?<index>\d+)\]/u.exec(t.slice(e.name.length))?.groups?.index),r=Mi(e.name,0,``);return t.startsWith(e.name)&&Number.isInteger(n)&&(e.itemProperty??[]).some(i=>t===Mi(e.name,n,i.name.slice(r.length)))}var cx=/\b(?<method>GET|POST|PUT|PATCH|DELETE) (?<path>\/[^\s?),]*[^\s?),.])/u;function lx(e){return e.map(([e])=>`'${e}'`).join(`, `)}function ux(e,t){if(e.deprecated!==!0)return``;let n=/^Deprecated: (?<advice>.*?\.)(?=\s|$)/su.exec(e.description)?.groups?.advice;if(n===void 0)return` ${e.operationId} is deprecated.`;let r=cx.exec(n)?.groups,i=t.find(e=>e.method===r?.method&&e.path===r?.path);return` ${e.operationId} is deprecated: ${n}${i===void 0?``:` Its replacement is ${i.operationId}: call aventure_${i.intent} {"operationId":"${i.operationId}"}.`}`}function dx(e,t){return t?e:e.map(fx)}function fx(e){let t=e.parameter.flatMap(mx),n=px(e.requestBody);return gx(t,e.parameter)&&n===e.requestBody?e:{...e,parameter:t,...n===void 0?{}:{requestBody:n}}}function px(e){if(e===void 0)return;let t=e.map(e=>{let t=e.parameter.flatMap(mx);return gx(t,e.parameter)?e:{...e,parameter:t}});return t.every((t,n)=>t===e[n])?e:t}function mx(e){if(!hx(e))return[];let t=e.itemProperty?.filter(hx);return gx(t,e.itemProperty)?[e]:[{...e,...t===void 0||t.length===0?{}:{itemProperty:t}}]}var hx=e=>e.visibility!==`private`;function gx(e,t){return e===t?!0:e?.length!==t?.length||e===void 0||t===void 0?!1:e.every((e,n)=>e===t[n])}new RegExp(di.join(`|`),`i`);var _x;function vx(e){let t=_x??=Ai([...Pi,...Fi]),n=yx(oi(e,ki(e,t))),r=Ei(t,n.data,n.summary)??JSON.stringify(n);return{isError:!n.ok,structuredContent:n,content:[{type:`text`,text:r}]}}function yx(e){let{omitted:t,ids:n,counts:r,references:i,warnings:a,...o}=e;return{...o,...t.length>0?{omitted:t}:{},...n.length>0?{ids:n}:{},...Object.keys(r).length>0?{counts:r}:{},...i.length>0?{references:i}:{},...a.length>0?{warnings:a}:{}}}var bx=`aventure_status`,xx=`aventure_help`,Sx=`aventure_read`,Cx=`aventure_lookup`,wx=`aventure_search`,Tx=`aventure_write`,Ex=`aventure_delete`,Dx=[bx,xx,Sx,Cx,wx,Tx,Ex],Ox=I([W(),U(),H()]),kx=F(W(),I([W(),U()])).optional(),Ax=F(W(),I([Ox,B(Ox)])).optional(),jx=F(W(),W()).optional(),Mx=V([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`]),Nx=I([Ox,Ce(),B(me()),F(W(),me())]).optional().describe(`JSON request body. For multipart/form-data operations, pass an object keyed by form part name; binary part values are http(s) URLs.`),Px=G({operationId:W().optional().describe(`Exact OpenAPI operationId, as listed by aventure_help. Takes precedence over method and path.`),method:Mx.optional().describe(`HTTP method when resolving by method+path.`),path:W().optional().describe(`OpenAPI route template or concrete API path.`),pathParams:kx.describe(`Values for route template parameters.`),query:Ax.describe(`Query parameters.`),headers:jx.describe(`Headers declared by the selected OpenAPI operation.`),contentType:W().optional().describe(`Declared request media type; omit for the first supported descriptor.`),responseFormat:V([`auto`,`json`,`text`]).optional().describe(`Response format for endpoints that offer both JSON and text/plain.`)}),Fx=G({q:W().optional().describe(`Plain-English task text, ranked against operationId, path, CLI command, summary, description, and query-parameter enum values. This tool reads no argument named query. Omitting q returns the catalog head unranked.`),root:W().optional().describe(`Filter by resource or first CLI segment.`),method:Mx.optional().describe(`Filter by HTTP method.`),scope:V([`read`,`write`]).optional().describe(`Filter by required MCP auth scope.`),limit:xe().min(1).max(100).default(20).describe(`Maximum rows to return.`),resolve:H().default(!1).describe(`Resolve q to one operation with the server resolver (requires sign-in): operation advice with an mcpCall skeleton, a clarification between candidate operations, or an abstention. scope narrows it; root, method, and limit do not apply.`)}),Ix=Px.extend({body:Nx});async function Lx(e,t,n){let r=Pi.find(e=>e.intent===`status`&&e.resource===`status`);if(r===void 0)return si(`No system status operation exists in the generated catalog.`);let i;try{i=ui().host}catch(e){return si(e.message)}let a=await Jb({method:r.method,path:r.path,auth:r.projection.auth,requesterScope:e,signal:n});return{...a,data:{transportScope:e,permissionGrant:t?.permissionGrant,host:i,status:a.data}}}var Rx=(e,t)=>dx(Pi,t?.operationAccess===`ADMIN`||t===void 0&&e===`write`).filter(n=>(t===void 0?e===`write`||n.projection.scope===`read`&&(n.projection.auth===`read`||n.projection.auth===`none`):t.operationAccess!==`READ`||n.projection.scope===`read`||n.projection.visibility!==`private`)&&(t===void 0||t.operation.some(e=>e.operationId===n.operationId&&e.method===n.method&&e.path===n.path)));async function zx(e,t,n,r,i,a){let o=Qb(e,r)??$n(e);if(!o.ok)return si(o.summary,o.warnings);if(o.data===null)return si(`OpenAPI operation resolution returned no data.`);let{method:s,operation:c,path:l,template:u}=o.data,d=c.operationId,f=r.find(e=>e.operationId===d&&e.method.toLowerCase()===s&&e.path===u);if(f===void 0)return si(`Operation `+d+` is not in the MCP catalog.`);let p=ox({contract:f,input:e,intent:t,contracts:r,catalog:Pi});if(p!==null)return p;let m=hi(f.requestBody??[],e.contentType);if(!m.ok||m.data===null)return si(m.summary,m.warnings);let h=m.data;return f.intent===`delete`&&h===void 0&&e.body!==void 0?si(d+` does not accept a request body.`):await Jb({method:f.method,path:l,searchParams:e.query,headers:e.headers,body:e.body,contentType:e.contentType,auth:f.projection.auth,requesterScope:n,responseFormat:e.responseFormat,clientInfo:i,signal:a})}function Bx(e,t,n){let r=Rx(t,n),i=()=>e.server.getClientVersion();e.registerTool(bx,{title:`aVenture status`,annotations:{readOnlyHint:!0},description:`Return API status, host, MCP auth scope, and your role and permission grant. Scope write means some write is callable, not every write; aventure_help with scope write lists the writes this grant allows.`,inputSchema:G({})},async(e,r)=>vx(await Lx(t,n,r?.mcpReq.signal))),e.registerTool(xx,{title:`aVenture help`,annotations:{readOnlyHint:!0},description:`Lists the aVenture API operations this connection may call. Each row gives operationId, method, path, CLI command, intent (the aventure_<intent> tool that runs it), required scope, request body shape, and arguments. q ranks rows against a plain-English task without calling the API. resolve asks the server to resolve q to one operation and returns the aventure_<intent> call to run it.`,inputSchema:Fx},async(e,n)=>{if(e.resolve)return vx(await wi(t===`read`?{...e,scope:`read`}:e,r,Pi,(e,r)=>Jb({method:e.method,path:Ve(e.operationId,{}),body:r.body,auth:e.projection.auth,requesterScope:t,responseFormat:`json`,clientInfo:i(),signal:n?.mcpReq.signal})));let{summary:a,data:o,counts:s}=Ti(e,r);return vx(ci(a,o,{counts:s}))}),e.registerTool(Sx,{title:`aVenture read`,annotations:{readOnlyHint:!0},description:`Runs one catalog operation whose intent is read: fetch a record by id or slug, list the records attached to it, or list a collection. Put route values in pathParams and URL query values in query. Example for an aventure.vc profile URL, slug, website, or domain: {"operationId":"getEntityLookup","query":{"url":"https://aventure.vc/investors/firms/<slug>"}}. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`read`],t,r,i(),n?.mcpReq.signal))),e.registerTool(Cx,{title:`aVenture lookup`,annotations:{readOnlyHint:!1},description:`Runs one catalog operation whose intent is lookup: identify a record from a name plus clues (such as lookupRecord), resolve a ticker or other identifier, or run a batch, preview, or duplicate check. Most lookups are POST operations that take a JSON body. An exact aventure.vc profile URL, slug, website, or domain is a read, not a lookup: call aventure_read with operationId getEntityLookup (or getPersonLookup) and query {url} or {slug}. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`lookup`],t,r,i(),n?.mcpReq.signal))),e.registerTool(wx,{title:`aVenture search`,annotations:{readOnlyHint:!1,destructiveHint:!1},description:`Runs one catalog operation whose intent is search: search or filter companies, people, news, publications, content, links, or the web, or answer a question. It has no free-text argument of its own: pass search text and filters where the chosen operation declares them, in query or body. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`search`],t,r,i(),n?.mcpReq.signal))),r.some(e=>e.intent===`write`)&&e.registerTool(Tx,{title:`aVenture write`,annotations:{readOnlyHint:!1,destructiveHint:!0},description:`Runs one catalog operation whose intent is write, limited to the writes your grant allows: create or change records in the shared aVenture corpus where your grant permits curation, or submit an account or enrichment request such as a billing checkout, plan change, portal session, or entity or person enrichment; aventure_help with scope write lists your writes, and each takes effect immediately. Pass the body the operation declares. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`write`],t,r,i(),n?.mcpReq.signal))),r.some(e=>e.intent===`delete`)&&e.registerTool(Ex,{title:`aVenture delete`,annotations:{readOnlyHint:!1,destructiveHint:!0},description:`Runs one catalog operation whose intent is delete: remove one record, one link between records, or a named batch of links, from the shared aVenture corpus. Pass the body the operation declares, such as the list of links a batch delete names; a body sent to an operation that declares none is refused. Select the operation by operationId from aventure_help, or by method plus path; operationId wins when both are given. An operation with a different intent is refused with the name of the tool that runs it.`,inputSchema:Ix},async(e,n)=>vx(await zx(e,[`delete`],t,r,i(),n?.mcpReq.signal)))}var Vx=pi().version,Hx={tools:{},events:{}};function Ux(e,t){let n=new Hv({name:`aventure-mcp-server`,title:`aVenture MCP Server`,version:Vx},{capabilities:Hx,instructions:bt().info?.description});return Bx(n,e,t),qb(n),n}var Wx=new Set([...Br.options,...ln.options].map(e=>e.shape.method.value)),Gx=new Set(Dx);function Kx(e){let t=typeof e==`object`&&e?Reflect.get(e,`method`):void 0,n=typeof e==`object`&&e?Reflect.get(e,`params`):void 0,r=typeof n==`object`&&n?Reflect.get(n,`name`):void 0;return{rpcMethod:typeof t==`string`&&Wx.has(t)?t:`other`,toolName:typeof r==`string`&&Gx.has(r)?r:`none`}}var qx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AddressError=void 0,e.AddressError=class extends Error{constructor(e,t){super(e),this.name=`AddressError`,this.parseMessage=t}}})),Jx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isInSubnet=n,e.isHostInSubnet=r,e.isGloballyReachable=i,e.offsetBigInt=a,e.isCorrect=o,e.prefixLengthFromMask=s,e.assertByteArray=c,e.numberToPaddedHex=l,e.stringToPaddedHex=u,e.testBit=d;var t=qx();function n(e){return this.subnetMask<e.subnetMask?!1:r.call(this,e)}function r(e){return this.binaryZeroPad().length===e.binaryZeroPad().length&&this.mask(e.subnetMask)===e.mask()}function i(e){let t=null;for(let n=0;n<e.length;n++){let i=e[n];i.reachable!==null&&r.call(this,i.subnet)&&(t===null||i.subnet.subnetMask>t.subnet.subnetMask)&&(t=i)}return t===null||t.reachable}function a(e,n,r,i){if(typeof n==`number`&&!Number.isSafeInteger(n)||typeof n!=`number`&&typeof n!=`bigint`)throw new t.AddressError(`${i} offset must be an integer`);let a=e+BigInt(n);if(a<BigInt(0)||a>(BigInt(1)<<BigInt(r))-BigInt(1))throw new t.AddressError(`${i} offset leaves the address space`);return a}function o(e){return function(){return this.addressMinusSuffix===this.correctForm()?this.subnetMask===e&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask):!1}}function s(e,n){let r=e.toString(2).padStart(n,`0`);if(r.length>n)throw new t.AddressError(`Invalid subnet mask.`);let i=r.indexOf(`0`);if(i===-1)return n;if(r.slice(i).includes(`1`))throw new t.AddressError(`Invalid subnet mask.`);return i}function c(e,n,r,i){if(e.length!==n)throw new t.AddressError(`${r} addresses require exactly ${n} bytes`);for(let n=0;n<e.length;n++)if(!Number.isInteger(e[n])||e[n]<i||e[n]>255)throw new t.AddressError(`All bytes must be integers between ${i} and 255`)}function l(e){return e.toString(16).padStart(2,`0`)}function u(e){return l(parseInt(e,10))}function d(e,t){let{length:n}=e;if(t>n)return!1;let r=n-t;return e.substring(r,r+1)===`1`}})),Yx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_SUBNET_STRING=e.RE_ADDRESS=e.GROUPS=e.BITS=void 0,e.BITS=32,e.GROUPS=4,e.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g,e.RE_SUBNET_STRING=/\/\d{1,2}$/,e.SPECIAL_PURPOSE=[[`0.0.0.0/8`,`This network`,!1],[`0.0.0.0/32`,`This host on this network`,!1],[`10.0.0.0/8`,`Private-Use`,!1],[`100.64.0.0/10`,`Shared Address Space`,!1],[`127.0.0.0/8`,`Loopback`,!1],[`169.254.0.0/16`,`Link Local`,!1],[`172.16.0.0/12`,`Private-Use`,!1],[`192.0.0.0/24`,`IETF Protocol Assignments`,!1],[`192.0.0.0/29`,`IPv4 Service Continuity Prefix`,!1],[`192.0.0.8/32`,`IPv4 dummy address`,!1],[`192.0.0.9/32`,`Port Control Protocol Anycast`,!0],[`192.0.0.10/32`,`Traversal Using Relays around NAT Anycast`,!0],[`192.0.0.170/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.0.171/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.2.0/24`,`Documentation (TEST-NET-1)`,!1],[`192.31.196.0/24`,`AS112-v4`,!0],[`192.52.193.0/24`,`AMT`,!0],[`192.88.99.0/24`,`Deprecated (6to4 Relay Anycast)`,null],[`192.88.99.2/32`,`6a44-relay anycast address`,!1],[`192.168.0.0/16`,`Private-Use`,!1],[`192.175.48.0/24`,`Direct Delegation AS112 Service`,!0],[`198.18.0.0/15`,`Benchmarking`,!1],[`198.51.100.0/24`,`Documentation (TEST-NET-2)`,!1],[`203.0.113.0/24`,`Documentation (TEST-NET-3)`,!1],[`240.0.0.0/4`,`Reserved`,!1],[`255.255.255.255/32`,`Limited Broadcast`,!1]]})),Xx=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Address4=void 0;var i=r(Jx()),a=r(Yx()),o=qx(),s=i.isCorrect(a.BITS),c=class e{constructor(e){this.addressMinusSuffix=``,this.groups=a.GROUPS,this.parsedAddress=[],this.parsedSubnet=``,this.subnet=`/32`,this.subnetMask=32,this.v4=!0,this.isCorrect=s,this.isInSubnet=i.isInSubnet,this.isHostInSubnet=i.isHostInSubnet,this.address=e;let t=a.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>a.BITS)throw new o.AddressError(`Invalid subnet mask.`);e=e.replace(a.RE_SUBNET_STRING,``)}let n=a.GROUPS*4-1;if(e.length>n)throw new o.AddressError(`IPv4 addresses are at most ${n} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}static isValid(t){try{return new e(t),!0}catch{return!1}}parse(e){let t=e.split(`.`);if(t.some(e=>/^0\d/.test(e)))throw new o.AddressError(`IPv4 addresses can't have leading zeroes.`);if(!e.match(a.RE_ADDRESS))throw new o.AddressError(`Invalid IPv4 address.`);return t}correctForm(){return this.parsedAddress.map(e=>parseInt(e,10)).join(`.`)}static fromAddressAndMask(t,n){let r=i.prefixLengthFromMask(new e(n).bigInt(),a.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(a.BITS))-BigInt(1),o=i.prefixLengthFromMask(r,a.BITS);return new e(`${t}/${o}`)}static fromWildcard(t){let n=t.split(`.`);if(n.length!==a.GROUPS)throw new o.AddressError(`Wildcard pattern must have 4 octets`);let r=-1;for(let e=0;e<n.length;e++)if(n[e]===`*`)r===-1&&(r=e);else if(r!==-1)throw new o.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");let i=r===-1?0:n.length-r,s=n.map(e=>e===`*`?`0`:e),c=a.BITS-i*8;return new e(`${s.join(`.`)}/${c}`)}static fromHex(t){let n=t.replace(/:/g,``);if(!/^[0-9a-fA-F]{8}$/.test(n))throw new o.AddressError(`IPv4 hex must be exactly 8 hex digits`);let r=[];for(let e=0;e<8;e+=2)r.push(parseInt(n.slice(e,e+2),16));return new e(r.join(`.`))}static fromInteger(t){if(!Number.isInteger(t)||t<0||t>4294967295)throw new o.AddressError(`IPv4 integer must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.?$/i,``).split(`.`).reverse().join(`.`);return new e(n)}toHex(){return this.parsedAddress.map(e=>i.stringToPaddedHex(e)).join(`:`)}toArray(){return this.parsedAddress.map(e=>parseInt(e,10))}toGroup6(){let e=[],t=0;for(;t<a.GROUPS;t+=2)e.push(`${i.stringToPaddedHex(this.parsedAddress[t])}${i.stringToPaddedHex(this.parsedAddress[t+1])}`);return e.join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(e=>i.stringToPaddedHex(e)).join(``)}`)}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(a.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}offset(t){return e.fromBigInt(i.offsetBigInt(this.bigInt(),t,a.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(i.offsetBigInt(this._endAddress(),1,a.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(a.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(a.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(a.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}static fromBigInt(t){if(t<BigInt(0)||t>BigInt(4294967295))throw new o.AddressError(`IPv4 BigInt must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromByteArray(e){return i.assertByteArray(e,4,`IPv4`,0),this.fromUnsignedByteArray(e)}static fromUnsignedByteArray(t){if(t.length!==4)throw new o.AddressError(`IPv4 addresses require exactly 4 bytes`);let n=t.join(`.`);return new e(n)}mask(e){return e===void 0&&(e=this.subnetMask),this.getBitsBase2(0,e)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}reverseForm(e){e||={};let t=this.correctForm().split(`.`).reverse().join(`.`);return e.omitSuffix?t:`${t}.in-addr.arpa.`}isMulticast(){return this.isHostInSubnet(l)}isPrivate(){return u.some(e=>this.isHostInSubnet(e))}isLoopback(){return this.isHostInSubnet(d)}isLinkLocal(){return this.isHostInSubnet(f)}isUnspecified(){return this.isHostInSubnet(p)}isBroadcast(){return this.isHostInSubnet(m)}isCGNAT(){return this.isHostInSubnet(h)}isDocumentation(){return g.some(e=>this.isHostInSubnet(e))}isBenchmarking(){return this.isHostInSubnet(_)}isReserved(){return this.isHostInSubnet(v)}isGlobal(){return!this.isMulticast()&&i.isGloballyReachable.call(this,y)}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(a.BITS,`0`)),this._binaryZeroPad}groupForV6(){let e=this.parsedAddress;return this.correctForm().replace(a.RE_ADDRESS,`<span class="hover-group group-v4 group-6">${e.slice(0,2).join(`.`)}</span>.<span class="hover-group group-v4 group-7">${e.slice(2,4).join(`.`)}</span>`)}};e.Address4=c;var l=new c(`224.0.0.0/4`),u=[new c(`10.0.0.0/8`),new c(`172.16.0.0/12`),new c(`192.168.0.0/16`)],d=new c(`127.0.0.0/8`),f=new c(`169.254.0.0/16`),p=new c(`0.0.0.0/32`),m=new c(`255.255.255.255/32`),h=new c(`100.64.0.0/10`),g=[new c(`192.0.2.0/24`),new c(`198.51.100.0/24`),new c(`203.0.113.0/24`)],_=new c(`198.18.0.0/15`),v=new c(`240.0.0.0/4`),y=a.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new c(e),reachable:t}))})),Zx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_URL_WITH_PORT=e.RE_URL=e.RE_ZONE_STRING=e.RE_SUBNET_STRING=e.RE_BAD_ADDRESS=e.RE_BAD_CHARACTERS=e.TYPES=e.SCOPES=e.GROUPS=e.BITS=void 0,e.BITS=128,e.GROUPS=8,e.SCOPES={0:`Reserved`,1:`Interface local`,2:`Link local`,4:`Admin local`,5:`Site local`,8:`Organization local`,14:`Global`,15:`Reserved`},e.TYPES={"ff01::1/128":`Multicast (All nodes on this interface)`,"ff01::2/128":`Multicast (All routers on this interface)`,"ff02::1/128":`Multicast (All nodes on this link)`,"ff02::2/128":`Multicast (All routers on this link)`,"ff05::2/128":`Multicast (All routers in this site)`,"ff02::5/128":`Multicast (OSPFv3 AllSPF routers)`,"ff02::6/128":`Multicast (OSPFv3 AllDR routers)`,"ff02::9/128":`Multicast (RIP routers)`,"ff02::a/128":`Multicast (EIGRP routers)`,"ff02::d/128":`Multicast (PIM routers)`,"ff02::16/128":`Multicast (MLDv2 reports)`,"ff01::fb/128":`Multicast (mDNSv6)`,"ff02::fb/128":`Multicast (mDNSv6)`,"ff05::fb/128":`Multicast (mDNSv6)`,"ff02::1:2/128":`Multicast (All DHCP servers and relay agents on this link)`,"ff05::1:2/128":`Multicast (All DHCP servers and relay agents in this site)`,"ff02::1:3/128":`Multicast (All DHCP servers on this link)`,"ff05::1:3/128":`Multicast (All DHCP servers in this site)`,"::/128":`Unspecified`,"::1/128":`Loopback`,"::ffff:0:0/96":`IPv4-mapped`,"ff00::/8":`Multicast`,"fe80::/10":`Link-local unicast`,"fc00::/7":`Unique local`,"2001::/32":`Teredo`,"2001:2::/48":`Benchmarking`,"2002::/16":`6to4`,"2001:db8::/32":`Documentation`,"3fff::/20":`Documentation`,"100::/64":`Discard-only`,"fec0::/10":`Site-local unicast (deprecated)`,"::/96":`IPv4-compatible (deprecated)`,"64:ff9b::/96":`NAT64 (well-known)`,"64:ff9b:1::/48":`NAT64 (local-use)`},e.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi,e.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,e.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,e.RE_ZONE_STRING=/%.*$/,e.RE_URL=/^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i,e.RE_URL_WITH_PORT=/^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i,e.SPECIAL_PURPOSE=[[`::1/128`,`Loopback Address`,!1],[`::/128`,`Unspecified Address`,!1],[`::ffff:0:0/96`,`IPv4-mapped Address`,!1],[`64:ff9b::/96`,`IPv4-IPv6 Translat.`,!0],[`64:ff9b:1::/48`,`IPv4-IPv6 Translat.`,!1],[`100::/64`,`Discard-Only Address Block`,!1],[`100:0:0:1::/64`,`Dummy IPv6 Prefix`,!1],[`2001::/23`,`IETF Protocol Assignments`,!1],[`2001::/32`,`TEREDO`,!1],[`2001:1::1/128`,`Port Control Protocol Anycast`,!0],[`2001:1::2/128`,`Traversal Using Relays around NAT Anycast`,!0],[`2001:1::3/128`,`DNS-SD Service Registration Protocol Anycast`,!0],[`2001:2::/48`,`Benchmarking`,!1],[`2001:3::/32`,`AMT`,!0],[`2001:4:112::/48`,`AS112-v6`,!0],[`2001:10::/28`,`Deprecated (previously ORCHID)`,null],[`2001:20::/28`,`ORCHIDv2`,!0],[`2001:30::/28`,`Drone Remote ID Protocol Entity Tags (DETs) Prefix`,!0],[`2001:db8::/32`,`Documentation`,!1],[`2002::/16`,`6to4`,!1],[`2620:4f:8000::/48`,`Direct Delegation AS112 Service`,!0],[`3fff::/20`,`Documentation`,!1],[`5f00::/16`,`Segment Routing (SRv6) SIDs`,!1],[`fc00::/7`,`Unique-Local`,!1],[`fe80::/10`,`Link-Local Unicast`,!1]]})),Qx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.escapeHtml=t,e.spanAllZeroes=n,e.spanAll=r,e.spanLeadingZeroes=a,e.simpleGroup=o;function t(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function n(e){return t(e).replace(/(0+)/g,`<span class="zero">$1</span>`)}function r(e,r=0){return e.split(``).map((e,i)=>`<span class="digit value-${t(e)} position-${i+r}">${n(e)}</span>`).join(``)}function i(e){return t(e).replace(/^(0+)/,`<span class="zero">$1</span>`)}function a(e){return e.split(`:`).map(e=>i(e)).join(`:`)}function o(e,t=0){return e.split(`:`).map((e,n)=>/group-v4/.test(e)?e:`<span class="hover-group group-${n+t}">${i(e)}</span>`)}})),$x=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.ADDRESS_BOUNDARY=void 0,e.groupPossibilities=a,e.padGroup=o,e.simpleRegularExpression=s,e.possibleElisions=c;var i=r(Zx());function a(e){return`(${e.join(`|`)})`}function o(e){return e.length<4?`0{0,${4-e.length}}${e}`:e}e.ADDRESS_BOUNDARY=`[^A-Fa-f0-9:]`;function s(e){let t=[];e.forEach((e,n)=>{parseInt(e,16)===0&&t.push(n)});let n=t.map(t=>e.map((e,n)=>{if(n===t){let t=n===0||n===i.GROUPS-1?`:`:``;return a([o(e),t])}return o(e)}).join(`:`));return n.push(e.map(o).join(`:`)),a(n)}function c(e,t,n){let r=t?``:`:`,i=n?``:`:`,o=[];!t&&!n&&o.push(`::`),t&&n&&o.push(``),(n&&!t||!n&&t)&&o.push(`:`),o.push(`${r}(:0{1,4}){1,${e-1}}`),o.push(`(0{1,4}:){1,${e-1}}${i}`),o.push(`(0{1,4}:){${e-1}}0{1,4}`);for(let t=1;t<e-1;t++)for(let n=1;n<e-t;n++)o.push(`(0{1,4}:){${n}}:(0{1,4}:){${e-n-t-1}}0{1,4}`);return a(o)}})),eS=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Address6=void 0;var i=r(Jx()),a=r(Yx()),o=r(Zx()),s=r(Qx()),c=Xx(),l=$x(),u=qx(),d=Jx(),f=i.isCorrect(o.BITS);function p(e){if(!e)throw Error(`Assertion failed.`)}function m(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,`$1,$2`);return e}function h(e){return e=e.replace(/^(0{1,})([1-9]+)$/,`<span class="parse-error">$1</span>$2`),e=e.replace(/^(0{1,})(0)$/,`<span class="parse-error">$1</span>$2`),e}function g(e,t){let n=[],r=[],i=0;for(;i<e.length;i++)i<t[0]?n.push(e[i]):i>t[1]&&r.push(e[i]);return n.concat([`compact`]).concat(r)}function _(e){return parseInt(e,16).toString(16).padStart(4,`0`)}function v(e){return e&255}var y=class e{constructor(e,t){this.addressMinusSuffix=``,this.parsedSubnet=``,this.subnet=`/128`,this.subnetMask=128,this.v4=!1,this.zone=``,this.isInSubnet=i.isInSubnet,this.isHostInSubnet=i.isHostInSubnet,this.isCorrect=f,this.groups=t===void 0?o.GROUPS:t,this.address=e;let n=o.RE_SUBNET_STRING.exec(e);if(n){if(this.parsedSubnet=n[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>o.BITS)throw new u.AddressError(`Invalid subnet mask.`);e=e.replace(o.RE_SUBNET_STRING,``)}if(/\//.test(e))throw new u.AddressError(`Invalid subnet mask.`);let r=o.RE_ZONE_STRING.exec(e);r&&(this.zone=r[0],e=e.replace(o.RE_ZONE_STRING,``));let a=this.groups*5+5;if(e.length>a)throw new u.AddressError(`IPv6 addresses are at most ${a} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new e(t),!0}catch{return!1}}static fromBigInt(t){if(t<BigInt(0)||t>(BigInt(1)<<BigInt(o.BITS))-BigInt(1))throw new u.AddressError(`IPv6 BigInt must be in the range 0 to 2**128 - 1`);let n=t.toString(16).padStart(32,`0`),r=[];for(let e=0;e<o.GROUPS;e++)r.push(n.slice(e*4,(e+1)*4));return new e(r.join(`:`))}static fromURL(t){let n,r=null,i,a,s=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``);if(s.indexOf(`[`)!==-1&&s.indexOf(`]:`)!==-1){if(a=`failed to parse address with port`,i=o.RE_URL_WITH_PORT.exec(s),i===null)return{error:a,address:null,port:null};n=i[1],r=i[2]}else{if(a=`failed to parse address from URL`,i=o.RE_URL.exec(s),i===null)return{error:a,address:null,port:null};n=i[1]??i[2]}r?(r=parseInt(r,10),(r<0||r>65535)&&(r=null)):r=null;let c;try{c=new e(n)}catch{return{error:a,address:null,port:null}}return{address:c,port:r}}static fromAddressAndMask(t,n){let r=i.prefixLengthFromMask(new e(n).bigInt(),o.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(o.BITS))-BigInt(1),a=i.prefixLengthFromMask(r,o.BITS);return new e(`${t}/${a}`)}static fromWildcard(t){if(t.includes(`%`)||t.includes(`/`))throw new u.AddressError(`Wildcard pattern must not include a zone or CIDR suffix`);let n=t.split(`::`);if(n.length>2)throw new u.AddressError(`Wildcard pattern cannot contain more than one '::'`);let r;if(n.length===2){let e=n[0]===``?[]:n[0].split(`:`),t=n[1]===``?[]:n[1].split(`:`),i=o.GROUPS-e.length-t.length;if(i<1)throw new u.AddressError(`Wildcard pattern with '::' has too many groups`);r=[...e,...Array(i).fill(`0`),...t]}else r=t.split(`:`);if(r.length!==o.GROUPS)throw new u.AddressError(`Wildcard pattern must have 8 groups`);let i=-1;for(let e=0;e<r.length;e++)if(r[e]===`*`)i===-1&&(i=e);else if(i!==-1)throw new u.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");let a=i===-1?0:r.length-i,s=r.map(e=>e===`*`?`0`:e),c=o.BITS-a*16;return new e(`${s.join(`:`)}/${c}`)}static fromAddress4(t){let n=new c.Address4(t),r=o.BITS-(a.BITS-n.subnetMask);return new e(`::ffff:${n.correctForm()}/${r}`)}static fromArpa(t){let n=t.replace(/(\.ip6\.arpa)?\.?$/i,``);if(!/^[0-9a-f](\.[0-9a-f]){0,31}$/i.test(n))throw new u.AddressError(`Invalid 'ip6.arpa' form.`);let r=n.split(`.`).reverse(),i=r.length*4,a=r.join(``).padEnd(32,`0`),s=[];for(let e=0;e<o.GROUPS;e++)s.push(a.slice(e*4,(e+1)*4));return new e(`${s.join(`:`)}/${i}`)}microsoftTranscription(){return`${this.correctForm().replace(/:/g,`-`)}.ipv6-literal.net`}mask(e=this.subnetMask){return this.getBitsBase2(0,e)}possibleSubnets(e=128){let t=o.BITS-this.subnetMask-Math.abs(e-o.BITS);return t<0?`0`:m((BigInt(`2`)**BigInt(t)).toString(10))}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(o.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(o.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}offset(t){return e.fromBigInt(i.offsetBigInt(this.bigInt(),t,o.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(i.offsetBigInt(this._endAddress(),1,o.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(o.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(o.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}getScope(){let e=this.getType();return e===`Multicast`||e.startsWith(`Multicast `)?o.SCOPES[parseInt(this.getBits(12,16).toString(10),10)]||`Unknown`:e===`Link-local unicast`||e===`Loopback`?`Link local`:e===`Unspecified`?`Unknown`:`Global`}getType(){for(let e=0;e<b.length;e++){let t=b[e];if(this.isHostInSubnet(t[0]))return t[1]}return`Global unicast`}getBits(e,t){return BigInt(`0b${this.getBitsBase2(e,t)}`)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}getBitsBase16(e,t){let n=t-e;if(n%4!=0)throw Error(`Length of bits to retrieve must be divisible by four`);return this.getBits(e,t).toString(16).padStart(n/4,`0`)}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,o.BITS)}reverseForm(e){e||={};let t=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,``).split(``).slice(0,t).reverse().join(`.`);return t>0?e.omitSuffix?n:`${n}.ip6.arpa.`:e.omitSuffix?``:`ip6.arpa.`}correctForm(){let e,t=[],n=0,r=[];for(e=0;e<this.parsedAddress.length;e++){let t=parseInt(this.parsedAddress[e],16);t===0&&n++,t!==0&&n>0&&(n>1&&r.push([e-n,e-1]),n=0)}n>1&&r.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let i=r.map(e=>e[1]-e[0]+1);if(r.length>0){let e=i.indexOf(Math.max(...i));t=g(this.parsedAddress,r[e])}else t=this.parsedAddress;for(e=0;e<t.length;e++)t[e]!==`compact`&&(t[e]=parseInt(t[e],16).toString(16));let a=t.join(`:`);return a=a.replace(/^compact$/,`::`),a=a.replace(/(^compact)|(compact$)/,`:`),a=a.replace(/compact/,``),a}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(o.BITS,`0`)),this._binaryZeroPad}parse4in6(e){if(e.indexOf(`.`)===-1)return e;let t=e.split(`:`),n=t.slice(-1)[0],r=n.split(`.`);if(r.length===a.GROUPS&&r.every(e=>/^\d{1,3}$/.test(e))&&r.some(e=>/^0\d/.test(e))){let e=r.map(h).join(`.`),n=t.slice(0,-1).map(s.escapeHtml).join(`:`),i=t.length>1?`:`:``;throw new u.AddressError(`IPv4 addresses can't have leading zeroes.`,`${n}${i}${e}`)}let i=n.match(a.RE_ADDRESS);if(i){this.parsedAddress4=i[0];let n=this.subnetMask>=96?`/${this.subnetMask-96}`:``;this.address4=new c.Address4(`${this.parsedAddress4}${n}`),this.v4=!0,t[t.length-1]=this.address4.toGroup6(),e=t.join(`:`)}return e}parse(e){e=this.parse4in6(e);let t=e.match(o.RE_BAD_CHARACTERS);if(t)throw new u.AddressError(`Bad character${t.length>1?`s`:``} detected in address: ${t.join(``)}`,e.replace(o.RE_BAD_CHARACTERS,`<span class="parse-error">$1</span>`));let n=e.match(o.RE_BAD_ADDRESS);if(n)throw new u.AddressError(`Address failed regex: ${n.join(``)}`,e.replace(o.RE_BAD_ADDRESS,`<span class="parse-error">$1</span>`));let r=[],i=e.split(`::`);if(i.length===2){let e=i[0].split(`:`),t=i[1].split(`:`);e.length===1&&e[0]===``&&(e=[]),t.length===1&&t[0]===``&&(t=[]);let n=this.groups-(e.length+t.length);if(!n)throw new u.AddressError(`Error parsing groups`);this.elidedGroups=n,this.elisionBegin=e.length,this.elisionEnd=e.length+this.elidedGroups,r=r.concat(e);for(let e=0;e<n;e++)r.push(`0`);r=r.concat(t)}else if(i.length===1)r=e.split(`:`),this.elidedGroups=0;else throw new u.AddressError(`Too many :: groups found`);if(r=r.map(e=>parseInt(e,16).toString(16)),r.length!==this.groups)throw new u.AddressError(`Incorrect number of groups found`);return r}canonicalForm(){return this.parsedAddress.map(_).join(`:`)}decimal(){return this.parsedAddress.map(e=>parseInt(e,16).toString(10).padStart(5,`0`)).join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(_).join(``)}`)}to4(){let e=this.binaryZeroPad().split(``),t=BigInt(`0b${e.slice(96,128).join(``)}`).toString(16).padStart(8,`0`);if(this.subnetMask>=96){let e=this.subnetMask-96,n=[];for(let e=0;e<8;e+=2)n.push(parseInt(t.slice(e,e+2),16));return new c.Address4(`${n.join(`.`)}/${e}`)}return c.Address4.fromHex(t)}to4in6(){let t=this.to4(),n=new e(this.parsedAddress.slice(0,6).join(`:`),6).correctForm(),r=``;return/:$/.test(n)||(r=`:`),n+r+t.correctForm()}inspectTeredo(){let e=this.getBitsBase16(0,32),t=(this.getBits(80,96)^BigInt(`0xffff`)).toString(),n=c.Address4.fromHex(this.getBitsBase16(32,64)),r=this.getBits(96,128),i=c.Address4.fromHex((r^BigInt(`0xffffffff`)).toString(16).padStart(8,`0`)),a=this.getBitsBase2(64,80),o=(0,d.testBit)(a,15),s=(0,d.testBit)(a,14),l=(0,d.testBit)(a,8),u=(0,d.testBit)(a,9),f=BigInt(`0b${a.slice(2,6)+a.slice(8,16)}`).toString(10);return{prefix:`${e.slice(0,4)}:${e.slice(4,8)}`,server4:n.address,client4:i.address,flags:a,coneNat:o,microsoft:{reserved:s,universalLocal:u,groupIndividual:l,nonce:f},udpPort:t}}inspect6to4(){let e=this.getBitsBase16(0,16),t=c.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:e.slice(0,4),gateway:t.address}}to6to4(){if(!this.is4())return null;let t=[`2002`,this.getBitsBase16(96,112),this.getBitsBase16(112,128),``,`/16`].join(`:`);return new e(t)}static fromAddress4Nat64(t,n=`64:ff9b::/96`){let r=new c.Address4(t),i=new e(n),a=i.subnetMask;if(a!==32&&a!==40&&a!==48&&a!==56&&a!==64&&a!==96)throw new u.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);let o=i.binaryZeroPad(),s=r.binaryZeroPad(),l;if(a===96)l=o.slice(0,96)+s;else{let e=64-a;l=[o.slice(0,a),s.slice(0,e),`00000000`,s.slice(e),`0`.repeat(56-(32-e))].join(``)}let d=BigInt(`0b${l}`).toString(16).padStart(32,`0`),f=[];for(let e=0;e<8;e++)f.push(d.slice(e*4,(e+1)*4));return new e(f.join(`:`))}toAddress4Nat64(t=`64:ff9b::/96`){let n=new e(t),r=n.subnetMask;if(r!==32&&r!==40&&r!==48&&r!==56&&r!==64&&r!==96)throw new u.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);if(!this.isHostInSubnet(n))return null;let i=this.binaryZeroPad(),a;if(r===96)a=i.slice(96,128);else{let e=64-r;a=i.slice(r,r+e)+i.slice(72,72+(32-e))}let o=[];for(let e=0;e<4;e++)o.push(parseInt(a.slice(e*8,(e+1)*8),2).toString());return new c.Address4(o.join(`.`))}toByteArray(){let e=this.bigInt().toString(16).padStart(o.BITS/4,`0`),t=[];for(let n=0,r=e.length;n<r;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}toUnsignedByteArray(){return this.toByteArray().map(v)}static fromByteArray(e){return i.assertByteArray(e,16,`IPv6`,-128),this.fromUnsignedByteArray(e.map(v))}static fromUnsignedByteArray(t){i.assertByteArray(t,16,`IPv6`,0);let n=BigInt(`256`),r=BigInt(`0`),a=BigInt(`1`);for(let e=t.length-1;e>=0;e--)r+=a*BigInt(t[e].toString(10)),a*=n;return e.fromBigInt(r)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){let e=this.embeddedIPv4();return e?e.isLinkLocal():this.isHostInSubnet(w)}isMulticast(){let e=this.embeddedIPv4();if(e)return e.isMulticast();let t=this.getType();return t===`Multicast`||t.startsWith(`Multicast `)}is4(){return this.v4}isMapped4(){return this.isHostInSubnet(O)}embeddedIPv4(){return this.isMapped4()||this.isHostInSubnet(k)?this.to4():null}isTeredo(){return this.isHostInSubnet(x)}is6to4(){return this.isHostInSubnet(S)}isLoopback(){let e=this.embeddedIPv4();return e?e.isLoopback():this.getType()===`Loopback`}isULA(){return this.isHostInSubnet(C)}isPrivate(){let e=this.embeddedIPv4();return e?e.isPrivate():this.isULA()||this.isHostInSubnet(A)}isCGNAT(){let e=this.embeddedIPv4();return e?e.isCGNAT():!1}isBroadcast(){let e=this.embeddedIPv4();return e?e.isBroadcast():!1}isUnspecified(){let e=this.embeddedIPv4();return e?e.isUnspecified():this.getType()===`Unspecified`}isDocumentation(){return T.some(e=>this.isHostInSubnet(e))}isBenchmarking(){let e=this.embeddedIPv4();return e?e.isBenchmarking():this.isHostInSubnet(ee)}isGlobal(){let e=this.embeddedIPv4();return e?e.isGlobal():this.isHostInSubnet(E)&&i.isGloballyReachable.call(this,D)}href(e){return e=e===void 0?``:`:${e}`,`http://[${this.correctForm()}]${e}/`}link(e){e||={},e.className===void 0&&(e.className=``),e.prefix===void 0&&(e.prefix=`/#address=`),e.v4===void 0&&(e.v4=!1);let t=this.correctForm;e.v4&&(t=this.to4in6);let n=t.call(this),r=s.escapeHtml(`${e.prefix}${n}`),i=s.escapeHtml(n);return e.className?`<a href="${r}" class="${s.escapeHtml(e.className)}">${i}</a>`:`<a href="${r}">${i}</a>`}group(){if(this.elidedGroups===0)return s.simpleGroup(this.addressMinusSuffix).join(`:`);p(typeof this.elidedGroups==`number`),p(typeof this.elisionBegin==`number`);let e=[],[t,n]=this.addressMinusSuffix.split(`::`);t.length?e.push(...s.simpleGroup(t)):e.push(``);let r=[`hover-group`];for(let e=this.elisionBegin;e<this.elisionBegin+this.elidedGroups;e++)r.push(`group-${e}`);return e.push(`<span class="${r.join(` `)}"></span>`),n.length?e.push(...s.simpleGroup(n,this.elisionEnd)):e.push(``),this.is4()&&(p(this.address4 instanceof c.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(`:`)}regularExpressionString(t=!1){let n=[],r=new e(this.correctForm());if(r.elidedGroups===0)n.push((0,l.simpleRegularExpression)(r.parsedAddress));else if(r.elidedGroups===o.GROUPS)n.push((0,l.possibleElisions)(o.GROUPS));else{let e=r.address.split(`::`);e[0].length&&n.push((0,l.simpleRegularExpression)(e[0].split(`:`))),p(typeof r.elidedGroups==`number`),n.push((0,l.possibleElisions)(r.elidedGroups,e[0].length!==0,e[1].length!==0)),e[1].length&&n.push((0,l.simpleRegularExpression)(e[1].split(`:`))),n=[n.join(`:`)]}return t||(n=[`(?=^|`,l.ADDRESS_BOUNDARY,`|[^\\w\\:])(`,...n,`)(?=[^\\w\\:]|`,l.ADDRESS_BOUNDARY,`|$)`]),n.join(``)}regularExpression(e=!1){return new RegExp(this.regularExpressionString(e),`i`)}};e.Address6=y;var b=Object.keys(o.TYPES).map(e=>[new y(e),o.TYPES[e]]),x=new y(`2001::/32`),S=new y(`2002::/16`),C=new y(`fc00::/7`),w=new y(`fe80::/10`),T=[new y(`2001:db8::/32`),new y(`3fff::/20`)],ee=new y(`2001:2::/48`),E=new y(`2000::/3`),D=o.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new y(e),reachable:t})),O=new y(`::ffff:0:0/96`),k=new y(`64:ff9b::/96`),A=new y(`64:ff9b:1::/48`)})),tS=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.v6=e.AddressError=e.Address6=e.Address4=void 0;var i=Xx();Object.defineProperty(e,"Address4",{enumerable:!0,get:function(){return i.Address4}});var a=eS();Object.defineProperty(e,"Address6",{enumerable:!0,get:function(){return a.Address6}});var o=qx();Object.defineProperty(e,"AddressError",{enumerable:!0,get:function(){return o.AddressError}}),e.v6={helpers:r(Qx())}}))(),nS=n(Kc(),1),rS=new tS.Address6(`::/96`);function iS(e,t=56){if(Hi(e)){let n=new tS.Address6(e);if(n.isMapped4()||n.is4()&&n.isInSubnet(rS))return n.to4().correctForm();if(t)return new tS.Address6(`${e}/${t}`).networkForm()}return e}var aS=class{constructor(e){this.validations=e,this.previous=new Map,this.current=new Map,this.localKeys=!0}init(e){this.windowMs=e.windowMs,this.validations?.windowMs(this.windowMs),this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.clearExpired()},this.windowMs),this.interval.unref?.()}async get(e){return this.current.get(e)??this.previous.get(e)}async increment(e){let t=this.getClient(e),n=Date.now();return t.resetTime.getTime()<=n&&this.resetClient(t,n),t.totalHits++,t}async decrement(e){let t=this.getClient(e);t.totalHits>0&&t.totalHits--}async resetKey(e){this.current.delete(e),this.previous.delete(e)}async resetAll(){this.current.clear(),this.previous.clear()}shutdown(){clearInterval(this.interval),this.resetAll()}resetClient(e,t=Date.now()){return e.totalHits=0,e.resetTime.setTime(t+this.windowMs),e}getClient(e){if(this.current.has(e))return this.current.get(e);let t;return this.previous.has(e)?(t=this.previous.get(e),this.previous.delete(e)):(t={totalHits:0,resetTime:new Date},this.resetClient(t)),this.current.set(e,t),t}clearExpired(){this.previous=this.current,this.current=new Map}},oS={warn(...e){console.warn(...e.reverse())},error(...e){console.error(...e.reverse())}},sS=[`draft-6`,`draft-7`,`draft-8`],cS=(e,t)=>{let n;if(t){let e=Math.ceil((t.getTime()-Date.now())/1e3);n=Math.max(0,e)}else n=Math.ceil(e/1e3);return n},lS=e=>{let t=Ui(`sha256`);t.update(e);let n=t.digest(`hex`).slice(0,12);return Ri.from(n).toString(`base64`)},uS=(e,t)=>{e.headersSent||(e.setHeader(`X-RateLimit-Limit`,t.limit.toString()),e.setHeader(`X-RateLimit-Remaining`,t.remaining.toString()),t.resetTime instanceof Date&&(e.setHeader(`Date`,new Date().toUTCString()),e.setHeader(`X-RateLimit-Reset`,Math.ceil(t.resetTime.getTime()/1e3).toString())))},dS=(e,t,n)=>{if(e.headersSent)return;let r=Math.ceil(n/1e3),i=cS(n,t.resetTime);e.setHeader(`RateLimit-Policy`,`${t.limit};w=${r}`),e.setHeader(`RateLimit-Limit`,t.limit.toString()),e.setHeader(`RateLimit-Remaining`,t.remaining.toString()),typeof i==`number`&&e.setHeader(`RateLimit-Reset`,i.toString())},fS=(e,t,n)=>{if(e.headersSent)return;let r=Math.ceil(n/1e3),i=cS(n,t.resetTime);e.setHeader(`RateLimit-Policy`,`${t.limit};w=${r}`),e.setHeader(`RateLimit`,`limit=${t.limit}, remaining=${t.remaining}, reset=${i}`)},pS=(e,t,n,r,i)=>{if(e.headersSent)return;let a=Math.ceil(n/1e3),o=cS(n,t.resetTime),s=lS(i),c=`r=${t.remaining}; t=${o}`,l=`q=${t.limit}; w=${a}; pk=:${s}:`;e.append(`RateLimit`,`"${r}"; ${c}`),e.append(`RateLimit-Policy`,`"${r}"; ${l}`)},mS=(e,t,n,r)=>{if(e.headersSent)return;let i=r??cS(n,t.resetTime);e.setHeader(`Retry-After`,i.toString())},hS=e=>{let t={};for(let n of Object.keys(e)){let r=n;e[r]!==void 0&&(t[r]=e[r])}return t},gS=class extends Error{constructor(e,t){let n=`https://express-rate-limit.github.io/${e}/`;super(`${t} See ${n} for more information.`),this.name=this.constructor.name,this.code=e,this.help=n}},_S=class extends gS{},vS=new Set,yS=new WeakMap,bS={enabled:{default:!0},disable(){for(let e of Object.keys(this.enabled))this.enabled[e]=!1},ip(e){if(e===void 0)throw new gS(`ERR_ERL_UNDEFINED_IP_ADDRESS`,`An undefined 'request.ip' was detected. This might indicate a misconfiguration or the connection being destroyed prematurely.`);if(!Bi(e))throw new gS(`ERR_ERL_INVALID_IP_ADDRESS`,`An invalid 'request.ip' (${e}) was detected. Consider passing a custom 'keyGenerator' function to the rate limiter.`)},trustProxy(e){if(e.app.get(`trust proxy`)===!0)throw new gS(`ERR_ERL_PERMISSIVE_TRUST_PROXY`,`The Express 'trust proxy' setting is true, which allows anyone to trivially bypass IP-based rate limiting.`)},xForwardedForHeader(e){if(e.headers[`x-forwarded-for`]&&e.app.get(`trust proxy`)===!1)throw new gS(`ERR_ERL_UNEXPECTED_X_FORWARDED_FOR`,`The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users.`)},forwardedHeader(e){if(e.headers.forwarded&&e.ip===e.socket?.remoteAddress)throw new gS(`ERR_ERL_FORWARDED_HEADER`,`The 'Forwarded' header (standardized X-Forwarded-For) is set but currently being ignored. Add a custom keyGenerator to use a value from this header.`)},positiveHits(e){if(typeof e!=`number`||e<1||e!==Math.round(e))throw new gS(`ERR_ERL_INVALID_HITS`,`The totalHits value returned from the store must be a positive integer, got ${e}`)},unsharedStore(e){if(vS.has(e)){let t=e?.localKeys?``:` (with a unique prefix)`;throw new gS(`ERR_ERL_STORE_REUSE`,`A Store instance must not be shared across multiple rate limiters. Create a new instance of ${e.constructor.name}${t} for each limiter instead.`)}vS.add(e)},singleCount(e,t,n){let r=yS.get(e);r||(r=new Map,yS.set(e,r));let i=t.localKeys?t:t.constructor.name,a=r.get(i);a||(a=[],r.set(i,a));let o=`${t.prefix??``}${n}`;if(a.includes(o))throw new gS(`ERR_ERL_DOUBLE_COUNT`,`The hit count for ${n} was incremented more than once for a single request.`);a.push(o)},limit(e){if(e===0)throw new _S(`WRN_ERL_MAX_ZERO`,`Setting limit or max to 0 disables rate limiting in express-rate-limit v6 and older, but will cause all requests to be blocked in v7`)},draftPolliHeaders(e){if(e)throw new _S(`WRN_ERL_DEPRECATED_DRAFT_POLLI_HEADERS`,`The draft_polli_ratelimit_headers configuration option is deprecated and has been removed in express-rate-limit v7, please set standardHeaders: 'draft-6' instead.`)},onLimitReached(e){if(e)throw new _S(`WRN_ERL_DEPRECATED_ON_LIMIT_REACHED`,`The onLimitReached configuration option is deprecated and has been removed in express-rate-limit v7.`)},headersDraftVersion(e){if(typeof e!=`string`||!sS.includes(e))throw new gS(`ERR_ERL_HEADERS_UNSUPPORTED_DRAFT_VERSION`,`standardHeaders: only the following versions of the IETF draft specification are supported: ${sS.join(`, `)}.`)},headersResetTime(e){if(!e)throw new gS(`ERR_ERL_HEADERS_NO_RESET`,`standardHeaders: 'draft-7' requires a 'resetTime', but the store did not provide one. The 'windowMs' value will be used instead, which may cause clients to wait longer than necessary.`)},knownOptions(e){if(!e)return;let t=Object.keys({windowMs:!0,limit:!0,message:!0,statusCode:!0,legacyHeaders:!0,standardHeaders:!0,identifier:!0,retryAfter:!0,requestPropertyName:!0,skipFailedRequests:!0,skipSuccessfulRequests:!0,keyGenerator:!0,ipv6Subnet:!0,handler:!0,skip:!0,requestWasSuccessful:!0,store:!0,validate:!0,headers:!0,max:!0,passOnStoreError:!0,logger:!0}).concat(`draft_polli_ratelimit_headers`,`delayAfter`,`delayMs`,`maxDelayMs`);for(let n of Object.keys(e))if(!t.includes(n))throw new gS(`ERR_ERL_UNKNOWN_OPTION`,`Unexpected configuration option: ${n}`)},validationsConfig(){let e=Object.keys(this).filter(e=>![`enabled`,`disable`].includes(e));e.push(`default`);for(let t of Object.keys(this.enabled))if(!e.includes(t))throw new gS(`ERR_ERL_UNKNOWN_VALIDATION`,`options.validate.${t} is not recognized. Supported validate options are: ${e.join(`, `)}.`)},creationStack(e){let{stack:t}=Error(`express-rate-limit validation check (set options.validate.creationStack=false to disable)`);if(t?.includes(`Layer.handle [as handle_request]`)||t?.includes(`Layer.handleRequest`))throw e.localKeys?new gS(`ERR_ERL_CREATED_IN_REQUEST_HANDLER`,`express-rate-limit instance should be created at app initialization, not when responding to a request.`):new gS(`ERR_ERL_CREATED_IN_REQUEST_HANDLER`,`express-rate-limit instance should *usually* be created at app initialization, not when responding to a request.`)},ipv6Subnet(e){if(e!==!1&&(!Number.isInteger(e)||e<32||e>64))throw new gS(`ERR_ERL_IPV6_SUBNET`,`Unexpected ipv6Subnet value: ${e}. Expected an integer between 32 and 64 (usually 48-64).`)},ipv6SubnetOrKeyGenerator(e){if(e.ipv6Subnet!==void 0&&e.keyGenerator)throw new gS(`ERR_ERL_IPV6SUBNET_OR_KEYGENERATOR`,`Incompatible options: the 'ipv6Subnet' option is ignored when a custom 'keyGenerator' function is also set.`)},keyGeneratorIpFallback(e){if(!e)return;let t=e.toString();if((t.includes(`req.ip`)||t.includes(`request.ip`))&&!t.includes(`ipKeyGenerator`))throw new gS(`ERR_ERL_KEY_GEN_IPV6`,`Custom keyGenerator appears to use request IP without calling the ipKeyGenerator helper function for IPv6 addresses. This could allow IPv6 users to bypass limits.`)},windowMs(e){let t=2**31-1;if(typeof e!=`number`||Number.isNaN(e)||e<1||e>t)throw new gS(`ERR_ERL_WINDOW_MS`,`Invalid windowMs value: ${e}${typeof e==`number`?``:` (${typeof e})`}, must be a number between 1 and ${t} when using the default MemoryStore`)}};function xS(e){if(typeof e!=`object`||typeof e.error!=`function`||typeof e.warn!=`function`)throw TypeError(`Provided logger does not implement the Logger interface`)}var SS=(e,t)=>{xS(t);let n;n=typeof e==`boolean`?{default:e}:{default:!0,...e};let r={enabled:n};for(let[e,i]of Object.entries(bS))typeof i==`function`&&(r[e]=(...a)=>{if(n[e]??n.default){n[e]=!1;try{i.apply(r,a)}catch(e){e instanceof _S?t.warn(e):t.error(e)}}});let i=Symbol.for(`nodejs.util.inspect.custom`);return i&&(r[i]=()=>r.enabled),r},CS=e=>typeof e.incr==`function`&&typeof e.increment!=`function`,wS=e=>{if(!CS(e))return e;let t=e;class n{async increment(e){return new Promise((n,r)=>{t.incr(e,(e,t,i)=>{e&&r(e),n({totalHits:t,resetTime:i})})})}async decrement(e){return t.decrement(e)}async resetKey(e){return t.resetKey(e)}async resetAll(){if(typeof t.resetAll==`function`)return t.resetAll()}}return new n},TS=e=>{let{validations:t,...n}=e;return{...n,validate:t.enabled}},ES=e=>{let t=hS(e),n=e.logger??oS,r=SS(t?.validate??!0,n);r.validationsConfig(),r.knownOptions(e),r.draftPolliHeaders(t.draft_polli_ratelimit_headers),r.onLimitReached(t.onLimitReached),t.ipv6Subnet!==void 0&&typeof t.ipv6Subnet!=`function`&&r.ipv6Subnet(t.ipv6Subnet),r.keyGeneratorIpFallback(t.keyGenerator),r.ipv6SubnetOrKeyGenerator(t);let i=t.standardHeaders??!1;i===!0&&(i=`draft-6`);let a={windowMs:6e4,limit:e.max??5,message:`Too many requests, please try again later.`,statusCode:429,legacyHeaders:e.headers??!0,identifier(e,t){let n=``,{limit:r}=e[a.requestPropertyName],i=a.windowMs/1e3,o=a.windowMs/6e4,s=a.windowMs/36e5,c=a.windowMs/864e5;return n=i<60?`${i}sec`:o<60?`${o}min`:s<24?`${s}hr${s>1?`s`:``}`:`${c}day${c>1?`s`:``}`,`${r}-in-${n}`},requestPropertyName:`rateLimit`,skipFailedRequests:!1,skipSuccessfulRequests:!1,requestWasSuccessful:(e,t)=>t.statusCode<400,skip:(e,t)=>!1,async keyGenerator(e,t){r.ip(e.ip),r.trustProxy(e),r.xForwardedForHeader(e),r.forwardedHeader(e);let n=e.ip,i=56;return Hi(n)&&(i=typeof a.ipv6Subnet==`function`?await a.ipv6Subnet(e,t):a.ipv6Subnet,typeof a.ipv6Subnet==`function`&&r.ipv6Subnet(i)),iS(n,i)},ipv6Subnet:56,async handler(e,t,n,r){t.status(a.statusCode);let i=typeof a.message==`function`?await a.message(e,t):a.message;t.writableEnded||t.send(i)},passOnStoreError:!1,...t,standardHeaders:i,store:wS(t.store??new aS(r)),validations:r,logger:n};if(typeof a.store.increment!=`function`||typeof a.store.decrement!=`function`||typeof a.store.resetKey!=`function`||a.store.resetAll!==void 0&&typeof a.store.resetAll!=`function`||a.store.init!==void 0&&typeof a.store.init!=`function`)throw TypeError("An invalid store was passed. Please ensure that the store is a class that implements the `Store` interface.");return a},DS=e=>async(t,n,r)=>{try{await Promise.resolve(e(t,n,r)).catch(r)}catch(e){r(e)}},OS=e=>{let t=ES(e??{}),n=TS(t),r=(0,nS.default)(`express-rate-limit`);r(`creating new rate limiter with %o`,t.store.constructor.name);for(let[e,n]of Object.entries(t))r(`set %s to %o`,e,n);if(t.validations.creationStack(t.store),t.validations.unsharedStore(t.store),typeof t.store.init==`function`){r(`executing init for store`);try{let e=t.store.init(n);e instanceof Promise&&e.catch(e=>t.logger.error(e,`express-rate-limit: async error during store initialization.`))}catch(e){t.logger.error(e,`express-rate-limit: error during store initialization.`)}}let i=DS(async(e,i,a)=>{let o=t.skipFailedRequests&&new Promise(e=>i.once(`close`,e)),s=(t.skipFailedRequests||t.skipSuccessfulRequests)&&new Promise(e=>i.once(`finish`,e)),c=t.skipFailedRequests&&new Promise(e=>i.once(`error`,e));if(r(`requested %o`,e.originalUrl),r(`request from ip %o`,e.ip),await t.skip(e,i)){r(`skipping request`),a();return}let l=e,u=await t.keyGenerator(e,i);r(`computed key %o`,u),r(`incrementing count`);let d=0,f;try{let e=await t.store.increment(u);d=e.totalHits,f=e.resetTime}catch(e){if(t.passOnStoreError){t.logger.error(e,`express-rate-limit: error from store, allowing request without rate-limiting.`),a();return}throw e}t.validations.positiveHits(d),t.validations.singleCount(e,t.store,u);let p=await(typeof t.limit==`function`?t.limit(e,i):t.limit);t.validations.limit(p);let m={limit:p,used:d,remaining:Math.max(p-d,0),resetTime:f,key:u};for(let[e,n]of Object.entries(m))r(`set request.%s.%s to be %o`,t.requestPropertyName,e,n);if(Object.defineProperty(m,"current",{configurable:!1,enumerable:!1,value:d}),l[t.requestPropertyName]=m,t.legacyHeaders&&!i.headersSent&&(r(`set legacy headers`),uS(i,m)),t.standardHeaders&&!i.headersSent)switch(t.standardHeaders){case`draft-6`:r(`set ietf draft 6 headers`),dS(i,m,t.windowMs);break;case`draft-7`:r(`set ietf draft 7 headers`),t.validations.headersResetTime(m.resetTime),fS(i,m,t.windowMs);break;case`draft-8`:{let n=await(typeof t.identifier==`function`?t.identifier(e,i):t.identifier);r(`set ietf draft 8 headers`),r(`set name to %o`,n),t.validations.headersResetTime(m.resetTime),pS(i,m,t.windowMs,n,u);break}default:t.validations.headersDraftVersion(t.standardHeaders)}if(t.skipFailedRequests||t.skipSuccessfulRequests){let n=!1,a=async()=>{if(!n){if(f&&Date.now()>=f.getTime())return;r(`decrementing count`),await t.store.decrement(u),n=!0}};t.skipFailedRequests&&(s&&s.then(async()=>{let n=await t.requestWasSuccessful(e,i);r(`computed requestWasSuccessful as %o`,n),n||await a()}),o&&o.then(async()=>{i.writableEnded||await a()}),c&&c.then(async()=>{await a()})),t.skipSuccessfulRequests&&s&&s.then(async()=>{let n=await t.requestWasSuccessful(e,i);r(`computed requestWasSuccessful as %o`,n),n&&await a()})}if(d>p){if(r(`limit exceeded`),t.legacyHeaders||t.standardHeaders){r(`set retry-after header`);let n=await(typeof t.retryAfter==`function`?t.retryAfter(e,i):t.retryAfter);mS(i,m,t.windowMs,n)}t.handler(e,i,a,n);return}a()});return i.resetKey=t.store.resetKey.bind(t.store),i.getKey=typeof t.store.get==`function`?t.store.get.bind(t.store):()=>{throw Error(`The current store does not support the get/getKey method`)},i},kS=Pi.map(({operationId:e,method:t,path:n,parameter:r})=>({operationId:e,method:t,path:n,authorizationPath:yi(n,Object.fromEntries(r.filter(e=>e.in===`path`).map(e=>e.schemaEnum?.[0]===void 0?e.schemaFormat===`uuid`?[e.name,Wi()]:e.schemaType===`integer`||e.schemaType===`number`?[e.name,1]:[e.name,`authorization-probe`]:[e.name,e.schemaEnum[0]])),e)})),AS={ttlMs:6e4,maxEntries:128,verificationDeadlineMs:1e4,maxConcurrentVerifications:16,maxOverBudgetVerifications:2},jS=()=>new Ge({status:429,title:`Too Many Requests`,type:`about:blank`,detail:`Too many credential verifications are in progress; retry shortly.`,retryAfterSeconds:1});function MS(e){if(!e.includes(`.`))return 1/0;try{let{exp:t}=Ye(e);return t===void 0?1/0:t*1e3}catch(e){if(!(e instanceof at))throw e;return 1/0}}var NS=(e,t)=>`${Ui(`sha256`).update(e).digest(`hex`)} ${t?.href??``}`;function PS(e=AS){let t=new Map,n={limit:e.maxConcurrentVerifications,inFlight:0},r={limit:e.maxOverBudgetVerifications,inFlight:0},i=(i,a,o)=>{let s=NS(i,a),c=t.get(s);if(c!==void 0&&c.expiresAt>Date.now())return t.delete(s),t.set(s,c),c.verification;let l=o?[n,r]:[n];if(l.some(({inFlight:e,limit:t})=>e>=t))return Promise.reject(jS());t.delete(s);for(let e of l)e.inFlight+=1;let u=()=>{for(let e of l)--e.inFlight},d=Yn(i,a,kS,AbortSignal.timeout(e.verificationDeadlineMs)),f={verification:d,expiresAt:1/0};t.set(s,f);for(let n of t.keys()){if(t.size<=e.maxEntries)break;t.delete(n)}let p=()=>{t.get(s)===f&&t.delete(s)};return d.then(t=>{u(),t===null||t===`forbidden`?p():f.expiresAt=Math.min(Date.now()+e.ttlMs,MS(i))},()=>{u(),p()}),d},a=(e,n)=>{let r=hb(e.header(`authorization`));if(r===void 0)return!1;let i=t.get(NS(r,n))?.expiresAt;return i!==void 0&&Number.isFinite(i)&&i>Date.now()},o=async(e,t,n)=>{let r=hb(e.header(`authorization`));if(r===void 0)return{ok:!1,reason:`missing_credential`,hasAuthorization:!1};try{let e=await i(r,t,n);if(e===`forbidden`)return{ok:!1,reason:`forbidden`,hasAuthorization:!0};if(e!==null)return{ok:!0,scope:e.operationAccess===`READ`?`read`:`write`,userBearerToken:r,authorization:e}}catch(e){if(!(e instanceof at))throw e;N({component:`aventure-mcp-server`,event:`invalid_bearer_jwt`,fields:{requestId:xi()},error:e})}return{ok:!1,reason:`credential_mismatch`,hasAuthorization:!0}},s=new WeakMap,c=(e,t,n=!1)=>{let r=s.get(e);if(r!==void 0&&r.resourceHref===t?.href)return r.decision;let i=o(e,t,n);return s.set(e,{resourceHref:t?.href,decision:i}),i};return Object.assign((e,t)=>c(e,t),{holdsGrant:a,admitsOverBudget:(e,t)=>hb(e.header(`authorization`))===void 0?Promise.resolve(!1):c(e,t,!0).then(e=>e.ok,()=>!1)})}function FS(e,t){let n=new WeakMap;return[OS({windowMs:6e4,limit:120,skipSuccessfulRequests:!0,skip:async n=>e.holdsGrant(n,await t()),handler:(...[e,,t,r])=>{n.set(e,r),t()}}),async(r,i,a)=>{let o=n.get(r);o===void 0||await e.admitsOverBudget(r,await t())?a():i.status(o.statusCode).send(o.message)},OS({windowMs:6e4,limit:120,keyGenerator:IS})]}function IS(e){let t=hb(e.header(`authorization`));return t===void 0?iS(e.ip??``):Ui(`sha256`).update(t).digest(`base64url`)}function LS(e,t){let n=`an API key from https://aventure.vc/settings/api-keys as Authorization: Bearer <key>`,r=t?`Sign in with OAuth through the authorization server in this server's resource metadata; a client that cannot register itself needs the OAuth client ID at https://docs.aventure.vc/mcp. Or send ${n}.`:`Send ${n}. This server advertises no OAuth authorization server.`;return e===`forbidden`?`The supplied credential is valid, but its account may not use this MCP server.`:e===`missing_credential`?r:`The supplied credential was rejected or expired; reconnect this server in the MCP client to sign in again. ${r}`}var RS=1024,zS=RS*RS,BS=1,VS=2,HS=`b`,US=`kb`,WS=`mb`,GS=/^(\d+(?:\.\d+)?)\s*(b|kb|mb)?$/u;function KS(e){let t=JS(e.limit),n=qS(e.path);return(r,i,a)=>{if(t===void 0||r.method!==`POST`||qS(r.path)!==n){a();return}let o=YS(r.header(`content-length`));if(o===void 0||o<=t){a();return}i.setHeader(`Connection`,`close`),e.reject(i)}}function qS(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;return t===``?`/`:t}function JS(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=0?e:void 0;let t=GS.exec(e.trim().toLowerCase());if(t===null)return;let n=Number(t[BS]);if(Number.isFinite(n))switch(t[VS]??HS){case WS:return Math.floor(n*zS);case US:return Math.floor(n*RS);case HS:return Math.floor(n)}}function YS(e){if(e===void 0)return;let t=Number(e);return Number.isInteger(t)&&t>=0?t:void 0}var XS=400,ZS=400,QS=413,$S=`10mb`,eC=`127.0.0.1`,tC=/^[\w.:/-]{1,128}$/,nC=`0.0.0.0`;async function rC(e){let t=e.jsonBodyLimit??$S,n=PS(),r=e.host??eC,i=r!==nC,a=(t,n)=>{let r=`${t.protocol}://${t.host}`;return URL.canParse(e.path,r)&&new URL(e.path,r).href===n?.resourceUrl.href?n:void 0},o=(0,Hd.default)();o.disable(`x-powered-by`),o.set(`trust proxy`,1),o.use((e,t,n)=>{let r=e.get(`x-client-request-id`)??``,i=tC.test(r)?r:Wi(),a=performance.now(),o={requestId:i,method:e.method,path:e.path,host:e.hostname,userAgent:e.get(`user-agent`)},s=oC(e);s||E({component:`aventure-mcp-server`,event:`http_request`,fields:o}),t.on(`finish`,()=>{let n=Math.round(performance.now()-a),r=e.route,i=typeof r==`object`&&r?Reflect.get(r,`path`):null,c=Kx(e.body);Eb(e.method,typeof i==`string`?i:`unmatched`,t.statusCode,n,c),(t.statusCode>=XS&&!s?N:E)({component:`aventure-mcp-server`,event:`http_response`,fields:{...o,...c,status:t.statusCode,durationMs:n}})}),_i(i,()=>n())}),o.use(i?(0,Vd.default)({origin:aC}):(0,Vd.default)()),o.use(KS({path:e.path,limit:t,reject:e=>sC(e,QS,`Payload Too Large`,`Request JSON body exceeds the MCP transport size limit.`)})),o.use(Hd.json({limit:t})),o.get(`/health`,(...e)=>{let t=e[1],n=process.env.GIT_SHA?.trim();t.setHeader(`X-Aventure-Revision`,n&&/^[0-9a-f]{40}$/i.test(n)?n.slice(0,7):`unknown`),t.status(200).json({status:`UP`})}),o.get([`/.well-known/oauth-protected-resource`,`/.well-known/oauth-protected-resource${e.path}`],(0,Vd.default)(),async(t,n,r)=>{let i=await e.resolveOAuthDiscovery();if(i===void 0){sC(n,503,`Service Unavailable`,`OAuth discovery is unavailable: the API published no OAuth resource indicator for this server.`);return}let o=a(t,i);if(o===void 0){r();return}n.status(200).json({resource:o.resourceUrl.href,authorization_servers:[o.client.authorizationServer],scopes_supported:o.client.scope})}),Db(o,e.metricsScrapeSecret),o.get(`/`,(...t)=>{t[1].status(200).json({name:`aventure-mcp-server`,mcp:e.path,health:`/health`,transport:`streamable-http`,method:`POST`})}),o.get(`/favicon.ico`,(...e)=>e[1].status(204).end());let s=FS(n,async()=>(await e.resolveOAuthDiscovery())?.resourceUrl);return o.post(e.path,s,async(t,r)=>{let o=xi(),s=t.header(`origin`);if(i&&!iC(s)){N({component:`aventure-mcp-server`,event:`foreign_origin_rejected`,fields:{requestId:o,method:t.method,path:t.path,origin:s}}),sC(r,403,`Forbidden`,`A self-hosted MCP transport accepts loopback browser origins only.`);return}let c,l;try{let r=await e.resolveOAuthDiscovery();l=a(t,r),c=await n(t,r?.resourceUrl)}catch(e){Pc(e,`authentication_unavailable`),j({component:`aventure-mcp-server`,event:`authentication_unavailable`,fields:{requestId:o,method:t.method,path:t.path},error:e});let n=e instanceof Ge&&(e.problem.status===429||ai(e.problem.status))?e.problem:void 0;n===void 0?sC(r,503,`Service Unavailable`,`Authentication service is temporarily unavailable.`):(typeof n.retryAfterSeconds==`number`&&r.set(`Retry-After`,String(n.retryAfterSeconds)),cC(r,n));return}if(!c.ok){N({component:`aventure-mcp-server`,event:`unauthorized_request`,fields:{requestId:o,method:t.method,path:t.path,reason:c.reason,hasAuthorization:c.hasAuthorization}});let e=[l===void 0?void 0:`resource_metadata="${hv(l.resourceUrl)}"`,l===void 0?void 0:`scope="${l.client.scope.join(` `)}"`,c.reason===`credential_mismatch`?`error="invalid_token"`:void 0,c.reason===`credential_mismatch`?`error_description="The bearer token is invalid or expired"`:void 0,c.reason===`forbidden`?`error="insufficient_scope"`:void 0].filter(e=>e!==void 0);r.set(`WWW-Authenticate`,e.length===0?`Bearer`:`Bearer ${e.join(`, `)}`);let n=c.reason===`forbidden`;sC(r,n?403:401,n?`Forbidden`:`Unauthorized`,LS(c.reason,l!==void 0));return}let u=t.header(`accept`)??`*/*`;if(!u.includes(`*/*`)&&(!u.includes(`application/json`)||!u.includes(`text/event-stream`))){sC(r,406,`Not Acceptable`,`MCP Streamable HTTP requires Accept: application/json, text/event-stream.`);return}E({component:`aventure-mcp-server`,event:`mcp_request_authorized`,fields:{requestId:o,method:t.method,path:t.path,scope:c.scope}});let d=[],f=e=>{Pc(e,`transport_error`),j({component:`aventure-mcp-server`,event:`transport_error`,message:se(e),fields:{requestId:o,method:t.method,path:t.path},error:e})},p=gy(()=>Ux(c.scope,c.authorization),{onerror:e=>d.push(e),maxSubscriptions:0}),m=async()=>{await Iy(p,{onerror:f})(t,r,t.body);for(let e of d)ai(r.statusCode)?f(e):(r.statusCode<XS?E:N)({component:`aventure-mcp-server`,event:`mcp_request_rejected`,message:se(e),fields:{requestId:o,method:t.method,path:t.path,status:r.statusCode}})};c.userBearerToken===void 0?await m():await gi(c.userBearerToken,m)}),o.all(e.path,(...e)=>sC(e[1],405,`Method Not Allowed`,`MCP transport accepts POST requests only.`)),o.use((e,t,n,r)=>{if(n.headersSent){r(e);return}let i=lC(e);if(i===void 0){r(e);return}N({component:`aventure-mcp-server`,event:`json_body_rejected`,message:i.message,fields:{requestId:xi(),method:t.method,path:t.path,status:i.status}}),sC(n,i.status,i.status===QS?`Payload Too Large`:`Bad Request`,i.status===QS?`Request JSON body exceeds the MCP transport size limit.`:`Request body must be valid JSON.`)}),await new Promise((t,n)=>{let i;i=o.listen(e.port,r,()=>{t({server:i,close:async()=>{await new Promise((e,t)=>{i.close(n=>n?t(n):e()),i.closeIdleConnections()}),await Ob()}})}),i.on(`error`,n)})}function iC(e){if(e===void 0)return!0;if(!URL.canParse(e))return!1;let{hostname:t}=new URL(e);return t===`localhost`?!0:t.startsWith(`[`)?t===`[::1]`:Vi(t)&&t.startsWith(`127.`)}var aC=(e,t)=>t(null,iC(e)),oC=e=>e.method===`GET`&&/^\/robots\.txt\/?$/iu.test(e.path);function sC(e,t,n,r){cC(e,{type:`about:blank`,title:n,status:t,detail:r})}function cC(e,t){e.status(t.status).type(`application/problem+json`).json(t)}function lC(e){if(typeof e!=`object`||!e||!(`type`in e)||!(`status`in e))return;let t=e.type===`entity.too.large`?QS:e.type===`entity.parse.failed`?ZS:e.status===QS||e.status===ZS?e.status:void 0;return t===void 0?void 0:{status:t,message:`message`in e&&typeof e.message==`string`?e.message:`JSON body rejected`}}var uC=65535,dC=55e3,fC=pi(zi(import.meta.url)),{host:pC}=(await new p().name(fC.bin[0]).description(`Serve aVenture tools over MCP Streamable HTTP.`).version(fC.version).option(`--host <address>`,`Bind this address instead of 127.0.0.1; 0.0.0.0 exposes the server to the network.`).addHelpText(`after`,`
145
145
  Connect an MCP client to the server's /mcp URL and send
146
146
  Authorization: Bearer <credential> using an OAuth access token or API key from
147
147
  aventure.vc. The hosted