@zuplo/runtime 6.70.34 → 6.70.36

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.
@@ -57,7 +57,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
57
57
  `,pad:u,indent:u+d}:p={newline:"@@__STRINGIFY_OBJECT_NEW_LINE__@@",newlineOrSpace:"@@__STRINGIFY_OBJECT_NEW_LINE_OR_SPACE__@@",pad:"@@__STRINGIFY_OBJECT_PAD__@@",indent:"@@__STRINGIFY_OBJECT_INDENT__@@"};let m=s(y=>{if(c.inlineCharacterLimit===void 0)return y;let g=y.replace(new RegExp(p.newline,"g"),"").replace(new RegExp(p.newlineOrSpace,"g")," ").replace(new RegExp(`${p.pad}|${p.indent}`,"g"),"");return g.length<=c.inlineCharacterLimit?g:y.replace(new RegExp(`${p.newline}|${p.newlineOrSpace}`,"g"),`
58
58
  `).replace(new RegExp(p.pad,"g"),u).replace(new RegExp(p.indent,"g"),u+d)},"expandWhiteSpace");if(o.includes(a))return'"[Circular]"';if(a==null||typeof a=="number"||typeof a=="boolean"||typeof a=="function"||typeof a=="symbol"||Gh(a))return String(a);if(a instanceof Date)return`new Date('${a.toISOString()}')`;if(l>n)return"...";if(Array.isArray(a)){if(a.length===0)return"[]";o.push(a);let y="["+p.newline+a.map((g,w)=>{let v=a.length-1===w?p.newline:`,${p.newlineOrSpace}`,x=i(g,c,u+d,l+1);return c.transform&&(x=c.transform(a,w,x)),p.indent+x+v}).join("")+p.pad+"]";return o.pop(),m(y)}if(xr(a)){let y=Vh(a);if(c.filter&&(y=y.filter(w=>c.filter?.(a,w))),y.length===0)return"{}";o.push(a);let g="{"+p.newline+y.map((w,v)=>{let x=y.length-1===v?p.newline:`,${p.newlineOrSpace}`,I=typeof w=="symbol",k=!I&&/^[a-z$_][$\w]*$/i.test(w),C=I||k?w:i(w,c,"",l+1),A=i(a[w],c,u+d,l+1);return c.transform&&(A=c.transform(a,w,A)),`${p.indent+String(C)}: ${A}${x}`}).join("")+p.pad+"}";return o.pop(),m(g)}return a=a.replace(/\\/g,"\\\\"),a=String(a).replace(/[\r\n]/g,y=>y===`
59
59
  `?"\\n":"\\r"),c.singleQuotes===!1?(a=a.replace(/"/g,'\\"'),`"${a}"`):(a=a.replace(/'/g,"\\'"),`'${a}'`)},"stringify")(t,e,r,0)}s(_i,"stringifyObject");function ut(t){return ry(Rr(t))}s(ut,"serializeMessage");function Nt(t){return t.map(e=>ut(e))}s(Nt,"serializeMessages");function Hr(t){if(t.length===0)return"<no data provided to log>";let e=t[0];return typeof e=="string"?e:e instanceof Error?e.message:ry(Rr(e))}s(Hr,"extractBestMessage");function ty(t){let e=[];return t.forEach(r=>{if(typeof r=="string")e.push(r);else if(Fn(r))if(r.stack)e.push(r.stack);else{let o=_i(Rr(r));e.push(o)}else if(typeof r=="object"){let o=_i(r);e.push(o)}else{let o=Oi(r);e.push(o)}}),e.join(`
60
- `)}s(ty,"messagesToMultilineText");function ry(t){return typeof t=="string"?t:JSON.stringify(t)}s(ry,"stringifyNonString");function Oi(t){return typeof t=="string"?t:t===null?"null":typeof t>"u"?"undefined":typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"||typeof t=="symbol"?t.toString():typeof t=="function"?`[function ${t.name}]`:typeof t=="object"&&Array.isArray(t)?`[array ${t.length}]`:t instanceof Error?`${t.name??"Error"}: ${t.message??"unknown"}`:typeof t=="object"?ac(t):"unknown"}s(Oi,"stringifyNonStringToText");var wI={internal:1,trace:2,debug:5,info:9,warn:13,error:17,fatal:21},Ai=s(t=>e=>{let r={};return r.accountName=t.build.ACCOUNT_NAME,r.projectName=t.build.PROJECT_NAME,r.deploymentName=t.deploymentName,r.environmentType=t.loggingEnvironmentStage,r.labels={requestId:e.requestId,source:e.logSource,logOwner:e.logOwner},r.rayId=e.rayId??"",r.runtime={buildId:t.build.BUILD_ID,buildTimestamp:t.build.TIMESTAMP,gitSHA:t.build.GIT_SHA,version:t.build.ZUPLO_VERSION},r.atomicCounter=e.vectorClock,{logId:e.logId,timestamp:e.timestamp,observerdTimestamp:e.timestamp,traceId:e.requestId,severityText:e.level,severityNumber:wI[e.level],body:Nt(e.messages),attributes:r}},"unifiedFormatter");async function me(t,e){if(t.level==="error"&&D.console.error(t.messages),!T.instance.remoteLogURL||!T.instance.loggingId||!T.instance.remoteLogToken)return;let r;try{r=await e?.text()}catch{}try{let o={...t,messages:[...t.messages,...r?[r]:[]],logId:crypto.randomUUID(),logOwner:"user",logSource:"runtime",rayId:null,requestId:`global-${crypto.randomUUID()}`,timestamp:new Date,buildId:T.instance.build.BUILD_ID,loggingId:T.instance.loggingId,vectorClock:0};await ny(T.instance,[o])}catch(o){D.console.error(o)}}s(me,"sendRemoteGlobalLog");async function ny(t,e){let r=Ai(t);try{let o=new Headers({"content-type":"application/json",authentication:`Bearer ${t.remoteLogToken}`});Le(o),await D.fetch(new URL("/v1/runtime-logs",t.remoteLogURL).toString(),{method:"POST",body:JSON.stringify({entries:e.map(r)}),headers:{"content-type":"application/json","user-agent":T.instance.systemUserAgent,"zp-dn":T.instance.deploymentName??"unknown"}})}catch(o){D.console.error(o)}}s(ny,"sendLogs");var xI=s(t=>async e=>{e.length!==0&&await ny(t,e)},"dispatchFunction"),$i,Hn=class{static{s(this,"UnifiedLogTransport")}constructor(e){$i||($i=new ue("unified-log-transport",1,xI(e)))}log(e,r){$i.enqueue(e),r.waitUntil($i.waitUntilFlushed())}};var mc=class extends Ne{constructor(r){super();this.options=r}static{s(this,"GoogleCloudLoggingPlugin")}getTransport(){return new Bn(this.options)}},RI="https://logging.googleapis.com/v2/entries:write?alt=json",fc={error:"ERROR",warn:"WARNING",info:"INFO",debug:"DEBUG"},Bn=class{static{s(this,"GoogleLogTransport")}constructor(e){P("logging.google-cloud"),this.#n=e.logName,this.#e=e.serviceAccountJson,this.#o=T.instance.loggingEnvironmentType,this.#i=T.instance.loggingEnvironmentStage,this.#r=T.instance.deploymentName,this.#s=e.fields??{}}#e;#t;#n;#r;#o;#i;#s;async init(){this.#t=await rt.init(this.#e)}log(e,r){if(!this.#t)throw new ye("Invalid state - Google log transport is not initialized");if(e.messages.length===0)return;let o=Object.assign({allMessages:Nt(e.messages)},this.#s,r.properties??{}),n=this.#t.projectId??"zuplo-production",i={logName:this.#n,resource:{type:"global"},severity:fc[e.level],timestamp:e.timestamp,trace:`projects/${n}/traces/${e.requestId}`,labels:{requestId:e.requestId,buildId:e.buildId,source:e.logSource,loggingId:e.loggingId,logOwner:e.logOwner,environment:this.#r,environmentType:this.#o,environmentStage:this.#i}};e.rayId&&(i.labels.rayId=e.rayId);let a=Hr(o.allMessages);i.jsonPayload={...o,message:a},this.batcher.enqueue(i),r.waitUntil(this.batcher.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length===0)return;this.#t||(this.#t=await rt.init(this.#e));let r=await bt({serviceAccount:this.#t,audience:"https://logging.googleapis.com/google.logging.v2.LoggingServiceV2"});try{let o=await D.fetch(RI,{method:"POST",body:JSON.stringify({entries:e}),headers:{Authorization:`Bearer ${r}`,"content-type":"application/json;charset=UTF-8"}});o.ok||await me({level:"error",messages:[`Failed to send logs to Google: ${o.status} - ${o.statusText}`]},o)}catch{await me({level:"error",messages:["Failed to connect to Google logging service. Check that the URL is correct."]})}},"dispatchFunction");batcher=new ue("google-log-transport",1,this.dispatchFunction)};var bc=class extends Ne{constructor(r){super();this.options=r}static{s(this,"DataDogLoggingPlugin")}getTransport(){return new Gn(this.options)}},gc="__ddtags",hc="__ddattr",yc=s(t=>t.replaceAll(",","_").replaceAll(":","_"),"cleanTagText"),II=s(t=>{let e=Object.keys(t),r=[];return e.forEach(o=>{let n=t[o];n==null?r.push(yc(o)):r.push(`${yc(o)}:${yc(n.toString())}`)}),r.join(",")},"formatTags"),Gn=class{static{s(this,"DataDogTransport")}constructor(e){P("logging.datadog"),this.#e=e.apiKey,this.#t=e.url??"https://http-intake.logs.datadoghq.com/api/v2/logs",this.#r=T.instance.loggingEnvironmentType,this.#o=T.instance.loggingEnvironmentStage,this.#n=T.instance.deploymentName,this.#i=e.fields??{},this.#s=e.tags??{},this.#a=e.source??"Zuplo"}#e;#t;#n;#r;#o;#i;#s;#a;log(e,r){let o=Object.assign({},this.#s),n=Object.assign({},this.#i,r.properties??{}),i=[...e.messages];if(!T.instance.build.COMPATIBILITY_FLAGS.removeLegacyLogInitialization){let l=r.custom[gc];l&&typeof l=="object"&&(P("logging.datadog.legacy-tags"),Object.assign(o,l));let d=e.messages.findIndex(y=>y[gc]!==void 0);d>-1&&(Object.assign(o,i[d][gc]),i.splice(d,1));let p=r.custom[hc];p&&typeof p=="object"&&(P("logging.datadog.legacy-attributes"),Object.assign(n,p));let m=e.messages.findIndex(y=>y[hc]!==void 0);m>-1&&(Object.assign(n,i[m][hc]),i.splice(m,1))}let a=Nt(i),c={...e,activityId:e.requestId,trace:e.requestId},u=Object.assign({message:{...c,messages:a},ddsource:this.#a,hostname:new URL(r.originalRequest.url).hostname,msg:Hr(a),atomic_counter:e.vectorClock,service:e.loggingId,ddtags:II(o),environment:this.#n,environment_type:this.#r,environment_stage:this.#o,ray_id:e.rayId,request_id:e.requestId},n);this.batcher.enqueue(u),r.waitUntil(this.batcher.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length!==0)try{let r=await D.fetch(this.#t,{method:"POST",body:JSON.stringify([...e]),headers:{"content-type":"application/json","DD-API-KEY":this.#e}});r.ok||await me({level:"error",messages:[`Failed to send logs to DataDog: ${r.status} - ${r.statusText}`]},r)}catch{await me({level:"error",messages:["Failed to connect to DataDog logging service. Check that the URL is correct."]})}},"dispatchFunction");batcher=new ue("data-dog-transport",10,this.dispatchFunction)};var Br=class{static{s(this,"LookupResult")}constructor(e,r,o){this.routeConfiguration=e,this.params=o??{},this.executableHandler=r}executableHandler;routeConfiguration;params},Li=class extends Error{static{s(this,"RouterError")}};import{trace as nP}from"@opentelemetry/api";import{SpanStatusCode as PI,trace as SI}from"@opentelemetry/api";function Mt(t,e,r,o){e.log.error(r,o);let n={};if(T.instance.isLocalDevelopment||T.instance.isWorkingCopy)if(o instanceof z&&o.extensionMembers)n=o.extensionMembers;else if(o.cause){let i=Rr(o.cause);"stack"in i&&(i.stack=pc(i.stack)),n={cause:i}}else{let i=Rr(o);"stack"in i&&(i.stack=pc(i.stack)),n={cause:i}}return M.internalServerError(t,e,{detail:o.message,...n})}s(Mt,"errorHandler");import{SpanStatusCode as Mi,trace as Di}from"@opentelemetry/api";var oy=s(t=>(e,r)=>t(e,r),"globalRequestHandlerProxy");function iy(t){oy=t}s(iy,"setTelemetryInitFunction");var sy=s(t=>oy(t),"proxyHandler");var Ic={},Pt=[],vc=[],wc=[],xc=[],Rc=[];var Ni={addPlugin(t){Pt.push(t)},addRequestHook(t){vc.push(t)},addResponseSendingHook(t){wc.push(t)},addResponseSendingFinalHook(t){xc.push(t)},addPreRoutingHook(t){Rc.push(t)}},cy=s(async(t,e)=>{if(vc.length===0)return t;let r=Di.getTracer("extension");return r.startActiveSpan("hook:onRequest",async o=>{try{let n=t;for(let i of vc){let a=await r.startActiveSpan(i.name,async c=>{let u=await i(n,e);if(u instanceof de||u instanceof Response)return c.end(),u;{let l=new R(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof n}.`);throw c.end(),c.recordException(l),c.setStatus({code:Mi.ERROR}),l}});if(a instanceof de)n=a;else return a}return n}finally{o.end()}})},"invokeOnRequestExtensions"),uy=s(async(t,e,r)=>{if(wc.length===0)return t;let o=Di.getTracer("extension"),n=T.instance.build.COMPATIBILITY_FLAGS.chainResponseSendingHooks;return o.startActiveSpan("hook:onResponseSending",async i=>{try{let a=t;for(let c of wc)await o.startActiveSpan(c.name,async u=>{let l=await c(n?a:t,e,r);if(l instanceof Response)a=l,u.end();else{let d=new R(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof a}.`);throw u.recordException(d),u.setStatus({code:Mi.ERROR}),u.end(),d}});return a}finally{i.end()}})},"invokeOnResponseSendingExtensions"),ly=s(async(t,e,r)=>{if(xc.length===0)return;let o=Di.getTracer("extension");return o.startActiveSpan("hook:onResponseSendingFinal",async n=>{try{for(let i of xc)await o.startActiveSpan(i.name,async a=>{try{await i(t,e,r)}catch(c){throw a.recordException(c),a.setStatus({code:Mi.ERROR}),a.end(),c}a.end()})}finally{n.end()}})},"invokeOnResponseSendingFinalExtensions"),dy=s(async t=>{if(Rc.length===0)return t;let e=Di.getTracer("extension");return e.startActiveSpan("hook:preRouting",async r=>{try{let o=t;for(let n of Rc)o=await e.startActiveSpan(n.name,async a=>{try{let c=await n(o);if(c instanceof Request)return c;{let u=new z(`Invalid state - the PreRouting hook must return a Request. Received ${typeof c}.`);throw a.recordException(u),a.setStatus({code:Mi.ERROR}),u}}finally{a.end()}});return o}finally{r.end()}})},"invokePreRoutingHooks"),ay=!1;async function py(t){if(!ay){t&&(P("runtime.extensions"),await t(Ni)),Ic.value=Ni;for(let e of Pt)if(e instanceof wr){let{requestHandlerProxy:r}=e.instrument({accountName:T.instance.build.ACCOUNT_NAME,projectName:T.instance.build.PROJECT_NAME,buildId:T.instance.build.BUILD_ID,zuploVersion:T.instance.build.ZUPLO_VERSION,compatibilityDate:T.instance.build.COMPATIBILITY_DATE,instanceId:T.instance.instanceId,environmentType:T.instance.loggingEnvironmentType,environmentStage:T.instance.loggingEnvironmentStage,deploymentName:T.instance.deploymentName});iy(r)}await Promise.all(Pt.map(async e=>{e instanceof Ue&&await e.initialize(Ni)})),qn.setProblemResponseFormat(Ni.problemResponseFormat),ay=!0}}s(py,"initializeRuntime");function Gr(t){let{developerPortal:e}=Pe.instance.runtimeSettings;return e.enabled&&e.basePath&&t.pathname.startsWith(e.basePath)||t.pathname.startsWith("/__zuplo/")||t.pathname.startsWith("/__/zuplo/")}s(Gr,"isSystemRoute");var He=class{static{s(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=s(e=>async(r,o)=>SI.getTracer("pipeline").startActiveSpan(`handler:${o.route.handler.export}`,async i=>{try{return await e(r,o)}catch(a){let c=Mt(r,o,"Error executing request handler.",a);return i.setStatus({code:PI.ERROR}),c}finally{i.end()}}),"#errorWrappedHandler");#t=s(({processors:e,handler:r})=>async(o,n)=>{let i=Je.getContextExtensions(n),a=[...e],c=s(async g=>{let w=a.pop();if(!w){let x=await this.#e(async I=>{let k=await r(I,n);return TI(k)})(g,n);try{await i.onHandlerResponse(x,g,n)}catch(I){return Mt(o,n,"Error invoking 'context.onHandlerResponse' hook",I)}return x}return w(o,n,c)},"nextPipe"),l=await c(o),d=new URL(o.url);if(Gr(d)&&T.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new Vn(o,l);n.dispatchEvent(p);let m=i.latestRequest,y;try{y=await p.mutableResponse}catch(g){return Mt(o,n,"Error retrieving mutableResponse",g)}try{y=await i.onResponseSending(y,m,n)}catch(g){return Mt(o,n,"Error invoking 'context.onResponseSending' hook",g)}try{y=await uy(y,m,n)}catch(g){return Mt(o,n,"Error invoking 'context.onResponseSending' hook",g)}n.dispatchEvent(new Jn(o,y));try{await i.onResponseSendingFinal(l,m,n)}catch(g){throw n.log.error("Error invoking 'runtime.onResponseSending' hook",g),g}try{await ly(l,m,n)}catch(g){throw n.log.error("Error invoking 'runtime.onResponseSending' hook",g),g}return y},"#toZuploPipeline")};function TI(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response(sc(t),{headers:{"content-type":"application/json"}})}s(TI,"resultToResponse");var vt=class extends or{static{s(this,"MetricsPlugin")}};var B=class t{static{s(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let r=t.#e.get(e);if(!r){let o=`No system logger found for context with requestId '${e.requestId}'`;throw D.console.error(o),new ye(o)}return r}static addLogger(e,r){t.#e.set(e,r)}};var Ui=class{static{s(this,"ZuploMetricsTransport")}#e;#t;constructor(e){this.#e=e,this.#t=new ue("zuplo-metrics-transport",10,this.dispatchFunction,B.getLogger(e))}pushMetrics(e,r){this.#t.enqueue(e),r.waitUntil(this.#t.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length!==0)try{let{remoteLogURL:r,deploymentName:o}=T.instance,{ACCOUNT_NAME:n,PROJECT_NAME:i}=T.instance.build,a=e.map(p=>{let m=Object.assign({},p);return delete m.requestContentLength,delete m.responseContentLength,m}),c=Zh(),u={metadata:{timestamp:new Date,accountName:n,projectName:i,deploymentName:o},metrics:a,features:c},l=new Headers({"content-type":"application/json"});Le(l);let d=await qe({retries:3,retryDelayMs:1e3,logger:D.console},new URL("/v2/runtime/metrics",r).toString(),{method:"POST",body:JSON.stringify(u),headers:l});if(!d.ok){let p=await d.text();B.getLogger(this.#e).error(`Metrics POST responded ${d.status}: ${d.statusText}`,p),qh(c)}}catch(r){B.getLogger(this.#e).error("Failed to send Zuplo metrics.",r)}},"dispatchFunction")};var Vr="SYSTEM_IGNORED";var Be=class{static{s(this,"SystemRouteConfiguration")}constructor({label:e,path:r,methods:o,systemRouteName:n,corsPolicy:i="none"}){this.label=e,this.path=r,this.methods=o,this.corsPolicy=i,this.handler={export:Vr,module:Vr},this.systemRouteName=n}label;path;methods;handler;corsPolicy;policies;systemRouteName;metadata;raw(){return{}}};var Pc="x-real-ip",kI="true-client-ip",EI="cf-connecting-ip",CI="x-forwarded-for";function wt(t){let e=t.headers,r=e.get(Pc)??e.get(kI)??e.get(EI);if(r)return r;let o=e.get(CI);if(o){let n=o.split(/,\s*/).map(i=>i.trim()).find(i=>i.length>0);if(n)return n}}s(wt,"getClientIp");var lt=s(async(t,e,r)=>{let o=new Date,n=Date.now(),i=await r(t),a=t.headers.get(Zr)??void 0,c=wt(t),u=e.incomingRequestProperties,l;e.route instanceof Be&&(l=e.route.systemRouteName);let d=Je.getContextExtensions(e).latestRequest,p={timestamp:o,statusCode:i.status,durationMs:Date.now()-n,requestContentLength:t.headers.get("content-length")?Number(t.headers.get("content-length")):void 0,responseContentLength:i.headers.get("content-length")?Number(i.headers.get("content-length")):void 0,routePath:e.route?.path??"SYSTEM_OR_NOT_FOUND",systemRouteName:l,contextId:e.contextId,parentContextId:e.parentContext?.contextId,requestId:e.requestId,parentRequestId:e.parentContext?.requestId,method:t.method,asn:u.asn,asOrganization:u.asOrganization,colo:u.colo,continent:u.continent,country:u.country,city:u.city,latitude:u.latitude,longitude:u.longitude,rayId:a,instanceId:T.instance.instanceId,userSub:d.user?.sub,clientIp:c},m=[];return!T.instance.isLocalDevelopment&&T.instance.remoteLogURL&&T.instance.remoteLogToken&&T.instance.loggingId&&m.push(new Ui(e)),Pt.forEach(y=>{if(y instanceof vt){let g=y.getTransport();m.push(g)}}),m.forEach(y=>{y.pushMetrics(p,e)}),i},"metricsProcessor");var Sc=s(t=>{let e=s(async(n,i)=>{let a=new URL(n.url),c=T.instance.build,u={buildId:c.BUILD_ID,zuploVersion:c.ZUPLO_VERSION,compatibilityDate:c.COMPATIBILITY_DATE,apiVersion:c.API_VERSION,gitSha:c.GIT_SHA,timestamp:c.TIMESTAMP,isProduction:c.ENVIRONMENT_TYPE==="PRODUCTION"};if(a.searchParams.get("system_log")==="true"&&B.getLogger(i).error("Test System Log",u),a.searchParams.get("error")==="true")throw new Error("this is an unhandled error");return new Response(JSON.stringify(u,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),r=new He({processors:[lt],handler:e}),o=new Be({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:"build-data"});t.addRoute(o,r.execute)},"registerBuildRoute");var ji=class{static{s(this,"BoundedSet")}limit;items;constructor(e){this.limit=e,this.items=new Map}add(e){if(this.items.has(e))this.items.delete(e);else if(this.items.size>=this.limit){let r=this.items.keys().next().value;r&&this.items.delete(r)}this.items.set(e,!0)}has(e){return this.items.has(e)}values(){return Array.from(this.items.keys())}size(){return this.items.size}};var my=new Map;function Dt(t){if(Array.isArray(t)&&!t.some(n=>typeof n!="number"))return t;if(typeof t!="string")throw new Error("Input must be a string or an array of numbers");if(!/^\d+(?:-\d+)?(?:,\s*\d+(?:-\d+)?)*$/.test(t))throw new R("Malformed input string");let e=my.get(t);if(e)return e;let r=t.split(","),o=[];for(let n of r){let i=n.split("-");if(i.length===2){let a=parseInt(i[0],10),c=parseInt(i[1],10);for(let u=a;u<=c;u++)o.push(u)}else o.push(parseInt(n,10))}return my.set(t,o),o}s(Dt,"statusCodesStringToNumberArray");function Gt(t,e,r){if(!e.startsWith("."))throw new R(`Invalid ${r} - must start with '.' - '${e}' does not`);let o=e.split(".").splice(1),n=t;return o.forEach(i=>{if(n===void 0)throw new z(`Error applying ${r} '${e}', reading '${i}'`);n=n[i]}),`${n}`}s(Gt,"getValueFromRequestUser");function fy(t,e){if(!e.startsWith("."))throw new R(`Invalid selector. must start with '.' - '${e}' does not`);let r=e.split(".").splice(1),o=t;return r.forEach(n=>{if(o===void 0)throw new z(`Error applying'${e}', reading '${n}'`);if(o&&typeof o=="object")o=Reflect.get(o,n);else throw new z(`Error applying'${e}', reading '${n}'`)}),`${o}`}s(fy,"selectPropertyUsingJsonPath");function Ir(t){if(Array.isArray(t)){if(t.includes(r=>typeof r!="string"))throw new R("Received an array that contains non-string values.");return t}if(Lt(t))return t.includes(",")?t.split(",").map(r=>r.trim()).filter(r=>r!==","&&r!==""):[t];throw new R(`Expected type of string, received type '${typeof t}'`)}s(Ir,"parseValueToStringArray");function gy(t){if(t==null)return[];if(!Array.isArray(t))throw new R(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(r=>{if(!xr(r))throw new R(`Invalid custom cors policy is set. Expected an object, received '${typeof r}'`);if(!Bh(r.name))throw new R("Value of 'name' on custom cors policies must be a non-empty string.");if(r.maxAge!==void 0&&!cc(r.maxAge))throw new R(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof r.maxAge}'`);if(r.allowCredentials!==void 0&&!uc(r.allowCredentials))throw new R("Value of 'allowCredentials' on custom cors policies must be a boolean or not be set. If using an environment variable, check that it is set correctly.");let o=Tc(r,"allowedHeaders"),n=Tc(r,"allowedMethods"),i=Tc(r,"exposeHeaders"),a;try{a=Ir(r.allowedOrigins)}catch(u){throw new R(`Value of 'allowedOrigins' on custom cors policies is invalid. ${u.message} If using an environment variable, check that it is set correctly.`)}return{name:r.name,allowCredentials:typeof r.allowCredentials=="boolean"?String(r.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:o?o.join(", "):void 0,allowedMethods:n?n.join(", "):void 0,exposeHeaders:i?i.join(", "):void 0,maxAge:typeof r.maxAge=="number"?r.maxAge.toString():void 0}})}s(gy,"parseCorsPolicies");function Tc(t,e){let r;if(t[e]!==void 0)try{r=Ir(t[e])}catch(o){throw new R(`Value of '${e}' on custom cors policies is invalid. ${o.message} If using an environment variable, check that it is set correctly.`)}return r}s(Tc,"parseOptionalProperty");var kc=new Map,_I=s((t,e,r)=>{for(let o of t){let n=o.trim().toLowerCase();if(n==="*")return e;if(n.includes("*.")){let a=n.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*\\\./g,"[^.]+\\.");if(new RegExp(`^${a}$`).test(r))return e}else{let i=n.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*");if(new RegExp(`^${i}$`).test(r))return e}}},"testMatchinOrigin"),zi=s((t,e,r)=>{if(r===null)return;let o=r.trim().toLowerCase(),n=kc.get(t);if(n?.has(o))return r;let i=_I(e,r,o);return i&&(n||kc.set(t,new ji(20)),kc.get(t)?.add(o)),i},"findMatchingOrigin"),Zi=s((t,e)=>{let r={"access-control-allow-origin":e};t.allowedHeaders&&(r["access-control-allow-headers"]=t.allowedHeaders),t.allowedMethods&&(r["access-control-allow-methods"]=t.allowedMethods),t.exposeHeaders&&(r["access-control-expose-headers"]=t.exposeHeaders);let o=t.allowCredentials;o&&(r["access-control-allow-credentials"]=o);let n=t.maxAge?.toString()??void 0;return n&&(r["access-control-max-age"]=n),r},"generateCorsHeaders"),qi=s((t,e)=>{if(!t)return!1;let{developerPortal:r}=e;return r.enabled&&r.type==="zudoku"&&r.urls?r.urls.urls.includes(t):!1},"isDevPortalOrigin");var Ec=s((t,e,r)=>{let o=s(async(a,c)=>{let u=new URL(a.url.toString()).pathname,l=a.headers.get("access-control-request-method"),d=a.headers.get("access-control-request-headers"),p=a.headers.get("origin");if(p===null||l===null)return M.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});if(qi(p,e)){let w={"access-control-allow-origin":p,"access-control-allow-methods":l,"access-control-allow-headers":d??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"};return new Response(void 0,{status:200,statusText:"OK",headers:w})}let m=t.lookup(u,l);if(!m)return M.notFound(a,c);let y=m.routeConfiguration,g=OI({requestedMethod:l,requestedHeaders:d,requestedOrigin:p,routeConfig:y,customPolicies:r});return g.isValid?new Response(void 0,{status:200,statusText:"OK",headers:g.headers}):(g.error&&c.log.warn(g.error),M.notFound(a,c))},"optionsHandler"),n=new He({processors:[lt],handler:o}),i=new Be({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:"cors-preflight"});t.addRoute(i,n.execute)},"registerCorsRoute"),OI=s(({requestedMethod:t,requestedHeaders:e,requestedOrigin:r,routeConfig:o,customPolicies:n})=>{let i={isValid:!1,headers:{}};if(o.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":r,"access-control-allow-methods":t,"access-control-allow-headers":e??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"}};if(o.corsPolicy==="none")return{...i,error:`No CORS policy set for the route '${o.pathPattern}'`};let a=n?.find(l=>l.name===o.corsPolicy);if(!a)throw new R(`Invalid Configuration - corsPolicy '${o.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=zi(a.name,a.allowedOrigins,r);return c?{isValid:!0,headers:Zi(a,c)}:{...i,error:`The CORS policy '${a.name}' does not allow the origin '${r}'`}},"validateAndBuildResponseHeaders");var hy=s(t=>{let e=s(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),r=new He({processors:[lt],handler:e}),o=new Be({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"empty-gateway-catchall"});t.addRoute(o,r.execute)},"registerNoRoutes");var sr=class{static{s(this,"UserRouteConfiguration")}constructor(e){this.path=e.path,this.methods=e.methods,this.label=e.label,this.key=e.key,this.handler=e.handler,this.corsPolicy=e.corsPolicy,this.custom=e.custom,this.mcp=e.mcp,this.policies=e.policies,this.excludeFromOpenApi=e.excludeFromOpenApi,this.pathPattern=e.pathPattern,this.metadata=e.metadata,this.raw=e.raw}raw;get summary(){return this.raw()?.summary}get operationId(){return this.raw()?.operationId}get tags(){return this.raw()?.tags}get parameters(){return this.raw()?.parameters}get responses(){return this.raw()?.responses}label;key;path;excludeFromOpenApi;pathPattern;metadata;custom;mcp;methods;handler;corsPolicy;policies};var AI=new Be({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"unmatched-path"}),yy=s(t=>{let e=s(async(o,n)=>{let i=Ic.value?.notFoundHandler;if(i){let l=new URL(o.url);return i(o,n,{get routesMatchedByPathOnly(){return t.lookupByPathOnly(l.pathname).map(p=>p.routeConfiguration).filter(p=>p instanceof sr)}})}let a=new URL(o.url);return t.lookupByPathOnly(a.pathname).filter(l=>l.routeConfiguration.handler?.export==="mcpServerHandler").length>0&&o.method!=="POST"?M.methodNotAllowed(o,n):M.notFound(o,n)},"notFoundHandler"),r=new He({processors:[lt],handler:e});t.addRoute(AI,r.execute)},"registerNotMatchedHandler");var $I=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],by=s(t=>{$I.forEach(e=>t.delete(e))},"stripCorsHeaders"),Wr=s(async(t,e,r)=>{let o=await r(t);if(T.instance.isDeno&&o.status===101&&[...o.headers.keys()].length===0&&!o.body)return o;let n=e.route,i=t.headers.get("origin"),a=qi(i,Pe.instance.runtimeSettings);if((!n.corsPolicy||n.corsPolicy==="none")&&!a){let p=new Headers(o.headers);return by(p),new Response(o.body,{status:o.status,statusText:o.statusText,headers:p,webSocket:o.webSocket})}if(!(o instanceof Response))throw new ye(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof o}'`);let c=LI(n,Pe.instance.routeData.corsPolicies,a),u=NI(i,c),l=new Headers(o.headers);return by(l),Object.entries(u).forEach(([p,m])=>{l.set(p,m)}),new Response(o.body,{status:o.status,statusText:o.statusText,headers:l,webSocket:o.webSocket})},"corsProcessor"),LI=s((t,e,r)=>{if(t.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};if(r)return{name:"dev-portal-anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let o=e?.find(n=>n.name===t.corsPolicy);if(o===void 0)throw new R(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return o},"getCorsPolicy"),NI=s((t,e)=>{let r=zi(e.name,e.allowedOrigins,t);return r?Zi(e,r):{}},"getCorsHeaders");var Cc=s(t=>{let e=s(async()=>new Response(JSON.stringify({buildId:T.instance.build.BUILD_ID}),{status:200,headers:{"content-type":"application/json"}}),"pingRouteHandler"),r=new He({processors:[Wr],handler:e}),o=new Be({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:"ping"});t.addRoute(o,r.execute)},"registerPingRoute");import{SpanStatusCode as vy,trace as wy}from"@opentelemetry/api";var Ac=class extends ke{static{s(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,r,o){super(r,o),this.policyType=e.name,this.#e=e}handler(e,r){return this.#e(e,r,this.options,this.policyName)}},$c=class extends ir{static{s(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,r,o){super(r,o),this.policyType=e.name,this.#e=e}handler(e,r,o){return this.#e(e,r,o,this.options,this.policyName)}},_c=new Map;function xy(t,e){let[r]=Kr([t],e);if(!r)throw new z("Internal error. Policy not found in cache.");return r}s(xy,"getInboundPolicyInstance");function Kr(t,e){let r,o;return Array.isArray(t)?r=t:(r=t.policies?.inbound??[],o=t.path),r.filter(i=>!_c.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new R(`Invalid state - no Policy with the name '${i}' ${o&&`on route '${o}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export];if(typeof c!="function")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof module '${typeof c}')`);if(c.prototype instanceof ke)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new Ac(c,a.handler.options,a.name);else throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new R(`Invalid state - invalid handler on policy '${i}' on route '${o}' (typeof handler '${typeof u.handler}')`);_c.set(a.name,u)}),r.map(i=>{let a=_c.get(i);if(a===void 0)throw new z("Internal error. Policy not found in cache.");return a})}s(Kr,"getInboundPolicyInstances");var Oc=new Map;function Wn(t,e){let r,o;return Array.isArray(t)?r=t:(r=t.policies?.outbound??[],o=t.path),r.filter(i=>!Oc.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new R(`Invalid state - no Policy with the name '${i}' on route '${o}' was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export],u;if(typeof c!="function")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof module '${typeof c}')`);if(c.prototype instanceof ir)u=new c(a.handler.options??{},a.name);else if(typeof c=="function")u=new $c(c,a.handler.options??{},a.name);else throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new R(`Invalid state - invalid handler on policy '${i}' on route '${o}'`);Oc.set(a.name,u)}),r.map(i=>{let a=Oc.get(i);if(a===void 0)throw new z("Internal error. Policy not found in cache.");return a})}s(Wn,"getOutboundPolicyInstances");var Lc=s(t=>async(e,r)=>{let o=Je.getContextExtensions(r),n=wy.getTracer("pipeline");return await n.startActiveSpan("policies:inbound",async i=>{try{let a=[...t],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;let l=await n.startActiveSpan(`policy:${u.policyName}`,async d=>{let p=await u.handler(c,r);if(p instanceof Request||p instanceof de||p instanceof Response){if(d.end(),p instanceof Response||p instanceof de)return p;{let m=c.user;return new de(p,{user:m})}}else{let m=new R(`Invalid state - invalid handler on policy '${u.policyName}' on route '${r.route.path}. The result of an inbound policy must be a Response or Request.`);throw d.end(),d.setStatus({code:vy.ERROR}),d.recordException(m),m}});if(l instanceof de)c=l;else if(l instanceof Request){let d=c.user;c=new de(l,{user:d})}else if(l instanceof Response)return l;o.latestRequest=c}return c}finally{i.end()}})},"toStackedInboundHandler"),Nc=s(t=>async(e,r,o)=>{let n=wy.getTracer("pipeline");return await n.startActiveSpan("policies:outbound",async i=>{try{let a=[...t],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;c=await n.startActiveSpan(`policy:${u.policyName}`,async d=>{try{d.setAttribute(Bt.PolicyName,u.policyName),d.setAttribute(Bt.PolicyType,u.policyType);let p=await u.handler(c,r,o);if(p instanceof Response)return p;{let m=new R(`Invalid state - invalid handler on policy '${u.policyName}' on route '${o.route.path}. The result of an outbound policy must be a Response.`);throw d.setStatus({code:vy.ERROR}),d.recordException(m),m}}finally{d.end()}})}return c}finally{i.end()}})},"toStackedOutboundHandler"),Fi=s(async(t,e,r)=>{let o=Kr(e.route,Pe.instance.routeData.policies),n=Wn(e.route,Pe.instance.routeData.policies);return MI({request:t,context:e,inboundPolicies:o,outboundPolicies:n,next:r})},"policyProcessor");async function MI({request:t,context:e,inboundPolicies:r,outboundPolicies:o,next:n}){let i=Lc(r);try{let a=await i(t,e);if(a instanceof Response)return a;let c=await n(a),u=Nc(o),l;return T.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?l=u(c,t,e):l=c.ok?u(c,t,e):c,l}catch(a){return Mt(t,e,"Error executing policies",a)}}s(MI,"executePolicyProcessor");var Sy=nI(Py(),1);function Ty(t,e){try{let r=/v\d+(-\d+)?/g,n=(0,Sy.parse)(e.get("Cookie")||"")["zp-dev-portal"];return n!==null&&n&&r.test(n)?`https://dev-portal-${n}.zuplo.com`:t}catch{}return t}s(Ty,"devPortalBaseURL");var ky="/__zuplo/dev-portal",VI="dev-portal-id",JI="dev-portal-host",WI="zp-account",KI="zp-project",QI="dev-portal-build",YI=`
60
+ `)}s(ty,"messagesToMultilineText");function ry(t){return typeof t=="string"?t:JSON.stringify(t)}s(ry,"stringifyNonString");function Oi(t){return typeof t=="string"?t:t===null?"null":typeof t>"u"?"undefined":typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"||typeof t=="symbol"?t.toString():typeof t=="function"?`[function ${t.name}]`:typeof t=="object"&&Array.isArray(t)?`[array ${t.length}]`:t instanceof Error?`${t.name??"Error"}: ${t.message??"unknown"}`:typeof t=="object"?ac(t):"unknown"}s(Oi,"stringifyNonStringToText");var wI={internal:1,trace:2,debug:5,info:9,warn:13,error:17,fatal:21},Ai=s(t=>e=>{let r={};return r.accountName=t.build.ACCOUNT_NAME,r.projectName=t.build.PROJECT_NAME,r.deploymentName=t.deploymentName,r.environmentType=t.loggingEnvironmentStage,r.labels={requestId:e.requestId,source:e.logSource,logOwner:e.logOwner},r.rayId=e.rayId??"",r.runtime={buildId:t.build.BUILD_ID,buildTimestamp:t.build.TIMESTAMP,gitSHA:t.build.GIT_SHA,version:t.build.ZUPLO_VERSION},r.atomicCounter=e.vectorClock,{logId:e.logId,timestamp:e.timestamp,observerdTimestamp:e.timestamp,traceId:e.requestId,severityText:e.level,severityNumber:wI[e.level],body:Nt(e.messages),attributes:r}},"unifiedFormatter");async function me(t,e){if(t.level==="error"&&D.console.error(t.messages),!T.instance.remoteLogURL||!T.instance.loggingId||!T.instance.remoteLogToken)return;let r;try{r=await e?.text()}catch{}try{let o={...t,messages:[...t.messages,...r?[r]:[]],logId:crypto.randomUUID(),logOwner:"user",logSource:"runtime",rayId:null,requestId:`global-${crypto.randomUUID()}`,timestamp:new Date,buildId:T.instance.build.BUILD_ID,loggingId:T.instance.loggingId,vectorClock:0};await ny(T.instance,[o])}catch(o){D.console.error(o)}}s(me,"sendRemoteGlobalLog");async function ny(t,e){let r=Ai(t);try{let o=new Headers({"content-type":"application/json",authentication:`Bearer ${t.remoteLogToken}`});Le(o),await D.fetch(new URL("/v1/runtime-logs",t.remoteLogURL).toString(),{method:"POST",body:JSON.stringify({entries:e.map(r)}),headers:{"content-type":"application/json","user-agent":T.instance.systemUserAgent,"zp-dn":T.instance.deploymentName??"unknown"}})}catch(o){D.console.error(o)}}s(ny,"sendLogs");var xI=s(t=>async e=>{e.length!==0&&await ny(t,e)},"dispatchFunction"),$i,Hn=class{static{s(this,"UnifiedLogTransport")}constructor(e){$i||($i=new ue("unified-log-transport",1,xI(e)))}log(e,r){$i.enqueue(e),r.waitUntil($i.waitUntilFlushed())}};var mc=class extends Ne{constructor(r){super();this.options=r}static{s(this,"GoogleCloudLoggingPlugin")}getTransport(){return new Bn(this.options)}},RI="https://logging.googleapis.com/v2/entries:write?alt=json",fc={error:"ERROR",warn:"WARNING",info:"INFO",debug:"DEBUG"},Bn=class{static{s(this,"GoogleLogTransport")}constructor(e){P("logging.google-cloud"),this.#n=e.logName,this.#e=e.serviceAccountJson,this.#o=T.instance.loggingEnvironmentType,this.#i=T.instance.loggingEnvironmentStage,this.#r=T.instance.deploymentName,this.#s=e.fields??{}}#e;#t;#n;#r;#o;#i;#s;async init(){this.#t=await rt.init(this.#e)}log(e,r){if(!this.#t)throw new ye("Invalid state - Google log transport is not initialized");if(e.messages.length===0)return;let o=Object.assign({allMessages:Nt(e.messages)},this.#s,r.properties??{}),n=this.#t.projectId??"zuplo-production",i={logName:this.#n,resource:{type:"global"},severity:fc[e.level],timestamp:e.timestamp,trace:`projects/${n}/traces/${e.requestId}`,labels:{requestId:e.requestId,buildId:e.buildId,source:e.logSource,loggingId:e.loggingId,logOwner:e.logOwner,environment:this.#r,environmentType:this.#o,environmentStage:this.#i}};e.rayId&&(i.labels.rayId=e.rayId);let a=Hr(o.allMessages);i.jsonPayload={...o,message:a},this.batcher.enqueue(i),r.waitUntil(this.batcher.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length===0)return;this.#t||(this.#t=await rt.init(this.#e));let r=await bt({serviceAccount:this.#t,audience:"https://logging.googleapis.com/google.logging.v2.LoggingServiceV2"});try{let o=await D.fetch(RI,{method:"POST",body:JSON.stringify({entries:e}),headers:{Authorization:`Bearer ${r}`,"content-type":"application/json;charset=UTF-8"}});o.ok||await me({level:"error",messages:[`Failed to send logs to Google: ${o.status} - ${o.statusText}`]},o)}catch{await me({level:"error",messages:["Failed to connect to Google logging service. Check that the URL is correct."]})}},"dispatchFunction");batcher=new ue("google-log-transport",1,this.dispatchFunction)};var bc=class extends Ne{constructor(r){super();this.options=r}static{s(this,"DataDogLoggingPlugin")}getTransport(){return new Gn(this.options)}},gc="__ddtags",hc="__ddattr",yc=s(t=>t.replaceAll(",","_").replaceAll(":","_"),"cleanTagText"),II=s(t=>{let e=Object.keys(t),r=[];return e.forEach(o=>{let n=t[o];n==null?r.push(yc(o)):r.push(`${yc(o)}:${yc(n.toString())}`)}),r.join(",")},"formatTags"),Gn=class{static{s(this,"DataDogTransport")}constructor(e){P("logging.datadog"),this.#e=e.apiKey,this.#t=e.url??"https://http-intake.logs.datadoghq.com/api/v2/logs",this.#r=T.instance.loggingEnvironmentType,this.#o=T.instance.loggingEnvironmentStage,this.#n=T.instance.deploymentName,this.#i=e.fields??{},this.#s=e.tags??{},this.#a=e.source??"Zuplo"}#e;#t;#n;#r;#o;#i;#s;#a;log(e,r){let o=Object.assign({},this.#s),n=Object.assign({},this.#i,r.properties??{}),i=[...e.messages];if(!T.instance.build.COMPATIBILITY_FLAGS.removeLegacyLogInitialization){let l=r.custom[gc];l&&typeof l=="object"&&(P("logging.datadog.legacy-tags"),Object.assign(o,l));let d=e.messages.findIndex(y=>y[gc]!==void 0);d>-1&&(Object.assign(o,i[d][gc]),i.splice(d,1));let p=r.custom[hc];p&&typeof p=="object"&&(P("logging.datadog.legacy-attributes"),Object.assign(n,p));let m=e.messages.findIndex(y=>y[hc]!==void 0);m>-1&&(Object.assign(n,i[m][hc]),i.splice(m,1))}let a=Nt(i),c={...e,activityId:e.requestId,trace:e.requestId},u=Object.assign({message:{...c,messages:a},ddsource:this.#a,hostname:new URL(r.originalRequest.url).hostname,msg:Hr(a),atomic_counter:e.vectorClock,service:e.loggingId,ddtags:II(o),environment:this.#n,environment_type:this.#r,environment_stage:this.#o,ray_id:e.rayId,request_id:e.requestId},n);this.batcher.enqueue(u),r.waitUntil(this.batcher.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length!==0)try{let r=await D.fetch(this.#t,{method:"POST",body:JSON.stringify([...e]),headers:{"content-type":"application/json","DD-API-KEY":this.#e}});r.ok||await me({level:"error",messages:[`Failed to send logs to DataDog: ${r.status} - ${r.statusText}`]},r)}catch{await me({level:"error",messages:["Failed to connect to DataDog logging service. Check that the URL is correct."]})}},"dispatchFunction");batcher=new ue("data-dog-transport",10,this.dispatchFunction)};var Br=class{static{s(this,"LookupResult")}constructor(e,r,o){this.routeConfiguration=e,this.params=o??{},this.executableHandler=r}executableHandler;routeConfiguration;params},Li=class extends Error{static{s(this,"RouterError")}};import{trace as nP}from"@opentelemetry/api";import{SpanStatusCode as PI,trace as SI}from"@opentelemetry/api";function Mt(t,e,r,o){e.log.error(r,o);let n={};if(T.instance.isLocalDevelopment||T.instance.isWorkingCopy)if(o instanceof z&&o.extensionMembers)n=o.extensionMembers;else if(o.cause){let i=Rr(o.cause);"stack"in i&&(i.stack=pc(i.stack)),n={cause:i}}else{let i=Rr(o);"stack"in i&&(i.stack=pc(i.stack)),n={cause:i}}return M.internalServerError(t,e,{detail:o.message,...n})}s(Mt,"errorHandler");import{SpanStatusCode as Mi,trace as Di}from"@opentelemetry/api";var oy=s(t=>(e,r)=>t(e,r),"globalRequestHandlerProxy");function iy(t){oy=t}s(iy,"setTelemetryInitFunction");var sy=s(t=>oy(t),"proxyHandler");var Ic={},Pt=[],vc=[],wc=[],xc=[],Rc=[];var Ni={addPlugin(t){Pt.push(t)},addRequestHook(t){vc.push(t)},addResponseSendingHook(t){wc.push(t)},addResponseSendingFinalHook(t){xc.push(t)},addPreRoutingHook(t){Rc.push(t)}},cy=s(async(t,e)=>{if(vc.length===0)return t;let r=Di.getTracer("extension");return r.startActiveSpan("hook:onRequest",async o=>{try{let n=t;for(let i of vc){let a=await r.startActiveSpan(i.name,async c=>{let u=await i(n,e);if(u instanceof de||u instanceof Response)return c.end(),u;{let l=new R(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof n}.`);throw c.end(),c.recordException(l),c.setStatus({code:Mi.ERROR}),l}});if(a instanceof de)n=a;else return a}return n}finally{o.end()}})},"invokeOnRequestExtensions"),uy=s(async(t,e,r)=>{if(wc.length===0)return t;let o=Di.getTracer("extension"),n=T.instance.build.COMPATIBILITY_FLAGS.chainResponseSendingHooks;return o.startActiveSpan("hook:onResponseSending",async i=>{try{let a=t;for(let c of wc)await o.startActiveSpan(c.name,async u=>{let l=await c(n?a:t,e,r);if(l instanceof Response)a=l,u.end();else{let d=new R(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof a}.`);throw u.recordException(d),u.setStatus({code:Mi.ERROR}),u.end(),d}});return a}finally{i.end()}})},"invokeOnResponseSendingExtensions"),ly=s(async(t,e,r)=>{if(xc.length===0)return;let o=Di.getTracer("extension");return o.startActiveSpan("hook:onResponseSendingFinal",async n=>{try{for(let i of xc)await o.startActiveSpan(i.name,async a=>{try{await i(t,e,r)}catch(c){throw a.recordException(c),a.setStatus({code:Mi.ERROR}),a.end(),c}a.end()})}finally{n.end()}})},"invokeOnResponseSendingFinalExtensions"),dy=s(async t=>{if(Rc.length===0)return t;let e=Di.getTracer("extension");return e.startActiveSpan("hook:preRouting",async r=>{try{let o=t;for(let n of Rc)o=await e.startActiveSpan(n.name,async a=>{try{let c=await n(o);if(c instanceof Request)return c;{let u=new z(`Invalid state - the PreRouting hook must return a Request. Received ${typeof c}.`);throw a.recordException(u),a.setStatus({code:Mi.ERROR}),u}}finally{a.end()}});return o}finally{r.end()}})},"invokePreRoutingHooks"),ay=!1;async function py(t){if(!ay){t&&(P("runtime.extensions"),await t(Ni)),Ic.value=Ni;for(let e of Pt)if(e instanceof wr){let{requestHandlerProxy:r}=e.instrument({accountName:T.instance.build.ACCOUNT_NAME,projectName:T.instance.build.PROJECT_NAME,buildId:T.instance.build.BUILD_ID,zuploVersion:T.instance.build.ZUPLO_VERSION,compatibilityDate:T.instance.build.COMPATIBILITY_DATE,instanceId:T.instance.instanceId,environmentType:T.instance.loggingEnvironmentType,environmentStage:T.instance.loggingEnvironmentStage,deploymentName:T.instance.deploymentName});iy(r)}await Promise.all(Pt.map(async e=>{e instanceof Ue&&await e.initialize(Ni)})),qn.setProblemResponseFormat(Ni.problemResponseFormat),ay=!0}}s(py,"initializeRuntime");function Gr(t){let{developerPortal:e}=Pe.instance.runtimeSettings;return e.enabled&&e.basePath&&t.pathname.startsWith(e.basePath)||t.pathname.startsWith("/__zuplo/")||t.pathname.startsWith("/__/zuplo/")}s(Gr,"isSystemRoute");var He=class{static{s(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=s(e=>async(r,o)=>SI.getTracer("pipeline").startActiveSpan(`handler:${o.route.handler.export}`,async i=>{try{return await e(r,o)}catch(a){let c=Mt(r,o,"Error executing request handler.",a);return i.setStatus({code:PI.ERROR}),c}finally{i.end()}}),"#errorWrappedHandler");#t=s(({processors:e,handler:r})=>async(o,n)=>{let i=Je.getContextExtensions(n),a=[...e],c=s(async g=>{let w=a.pop();if(!w){let x=await this.#e(async I=>{let k=await r(I,n);return TI(k)})(g,n);try{await i.onHandlerResponse(x,g,n)}catch(I){return Mt(o,n,"Error invoking 'context.onHandlerResponse' hook",I)}return x}return w(g,n,c)},"nextPipe"),l=await c(o),d=new URL(o.url);if(Gr(d)&&T.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new Vn(o,l);n.dispatchEvent(p);let m=i.latestRequest,y;try{y=await p.mutableResponse}catch(g){return Mt(o,n,"Error retrieving mutableResponse",g)}try{y=await i.onResponseSending(y,m,n)}catch(g){return Mt(o,n,"Error invoking 'context.onResponseSending' hook",g)}try{y=await uy(y,m,n)}catch(g){return Mt(o,n,"Error invoking 'context.onResponseSending' hook",g)}n.dispatchEvent(new Jn(o,y));try{await i.onResponseSendingFinal(l,m,n)}catch(g){throw n.log.error("Error invoking 'runtime.onResponseSending' hook",g),g}try{await ly(l,m,n)}catch(g){throw n.log.error("Error invoking 'runtime.onResponseSending' hook",g),g}return y},"#toZuploPipeline")};function TI(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response(sc(t),{headers:{"content-type":"application/json"}})}s(TI,"resultToResponse");var vt=class extends or{static{s(this,"MetricsPlugin")}};var B=class t{static{s(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let r=t.#e.get(e);if(!r){let o=`No system logger found for context with requestId '${e.requestId}'`;throw D.console.error(o),new ye(o)}return r}static addLogger(e,r){t.#e.set(e,r)}};var Ui=class{static{s(this,"ZuploMetricsTransport")}#e;#t;constructor(e){this.#e=e,this.#t=new ue("zuplo-metrics-transport",10,this.dispatchFunction,B.getLogger(e))}pushMetrics(e,r){this.#t.enqueue(e),r.waitUntil(this.#t.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length!==0)try{let{remoteLogURL:r,deploymentName:o}=T.instance,{ACCOUNT_NAME:n,PROJECT_NAME:i}=T.instance.build,a=e.map(p=>{let m=Object.assign({},p);return delete m.requestContentLength,delete m.responseContentLength,m}),c=Zh(),u={metadata:{timestamp:new Date,accountName:n,projectName:i,deploymentName:o},metrics:a,features:c},l=new Headers({"content-type":"application/json"});Le(l);let d=await qe({retries:3,retryDelayMs:1e3,logger:D.console},new URL("/v2/runtime/metrics",r).toString(),{method:"POST",body:JSON.stringify(u),headers:l});if(!d.ok){let p=await d.text();B.getLogger(this.#e).error(`Metrics POST responded ${d.status}: ${d.statusText}`,p),qh(c)}}catch(r){B.getLogger(this.#e).error("Failed to send Zuplo metrics.",r)}},"dispatchFunction")};var Vr="SYSTEM_IGNORED";var Be=class{static{s(this,"SystemRouteConfiguration")}constructor({label:e,path:r,methods:o,systemRouteName:n,corsPolicy:i="none"}){this.label=e,this.path=r,this.methods=o,this.corsPolicy=i,this.handler={export:Vr,module:Vr},this.systemRouteName=n}label;path;methods;handler;corsPolicy;policies;systemRouteName;metadata;raw(){return{}}};var Pc="x-real-ip",kI="true-client-ip",EI="cf-connecting-ip",CI="x-forwarded-for";function wt(t){let e=t.headers,r=e.get(Pc)??e.get(kI)??e.get(EI);if(r)return r;let o=e.get(CI);if(o){let n=o.split(/,\s*/).map(i=>i.trim()).find(i=>i.length>0);if(n)return n}}s(wt,"getClientIp");var lt=s(async(t,e,r)=>{let o=new Date,n=Date.now(),i=await r(t),a=t.headers.get(Zr)??void 0,c=wt(t),u=e.incomingRequestProperties,l;e.route instanceof Be&&(l=e.route.systemRouteName);let d=Je.getContextExtensions(e).latestRequest,p={timestamp:o,statusCode:i.status,durationMs:Date.now()-n,requestContentLength:t.headers.get("content-length")?Number(t.headers.get("content-length")):void 0,responseContentLength:i.headers.get("content-length")?Number(i.headers.get("content-length")):void 0,routePath:e.route?.path??"SYSTEM_OR_NOT_FOUND",systemRouteName:l,contextId:e.contextId,parentContextId:e.parentContext?.contextId,requestId:e.requestId,parentRequestId:e.parentContext?.requestId,method:t.method,asn:u.asn,asOrganization:u.asOrganization,colo:u.colo,continent:u.continent,country:u.country,city:u.city,latitude:u.latitude,longitude:u.longitude,rayId:a,instanceId:T.instance.instanceId,userSub:d.user?.sub,clientIp:c},m=[];return!T.instance.isLocalDevelopment&&T.instance.remoteLogURL&&T.instance.remoteLogToken&&T.instance.loggingId&&m.push(new Ui(e)),Pt.forEach(y=>{if(y instanceof vt){let g=y.getTransport();m.push(g)}}),m.forEach(y=>{y.pushMetrics(p,e)}),i},"metricsProcessor");var Sc=s(t=>{let e=s(async(n,i)=>{let a=new URL(n.url),c=T.instance.build,u={buildId:c.BUILD_ID,zuploVersion:c.ZUPLO_VERSION,compatibilityDate:c.COMPATIBILITY_DATE,apiVersion:c.API_VERSION,gitSha:c.GIT_SHA,timestamp:c.TIMESTAMP,isProduction:c.ENVIRONMENT_TYPE==="PRODUCTION"};if(a.searchParams.get("system_log")==="true"&&B.getLogger(i).error("Test System Log",u),a.searchParams.get("error")==="true")throw new Error("this is an unhandled error");return new Response(JSON.stringify(u,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),r=new He({processors:[lt],handler:e}),o=new Be({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:"build-data"});t.addRoute(o,r.execute)},"registerBuildRoute");var ji=class{static{s(this,"BoundedSet")}limit;items;constructor(e){this.limit=e,this.items=new Map}add(e){if(this.items.has(e))this.items.delete(e);else if(this.items.size>=this.limit){let r=this.items.keys().next().value;r&&this.items.delete(r)}this.items.set(e,!0)}has(e){return this.items.has(e)}values(){return Array.from(this.items.keys())}size(){return this.items.size}};var my=new Map;function Dt(t){if(Array.isArray(t)&&!t.some(n=>typeof n!="number"))return t;if(typeof t!="string")throw new Error("Input must be a string or an array of numbers");if(!/^\d+(?:-\d+)?(?:,\s*\d+(?:-\d+)?)*$/.test(t))throw new R("Malformed input string");let e=my.get(t);if(e)return e;let r=t.split(","),o=[];for(let n of r){let i=n.split("-");if(i.length===2){let a=parseInt(i[0],10),c=parseInt(i[1],10);for(let u=a;u<=c;u++)o.push(u)}else o.push(parseInt(n,10))}return my.set(t,o),o}s(Dt,"statusCodesStringToNumberArray");function Gt(t,e,r){if(!e.startsWith("."))throw new R(`Invalid ${r} - must start with '.' - '${e}' does not`);let o=e.split(".").splice(1),n=t;return o.forEach(i=>{if(n===void 0)throw new z(`Error applying ${r} '${e}', reading '${i}'`);n=n[i]}),`${n}`}s(Gt,"getValueFromRequestUser");function fy(t,e){if(!e.startsWith("."))throw new R(`Invalid selector. must start with '.' - '${e}' does not`);let r=e.split(".").splice(1),o=t;return r.forEach(n=>{if(o===void 0)throw new z(`Error applying'${e}', reading '${n}'`);if(o&&typeof o=="object")o=Reflect.get(o,n);else throw new z(`Error applying'${e}', reading '${n}'`)}),`${o}`}s(fy,"selectPropertyUsingJsonPath");function Ir(t){if(Array.isArray(t)){if(t.includes(r=>typeof r!="string"))throw new R("Received an array that contains non-string values.");return t}if(Lt(t))return t.includes(",")?t.split(",").map(r=>r.trim()).filter(r=>r!==","&&r!==""):[t];throw new R(`Expected type of string, received type '${typeof t}'`)}s(Ir,"parseValueToStringArray");function gy(t){if(t==null)return[];if(!Array.isArray(t))throw new R(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(r=>{if(!xr(r))throw new R(`Invalid custom cors policy is set. Expected an object, received '${typeof r}'`);if(!Bh(r.name))throw new R("Value of 'name' on custom cors policies must be a non-empty string.");if(r.maxAge!==void 0&&!cc(r.maxAge))throw new R(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof r.maxAge}'`);if(r.allowCredentials!==void 0&&!uc(r.allowCredentials))throw new R("Value of 'allowCredentials' on custom cors policies must be a boolean or not be set. If using an environment variable, check that it is set correctly.");let o=Tc(r,"allowedHeaders"),n=Tc(r,"allowedMethods"),i=Tc(r,"exposeHeaders"),a;try{a=Ir(r.allowedOrigins)}catch(u){throw new R(`Value of 'allowedOrigins' on custom cors policies is invalid. ${u.message} If using an environment variable, check that it is set correctly.`)}return{name:r.name,allowCredentials:typeof r.allowCredentials=="boolean"?String(r.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:o?o.join(", "):void 0,allowedMethods:n?n.join(", "):void 0,exposeHeaders:i?i.join(", "):void 0,maxAge:typeof r.maxAge=="number"?r.maxAge.toString():void 0}})}s(gy,"parseCorsPolicies");function Tc(t,e){let r;if(t[e]!==void 0)try{r=Ir(t[e])}catch(o){throw new R(`Value of '${e}' on custom cors policies is invalid. ${o.message} If using an environment variable, check that it is set correctly.`)}return r}s(Tc,"parseOptionalProperty");var kc=new Map,_I=s((t,e,r)=>{for(let o of t){let n=o.trim().toLowerCase();if(n==="*")return e;if(n.includes("*.")){let a=n.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*\\\./g,"[^.]+\\.");if(new RegExp(`^${a}$`).test(r))return e}else{let i=n.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*");if(new RegExp(`^${i}$`).test(r))return e}}},"testMatchinOrigin"),zi=s((t,e,r)=>{if(r===null)return;let o=r.trim().toLowerCase(),n=kc.get(t);if(n?.has(o))return r;let i=_I(e,r,o);return i&&(n||kc.set(t,new ji(20)),kc.get(t)?.add(o)),i},"findMatchingOrigin"),Zi=s((t,e)=>{let r={"access-control-allow-origin":e};t.allowedHeaders&&(r["access-control-allow-headers"]=t.allowedHeaders),t.allowedMethods&&(r["access-control-allow-methods"]=t.allowedMethods),t.exposeHeaders&&(r["access-control-expose-headers"]=t.exposeHeaders);let o=t.allowCredentials;o&&(r["access-control-allow-credentials"]=o);let n=t.maxAge?.toString()??void 0;return n&&(r["access-control-max-age"]=n),r},"generateCorsHeaders"),qi=s((t,e)=>{if(!t)return!1;let{developerPortal:r}=e;return r.enabled&&r.type==="zudoku"&&r.urls?r.urls.urls.includes(t):!1},"isDevPortalOrigin");var Ec=s((t,e,r)=>{let o=s(async(a,c)=>{let u=new URL(a.url.toString()).pathname,l=a.headers.get("access-control-request-method"),d=a.headers.get("access-control-request-headers"),p=a.headers.get("origin");if(p===null||l===null)return M.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});if(qi(p,e)){let w={"access-control-allow-origin":p,"access-control-allow-methods":l,"access-control-allow-headers":d??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"};return new Response(void 0,{status:200,statusText:"OK",headers:w})}let m=t.lookup(u,l);if(!m)return M.notFound(a,c);let y=m.routeConfiguration,g=OI({requestedMethod:l,requestedHeaders:d,requestedOrigin:p,routeConfig:y,customPolicies:r});return g.isValid?new Response(void 0,{status:200,statusText:"OK",headers:g.headers}):(g.error&&c.log.warn(g.error),M.notFound(a,c))},"optionsHandler"),n=new He({processors:[lt],handler:o}),i=new Be({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:"cors-preflight"});t.addRoute(i,n.execute)},"registerCorsRoute"),OI=s(({requestedMethod:t,requestedHeaders:e,requestedOrigin:r,routeConfig:o,customPolicies:n})=>{let i={isValid:!1,headers:{}};if(o.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":r,"access-control-allow-methods":t,"access-control-allow-headers":e??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"}};if(o.corsPolicy==="none")return{...i,error:`No CORS policy set for the route '${o.pathPattern}'`};let a=n?.find(l=>l.name===o.corsPolicy);if(!a)throw new R(`Invalid Configuration - corsPolicy '${o.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=zi(a.name,a.allowedOrigins,r);return c?{isValid:!0,headers:Zi(a,c)}:{...i,error:`The CORS policy '${a.name}' does not allow the origin '${r}'`}},"validateAndBuildResponseHeaders");var hy=s(t=>{let e=s(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),r=new He({processors:[lt],handler:e}),o=new Be({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"empty-gateway-catchall"});t.addRoute(o,r.execute)},"registerNoRoutes");var sr=class{static{s(this,"UserRouteConfiguration")}constructor(e){this.path=e.path,this.methods=e.methods,this.label=e.label,this.key=e.key,this.handler=e.handler,this.corsPolicy=e.corsPolicy,this.custom=e.custom,this.mcp=e.mcp,this.policies=e.policies,this.excludeFromOpenApi=e.excludeFromOpenApi,this.pathPattern=e.pathPattern,this.metadata=e.metadata,this.raw=e.raw}raw;get summary(){return this.raw()?.summary}get operationId(){return this.raw()?.operationId}get tags(){return this.raw()?.tags}get parameters(){return this.raw()?.parameters}get responses(){return this.raw()?.responses}label;key;path;excludeFromOpenApi;pathPattern;metadata;custom;mcp;methods;handler;corsPolicy;policies};var AI=new Be({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"unmatched-path"}),yy=s(t=>{let e=s(async(o,n)=>{let i=Ic.value?.notFoundHandler;if(i){let l=new URL(o.url);return i(o,n,{get routesMatchedByPathOnly(){return t.lookupByPathOnly(l.pathname).map(p=>p.routeConfiguration).filter(p=>p instanceof sr)}})}let a=new URL(o.url);return t.lookupByPathOnly(a.pathname).filter(l=>l.routeConfiguration.handler?.export==="mcpServerHandler").length>0&&o.method!=="POST"?M.methodNotAllowed(o,n):M.notFound(o,n)},"notFoundHandler"),r=new He({processors:[lt],handler:e});t.addRoute(AI,r.execute)},"registerNotMatchedHandler");var $I=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],by=s(t=>{$I.forEach(e=>t.delete(e))},"stripCorsHeaders"),Wr=s(async(t,e,r)=>{let o=await r(t);if(T.instance.isDeno&&o.status===101&&[...o.headers.keys()].length===0&&!o.body)return o;let n=e.route,i=t.headers.get("origin"),a=qi(i,Pe.instance.runtimeSettings);if((!n.corsPolicy||n.corsPolicy==="none")&&!a){let p=new Headers(o.headers);return by(p),new Response(o.body,{status:o.status,statusText:o.statusText,headers:p,webSocket:o.webSocket})}if(!(o instanceof Response))throw new ye(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof o}'`);let c=LI(n,Pe.instance.routeData.corsPolicies,a),u=NI(i,c),l=new Headers(o.headers);return by(l),Object.entries(u).forEach(([p,m])=>{l.set(p,m)}),new Response(o.body,{status:o.status,statusText:o.statusText,headers:l,webSocket:o.webSocket})},"corsProcessor"),LI=s((t,e,r)=>{if(t.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};if(r)return{name:"dev-portal-anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let o=e?.find(n=>n.name===t.corsPolicy);if(o===void 0)throw new R(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return o},"getCorsPolicy"),NI=s((t,e)=>{let r=zi(e.name,e.allowedOrigins,t);return r?Zi(e,r):{}},"getCorsHeaders");var Cc=s(t=>{let e=s(async()=>new Response(JSON.stringify({buildId:T.instance.build.BUILD_ID}),{status:200,headers:{"content-type":"application/json"}}),"pingRouteHandler"),r=new He({processors:[Wr],handler:e}),o=new Be({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:"ping"});t.addRoute(o,r.execute)},"registerPingRoute");import{SpanStatusCode as vy,trace as wy}from"@opentelemetry/api";var Ac=class extends ke{static{s(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,r,o){super(r,o),this.policyType=e.name,this.#e=e}handler(e,r){return this.#e(e,r,this.options,this.policyName)}},$c=class extends ir{static{s(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,r,o){super(r,o),this.policyType=e.name,this.#e=e}handler(e,r,o){return this.#e(e,r,o,this.options,this.policyName)}},_c=new Map;function xy(t,e){let[r]=Kr([t],e);if(!r)throw new z("Internal error. Policy not found in cache.");return r}s(xy,"getInboundPolicyInstance");function Kr(t,e){let r,o;return Array.isArray(t)?r=t:(r=t.policies?.inbound??[],o=t.path),r.filter(i=>!_c.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new R(`Invalid state - no Policy with the name '${i}' ${o&&`on route '${o}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export];if(typeof c!="function")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof module '${typeof c}')`);if(c.prototype instanceof ke)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new Ac(c,a.handler.options,a.name);else throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new R(`Invalid state - invalid handler on policy '${i}' on route '${o}' (typeof handler '${typeof u.handler}')`);_c.set(a.name,u)}),r.map(i=>{let a=_c.get(i);if(a===void 0)throw new z("Internal error. Policy not found in cache.");return a})}s(Kr,"getInboundPolicyInstances");var Oc=new Map;function Wn(t,e){let r,o;return Array.isArray(t)?r=t:(r=t.policies?.outbound??[],o=t.path),r.filter(i=>!Oc.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new R(`Invalid state - no Policy with the name '${i}' on route '${o}' was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export],u;if(typeof c!="function")throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof module '${typeof c}')`);if(c.prototype instanceof ir)u=new c(a.handler.options??{},a.name);else if(typeof c=="function")u=new $c(c,a.handler.options??{},a.name);else throw new R(`Invalid state - invalid policy '${i}' on route '${o}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new R(`Invalid state - invalid handler on policy '${i}' on route '${o}'`);Oc.set(a.name,u)}),r.map(i=>{let a=Oc.get(i);if(a===void 0)throw new z("Internal error. Policy not found in cache.");return a})}s(Wn,"getOutboundPolicyInstances");var Lc=s(t=>async(e,r)=>{let o=Je.getContextExtensions(r),n=wy.getTracer("pipeline");return await n.startActiveSpan("policies:inbound",async i=>{try{let a=[...t],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;let l=await n.startActiveSpan(`policy:${u.policyName}`,async d=>{let p=await u.handler(c,r);if(p instanceof Request||p instanceof de||p instanceof Response){if(d.end(),p instanceof Response||p instanceof de)return p;{let m=c.user;return new de(p,{user:m})}}else{let m=new R(`Invalid state - invalid handler on policy '${u.policyName}' on route '${r.route.path}. The result of an inbound policy must be a Response or Request.`);throw d.end(),d.setStatus({code:vy.ERROR}),d.recordException(m),m}});if(l instanceof de)c=l;else if(l instanceof Request){let d=c.user;c=new de(l,{user:d})}else if(l instanceof Response)return l;o.latestRequest=c}return c}finally{i.end()}})},"toStackedInboundHandler"),Nc=s(t=>async(e,r,o)=>{let n=wy.getTracer("pipeline");return await n.startActiveSpan("policies:outbound",async i=>{try{let a=[...t],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;c=await n.startActiveSpan(`policy:${u.policyName}`,async d=>{try{d.setAttribute(Bt.PolicyName,u.policyName),d.setAttribute(Bt.PolicyType,u.policyType);let p=await u.handler(c,r,o);if(p instanceof Response)return p;{let m=new R(`Invalid state - invalid handler on policy '${u.policyName}' on route '${o.route.path}. The result of an outbound policy must be a Response.`);throw d.setStatus({code:vy.ERROR}),d.recordException(m),m}}finally{d.end()}})}return c}finally{i.end()}})},"toStackedOutboundHandler"),Fi=s(async(t,e,r)=>{let o=Kr(e.route,Pe.instance.routeData.policies),n=Wn(e.route,Pe.instance.routeData.policies);return MI({request:t,context:e,inboundPolicies:o,outboundPolicies:n,next:r})},"policyProcessor");async function MI({request:t,context:e,inboundPolicies:r,outboundPolicies:o,next:n}){let i=Lc(r);try{let a=await i(t,e);if(a instanceof Response)return a;let c=await n(a),u=Nc(o),l;return T.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?l=u(c,t,e):l=c.ok?u(c,t,e):c,l}catch(a){return Mt(t,e,"Error executing policies",a)}}s(MI,"executePolicyProcessor");var Sy=nI(Py(),1);function Ty(t,e){try{let r=/v\d+(-\d+)?/g,n=(0,Sy.parse)(e.get("Cookie")||"")["zp-dev-portal"];return n!==null&&n&&r.test(n)?`https://dev-portal-${n}.zuplo.com`:t}catch{}return t}s(Ty,"devPortalBaseURL");var ky="/__zuplo/dev-portal",VI="dev-portal-id",JI="dev-portal-host",WI="zp-account",KI="zp-project",QI="dev-portal-build",YI=`
61
61
  <!DOCTYPE html>
62
62
  <html lang="en">
63
63
  <head>
@@ -313,6 +313,6 @@ Signature verification is impossible without access to the original signed mater
313
313
  `)}s(x,"buildSignedData"),ee(x,"buildSignedData");var I="./well-known/http-message-signatures-directory",k=(G=>(G.HTTP_MESSAGE_SIGNATURES_DIRECTORY="application/http-message-signatures-directory",G))(k||{});function C(G,ie){let F=ie.indexOf("=");if(F===-1)return[ie.trim(),!0];let X=ie.slice(0,F),Y=ie.slice(F+1).trim();if(X.length===0)throw new Error(`Invalid ${G} header. Invalid value ${ie}`);if(Y.match(/^".*"$/))return[X.trim(),Y.slice(1,-1)];if(Y.match(/^\d+$/))return[X.trim(),parseInt(Y)];if(Y.match(/^\(.*\)$/)){let he=Y.slice(1,-1).split(/\s+/).map(Te=>{var ve;return((ve=Te.match(/^"(.*)"$/))==null?void 0:ve[1])??parseInt(Te)});if(he.some(Te=>typeof Te=="number"&&isNaN(Te)))throw new Error(`Invalid ${G} header. Invalid value ${X}=${Y}`);return[X.trim(),he]}throw new Error(`Invalid ${G} header. Invalid value ${X}=${Y}`)}s(C,"parseEntry"),ee(C,"parseEntry");function A(G,ie){var F;let X=(F=ie.toString().match(/(?:[^;"]+|"[^"]+")+/g))==null?void 0:F.map(Ye=>C(G,Ye.trim()));if(!X)throw new Error(`Invalid ${G} header. Invalid value`);let Y=X.findIndex(([,Ye])=>Array.isArray(Ye));if(Y===-1)throw new Error(`Invalid ${G} header. Missing components`);let[[he,Te]]=X.splice(Y,1);if(X.some(([,Ye])=>Array.isArray(Ye)))throw new Error("Multiple signatures is not supported");let ve=Object.fromEntries(X);return typeof ve.created=="number"&&(ve.created=new Date(ve.created*1e3)),typeof ve.expires=="number"&&(ve.expires=new Date(ve.expires*1e3)),{key:he,components:Te,parameters:ve}}s(A,"parseParametersHeader"),ee(A,"parseParametersHeader");function Z(G){return A("Signature-Input",G)}s(Z,"parseSignatureInputHeader"),ee(Z,"parseSignatureInputHeader");function V(G){return A("Accept-Signature",G)}s(V,"parseAcceptSignatureHeader"),ee(V,"parseAcceptSignatureHeader");function Q(G,ie){let F=ie.toString().match(/^([\w-]+)=:([A-Za-z0-9+/=]+):$/);if(!F)throw new Error("Invalid Signature header");let[,X,Y]=F;if(X!==G)throw new Error(`Invalid Signature header. Key mismatch ${X} !== ${G}`);return m(Y)}s(Q,"parseSignatureHeader"),ee(Q,"parseSignatureHeader");var te=["@method","@path","@query","@authority","content-type","digest"],re=["@status","content-type","digest"];async function se(G,ie){let{signer:F,components:X,key:Y,...he}=ie,Te=X??("status"in G?re:te),ve=Y??"sig1",Ye={created:new Date,keyid:F.keyid,alg:F.alg,...he},$t=v(Te,Ye),yt=x(G,Te,$t),nr=await F.sign(yt),Dr=p(nr);return{Signature:`${ve}=:${Dr}:`,"Signature-Input":`${ve}=${$t}`}}s(se,"signatureHeaders2"),ee(se,"signatureHeaders");function Ee(G,ie){let{signer:F,components:X,key:Y,...he}=ie,Te=X??("status"in G?re:te),ve=Y??"sig1",Ye={created:new Date,keyid:F.keyid,alg:F.alg,...he},$t=v(Te,Ye),yt=x(G,Te,$t),nr=F.signSync(yt),Dr=p(nr);return{Signature:`${ve}=:${Dr}:`,"Signature-Input":`${ve}=${$t}`}}s(Ee,"signatureHeadersSync2"),ee(Ee,"signatureHeadersSync");async function Ve(G,ie){let F=y(G,"signature-input");if(!F)throw new Error("Message does not contain Signature-Input header");let{key:X,components:Y,parameters:he}=Z(F);if(he.expires&&he.expires<new Date)throw new Error("Signature expired");let Te=y(G,"signature");if(!Te)throw new Error("Message does not contain Signature header");let ve=Q(X,Te),Ye=F.toString().replace(/^[^=]+=/,""),$t=x(G,Y,Ye);return ie($t,ve,he)}s(Ve,"verify2"),ee(Ve,"verify")}}),zR=Bg({"node_modules/jsonwebkey-thumbprint/dist/index.js"(t,e){var r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=ee((m,y)=>{for(var g in y)r(m,g,{get:y[g],enumerable:!0})},"__export"),c=ee((m,y,g,w)=>{if(y&&typeof y=="object"||typeof y=="function")for(let v of n(y))!i.call(m,v)&&v!==g&&r(m,v,{get:ee(()=>y[v],"get"),enumerable:!(w=o(y,v))||w.enumerable});return m},"__copyProps"),u=ee(m=>c(r({},"__esModule",{value:!0}),m),"__toCommonJS"),l={};a(l,{jwkThumbprint:ee(()=>p,"jwkThumbprint"),jwkThumbprintPreCompute:ee(()=>d,"jwkThumbprintPreCompute")}),e.exports=u(l);var d=ee(m=>{let y=new TextEncoder;switch(m.kty){case"EC":return y.encode(`{"crv":"${m.crv}","kty":"EC","x":"${m.x}","y":"${m.y}"}`);case"OKP":return y.encode(`{"crv":"${m.crv}","kty":"OKP","x":"${m.x}"}`);case"RSA":return y.encode(`{"e":"${m.e}","kty":"RSA","n":"${m.n}"}`);default:throw new Error("Unsupported key type")}},"jwkThumbprintPreCompute"),p=ee(async(m,y,g)=>{let w=d(m),v=await y(w);return g(v)},"jwkThumbprint")}}),QA=Bg({"node_modules/web-bot-auth/dist/index.js"(t,e){var r=Object.create,o=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,u=ee((F,X)=>{for(var Y in X)o(F,Y,{get:X[Y],enumerable:!0})},"__export"),l=ee((F,X,Y,he)=>{if(X&&typeof X=="object"||typeof X=="function")for(let Te of i(X))!c.call(F,Te)&&Te!==Y&&o(F,Te,{get:ee(()=>X[Te],"get"),enumerable:!(he=n(X,Te))||he.enumerable});return F},"__copyProps"),d=ee((F,X,Y)=>(Y=F!=null?r(a(F)):{},l(X||!F||!F.__esModule?o(Y,"default",{value:F,enumerable:!0}):Y,F)),"__toESM"),p=ee(F=>l(o({},"__esModule",{value:!0}),F),"__toCommonJS"),m={};u(m,{HTTP_MESSAGE_SIGNAGURE_TAG:ee(()=>Z,"HTTP_MESSAGE_SIGNAGURE_TAG"),HTTP_MESSAGE_SIGNATURES_DIRECTORY:ee(()=>g.HTTP_MESSAGE_SIGNATURES_DIRECTORY,"HTTP_MESSAGE_SIGNATURES_DIRECTORY"),MediaType:ee(()=>g.MediaType,"MediaType"),NONCE_LENGTH_IN_BYTES:ee(()=>re,"NONCE_LENGTH_IN_BYTES"),REQUEST_COMPONENTS:ee(()=>te,"REQUEST_COMPONENTS"),REQUEST_COMPONENTS_WITHOUT_SIGNATURE_AGENT:ee(()=>Q,"REQUEST_COMPONENTS_WITHOUT_SIGNATURE_AGENT"),SIGNATURE_AGENT_HEADER:ee(()=>V,"SIGNATURE_AGENT_HEADER"),generateNonce:ee(()=>se,"generateNonce"),helpers:ee(()=>A,"helpers"),jwkToKeyID:ee(()=>w.jwkThumbprint,"jwkToKeyID"),signatureHeaders:ee(()=>Ve,"signatureHeaders"),signatureHeadersSync:ee(()=>G,"signatureHeadersSync"),validateNonce:ee(()=>Ee,"validateNonce"),verify:ee(()=>ie,"verify")}),e.exports=p(m);var y=d(jR()),g=jR(),w=zR();function v(F){return btoa(String.fromCharCode(...F))}s(v,"u8ToB64"),ee(v,"u8ToB64");function x(F){return Uint8Array.from(atob(F),X=>X.charCodeAt(0))}s(x,"b64Tou8"),ee(x,"b64Tou8");function I(F){return F.replace(/\+/g,"-").replace(/\//g,"_")}s(I,"b64ToB64URL"),ee(I,"b64ToB64URL");function k(F){return F.replace(/=/g,"")}s(k,"b64ToB64NoPadding"),ee(k,"b64ToB64NoPadding");var C=zR(),A={WEBCRYPTO_SHA256:ee(F=>crypto.subtle.digest("SHA-256",F),"WEBCRYPTO_SHA256"),BASE64URL_DECODE:ee(F=>I(k(v(new Uint8Array(F)))),"BASE64URL_DECODE")},Z="web-bot-auth",V="signature-agent",Q=["@authority"],te=["@authority",V],re=64;function se(){let F=new Uint8Array(re);return crypto.getRandomValues(F),v(F)}s(se,"generateNonce"),ee(se,"generateNonce");function Ee(F){try{return x(F).length===re}catch{return!1}}s(Ee,"validateNonce"),ee(Ee,"validateNonce");function Ve(F,X,Y){if(Y.created.getTime()>Y.expires.getTime())throw new Error("created should happen before expires");let he=Y.nonce;if(!he)he=se();else if(!Ee(he))throw new Error("nonce is not a valid uint32");let Te=y.extractHeader(F,V),ve=te;return Te||(ve=Q),y.signatureHeaders(F,{signer:X,components:ve,created:Y.created,expires:Y.expires,nonce:he,keyid:X.keyid,key:Y.key,tag:Z})}s(Ve,"signatureHeaders2"),ee(Ve,"signatureHeaders2");function G(F,X,Y){if(Y.created.getTime()>Y.expires.getTime())throw new Error("created should happen before expires");let he=Y.nonce;if(!he)he=se();else if(!Ee(he))throw new Error("nonce is not a valid uint32");let Te=y.extractHeader(F,V),ve=te;return Te||(ve=Q),y.signatureHeadersSync(F,{signer:X,components:ve,created:Y.created,expires:Y.expires,nonce:he,keyid:X.keyid,tag:Z})}s(G,"signatureHeadersSync2"),ee(G,"signatureHeadersSync2");function ie(F,X){let Y=ee((he,Te,ve)=>{if(ve.tag!==Z)throw new Error(`tag must be '${Z}'`);if(ve.created.getTime()>Date.now())throw new Error("created in the future");if(ve.expires.getTime()<Date.now())throw new Error("signature has expired");if(ve.keyid===void 0)throw new Error("keyid MUST be defined");let Ye={keyid:ve.keyid,created:ve.created,expires:ve.expires,tag:ve.tag,nonce:ve.nonce};return X(he,Te,Ye)},"v");return y.verify(F,Y)}s(ie,"verify2"),ee(ie,"verify2")}}),Mr=QA();var YA=Mr.verify,aoe=Mr.signatureHeaders,coe=Mr.signatureHeadersSync,ZR=YA;var uoe=Mr.generateNonce,loe=Mr.validateNonce,doe=Mr.Algorithm;var ct=class extends Error{constructor(r,o=401,n){super(r);this.status=o;this.botId=n;this.name="BotAuthenticationError"}static{s(this,"BotAuthenticationError")}};async function XA(t,e,r,o,n,i){try{let a=await D.fetch(o);if(!a.ok)throw new ct(`Failed to fetch directory: ${a.status}`,500);let u=(await a.json())[t];if(!u)throw new ct(`Bot ${t} not found in directory`,403,t);n.log.info(`${i}: Bot ${t} found in directory`);let l=await crypto.subtle.importKey("jwk",u,{name:"Ed25519"},!0,["verify"]),d=new TextEncoder().encode(e);if(!await crypto.subtle.verify({name:"Ed25519"},l,r,d))throw new ct("Invalid signature",401,t)}catch(a){throw a instanceof ct?a:(n.log.error(`${i}: Error verifying signature: ${a}`),new ct(`Error verifying signature: ${a.message}`,500,t))}}s(XA,"verifyWithDirectory");async function qR(t,e,r,o){let n=t.headers.get("Signature"),i=t.headers.get("Signature-Input");if(!n||!i)throw new ct("Bot authentication required");try{let a;async function c(u,l,d){let p=d.keyid;if(a=p,!e.allowedBots.includes(p)&&e.blockUnknownBots)throw new ct(`Bot ${p} is not in the allowed list`,403,p);r.log.info(`${o}: Verifying signature for bot ${p}`),e.directoryUrl?await XA(p,u,l,e.directoryUrl,r,o):r.log.info(`${o}: No directory URL provided, using default verification`),r.log.info(`${o}: Bot ${p} authenticated successfully`)}if(s(c,"verifySignature"),await ZR(t,c),!a)throw new ct("Could not extract bot ID from signature");return a}catch(a){throw a instanceof ct?a:new ct(`Bot authentication failed: ${a.message}`)}}s(qR,"verifyBotSignature");var e$=Symbol("botId"),t$=new fe(e$);var r$=s(async(t,e,r,o)=>{P("policy.inbound.web-bot-auth");let n=t.headers.get("Signature"),i=t.headers.get("Signature-Input");if(!n||!i)return r.allowUnauthenticatedRequests?(e.log.info(`${o}: No bot signature found, allowing unauthenticated request`),t):(e.log.warn(`${o}: No bot signature found, rejecting request`),new Response("Bot authentication required",{status:401}));try{let a=await qR(t,r,e,o);return t$.set(e,a),t}catch(a){return a instanceof ct?(e.log.error(`${o}: Bot authentication failed: ${a.message}`),new Response(`Bot authentication failed: ${a.message}`,{status:a.status})):(e.log.error(`${o}: Bot authentication failed: ${a}`),new Response(`Bot authentication failed: ${a.message}`,{status:401}))}},"WebBotAuthInboundPolicy");var FR=s(t=>{var e=Object.defineProperty,r=s((f,b)=>e(f,"name",{value:b,configurable:!0}),"__name"),o={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:r(function(f,b){return b},"tagValueProcessor"),attributeValueProcessor:r(function(f,b){return b},"attributeValueProcessor"),stopNodes:[],alwaysCreateTextNode:!1,isArray:r(()=>!1,"isArray"),commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:r(function(f,b,S){return f},"updateTag"),captureMetaData:!1};function n(f){return typeof f=="boolean"?{enabled:f,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof f=="object"&&f!==null?{enabled:f.enabled!==!1,maxEntitySize:f.maxEntitySize??1e4,maxExpansionDepth:f.maxExpansionDepth??10,maxTotalExpansions:f.maxTotalExpansions??1e3,maxExpandedLength:f.maxExpandedLength??1e5,allowedTags:f.allowedTags??null,tagFilter:f.tagFilter??null}:n(!0)}s(n,"normalizeProcessEntities"),r(n,"normalizeProcessEntities");var i=r(function(f){let b=Object.assign({},o,f);return b.processEntities=n(b.processEntities),b},"buildOptions"),a=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",c=a+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",u="["+a+"]["+c+"]*",l=new RegExp("^"+u+"$");function d(f,b){let S=[],_=b.exec(f);for(;_;){let $=[];$.startIndex=b.lastIndex-_[0].length;let O=_.length;for(let U=0;U<O;U++)$.push(_[U]);S.push($),_=b.exec(f)}return S}s(d,"getAllMatches"),r(d,"getAllMatches");var p=r(function(f){let b=l.exec(f);return!(b===null||typeof b>"u")},"isName");function m(f){return typeof f<"u"}s(m,"isExist"),r(m,"isExist");var y;typeof Symbol!="function"?y="@@xmlMetadata":y=Symbol("XML Node Metadata");var g=class{static{s(this,"XmlNode")}static{r(this,"XmlNode")}constructor(f){this.tagname=f,this.child=[],this[":@"]={}}add(f,b){f==="__proto__"&&(f="#__proto__"),this.child.push({[f]:b})}addChild(f,b){f.tagname==="__proto__"&&(f.tagname="#__proto__"),f[":@"]&&Object.keys(f[":@"]).length>0?this.child.push({[f.tagname]:f.child,":@":f[":@"]}):this.child.push({[f.tagname]:f.child}),b!==void 0&&(this.child[this.child.length-1][y]={startIndex:b})}static getMetaDataSymbol(){return y}},w=class{static{s(this,"DocTypeReader")}static{r(this,"DocTypeReader")}constructor(f){this.suppressValidationErr=!f,this.options=f}readDocType(f,b){let S={};if(f[b+3]==="O"&&f[b+4]==="C"&&f[b+5]==="T"&&f[b+6]==="Y"&&f[b+7]==="P"&&f[b+8]==="E"){b=b+9;let _=1,$=!1,O=!1,U="";for(;b<f.length;b++)if(f[b]==="<"&&!O){if($&&x(f,"!ENTITY",b)){b+=7;let oe,q;if([oe,q,b]=this.readEntityExp(f,b+1,this.suppressValidationErr),q.indexOf("&")===-1){let j=oe.replace(/[.\-+*:]/g,"\\.");S[oe]={regx:RegExp(`&${j};`,"g"),val:q}}}else if($&&x(f,"!ELEMENT",b)){b+=8;let{index:oe}=this.readElementExp(f,b+1);b=oe}else if($&&x(f,"!ATTLIST",b))b+=8;else if($&&x(f,"!NOTATION",b)){b+=9;let{index:oe}=this.readNotationExp(f,b+1,this.suppressValidationErr);b=oe}else if(x(f,"!--",b))O=!0;else throw new Error("Invalid DOCTYPE");_++,U=""}else if(f[b]===">"){if(O?f[b-1]==="-"&&f[b-2]==="-"&&(O=!1,_--):_--,_===0)break}else f[b]==="["?$=!0:U+=f[b];if(_!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:S,i:b}}readEntityExp(f,b){b=v(f,b);let S="";for(;b<f.length&&!/\s/.test(f[b])&&f[b]!=='"'&&f[b]!=="'";)S+=f[b],b++;if(I(S),b=v(f,b),!this.suppressValidationErr){if(f.substring(b,b+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(f[b]==="%")throw new Error("Parameter entities are not supported")}let _="";if([b,_]=this.readIdentifierVal(f,b,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize&&_.length>this.options.maxEntitySize)throw new Error(`Entity "${S}" size (${_.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return b--,[S,_,b]}readNotationExp(f,b){b=v(f,b);let S="";for(;b<f.length&&!/\s/.test(f[b]);)S+=f[b],b++;!this.suppressValidationErr&&I(S),b=v(f,b);let _=f.substring(b,b+6).toUpperCase();if(!this.suppressValidationErr&&_!=="SYSTEM"&&_!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${_}"`);b+=_.length,b=v(f,b);let $=null,O=null;if(_==="PUBLIC")[b,$]=this.readIdentifierVal(f,b,"publicIdentifier"),b=v(f,b),(f[b]==='"'||f[b]==="'")&&([b,O]=this.readIdentifierVal(f,b,"systemIdentifier"));else if(_==="SYSTEM"&&([b,O]=this.readIdentifierVal(f,b,"systemIdentifier"),!this.suppressValidationErr&&!O))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:S,publicIdentifier:$,systemIdentifier:O,index:--b}}readIdentifierVal(f,b,S){let _="",$=f[b];if($!=='"'&&$!=="'")throw new Error(`Expected quoted string, found "${$}"`);for(b++;b<f.length&&f[b]!==$;)_+=f[b],b++;if(f[b]!==$)throw new Error(`Unterminated ${S} value`);return b++,[b,_]}readElementExp(f,b){b=v(f,b);let S="";for(;b<f.length&&!/\s/.test(f[b]);)S+=f[b],b++;if(!this.suppressValidationErr&&!p(S))throw new Error(`Invalid element name: "${S}"`);b=v(f,b);let _="";if(f[b]==="E"&&x(f,"MPTY",b))b+=4;else if(f[b]==="A"&&x(f,"NY",b))b+=2;else if(f[b]==="("){for(b++;b<f.length&&f[b]!==")";)_+=f[b],b++;if(f[b]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${f[b]}"`);return{elementName:S,contentModel:_.trim(),index:b}}readAttlistExp(f,b){b=v(f,b);let S="";for(;b<f.length&&!/\s/.test(f[b]);)S+=f[b],b++;I(S),b=v(f,b);let _="";for(;b<f.length&&!/\s/.test(f[b]);)_+=f[b],b++;if(!I(_))throw new Error(`Invalid attribute name: "${_}"`);b=v(f,b);let $="";if(f.substring(b,b+8).toUpperCase()==="NOTATION"){if($="NOTATION",b+=8,b=v(f,b),f[b]!=="(")throw new Error(`Expected '(', found "${f[b]}"`);b++;let U=[];for(;b<f.length&&f[b]!==")";){let oe="";for(;b<f.length&&f[b]!=="|"&&f[b]!==")";)oe+=f[b],b++;if(oe=oe.trim(),!I(oe))throw new Error(`Invalid notation name: "${oe}"`);U.push(oe),f[b]==="|"&&(b++,b=v(f,b))}if(f[b]!==")")throw new Error("Unterminated list of notations");b++,$+=" ("+U.join("|")+")"}else{for(;b<f.length&&!/\s/.test(f[b]);)$+=f[b],b++;let U=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!U.includes($.toUpperCase()))throw new Error(`Invalid attribute type: "${$}"`)}b=v(f,b);let O="";return f.substring(b,b+8).toUpperCase()==="#REQUIRED"?(O="#REQUIRED",b+=8):f.substring(b,b+7).toUpperCase()==="#IMPLIED"?(O="#IMPLIED",b+=7):[b,O]=this.readIdentifierVal(f,b,"ATTLIST"),{elementName:S,attributeName:_,attributeType:$,defaultValue:O,index:b}}},v=r((f,b)=>{for(;b<f.length&&/\s/.test(f[b]);)b++;return b},"skipWhitespace");function x(f,b,S){for(let _=0;_<b.length;_++)if(b[_]!==f[S+_+1])return!1;return!0}s(x,"hasSeq"),r(x,"hasSeq");function I(f){if(p(f))return f;throw new Error(`Invalid entity name ${f}`)}s(I,"validateEntityName"),r(I,"validateEntityName");var k=/^[-+]?0x[a-fA-F0-9]+$/,C=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,A={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Z(f,b={}){if(b=Object.assign({},A,b),!f||typeof f!="string")return f;let S=f.trim();if(b.skipLike!==void 0&&b.skipLike.test(S))return f;if(f==="0")return 0;if(b.hex&&k.test(S))return re(S,16);if(S.includes("e")||S.includes("E"))return Q(f,S,b);{let _=C.exec(S);if(_){let $=_[1]||"",O=_[2],U=te(_[3]),oe=$?f[O.length+1]===".":f[O.length]===".";if(!b.leadingZeros&&(O.length>1||O.length===1&&!oe))return f;{let q=Number(S),j=String(q);if(q===0)return q;if(j.search(/[eE]/)!==-1)return b.eNotation?q:f;if(S.indexOf(".")!==-1)return j==="0"||j===U||j===`${$}${U}`?q:f;let Ie=O?U:S;return O?Ie===j||$+Ie===j?q:f:Ie===j||Ie===$+j?q:f}}else return f}}s(Z,"toNumber"),r(Z,"toNumber");var V=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Q(f,b,S){if(!S.eNotation)return f;let _=b.match(V);if(_){let $=_[1]||"",O=_[3].indexOf("e")===-1?"E":"e",U=_[2],oe=$?f[U.length+1]===O:f[U.length]===O;return U.length>1&&oe?f:U.length===1&&(_[3].startsWith(`.${O}`)||_[3][0]===O)?Number(b):S.leadingZeros&&!oe?(b=(_[1]||"")+_[3],Number(b)):f}else return f}s(Q,"resolveEnotation"),r(Q,"resolveEnotation");function te(f){return f&&f.indexOf(".")!==-1&&(f=f.replace(/0+$/,""),f==="."?f="0":f[0]==="."?f="0"+f:f[f.length-1]==="."&&(f=f.substring(0,f.length-1))),f}s(te,"trimZeros"),r(te,"trimZeros");function re(f,b){if(parseInt)return parseInt(f,b);if(Number.parseInt)return Number.parseInt(f,b);if(window&&window.parseInt)return window.parseInt(f,b);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}s(re,"parse_int"),r(re,"parse_int");function se(f){return typeof f=="function"?f:Array.isArray(f)?b=>{for(let S of f)if(typeof S=="string"&&b===S||S instanceof RegExp&&S.test(b))return!0}:()=>!1}s(se,"getIgnoreAttributesFn"),r(se,"getIgnoreAttributesFn");var Ee=class{static{s(this,"OrderedObjParser")}static{r(this,"OrderedObjParser")}constructor(f){if(this.options=f,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:r((b,S)=>qa(S,10,"&#"),"val")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:r((b,S)=>qa(S,16,"&#x"),"val")}},this.addExternalEntities=Ve,this.parseXml=Y,this.parseTextData=G,this.resolveNameSpace=ie,this.buildAttributesMap=X,this.isItStopNode=Ye,this.replaceEntitiesValue=Te,this.readStopNodeData=Dr,this.saveTextToParentTag=ve,this.addChild=he,this.ignoreAttributesFn=se(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let b=0;b<this.options.stopNodes.length;b++){let S=this.options.stopNodes[b];typeof S=="string"&&(S.startsWith("*.")?this.stopNodesWildcard.add(S.substring(2)):this.stopNodesExact.add(S))}}}};function Ve(f){let b=Object.keys(f);for(let S=0;S<b.length;S++){let _=b[S],$=_.replace(/[.\-+*:]/g,"\\.");this.lastEntities[_]={regex:new RegExp("&"+$+";","g"),val:f[_]}}}s(Ve,"addExternalEntities"),r(Ve,"addExternalEntities");function G(f,b,S,_,$,O,U){if(f!==void 0&&(this.options.trimValues&&!_&&(f=f.trim()),f.length>0)){U||(f=this.replaceEntitiesValue(f,b,S));let oe=this.options.tagValueProcessor(b,f,S,$,O);return oe==null?f:typeof oe!=typeof f||oe!==f?oe:this.options.trimValues?fi(f,this.options.parseTagValue,this.options.numberParseOptions):f.trim()===f?fi(f,this.options.parseTagValue,this.options.numberParseOptions):f}}s(G,"parseTextData"),r(G,"parseTextData");function ie(f){if(this.options.removeNSPrefix){let b=f.split(":"),S=f.charAt(0)==="/"?"/":"";if(b[0]==="xmlns")return"";b.length===2&&(f=S+b[1])}return f}s(ie,"resolveNameSpace"),r(ie,"resolveNameSpace");var F=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function X(f,b,S){if(this.options.ignoreAttributes!==!0&&typeof f=="string"){let _=d(f,F),$=_.length,O={};for(let U=0;U<$;U++){let oe=this.resolveNameSpace(_[U][1]);if(this.ignoreAttributesFn(oe,b))continue;let q=_[U][4],j=this.options.attributeNamePrefix+oe;if(oe.length)if(this.options.transformAttributeName&&(j=this.options.transformAttributeName(j)),j==="__proto__"&&(j="#__proto__"),q!==void 0){this.options.trimValues&&(q=q.trim()),q=this.replaceEntitiesValue(q,S,b);let Ie=this.options.attributeValueProcessor(oe,q,b);Ie==null?O[j]=q:typeof Ie!=typeof q||Ie!==q?O[j]=Ie:O[j]=fi(q,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(O[j]=!0)}if(!Object.keys(O).length)return;if(this.options.attributesGroupName){let U={};return U[this.options.attributesGroupName]=O,U}return O}}s(X,"buildAttributesMap"),r(X,"buildAttributesMap");var Y=r(function(f){f=f.replace(/\r\n?/g,`
314
314
  `);let b=new g("!xml"),S=b,_="",$="";this.entityExpansionCount=0,this.currentExpandedLength=0;let O=new w(this.options.processEntities);for(let U=0;U<f.length;U++)if(f[U]==="<")if(f[U+1]==="/"){let q=yt(f,">",U,"Closing Tag is not closed."),j=f.substring(U+2,q).trim();if(this.options.removeNSPrefix){let et=j.indexOf(":");et!==-1&&(j=j.substr(et+1))}this.options.transformTagName&&(j=this.options.transformTagName(j)),S&&(_=this.saveTextToParentTag(_,S,$));let Ie=$.substring($.lastIndexOf(".")+1);if(j&&this.options.unpairedTags.indexOf(j)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${j}>`);let ae=0;Ie&&this.options.unpairedTags.indexOf(Ie)!==-1?(ae=$.lastIndexOf(".",$.lastIndexOf(".")-1),this.tagsNodeStack.pop()):ae=$.lastIndexOf("."),$=$.substring(0,ae),S=this.tagsNodeStack.pop(),_="",U=q}else if(f[U+1]==="?"){let q=nr(f,U,!1,"?>");if(!q)throw new Error("Pi Tag is not closed.");if(_=this.saveTextToParentTag(_,S,$),!(this.options.ignoreDeclaration&&q.tagName==="?xml"||this.options.ignorePiTags)){let j=new g(q.tagName);j.add(this.options.textNodeName,""),q.tagName!==q.tagExp&&q.attrExpPresent&&(j[":@"]=this.buildAttributesMap(q.tagExp,$,q.tagName)),this.addChild(S,j,$,U)}U=q.closeIndex+1}else if(f.substr(U+1,3)==="!--"){let q=yt(f,"-->",U+4,"Comment is not closed.");if(this.options.commentPropName){let j=f.substring(U+4,q-2);_=this.saveTextToParentTag(_,S,$),S.add(this.options.commentPropName,[{[this.options.textNodeName]:j}])}U=q}else if(f.substr(U+1,2)==="!D"){let q=O.readDocType(f,U);this.docTypeEntities=q.entities,U=q.i}else if(f.substr(U+1,2)==="!["){let q=yt(f,"]]>",U,"CDATA is not closed.")-2,j=f.substring(U+9,q);_=this.saveTextToParentTag(_,S,$);let Ie=this.parseTextData(j,S.tagname,$,!0,!1,!0,!0);Ie==null&&(Ie=""),this.options.cdataPropName?S.add(this.options.cdataPropName,[{[this.options.textNodeName]:j}]):S.add(this.options.textNodeName,Ie),U=q+2}else{let q=nr(f,U,this.options.removeNSPrefix),j=q.tagName,Ie=q.rawTagName,ae=q.tagExp,et=q.attrExpPresent,oh=q.closeIndex;if(this.options.transformTagName){let tt=this.options.transformTagName(j);ae===j&&(ae=tt),j=tt}S&&_&&S.tagname!=="!xml"&&(_=this.saveTextToParentTag(_,S,$,!1));let ih=S;ih&&this.options.unpairedTags.indexOf(ih.tagname)!==-1&&(S=this.tagsNodeStack.pop(),$=$.substring(0,$.lastIndexOf("."))),j!==b.tagname&&($+=$?"."+j:j);let Wa=U;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,$,j)){let tt="";if(ae.length>0&&ae.lastIndexOf("/")===ae.length-1)j[j.length-1]==="/"?(j=j.substr(0,j.length-1),$=$.substr(0,$.length-1),ae=j):ae=ae.substr(0,ae.length-1),U=q.closeIndex;else if(this.options.unpairedTags.indexOf(j)!==-1)U=q.closeIndex;else{let Ka=this.readStopNodeData(f,Ie,oh+1);if(!Ka)throw new Error(`Unexpected end of ${Ie}`);U=Ka.i,tt=Ka.tagContent}let jr=new g(j);j!==ae&&et&&(jr[":@"]=this.buildAttributesMap(ae,$,j)),tt&&(tt=this.parseTextData(tt,j,$,!0,et,!0,!0)),$=$.substr(0,$.lastIndexOf(".")),jr.add(this.options.textNodeName,tt),this.addChild(S,jr,$,Wa)}else{if(ae.length>0&&ae.lastIndexOf("/")===ae.length-1){if(j[j.length-1]==="/"?(j=j.substr(0,j.length-1),$=$.substr(0,$.length-1),ae=j):ae=ae.substr(0,ae.length-1),this.options.transformTagName){let jr=this.options.transformTagName(j);ae===j&&(ae=jr),j=jr}let tt=new g(j);j!==ae&&et&&(tt[":@"]=this.buildAttributesMap(ae,$,j)),this.addChild(S,tt,$,Wa),$=$.substr(0,$.lastIndexOf("."))}else{let tt=new g(j);this.tagsNodeStack.push(S),j!==ae&&et&&(tt[":@"]=this.buildAttributesMap(ae,$,j)),this.addChild(S,tt,$,Wa),S=tt}_="",U=oh}}else _+=f[U];return b.child},"parseXml");function he(f,b,S,_){this.options.captureMetaData||(_=void 0);let $=this.options.updateTag(b.tagname,S,b[":@"]);$===!1||(typeof $=="string"&&(b.tagname=$),f.addChild(b,_))}s(he,"addChild"),r(he,"addChild");var Te=r(function(f,b,S){if(f.indexOf("&")===-1)return f;let _=this.options.processEntities;if(!_.enabled||_.allowedTags&&!_.allowedTags.includes(b)||_.tagFilter&&!_.tagFilter(b,S))return f;for(let $ in this.docTypeEntities){let O=this.docTypeEntities[$],U=f.match(O.regx);if(U){if(this.entityExpansionCount+=U.length,_.maxTotalExpansions&&this.entityExpansionCount>_.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${_.maxTotalExpansions}`);let oe=f.length;if(f=f.replace(O.regx,O.val),_.maxExpandedLength&&(this.currentExpandedLength+=f.length-oe,this.currentExpandedLength>_.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${_.maxExpandedLength}`)}}if(f.indexOf("&")===-1)return f;for(let $ in this.lastEntities){let O=this.lastEntities[$];f=f.replace(O.regex,O.val)}if(f.indexOf("&")===-1)return f;if(this.options.htmlEntities)for(let $ in this.htmlEntities){let O=this.htmlEntities[$];f=f.replace(O.regex,O.val)}return f=f.replace(this.ampEntity.regex,this.ampEntity.val),f},"replaceEntitiesValue");function ve(f,b,S,_){return f&&(_===void 0&&(_=b.child.length===0),f=this.parseTextData(f,b.tagname,S,!1,b[":@"]?Object.keys(b[":@"]).length!==0:!1,_),f!==void 0&&f!==""&&b.add(this.options.textNodeName,f),f=""),f}s(ve,"saveTextToParentTag"),r(ve,"saveTextToParentTag");function Ye(f,b,S,_){return!!(b&&b.has(_)||f&&f.has(S))}s(Ye,"isItStopNode"),r(Ye,"isItStopNode");function $t(f,b,S=">"){let _,$="";for(let O=b;O<f.length;O++){let U=f[O];if(_)U===_&&(_="");else if(U==='"'||U==="'")_=U;else if(U===S[0])if(S[1]){if(f[O+1]===S[1])return{data:$,index:O}}else return{data:$,index:O};else U===" "&&(U=" ");$+=U}}s($t,"tagExpWithClosingIndex"),r($t,"tagExpWithClosingIndex");function yt(f,b,S,_){let $=f.indexOf(b,S);if($===-1)throw new Error(_);return $+b.length-1}s(yt,"findClosingIndex"),r(yt,"findClosingIndex");function nr(f,b,S,_=">"){let $=$t(f,b+1,_);if(!$)return;let O=$.data,U=$.index,oe=O.search(/\s/),q=O,j=!0;oe!==-1&&(q=O.substring(0,oe),O=O.substring(oe+1).trimStart());let Ie=q;if(S){let ae=q.indexOf(":");ae!==-1&&(q=q.substr(ae+1),j=q!==$.data.substr(ae+1))}return{tagName:q,tagExp:O,closeIndex:U,attrExpPresent:j,rawTagName:Ie}}s(nr,"readTagExp"),r(nr,"readTagExp");function Dr(f,b,S){let _=S,$=1;for(;S<f.length;S++)if(f[S]==="<")if(f[S+1]==="/"){let O=yt(f,">",S,`${b} is not closed`);if(f.substring(S+2,O).trim()===b&&($--,$===0))return{tagContent:f.substring(_,S),i:O};S=O}else if(f[S+1]==="?")S=yt(f,"?>",S+1,"StopNode is not closed.");else if(f.substr(S+1,3)==="!--")S=yt(f,"-->",S+3,"StopNode is not closed.");else if(f.substr(S+1,2)==="![")S=yt(f,"]]>",S,"StopNode is not closed.")-2;else{let O=nr(f,S,">");O&&((O&&O.tagName)===b&&O.tagExp[O.tagExp.length-1]!=="/"&&$++,S=O.closeIndex)}}s(Dr,"readStopNodeData"),r(Dr,"readStopNodeData");function fi(f,b,S){if(b&&typeof f=="string"){let _=f.trim();return _==="true"?!0:_==="false"?!1:Z(f,S)}else return m(f)?f:""}s(fi,"parseValue"),r(fi,"parseValue");function qa(f,b,S){let _=Number.parseInt(f,b);return _>=0&&_<=1114111?String.fromCodePoint(_):S+f+";"}s(qa,"fromCodePoint"),r(qa,"fromCodePoint");var Fa=g.getMetaDataSymbol();function Wg(f,b){return Ha(f,b)}s(Wg,"prettify"),r(Wg,"prettify");function Ha(f,b,S){let _,$={};for(let O=0;O<f.length;O++){let U=f[O],oe=Kg(U),q="";if(S===void 0?q=oe:q=S+"."+oe,oe===b.textNodeName)_===void 0?_=U[oe]:_+=""+U[oe];else{if(oe===void 0)continue;if(U[oe]){let j=Ha(U[oe],b,q),Ie=Yg(j,b);U[Fa]!==void 0&&(j[Fa]=U[Fa]),U[":@"]?Qg(j,U[":@"],q,b):Object.keys(j).length===1&&j[b.textNodeName]!==void 0&&!b.alwaysCreateTextNode?j=j[b.textNodeName]:Object.keys(j).length===0&&(b.alwaysCreateTextNode?j[b.textNodeName]="":j=""),$[oe]!==void 0&&$.hasOwnProperty(oe)?(Array.isArray($[oe])||($[oe]=[$[oe]]),$[oe].push(j)):b.isArray(oe,q,Ie)?$[oe]=[j]:$[oe]=j}}}return typeof _=="string"?_.length>0&&($[b.textNodeName]=_):_!==void 0&&($[b.textNodeName]=_),$}s(Ha,"compress"),r(Ha,"compress");function Kg(f){let b=Object.keys(f);for(let S=0;S<b.length;S++){let _=b[S];if(_!==":@")return _}}s(Kg,"propName"),r(Kg,"propName");function Qg(f,b,S,_){if(b){let $=Object.keys(b),O=$.length;for(let U=0;U<O;U++){let oe=$[U];_.isArray(oe,S+"."+oe,!0,!0)?f[oe]=[b[oe]]:f[oe]=b[oe]}}}s(Qg,"assignAttributes"),r(Qg,"assignAttributes");function Yg(f,b){let{textNodeName:S}=b,_=Object.keys(f).length;return!!(_===0||_===1&&(f[S]||typeof f[S]=="boolean"||f[S]===0))}s(Yg,"isLeafTag"),r(Yg,"isLeafTag");var QR={allowBooleanAttributes:!1,unpairedTags:[]};function Xg(f,b){b=Object.assign({},QR,b);let S=[],_=!1,$=!1;f[0]==="\uFEFF"&&(f=f.substr(1));for(let O=0;O<f.length;O++)if(f[O]==="<"&&f[O+1]==="?"){if(O+=2,O=Ga(f,O),O.err)return O}else if(f[O]==="<"){let U=O;if(O++,f[O]==="!"){O=Va(f,O);continue}else{let oe=!1;f[O]==="/"&&(oe=!0,O++);let q="";for(;O<f.length&&f[O]!==">"&&f[O]!==" "&&f[O]!==" "&&f[O]!==`
315
315
  `&&f[O]!=="\r";O++)q+=f[O];if(q=q.trim(),q[q.length-1]==="/"&&(q=q.substring(0,q.length-1),O--),!L(q)){let ae;return q.trim().length===0?ae="Invalid space after '<'.":ae="Tag '"+q+"' is an invalid name.",De("InvalidTag",ae,Xe(f,O))}let j=eh(f,O);if(j===!1)return De("InvalidAttr","Attributes for '"+q+"' have open quote.",Xe(f,O));let Ie=j.value;if(O=j.index,Ie[Ie.length-1]==="/"){let ae=O-Ie.length;Ie=Ie.substring(0,Ie.length-1);let et=Ja(Ie,b);if(et===!0)_=!0;else return De(et.err.code,et.err.msg,Xe(f,ae+et.err.line))}else if(oe)if(j.tagClosed){if(Ie.trim().length>0)return De("InvalidTag","Closing tag '"+q+"' can't have attributes or invalid starting.",Xe(f,U));if(S.length===0)return De("InvalidTag","Closing tag '"+q+"' has not been opened.",Xe(f,U));{let ae=S.pop();if(q!==ae.tagName){let et=Xe(f,ae.tagStartPos);return De("InvalidTag","Expected closing tag '"+ae.tagName+"' (opened in line "+et.line+", col "+et.col+") instead of closing tag '"+q+"'.",Xe(f,U))}S.length==0&&($=!0)}}else return De("InvalidTag","Closing tag '"+q+"' doesn't have proper closing.",Xe(f,O));else{let ae=Ja(Ie,b);if(ae!==!0)return De(ae.err.code,ae.err.msg,Xe(f,O-Ie.length+ae.err.line));if($===!0)return De("InvalidXml","Multiple possible root nodes found.",Xe(f,O));b.unpairedTags.indexOf(q)!==-1||S.push({tagName:q,tagStartPos:U}),_=!0}for(O++;O<f.length;O++)if(f[O]==="<")if(f[O+1]==="!"){O++,O=Va(f,O);continue}else if(f[O+1]==="?"){if(O=Ga(f,++O),O.err)return O}else break;else if(f[O]==="&"){let ae=rh(f,O);if(ae==-1)return De("InvalidChar","char '&' is not expected.",Xe(f,O));O=ae}else if($===!0&&!Ba(f[O]))return De("InvalidXml","Extra text at the end",Xe(f,O));f[O]==="<"&&O--}}else{if(Ba(f[O]))continue;return De("InvalidChar","char '"+f[O]+"' is not expected.",Xe(f,O))}if(_){if(S.length==1)return De("InvalidTag","Unclosed tag '"+S[0].tagName+"'.",Xe(f,S[0].tagStartPos));if(S.length>0)return De("InvalidXml","Invalid '"+JSON.stringify(S.map(O=>O.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return De("InvalidXml","Start tag expected.",1);return!0}s(Xg,"validate"),r(Xg,"validate");function Ba(f){return f===" "||f===" "||f===`
316
- `||f==="\r"}s(Ba,"isWhiteSpace"),r(Ba,"isWhiteSpace");function Ga(f,b){let S=b;for(;b<f.length;b++)if(f[b]=="?"||f[b]==" "){let _=f.substr(S,b-S);if(b>5&&_==="xml")return De("InvalidXml","XML declaration allowed only at the start of the document.",Xe(f,b));if(f[b]=="?"&&f[b+1]==">"){b++;break}else continue}return b}s(Ga,"readPI"),r(Ga,"readPI");function Va(f,b){if(f.length>b+5&&f[b+1]==="-"&&f[b+2]==="-"){for(b+=3;b<f.length;b++)if(f[b]==="-"&&f[b+1]==="-"&&f[b+2]===">"){b+=2;break}}else if(f.length>b+8&&f[b+1]==="D"&&f[b+2]==="O"&&f[b+3]==="C"&&f[b+4]==="T"&&f[b+5]==="Y"&&f[b+6]==="P"&&f[b+7]==="E"){let S=1;for(b+=8;b<f.length;b++)if(f[b]==="<")S++;else if(f[b]===">"&&(S--,S===0))break}else if(f.length>b+9&&f[b+1]==="["&&f[b+2]==="C"&&f[b+3]==="D"&&f[b+4]==="A"&&f[b+5]==="T"&&f[b+6]==="A"&&f[b+7]==="["){for(b+=8;b<f.length;b++)if(f[b]==="]"&&f[b+1]==="]"&&f[b+2]===">"){b+=2;break}}return b}s(Va,"readCommentAndCDATA"),r(Va,"readCommentAndCDATA");var YR='"',XR="'";function eh(f,b){let S="",_="",$=!1;for(;b<f.length;b++){if(f[b]===YR||f[b]===XR)_===""?_=f[b]:_!==f[b]||(_="");else if(f[b]===">"&&_===""){$=!0;break}S+=f[b]}return _!==""?!1:{value:S,index:b,tagClosed:$}}s(eh,"readAttributeStr"),r(eh,"readAttributeStr");var eI=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Ja(f,b){let S=d(f,eI),_={};for(let $=0;$<S.length;$++){if(S[$][1].length===0)return De("InvalidAttr","Attribute '"+S[$][2]+"' has no space in starting.",Ur(S[$]));if(S[$][3]!==void 0&&S[$][4]===void 0)return De("InvalidAttr","Attribute '"+S[$][2]+"' is without value.",Ur(S[$]));if(S[$][3]===void 0&&!b.allowBooleanAttributes)return De("InvalidAttr","boolean attribute '"+S[$][2]+"' is not allowed.",Ur(S[$]));let O=S[$][2];if(!nh(O))return De("InvalidAttr","Attribute '"+O+"' is an invalid name.",Ur(S[$]));if(!_.hasOwnProperty(O))_[O]=1;else return De("InvalidAttr","Attribute '"+O+"' is repeated.",Ur(S[$]))}return!0}s(Ja,"validateAttributeString"),r(Ja,"validateAttributeString");function th(f,b){let S=/\d/;for(f[b]==="x"&&(b++,S=/[\da-fA-F]/);b<f.length;b++){if(f[b]===";")return b;if(!f[b].match(S))break}return-1}s(th,"validateNumberAmpersand"),r(th,"validateNumberAmpersand");function rh(f,b){if(b++,f[b]===";")return-1;if(f[b]==="#")return b++,th(f,b);let S=0;for(;b<f.length;b++,S++)if(!(f[b].match(/\w/)&&S<20)){if(f[b]===";")break;return-1}return b}s(rh,"validateAmpersand"),r(rh,"validateAmpersand");function De(f,b,S){return{err:{code:f,msg:b,line:S.line||S,col:S.col}}}s(De,"getErrorObject"),r(De,"getErrorObject");function nh(f){return p(f)}s(nh,"validateAttrName"),r(nh,"validateAttrName");function L(f){return p(f)}s(L,"validateTagName"),r(L,"validateTagName");function Xe(f,b){let S=f.substring(0,b).split(/\r?\n/);return{line:S.length,col:S[S.length-1].length+1}}s(Xe,"getLineNumberForPosition"),r(Xe,"getLineNumberForPosition");function Ur(f){return f.startIndex+f[1].length}s(Ur,"getPositionFromMatch"),r(Ur,"getPositionFromMatch");var tI=class{static{s(this,"XMLParser")}static{r(this,"XMLParser")}constructor(f){this.externalEntities={},this.options=i(f)}parse(f,b){if(typeof f!="string"&&f.toString)f=f.toString();else if(typeof f!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(b){b===!0&&(b={});let $=Xg(f,b);if($!==!0)throw Error(`${$.err.msg}:${$.err.line}:${$.err.col}`)}let S=new Ee(this.options);S.addExternalEntities(this.externalEntities);let _=S.parseXml(f);return this.options.preserveOrder||_===void 0?_:Wg(_,this.options)}addEntity(f,b){if(b.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(f.indexOf("&")!==-1||f.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(b==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[f]=b}static getMetaDataSymbol(){return g.getMetaDataSymbol()}};return new tI(t)},"getXmlParser");var Gg=class extends ir{static{s(this,"XmlToJsonOutboundPolicy")}parser;parseOnStatusCodes;constructor(e,r){super(e,r),P("policy.outbound.xml-to-json"),ge(this.options,this.policyName).optional("removeNSPrefix","boolean").optional("ignoreProcessingInstructions","boolean").optional("ignoreDeclarations","boolean").optional("ignoreAttributes","boolean").optional("stopNodes","array").optional("attributeNamePrefix","string").optional("textNodeName","string").optional("trimValues","boolean"),this.parseOnStatusCodes=e.parseOnStatusCodes?Dt(e.parseOnStatusCodes):void 0,this.parser=FR({removeNSPrefix:e?.removeNSPrefix??!0,ignorePiTags:e?.ignoreProcessingInstructions??!0,ignoreDeclaration:e?.ignoreDeclarations??!0,ignoreAttributes:e?.ignoreAttributes??!0,stopNodes:e?.stopNodes??[],attributeNamePrefix:e?.attributeNamePrefix??"@_",textNodeName:e?.textNodeName??"#text",trimValues:e?.trimValues??!0})}async handler(e,r,o){if(this.parseOnStatusCodes&&!this.parseOnStatusCodes.includes(e.status))return e;let n;try{let c=await e.text();n=this.parser.parse(c)}catch(c){let u=`XmlToJsonOutboundPolicy - Error parsing XML contents in policy '${this.policyName}'.`;throw o.log.error(u,c),new z(u)}let i=new Headers(e.headers);return i.set("content-type","application/json"),new Response(JSON.stringify(n),{status:e.status,statusText:e.statusText,headers:i})}};var Vg=class{static{s(this,"ServiceProviderImpl")}services=new Map;addService(e,r){if(this.services.get(e))throw new ye(`A service with the name ${e} already exists -- you cannot have duplicate services`);this.services.set(e,r)}getService(e){return this.services.get(e)}};var Jg=class{static{s(this,"ApiKeyConsumerClient")}bucketId;cacheDurationSeconds;cacheNamePromise;constructor(e){this.bucketId=e?.bucketId,this.cacheDurationSeconds=e?.cacheDurationSeconds??60}getCacheName(e){return this.cacheNamePromise||(this.cacheNamePromise=Re("zuplo-get-consumer",void 0,{bucketId:e})),this.cacheNamePromise}async get(e){P("utility.get-consumer");let r=My(),o=this.bucketId??Ze.ZUPLO_SERVICE_BUCKET_ID;if(!o)throw new R("ApiKeyConsumerClient - no bucketId provided and no default bucket is configured for this environment. Pass `bucketId` explicitly (find it in the Zuplo portal under Settings > API Key Buckets).");if(!o.startsWith("bckt_"))throw new R(`ApiKeyConsumerClient - bucketId "${o}" is not a valid bucket id. Bucket ids start with "bckt_" (e.g. "bckt_2HaK3odRyJle6NJSu8mzNKBC30BYxllxL"); a bucket name (e.g. "zprj-...-working-copy") is not accepted here. Find the bucket id in the Zuplo portal under Settings > API Key Buckets.`);if(!e||e.trim()==="")throw new R("ApiKeyConsumerClient.get - consumerId is required and cannot be empty");let n=await this.getCacheName(o),i=new we(n,r);if(this.cacheDurationSeconds>0){let l=await i.get(e);if(l)return l}let a=`/v2/key-auth/${encodeURIComponent(o)}/consumers/${encodeURIComponent(e)}`,c=await Xa(a),u={id:c.id,name:c.name,createdOn:c.createdOn,updatedOn:c.updatedOn};return c.description!==void 0&&(u.description=c.description),c.metadata!==void 0&&(u.metadata=c.metadata),this.cacheDurationSeconds>0&&i.put(e,u,this.cacheDurationSeconds),u}};var HR=10,BR=3e4,si=class{static{s(this,"BackgroundLoader")}#e=new Map;#t;#n;#r;#o;#i={};constructor(e,r){if(typeof r=="number"){let o=r;this.#n=o*1e3,this.#o=BR,this.#r=HR}else{let o=r;this.#n=o.ttlSeconds*1e3,this.#o=o.loaderTimeoutSeconds?o.loaderTimeoutSeconds*1e3:BR,this.#r=HR}this.#t=e}#s(e){return e.expiry<=new Date}#a(e){let r=this.#i[e];return!(r===void 0||r===0)}#u(e){let r=this.#e.get(e);if(r&&!this.#s(r))return r.data}async get(e){let r=this.#u(e);if(r)return this.#l(e),r;if(this.#a(e))try{await n$(()=>this.#u(e)!==void 0||!this.#a(e),this.#o+this.#r+1,this.#r);let o=this.#u(e);if(o)return o}catch{}return this.#c(e)}#l(e){if(!this.#a(e)){let r=this.#c(e);ar().waitUntil(r)}}async#c(e){try{this.#i[e]===void 0&&(this.#i[e]=0),this.#i[e]++;let r=await Promise.race([this.#t(e),scheduler.wait(this.#o)]);if(r===void 0)throw new R(`BackgroundLoader: Loader timed out after ${this.#o} ms.`);return this.#e.set(e,{data:r,expiry:new Date(Date.now()+this.#n)}),r}finally{this.#i[e]--}}};async function n$(t,e,r){let o=Date.now();for(;!t();){let n=Date.now()-o;if(n>e)throw new R(`BackgroundLoader: Timeout waiting for an on-going loader after ${n} ms.`);await scheduler.wait(r)}}s(n$,"waitUntilTrue");import{SpanStatusCode as GR,trace as VR}from"@opentelemetry/api";var JR=s(async(t,e,r)=>{let o=Pe.instance.routeData.policies,n=Kr([t],o);if(n.length===0)throw new z(`Invalid 'invokeInboundPolicy call' - no policy '${t}' found.`);let i=n[0];return await VR.getTracer("pipeline").startActiveSpan(`policy:${i.policyName}`,async u=>{try{let l=await i.handler(e,r);if(l instanceof Request||l instanceof de||l instanceof Response)return l instanceof Response||l instanceof de?l:new de(l);{let d=new R(`Invalid state - invalid handler on policy '${i.policyName}' invoked via 'invokeInboundPolicy' on route '${r.route.path}'. The result of an inbound policy must be a Response or Request.`);throw u.setStatus({code:GR.ERROR}),u.recordException(d),d}}finally{u.end()}})},"invokeInboundPolicy"),WR=s(async(t,e,r,o)=>{let n=Pe.instance.routeData.policies,i=Wn([t],n);if(i.length===0)throw new z(`Invalid 'invokeOutboundPolicy call' - no policy '${t}' found.`);let a=i[0];return await VR.getTracer("pipeline").startActiveSpan(`policy:${a.policyName}`,async l=>{try{let d=await a.handler(e,r,o);if(d instanceof Response)return d;{let p=new R(`Invalid state - invalid handler on policy '${a.policyName}' invoked via 'invokeOutboundPolicy' on route '${o.route.path}. The result of an outbound policy must be a Response.`);throw l.setStatus({code:GR.ERROR}),l.recordException(p),p}}finally{l.end()}})},"invokeOutboundPolicy");function o$(t){let e={};if(!t)return e;try{let r=t.split(","),o={};return r.forEach(n=>{let[i,a]=n.split("=");i&&a&&(o[i.trim()]=a.trim())}),o.asnum&&(e[xi]=o.asnum),o.zip&&(e[Ri]=o.zip.split("+")[0]),o.dma&&(e[Ii]=o.dma),o.region_code&&(e[Pi]=o.region_code),o.timezone&&(e[Si]=o.timezone),o.city&&(e[hi]=o.city),o.continent&&(e[yi]=o.continent),o.country_code&&(e[bi]=o.country_code),o.long&&(e[vi]=o.long),o.lat&&(e[wi]=o.lat),e}catch{return{}}}s(o$,"parseEdgeScapeHeader");function KR(t,e){let r=o$(e);for(let[o,n]of Object.entries(r))t.has(o)||t.set(o,n)}s(KR,"setZpHeadersFromAkamaiEdgeScapeHeader");var Yi=class{static{s(this,"HeaderIncomingRequestProperties")}#e;constructor(e){this.#e=e;let r=e.get(Lh);if(r){let o=new Headers(e);KR(o,r),this.#e=o}}get asn(){try{let e=this.#e.get(xi);if(typeof e=="string")return parseInt(e,10)}catch{}}get asOrganization(){return this.#e.get(Ch)??void 0}get city(){return this.#e.get(dh)??this.#e.get(hi)??void 0}get continent(){return this.#e.get(ph)??this.#e.get(yi)??void 0}get country(){return this.#e.get(mh)??this.#e.get(bi)??void 0}get latitude(){return this.#e.get(gh)??this.#e.get(wi)??void 0}get longitude(){return this.#e.get(fh)??this.#e.get(vi)??void 0}get colo(){return this.#e.get(_h)??void 0}get postalCode(){return this.#e.get(vh)??this.#e.get(Ri)??void 0}get metroCode(){return this.#e.get(bh)??this.#e.get(Ii)??void 0}get region(){return this.#e.get(hh)??this.#e.get(Oh)??void 0}get regionCode(){return this.#e.get(yh)??this.#e.get(Pi)??void 0}get timezone(){return this.#e.get(wh)??this.#e.get(Si)??void 0}get httpProtocol(){return this.#e.get(Ah)??void 0}get clientCert(){return this.#e.get(xh)??void 0}get clientMtlsVerificationStatus(){return this.#e.get(Rh)??void 0}get clientMtlsVerificationReason(){return this.#e.get(Ih)??void 0}get clientCertFingerprintSha256(){return this.#e.get(Ph)??void 0}get clientCertNotBefore(){return this.#e.get(Sh)??void 0}get clientCertNotAfter(){return this.#e.get(Th)??void 0}get clientCertIssuerDn(){return this.#e.get(kh)??void 0}get clientCertSubjectDn(){return this.#e.get(Eh)??void 0}toJSON(){return{asn:this.asn,asOrganization:this.asOrganization,city:this.city,continent:this.continent,country:this.country,latitude:this.latitude,longitude:this.longitude,colo:this.colo,postalCode:this.postalCode,metroCode:this.metroCode,region:this.region,regionCode:this.regionCode,timezone:this.timezone,httpProtocol:this.httpProtocol,clientCert:this.clientCert,clientMtlsVerificationStatus:this.clientMtlsVerificationStatus,clientMtlsVerificationReason:this.clientMtlsVerificationReason,clientCertFingerprintSha256:this.clientCertFingerprintSha256,clientCertNotBefore:this.clientCertNotBefore,clientCertNotAfter:this.clientCertNotAfter,clientCertIssuerDn:this.clientCertIssuerDn,clientCertSubjectDn:this.clientCertSubjectDn}}};function yr(t){return{contextId:t.contextId,incomingRequestProperties:t.incomingRequestProperties,requestId:t.requestId,route:t.route,custom:t.custom,parentContext:t.parentContext,analyticsContext:t.analyticsContext}}s(yr,"createRewriteContext");var Vn=class extends Event{static{s(this,"ResponseSendingEvent")}constructor(e,r){super("responseSending"),this.request=e,this.mutableResponse=r}request;mutableResponse},Jn=class extends Event{static{s(this,"ResponseSentEvent")}constructor(e,r){super("responseSent"),this.request=e,this.response=r}request;response},Je=class t{static{s(this,"ZuploContextExtensions")}static#e=new WeakMap;static initialize(e,r){if(!t.#e.has(e)){let o=new t(r);return t.#e.set(e,o),o}throw new Error(`ZuploContextExtensions already initialized for context with requestId '${e.requestId}'`)}static getContextExtensions(e){let r=t.#e.get(e);if(!r)throw new z(`Invalid state, could not get ZuploContext extensions for context with requestId '${e.requestId}'`);return r}latestRequest;#t;#n;#r;constructor(e){this.latestRequest=e,this.#t=[],this.#n=[],this.#r=[]}addResponseSendingHook(e){this.#n.push(e)}addResponseSendingFinalHook(e){this.#t.push(e)}addHandlerResponseHook(e){this.#r.push(e)}onResponseSendingFinal=s(async(e,r,o)=>{for(let n of this.#t)await n(e,r,o)},"onResponseSendingFinal");onResponseSending=s(async(e,r,o)=>{let n=e,i=T.instance.build.COMPATIBILITY_FLAGS.chainResponseSendingHooks;for(let a of this.#n)n=await a(i?n:e,r,o);return n},"onResponseSending");onHandlerResponse=s(async(e,r,o)=>{for(let n of this.#r)await n(e,r,o)},"onHandlerResponse")},Xi=class extends EventTarget{static{s(this,"SystemZuploContext")}constructor({logger:e,route:r,requestId:o,event:n,custom:i,incomingRequestProperties:a,parentContext:c}){super(),this.log=Object.freeze(e),this.route=r,this.requestId=o,this.custom=i,this.incomingRequestProperties=a,this.parentContext=c,this.#e=n,this.invokeInboundPolicy=(u,l)=>JR(u,l,this),this.contextId=crypto.randomUUID(),this.invokeOutboundPolicy=(u,l,d)=>WR(u,l,d,this),this.invokeRoute=async(u,l)=>{let d=u;typeof u=="string"&&u.startsWith("/")&&(d=new URL(u,"http://localhost"));let p=new de(d,l);return Pe.instance.handleRequest(p,this,{parentContext:this})},this.waitUntil=u=>{this.#e.waitUntil(u)},this.addResponseSendingHook=u=>{Je.getContextExtensions(this).addResponseSendingHook(u)},this.addResponseSendingFinalHook=u=>{Je.getContextExtensions(this).addResponseSendingFinalHook(u)},this.analyticsContext=new jh(o),Object.freeze(this)}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;invokeInboundPolicy;invokeOutboundPolicy;invokeRoute;waitUntil;addResponseSendingHook;addResponseSendingFinalHook;addEventListener(e,r,o){P("context.addEventListener");let n=s(i=>{try{typeof r=="function"?r(i):r.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,n,o)}removeEventListener(e,r,o){P("context.removeEventListener"),super.removeEventListener(e,r,o)}};export{P as a,Le as b,Xa as c,jn as d,we as e,nc as f,zn as g,Zn as h,vr as i,M as j,Ue as k,wr as l,de as m,ic as n,sc as o,ue as p,lt as q,Bt as r,ke as s,ir as t,mc as u,bc as v,Br as w,My as x,Vn as y,Jn as z,Je as A,fe as B,Hc as C,ot as D,wP as E,OP as F,AP as G,ub as H,zP as I,Xc as J,gu as K,gt as L,Xs as M,im as N,$T as O,Sv as P,Tv as Q,_v as R,ik as S,na as T,Tm as U,uk as V,dk as W,la as X,pk as Y,Uv as Z,zv as _,Fv as $,Bv as aa,oa as ba,Pk as ca,Ek as da,Ck as ea,Lm as fa,h as ga,je as ha,_E as ia,nC as ja,iC as ka,aC as la,cC as ma,lC as na,pC as oa,fC as pa,bC as qa,rf as ra,of as sa,af as ta,lf as ua,pf as va,ff as wa,hf as xa,bf as ya,xf as za,Pf as Aa,kf as Ba,_f as Ca,Af as Da,$f as Ea,ri as Fa,ni as Ga,oi as Ha,Uf as Ia,ai as Ja,Zf as Ka,qf as La,XC as Ma,Ff as Na,Hf as Oa,r_ as Pa,o_ as Qa,s_ as Ra,u_ as Sa,l_ as Ta,d_ as Ua,p_ as Va,R_ as Wa,P_ as Xa,Xf as Ya,S_ as Za,eg as _a,E_ as $a,it as ab,M_ as bb,ig as cb,sg as db,U_ as eb,ug as fb,W_ as gb,K_ as hb,Q_ as ib,Y_ as jb,X_ as kb,eO as lb,aO as mb,yg as nb,hO as ob,yO as pb,bO as qb,wO as rb,xO as sb,PO as tb,SO as ub,kO as vb,EO as wb,CO as xb,$O as yb,MO as zb,Ig as Ab,FO as Bb,Sg as Cb,WO as Db,Tg as Eb,Eg as Fb,KO as Gb,YO as Hb,XO as Ib,Og as Jb,RR as Kb,iA as Lb,sA as Mb,aA as Nb,cA as Ob,uA as Pb,lA as Qb,_R as Rb,dA as Sb,pA as Tb,fA as Ub,wA as Vb,xA as Wb,RA as Xb,IA as Yb,PA as Zb,SA as _b,TA as $b,EA as ac,Dg as bc,UA as cc,jA as dc,ZA as ec,HA as fc,mi as gc,zg as hc,BA as ic,VA as jc,Hg as kc,JA as lc,r$ as mc,Gg as nc,Vg as oc,Jg as pc,si as qc};
317
- /*! For license information please see chunk-HOAEPNOG.js.LEGAL.txt */
318
- //# sourceMappingURL=chunk-HOAEPNOG.js.map
316
+ `||f==="\r"}s(Ba,"isWhiteSpace"),r(Ba,"isWhiteSpace");function Ga(f,b){let S=b;for(;b<f.length;b++)if(f[b]=="?"||f[b]==" "){let _=f.substr(S,b-S);if(b>5&&_==="xml")return De("InvalidXml","XML declaration allowed only at the start of the document.",Xe(f,b));if(f[b]=="?"&&f[b+1]==">"){b++;break}else continue}return b}s(Ga,"readPI"),r(Ga,"readPI");function Va(f,b){if(f.length>b+5&&f[b+1]==="-"&&f[b+2]==="-"){for(b+=3;b<f.length;b++)if(f[b]==="-"&&f[b+1]==="-"&&f[b+2]===">"){b+=2;break}}else if(f.length>b+8&&f[b+1]==="D"&&f[b+2]==="O"&&f[b+3]==="C"&&f[b+4]==="T"&&f[b+5]==="Y"&&f[b+6]==="P"&&f[b+7]==="E"){let S=1;for(b+=8;b<f.length;b++)if(f[b]==="<")S++;else if(f[b]===">"&&(S--,S===0))break}else if(f.length>b+9&&f[b+1]==="["&&f[b+2]==="C"&&f[b+3]==="D"&&f[b+4]==="A"&&f[b+5]==="T"&&f[b+6]==="A"&&f[b+7]==="["){for(b+=8;b<f.length;b++)if(f[b]==="]"&&f[b+1]==="]"&&f[b+2]===">"){b+=2;break}}return b}s(Va,"readCommentAndCDATA"),r(Va,"readCommentAndCDATA");var YR='"',XR="'";function eh(f,b){let S="",_="",$=!1;for(;b<f.length;b++){if(f[b]===YR||f[b]===XR)_===""?_=f[b]:_!==f[b]||(_="");else if(f[b]===">"&&_===""){$=!0;break}S+=f[b]}return _!==""?!1:{value:S,index:b,tagClosed:$}}s(eh,"readAttributeStr"),r(eh,"readAttributeStr");var eI=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Ja(f,b){let S=d(f,eI),_={};for(let $=0;$<S.length;$++){if(S[$][1].length===0)return De("InvalidAttr","Attribute '"+S[$][2]+"' has no space in starting.",Ur(S[$]));if(S[$][3]!==void 0&&S[$][4]===void 0)return De("InvalidAttr","Attribute '"+S[$][2]+"' is without value.",Ur(S[$]));if(S[$][3]===void 0&&!b.allowBooleanAttributes)return De("InvalidAttr","boolean attribute '"+S[$][2]+"' is not allowed.",Ur(S[$]));let O=S[$][2];if(!nh(O))return De("InvalidAttr","Attribute '"+O+"' is an invalid name.",Ur(S[$]));if(!_.hasOwnProperty(O))_[O]=1;else return De("InvalidAttr","Attribute '"+O+"' is repeated.",Ur(S[$]))}return!0}s(Ja,"validateAttributeString"),r(Ja,"validateAttributeString");function th(f,b){let S=/\d/;for(f[b]==="x"&&(b++,S=/[\da-fA-F]/);b<f.length;b++){if(f[b]===";")return b;if(!f[b].match(S))break}return-1}s(th,"validateNumberAmpersand"),r(th,"validateNumberAmpersand");function rh(f,b){if(b++,f[b]===";")return-1;if(f[b]==="#")return b++,th(f,b);let S=0;for(;b<f.length;b++,S++)if(!(f[b].match(/\w/)&&S<20)){if(f[b]===";")break;return-1}return b}s(rh,"validateAmpersand"),r(rh,"validateAmpersand");function De(f,b,S){return{err:{code:f,msg:b,line:S.line||S,col:S.col}}}s(De,"getErrorObject"),r(De,"getErrorObject");function nh(f){return p(f)}s(nh,"validateAttrName"),r(nh,"validateAttrName");function L(f){return p(f)}s(L,"validateTagName"),r(L,"validateTagName");function Xe(f,b){let S=f.substring(0,b).split(/\r?\n/);return{line:S.length,col:S[S.length-1].length+1}}s(Xe,"getLineNumberForPosition"),r(Xe,"getLineNumberForPosition");function Ur(f){return f.startIndex+f[1].length}s(Ur,"getPositionFromMatch"),r(Ur,"getPositionFromMatch");var tI=class{static{s(this,"XMLParser")}static{r(this,"XMLParser")}constructor(f){this.externalEntities={},this.options=i(f)}parse(f,b){if(typeof f!="string"&&f.toString)f=f.toString();else if(typeof f!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(b){b===!0&&(b={});let $=Xg(f,b);if($!==!0)throw Error(`${$.err.msg}:${$.err.line}:${$.err.col}`)}let S=new Ee(this.options);S.addExternalEntities(this.externalEntities);let _=S.parseXml(f);return this.options.preserveOrder||_===void 0?_:Wg(_,this.options)}addEntity(f,b){if(b.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(f.indexOf("&")!==-1||f.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(b==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[f]=b}static getMetaDataSymbol(){return g.getMetaDataSymbol()}};return new tI(t)},"getXmlParser");var Gg=class extends ir{static{s(this,"XmlToJsonOutboundPolicy")}parser;parseOnStatusCodes;constructor(e,r){super(e,r),P("policy.outbound.xml-to-json"),ge(this.options,this.policyName).optional("removeNSPrefix","boolean").optional("ignoreProcessingInstructions","boolean").optional("ignoreDeclarations","boolean").optional("ignoreAttributes","boolean").optional("stopNodes","array").optional("attributeNamePrefix","string").optional("textNodeName","string").optional("trimValues","boolean"),this.parseOnStatusCodes=e.parseOnStatusCodes?Dt(e.parseOnStatusCodes):void 0,this.parser=FR({removeNSPrefix:e?.removeNSPrefix??!0,ignorePiTags:e?.ignoreProcessingInstructions??!0,ignoreDeclaration:e?.ignoreDeclarations??!0,ignoreAttributes:e?.ignoreAttributes??!0,stopNodes:e?.stopNodes??[],attributeNamePrefix:e?.attributeNamePrefix??"@_",textNodeName:e?.textNodeName??"#text",trimValues:e?.trimValues??!0})}async handler(e,r,o){if(this.parseOnStatusCodes&&!this.parseOnStatusCodes.includes(e.status))return e;let n;try{let c=await e.text();n=this.parser.parse(c)}catch(c){let u=`XmlToJsonOutboundPolicy - Error parsing XML contents in policy '${this.policyName}'.`;throw o.log.error(u,c),new z(u)}let i=new Headers(e.headers);return i.set("content-type","application/json"),new Response(JSON.stringify(n),{status:e.status,statusText:e.statusText,headers:i})}};var Vg=class{static{s(this,"ServiceProviderImpl")}services=new Map;addService(e,r){if(this.services.get(e))throw new ye(`A service with the name ${e} already exists -- you cannot have duplicate services`);this.services.set(e,r)}getService(e){return this.services.get(e)}};var Jg=class{static{s(this,"ApiKeyConsumerClient")}bucketId;cacheDurationSeconds;cacheNamePromise;constructor(e){this.bucketId=e?.bucketId,this.cacheDurationSeconds=e?.cacheDurationSeconds??60}getCacheName(e){return this.cacheNamePromise||(this.cacheNamePromise=Re("zuplo-get-consumer",void 0,{bucketId:e})),this.cacheNamePromise}async get(e){P("utility.get-consumer");let r=My(),o=this.bucketId??Ze.ZUPLO_SERVICE_BUCKET_ID;if(!o)throw new R("ApiKeyConsumerClient - no bucketId provided and no default bucket is configured for this environment. Pass `bucketId` explicitly (find it in the Zuplo portal under Settings > API Key Buckets).");if(!o.startsWith("bckt_"))throw new R(`ApiKeyConsumerClient - bucketId "${o}" is not a valid bucket id. Bucket ids start with "bckt_" (e.g. "bckt_2HaK3odRyJle6NJSu8mzNKBC30BYxllxL"); a bucket name (e.g. "zprj-...-working-copy") is not accepted here. Find the bucket id in the Zuplo portal under Settings > API Key Buckets.`);if(!e||e.trim()==="")throw new R("ApiKeyConsumerClient.get - consumerId is required and cannot be empty");let n=await this.getCacheName(o),i=new we(n,r);if(this.cacheDurationSeconds>0){let l=await i.get(e);if(l)return l}let a=`/v2/key-auth/${encodeURIComponent(o)}/consumers/${encodeURIComponent(e)}`,c=await Xa(a),u={id:c.id,name:c.name,createdOn:c.createdOn,updatedOn:c.updatedOn};return c.description!==void 0&&(u.description=c.description),c.metadata!==void 0&&(u.metadata=c.metadata),this.cacheDurationSeconds>0&&i.put(e,u,this.cacheDurationSeconds),u}};var HR=10,BR=3e4,si=class{static{s(this,"BackgroundLoader")}#e=new Map;#t;#n;#r;#o;#i={};constructor(e,r){if(typeof r=="number"){let o=r;this.#n=o*1e3,this.#o=BR,this.#r=HR}else{let o=r;this.#n=o.ttlSeconds*1e3,this.#o=o.loaderTimeoutSeconds?o.loaderTimeoutSeconds*1e3:BR,this.#r=HR}this.#t=e}#s(e){return e.expiry<=new Date}#a(e){let r=this.#i[e];return!(r===void 0||r===0)}#u(e){let r=this.#e.get(e);if(r&&!this.#s(r))return r.data}async get(e){let r=this.#u(e);if(r)return this.#l(e),r;if(this.#a(e))try{await n$(()=>this.#u(e)!==void 0||!this.#a(e),this.#o+this.#r+1,this.#r);let o=this.#u(e);if(o)return o}catch{}return this.#c(e)}#l(e){if(!this.#a(e)){let r=this.#c(e);ar().waitUntil(r)}}async#c(e){try{this.#i[e]===void 0&&(this.#i[e]=0),this.#i[e]++;let r=await Promise.race([this.#t(e),scheduler.wait(this.#o)]);if(r===void 0)throw new R(`BackgroundLoader: Loader timed out after ${this.#o} ms.`);return this.#e.set(e,{data:r,expiry:new Date(Date.now()+this.#n)}),r}finally{this.#i[e]--}}};async function n$(t,e,r){let o=Date.now();for(;!t();){let n=Date.now()-o;if(n>e)throw new R(`BackgroundLoader: Timeout waiting for an on-going loader after ${n} ms.`);await scheduler.wait(r)}}s(n$,"waitUntilTrue");import{SpanStatusCode as GR,trace as VR}from"@opentelemetry/api";var JR=s(async(t,e,r)=>{let o=Pe.instance.routeData.policies,n=Kr([t],o);if(n.length===0)throw new z(`Invalid 'invokeInboundPolicy call' - no policy '${t}' found.`);let i=n[0];return await VR.getTracer("pipeline").startActiveSpan(`policy:${i.policyName}`,async u=>{try{let l=await i.handler(e,r);if(l instanceof Request||l instanceof de||l instanceof Response)return l instanceof Response||l instanceof de?l:new de(l);{let d=new R(`Invalid state - invalid handler on policy '${i.policyName}' invoked via 'invokeInboundPolicy' on route '${r.route.path}'. The result of an inbound policy must be a Response or Request.`);throw u.setStatus({code:GR.ERROR}),u.recordException(d),d}}finally{u.end()}})},"invokeInboundPolicy"),WR=s(async(t,e,r,o)=>{let n=Pe.instance.routeData.policies,i=Wn([t],n);if(i.length===0)throw new z(`Invalid 'invokeOutboundPolicy call' - no policy '${t}' found.`);let a=i[0];return await VR.getTracer("pipeline").startActiveSpan(`policy:${a.policyName}`,async l=>{try{let d=await a.handler(e,r,o);if(d instanceof Response)return d;{let p=new R(`Invalid state - invalid handler on policy '${a.policyName}' invoked via 'invokeOutboundPolicy' on route '${o.route.path}. The result of an outbound policy must be a Response.`);throw l.setStatus({code:GR.ERROR}),l.recordException(p),p}}finally{l.end()}})},"invokeOutboundPolicy");function o$(t){let e={};if(!t)return e;try{let r=t.split(","),o={};return r.forEach(n=>{let[i,a]=n.split("=");i&&a&&(o[i.trim()]=a.trim())}),o.asnum&&(e[xi]=o.asnum),o.zip&&(e[Ri]=o.zip.split("+")[0]),o.dma&&(e[Ii]=o.dma),o.region_code&&(e[Pi]=o.region_code),o.timezone&&(e[Si]=o.timezone),o.city&&(e[hi]=o.city),o.continent&&(e[yi]=o.continent),o.country_code&&(e[bi]=o.country_code),o.long&&(e[vi]=o.long),o.lat&&(e[wi]=o.lat),e}catch{return{}}}s(o$,"parseEdgeScapeHeader");function KR(t,e){let r=o$(e);for(let[o,n]of Object.entries(r))t.has(o)||t.set(o,n)}s(KR,"setZpHeadersFromAkamaiEdgeScapeHeader");var Yi=class{static{s(this,"HeaderIncomingRequestProperties")}#e;constructor(e){this.#e=e;let r=e.get(Lh);if(r){let o=new Headers(e);KR(o,r),this.#e=o}}get asn(){try{let e=this.#e.get(xi);if(typeof e=="string")return parseInt(e,10)}catch{}}get asOrganization(){return this.#e.get(Ch)??void 0}get city(){return this.#e.get(dh)??this.#e.get(hi)??void 0}get continent(){return this.#e.get(ph)??this.#e.get(yi)??void 0}get country(){return this.#e.get(mh)??this.#e.get(bi)??void 0}get latitude(){return this.#e.get(gh)??this.#e.get(wi)??void 0}get longitude(){return this.#e.get(fh)??this.#e.get(vi)??void 0}get colo(){return this.#e.get(_h)??void 0}get postalCode(){return this.#e.get(vh)??this.#e.get(Ri)??void 0}get metroCode(){return this.#e.get(bh)??this.#e.get(Ii)??void 0}get region(){return this.#e.get(hh)??this.#e.get(Oh)??void 0}get regionCode(){return this.#e.get(yh)??this.#e.get(Pi)??void 0}get timezone(){return this.#e.get(wh)??this.#e.get(Si)??void 0}get httpProtocol(){return this.#e.get(Ah)??void 0}get clientCert(){return this.#e.get(xh)??void 0}get clientMtlsVerificationStatus(){return this.#e.get(Rh)??void 0}get clientMtlsVerificationReason(){return this.#e.get(Ih)??void 0}get clientCertFingerprintSha256(){return this.#e.get(Ph)??void 0}get clientCertNotBefore(){return this.#e.get(Sh)??void 0}get clientCertNotAfter(){return this.#e.get(Th)??void 0}get clientCertIssuerDn(){return this.#e.get(kh)??void 0}get clientCertSubjectDn(){return this.#e.get(Eh)??void 0}toJSON(){return{asn:this.asn,asOrganization:this.asOrganization,city:this.city,continent:this.continent,country:this.country,latitude:this.latitude,longitude:this.longitude,colo:this.colo,postalCode:this.postalCode,metroCode:this.metroCode,region:this.region,regionCode:this.regionCode,timezone:this.timezone,httpProtocol:this.httpProtocol,clientCert:this.clientCert,clientMtlsVerificationStatus:this.clientMtlsVerificationStatus,clientMtlsVerificationReason:this.clientMtlsVerificationReason,clientCertFingerprintSha256:this.clientCertFingerprintSha256,clientCertNotBefore:this.clientCertNotBefore,clientCertNotAfter:this.clientCertNotAfter,clientCertIssuerDn:this.clientCertIssuerDn,clientCertSubjectDn:this.clientCertSubjectDn}}};function yr(t){return{contextId:t.contextId,incomingRequestProperties:t.incomingRequestProperties,requestId:t.requestId,route:t.route,custom:t.custom,parentContext:t.parentContext,analyticsContext:t.analyticsContext}}s(yr,"createRewriteContext");var Vn=class extends Event{static{s(this,"ResponseSendingEvent")}constructor(e,r){super("responseSending"),this.request=e,this.mutableResponse=r}request;mutableResponse},Jn=class extends Event{static{s(this,"ResponseSentEvent")}constructor(e,r){super("responseSent"),this.request=e,this.response=r}request;response},Je=class t{static{s(this,"ZuploContextExtensions")}static#e=new WeakMap;static initialize(e,r){if(!t.#e.has(e)){let o=new t(r);return t.#e.set(e,o),o}throw new Error(`ZuploContextExtensions already initialized for context with requestId '${e.requestId}'`)}static getContextExtensions(e){let r=t.#e.get(e);if(!r)throw new z(`Invalid state, could not get ZuploContext extensions for context with requestId '${e.requestId}'`);return r}latestRequest;#t;#n;#r;constructor(e){this.latestRequest=e,this.#t=[],this.#n=[],this.#r=[]}addResponseSendingHook(e){this.#n.push(e)}addResponseSendingFinalHook(e){this.#t.push(e)}addHandlerResponseHook(e){this.#r.push(e)}onResponseSendingFinal=s(async(e,r,o)=>{for(let n of this.#t)await n(e,r,o)},"onResponseSendingFinal");onResponseSending=s(async(e,r,o)=>{let n=e,i=T.instance.build.COMPATIBILITY_FLAGS.chainResponseSendingHooks;for(let a of this.#n)n=await a(i?n:e,r,o);return n},"onResponseSending");onHandlerResponse=s(async(e,r,o)=>{for(let n of this.#r)await n(e,r,o)},"onHandlerResponse")},Xi=class extends EventTarget{static{s(this,"SystemZuploContext")}constructor({logger:e,route:r,requestId:o,event:n,custom:i,incomingRequestProperties:a,parentContext:c}){super(),this.log=Object.freeze(e),this.route=r,this.requestId=o,this.custom=i,this.incomingRequestProperties=a,this.parentContext=c,this.#e=n,this.invokeInboundPolicy=(u,l)=>JR(u,l,this),this.contextId=crypto.randomUUID(),this.invokeOutboundPolicy=(u,l,d)=>WR(u,l,d,this),this.invokeRoute=async(u,l)=>{let d=u;typeof u=="string"&&u.startsWith("/")&&(d=new URL(u,"http://localhost"));let p=new de(d,l);return Pe.instance.handleRequest(p,this,{parentContext:this})},this.waitUntil=u=>{this.#e.waitUntil(u)},this.addResponseSendingHook=u=>{Je.getContextExtensions(this).addResponseSendingHook(u)},this.addResponseSendingFinalHook=u=>{Je.getContextExtensions(this).addResponseSendingFinalHook(u)},this.analyticsContext=new jh(o),Object.freeze(this)}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;invokeInboundPolicy;invokeOutboundPolicy;invokeRoute;waitUntil;addResponseSendingHook;addResponseSendingFinalHook;addEventListener(e,r,o){P("context.addEventListener");let n=s(i=>{try{typeof r=="function"?r(i):r.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,n,o)}removeEventListener(e,r,o){P("context.removeEventListener"),super.removeEventListener(e,r,o)}};export{P as a,Le as b,Xa as c,jn as d,we as e,nc as f,zn as g,Zn as h,vr as i,M as j,Ue as k,wr as l,de as m,ic as n,sc as o,ue as p,lt as q,Bt as r,ke as s,ir as t,mc as u,bc as v,Br as w,My as x,Vn as y,Jn as z,Je as A,fe as B,Hc as C,ot as D,wP as E,OP as F,AP as G,ub as H,zP as I,Xc as J,Xs as K,im as L,$T as M,Sv as N,Tv as O,_v as P,ik as Q,na as R,Tm as S,uk as T,dk as U,la as V,pk as W,Uv as X,zv as Y,Fv as Z,Bv as _,oa as $,Pk as aa,Ek as ba,Ck as ca,Lm as da,h as ea,je as fa,_E as ga,nC as ha,iC as ia,aC as ja,cC as ka,lC as la,pC as ma,fC as na,bC as oa,rf as pa,of as qa,af as ra,lf as sa,pf as ta,ff as ua,hf as va,bf as wa,xf as xa,Pf as ya,kf as za,_f as Aa,Af as Ba,$f as Ca,ri as Da,ni as Ea,oi as Fa,Uf as Ga,ai as Ha,Zf as Ia,qf as Ja,XC as Ka,Ff as La,Hf as Ma,r_ as Na,o_ as Oa,s_ as Pa,u_ as Qa,l_ as Ra,d_ as Sa,p_ as Ta,R_ as Ua,P_ as Va,Xf as Wa,S_ as Xa,eg as Ya,E_ as Za,it as _a,M_ as $a,ig as ab,sg as bb,U_ as cb,ug as db,W_ as eb,K_ as fb,Q_ as gb,Y_ as hb,X_ as ib,eO as jb,aO as kb,yg as lb,hO as mb,yO as nb,bO as ob,wO as pb,xO as qb,PO as rb,SO as sb,kO as tb,EO as ub,CO as vb,$O as wb,MO as xb,Ig as yb,FO as zb,Sg as Ab,WO as Bb,Tg as Cb,Eg as Db,KO as Eb,YO as Fb,XO as Gb,Og as Hb,RR as Ib,iA as Jb,sA as Kb,aA as Lb,cA as Mb,uA as Nb,lA as Ob,_R as Pb,dA as Qb,pA as Rb,fA as Sb,wA as Tb,xA as Ub,RA as Vb,IA as Wb,PA as Xb,SA as Yb,TA as Zb,EA as _b,Dg as $b,UA as ac,jA as bc,ZA as cc,HA as dc,mi as ec,zg as fc,BA as gc,VA as hc,Hg as ic,JA as jc,r$ as kc,Gg as lc,Vg as mc,Jg as nc,si as oc};
317
+ /*! For license information please see chunk-YTQ3TTI6.js.LEGAL.txt */
318
+ //# sourceMappingURL=chunk-YTQ3TTI6.js.map