@ahmadissa/cloudworker-proxy 1.1.132 → 1.1.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var Ro=Object.create;var Er=Object.defineProperty;var xo=Object.getOwnPropertyDescriptor;var Uo=Object.getOwnPropertyNames;var Io=Object.getPrototypeOf,Wo=Object.prototype.hasOwnProperty;var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Jo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Uo(t))!Wo.call(e,o)&&o!==r&&Er(e,o,{get:()=>t[o],enumerable:!(n=xo(t,o))||n.enumerable});return e};var v=(e,t,r)=>(r=e!=null?Ro(Io(e)):{},Jo(t||!e||!e.__esModule?Er(r,"default",{value:e,enumerable:!0}):r,e));var mt=_((dd,Cr)=>{function ko({host:e=".*",path:t=".*",excludePath:r=null,method:n=[".*"],handler:o,protocol:s=".*",handlerName:a,headers:i={},data:c}){let u=[],p=[],d=e.replace(/(:([^.]+))/g,(T,N,U)=>(u.push(U),"([^.]+)")),h=t.replace(/(:([^/]+))/g,(T,N,U)=>U.slice(-1)==="*"?(p.push(U.slice(0,U.length-1)),"(.*)"):(p.push(U),"([^/]*)")),l=new RegExp(`^${d}$`,"i"),m=new RegExp(`^${h}$`,"i"),w=r?new RegExp(`^${r}$`,"i"):null,y=new RegExp(`^${n.join("|")}$`,"i"),g=new RegExp(`^${s}$`,"i");return{hostVariables:u,pathVariables:p,host:l,path:m,excludePath:w,method:y,protocol:g,handler:o,handlerName:a,headers:i,data:c}}function br(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}async function No(e,t=1024*1024){let r=[],n=e.getReader(),o=new TextDecoder,s=0;for(;t&&s<t;){let{done:i,value:c}=await n.read();if(i)break;s+=c.byteLength,r.push(o.decode(c))}let a=r.join("");return t?a.substring(0,t):a}function Do(e){let t=new URL(e.url),r=br(t.searchParams),n=br(e.headers);n.host&&(t.hostname=n.host);let o,s;async function a(i){if(s>=i)return o.substring(0,i);let c=e.clone();return o=await No(c.body,i),o}return{body:e.body,headers:n,host:t.host,hostname:t.hostname,href:t.href,json:async i=>JSON.parse(a(i)),method:e.method,origin:`${t.protocol}//${t.host}`,path:t.pathname,protocol:t.protocol.slice(0,-1),query:r,querystring:t.search.slice(1),search:t.search,text:async i=>e.headers.get("content-type")==="application/x-www-form-urlencoded"?decodeURIComponent(await a(i)):a(i)}}Cr.exports={parseRoute:ko,parseRequest:Do}});var vr=_((ud,_r)=>{function Mo(e,t){let r={},n=t.host.exec(e.host);t.hostVariables.forEach((s,a)=>{r[s]=n[a+1]});let o=t.path.exec(e.path);return t.pathVariables.forEach((s,a)=>{r[s]=o[a+1]}),r}function $o(e,t){let r=!0;return Object.keys(e.headers).forEach(n=>{t.headers[n]!==e.headers[n]&&(r=!1)}),r}function qo(e,t){return e.protocol.test(t.protocol)}function Lo(e,t){return e.method.test(t.method)&&e.host.test(t.host)&&e.path.test(t.path)&&$o(e,t)&&qo(e,t)&&(!e.excludePath||!e.excludePath.test(t.path))}async function yt(e,t){let[r,...n]=t;if(!r)return new Response("NOT_FOUND",{status:404});if(!Lo(r,e.request))return yt(e,n);e.state.handlers=e.state.handlers||[],e.state.handlers.push(r.handlerName||r.handler.name),e.params=Mo(e.request,r);try{return r.handler(e,async o=>yt(o,n))}catch(o){throw o.route=r.handler.name,o}}_r.exports={recurseRoutes:yt}});var Hr=_((pd,Pr)=>{Pr.exports={methods:{DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST"},statusMessages:{404:"Not found",429:"Rate limited"}}});var Or=_((hd,Kr)=>{var Fo=mt();Kr.exports=class Tr{constructor(t){this.request=Fo.parseRequest(t.request),this.event=t,this.state={},this.cloned=!1,this.response={headers:{}},this.body="",this.status=404,this.query=this.request.query}header(t){return this.request.headers[t]}set(t,r){this.response.headers[t]=r}clone(){let t=new Tr(this.event);return t.cloned=!0,t}}});var xr=_((ld,Rr)=>{var ue=mt(),Go=vr(),_e=Hr(),Bo=Or();Rr.exports=class{constructor(){this.routes=[]}get(t,r){let n=ue.parseRoute({method:[_e.methods.GET,_e.methods.HEAD],path:t,handler:r});this.routes.push(n)}post(t,r){let n=ue.parseRoute({method:[_e.methods.POST],path:t,handler:r});this.routes.push(n)}patch(t,r){let n=ue.parseRoute({method:[_e.methods.PATCH],path:t,handler:r});this.routes.push(n)}del(t,r){let n=ue.parseRoute({method:[_e.methods.DELETE],path:t,handler:r});this.routes.push(n)}use(t){let r=ue.parseRoute({handler:t,middleware:!0});this.routes.push(r)}add({host:t,path:r,excludePath:n,method:o,handlerName:s,headers:a,protocol:i},c){let u=ue.parseRoute({method:o,host:t,path:r,excludePath:n,handler:c,headers:a,handlerName:s,protocol:i});this.routes.push(u)}async resolve(t){let r=new Bo(t);try{return await Go.recurseRoutes(r,this.routes),new Response(r.body,{status:r.status,headers:r.response.headers})}catch(n){return new Response(n.message,{status:500})}}}});var M=_((md,Gr)=>{var Vo="Expected a function",kr="__lodash_hash_undefined__",Nr=1/0,zo="[object Function]",Xo="[object GeneratorFunction]",jo="[object Symbol]",Yo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zo=/^\w*$/,Qo=/^\./,es=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ts=/[\\^$.*+?()[\]{}|]/g,rs=/\\(\\)?/g,ns=/^\[object .+?Constructor\]$/,os=typeof global=="object"&&global&&global.Object===Object&&global,ss=typeof self=="object"&&self&&self.Object===Object&&self,wt=os||ss||Function("return this")();function as(e,t){return e?.[t]}function is(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var cs=Array.prototype,ds=Function.prototype,Dr=Object.prototype,gt=wt["__core-js_shared__"],Ur=function(){var e=/[^.]+$/.exec(gt&&gt.keys&&gt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Mr=ds.toString,At=Dr.hasOwnProperty,$r=Dr.toString,us=RegExp("^"+Mr.call(At).replace(ts,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ir=wt.Symbol,ps=cs.splice,hs=qr(wt,"Map"),ve=qr(Object,"create"),Wr=Ir?Ir.prototype:void 0,Jr=Wr?Wr.toString:void 0;function re(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function fs(){this.__data__=ve?ve(null):{}}function ls(e){return this.has(e)&&delete this.__data__[e]}function ms(e){var t=this.__data__;if(ve){var r=t[e];return r===kr?void 0:r}return At.call(t,e)?t[e]:void 0}function ys(e){var t=this.__data__;return ve?t[e]!==void 0:At.call(t,e)}function gs(e,t){var r=this.__data__;return r[e]=ve&&t===void 0?kr:t,this}re.prototype.clear=fs;re.prototype.delete=ls;re.prototype.get=ms;re.prototype.has=ys;re.prototype.set=gs;function pe(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ws(){this.__data__=[]}function As(e){var t=this.__data__,r=qe(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():ps.call(t,r,1),!0}function Ss(e){var t=this.__data__,r=qe(t,e);return r<0?void 0:t[r][1]}function Es(e){return qe(this.__data__,e)>-1}function bs(e,t){var r=this.__data__,n=qe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}pe.prototype.clear=ws;pe.prototype.delete=As;pe.prototype.get=Ss;pe.prototype.has=Es;pe.prototype.set=bs;function ne(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Cs(){this.__data__={hash:new re,map:new(hs||pe),string:new re}}function _s(e){return Le(this,e).delete(e)}function vs(e){return Le(this,e).get(e)}function Ps(e){return Le(this,e).has(e)}function Hs(e,t){return Le(this,e).set(e,t),this}ne.prototype.clear=Cs;ne.prototype.delete=_s;ne.prototype.get=vs;ne.prototype.has=Ps;ne.prototype.set=Hs;function qe(e,t){for(var r=e.length;r--;)if(Ns(e[r][0],t))return r;return-1}function Ts(e,t){t=xs(t,e)?[t]:Rs(t);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Js(t[r++])];return r&&r==n?e:void 0}function Ks(e){if(!Fr(e)||Is(e))return!1;var t=Ds(e)||is(e)?us:ns;return t.test(ks(e))}function Os(e){if(typeof e=="string")return e;if(Et(e))return Jr?Jr.call(e):"";var t=e+"";return t=="0"&&1/e==-Nr?"-0":t}function Rs(e){return Lr(e)?e:Ws(e)}function Le(e,t){var r=e.__data__;return Us(t)?r[typeof t=="string"?"string":"hash"]:r.map}function qr(e,t){var r=as(e,t);return Ks(r)?r:void 0}function xs(e,t){if(Lr(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Et(e)?!0:Zo.test(e)||!Yo.test(e)||t!=null&&e in Object(t)}function Us(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Is(e){return!!Ur&&Ur in e}var Ws=St(function(e){e=$s(e);var t=[];return Qo.test(e)&&t.push(""),e.replace(es,function(r,n,o,s){t.push(o?s.replace(rs,"$1"):n||r)}),t});function Js(e){if(typeof e=="string"||Et(e))return e;var t=e+"";return t=="0"&&1/e==-Nr?"-0":t}function ks(e){if(e!=null){try{return Mr.call(e)}catch{}try{return e+""}catch{}}return""}function St(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Vo);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],s=r.cache;if(s.has(o))return s.get(o);var a=e.apply(this,n);return r.cache=s.set(o,a),a};return r.cache=new(St.Cache||ne),r}St.Cache=ne;function Ns(e,t){return e===t||e!==e&&t!==t}var Lr=Array.isArray;function Ds(e){var t=Fr(e)?$r.call(e):"";return t==zo||t==Xo}function Fr(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Ms(e){return!!e&&typeof e=="object"}function Et(e){return typeof e=="symbol"||Ms(e)&&$r.call(e)==jo}function $s(e){return e==null?"":Os(e)}function qs(e,t,r){var n=e==null?void 0:Ts(e,t);return n===void 0?r:n}Gr.exports=qs});var Ge=_((Fe,Qr)=>{(function(e,t){typeof Fe=="object"&&typeof Qr<"u"?t(Fe):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.aws4fetch={}))})(Fe,function(e){"use strict";let t=new TextEncoder,r={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},n=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];class o{constructor({accessKeyId:h,secretAccessKey:l,sessionToken:m,service:w,region:y,cache:g,retries:T,initRetryMs:N}){if(h==null)throw new TypeError("accessKeyId is a required option");if(l==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=h,this.secretAccessKey=l,this.sessionToken=m,this.service=w,this.region=y,this.cache=g||new Map,this.retries=T??10,this.initRetryMs=N||50}async sign(h,l){if(h instanceof Request){let{method:y,url:g,headers:T,body:N}=h;l=Object.assign({method:y,url:g,headers:T},l),l.body==null&&T.has("Content-Type")&&(l.body=N!=null&&T.has("X-Amz-Content-Sha256")?N:await h.clone().arrayBuffer()),h=g}let m=new s(Object.assign({url:h},l,this,l&&l.aws)),w=Object.assign({},l,await m.sign());return delete w.aws,new Request(w.url.toString(),w)}async fetch(h,l){for(let m=0;m<=this.retries;m++){let w=fetch(await this.sign(h,l));if(m===this.retries)return w;let y=await w;if(y.status<500&&y.status!==429)return y;await new Promise(g=>setTimeout(g,Math.random()*this.initRetryMs*Math.pow(2,m)))}throw new Error("An unknown error occurred, ensure retries is not negative")}}class s{constructor({method:h,url:l,headers:m,body:w,accessKeyId:y,secretAccessKey:g,sessionToken:T,service:N,region:U,cache:ee,datetime:Se,signQuery:ut,appendSessionToken:pt,allHeaders:De,singleEncode:ht}){if(l==null)throw new TypeError("url is a required option");if(y==null)throw new TypeError("accessKeyId is a required option");if(g==null)throw new TypeError("secretAccessKey is a required option");this.method=h||(w?"POST":"GET"),this.url=new URL(l),this.headers=new Headers(m||{}),this.body=w,this.accessKeyId=y,this.secretAccessKey=g,this.sessionToken=T;let V,Ee;(!N||!U)&&([V,Ee]=p(this.url,this.headers)),this.service=N||V||"",this.region=U||Ee||"us-east-1",this.cache=ee||new Map,this.datetime=Se||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=ut,this.appendSessionToken=pt||this.service==="iotdevicegateway",this.headers.delete("Host");let q=this.signQuery?this.url.searchParams:this.headers;if(this.service==="s3"&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD"),q.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&q.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(C=>De||!n.includes(C)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(C=>C+":"+(C==="host"?this.url.host:(this.headers.get(C)||"").replace(/\s+/g," "))).join(`
2
- `),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!q.has("X-Amz-Expires")&&q.set("X-Amz-Expires","86400"),q.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),q.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),q.set("X-Amz-SignedHeaders",this.signedHeaders)),this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch{this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");ht||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=u(this.encodedPath);let Me=new Set;this.encodedSearch=[...this.url.searchParams].filter(([C])=>{if(!C)return!1;if(this.service==="s3"){if(Me.has(C))return!1;Me.add(C)}return!0}).map(C=>C.map(be=>u(encodeURIComponent(be)))).sort(([C,be],[Ce,$e])=>C<Ce?-1:C>Ce?1:be<$e?-1:be>$e?1:0).map(C=>C.join("=")).join("&")}async sign(){return this.signQuery?(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken&&this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)):this.headers.set("Authorization",await this.authHeader()),{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let h=this.datetime.slice(0,8),l=[this.secretAccessKey,h,this.region,this.service].join(),m=this.cache.get(l);if(!m){let w=await a("AWS4"+this.secretAccessKey,h),y=await a(w,this.region),g=await a(y,this.service);m=await a(g,"aws4_request"),this.cache.set(l,m)}return c(await a(m,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,c(await i(await this.canonicalString()))].join(`
1
+ "use strict";var Ro=Object.create;var Er=Object.defineProperty;var xo=Object.getOwnPropertyDescriptor;var Uo=Object.getOwnPropertyNames;var Io=Object.getPrototypeOf,Wo=Object.prototype.hasOwnProperty;var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Jo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Uo(t))!Wo.call(e,o)&&o!==r&&Er(e,o,{get:()=>t[o],enumerable:!(n=xo(t,o))||n.enumerable});return e};var v=(e,t,r)=>(r=e!=null?Ro(Io(e)):{},Jo(t||!e||!e.__esModule?Er(r,"default",{value:e,enumerable:!0}):r,e));var yt=_((cd,Cr)=>{function ko({host:e=".*",path:t=".*",excludePath:r=null,method:n=[".*"],handler:o,protocol:s=".*",handlerName:a,headers:i={},data:c}){let d=[],p=[],u=e.replace(/(:([^.]+))/g,(H,K,O)=>(d.push(O),"([^.]+)")),l=t.replace(/(:([^/]+))/g,(H,K,O)=>O.slice(-1)==="*"?(p.push(O.slice(0,O.length-1)),"(.*)"):(p.push(O),"([^/]*)")),f=new RegExp(`^${u}$`,"i"),m=new RegExp(`^${l}$`,"i"),w=r?new RegExp(`^${r}$`,"i"):null,y=new RegExp(`^${n.join("|")}$`,"i"),g=new RegExp(`^${s}$`,"i");return{hostVariables:d,pathVariables:p,host:f,path:m,excludePath:w,method:y,protocol:g,handler:o,handlerName:a,headers:i,data:c}}function br(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}async function No(e,t=1024*1024){let r=[],n=e.getReader(),o=new TextDecoder,s=0;for(;t&&s<t;){let{done:i,value:c}=await n.read();if(i)break;s+=c.byteLength,r.push(o.decode(c))}let a=r.join("");return t?a.substring(0,t):a}function Do(e){let t=new URL(e.url),r=br(t.searchParams),n=br(e.headers);n.host&&(t.hostname=n.host);let o,s;async function a(i){if(s>=i)return o.substring(0,i);let c=e.clone();return o=await No(c.body,i),o}return{body:e.body,headers:n,host:t.host,hostname:t.hostname,href:t.href,json:async i=>JSON.parse(a(i)),method:e.method,origin:`${t.protocol}//${t.host}`,path:t.pathname,protocol:t.protocol.slice(0,-1),query:r,querystring:t.search.slice(1),search:t.search,text:async i=>e.headers.get("content-type")==="application/x-www-form-urlencoded"?decodeURIComponent(await a(i)):a(i)}}Cr.exports={parseRoute:ko,parseRequest:Do}});var vr=_((dd,_r)=>{function Mo(e,t){let r={},n=t.host.exec(e.host);t.hostVariables.forEach((s,a)=>{r[s]=n[a+1]});let o=t.path.exec(e.path);return t.pathVariables.forEach((s,a)=>{r[s]=o[a+1]}),r}function $o(e,t){let r=!0;return Object.keys(e.headers).forEach(n=>{t.headers[n]!==e.headers[n]&&(r=!1)}),r}function qo(e,t){return e.protocol.test(t.protocol)}function Lo(e,t){return e.method.test(t.method)&&e.host.test(t.host)&&e.path.test(t.path)&&$o(e,t)&&qo(e,t)&&(!e.excludePath||!e.excludePath.test(t.path))}async function gt(e,t){let[r,...n]=t;if(!r)return new Response("NOT_FOUND",{status:404});if(!Lo(r,e.request))return gt(e,n);e.state.handlers=e.state.handlers||[],e.state.handlers.push(r.handlerName||r.handler.name),e.params=Mo(e.request,r);try{return r.handler(e,async o=>gt(o,n))}catch(o){throw o.route=r.handler.name,o}}_r.exports={recurseRoutes:gt}});var Hr=_((ud,Pr)=>{Pr.exports={methods:{DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST"},statusMessages:{404:"Not found",429:"Rate limited"}}});var Or=_((pd,Kr)=>{var Fo=yt();Kr.exports=class Tr{constructor(t){this.request=Fo.parseRequest(t.request),this.event=t,this.state={},this.cloned=!1,this.response={headers:{}},this.body="",this.status=404,this.query=this.request.query}header(t){return this.request.headers[t]}set(t,r){this.response.headers[t]=r}clone(){let t=new Tr(this.event);return t.cloned=!0,t}}});var xr=_((fd,Rr)=>{var ue=yt(),Go=vr(),_e=Hr(),Bo=Or();Rr.exports=class{constructor(){this.routes=[]}get(t,r){let n=ue.parseRoute({method:[_e.methods.GET,_e.methods.HEAD],path:t,handler:r});this.routes.push(n)}post(t,r){let n=ue.parseRoute({method:[_e.methods.POST],path:t,handler:r});this.routes.push(n)}patch(t,r){let n=ue.parseRoute({method:[_e.methods.PATCH],path:t,handler:r});this.routes.push(n)}del(t,r){let n=ue.parseRoute({method:[_e.methods.DELETE],path:t,handler:r});this.routes.push(n)}use(t){let r=ue.parseRoute({handler:t,middleware:!0});this.routes.push(r)}add({host:t,path:r,excludePath:n,method:o,handlerName:s,headers:a,protocol:i},c){let d=ue.parseRoute({method:o,host:t,path:r,excludePath:n,handler:c,headers:a,handlerName:s,protocol:i});this.routes.push(d)}async resolve(t){let r=new Bo(t);try{return await Go.recurseRoutes(r,this.routes),new Response(r.body,{status:r.status,headers:r.response.headers})}catch(n){return new Response(n.message,{status:500})}}}});var M=_((ld,Gr)=>{var Vo="Expected a function",kr="__lodash_hash_undefined__",Nr=1/0,Xo="[object Function]",zo="[object GeneratorFunction]",jo="[object Symbol]",Yo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zo=/^\w*$/,Qo=/^\./,es=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ts=/[\\^$.*+?()[\]{}|]/g,rs=/\\(\\)?/g,ns=/^\[object .+?Constructor\]$/,os=typeof global=="object"&&global&&global.Object===Object&&global,ss=typeof self=="object"&&self&&self.Object===Object&&self,At=os||ss||Function("return this")();function as(e,t){return e?.[t]}function is(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var cs=Array.prototype,ds=Function.prototype,Dr=Object.prototype,wt=At["__core-js_shared__"],Ur=function(){var e=/[^.]+$/.exec(wt&&wt.keys&&wt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Mr=ds.toString,St=Dr.hasOwnProperty,$r=Dr.toString,us=RegExp("^"+Mr.call(St).replace(ts,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ir=At.Symbol,ps=cs.splice,hs=qr(At,"Map"),ve=qr(Object,"create"),Wr=Ir?Ir.prototype:void 0,Jr=Wr?Wr.toString:void 0;function re(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function fs(){this.__data__=ve?ve(null):{}}function ls(e){return this.has(e)&&delete this.__data__[e]}function ms(e){var t=this.__data__;if(ve){var r=t[e];return r===kr?void 0:r}return St.call(t,e)?t[e]:void 0}function ys(e){var t=this.__data__;return ve?t[e]!==void 0:St.call(t,e)}function gs(e,t){var r=this.__data__;return r[e]=ve&&t===void 0?kr:t,this}re.prototype.clear=fs;re.prototype.delete=ls;re.prototype.get=ms;re.prototype.has=ys;re.prototype.set=gs;function pe(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ws(){this.__data__=[]}function As(e){var t=this.__data__,r=qe(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():ps.call(t,r,1),!0}function Ss(e){var t=this.__data__,r=qe(t,e);return r<0?void 0:t[r][1]}function Es(e){return qe(this.__data__,e)>-1}function bs(e,t){var r=this.__data__,n=qe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}pe.prototype.clear=ws;pe.prototype.delete=As;pe.prototype.get=Ss;pe.prototype.has=Es;pe.prototype.set=bs;function ne(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Cs(){this.__data__={hash:new re,map:new(hs||pe),string:new re}}function _s(e){return Le(this,e).delete(e)}function vs(e){return Le(this,e).get(e)}function Ps(e){return Le(this,e).has(e)}function Hs(e,t){return Le(this,e).set(e,t),this}ne.prototype.clear=Cs;ne.prototype.delete=_s;ne.prototype.get=vs;ne.prototype.has=Ps;ne.prototype.set=Hs;function qe(e,t){for(var r=e.length;r--;)if(Ns(e[r][0],t))return r;return-1}function Ts(e,t){t=xs(t,e)?[t]:Rs(t);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Js(t[r++])];return r&&r==n?e:void 0}function Ks(e){if(!Fr(e)||Is(e))return!1;var t=Ds(e)||is(e)?us:ns;return t.test(ks(e))}function Os(e){if(typeof e=="string")return e;if(bt(e))return Jr?Jr.call(e):"";var t=e+"";return t=="0"&&1/e==-Nr?"-0":t}function Rs(e){return Lr(e)?e:Ws(e)}function Le(e,t){var r=e.__data__;return Us(t)?r[typeof t=="string"?"string":"hash"]:r.map}function qr(e,t){var r=as(e,t);return Ks(r)?r:void 0}function xs(e,t){if(Lr(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||bt(e)?!0:Zo.test(e)||!Yo.test(e)||t!=null&&e in Object(t)}function Us(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Is(e){return!!Ur&&Ur in e}var Ws=Et(function(e){e=$s(e);var t=[];return Qo.test(e)&&t.push(""),e.replace(es,function(r,n,o,s){t.push(o?s.replace(rs,"$1"):n||r)}),t});function Js(e){if(typeof e=="string"||bt(e))return e;var t=e+"";return t=="0"&&1/e==-Nr?"-0":t}function ks(e){if(e!=null){try{return Mr.call(e)}catch{}try{return e+""}catch{}}return""}function Et(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Vo);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],s=r.cache;if(s.has(o))return s.get(o);var a=e.apply(this,n);return r.cache=s.set(o,a),a};return r.cache=new(Et.Cache||ne),r}Et.Cache=ne;function Ns(e,t){return e===t||e!==e&&t!==t}var Lr=Array.isArray;function Ds(e){var t=Fr(e)?$r.call(e):"";return t==Xo||t==zo}function Fr(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Ms(e){return!!e&&typeof e=="object"}function bt(e){return typeof e=="symbol"||Ms(e)&&$r.call(e)==jo}function $s(e){return e==null?"":Os(e)}function qs(e,t,r){var n=e==null?void 0:Ts(e,t);return n===void 0?r:n}Gr.exports=qs});var Ge=_((Fe,Qr)=>{(function(e,t){typeof Fe=="object"&&typeof Qr<"u"?t(Fe):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.aws4fetch={}))})(Fe,function(e){"use strict";let t=new TextEncoder,r={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},n=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];class o{constructor({accessKeyId:l,secretAccessKey:f,sessionToken:m,service:w,region:y,cache:g,retries:H,initRetryMs:K}){if(l==null)throw new TypeError("accessKeyId is a required option");if(f==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=l,this.secretAccessKey=f,this.sessionToken=m,this.service=w,this.region=y,this.cache=g||new Map,this.retries=H??10,this.initRetryMs=K||50}async sign(l,f){if(l instanceof Request){let{method:y,url:g,headers:H,body:K}=l;f=Object.assign({method:y,url:g,headers:H},f),f.body==null&&H.has("Content-Type")&&(f.body=K!=null&&H.has("X-Amz-Content-Sha256")?K:await l.clone().arrayBuffer()),l=g}let m=new s(Object.assign({url:l},f,this,f&&f.aws)),w=Object.assign({},f,await m.sign());return delete w.aws,new Request(w.url.toString(),w)}async fetch(l,f){for(let m=0;m<=this.retries;m++){let w=fetch(await this.sign(l,f));if(m===this.retries)return w;let y=await w;if(y.status<500&&y.status!==429)return y;await new Promise(g=>setTimeout(g,Math.random()*this.initRetryMs*Math.pow(2,m)))}throw new Error("An unknown error occurred, ensure retries is not negative")}}class s{constructor({method:l,url:f,headers:m,body:w,accessKeyId:y,secretAccessKey:g,sessionToken:H,service:K,region:O,cache:ee,datetime:Se,signQuery:pt,appendSessionToken:ht,allHeaders:De,singleEncode:ft}){if(f==null)throw new TypeError("url is a required option");if(y==null)throw new TypeError("accessKeyId is a required option");if(g==null)throw new TypeError("secretAccessKey is a required option");this.method=l||(w?"POST":"GET"),this.url=new URL(f),this.headers=new Headers(m||{}),this.body=w,this.accessKeyId=y,this.secretAccessKey=g,this.sessionToken=H;let V,Ee;(!K||!O)&&([V,Ee]=p(this.url,this.headers)),this.service=K||V||"",this.region=O||Ee||"us-east-1",this.cache=ee||new Map,this.datetime=Se||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=pt,this.appendSessionToken=ht||this.service==="iotdevicegateway",this.headers.delete("Host");let q=this.signQuery?this.url.searchParams:this.headers;if(this.service==="s3"&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD"),q.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&q.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(C=>De||!n.includes(C)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(C=>C+":"+(C==="host"?this.url.host:(this.headers.get(C)||"").replace(/\s+/g," "))).join(`
2
+ `),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!q.has("X-Amz-Expires")&&q.set("X-Amz-Expires","86400"),q.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),q.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),q.set("X-Amz-SignedHeaders",this.signedHeaders)),this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch{this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");ft||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=d(this.encodedPath);let Me=new Set;this.encodedSearch=[...this.url.searchParams].filter(([C])=>{if(!C)return!1;if(this.service==="s3"){if(Me.has(C))return!1;Me.add(C)}return!0}).map(C=>C.map(be=>d(encodeURIComponent(be)))).sort(([C,be],[Ce,$e])=>C<Ce?-1:C>Ce?1:be<$e?-1:be>$e?1:0).map(C=>C.join("=")).join("&")}async sign(){return this.signQuery?(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken&&this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)):this.headers.set("Authorization",await this.authHeader()),{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let l=this.datetime.slice(0,8),f=[this.secretAccessKey,l,this.region,this.service].join(),m=this.cache.get(f);if(!m){let w=await a("AWS4"+this.secretAccessKey,l),y=await a(w,this.region),g=await a(y,this.service);m=await a(g,"aws4_request"),this.cache.set(f,m)}return c(await a(m,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,c(await i(await this.canonicalString()))].join(`
3
3
  `)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
4
4
  `,this.signedHeaders,await this.hexBodyHash()].join(`
5
- `)}async hexBodyHash(){let h=this.headers.get("X-Amz-Content-Sha256");if(h==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");h=c(await i(this.body||""))}return h}}async function a(d,h){let l=await crypto.subtle.importKey("raw",typeof d=="string"?t.encode(d):d,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",l,t.encode(h))}async function i(d){return crypto.subtle.digest("SHA-256",typeof d=="string"?t.encode(d):d)}function c(d){return Array.prototype.map.call(new Uint8Array(d),h=>("0"+h.toString(16)).slice(-2)).join("")}function u(d){return d.replace(/[!'()*]/g,h=>"%"+h.charCodeAt(0).toString(16).toUpperCase())}function p(d,h){let{hostname:l,pathname:m}=d,w=l.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[y,g]=(w||["",""]).slice(1,3);if(g==="us-gov")g="us-gov-west-1";else if(g==="s3"||g==="s3-accelerate")g="us-east-1",y="s3";else if(y==="iot")l.startsWith("iot.")?y="execute-api":l.startsWith("data.jobs.iot.")?y="iot-jobs-data":y=m==="/mqtt"?"iotdevicegateway":"iotdata";else if(y==="autoscaling"){let T=(h.get("X-Amz-Target")||"").split(".")[0];T==="AnyScaleFrontendService"?y="application-autoscaling":T==="AnyScaleScalingPlannerFrontendService"&&(y="autoscaling-plans")}else g==null&&y.startsWith("s3-")?(g=y.slice(3).replace(/^fips-|^external-1/,""),y="s3"):y.endsWith("-fips")?y=y.slice(0,-5):g&&/-\d$/.test(y)&&!/-\d$/.test(g)&&([y,g]=[g,y]);return[r[y]||y,g]}e.AwsClient=o,e.AwsV4Signer=s,Object.defineProperty(e,"__esModule",{value:!0})})});var je=_((Nd,ln)=>{var ua="Expected a function",sn="__lodash_hash_undefined__",an=1/0,pa=9007199254740991,ha="[object Function]",fa="[object GeneratorFunction]",la="[object Symbol]",ma=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ya=/^\w*$/,ga=/^\./,wa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Aa=/[\\^$.*+?()[\]{}|]/g,Sa=/\\(\\)?/g,Ea=/^\[object .+?Constructor\]$/,ba=/^(?:0|[1-9]\d*)$/,Ca=typeof global=="object"&&global&&global.Object===Object&&global,_a=typeof self=="object"&&self&&self.Object===Object&&self,Jt=Ca||_a||Function("return this")();function va(e,t){return e?.[t]}function Pa(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Ha=Array.prototype,Ta=Function.prototype,cn=Object.prototype,Wt=Jt["__core-js_shared__"],tn=function(){var e=/[^.]+$/.exec(Wt&&Wt.keys&&Wt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),dn=Ta.toString,Ve=cn.hasOwnProperty,un=cn.toString,Ka=RegExp("^"+dn.call(Ve).replace(Aa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rn=Jt.Symbol,Oa=Ha.splice,Ra=pn(Jt,"Map"),Pe=pn(Object,"create"),nn=rn?rn.prototype:void 0,on=nn?nn.toString:void 0;function se(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function xa(){this.__data__=Pe?Pe(null):{}}function Ua(e){return this.has(e)&&delete this.__data__[e]}function Ia(e){var t=this.__data__;if(Pe){var r=t[e];return r===sn?void 0:r}return Ve.call(t,e)?t[e]:void 0}function Wa(e){var t=this.__data__;return Pe?t[e]!==void 0:Ve.call(t,e)}function Ja(e,t){var r=this.__data__;return r[e]=Pe&&t===void 0?sn:t,this}se.prototype.clear=xa;se.prototype.delete=Ua;se.prototype.get=Ia;se.prototype.has=Wa;se.prototype.set=Ja;function he(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ka(){this.__data__=[]}function Na(e){var t=this.__data__,r=ze(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Oa.call(t,r,1),!0}function Da(e){var t=this.__data__,r=ze(t,e);return r<0?void 0:t[r][1]}function Ma(e){return ze(this.__data__,e)>-1}function $a(e,t){var r=this.__data__,n=ze(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}he.prototype.clear=ka;he.prototype.delete=Na;he.prototype.get=Da;he.prototype.has=Ma;he.prototype.set=$a;function ae(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function qa(){this.__data__={hash:new se,map:new(Ra||he),string:new se}}function La(e){return Xe(this,e).delete(e)}function Fa(e){return Xe(this,e).get(e)}function Ga(e){return Xe(this,e).has(e)}function Ba(e,t){return Xe(this,e).set(e,t),this}ae.prototype.clear=qa;ae.prototype.delete=La;ae.prototype.get=Fa;ae.prototype.has=Ga;ae.prototype.set=Ba;function Va(e,t,r){var n=e[t];(!(Ve.call(e,t)&&hn(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function ze(e,t){for(var r=e.length;r--;)if(hn(e[r][0],t))return r;return-1}function za(e){if(!Be(e)||ti(e))return!1;var t=si(e)||Pa(e)?Ka:Ea;return t.test(oi(e))}function Xa(e,t,r,n){if(!Be(e))return e;t=Qa(t,e)?[t]:Ya(t);for(var o=-1,s=t.length,a=s-1,i=e;i!=null&&++o<s;){var c=ni(t[o]),u=r;if(o!=a){var p=i[c];u=n?n(p,c,i):void 0,u===void 0&&(u=Be(p)?p:Za(t[o+1])?[]:{})}Va(i,c,u),i=i[c]}return e}function ja(e){if(typeof e=="string")return e;if(Nt(e))return on?on.call(e):"";var t=e+"";return t=="0"&&1/e==-an?"-0":t}function Ya(e){return fn(e)?e:ri(e)}function Xe(e,t){var r=e.__data__;return ei(t)?r[typeof t=="string"?"string":"hash"]:r.map}function pn(e,t){var r=va(e,t);return za(r)?r:void 0}function Za(e,t){return t=t??pa,!!t&&(typeof e=="number"||ba.test(e))&&e>-1&&e%1==0&&e<t}function Qa(e,t){if(fn(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Nt(e)?!0:ya.test(e)||!ma.test(e)||t!=null&&e in Object(t)}function ei(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ti(e){return!!tn&&tn in e}var ri=kt(function(e){e=ii(e);var t=[];return ga.test(e)&&t.push(""),e.replace(wa,function(r,n,o,s){t.push(o?s.replace(Sa,"$1"):n||r)}),t});function ni(e){if(typeof e=="string"||Nt(e))return e;var t=e+"";return t=="0"&&1/e==-an?"-0":t}function oi(e){if(e!=null){try{return dn.call(e)}catch{}try{return e+""}catch{}}return""}function kt(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(ua);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],s=r.cache;if(s.has(o))return s.get(o);var a=e.apply(this,n);return r.cache=s.set(o,a),a};return r.cache=new(kt.Cache||ae),r}kt.Cache=ae;function hn(e,t){return e===t||e!==e&&t!==t}var fn=Array.isArray;function si(e){var t=Be(e)?un.call(e):"";return t==ha||t==fa}function Be(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function ai(e){return!!e&&typeof e=="object"}function Nt(e){return typeof e=="symbol"||ai(e)&&un.call(e)==la}function ii(e){return e==null?"":ja(e)}function ci(e,t,r){return e==null?e:Xa(e,t,r)}ln.exports=ci});var En=_(qt=>{"use strict";qt.parse=yi;qt.serialize=gi;var fi=decodeURIComponent,li=encodeURIComponent,mi=/; */,Ze=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function yi(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},o=e.split(mi),s=n.decode||fi,a=0;a<o.length;a++){var i=o[a],c=i.indexOf("=");if(!(c<0)){var u=i.substr(0,c).trim(),p=i.substr(++c,i.length).trim();p[0]=='"'&&(p=p.slice(1,-1)),r[u]==null&&(r[u]=wi(p,s))}}return r}function gi(e,t,r){var n=r||{},o=n.encode||li;if(typeof o!="function")throw new TypeError("option encode is invalid");if(!Ze.test(e))throw new TypeError("argument name is invalid");var s=o(t);if(s&&!Ze.test(s))throw new TypeError("argument val is invalid");var a=e+"="+s;if(n.maxAge!=null){var i=n.maxAge-0;if(isNaN(i)||!isFinite(i))throw new TypeError("option maxAge is invalid");a+="; Max-Age="+Math.floor(i)}if(n.domain){if(!Ze.test(n.domain))throw new TypeError("option domain is invalid");a+="; Domain="+n.domain}if(n.path){if(!Ze.test(n.path))throw new TypeError("option path is invalid");a+="; Path="+n.path}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(a+="; HttpOnly"),n.secure&&(a+="; Secure"),n.sameSite){var c=typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite;switch(c){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a}function wi(e,t){try{return t(e)}catch{return e}}});var Cn=_((ru,bn)=>{"use strict";var Qe=1;function Ai(){return Qe=(Qe*9301+49297)%233280,Qe/233280}function Si(e){Qe=e}bn.exports={nextValue:Ai,seed:Si}});var Oe=_((nu,Hn)=>{"use strict";var Lt=Cn(),ce="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",z,_n,Ke;function Ft(){Ke=!1}function vn(e){if(!e){z!==ce&&(z=ce,Ft());return}if(e!==z){if(e.length!==ce.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter(function(r,n,o){return n!==o.lastIndexOf(r)});if(t.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. These characters were not unique: "+t.join(", "));z=e,Ft()}}function Ei(e){return vn(e),z}function bi(e){Lt.seed(e),_n!==e&&(Ft(),_n=e)}function Ci(){z||vn(ce);for(var e=z.split(""),t=[],r=Lt.nextValue(),n;e.length>0;)r=Lt.nextValue(),n=Math.floor(r*e.length),t.push(e.splice(n,1)[0]);return t.join("")}function Pn(){return Ke||(Ke=Ci(),Ke)}function _i(e){var t=Pn();return t[e]}function vi(){return z||ce}Hn.exports={get:vi,characters:Ei,seed:bi,lookup:_i,shuffled:Pn}});var Kn=_((ou,Tn)=>{"use strict";var Gt=typeof window=="object"&&(window.crypto||window.msCrypto),Bt;!Gt||!Gt.getRandomValues?Bt=function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(Math.random()*256));return t}:Bt=function(e){return Gt.getRandomValues(new Uint8Array(e))};Tn.exports=Bt});var Rn=_((su,On)=>{On.exports=function(e,t,r){for(var n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length),s="";;)for(var a=e(o),i=o;i--;)if(s+=t[a[i]&n]||"",s.length===+r)return s}});var Un=_((au,xn)=>{"use strict";var Pi=Oe(),Hi=Kn(),Ti=Rn();function Ki(e){for(var t=0,r,n="";!r;)n=n+Ti(Hi,Pi.get(),1),r=e<Math.pow(16,t+1),t++;return n}xn.exports=Ki});var Jn=_((cu,Wn)=>{"use strict";var et=Un(),iu=Oe(),Oi=1567752802062,Ri=7,tt,In;function xi(e){var t="",r=Math.floor((Date.now()-Oi)*.001);return r===In?tt++:(tt=0,In=r),t=t+et(Ri),t=t+et(e),tt>0&&(t=t+et(tt)),t=t+et(r),t}Wn.exports=xi});var Nn=_((du,kn)=>{"use strict";var Ui=Oe();function Ii(e){if(!e||typeof e!="string"||e.length<6)return!1;var t=new RegExp("[^"+Ui.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!t.test(e)}kn.exports=Ii});var Mn=_((uu,Dn)=>{"use strict";Dn.exports=0});var Ln=_((pu,G)=>{"use strict";var Vt=Oe(),Wi=Jn(),Ji=Nn(),$n=Mn()||0;function ki(e){return Vt.seed(e),G.exports}function Ni(e){return $n=e,G.exports}function Di(e){return e!==void 0&&Vt.characters(e),Vt.shuffled()}function qn(){return Wi($n)}G.exports=qn;G.exports.generate=qn;G.exports.seed=ki;G.exports.worker=Ni;G.exports.characters=Di;G.exports.isValid=Ji});var Gn=_((hu,Fn)=>{"use strict";Fn.exports=Ln()});var vo=v(xr());var Br=v(M()),Ls={get:Br.default};function bt(e){e.status=401,e.body="Unauthorized",e.set("WWW-Authenticate","Basic")}function Ct(e){return async(t,r)=>{if(t.request.path===e.logoutPath)return bt(t);let n=Ls.get(t,"request.headers.authorization");if(!n||!n.startsWith("Basic "))return bt(t);let o=e.users.map(i=>i.authToken),s=n.substring(6),a=o.indexOf(s);return a===-1?bt(t):(t.state.user=e.users[a].username,r(t))}}var Vr=caches.default;async function Fs(e){return await Vr.match(e)}async function Gs(e,t){return Vr.put(e.href,t)}var _t={get:Fs,set:Gs};async function Bs(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}var zr=Bs;function Vs(e,t={}){return Object.keys(t).reduce((r,n)=>r.replace(`{${n}}`,t[n]),e)}function vt(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}function zs(e,t){Object.entries(e).forEach(([r,n])=>{t.header(r)||t.set(r,n)})}var Pt=e=>{e.set=(t,r)=>{e.response.headers[t.toLowerCase()]=r},e.header=t=>e.request.headers[t.toLowerCase()]},A={resolveParams:Vs,instanceToJson:vt,mergeHeaders:zs,upgradeCTX:Pt};var Xs=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function js(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}async function Ys(e,t){if(!t)return e.event.request;let r=t.match(/{.*?}/gi).map(s=>s.slice(1,-1)),n={};for(let s=0;s<r.length;s+=1){let a=r[s],i=a.split(":");switch(i[0]){case"method":n[a]=e.request.method;break;case"path":n[a]=e.request.path;break;case"bodyHash":n[a]=await zr(await js(e.request));break;case"header":n[a]=e.request.headers[i[1]]||"";break;default:n[a]=a}}let o=encodeURIComponent(t.replace(/({(.*?)})/gi,(s,a,i)=>n[i]));return new Request(`http://${e.request.hostname}/${o}`)}function Ht({cacheDuration:e,cacheKeyTemplate:t,headerBlacklist:r=Xs}){return async(n,o)=>{let s=await Ys(n,t),a=await _t.get(s);if(a){n.body=a.body,n.status=a.status;let i=vt(a.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])}),n.set("X-Cache-Hit",!0)}else{await o(n);let i;n.body.tee?[n.body,i]=n.body.tee():i=n.body;let c=new Response(i,{status:n.status});Object.keys(n.response.headers).forEach(u=>{r.indexOf(u.toLowerCase())===-1&&c.headers.set(u,n.response.headers[u])}),e&&(c.headers.delete("Cache-Control"),c.headers.set("Cache-Control",`max-age=${e}`)),n.event.waitUntil(_t.set(s,c))}}}function Tt({allowedOrigins:e=["*"],allowedMethods:t=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:n=["Content-Type"],allowedExposeHeaders:o=[],maxAge:s=600,optionsSuccessStatus:a=204,terminatePreflight:i=!1}){return async(c,u)=>{let{method:p}=c.request,{origin:d}=c.request.headers,h=c.request.headers["access-control-request-headers"];if(Zs(c,d,e),Qs(c,r),na(c,o),!t.includes(p.toUpperCase())){c.status=405,c.body={error:`Method ${p} not allowed`};return}if(p==="OPTIONS"&&(ea(c,t),ta(c,h,n),ra(c,s),i)){c.status=a,c.set("content-length","0"),c.body="";return}await u(c)}}function Zs(e,t,r){if(Array.isArray(r)){if(r[0]==="origin"){e.set("Access-Control-Allow-Origin",t),Xr(e,"Origin");return}r[0]==="*"?e.set("Access-Control-Allow-Origin","*"):r.indexOf(t)!==-1&&(e.set("Access-Control-Allow-Origin",t),Xr(e,"Origin"))}}function Qs(e,t){t&&e.set("Access-Control-Allow-Credentials",String(t))}function ea(e,t){e.set("Access-Control-Allow-Methods",t.join(","))}function ta(e,t,r){r.length===0&&t?e.set("Access-Control-Allow-Headers",t):r.length&&e.set("Access-Control-Allow-Headers",r.join(","))}function ra(e,t){t&&e.set("Access-Control-Max-Age",String(t))}function na(e,t){t.length&&e.set("Access-Control-Expose-Headers",t.join(","))}function Xr(e,t){let r=e.header("vary")||e.header("Vary");(r?.split(",").map(o=>o.trim().toLowerCase())||[]).includes(t.toLowerCase())||e.set("Vary",r?`${r}, ${t}`:t)}var oa={AF:"AS",AL:"EU",AQ:"AN",DZ:"AF",AS:"OC",AD:"EU",AO:"AF",AG:"NA",AZ:"EU",AR:"SA",AU:"OC",AT:"EU",BS:"NA",BH:"AS",BD:"AS",AM:"EU",BB:"NA",BE:"EU",BM:"NA",BT:"AS",BO:"SA",BA:"EU",BW:"AF",BV:"AN",BR:"SA",BZ:"NA",IO:"AS",SB:"OC",VG:"NA",BN:"AS",BG:"EU",MM:"AS",BI:"AF",BY:"EU",KH:"AS",CM:"AF",CA:"NA",CV:"AF",KY:"NA",CF:"AF",LK:"AS",TD:"AF",CL:"SA",CN:"AS",TW:"AS",CX:"AS",CC:"AS",CO:"SA",KM:"AF",YT:"AF",CG:"AF",CD:"AF",CK:"OC",CR:"NA",HR:"EU",CU:"NA",CY:"EU",CZ:"EU",BJ:"AF",DK:"EU",DM:"NA",DO:"NA",EC:"SA",SV:"NA",GQ:"AF",ET:"AF",ER:"AF",EE:"EU",FO:"EU",FK:"SA",GS:"AN",FJ:"OC",FI:"EU",AX:"EU",FR:"EU",GF:"SA",PF:"OC",TF:"AN",DJ:"AF",GA:"AF",GE:"EU",GM:"AF",PS:"AS",DE:"EU",GH:"AF",GI:"EU",KI:"OC",GR:"EU",GL:"NA",GD:"NA",GP:"NA",GU:"OC",GT:"NA",GN:"AF",GY:"SA",HT:"NA",HM:"AN",VA:"EU",HN:"NA",HK:"AS",HU:"EU",IS:"EU",IN:"AS",ID:"AS",IR:"AS",IQ:"AS",IE:"EU",IL:"AS",IT:"EU",CI:"AF",JM:"NA",JP:"AS",KZ:"EU",JO:"AS",KE:"AF",KP:"AS",KR:"AS",KW:"AS",KG:"AS",LA:"AS",LB:"AS",LS:"AF",LV:"EU",LR:"AF",LY:"AF",LI:"EU",LT:"EU",LU:"EU",MO:"AS",MG:"AF",MW:"AF",MY:"AS",MV:"AS",ML:"AF",MT:"EU",MQ:"NA",MR:"AF",MU:"AF",MX:"NA",MC:"EU",MN:"AS",MD:"EU",ME:"EU",MS:"NA",MA:"AF",MZ:"AF",OM:"AS",NA:"AF",NR:"OC",NP:"AS",NL:"EU",AN:"NA",CW:"NA",AW:"NA",SX:"NA",BQ:"NA",NC:"OC",VU:"OC",NZ:"OC",NI:"NA",NE:"AF",NG:"AF",NU:"OC",NF:"OC",NO:"EU",MP:"OC",UM:"OC",FM:"OC",MH:"OC",PW:"OC",PK:"AS",PA:"NA",PG:"OC",PY:"SA",PE:"SA",PH:"AS",PN:"OC",PL:"EU",PT:"EU",GW:"AF",TL:"AS",PR:"NA",QA:"AS",RE:"AF",RO:"EU",RU:"EU",RW:"AF",BL:"NA",SH:"AF",KN:"NA",AI:"NA",LC:"NA",MF:"NA",PM:"NA",VC:"NA",SM:"EU",ST:"AF",SA:"AS",SN:"AF",RS:"EU",SC:"AF",SL:"AF",SG:"AS",SK:"EU",VN:"AS",SI:"EU",SO:"AF",ZA:"AF",ZW:"AF",ES:"EU",SS:"AF",EH:"AF",SD:"AF",SR:"SA",SJ:"EU",SZ:"AF",SE:"EU",CH:"EU",SY:"AS",TJ:"AS",TH:"AS",TG:"AF",TK:"OC",TO:"OC",TT:"NA",AE:"AS",TN:"AF",TR:"EU",TM:"AS",TC:"NA",TV:"OC",UG:"AF",UA:"EU",MK:"EU",EG:"AF",GB:"EU",GG:"EU",JE:"EU",IM:"EU",TZ:"AF",US:"NA",VI:"NA",BF:"AF",UY:"SA",UZ:"AS",VE:"SA",WF:"OC",WS:"OC",YE:"AS",ZM:"AF",XX:"XX"};function Kt(){return async(e,t)=>{let r=e.request.headers["cf-ipcountry"]||"XX";e.request.headers["proxy-continent"]=oa[r],await t(e)}}function jr(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=atob(t),n=Uint8Array.from(r,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}function sa(e){let t=e.split("."),r=JSON.parse(jr(t[0])),n=JSON.parse(jr(t[1])),o=atob(t[2].replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:n,signature:o,raw:{header:t[0],payload:t[1],signature:t[2]}}}function Ot({jwksUri:e,iss:t,aud:r,allowPublicAccess:n=!1}){async function o(){return(await(await fetch(e)).json()).keys}function s(c){return c.status=403,c.body="Forbidden",c}async function a(c){let p=new TextEncoder().encode([c.raw.header,c.raw.payload].join(".")),d=new Uint8Array(Array.from(c.signature).map(m=>m.charCodeAt(0))),h=await o();return(await Promise.all(h.map(async m=>{let w=await crypto.subtle.importKey("jwk",m,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",w,d,p)}))).some(m=>m)}async function i(c,u){if(c.request.method==="OPTIONS"||n)return u(c);if((c.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let d=sa(c.request.headers.authorization.slice(7)),h=new Date(d.payload.exp*1e3),l=new Date(Date.now());return h<=l||!t||d.payload.iss!==t||!r||d.payload.aud!==r||!await a(d)?s(c):(c.state.user=d.payload,u(c))}return s(c)}return i}var Yr=v(M()),aa={get:Yr.default},oe=class{constructor({accountId:t,namespace:r,authEmail:n,authKey:o,ttl:s}){this.accountId=t,this.namespace=r,this.authEmail=n,this.authKey=o,this.ttl=s}getNamespaceUrl(){return new URL(`https://api.cloudflare.com/client/v4/accounts/${this.accountId}/storage/kv/namespaces/${this.namespace}`)}getUrlForKey(t){return new URL(`${this.getNamespaceUrl()}/values/${t}`)}async list(t,r=10){let n=`${this.getNamespaceUrl()}/keys?prefix=${t}&limit=${r}`,o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});return o.ok?o.json():null}async get(t,r){let n=this.getUrlForKey(t),o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});if(o.ok)switch(r){case"json":return o.json();case"stream":return o;case"arrayBuffer":return o.arrayBuffer();default:return o.text()}return null}async getWithMetadata(t,r){let[n,o]=await Promise.all([this.get(t,r),this.list(t)]),s=aa.get(o,"result.0.metadata",{});return{value:n,metadata:s}}async put(t,r,n={}){let o=this.getUrlForKey(t),s=new URLSearchParams;this.ttl&&s.append("expiration_ttl",this.ttl.toString());let a={"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey};o.search=s.toString();let i=new FormData;return i.append("value",r),i.append("metadata",JSON.stringify(n)),(await fetch(o.toString(),{method:"PUT",headers:a,body:r})).ok}async delete(t){let r=this.getUrlForKey(t);return fetch(r,{method:"DELETE",headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}})}};var O={methodsMethodsWithBody:["POST","PUT","PATCH"],http:{statusMessages:{404:"Not Found"}},mime:{css:"text/css",csv:"text/csv",html:"text/html",ico:"image/microsoft.vnd.icon",jpeg:"image/jpeg",js:"application/javascript",json:"application/json",png:"image/png",svg:"image/svg+xml",xml:"application/xml"}};function ia(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function Rt({kvAccountId:e,kvNamespace:t,kvAuthEmail:r,kvAuthKey:n,kvBasePath:o="",kvKey:s="{file}",defaultExtension:a="html",defaultIndexDocument:i,defaultErrorDocument:c,mime:u={},mode:p="rest"}){let d=new oe({accountId:e,namespace:t,authEmail:r,authKey:n,mode:p}),h={...O.mime,...u};return async l=>{let m=A.resolveParams(s,l.params),w=m===""&&i?i:ia(m,a),y=await d.get(o+w);!y&&c&&(y=await d.get(o+c)),y?(l.status=200,l.body=y,l.set("Content-Type",h[w.split(".").pop()]||"text/plain")):(l.status=404,l.body=O.http.statusMessages[404],l.set("Content-Type","text/plain"))}}var Zr=v(M());var xt={get:Zr.default};function ca(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function da(e,t){let r=xt.get(e,"headers.if-none-match"),n=xt.get(t,"metadata.headers.etag");return r?r===n:!1}function Ut({kvNamespaceBinding:e,kvBasePath:t="",kvKey:r="{file}",defaultExtension:n="html",defaultIndexDocument:o,defaultErrorDocument:s}){async function a(i){return await global[e].getWithMetadata(i)}return async i=>{let c=A.resolveParams(r,i.params),u=c===""&&o?o:ca(c,n),p=await a(t+u);if(!p&&s&&(p=await a(t+s)),p)if(da(i.request,p))i.status=304;else{i.status=p.status,i.body=p.value;let d=xt.get(p,"metadata.headers",{});Object.keys(d).forEach(h=>{i.set(h,d[h])})}else i.status=404,i.body=O.http.statusMessages[404],i.set("Content-Type","text/plain")}}var en=v(Ge());function It({accessKeyId:e,secretAccessKey:t,region:r,lambdaName:n}){let o=new en.AwsClient({accessKeyId:e,secretAccessKey:t});return async s=>{let a=`https://lambda.${r}.amazonaws.com/2015-03-31/functions/${n}/invocations`,i={},c=await o.fetch(a,{body:JSON.stringify(i)});s.status=c.status,s.body=c.body;let u=A.instanceToJson(c.headers);Object.keys(u).forEach(p=>{s.set(p,u[p])})}}var yn=v(M()),gn=v(je());var mn={get:yn.default,set:gn.default};function di(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function ui(e){return e[Math.floor(Math.random()*e.length)]}function Dt({sources:e=[]}){return async t=>{let r=ui(e),n={method:t.request.method,headers:di(t.request.headers),redirect:"manual",cf:t.request.cf};if(O.methodsMethodsWithBody.indexOf(t.request.method)!==-1&&mn.get(t,"event.request.body")){let i=t.event.request.clone();n.body=i.body}let o=A.resolveParams(r.url,t.params);if(r.resolveOverride){let i=A.resolveParams(r.resolveOverride,t.request.params);mn.set(n,"cf.resolveOverride",i)}let s=await fetch(o+t.request.search,n);t.body=s.body,t.status=s.status;let a=A.instanceToJson(s.headers);Object.keys(a).forEach(i=>{t.set(i,a[i])})}}var Sn=v(M());var Mt={name:"@ahmadissa/cloudworker-proxy",version:"1.1.132",description:"An api gateway for cloudflare workers",license:"MIT",repository:{type:"git",url:"git+https://github.com/ahmadissa/cloudworker-proxy.git"},bugs:{url:"https://github.com/ahmadissa/cloudworker-proxy/issues"},homepage:"https://github.com/ahmadissa/cloudworker-proxy#readme",author:"Ahmad Issa",keywords:["cloudflare","workers","api","gateway","proxy"],main:"dist/index.js",files:["dist/**"],scripts:{build:"esbuild --bundle src/index.ts --format=cjs --outdir=dist --sourcemap --minify",lint:"eslint src",package:"bun install; npm run build",test:"npm run unit && npm run lint",public:"npm run package && npm publish","test:integration":"node integration/run.js",unit:"bun test","semantic-release":"semantic-release",prepare:"husky install"},release:{branches:["master"],plugins:["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator",["@semantic-release/npm",{npmPublish:!1}],["@semantic-release/git",{assets:["docs","package.json"],message:"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"}]]},dependencies:{aws4fetch:"1.0.13",build:"^0.1.4","cloudworker-router":"1.11.2",cookie:"0.4.1",jose:"^5.1.0","lodash.get":"4.4.2","lodash.set":"4.3.2",package:"^1.0.1",redaxios:"^0.5.1",shortid:"2.2.16"},devDependencies:{"@semantic-release/git":"^10.0.1","@types/jest":"^29.5.5","@types/mocha":"^10.0.1","@types/node":"^20.5.9","@typescript-eslint/eslint-plugin":"^6.6.0","@typescript-eslint/parser":"^6.6.0",bun:"1.0.3",dotenv:"8.2.0",esbuild:"^0.19.2",eslint:"7.13.0","eslint-config-airbnb-base":"14.2.1","eslint-config-prettier":"6.15.0","eslint-plugin-import":"2.22.1","eslint-plugin-prettier":"3.1.4","fetch-mock":"9.11.0",husky:"^8.0.3","node-fetch":"2.6.1",prettier:"2.1.2","semantic-release":"^22.0.4",typescript:"^5.2.2",wrangler:"^3.7.0"},directories:{example:"examples",test:"test"}};var ie=class{constructor({maxSize:t=10,maxSeconds:r=10,sink:n}){this.maxSize=t,this.maxSeconds=r,this.queue=[],this.sink=n,this.flushing=!1,this.timer=null}async push(t){return this.queue.push(t),this.queue.length>this.maxSize?this.flush():(this.timer||(this.timer=new Promise((r,n)=>{this.resolveTimer=r,this.rejectTimer=n,this.cancelationToken=setTimeout(async()=>{try{r(await this.flush())}catch(o){n(o)}},this.maxSeconds*1e3)})),this.timer)}async flush(){if(!this.flushing){this.flushing=!0;try{let t=this.queue.join(`
5
+ `)}async hexBodyHash(){let l=this.headers.get("X-Amz-Content-Sha256");if(l==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");l=c(await i(this.body||""))}return l}}async function a(u,l){let f=await crypto.subtle.importKey("raw",typeof u=="string"?t.encode(u):u,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",f,t.encode(l))}async function i(u){return crypto.subtle.digest("SHA-256",typeof u=="string"?t.encode(u):u)}function c(u){return Array.prototype.map.call(new Uint8Array(u),l=>("0"+l.toString(16)).slice(-2)).join("")}function d(u){return u.replace(/[!'()*]/g,l=>"%"+l.charCodeAt(0).toString(16).toUpperCase())}function p(u,l){let{hostname:f,pathname:m}=u,w=f.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[y,g]=(w||["",""]).slice(1,3);if(g==="us-gov")g="us-gov-west-1";else if(g==="s3"||g==="s3-accelerate")g="us-east-1",y="s3";else if(y==="iot")f.startsWith("iot.")?y="execute-api":f.startsWith("data.jobs.iot.")?y="iot-jobs-data":y=m==="/mqtt"?"iotdevicegateway":"iotdata";else if(y==="autoscaling"){let H=(l.get("X-Amz-Target")||"").split(".")[0];H==="AnyScaleFrontendService"?y="application-autoscaling":H==="AnyScaleScalingPlannerFrontendService"&&(y="autoscaling-plans")}else g==null&&y.startsWith("s3-")?(g=y.slice(3).replace(/^fips-|^external-1/,""),y="s3"):y.endsWith("-fips")?y=y.slice(0,-5):g&&/-\d$/.test(y)&&!/-\d$/.test(g)&&([y,g]=[g,y]);return[r[y]||y,g]}e.AwsClient=o,e.AwsV4Signer=s,Object.defineProperty(e,"__esModule",{value:!0})})});var je=_((kd,ln)=>{var ua="Expected a function",sn="__lodash_hash_undefined__",an=1/0,pa=9007199254740991,ha="[object Function]",fa="[object GeneratorFunction]",la="[object Symbol]",ma=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ya=/^\w*$/,ga=/^\./,wa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Aa=/[\\^$.*+?()[\]{}|]/g,Sa=/\\(\\)?/g,Ea=/^\[object .+?Constructor\]$/,ba=/^(?:0|[1-9]\d*)$/,Ca=typeof global=="object"&&global&&global.Object===Object&&global,_a=typeof self=="object"&&self&&self.Object===Object&&self,kt=Ca||_a||Function("return this")();function va(e,t){return e?.[t]}function Pa(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Ha=Array.prototype,Ta=Function.prototype,cn=Object.prototype,Jt=kt["__core-js_shared__"],tn=function(){var e=/[^.]+$/.exec(Jt&&Jt.keys&&Jt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),dn=Ta.toString,Ve=cn.hasOwnProperty,un=cn.toString,Ka=RegExp("^"+dn.call(Ve).replace(Aa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rn=kt.Symbol,Oa=Ha.splice,Ra=pn(kt,"Map"),Pe=pn(Object,"create"),nn=rn?rn.prototype:void 0,on=nn?nn.toString:void 0;function se(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function xa(){this.__data__=Pe?Pe(null):{}}function Ua(e){return this.has(e)&&delete this.__data__[e]}function Ia(e){var t=this.__data__;if(Pe){var r=t[e];return r===sn?void 0:r}return Ve.call(t,e)?t[e]:void 0}function Wa(e){var t=this.__data__;return Pe?t[e]!==void 0:Ve.call(t,e)}function Ja(e,t){var r=this.__data__;return r[e]=Pe&&t===void 0?sn:t,this}se.prototype.clear=xa;se.prototype.delete=Ua;se.prototype.get=Ia;se.prototype.has=Wa;se.prototype.set=Ja;function he(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ka(){this.__data__=[]}function Na(e){var t=this.__data__,r=Xe(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Oa.call(t,r,1),!0}function Da(e){var t=this.__data__,r=Xe(t,e);return r<0?void 0:t[r][1]}function Ma(e){return Xe(this.__data__,e)>-1}function $a(e,t){var r=this.__data__,n=Xe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}he.prototype.clear=ka;he.prototype.delete=Na;he.prototype.get=Da;he.prototype.has=Ma;he.prototype.set=$a;function ae(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function qa(){this.__data__={hash:new se,map:new(Ra||he),string:new se}}function La(e){return ze(this,e).delete(e)}function Fa(e){return ze(this,e).get(e)}function Ga(e){return ze(this,e).has(e)}function Ba(e,t){return ze(this,e).set(e,t),this}ae.prototype.clear=qa;ae.prototype.delete=La;ae.prototype.get=Fa;ae.prototype.has=Ga;ae.prototype.set=Ba;function Va(e,t,r){var n=e[t];(!(Ve.call(e,t)&&hn(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function Xe(e,t){for(var r=e.length;r--;)if(hn(e[r][0],t))return r;return-1}function Xa(e){if(!Be(e)||ti(e))return!1;var t=si(e)||Pa(e)?Ka:Ea;return t.test(oi(e))}function za(e,t,r,n){if(!Be(e))return e;t=Qa(t,e)?[t]:Ya(t);for(var o=-1,s=t.length,a=s-1,i=e;i!=null&&++o<s;){var c=ni(t[o]),d=r;if(o!=a){var p=i[c];d=n?n(p,c,i):void 0,d===void 0&&(d=Be(p)?p:Za(t[o+1])?[]:{})}Va(i,c,d),i=i[c]}return e}function ja(e){if(typeof e=="string")return e;if(Dt(e))return on?on.call(e):"";var t=e+"";return t=="0"&&1/e==-an?"-0":t}function Ya(e){return fn(e)?e:ri(e)}function ze(e,t){var r=e.__data__;return ei(t)?r[typeof t=="string"?"string":"hash"]:r.map}function pn(e,t){var r=va(e,t);return Xa(r)?r:void 0}function Za(e,t){return t=t??pa,!!t&&(typeof e=="number"||ba.test(e))&&e>-1&&e%1==0&&e<t}function Qa(e,t){if(fn(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Dt(e)?!0:ya.test(e)||!ma.test(e)||t!=null&&e in Object(t)}function ei(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ti(e){return!!tn&&tn in e}var ri=Nt(function(e){e=ii(e);var t=[];return ga.test(e)&&t.push(""),e.replace(wa,function(r,n,o,s){t.push(o?s.replace(Sa,"$1"):n||r)}),t});function ni(e){if(typeof e=="string"||Dt(e))return e;var t=e+"";return t=="0"&&1/e==-an?"-0":t}function oi(e){if(e!=null){try{return dn.call(e)}catch{}try{return e+""}catch{}}return""}function Nt(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(ua);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],s=r.cache;if(s.has(o))return s.get(o);var a=e.apply(this,n);return r.cache=s.set(o,a),a};return r.cache=new(Nt.Cache||ae),r}Nt.Cache=ae;function hn(e,t){return e===t||e!==e&&t!==t}var fn=Array.isArray;function si(e){var t=Be(e)?un.call(e):"";return t==ha||t==fa}function Be(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function ai(e){return!!e&&typeof e=="object"}function Dt(e){return typeof e=="symbol"||ai(e)&&un.call(e)==la}function ii(e){return e==null?"":ja(e)}function ci(e,t,r){return e==null?e:za(e,t,r)}ln.exports=ci});var En=_(Lt=>{"use strict";Lt.parse=yi;Lt.serialize=gi;var fi=decodeURIComponent,li=encodeURIComponent,mi=/; */,Ze=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function yi(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},o=e.split(mi),s=n.decode||fi,a=0;a<o.length;a++){var i=o[a],c=i.indexOf("=");if(!(c<0)){var d=i.substr(0,c).trim(),p=i.substr(++c,i.length).trim();p[0]=='"'&&(p=p.slice(1,-1)),r[d]==null&&(r[d]=wi(p,s))}}return r}function gi(e,t,r){var n=r||{},o=n.encode||li;if(typeof o!="function")throw new TypeError("option encode is invalid");if(!Ze.test(e))throw new TypeError("argument name is invalid");var s=o(t);if(s&&!Ze.test(s))throw new TypeError("argument val is invalid");var a=e+"="+s;if(n.maxAge!=null){var i=n.maxAge-0;if(isNaN(i)||!isFinite(i))throw new TypeError("option maxAge is invalid");a+="; Max-Age="+Math.floor(i)}if(n.domain){if(!Ze.test(n.domain))throw new TypeError("option domain is invalid");a+="; Domain="+n.domain}if(n.path){if(!Ze.test(n.path))throw new TypeError("option path is invalid");a+="; Path="+n.path}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(a+="; HttpOnly"),n.secure&&(a+="; Secure"),n.sameSite){var c=typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite;switch(c){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a}function wi(e,t){try{return t(e)}catch{return e}}});var Cn=_((tu,bn)=>{"use strict";var Qe=1;function Ai(){return Qe=(Qe*9301+49297)%233280,Qe/233280}function Si(e){Qe=e}bn.exports={nextValue:Ai,seed:Si}});var Oe=_((ru,Hn)=>{"use strict";var Ft=Cn(),ce="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",X,_n,Ke;function Gt(){Ke=!1}function vn(e){if(!e){X!==ce&&(X=ce,Gt());return}if(e!==X){if(e.length!==ce.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter(function(r,n,o){return n!==o.lastIndexOf(r)});if(t.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. These characters were not unique: "+t.join(", "));X=e,Gt()}}function Ei(e){return vn(e),X}function bi(e){Ft.seed(e),_n!==e&&(Gt(),_n=e)}function Ci(){X||vn(ce);for(var e=X.split(""),t=[],r=Ft.nextValue(),n;e.length>0;)r=Ft.nextValue(),n=Math.floor(r*e.length),t.push(e.splice(n,1)[0]);return t.join("")}function Pn(){return Ke||(Ke=Ci(),Ke)}function _i(e){var t=Pn();return t[e]}function vi(){return X||ce}Hn.exports={get:vi,characters:Ei,seed:bi,lookup:_i,shuffled:Pn}});var Kn=_((nu,Tn)=>{"use strict";var Bt=typeof window=="object"&&(window.crypto||window.msCrypto),Vt;!Bt||!Bt.getRandomValues?Vt=function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(Math.random()*256));return t}:Vt=function(e){return Bt.getRandomValues(new Uint8Array(e))};Tn.exports=Vt});var Rn=_((ou,On)=>{On.exports=function(e,t,r){for(var n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length),s="";;)for(var a=e(o),i=o;i--;)if(s+=t[a[i]&n]||"",s.length===+r)return s}});var Un=_((su,xn)=>{"use strict";var Pi=Oe(),Hi=Kn(),Ti=Rn();function Ki(e){for(var t=0,r,n="";!r;)n=n+Ti(Hi,Pi.get(),1),r=e<Math.pow(16,t+1),t++;return n}xn.exports=Ki});var Jn=_((iu,Wn)=>{"use strict";var et=Un(),au=Oe(),Oi=1567752802062,Ri=7,tt,In;function xi(e){var t="",r=Math.floor((Date.now()-Oi)*.001);return r===In?tt++:(tt=0,In=r),t=t+et(Ri),t=t+et(e),tt>0&&(t=t+et(tt)),t=t+et(r),t}Wn.exports=xi});var Nn=_((cu,kn)=>{"use strict";var Ui=Oe();function Ii(e){if(!e||typeof e!="string"||e.length<6)return!1;var t=new RegExp("[^"+Ui.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!t.test(e)}kn.exports=Ii});var Mn=_((du,Dn)=>{"use strict";Dn.exports=0});var Ln=_((uu,G)=>{"use strict";var Xt=Oe(),Wi=Jn(),Ji=Nn(),$n=Mn()||0;function ki(e){return Xt.seed(e),G.exports}function Ni(e){return $n=e,G.exports}function Di(e){return e!==void 0&&Xt.characters(e),Xt.shuffled()}function qn(){return Wi($n)}G.exports=qn;G.exports.generate=qn;G.exports.seed=ki;G.exports.worker=Ni;G.exports.characters=Di;G.exports.isValid=Ji});var Gn=_((pu,Fn)=>{"use strict";Fn.exports=Ln()});var vo=v(xr());var Br=v(M()),Ls={get:Br.default};function Ct(e){e.status=401,e.body="Unauthorized",e.set("WWW-Authenticate","Basic")}function _t(e){return async(t,r)=>{if(t.request.path===e.logoutPath)return Ct(t);let n=Ls.get(t,"request.headers.authorization");if(!n||!n.startsWith("Basic "))return Ct(t);let o=e.users.map(i=>i.authToken),s=n.substring(6),a=o.indexOf(s);return a===-1?Ct(t):(t.state.user=e.users[a].username,r(t))}}var Vr=caches.default;async function Fs(e){return await Vr.match(e)}async function Gs(e,t){return Vr.put(e.href,t)}var vt={get:Fs,set:Gs};async function Bs(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}var Xr=Bs;function Vs(e,t={}){return Object.keys(t).reduce((r,n)=>r.replace(`{${n}}`,t[n]),e)}function Pt(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}function Xs(e,t){Object.entries(e).forEach(([r,n])=>{t.header(r)||t.set(r,n)})}var Ht=e=>{e.set=(t,r)=>{e.response.headers[t.toLowerCase()]=r},e.header=t=>e.request.headers[t.toLowerCase()]},A={resolveParams:Vs,instanceToJson:Pt,mergeHeaders:Xs,upgradeCTX:Ht};var zs=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function js(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}async function Ys(e,t){if(!t)return e.event.request;let r=t.match(/{.*?}/gi).map(s=>s.slice(1,-1)),n={};for(let s=0;s<r.length;s+=1){let a=r[s],i=a.split(":");switch(i[0]){case"method":n[a]=e.request.method;break;case"path":n[a]=e.request.path;break;case"bodyHash":n[a]=await Xr(await js(e.request));break;case"header":n[a]=e.request.headers[i[1]]||"";break;default:n[a]=a}}let o=encodeURIComponent(t.replace(/({(.*?)})/gi,(s,a,i)=>n[i]));return new Request(`http://${e.request.hostname}/${o}`)}function Tt({cacheDuration:e,cacheKeyTemplate:t,headerBlacklist:r=zs}){return async(n,o)=>{let s=await Ys(n,t),a=await vt.get(s);if(a){n.body=a.body,n.status=a.status;let i=Pt(a.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])}),n.set("X-Cache-Hit",!0)}else{await o(n);let i;n.body.tee?[n.body,i]=n.body.tee():i=n.body;let c=new Response(i,{status:n.status});Object.keys(n.response.headers).forEach(d=>{r.indexOf(d.toLowerCase())===-1&&c.headers.set(d,n.response.headers[d])}),e&&(c.headers.delete("Cache-Control"),c.headers.set("Cache-Control",`max-age=${e}`)),n.event.waitUntil(vt.set(s,c))}}}function Kt({allowedOrigins:e=["*"],allowedMethods:t=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:n=["Content-Type"],allowedExposeHeaders:o=[],maxAge:s=600,optionsSuccessStatus:a=204,terminatePreflight:i=!1}){return async(c,d)=>{let{method:p}=c.request,{origin:u}=c.request.headers,l=c.request.headers["access-control-request-headers"];if(Zs(c,u,e),Qs(c,r),na(c,o),!t.includes(p.toUpperCase())){c.status=405,c.body={error:`Method ${p} not allowed`};return}if(p==="OPTIONS"&&(ea(c,t),ta(c,l,n),ra(c,s),i)){c.status=a,c.set("content-length","0"),c.body="";return}await d(c)}}function Zs(e,t,r){if(Array.isArray(r)){if(r[0]==="origin"){e.set("Access-Control-Allow-Origin",t),zr(e,"Origin");return}r[0]==="*"?e.set("Access-Control-Allow-Origin","*"):r.indexOf(t)!==-1&&(e.set("Access-Control-Allow-Origin",t),zr(e,"Origin"))}}function Qs(e,t){t&&e.set("Access-Control-Allow-Credentials",String(t))}function ea(e,t){e.set("Access-Control-Allow-Methods",t.join(","))}function ta(e,t,r){r.length===0&&t?e.set("Access-Control-Allow-Headers",t):r.length&&e.set("Access-Control-Allow-Headers",r.join(","))}function ra(e,t){t&&e.set("Access-Control-Max-Age",String(t))}function na(e,t){t.length&&e.set("Access-Control-Expose-Headers",t.join(","))}function zr(e,t){let r=e.header("vary")||e.header("Vary");(r?.split(",").map(o=>o.trim().toLowerCase())||[]).includes(t.toLowerCase())||e.set("Vary",r?`${r}, ${t}`:t)}var oa={AF:"AS",AL:"EU",AQ:"AN",DZ:"AF",AS:"OC",AD:"EU",AO:"AF",AG:"NA",AZ:"EU",AR:"SA",AU:"OC",AT:"EU",BS:"NA",BH:"AS",BD:"AS",AM:"EU",BB:"NA",BE:"EU",BM:"NA",BT:"AS",BO:"SA",BA:"EU",BW:"AF",BV:"AN",BR:"SA",BZ:"NA",IO:"AS",SB:"OC",VG:"NA",BN:"AS",BG:"EU",MM:"AS",BI:"AF",BY:"EU",KH:"AS",CM:"AF",CA:"NA",CV:"AF",KY:"NA",CF:"AF",LK:"AS",TD:"AF",CL:"SA",CN:"AS",TW:"AS",CX:"AS",CC:"AS",CO:"SA",KM:"AF",YT:"AF",CG:"AF",CD:"AF",CK:"OC",CR:"NA",HR:"EU",CU:"NA",CY:"EU",CZ:"EU",BJ:"AF",DK:"EU",DM:"NA",DO:"NA",EC:"SA",SV:"NA",GQ:"AF",ET:"AF",ER:"AF",EE:"EU",FO:"EU",FK:"SA",GS:"AN",FJ:"OC",FI:"EU",AX:"EU",FR:"EU",GF:"SA",PF:"OC",TF:"AN",DJ:"AF",GA:"AF",GE:"EU",GM:"AF",PS:"AS",DE:"EU",GH:"AF",GI:"EU",KI:"OC",GR:"EU",GL:"NA",GD:"NA",GP:"NA",GU:"OC",GT:"NA",GN:"AF",GY:"SA",HT:"NA",HM:"AN",VA:"EU",HN:"NA",HK:"AS",HU:"EU",IS:"EU",IN:"AS",ID:"AS",IR:"AS",IQ:"AS",IE:"EU",IL:"AS",IT:"EU",CI:"AF",JM:"NA",JP:"AS",KZ:"EU",JO:"AS",KE:"AF",KP:"AS",KR:"AS",KW:"AS",KG:"AS",LA:"AS",LB:"AS",LS:"AF",LV:"EU",LR:"AF",LY:"AF",LI:"EU",LT:"EU",LU:"EU",MO:"AS",MG:"AF",MW:"AF",MY:"AS",MV:"AS",ML:"AF",MT:"EU",MQ:"NA",MR:"AF",MU:"AF",MX:"NA",MC:"EU",MN:"AS",MD:"EU",ME:"EU",MS:"NA",MA:"AF",MZ:"AF",OM:"AS",NA:"AF",NR:"OC",NP:"AS",NL:"EU",AN:"NA",CW:"NA",AW:"NA",SX:"NA",BQ:"NA",NC:"OC",VU:"OC",NZ:"OC",NI:"NA",NE:"AF",NG:"AF",NU:"OC",NF:"OC",NO:"EU",MP:"OC",UM:"OC",FM:"OC",MH:"OC",PW:"OC",PK:"AS",PA:"NA",PG:"OC",PY:"SA",PE:"SA",PH:"AS",PN:"OC",PL:"EU",PT:"EU",GW:"AF",TL:"AS",PR:"NA",QA:"AS",RE:"AF",RO:"EU",RU:"EU",RW:"AF",BL:"NA",SH:"AF",KN:"NA",AI:"NA",LC:"NA",MF:"NA",PM:"NA",VC:"NA",SM:"EU",ST:"AF",SA:"AS",SN:"AF",RS:"EU",SC:"AF",SL:"AF",SG:"AS",SK:"EU",VN:"AS",SI:"EU",SO:"AF",ZA:"AF",ZW:"AF",ES:"EU",SS:"AF",EH:"AF",SD:"AF",SR:"SA",SJ:"EU",SZ:"AF",SE:"EU",CH:"EU",SY:"AS",TJ:"AS",TH:"AS",TG:"AF",TK:"OC",TO:"OC",TT:"NA",AE:"AS",TN:"AF",TR:"EU",TM:"AS",TC:"NA",TV:"OC",UG:"AF",UA:"EU",MK:"EU",EG:"AF",GB:"EU",GG:"EU",JE:"EU",IM:"EU",TZ:"AF",US:"NA",VI:"NA",BF:"AF",UY:"SA",UZ:"AS",VE:"SA",WF:"OC",WS:"OC",YE:"AS",ZM:"AF",XX:"XX"};function Ot(){return async(e,t)=>{let r=e.request.headers["cf-ipcountry"]||"XX";e.request.headers["proxy-continent"]=oa[r],await t(e)}}function jr(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=atob(t),n=Uint8Array.from(r,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}function sa(e){let t=e.split("."),r=JSON.parse(jr(t[0])),n=JSON.parse(jr(t[1])),o=atob(t[2].replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:n,signature:o,raw:{header:t[0],payload:t[1],signature:t[2]}}}function Rt({jwksUri:e,iss:t,aud:r,allowPublicAccess:n=!1}){async function o(){return(await(await fetch(e)).json()).keys}function s(c){return c.status=403,c.body="Forbidden",c}async function a(c){let p=new TextEncoder().encode([c.raw.header,c.raw.payload].join(".")),u=new Uint8Array(Array.from(c.signature).map(m=>m.charCodeAt(0))),l=await o();return(await Promise.all(l.map(async m=>{let w=await crypto.subtle.importKey("jwk",m,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",w,u,p)}))).some(m=>m)}async function i(c,d){if(c.request.method==="OPTIONS"||n)return d(c);if((c.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let u=sa(c.request.headers.authorization.slice(7)),l=new Date(u.payload.exp*1e3),f=new Date(Date.now());return l<=f||!t||u.payload.iss!==t||!r||u.payload.aud!==r||!await a(u)?s(c):(c.state.user=u.payload,d(c))}return s(c)}return i}var Yr=v(M()),aa={get:Yr.default},oe=class{constructor({accountId:t,namespace:r,authEmail:n,authKey:o,ttl:s}){this.accountId=t,this.namespace=r,this.authEmail=n,this.authKey=o,this.ttl=s}getNamespaceUrl(){return new URL(`https://api.cloudflare.com/client/v4/accounts/${this.accountId}/storage/kv/namespaces/${this.namespace}`)}getUrlForKey(t){return new URL(`${this.getNamespaceUrl()}/values/${t}`)}async list(t,r=10){let n=`${this.getNamespaceUrl()}/keys?prefix=${t}&limit=${r}`,o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});return o.ok?o.json():null}async get(t,r){let n=this.getUrlForKey(t),o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});if(o.ok)switch(r){case"json":return o.json();case"stream":return o;case"arrayBuffer":return o.arrayBuffer();default:return o.text()}return null}async getWithMetadata(t,r){let[n,o]=await Promise.all([this.get(t,r),this.list(t)]),s=aa.get(o,"result.0.metadata",{});return{value:n,metadata:s}}async put(t,r,n={}){let o=this.getUrlForKey(t),s=new URLSearchParams;this.ttl&&s.append("expiration_ttl",this.ttl.toString());let a={"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey};o.search=s.toString();let i=new FormData;return i.append("value",r),i.append("metadata",JSON.stringify(n)),(await fetch(o.toString(),{method:"PUT",headers:a,body:r})).ok}async delete(t){let r=this.getUrlForKey(t);return fetch(r,{method:"DELETE",headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}})}};var x={methodsMethodsWithBody:["POST","PUT","PATCH"],http:{statusMessages:{404:"Not Found"}},mime:{css:"text/css",csv:"text/csv",html:"text/html",ico:"image/microsoft.vnd.icon",jpeg:"image/jpeg",js:"application/javascript",json:"application/json",png:"image/png",svg:"image/svg+xml",xml:"application/xml"}};function ia(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function xt({kvAccountId:e,kvNamespace:t,kvAuthEmail:r,kvAuthKey:n,kvBasePath:o="",kvKey:s="{file}",defaultExtension:a="html",defaultIndexDocument:i,defaultErrorDocument:c,mime:d={},mode:p="rest"}){let u=new oe({accountId:e,namespace:t,authEmail:r,authKey:n,mode:p}),l={...x.mime,...d};return async f=>{let m=A.resolveParams(s,f.params),w=m===""&&i?i:ia(m,a),y=await u.get(o+w);!y&&c&&(y=await u.get(o+c)),y?(f.status=200,f.body=y,f.set("Content-Type",l[w.split(".").pop()]||"text/plain")):(f.status=404,f.body=x.http.statusMessages[404],f.set("Content-Type","text/plain"))}}var Zr=v(M());var Ut={get:Zr.default};function ca(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function da(e,t){let r=Ut.get(e,"headers.if-none-match"),n=Ut.get(t,"metadata.headers.etag");return r?r===n:!1}function It({kvNamespaceBinding:e,kvBasePath:t="",kvKey:r="{file}",defaultExtension:n="html",defaultIndexDocument:o,defaultErrorDocument:s}){async function a(i){return await global[e].getWithMetadata(i)}return async i=>{let c=A.resolveParams(r,i.params),d=c===""&&o?o:ca(c,n),p=await a(t+d);if(!p&&s&&(p=await a(t+s)),p)if(da(i.request,p))i.status=304;else{i.status=p.status,i.body=p.value;let u=Ut.get(p,"metadata.headers",{});Object.keys(u).forEach(l=>{i.set(l,u[l])})}else i.status=404,i.body=x.http.statusMessages[404],i.set("Content-Type","text/plain")}}var en=v(Ge());function Wt({accessKeyId:e,secretAccessKey:t,region:r,lambdaName:n}){let o=new en.AwsClient({accessKeyId:e,secretAccessKey:t});return async s=>{let a=`https://lambda.${r}.amazonaws.com/2015-03-31/functions/${n}/invocations`,i={},c=await o.fetch(a,{body:JSON.stringify(i)});s.status=c.status,s.body=c.body;let d=A.instanceToJson(c.headers);Object.keys(d).forEach(p=>{s.set(p,d[p])})}}var yn=v(M()),gn=v(je());var mn={get:yn.default,set:gn.default};function di(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function ui(e){return e[Math.floor(Math.random()*e.length)]}function Mt({sources:e=[]}){return async t=>{let r=ui(e),n={method:t.request.method,headers:di(t.request.headers),redirect:"manual",cf:t.request.cf};if(x.methodsMethodsWithBody.indexOf(t.request.method)!==-1&&mn.get(t,"event.request.body")){let i=t.event.request.clone();n.body=i.body}let o=A.resolveParams(r.url,t.params);if(r.resolveOverride){let i=A.resolveParams(r.resolveOverride,t.request.params);mn.set(n,"cf.resolveOverride",i)}let s=await fetch(o+t.request.search,n);t.body=s.body,t.status=s.status;let a=A.instanceToJson(s.headers);Object.keys(a).forEach(i=>{t.set(i,a[i])})}}var Sn=v(M());var $t={name:"@ahmadissa/cloudworker-proxy",version:"1.1.134",description:"An api gateway for cloudflare workers",license:"MIT",repository:{type:"git",url:"git+https://github.com/ahmadissa/cloudworker-proxy.git"},bugs:{url:"https://github.com/ahmadissa/cloudworker-proxy/issues"},homepage:"https://github.com/ahmadissa/cloudworker-proxy#readme",author:"Ahmad Issa",keywords:["cloudflare","workers","api","gateway","proxy"],main:"dist/index.js",files:["dist/**"],scripts:{build:"esbuild --bundle src/index.ts --format=cjs --outdir=dist --sourcemap --minify",lint:"eslint src",package:"bun install; npm run build",test:"npm run unit && npm run lint",public:"npm run package && npm publish","test:integration":"node integration/run.js",unit:"bun test","semantic-release":"semantic-release",prepare:"husky install"},release:{branches:["master"],plugins:["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator",["@semantic-release/npm",{npmPublish:!1}],["@semantic-release/git",{assets:["docs","package.json"],message:"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"}]]},dependencies:{aws4fetch:"1.0.13",build:"^0.1.4","cloudworker-router":"1.11.2",cookie:"0.4.1",jose:"^5.1.0","lodash.get":"4.4.2","lodash.set":"4.3.2",package:"^1.0.1",redaxios:"^0.5.1",shortid:"2.2.16"},devDependencies:{"@semantic-release/git":"^10.0.1","@types/jest":"^29.5.5","@types/mocha":"^10.0.1","@types/node":"^20.5.9","@typescript-eslint/eslint-plugin":"^6.6.0","@typescript-eslint/parser":"^6.6.0",bun:"1.0.3",dotenv:"8.2.0",esbuild:"^0.19.2",eslint:"7.13.0","eslint-config-airbnb-base":"14.2.1","eslint-config-prettier":"6.15.0","eslint-plugin-import":"2.22.1","eslint-plugin-prettier":"3.1.4","fetch-mock":"9.11.0",husky:"^8.0.3","node-fetch":"2.6.1",prettier:"2.1.2","semantic-release":"^22.0.4",typescript:"^5.2.2",wrangler:"^3.7.0"},directories:{example:"examples",test:"test"}};var ie=class{constructor({maxSize:t=10,maxSeconds:r=10,sink:n}){this.maxSize=t,this.maxSeconds=r,this.queue=[],this.sink=n,this.flushing=!1,this.timer=null}async push(t){return this.queue.push(t),this.queue.length>this.maxSize?this.flush():(this.timer||(this.timer=new Promise((r,n)=>{this.resolveTimer=r,this.rejectTimer=n,this.cancelationToken=setTimeout(async()=>{try{r(await this.flush())}catch(o){n(o)}},this.maxSeconds*1e3)})),this.timer)}async flush(){if(!this.flushing){this.flushing=!0;try{let t=this.queue.join(`
6
6
  `);this.queue=[];let r=await this.sink(t);this.timer&&(clearTimeout(this.cancelationToken),this.resolveTimer(r))}catch(t){this.timer&&this.rejectTimer(t)}finally{this.timer=null,this.flushing=!1}}}};function wn(e,t=".",r=""){return e instanceof Object?Object.keys(e).reduce((n,o)=>e[o]==null?n:{...n,...wn(e[o],t,r+o+t)},{}):r.endsWith(t)?{[r.slice(0,r.length-1)]:e}:{[r]:e}}var Ye=wn;var He=class{constructor(t){this.url=t.url,this.contentType=t.contentType,this.delimiter=t.delimiter,this.chunker=new ie({sink:this.sendMessage.bind(this),...t})}async log(t){let r=Ye(t,this.delimiter);await this.chunker.push(JSON.stringify(r))}async sendMessage(t){return fetch(this.url,{body:t,method:"POST",headers:{"Content-Type":this.contentType}})}};var An=v(Ge());var Te=class{constructor(t){this.delimiter=t.delimiter,this.chunker=new ie({sink:this.sendMessage.bind(this),...t}),this.awsClient=new An.AwsClient({accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,region:t.region}),this.streamName=t.streamName,this.region=t.region}async log(t){let r=Ye(t,this.delimiter);await this.chunker.push(JSON.stringify(r))}async sendMessage(t){let r=btoa(`${JSON.stringify(t)}
7
- `),n=JSON.stringify({DeliveryStreamName:this.streamName,Record:{Data:r}}),o=`https://firehose.${this.region}.amazonaws.com`,s=new Request(o,{method:"POST",body:n,headers:{"X-Amz-Target":"Firehose_20150804.PutRecord","Content-Type":" application/x-amz-json-1.1"}});return this.awsClient.fetch(s)}};var I={get:Sn.default};async function hi(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}function $t(e){let t;switch(e.type){case"http":t=new He(e);break;case"kinesis":t=new Te(e);break;default:throw new Error(`Log service type not supported: ${e.type}`)}return async(r,n)=>{r.state["logger-startDate"]=new Date;let o=await hi(r.request);try{await n(r);let s={message:"START",requestIp:I.get(r,"request.headers.x-real-ip"),requestId:I.get(r,"request.requestId"),request:{headers:I.get(r,"request.headers"),method:I.get(r,"request.method"),url:I.get(r,"request.href"),protocol:I.get(r,"request.protocol"),body:o},response:{status:r.status,headers:I.get(r,"response.headers")},handlers:I.get(r,"state.handlers",[]).join(","),route:I.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:Mt.version};r.event.waitUntil(t.log(s))}catch(s){let a={request:{headers:I.get(r,"request.headers"),method:I.get(r,"request.method"),handlers:I.get(r,"state.handlers",[]).join(","),url:I.get(r,"request.href"),body:o},message:"ERROR",stack:s.stack,error:s.message,severity:50,proxyVersion:Mt.version};r.event.waitUntil(t.log(a))}}}var Re=v(En()),Xn=v(M()),jn=v(je()),Yn=v(Gn());async function zt({refresh_token:e,authDomain:t,clientId:r,clientSecret:n}){let o=`${t}/oauth/token`,s=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",client_id:r,client_secret:n,refresh_token:e})});if(!s.ok)throw new Error("Authentication failed");let a=await s.json();return{...a,expires:Date.now()+a.expires_in*1e3,refresh_token:e}}var Bn="PBKDF2",Xt="AES-GCM",Mi="SHA-256",$i="raw";function qi(e){let t=atob(e.replace(/_/g,"/").replace(/-/g,"+")),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o+=1)n[o]=t.charCodeAt(o);return n.buffer}function Vn(e){let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o+=1)t+=String.fromCharCode(r[o]);return btoa(t).replace(/\//g,"_").replace(/\+/g,"-")}function Li(e){return new TextEncoder().encode(e).buffer}function Fi(e){return new TextDecoder().decode(e)}async function Gi(e){let t=new TextEncoder;return crypto.subtle.importKey($i,t.encode(e),{name:Bn},!1,["deriveKey"])}async function Bi(e,t){let r=await Gi(e),o=new TextEncoder().encode(t.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:Bn,salt:o,iterations:1e3,hash:{name:Mi}},r,{name:Xt,length:256},!0,["encrypt","decrypt"])}async function Vi(){let e=crypto.getRandomValues(new Uint8Array(8));return Vn(e)}async function zi(e,t){let r=qi(t),n=r.slice(0,16),o=r.slice(16),s=await crypto.subtle.decrypt({name:Xt,iv:n},e,o);return Fi(s)}async function Xi(e,t){let r=crypto.getRandomValues(new Uint8Array(16)),n=await crypto.subtle.encrypt({name:Xt,iv:r},e,Li(t)),o=new Uint8Array(n.byteLength+r.byteLength);return o.set(r,0),o.set(new Uint8Array(n),r.byteLength),Vn(o)}var de={decrypt:zi,deriveAesGcmKey:Bi,encrypt:Xi,getSalt:Vi};var fe={get:Xn.default,set:jn.default};function zn({cookieHeader:e="",cookieName:t}){return Re.default.parse(e)[t]}function ji(e){return Object.keys(e).map(t=>`${t}=${encodeURIComponent(e[t])}`).join("&")}function Yi(e=""){return e.split(",").indexOf("text/html")!==-1}function jt({cookieName:e="proxy",cookieHttpOnly:t=!0,allowPublicAccess:r=!1,kvAccountId:n,kvNamespace:o,kvAuthEmail:s,kvAuthKey:a,kvTtl:i=2592e3,oauth2AuthDomain:c,oauth2ClientId:u,oauth2ClientSecret:p,oauth2Audience:d,oauth2Scopes:h=[],oauth2CallbackPath:l="/callback",oauth2CallbackType:m="cookie",oauth2LogoutPath:w="/logout",oauth2LoginPath:y="/login",oauth2ServerTokenPath:g="/oauth/token",oauth2ServerAuthorizePath:T="",oauth2ServerLogoutPath:N}){let U=new oe({accountId:n,namespace:o,authEmail:s,authKey:a,ttl:i}),ee=c,Se=l,ut=m,pt=g,De=T,ht=N,V=u,Ee=p,q=d,Me=w,C=y,Ce=h.join("%20");async function $e(f,H){let P=`${ee}${pt}`,K=await fetch(P,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:ji({code:f,grant_type:"authorization_code",client_id:V,client_secret:Ee,redirect_uri:H})});if(!K.ok)throw new Error("Authentication failed");let L=await K.json();return{...L,expires:Date.now()+L.expires_in*1e3}}async function Po(f){if(zn({cookieHeader:f.request.headers.cookie,cookieName:e})){let K=f.request.hostname.match(/[^.]+\.[^.]+$/i)[0];f.set("Set-Cookie",Re.default.serialize(e,"",{domain:`.${K}`,path:"/",maxAge:0}))}let P=Sr(f);if(N){let K=encodeURIComponent(`${f.request.protocol}://${f.request.host}${P}`);f.set("Location",`${ee}${ht}?client_id=${V}&returnTo=${K}`)}else f.set("Location",P);f.status=302}async function Ho(f){let H=f.request.href.split("?")[0],P=await $e(f.request.query.code,H),K=Yn.default.generate(),L=await de.getSalt(),F=`${K}.${L}`,ft=await de.deriveAesGcmKey(K,L),te=await de.encrypt(ft,JSON.stringify(P));await U.put(K,te);let lt=f.request.hostname.match(/[^.]+\.[^.]+$/i)[0];f.status=302,ut==="query"?f.set("Location",`${f.request.query.state}?auth=${F}`):(f.set("Set-Cookie",Re.default.serialize(e,F,{httpOnly:t,domain:`.${lt}`,path:"/",maxAge:60*60*24*365})),f.set("Location",f.request.query.state))}async function To(f,H){let[P,K]=H.split("."),L=await U.get(P);if(L){let F=await de.deriveAesGcmKey(P,K),ft=await de.decrypt(F,L),te=JSON.parse(ft);if(te.expires<Date.now()){te=await zt({refresh_token:te.refresh_token,clientId:V,authDomain:ee,clientSecret:Ee});let lt=await de.encrypt(F,JSON.stringify(te));await U.put(P,lt)}f.state.accessToken=te.access_token,f.state.accessToken&&(f.request.headers.authorization=`bearer ${f.state.accessToken}`)}else{let F=f.request.hostname.match(/[^.]+\.[^.]+$/i)[0];f.set("Set-Cookie",Re.default.serialize(e,"",{domain:`.${F}`,maxAge:0}))}}function Sr(f){let H=fe.get(f,"request.query.redirect-to");if(H)return H;let P=fe.get(f,"request.headers.referer");return P||"/"}async function Ko(f){if(f.request.method==="OPTIONS")f.status=200;else{let H=Sr(f),P=encodeURIComponent(H||"/"),K=encodeURIComponent(`${f.request.protocol}://${f.request.host}${Se}`);f.status=302,f.set("location",`${ee}${De}/authorize?state=${P}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${K}`)}}async function Oo(f,H){if(f.request.method==="OPTIONS")await H(f);else if(fe.get(f,"request.headers.authorization","").toLowerCase().startsWith("bearer "))fe.set(f,"state.access_token",f.request.headers.authorization.slice(7)),await H(f);else{let P=fe.get(f,"request.query.auth")||zn({cookieHeader:f.request.headers.cookie,cookieName:e});if(P&&await To(f,P),fe.get(f,"state.accessToken")||r)await H(f);else if(Yi(f.request.headers.accept)){let L=encodeURIComponent(f.request.href),F=encodeURIComponent(`${f.request.protocol}://${f.request.host}${Se}`);f.status=302,f.set("location",`${ee}${De}/authorize?state=${L}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${F}`)}else f.status=403,f.body="Forbidden"}}return async(f,H)=>{switch(f.request.path){case Se:await Ho(f);break;case Me:await Po(f);break;case C:await Ko(f);break;default:await Oo(f,H)}}}var Zn=v(M());var Zi={get:Zn.default};function Qi(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Yt(e){let{localOriginOverride:t,backend:r}=e;return async n=>{let o=process.env.LOCAL?`${t||n.request.origin}${n.request.path}`:`${r}${n.request.path}`,s={headers:Qi(n.request.headers),method:n.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(n.request.method)!==-1&&Zi.get(n,"event.request.body")){let c=n.event.request.clone();s.body=c.body}let a=await fetch(o,s);n.body=a.body,n.status=a.status;let i=A.instanceToJson(a.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])})}}function Zt({body:e="",headers:t={},status:r=200}){return async n=>{e instanceof Object?(n.body=JSON.stringify(e),n.set("Content-Type","application/json")):n.body=A.resolveParams(e,n.params),n.status=r,Object.keys(t).forEach(o=>{n.set(o,A.resolveParams(t[o],n.params))})}}var Qn=v(M()),eo=v(je()),Qt={get:Qn.default,set:eo.default};function er({type:e="IP",scope:t="default",limit:r=1e3}){let n={};function o(a,i){let c=i["x-real-ip"];return e==="IP"?`minute.${a}.${t}.${c}`:`minute.${a}.${t}.account`}function s(a){let i=Qt.get(n,"minutes",{});Object.keys(i).forEach(c=>{c!==a&&delete n.minutes.minute})}return async(a,i)=>{let c=Math.trunc(Date.now()/6e4),u=Math.trunc(c*60+60-Date.now()/1e3),p=o(c,a.request.headers),d=Qt.get(n,p,0);if(["HEAD","OPTIONS"].indexOf(a.request.method)===-1&&(d+=1),Qt.set(n,p,d),r<d){a.status=429;return}s(c),await i(a)}}var to=v(Ge());function ec(e,t={}){if(e&&t.forcePathStyle){let r=new URL(e);return`${r.protocol}//${r.host}/${t.bucket}`}if(e){let r=new URL(e);return`${r.protocol}//${t.bucket}.${r.host}`}return t.forcePathStyle&&t.region?`https://s3.${t.region}.amazonaws.com/${t.bucket}`:t.forcePathStyle?`https://s3.amazonaws.com/${t.bucket}`:t.region?`https://${t.bucket}.s3.${t.region}.amazonaws.com`:`https://${t.bucket}.s3.amazonaws.com`}function tr({accessKeyId:e,secretAccessKey:t,bucket:r,region:n,endpoint:o,forcePathStyle:s,enableBucketOperations:a=!1}){let i=new to.AwsClient({accessKeyId:e,region:n,secretAccessKey:t}),c=ec(o,{region:n,bucket:r,forcePathStyle:s});return async u=>{if(u.params.file===void 0&&!a){u.status=404,u.body=O.http.statusMessages[404],u.set("Content-Type","text/plain");return}let p=u.params.file?A.resolveParams(`${c}/{file}`,u.params):c,d={};u.request.headers.range&&(d.range=u.request.headers.range);let h=await i.fetch(p,{method:u.method||u.request.method,headers:d});u.status=h.status,u.body=h.body;let l=A.instanceToJson(h.headers);Object.keys(l).forEach(m=>{u.set(m,l[m])})}}var rr;function ro(e){return new Uint8Array(e.split("").map(r=>r.charCodeAt(0)))}async function tc(e){return rr||(rr=await crypto.subtle.importKey("raw",ro(e),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),rr}async function rc(e,t){let r=await tc(t),n=await crypto.subtle.sign({name:"HMAC"},r,ro(e));return btoa(String.fromCharCode.apply(null,new Uint8Array(n))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function nr({secret:e}){return async(t,r)=>{let n=(t.request.path+t.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await rc(n,e)!==t.query.sign){t.status=403;return}await r(t)}}function or({host:e}){if(!e)throw new Error("Need to specify a host for the split middleware.");return async(t,r)=>{let n=t.clone();n.cloned=!0,n.request={...n.request,href:n.request.href.replace(n.request.href,e),host:e},t.event.waitUntil(r(n)),await r(t)}}async function nc(e,t,r){let n=e.getReader(),o=t.getWriter(),s=new TextDecoder,a=new TextEncoder;for(;;){let{done:i,value:c}=await n.read();if(i)break;let u=s.decode(c),p=no(u,r),d=a.encode(p);await o.write(d)}await o.close()}function oc(e,t){return e.replace(/{{\$(\d)}}/g,(r,n)=>t[parseInt(n,10)])}function no(e,t){return t.reduce((r,n)=>r.replace(n.regex,(...o)=>oc(n.replace,o)),e)}function sr({transforms:e=[],statusCodes:t=[200]}){let r=e.map(n=>({regex:new RegExp(n.regex,"g"),replace:n.replace}));return async(n,o)=>{await o(n);let{body:s}=n;if(t.indexOf(n.status)!==-1)if(typeof s=="string")n.body=no(s,r);else{let{readable:a,writable:i}=new TransformStream;nc(s,i,r),n.body=a}}}async function sc({projectID:e="your-project-id",API_KEY:t="GCP_API_KEY",token:r="action-token",siteKey:n="siteKey",expectedAction:o="action-name"}){let a=await(await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${e}/assessments?key=${t}`,{body:JSON.stringify({event:{token:r,siteKey:n,expectedAction:o}}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return a.tokenProperties.valid?a.tokenProperties.action===o?(a.riskAnalysis.reasons.forEach(i=>{console.log(i)}),a.riskAnalysis.score):(console.error("reCAPTCHA action error:"+o+":action:"+a.tokenProperties.action),null):(console.error("The CreateAssessment call failed because the token was: "+a.tokenProperties.invalidReason),0)}var ac=e=>(e=e.split("?")[0],e.replace(/\W/g,"").slice(0,100));function ar({projectID:e,API_KEY:t,siteKey:r}){function n(o){return{token:o["g-recaptcha-token"]}}return async(o,s)=>{let{token:a}=n(o.request.headers),i=ac(o.request.path);if((await sc({projectID:e,API_KEY:t,token:a,siteKey:r,expectedAction:i})||0)<.5){o.status=409;return}await s(o)}}async function ic({secret:e,token:t,expectedAction:r,remoteip:n}){if(!t)return{ok:!1,score:0,errorCodes:["missing-input-response"]};let o=new URLSearchParams({secret:e,response:t,...n?{remoteip:n}:{}}),a=await(await fetch("https://www.google.com/recaptcha/api/siteverify",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o})).json(),i=!!a.success,c=a.action===r,u=typeof a.score=="number"?a.score:0;return{ok:i&&c,score:u,action:a.action,errorCodes:a["error-codes"]}}var cc=e=>{let t=e;try{t=new URL(e,"http://dummy").pathname}catch{}return t=t.split("?")[0]||"/",t.replace(/\W/g,"").slice(0,100)},xe=(e,t)=>{if(e instanceof Headers)return e.get(t);let r=e[t]??e[t.toLowerCase()];return Array.isArray(r)?r[0]??null:r??null};function ir({secret:e,headerName:t="x-recaptcha-token",minScore:r=.5,requireActionMatch:n=!0}){return async(o,s)=>{let a=o.request?.req||o.request||o,i=a.headers??o.request?.headers??{},c=xe(i,t)||xe(i,"g-recaptcha-token")||null,p=xe(i,"x-recaptcha-action")||cc(o.request?.path||o.request?.url||a.url||"/"),d=xe(i,"cf-connecting-ip")||xe(i,"x-forwarded-for")||void 0,h=await ic({secret:e,token:c,expectedAction:p,remoteip:d});if(!(h.score>=r&&h.ok)){let m={action:h.action,expectedAction:p,score:h.score??0,errors:h.errorCodes??[]};console.warn("[reCAPTCHA] failed:"+JSON.stringify(m)),o.status=409,o.set?.("Content-Type","application/json"),o.body=JSON.stringify({error:"reCAPTCHA verification failed"});return}await s(o)}}async function dc({secret:e,token:t,remoteip:r}){if(!t)return{ok:!1,errorCodes:["missing-input-response"]};let n=new URLSearchParams({secret:e,response:t,...r?{remoteip:r}:{}}),s=await(await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify",{method:"POST",body:n})).json();return{ok:!!s.success,action:s.action,errorCodes:s["error-codes"]}}var uc=e=>{let t=e;try{t=new URL(e,"http://dummy").pathname}catch{}return t=t.split("?")[0]||"/",t.replace(/\W/g,"").slice(0,100)},Ue=(e,t)=>{if(e instanceof Headers)return e.get(t);let r=e[t]??e[t.toLowerCase()];return Array.isArray(r)?r[0]??null:r??null};function cr({secret:e,headerName:t="x-recaptcha-token",requireActionMatch:r=!1}){return async(n,o)=>{let s=n.request||n,a=s.headers||{},i=Ue(a,t)||Ue(a,"cf-turnstile-token")||null,u=Ue(a,"cf-turnstile-action")||uc(s.url||"/"),p=Ue(a,"cf-connecting-ip")||Ue(a,"x-forwarded-for")||void 0,d=await dc({secret:e,token:i,remoteip:p}),h=d.ok;if(r&&u&&d.action&&(h=h&&d.action===u),!h){let l={action:d.action,expectedAction:u,errors:d.errorCodes??[]};console.warn("[Turnstile] verification failed: "+JSON.stringify(l)),n.status=409,n.headers||=new Headers,n.headers.set("Content-Type","application/json"),n.body=JSON.stringify({error:"Turnstile verification failed"});return}n.turnstile={action:d.action},await o(n)}}var pc=e=>!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(e),hc=(e,t,r)=>!(!pc(t)||!r[e](t)),fc=e=>!(e===null||typeof e!="object"||Array.isArray(e)&&(!e[0]||typeof e[0]!="object")),rt=(e,t)=>{let r=Object.keys(e);for(let n of r){if(!t[n])return console.error("key not allowed",n),!1;if(e[n]===null&&(e[n]=""),fc(e[n])){if(!rt(e[n],t))return console.error("error validating key+validateObject:",n),!1}else if(!hc(n,e[n],t))return console.error("error validating key+validateKeyValue:",n),!1}return!0},oo=e=>!(e==null||typeof e!="object"),lc=(e,t)=>{let r=e.query;return oo(r)?rt(r,t):!1},dr=(e,t)=>{let r=e.params;return r?oo(r)?rt(r,t):!1:!0};async function mc(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return{};try{let t=await e.text();return JSON.parse(t)}catch{}return{}}function ur({allowedKeys:e}){return async(r,n)=>{if(!e)return r.status=501,!1;if(!dr(r,e)||!lc(r,e))return r.status=422,!1;let o=await mc(r.request);if(!rt(o,e))return r.status=422,!1;await n(r)}}var Eo=v(M());var E=crypto,D=e=>e instanceof CryptoKey;var R=new TextEncoder,W=new TextDecoder,Du=2**32;function X(...e){let t=e.reduce((o,{length:s})=>o+s,0),r=new Uint8Array(t),n=0;return e.forEach(o=>{r.set(o,n),n+=o.length}),r}var so=e=>{let t=e;typeof t=="string"&&(t=R.encode(t));let r=32768,n=[];for(let o=0;o<t.length;o+=r)n.push(String.fromCharCode.apply(null,t.subarray(o,o+r)));return btoa(n.join(""))},J=e=>so(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var le=class extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};var S=class extends le{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}};var k=class extends le{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}},j=class extends le{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}};var nt=E.getRandomValues.bind(E);function B(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function ot(e,t){return e.name===t}function pr(e){return parseInt(e.name.slice(4),10)}function wc(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Ac(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){let n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function io(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!ot(e.algorithm,"HMAC"))throw B("HMAC");let n=parseInt(t.slice(2),10);if(pr(e.algorithm.hash)!==n)throw B(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!ot(e.algorithm,"RSASSA-PKCS1-v1_5"))throw B("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(pr(e.algorithm.hash)!==n)throw B(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!ot(e.algorithm,"RSA-PSS"))throw B("RSA-PSS");let n=parseInt(t.slice(2),10);if(pr(e.algorithm.hash)!==n)throw B(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw B("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!ot(e.algorithm,"ECDSA"))throw B("ECDSA");let n=wc(t);if(e.algorithm.namedCurve!==n)throw B(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Ac(e,r)}function co(e,t,...r){if(r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&t.constructor&&t.constructor.name&&(e+=` Received an instance of ${t.constructor.name}`),e}var $=(e,...t)=>co("Key must be ",e,...t);function hr(e,t,...r){return co(`Key for the ${e} algorithm must be `,t,...r)}var fr=e=>D(e),b=["CryptoKey"];var _c=(...e)=>{let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let o=Object.keys(n);if(!r||r.size===0){r=new Set(o);continue}for(let s of o){if(r.has(s))return!1;r.add(s)}}return!0},me=_c;function vc(e){return typeof e=="object"&&e!==null}function x(e){if(!vc(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var st=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};var Z=(e,t,r=0)=>{r===0&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(n===-1)return!1;let o=e.subarray(n,n+t.length);return o.length!==t.length?!1:o.every((s,a)=>s===t[a])||Z(e,t,n+1)},po=e=>{switch(!0){case Z(e,[42,134,72,206,61,3,1,7]):return"P-256";case Z(e,[43,129,4,0,34]):return"P-384";case Z(e,[43,129,4,0,35]):return"P-521";case Z(e,[43,101,110]):return"X25519";case Z(e,[43,101,111]):return"X448";case Z(e,[43,101,112]):return"Ed25519";case Z(e,[43,101,113]):return"Ed448";default:throw new S("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},Kc=async(e,t,r,n,o)=>{let s,a,i=new Uint8Array(atob(r.replace(e,"")).split("").map(u=>u.charCodeAt(0))),c=t==="spki";switch(n){case"PS256":case"PS384":case"PS512":s={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},a=c?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":s={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},a=c?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=c?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":s={name:"ECDSA",namedCurve:"P-256"},a=c?["verify"]:["sign"];break;case"ES384":s={name:"ECDSA",namedCurve:"P-384"},a=c?["verify"]:["sign"];break;case"ES512":s={name:"ECDSA",namedCurve:"P-521"},a=c?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let u=po(i);s=u.startsWith("P-")?{name:"ECDH",namedCurve:u}:{name:u},a=c?[]:["deriveBits"];break}case"EdDSA":s={name:po(i)},a=c?["verify"]:["sign"];break;default:throw new S('Invalid or unsupported "alg" (Algorithm) value')}return E.subtle.importKey(t,i,s,o?.extractable??!1,a)},ho=(e,t,r)=>Kc(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r);async function lr(e,t,r){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return ho(e,t,r)}var Oc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!fr(t))throw new TypeError(hr(e,t,...b,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${b.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},Rc=(e,t,r)=>{if(!fr(t))throw new TypeError(hr(e,t,...b));if(t.type==="secret")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},xc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Oc(e,t):Rc(e,t,r)},Je=xc;function Dc(e,t,r,n,o){if(o.crit!==void 0&&n.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(a=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let s;r!==void 0?s=new Map([...Object.entries(r),...t.entries()]):s=t;for(let a of n.crit){if(!s.has(a))throw new S(`Extension Header Parameter "${a}" is not recognized`);if(o[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(s.get(a)&&n[a]===void 0)throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(n.crit)}var ye=Dc;var Fc=Symbol();function at(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new S(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function it(e,t,r){if(D(t))return io(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError($(t,...b));return E.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError($(t,...b,"Uint8Array"))}var Q=e=>Math.floor(e.getTime()/1e3);var Bc=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,ct=e=>{let t=Bc.exec(e);if(!t)throw new TypeError("Invalid time period format");let r=parseFloat(t[1]);switch(t[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(r);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(r*60);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(r*3600);case"day":case"days":case"d":return Math.round(r*86400);case"week":case"weeks":case"w":return Math.round(r*604800);default:return Math.round(r*31557600)}};var jc=async(e,t,r)=>{let n=await it(e,t,"sign");st(e,n);let o=await E.subtle.sign(at(e,n.algorithm),n,r);return new Uint8Array(o)},wo=jc;var ge=class{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=t}setProtectedHeader(t){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=t,this}setUnprotectedHeader(t){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=t,this}async sign(t,r){if(!this._protectedHeader&&!this._unprotectedHeader)throw new k("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!me(this._protectedHeader,this._unprotectedHeader))throw new k("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader},o=ye(k,new Map([["b64",!0]]),r?.crit,this._protectedHeader,n),s=!0;if(o.has("b64")&&(s=this._protectedHeader.b64,typeof s!="boolean"))throw new k('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:a}=n;if(typeof a!="string"||!a)throw new k('JWS "alg" (Algorithm) Header Parameter missing or invalid');Je(a,t,"sign");let i=this._payload;s&&(i=R.encode(J(i)));let c;this._protectedHeader?c=R.encode(J(JSON.stringify(this._protectedHeader))):c=R.encode("");let u=X(c,R.encode("."),i),p=await wo(a,t,u),d={signature:J(p),payload:""};return s&&(d.payload=W.decode(i)),this._unprotectedHeader&&(d.header=this._unprotectedHeader),this._protectedHeader&&(d.protected=W.decode(c)),d}};var ke=class{constructor(t){this._flattened=new ge(t)}setProtectedHeader(t){return this._flattened.setProtectedHeader(t),this}async sign(t,r){let n=await this._flattened.sign(t,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}};function we(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}var Ae=class{constructor(t={}){if(!x(t))throw new TypeError("JWT Claims Set MUST be an object");this._payload=t}setIssuer(t){return this._payload={...this._payload,iss:t},this}setSubject(t){return this._payload={...this._payload,sub:t},this}setAudience(t){return this._payload={...this._payload,aud:t},this}setJti(t){return this._payload={...this._payload,jti:t},this}setNotBefore(t){return typeof t=="number"?this._payload={...this._payload,nbf:we("setNotBefore",t)}:t instanceof Date?this._payload={...this._payload,nbf:we("setNotBefore",Q(t))}:this._payload={...this._payload,nbf:Q(new Date)+ct(t)},this}setExpirationTime(t){return typeof t=="number"?this._payload={...this._payload,exp:we("setExpirationTime",t)}:t instanceof Date?this._payload={...this._payload,exp:we("setExpirationTime",Q(t))}:this._payload={...this._payload,exp:Q(new Date)+ct(t)},this}setIssuedAt(t){return typeof t>"u"?this._payload={...this._payload,iat:Q(new Date)}:t instanceof Date?this._payload={...this._payload,iat:we("setIssuedAt",Q(t))}:this._payload={...this._payload,iat:we("setIssuedAt",t)},this}};var Ne=class extends Ae{setProtectedHeader(t){return this._protectedHeader=t,this}async sign(t,r){let n=new ke(R.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new j("JWTs MUST NOT use unencoded payload");return n.sign(t,r)}};var ed;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(ed="jose/v5.1.0");var Ao=function e(t){function r(o,s,a){var i,c={};if(Array.isArray(o))return o.concat(s);for(i in o)c[a?i.toLowerCase():i]=o[i];for(i in s){var u=a?i.toLowerCase():i,p=s[i];c[u]=u in c&&typeof p=="object"?r(c[u],p,u=="headers"):p}return c}function n(o,s,a,i,c){var u=typeof o!="string"?(s=o).url:o,p={config:s},d=r(t,s),h={};i=i||d.data,(d.transformRequest||[]).map(function(l){i=l(i,d.headers)||i}),d.auth&&(h.authorization=d.auth),i&&typeof i=="object"&&typeof i.append!="function"&&typeof i.text!="function"&&(i=JSON.stringify(i),h["content-type"]="application/json");try{h[d.xsrfHeaderName]=decodeURIComponent(document.cookie.match(RegExp("(^|; )"+d.xsrfCookieName+"=([^;]*)"))[2])}catch{}return d.baseURL&&(u=u.replace(/^(?!.*\/\/)\/?/,d.baseURL+"/")),d.params&&(u+=(~u.indexOf("?")?"&":"?")+(d.paramsSerializer?d.paramsSerializer(d.params):new URLSearchParams(d.params))),(d.fetch||fetch)(u,{method:(a||d.method||"get").toUpperCase(),body:i,headers:r(d.headers,h,!0),credentials:d.withCredentials?"include":c}).then(function(l){for(var m in l)typeof l[m]!="function"&&(p[m]=l[m]);return d.responseType=="stream"?(p.data=l.body,p):l[d.responseType||"text"]().then(function(w){p.data=w,p.data=JSON.parse(w)}).catch(Object).then(function(){return(d.validateStatus?d.validateStatus(l.status):l.ok)?p:Promise.reject(p)})})}return t=t||{},n.request=n,n.get=function(o,s){return n(o,s,"get")},n.delete=function(o,s){return n(o,s,"delete")},n.head=function(o,s){return n(o,s,"head")},n.options=function(o,s){return n(o,s,"options")},n.post=function(o,s,a){return n(o,a,"post",s)},n.put=function(o,s,a){return n(o,a,"put",s)},n.patch=function(o,s,a){return n(o,a,"patch",s)},n.all=Promise.all.bind(Promise),n.spread=function(o){return o.apply.bind(o,o)},n.CancelToken=typeof AbortController=="function"?AbortController:Object,n.defaults=t,n.create=e,n}();var nd=e=>{if(!e)return!1;let t=JSON.parse(atob(e.split(".")[1])),r=Math.floor(Date.now()/1e3);return t.exp>r-600},dt=async(e,t)=>{let r=await GCP_INVOKER_TOKEN.get(t);if(nd(r))return r;let n=await lr(e.private_key,"RS256"),o=e.client_email,s={iss:o,sub:o,aud:"https://www.googleapis.com/oauth2/v4/token",target_audience:t,iat:Math.floor(Date.now()/1e3),exp:Math.floor(Date.now()/1e3)+3600},a=await new Ne(s).setProtectedHeader({alg:"RS256",typ:"JWT"}).sign(n),i=await Ao.post("https://www.googleapis.com/oauth2/v4/token",{grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:a});return await GCP_INVOKER_TOKEN.delete(t),await GCP_INVOKER_TOKEN.put(t,i.data.id_token),i.data.id_token};var So={get:Eo.default};function yr({project_id:e,region:t,functionName:r,serviceAccount:n}){return async(o,s)=>{let a=So.get(o,"request.query",{}),i=new URLSearchParams(a).toString(),c=`https://${t}-${e}.cloudfunctions.net/${r}`,u=`https://${t}-${e}.cloudfunctions.net/${r}${i?`?${i}`:""}`,p=await dt(n,c);o.request.headers["X-Serverless-Authorization"]=`Bearer ${p}`;let d={headers:o.request.headers,method:o.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(o.request.method)!==-1&&So.get(o,"event.request.body")){let m=o.event.request.clone();d.body=m.body}let h=await fetch(u,d);o.body=h.body,o.status=h.status;let l=A.instanceToJson(h.headers);A.mergeHeaders(l,o),await s(o)}}var bo=v(M());var od={get:bo.default};function gr({domain:e,serviceAccount:t,allowedKeys:r}){return async(n,o)=>{if(r&&n.params&&!dr(n,r))return n.status=422,n.body=JSON.stringify({error:"Invalid params"}),!1;let s=`${e}${n.request.path}`,a=await dt(t,e),i=new Headers(n.request.headers);i.set("X-Serverless-Authorization",`Bearer ${a}`),i.set("X-Token",i.get("authorization")||"N/A"),i.set("authorization","");let c=n.event.cf||{},u={"X-Geo-Country":c.country,"X-Geo-City":c.city,"X-Geo-Latitude":c.latitude,"X-Geo-Longitude":c.longitude,"X-Geo-Timezone":c.timezone,"X-Geo-Region":c.region,"X-Geo-PostalCode":c.postalCode,"X-Geo-RegionCode":c.regionCode,"X-Geo-EU-Country":c.isEUCountry?"1":"0"};for(let[l,m]of Object.entries(u))m!==void 0&&i.set(l,m);let p={method:n.request.method,headers:i,redirect:"manual"};if(O.methodsMethodsWithBody.includes(n.request.method)&&od.get(n,"event.request.body")){let l=n.event.request.clone();p.body=l.body}let d=await fetch(s,p),h=A.instanceToJson(d.headers);n.status=d.status,n.body=await d.text(),A.mergeHeaders(h,n),await o(n)}}function wr({headers:e={},headersFN:t}){return async(r,n)=>{if(e)for(let o of Object.keys(e))r.set(o.toLowerCase(),e[o]);if(t){let o=await t();for(let s of Object.keys(o))r.set(s,o[s])}await n(r)}}async function sd(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return"";try{return await e.text()}catch{return""}}function ad(e){return new TextEncoder().encode(e).length}function Co(e,t,r){e.status=413;let n=JSON.stringify({error:"Payload too large",limit:t,...r!=null?{received:r}:{}});e.set("content-type","application/json"),e.set("content-length",String(n.length)),e.body=n}function Ar({bodySizeLimit:e=512}={}){return async(t,r)=>{let n=t.request?.method||"GET";if(["POST","PATCH","PUT","DELETE"].indexOf(n)===-1)return r(t);let o=t.request?.headers?.["content-length"],s=o?Number(o):NaN;if(Number.isFinite(s)&&s>e)return Co(t,e,s);let a=await sd(t.request),i=typeof a=="string"?ad(a):0;if(i>e)return Co(t,e,i);await r(t)}}var _o={basicAuth:Ct,cache:Ht,cors:Tt,geoDecorator:Kt,jwt:Ot,kvStorage:Rt,kvStorageBinding:Ut,lambda:It,loadbalancer:Dt,logger:$t,oauth2:jt,origin:Yt,rateLimit:er,response:Zt,s3:tr,signature:nr,split:or,transform:sr,recaptcha:ar,recaptchaV3:ir,turnstileVerify:cr,userInputValidation:ur,cloudfunction:yr,gcpCloudrun:gr,headers:wr,bodySizeLimit:Ar};function id(e){return t=>{let r=e(t);return async(n,o)=>(n.__upgraded||(Pt(n),n.__upgraded=!0),r(n,o))}}module.exports=class{constructor(t=[],r={}){this.router=new vo.default,t.forEach(n=>{let o=r[n.handlerName]||_o[n.handlerName];if(!o)throw new Error(`Handler ${n.handlerName} is not supported`);let s=id(o);this.router.add(n,s(n.options))})}async resolve(t){return t.cf=t?.request?.cf||{},this.router.resolve(t)}};
7
+ `),n=JSON.stringify({DeliveryStreamName:this.streamName,Record:{Data:r}}),o=`https://firehose.${this.region}.amazonaws.com`,s=new Request(o,{method:"POST",body:n,headers:{"X-Amz-Target":"Firehose_20150804.PutRecord","Content-Type":" application/x-amz-json-1.1"}});return this.awsClient.fetch(s)}};var W={get:Sn.default};async function hi(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}function qt(e){let t;switch(e.type){case"http":t=new He(e);break;case"kinesis":t=new Te(e);break;default:throw new Error(`Log service type not supported: ${e.type}`)}return async(r,n)=>{r.state["logger-startDate"]=new Date;let o=await hi(r.request);try{await n(r);let s={message:"START",requestIp:W.get(r,"request.headers.x-real-ip"),requestId:W.get(r,"request.requestId"),request:{headers:W.get(r,"request.headers"),method:W.get(r,"request.method"),url:W.get(r,"request.href"),protocol:W.get(r,"request.protocol"),body:o},response:{status:r.status,headers:W.get(r,"response.headers")},handlers:W.get(r,"state.handlers",[]).join(","),route:W.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:$t.version};r.event.waitUntil(t.log(s))}catch(s){let a={request:{headers:W.get(r,"request.headers"),method:W.get(r,"request.method"),handlers:W.get(r,"state.handlers",[]).join(","),url:W.get(r,"request.href"),body:o},message:"ERROR",stack:s.stack,error:s.message,severity:50,proxyVersion:$t.version};r.event.waitUntil(t.log(a))}}}var Re=v(En()),zn=v(M()),jn=v(je()),Yn=v(Gn());async function zt({refresh_token:e,authDomain:t,clientId:r,clientSecret:n}){let o=`${t}/oauth/token`,s=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",client_id:r,client_secret:n,refresh_token:e})});if(!s.ok)throw new Error("Authentication failed");let a=await s.json();return{...a,expires:Date.now()+a.expires_in*1e3,refresh_token:e}}var Bn="PBKDF2",jt="AES-GCM",Mi="SHA-256",$i="raw";function qi(e){let t=atob(e.replace(/_/g,"/").replace(/-/g,"+")),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o+=1)n[o]=t.charCodeAt(o);return n.buffer}function Vn(e){let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o+=1)t+=String.fromCharCode(r[o]);return btoa(t).replace(/\//g,"_").replace(/\+/g,"-")}function Li(e){return new TextEncoder().encode(e).buffer}function Fi(e){return new TextDecoder().decode(e)}async function Gi(e){let t=new TextEncoder;return crypto.subtle.importKey($i,t.encode(e),{name:Bn},!1,["deriveKey"])}async function Bi(e,t){let r=await Gi(e),o=new TextEncoder().encode(t.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:Bn,salt:o,iterations:1e3,hash:{name:Mi}},r,{name:jt,length:256},!0,["encrypt","decrypt"])}async function Vi(){let e=crypto.getRandomValues(new Uint8Array(8));return Vn(e)}async function Xi(e,t){let r=qi(t),n=r.slice(0,16),o=r.slice(16),s=await crypto.subtle.decrypt({name:jt,iv:n},e,o);return Fi(s)}async function zi(e,t){let r=crypto.getRandomValues(new Uint8Array(16)),n=await crypto.subtle.encrypt({name:jt,iv:r},e,Li(t)),o=new Uint8Array(n.byteLength+r.byteLength);return o.set(r,0),o.set(new Uint8Array(n),r.byteLength),Vn(o)}var de={decrypt:Xi,deriveAesGcmKey:Bi,encrypt:zi,getSalt:Vi};var fe={get:zn.default,set:jn.default};function Xn({cookieHeader:e="",cookieName:t}){return Re.default.parse(e)[t]}function ji(e){return Object.keys(e).map(t=>`${t}=${encodeURIComponent(e[t])}`).join("&")}function Yi(e=""){return e.split(",").indexOf("text/html")!==-1}function Yt({cookieName:e="proxy",cookieHttpOnly:t=!0,allowPublicAccess:r=!1,kvAccountId:n,kvNamespace:o,kvAuthEmail:s,kvAuthKey:a,kvTtl:i=2592e3,oauth2AuthDomain:c,oauth2ClientId:d,oauth2ClientSecret:p,oauth2Audience:u,oauth2Scopes:l=[],oauth2CallbackPath:f="/callback",oauth2CallbackType:m="cookie",oauth2LogoutPath:w="/logout",oauth2LoginPath:y="/login",oauth2ServerTokenPath:g="/oauth/token",oauth2ServerAuthorizePath:H="",oauth2ServerLogoutPath:K}){let O=new oe({accountId:n,namespace:o,authEmail:s,authKey:a,ttl:i}),ee=c,Se=f,pt=m,ht=g,De=H,ft=K,V=d,Ee=p,q=u,Me=w,C=y,Ce=l.join("%20");async function $e(h,T){let P=`${ee}${ht}`,R=await fetch(P,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:ji({code:h,grant_type:"authorization_code",client_id:V,client_secret:Ee,redirect_uri:T})});if(!R.ok)throw new Error("Authentication failed");let L=await R.json();return{...L,expires:Date.now()+L.expires_in*1e3}}async function Po(h){if(Xn({cookieHeader:h.request.headers.cookie,cookieName:e})){let R=h.request.hostname.match(/[^.]+\.[^.]+$/i)[0];h.set("Set-Cookie",Re.default.serialize(e,"",{domain:`.${R}`,path:"/",maxAge:0}))}let P=Sr(h);if(K){let R=encodeURIComponent(`${h.request.protocol}://${h.request.host}${P}`);h.set("Location",`${ee}${ft}?client_id=${V}&returnTo=${R}`)}else h.set("Location",P);h.status=302}async function Ho(h){let T=h.request.href.split("?")[0],P=await $e(h.request.query.code,T),R=Yn.default.generate(),L=await de.getSalt(),F=`${R}.${L}`,lt=await de.deriveAesGcmKey(R,L),te=await de.encrypt(lt,JSON.stringify(P));await O.put(R,te);let mt=h.request.hostname.match(/[^.]+\.[^.]+$/i)[0];h.status=302,pt==="query"?h.set("Location",`${h.request.query.state}?auth=${F}`):(h.set("Set-Cookie",Re.default.serialize(e,F,{httpOnly:t,domain:`.${mt}`,path:"/",maxAge:60*60*24*365})),h.set("Location",h.request.query.state))}async function To(h,T){let[P,R]=T.split("."),L=await O.get(P);if(L){let F=await de.deriveAesGcmKey(P,R),lt=await de.decrypt(F,L),te=JSON.parse(lt);if(te.expires<Date.now()){te=await zt({refresh_token:te.refresh_token,clientId:V,authDomain:ee,clientSecret:Ee});let mt=await de.encrypt(F,JSON.stringify(te));await O.put(P,mt)}h.state.accessToken=te.access_token,h.state.accessToken&&(h.request.headers.authorization=`bearer ${h.state.accessToken}`)}else{let F=h.request.hostname.match(/[^.]+\.[^.]+$/i)[0];h.set("Set-Cookie",Re.default.serialize(e,"",{domain:`.${F}`,maxAge:0}))}}function Sr(h){let T=fe.get(h,"request.query.redirect-to");if(T)return T;let P=fe.get(h,"request.headers.referer");return P||"/"}async function Ko(h){if(h.request.method==="OPTIONS")h.status=200;else{let T=Sr(h),P=encodeURIComponent(T||"/"),R=encodeURIComponent(`${h.request.protocol}://${h.request.host}${Se}`);h.status=302,h.set("location",`${ee}${De}/authorize?state=${P}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${R}`)}}async function Oo(h,T){if(h.request.method==="OPTIONS")await T(h);else if(fe.get(h,"request.headers.authorization","").toLowerCase().startsWith("bearer "))fe.set(h,"state.access_token",h.request.headers.authorization.slice(7)),await T(h);else{let P=fe.get(h,"request.query.auth")||Xn({cookieHeader:h.request.headers.cookie,cookieName:e});if(P&&await To(h,P),fe.get(h,"state.accessToken")||r)await T(h);else if(Yi(h.request.headers.accept)){let L=encodeURIComponent(h.request.href),F=encodeURIComponent(`${h.request.protocol}://${h.request.host}${Se}`);h.status=302,h.set("location",`${ee}${De}/authorize?state=${L}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${F}`)}else h.status=403,h.body="Forbidden"}}return async(h,T)=>{switch(h.request.path){case Se:await Ho(h);break;case Me:await Po(h);break;case C:await Ko(h);break;default:await Oo(h,T)}}}var Zn=v(M());var Zi={get:Zn.default};function Qi(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Zt(e){let{localOriginOverride:t,backend:r}=e;return async n=>{let o=process.env.LOCAL?`${t||n.request.origin}${n.request.path}`:`${r}${n.request.path}`,s={headers:Qi(n.request.headers),method:n.request.method,redirect:"manual"};if(x.methodsMethodsWithBody.indexOf(n.request.method)!==-1&&Zi.get(n,"event.request.body")){let c=n.event.request.clone();s.body=c.body}let a=await fetch(o,s);n.body=a.body,n.status=a.status;let i=A.instanceToJson(a.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])})}}function Qt({body:e="",headers:t={},status:r=200}){return async n=>{e instanceof Object?(n.body=JSON.stringify(e),n.set("Content-Type","application/json")):n.body=A.resolveParams(e,n.params),n.status=r,Object.keys(t).forEach(o=>{n.set(o,A.resolveParams(t[o],n.params))})}}var Qn=v(M()),eo=v(je()),er={get:Qn.default,set:eo.default};function tr({type:e="IP",scope:t="default",limit:r=1e3}){let n={};function o(a,i){let c=i["x-real-ip"];return e==="IP"?`minute.${a}.${t}.${c}`:`minute.${a}.${t}.account`}function s(a){let i=er.get(n,"minutes",{});Object.keys(i).forEach(c=>{c!==a&&delete n.minutes.minute})}return async(a,i)=>{let c=Math.trunc(Date.now()/6e4),d=Math.trunc(c*60+60-Date.now()/1e3),p=o(c,a.request.headers),u=er.get(n,p,0);if(["HEAD","OPTIONS"].indexOf(a.request.method)===-1&&(u+=1),er.set(n,p,u),r<u){a.status=429;return}s(c),await i(a)}}var to=v(Ge());function ec(e,t={}){if(e&&t.forcePathStyle){let r=new URL(e);return`${r.protocol}//${r.host}/${t.bucket}`}if(e){let r=new URL(e);return`${r.protocol}//${t.bucket}.${r.host}`}return t.forcePathStyle&&t.region?`https://s3.${t.region}.amazonaws.com/${t.bucket}`:t.forcePathStyle?`https://s3.amazonaws.com/${t.bucket}`:t.region?`https://${t.bucket}.s3.${t.region}.amazonaws.com`:`https://${t.bucket}.s3.amazonaws.com`}function rr({accessKeyId:e,secretAccessKey:t,bucket:r,region:n,endpoint:o,forcePathStyle:s,enableBucketOperations:a=!1}){let i=new to.AwsClient({accessKeyId:e,region:n,secretAccessKey:t}),c=ec(o,{region:n,bucket:r,forcePathStyle:s});return async d=>{if(d.params.file===void 0&&!a){d.status=404,d.body=x.http.statusMessages[404],d.set("Content-Type","text/plain");return}let p=d.params.file?A.resolveParams(`${c}/{file}`,d.params):c,u={};d.request.headers.range&&(u.range=d.request.headers.range);let l=await i.fetch(p,{method:d.method||d.request.method,headers:u});d.status=l.status,d.body=l.body;let f=A.instanceToJson(l.headers);Object.keys(f).forEach(m=>{d.set(m,f[m])})}}var nr;function ro(e){return new Uint8Array(e.split("").map(r=>r.charCodeAt(0)))}async function tc(e){return nr||(nr=await crypto.subtle.importKey("raw",ro(e),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),nr}async function rc(e,t){let r=await tc(t),n=await crypto.subtle.sign({name:"HMAC"},r,ro(e));return btoa(String.fromCharCode.apply(null,new Uint8Array(n))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function or({secret:e}){return async(t,r)=>{let n=(t.request.path+t.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await rc(n,e)!==t.query.sign){t.status=403;return}await r(t)}}function sr({host:e}){if(!e)throw new Error("Need to specify a host for the split middleware.");return async(t,r)=>{let n=t.clone();n.cloned=!0,n.request={...n.request,href:n.request.href.replace(n.request.href,e),host:e},t.event.waitUntil(r(n)),await r(t)}}async function nc(e,t,r){let n=e.getReader(),o=t.getWriter(),s=new TextDecoder,a=new TextEncoder;for(;;){let{done:i,value:c}=await n.read();if(i)break;let d=s.decode(c),p=no(d,r),u=a.encode(p);await o.write(u)}await o.close()}function oc(e,t){return e.replace(/{{\$(\d)}}/g,(r,n)=>t[parseInt(n,10)])}function no(e,t){return t.reduce((r,n)=>r.replace(n.regex,(...o)=>oc(n.replace,o)),e)}function ar({transforms:e=[],statusCodes:t=[200]}){let r=e.map(n=>({regex:new RegExp(n.regex,"g"),replace:n.replace}));return async(n,o)=>{await o(n);let{body:s}=n;if(t.indexOf(n.status)!==-1)if(typeof s=="string")n.body=no(s,r);else{let{readable:a,writable:i}=new TransformStream;nc(s,i,r),n.body=a}}}async function sc({projectID:e="your-project-id",API_KEY:t="GCP_API_KEY",token:r="action-token",siteKey:n="siteKey",expectedAction:o="action-name"}){let a=await(await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${e}/assessments?key=${t}`,{body:JSON.stringify({event:{token:r,siteKey:n,expectedAction:o}}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return a.tokenProperties.valid?a.tokenProperties.action===o?(a.riskAnalysis.reasons.forEach(i=>{console.log(i)}),a.riskAnalysis.score):(console.error("reCAPTCHA action error:"+o+":action:"+a.tokenProperties.action),null):(console.error("The CreateAssessment call failed because the token was: "+a.tokenProperties.invalidReason),0)}var ac=e=>(e=e.split("?")[0],e.replace(/\W/g,"").slice(0,100));function ir({projectID:e,API_KEY:t,siteKey:r}){function n(o){return{token:o["g-recaptcha-token"]}}return async(o,s)=>{let{token:a}=n(o.request.headers),i=ac(o.request.path);if((await sc({projectID:e,API_KEY:t,token:a,siteKey:r,expectedAction:i})||0)<.5){o.status=409;return}await s(o)}}async function ic({secret:e,token:t,expectedAction:r,remoteip:n}){if(!t)return{ok:!1,score:0,errorCodes:["missing-input-response"]};let o=new URLSearchParams({secret:e,response:t,...n?{remoteip:n}:{}}),a=await(await fetch("https://www.google.com/recaptcha/api/siteverify",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o})).json(),i=!!a.success,c=a.action===r,d=typeof a.score=="number"?a.score:0;return{ok:i&&c,score:d,action:a.action,errorCodes:a["error-codes"]}}var cc=e=>{let t=e;try{t=new URL(e,"http://dummy").pathname}catch{}return t=t.split("?")[0]||"/",t.replace(/\W/g,"").slice(0,100)},xe=(e,t)=>{if(e instanceof Headers)return e.get(t);let r=e[t]??e[t.toLowerCase()];return Array.isArray(r)?r[0]??null:r??null};function cr({secret:e,headerName:t="x-recaptcha-token",minScore:r=.5,requireActionMatch:n=!0}){return async(o,s)=>{let a=o.request?.req||o.request||o,i=a.headers??o.request?.headers??{},c=xe(i,t)||xe(i,"g-recaptcha-token")||null,p=xe(i,"x-recaptcha-action")||cc(o.request?.path||o.request?.url||a.url||"/"),u=xe(i,"cf-connecting-ip")||xe(i,"x-forwarded-for")||void 0,l=await ic({secret:e,token:c,expectedAction:p,remoteip:u});if(!(l.score>=r&&l.ok)){let m={action:l.action,expectedAction:p,score:l.score??0,errors:l.errorCodes??[]};console.warn("[reCAPTCHA] failed:"+JSON.stringify(m)),o.status=409,o.set?.("Content-Type","application/json"),o.body=JSON.stringify({error:"reCAPTCHA verification failed"});return}await s(o)}}async function dc({secret:e,token:t,remoteip:r}){if(!t)return{ok:!1,errorCodes:["missing-input-response"]};let n=new URLSearchParams({secret:e,response:t,...r?{remoteip:r}:{}}),s=await(await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify",{method:"POST",body:n})).json();return{ok:!!s.success,errorCodes:s["error-codes"]}}var rt=(e,t)=>{if(e instanceof Headers)return e.get(t);let r=e[t]??e[t.toLowerCase()];return Array.isArray(r)?r[0]??null:r??null};function dr({secret:e,headerName:t="x-recaptcha-token"}){return async(r,n)=>{let s=(r.request||r).headers||{},a=rt(s,t)||rt(s,"cf-turnstile-token")||null,i=rt(s,"cf-connecting-ip")||rt(s,"x-forwarded-for")||void 0,c=await dc({secret:e,token:a,remoteip:i});if(!c.ok){let p={errors:c.errorCodes??[]};console.warn("[Turnstile] verification failed: "+JSON.stringify(p)),r.status=409,r.headers||=new Headers,r.headers.set("Content-Type","application/json"),r.body=JSON.stringify({error:"Turnstile verification failed"});return}await n(r)}}var uc=e=>!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(e),pc=(e,t,r)=>!(!uc(t)||!r[e](t)),hc=e=>!(e===null||typeof e!="object"||Array.isArray(e)&&(!e[0]||typeof e[0]!="object")),nt=(e,t)=>{let r=Object.keys(e);for(let n of r){if(!t[n])return console.error("key not allowed",n),!1;if(e[n]===null&&(e[n]=""),hc(e[n])){if(!nt(e[n],t))return console.error("error validating key+validateObject:",n),!1}else if(!pc(n,e[n],t))return console.error("error validating key+validateKeyValue:",n),!1}return!0},oo=e=>!(e==null||typeof e!="object"),fc=(e,t)=>{let r=e.query;return oo(r)?nt(r,t):!1},Ue=(e,t)=>{let r=e.params;return r?oo(r)?nt(r,t):!1:!0};async function lc(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return{};try{let t=await e.text();return JSON.parse(t)}catch{}return{}}function ur({allowedKeys:e}){return async(r,n)=>{if(!e)return r.status=501,!1;if(!Ue(r,e)||!fc(r,e))return r.status=422,!1;let o=await lc(r.request);if(!nt(o,e))return r.status=422,!1;await n(r)}}var Eo=v(M());var E=crypto,D=e=>e instanceof CryptoKey;var U=new TextEncoder,J=new TextDecoder,Nu=2**32;function z(...e){let t=e.reduce((o,{length:s})=>o+s,0),r=new Uint8Array(t),n=0;return e.forEach(o=>{r.set(o,n),n+=o.length}),r}var so=e=>{let t=e;typeof t=="string"&&(t=U.encode(t));let r=32768,n=[];for(let o=0;o<t.length;o+=r)n.push(String.fromCharCode.apply(null,t.subarray(o,o+r)));return btoa(n.join(""))},k=e=>so(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var le=class extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};var S=class extends le{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}};var N=class extends le{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}},j=class extends le{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}};var ot=E.getRandomValues.bind(E);function B(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function st(e,t){return e.name===t}function pr(e){return parseInt(e.name.slice(4),10)}function gc(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function wc(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){let n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function io(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!st(e.algorithm,"HMAC"))throw B("HMAC");let n=parseInt(t.slice(2),10);if(pr(e.algorithm.hash)!==n)throw B(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!st(e.algorithm,"RSASSA-PKCS1-v1_5"))throw B("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(pr(e.algorithm.hash)!==n)throw B(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!st(e.algorithm,"RSA-PSS"))throw B("RSA-PSS");let n=parseInt(t.slice(2),10);if(pr(e.algorithm.hash)!==n)throw B(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw B("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!st(e.algorithm,"ECDSA"))throw B("ECDSA");let n=gc(t);if(e.algorithm.namedCurve!==n)throw B(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}wc(e,r)}function co(e,t,...r){if(r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&t.constructor&&t.constructor.name&&(e+=` Received an instance of ${t.constructor.name}`),e}var $=(e,...t)=>co("Key must be ",e,...t);function hr(e,t,...r){return co(`Key for the ${e} algorithm must be `,t,...r)}var fr=e=>D(e),b=["CryptoKey"];var Cc=(...e)=>{let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let o=Object.keys(n);if(!r||r.size===0){r=new Set(o);continue}for(let s of o){if(r.has(s))return!1;r.add(s)}}return!0},me=Cc;function _c(e){return typeof e=="object"&&e!==null}function I(e){if(!_c(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var at=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};var Z=(e,t,r=0)=>{r===0&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(n===-1)return!1;let o=e.subarray(n,n+t.length);return o.length!==t.length?!1:o.every((s,a)=>s===t[a])||Z(e,t,n+1)},po=e=>{switch(!0){case Z(e,[42,134,72,206,61,3,1,7]):return"P-256";case Z(e,[43,129,4,0,34]):return"P-384";case Z(e,[43,129,4,0,35]):return"P-521";case Z(e,[43,101,110]):return"X25519";case Z(e,[43,101,111]):return"X448";case Z(e,[43,101,112]):return"Ed25519";case Z(e,[43,101,113]):return"Ed448";default:throw new S("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},Tc=async(e,t,r,n,o)=>{let s,a,i=new Uint8Array(atob(r.replace(e,"")).split("").map(d=>d.charCodeAt(0))),c=t==="spki";switch(n){case"PS256":case"PS384":case"PS512":s={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},a=c?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":s={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},a=c?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=c?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":s={name:"ECDSA",namedCurve:"P-256"},a=c?["verify"]:["sign"];break;case"ES384":s={name:"ECDSA",namedCurve:"P-384"},a=c?["verify"]:["sign"];break;case"ES512":s={name:"ECDSA",namedCurve:"P-521"},a=c?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let d=po(i);s=d.startsWith("P-")?{name:"ECDH",namedCurve:d}:{name:d},a=c?[]:["deriveBits"];break}case"EdDSA":s={name:po(i)},a=c?["verify"]:["sign"];break;default:throw new S('Invalid or unsupported "alg" (Algorithm) value')}return E.subtle.importKey(t,i,s,o?.extractable??!1,a)},ho=(e,t,r)=>Tc(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r);async function lr(e,t,r){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return ho(e,t,r)}var Kc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!fr(t))throw new TypeError(hr(e,t,...b,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${b.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},Oc=(e,t,r)=>{if(!fr(t))throw new TypeError(hr(e,t,...b));if(t.type==="secret")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},Rc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Kc(e,t):Oc(e,t,r)},Je=Rc;function Nc(e,t,r,n,o){if(o.crit!==void 0&&n.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(a=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let s;r!==void 0?s=new Map([...Object.entries(r),...t.entries()]):s=t;for(let a of n.crit){if(!s.has(a))throw new S(`Extension Header Parameter "${a}" is not recognized`);if(o[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(s.get(a)&&n[a]===void 0)throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(n.crit)}var ye=Nc;var Lc=Symbol();function it(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new S(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function ct(e,t,r){if(D(t))return io(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError($(t,...b));return E.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError($(t,...b,"Uint8Array"))}var Q=e=>Math.floor(e.getTime()/1e3);var Gc=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,dt=e=>{let t=Gc.exec(e);if(!t)throw new TypeError("Invalid time period format");let r=parseFloat(t[1]);switch(t[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(r);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(r*60);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(r*3600);case"day":case"days":case"d":return Math.round(r*86400);case"week":case"weeks":case"w":return Math.round(r*604800);default:return Math.round(r*31557600)}};var zc=async(e,t,r)=>{let n=await ct(e,t,"sign");at(e,n);let o=await E.subtle.sign(it(e,n.algorithm),n,r);return new Uint8Array(o)},wo=zc;var ge=class{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=t}setProtectedHeader(t){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=t,this}setUnprotectedHeader(t){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=t,this}async sign(t,r){if(!this._protectedHeader&&!this._unprotectedHeader)throw new N("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!me(this._protectedHeader,this._unprotectedHeader))throw new N("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader},o=ye(N,new Map([["b64",!0]]),r?.crit,this._protectedHeader,n),s=!0;if(o.has("b64")&&(s=this._protectedHeader.b64,typeof s!="boolean"))throw new N('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:a}=n;if(typeof a!="string"||!a)throw new N('JWS "alg" (Algorithm) Header Parameter missing or invalid');Je(a,t,"sign");let i=this._payload;s&&(i=U.encode(k(i)));let c;this._protectedHeader?c=U.encode(k(JSON.stringify(this._protectedHeader))):c=U.encode("");let d=z(c,U.encode("."),i),p=await wo(a,t,d),u={signature:k(p),payload:""};return s&&(u.payload=J.decode(i)),this._unprotectedHeader&&(u.header=this._unprotectedHeader),this._protectedHeader&&(u.protected=J.decode(c)),u}};var ke=class{constructor(t){this._flattened=new ge(t)}setProtectedHeader(t){return this._flattened.setProtectedHeader(t),this}async sign(t,r){let n=await this._flattened.sign(t,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}};function we(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}var Ae=class{constructor(t={}){if(!I(t))throw new TypeError("JWT Claims Set MUST be an object");this._payload=t}setIssuer(t){return this._payload={...this._payload,iss:t},this}setSubject(t){return this._payload={...this._payload,sub:t},this}setAudience(t){return this._payload={...this._payload,aud:t},this}setJti(t){return this._payload={...this._payload,jti:t},this}setNotBefore(t){return typeof t=="number"?this._payload={...this._payload,nbf:we("setNotBefore",t)}:t instanceof Date?this._payload={...this._payload,nbf:we("setNotBefore",Q(t))}:this._payload={...this._payload,nbf:Q(new Date)+dt(t)},this}setExpirationTime(t){return typeof t=="number"?this._payload={...this._payload,exp:we("setExpirationTime",t)}:t instanceof Date?this._payload={...this._payload,exp:we("setExpirationTime",Q(t))}:this._payload={...this._payload,exp:Q(new Date)+dt(t)},this}setIssuedAt(t){return typeof t>"u"?this._payload={...this._payload,iat:Q(new Date)}:t instanceof Date?this._payload={...this._payload,iat:we("setIssuedAt",Q(t))}:this._payload={...this._payload,iat:we("setIssuedAt",t)},this}};var Ne=class extends Ae{setProtectedHeader(t){return this._protectedHeader=t,this}async sign(t,r){let n=new ke(U.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new j("JWTs MUST NOT use unencoded payload");return n.sign(t,r)}};var Qc;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(Qc="jose/v5.1.0");var Ao=function e(t){function r(o,s,a){var i,c={};if(Array.isArray(o))return o.concat(s);for(i in o)c[a?i.toLowerCase():i]=o[i];for(i in s){var d=a?i.toLowerCase():i,p=s[i];c[d]=d in c&&typeof p=="object"?r(c[d],p,d=="headers"):p}return c}function n(o,s,a,i,c){var d=typeof o!="string"?(s=o).url:o,p={config:s},u=r(t,s),l={};i=i||u.data,(u.transformRequest||[]).map(function(f){i=f(i,u.headers)||i}),u.auth&&(l.authorization=u.auth),i&&typeof i=="object"&&typeof i.append!="function"&&typeof i.text!="function"&&(i=JSON.stringify(i),l["content-type"]="application/json");try{l[u.xsrfHeaderName]=decodeURIComponent(document.cookie.match(RegExp("(^|; )"+u.xsrfCookieName+"=([^;]*)"))[2])}catch{}return u.baseURL&&(d=d.replace(/^(?!.*\/\/)\/?/,u.baseURL+"/")),u.params&&(d+=(~d.indexOf("?")?"&":"?")+(u.paramsSerializer?u.paramsSerializer(u.params):new URLSearchParams(u.params))),(u.fetch||fetch)(d,{method:(a||u.method||"get").toUpperCase(),body:i,headers:r(u.headers,l,!0),credentials:u.withCredentials?"include":c}).then(function(f){for(var m in f)typeof f[m]!="function"&&(p[m]=f[m]);return u.responseType=="stream"?(p.data=f.body,p):f[u.responseType||"text"]().then(function(w){p.data=w,p.data=JSON.parse(w)}).catch(Object).then(function(){return(u.validateStatus?u.validateStatus(f.status):f.ok)?p:Promise.reject(p)})})}return t=t||{},n.request=n,n.get=function(o,s){return n(o,s,"get")},n.delete=function(o,s){return n(o,s,"delete")},n.head=function(o,s){return n(o,s,"head")},n.options=function(o,s){return n(o,s,"options")},n.post=function(o,s,a){return n(o,a,"post",s)},n.put=function(o,s,a){return n(o,a,"put",s)},n.patch=function(o,s,a){return n(o,a,"patch",s)},n.all=Promise.all.bind(Promise),n.spread=function(o){return o.apply.bind(o,o)},n.CancelToken=typeof AbortController=="function"?AbortController:Object,n.defaults=t,n.create=e,n}();var rd=e=>{if(!e)return!1;let t=JSON.parse(atob(e.split(".")[1])),r=Math.floor(Date.now()/1e3);return t.exp>r-600},ut=async(e,t)=>{let r=await GCP_INVOKER_TOKEN.get(t);if(rd(r))return r;let n=await lr(e.private_key,"RS256"),o=e.client_email,s={iss:o,sub:o,aud:"https://www.googleapis.com/oauth2/v4/token",target_audience:t,iat:Math.floor(Date.now()/1e3),exp:Math.floor(Date.now()/1e3)+3600},a=await new Ne(s).setProtectedHeader({alg:"RS256",typ:"JWT"}).sign(n),i=await Ao.post("https://www.googleapis.com/oauth2/v4/token",{grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:a});return await GCP_INVOKER_TOKEN.delete(t),await GCP_INVOKER_TOKEN.put(t,i.data.id_token),i.data.id_token};var So={get:Eo.default};function yr({project_id:e,region:t,functionName:r,serviceAccount:n,allowedKeys:o}){return async(s,a)=>{if(o&&s.params&&!Ue(s,o))return s.status=422,s.body=JSON.stringify({error:"Invalid params"}),!1;let i=So.get(s,"request.query",{}),c=new URLSearchParams(i).toString(),d=`https://${t}-${e}.cloudfunctions.net/${r}`,p=s.request.path,u=`https://${t}-${e}.cloudfunctions.net/${r}${p||""}${c?`?${c}`:""}`,l=await ut(n,d),f=new Headers(s.request.headers);f.set("X-Serverless-Authorization",`Bearer ${l}`);let m=s.event.cf||{},w={"X-Geo-Country":m.country,"X-Geo-City":m.city,"X-Geo-Latitude":m.latitude,"X-Geo-Longitude":m.longitude,"X-Geo-Timezone":m.timezone,"X-Geo-Region":m.region,"X-Geo-PostalCode":m.postalCode,"X-Geo-RegionCode":m.regionCode,"X-Geo-EU-Country":m.isEUCountry?"1":"0"};for(let[K,O]of Object.entries(w))O!==void 0&&f.set(K,O);let y={headers:f,method:s.request.method,redirect:"manual"};if(x.methodsMethodsWithBody.indexOf(s.request.method)!==-1&&So.get(s,"event.request.body")){let K=s.event.request.clone();y.body=K.body}let g=await fetch(u,y);s.body=g.body,s.status=g.status;let H=A.instanceToJson(g.headers);A.mergeHeaders(H,s),await a(s)}}var bo=v(M());var nd={get:bo.default};function gr({domain:e,serviceAccount:t,allowedKeys:r}){return async(n,o)=>{if(r&&n.params&&!Ue(n,r))return n.status=422,n.body=JSON.stringify({error:"Invalid params"}),!1;let s=`${e}${n.request.path}`,a=await ut(t,e),i=new Headers(n.request.headers);i.set("X-Serverless-Authorization",`Bearer ${a}`),i.set("X-Token",i.get("authorization")||"N/A"),i.set("authorization","");let c=n.event.cf||{},d={"X-Geo-Country":c.country,"X-Geo-City":c.city,"X-Geo-Latitude":c.latitude,"X-Geo-Longitude":c.longitude,"X-Geo-Timezone":c.timezone,"X-Geo-Region":c.region,"X-Geo-PostalCode":c.postalCode,"X-Geo-RegionCode":c.regionCode,"X-Geo-EU-Country":c.isEUCountry?"1":"0"};for(let[f,m]of Object.entries(d))m!==void 0&&i.set(f,m);let p={method:n.request.method,headers:i,redirect:"manual"};if(x.methodsMethodsWithBody.includes(n.request.method)&&nd.get(n,"event.request.body")){let f=n.event.request.clone();p.body=f.body}let u=await fetch(s,p),l=A.instanceToJson(u.headers);n.status=u.status,n.body=await u.text(),A.mergeHeaders(l,n),await o(n)}}function wr({headers:e={},headersFN:t}){return async(r,n)=>{if(e)for(let o of Object.keys(e))r.set(o.toLowerCase(),e[o]);if(t){let o=await t();for(let s of Object.keys(o))r.set(s,o[s])}await n(r)}}async function od(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return"";try{return await e.text()}catch{return""}}function sd(e){return new TextEncoder().encode(e).length}function Co(e,t,r){e.status=413;let n=JSON.stringify({error:"Payload too large",limit:t,...r!=null?{received:r}:{}});e.set("content-type","application/json"),e.set("content-length",String(n.length)),e.body=n}function Ar({bodySizeLimit:e=512}={}){return async(t,r)=>{let n=t.request?.method||"GET";if(["POST","PATCH","PUT","DELETE"].indexOf(n)===-1)return r(t);let o=t.request?.headers?.["content-length"],s=o?Number(o):NaN;if(Number.isFinite(s)&&s>e)return Co(t,e,s);let a=await od(t.request),i=typeof a=="string"?sd(a):0;if(i>e)return Co(t,e,i);await r(t)}}var _o={basicAuth:_t,cache:Tt,cors:Kt,geoDecorator:Ot,jwt:Rt,kvStorage:xt,kvStorageBinding:It,lambda:Wt,loadbalancer:Mt,logger:qt,oauth2:Yt,origin:Zt,rateLimit:tr,response:Qt,s3:rr,signature:or,split:sr,transform:ar,recaptcha:ir,recaptchaV3:cr,turnstileVerify:dr,userInputValidation:ur,cloudfunction:yr,gcpCloudrun:gr,headers:wr,bodySizeLimit:Ar};function ad(e){return t=>{let r=e(t);return async(n,o)=>(n.__upgraded||(Ht(n),n.__upgraded=!0),r(n,o))}}module.exports=class{constructor(t=[],r={}){this.router=new vo.default,t.forEach(n=>{let o=r[n.handlerName]||_o[n.handlerName];if(!o)throw new Error(`Handler ${n.handlerName} is not supported`);let s=ad(o);this.router.add(n,s(n.options))})}async resolve(t){return t.cf=t?.request?.cf||{},this.router.resolve(t)}};
8
8
  /*! Bundled license information:
9
9
 
10
10
  aws4fetch/dist/aws4fetch.umd.js: