@wraps.dev/cli 3.4.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +864 -598
- package/dist/cli.js.map +1 -1
- package/dist/console/assets/index-CGthEkGy.js +127 -0
- package/dist/console/index.html +1 -1
- package/dist/lambda/agent-enforcer/.bundled +1 -1
- package/dist/lambda/agent-enforcer/index.js +13 -13
- package/dist/lambda/agent-enforcer/index.test.ts +99 -0
- package/dist/lambda/agent-enforcer/index.ts +54 -0
- package/dist/lambda/event-processor/.bundled +1 -1
- package/dist/lambda/inbound-processor/.bundled +1 -1
- package/dist/lambda/inbound-processor/index.js +56 -56
- package/dist/lambda/sms-event-processor/.bundled +1 -1
- package/package.json +3 -3
- package/dist/console/assets/index-YRZcw9N8.js +0 -127
package/dist/console/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"
|
|
12
12
|
rel="stylesheet"
|
|
13
13
|
>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-CGthEkGy.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-DWGm-yr4.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Built at: 2026-
|
|
1
|
+
Built at: 2026-09-03T04:11:31.040Z
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ic=Object.create;var ut=Object.defineProperty;var ac=Object.getOwnPropertyDescriptor;var cc=Object.getOwnPropertyNames;var fc=Object.getPrototypeOf,mc=Object.prototype.hasOwnProperty;var m=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(n){throw r=[n],n}};var Xn=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},lt=(t,e)=>{for(var r in e)ut(t,r,{get:e[r],enumerable:!0})},Zn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of cc(e))!mc.call(t,o)&&o!==r&&ut(t,o,{get:()=>e[o],enumerable:!(n=ac(e,o))||n.enumerable});return t};var xe=(t,e,r)=>(r=t!=null?ic(fc(t)):{},Zn(e||!t||!t.__esModule?ut(r,"default",{value:t,enumerable:!0}):r,t)),Sr=t=>Zn(ut({},"__esModule",{value:!0}),t);var dt,br=m(()=>{dt=t=>typeof ArrayBuffer=="function"&&t instanceof ArrayBuffer||Object.prototype.toString.call(t)==="[object ArrayBuffer]"});var $,te,re=m(()=>{br();$=(t,e=0,r=t.byteLength-e)=>{if(!dt(t))throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof t} (${t})`);return Buffer.from(t,e,r)},te=(t,e)=>{if(typeof t!="string")throw new TypeError(`The "input" argument must be of type string. Received type ${typeof t} (${t})`);return e?Buffer.from(t,e):Buffer.from(t)}});var uc,Ee,Yn=m(()=>{re();uc=/^[A-Za-z0-9+/]*={0,2}$/,Ee=t=>{if(t.length*3%4!==0)throw new TypeError("Incorrect padding on base64 string.");if(!uc.exec(t))throw new TypeError("Invalid base64 string.");let e=te(t,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}});var B,ht=m(()=>{re();B=t=>{let e=te(t,"utf8");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)}});var ne,wr=m(()=>{re();ht();ne=t=>{let e;if(typeof t=="string"?e=B(t):e=t,typeof e!="object"||typeof e.byteOffset!="number"||typeof e.byteLength!="number")throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");return $(e.buffer,e.byteOffset,e.byteLength).toString("base64")}});function eo(t,e,r,n){return class pt extends Uint8Array{static fromString(s,i="utf-8"){if(typeof s=="string")return i==="base64"?pt.mutate(n(s)):pt.mutate(e(s));throw new Error(`Unsupported conversion from ${typeof s} to Uint8ArrayBlobAdapter.`)}static mutate(s){return Object.setPrototypeOf(s,pt.prototype),s}transformToString(s="utf-8"){return s==="base64"?r(this):t(this)}}}var to=m(()=>{});var W,ro=m(()=>{re();W=t=>{if(typeof t=="string")return t;if(typeof t!="object"||typeof t.byteOffset!="number"||typeof t.byteLength!="number")throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return $(t.buffer,t.byteOffset,t.byteLength).toString("utf8")}});function no(t){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?()=>crypto.randomUUID():()=>{let e=new Uint8Array(16);return t(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128,v[e[0]]+v[e[1]]+v[e[2]]+v[e[3]]+"-"+v[e[4]]+v[e[5]]+"-"+v[e[6]]+v[e[7]]+"-"+v[e[8]]+v[e[9]]+"-"+v[e[10]]+v[e[11]]+v[e[12]]+v[e[13]]+v[e[14]]+v[e[15]]}}var v,oo=m(()=>{v=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"))});var so,io=m(()=>{so=(t,e,r=n=>n)=>t});var ao,co,Te,lc,We,Ce,fo,gt,yt,St,xr,dc,mo,Er,uo,lo,Je,ho,wt,hc,Ae,xt,po,go,yo,So,Tr,bo,wo,oe,Et,bt,Ie,Cr=m(()=>{ao=t=>{switch(t){case"true":return!0;case"false":return!1;default:throw new Error(`Unable to parse boolean value "${t}"`)}},co=t=>{if(t!=null){if(typeof t=="number"){if((t===0||t===1)&&Ie.warn(bt(`Expected boolean, got ${typeof t}: ${t}`)),t===0)return!1;if(t===1)return!0}if(typeof t=="string"){let e=t.toLowerCase();if((e==="false"||e==="true")&&Ie.warn(bt(`Expected boolean, got ${typeof t}: ${t}`)),e==="false")return!1;if(e==="true")return!0}if(typeof t=="boolean")return t;throw new TypeError(`Expected boolean, got ${typeof t}: ${t}`)}},Te=t=>{if(t!=null){if(typeof t=="string"){let e=parseFloat(t);if(!Number.isNaN(e))return String(e)!==String(t)&&Ie.warn(bt(`Expected number but observed string: ${t}`)),e}if(typeof t=="number")return t;throw new TypeError(`Expected number, got ${typeof t}: ${t}`)}},lc=Math.ceil(34028234663852886e22),We=t=>{let e=Te(t);if(e!==void 0&&!Number.isNaN(e)&&e!==1/0&&e!==-1/0&&Math.abs(e)>lc)throw new TypeError(`Expected 32-bit float, got ${t}`);return e},Ce=t=>{if(t!=null){if(Number.isInteger(t)&&!Number.isNaN(t))return t;throw new TypeError(`Expected integer, got ${typeof t}: ${t}`)}},fo=Ce,gt=t=>xr(t,32),yt=t=>xr(t,16),St=t=>xr(t,8),xr=(t,e)=>{let r=Ce(t);if(r!==void 0&&dc(r,e)!==r)throw new TypeError(`Expected ${e}-bit integer, got ${t}`);return r},dc=(t,e)=>{switch(e){case 32:return Int32Array.of(t)[0];case 16:return Int16Array.of(t)[0];case 8:return Int8Array.of(t)[0]}},mo=(t,e)=>{if(t==null)throw e?new TypeError(`Expected a non-null value for ${e}`):new TypeError("Expected a non-null value");return t},Er=t=>{if(t==null)return;if(typeof t=="object"&&!Array.isArray(t))return t;let e=Array.isArray(t)?"array":typeof t;throw new TypeError(`Expected object, got ${e}: ${t}`)},uo=t=>{if(t!=null){if(typeof t=="string")return t;if(["boolean","number","bigint"].includes(typeof t))return Ie.warn(bt(`Expected string, got ${typeof t}: ${t}`)),String(t);throw new TypeError(`Expected string, got ${typeof t}: ${t}`)}},lo=t=>{if(t==null)return;let e=Er(t),r=[];for(let n in e)e[n]!=null&&r.push(n);if(r.length===0)throw new TypeError("Unions must have exactly one non-null member. None were found.");if(r.length>1)throw new TypeError(`Unions must have exactly one non-null member. Keys ${r} were not null.`);return e},Je=t=>Te(typeof t=="string"?Ae(t):t),ho=Je,wt=t=>We(typeof t=="string"?Ae(t):t),hc=/(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|(-?Infinity)|(NaN)/g,Ae=t=>{let e=t.match(hc);if(e===null||e[0].length!==t.length)throw new TypeError("Expected real number, got implicit NaN");return parseFloat(t)},xt=t=>typeof t=="string"?So(t):Te(t),po=xt,go=xt,yo=t=>typeof t=="string"?So(t):We(t),So=t=>{switch(t){case"NaN":return NaN;case"Infinity":return 1/0;case"-Infinity":return-1/0;default:throw new Error(`Unable to parse float value: ${t}`)}},Tr=t=>Ce(typeof t=="string"?Ae(t):t),bo=Tr,wo=t=>gt(typeof t=="string"?Ae(t):t),oe=t=>yt(typeof t=="string"?Ae(t):t),Et=t=>St(typeof t=="string"?Ae(t):t),bt=t=>String(new TypeError(t).stack||t).split(`
|
|
2
2
|
`).slice(0,5).filter(e=>!e.includes("stackTraceWarning")).join(`
|
|
3
|
-
`),Ie={warn:console.warn}});function Tt(t){let e=t.getUTCFullYear(),r=t.getUTCMonth(),n=t.getUTCDay(),o=t.getUTCDate(),s=t.getUTCHours(),i=t.getUTCMinutes(),a=t.getUTCSeconds(),c=o<10?`0${o}`:`${o}`,f=s<10?`0${s}`:`${s}`,u=i<10?`0${i}`:`${i}`,l=a<10?`0${a}`:`${a}`;return`${lc[n]}, ${c} ${Ar[r]} ${e} ${f}:${u}:${l} GMT`}var lc,Ar,hc,wo,pc,xo,gc,yc,Sc,Eo,To,Ke,bc,wc,xc,Ir,Ec,Tc,Cc,j,Ic,Ac,ve,Co=m(()=>{Cr();lc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ar=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];hc=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/),wo=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let e=hc.exec(t);if(!e)throw new TypeError("Invalid RFC-3339 date-time value");let[r,n,o,s,i,a,c,f]=e,u=oe(ve(n)),l=j(o,"month",1,12),d=j(s,"day",1,31);return Ke(u,l,d,{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f})},pc=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}:\d{2})|[zZ])$/),xo=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let e=pc.exec(t);if(!e)throw new TypeError("Invalid RFC-3339 date-time value");let[r,n,o,s,i,a,c,f,u]=e,l=oe(ve(n)),d=j(o,"month",1,12),h=j(s,"day",1,31),p=Ke(l,d,h,{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f});return u.toUpperCase()!="Z"&&p.setTime(p.getTime()-Ac(u)),p},gc=new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/),yc=new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/),Sc=new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( [1-9]|\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? (\d{4})$/),Eo=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC-7231 date-times must be expressed as strings");let e=gc.exec(t);if(e){let[r,n,o,s,i,a,c,f]=e;return Ke(oe(ve(s)),Ir(o),j(n,"day",1,31),{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f})}if(e=yc.exec(t),e){let[r,n,o,s,i,a,c,f]=e;return xc(Ke(bc(s),Ir(o),j(n,"day",1,31),{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f}))}if(e=Sc.exec(t),e){let[r,n,o,s,i,a,c,f]=e;return Ke(oe(ve(f)),Ir(n),j(o.trimLeft(),"day",1,31),{hours:s,minutes:i,seconds:a,fractionalMilliseconds:c})}throw new TypeError("Invalid RFC-7231 date-time value")},To=t=>{if(t==null)return;let e;if(typeof t=="number")e=t;else if(typeof t=="string")e=Je(t);else if(typeof t=="object"&&t.tag===1)e=t.value;else throw new TypeError("Epoch timestamps must be expressed as floating point numbers or their string representation");if(Number.isNaN(e)||e===1/0||e===-1/0)throw new TypeError("Epoch timestamps must be valid, non-Infinite, non-NaN numerics");return new Date(Math.round(e*1e3))},Ke=(t,e,r,n)=>{let o=e-1;return Tc(t,o,r),new Date(Date.UTC(t,o,r,j(n.hours,"hour",0,23),j(n.minutes,"minute",0,59),j(n.seconds,"seconds",0,60),Ic(n.fractionalMilliseconds)))},bc=t=>{let e=new Date().getUTCFullYear(),r=Math.floor(e/100)*100+oe(ve(t));return r<e?r+100:r},wc=50*365*24*60*60*1e3,xc=t=>t.getTime()-new Date().getTime()>wc?new Date(Date.UTC(t.getUTCFullYear()-100,t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())):t,Ir=t=>{let e=Ar.indexOf(t);if(e<0)throw new TypeError(`Invalid month: ${t}`);return e+1},Ec=[31,28,31,30,31,30,31,31,30,31,30,31],Tc=(t,e,r)=>{let n=Ec[e];if(e===1&&Cc(t)&&(n=29),r>n)throw new TypeError(`Invalid day for ${Ar[e]} in ${t}: ${r}`)},Cc=t=>t%4===0&&(t%100!==0||t%400===0),j=(t,e,r,n)=>{let o=Et(ve(t));if(o<r||o>n)throw new TypeError(`${e} must be between ${r} and ${n}, inclusive`);return o},Ic=t=>t==null?0:wt("0."+t)*1e3,Ac=t=>{let e=t[0],r=1;if(e=="+")r=1;else if(e=="-")r=-1;else throw new TypeError(`Offset direction, ${e}, must be "+" or "-"`);let n=Number(t.substring(1,3)),o=Number(t.substring(4,6));return r*(n*60+o)*60*1e3},ve=t=>{let e=0;for(;e<t.length-1&&t.charAt(e)==="0";)e++;return e===0?t:t.slice(e)}});var k,Io=m(()=>{k=function(e){return Object.assign(new String(e),{deserializeJSON(){return JSON.parse(String(e))},toString(){return String(e)},toJSON(){return String(e)}})};k.from=t=>t&&typeof t=="object"&&(t instanceof k||"deserializeJSON"in t)?t:typeof t=="string"||Object.getPrototypeOf(t)===String.prototype?k(String(t)):k(JSON.stringify(t));k.fromObject=k.from});function Ct(t){return(t.includes(",")||t.includes('"'))&&(t=`"${t.replace(/"/g,'\\"')}"`),t}var Ao=m(()=>{});function J(t,e,r){let n=Number(t);if(n<e||n>r)throw new Error(`Value ${n} out of range [${e}, ${r}]`)}var vr,Rr,Nr,vo,Ro,vc,Rc,Nc,Oc,Mc,It,At,vt,No=m(()=>{vr="(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)(?:[ne|u?r]?s?day)?",Rr="(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)",Nr="(\\d?\\d):(\\d{2}):(\\d{2})(?:\\.(\\d+))?",vo="(\\d?\\d)",Ro="(\\d{4})",vc=new RegExp(/^(\d{4})-(\d\d)-(\d\d)[tT](\d\d):(\d\d):(\d\d)(\.(\d+))?(([-+]\d\d:\d\d)|[zZ])$/),Rc=new RegExp(`^${vr}, ${vo} ${Rr} ${Ro} ${Nr} GMT$`),Nc=new RegExp(`^${vr}, ${vo}-${Rr}-(\\d\\d) ${Nr} GMT$`),Oc=new RegExp(`^${vr} ${Rr} ( [1-9]|\\d\\d) ${Nr} ${Ro}$`),Mc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],It=t=>{if(t==null)return;let e=NaN;if(typeof t=="number")e=t;else if(typeof t=="string"){if(!/^-?\d*\.?\d+$/.test(t))throw new TypeError("parseEpochTimestamp - numeric string invalid.");e=Number.parseFloat(t)}else typeof t=="object"&&t.tag===1&&(e=t.value);if(isNaN(e)||Math.abs(e)===1/0)throw new TypeError("Epoch timestamps must be valid finite numbers.");return new Date(Math.round(e*1e3))},At=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC3339 timestamps must be strings");let e=vc.exec(t);if(!e)throw new TypeError(`Invalid RFC3339 timestamp format ${t}`);let[,r,n,o,s,i,a,,c,f]=e;J(n,1,12),J(o,1,31),J(s,0,23),J(i,0,59),J(a,0,60);let u=new Date(Date.UTC(Number(r),Number(n)-1,Number(o),Number(s),Number(i),Number(a),Number(c)?Math.round(parseFloat(`0.${c}`)*1e3):0));if(u.setUTCFullYear(Number(r)),f.toUpperCase()!="Z"){let[,l,d,h]=/([+-])(\d\d):(\d\d)/.exec(f)||[void 0,"+",0,0],p=l==="-"?1:-1;u.setTime(u.getTime()+p*(Number(d)*60*60*1e3+Number(h)*60*1e3))}return u},vt=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC7231 timestamps must be strings.");let e,r,n,o,s,i,a,c;if((c=Rc.exec(t))?[,e,r,n,o,s,i,a]=c:(c=Nc.exec(t))?([,e,r,n,o,s,i,a]=c,n=(Number(n)+1900).toString()):(c=Oc.exec(t))&&([,r,e,o,s,i,a,n]=c),n&&i){let f=Date.UTC(Number(n),Mc.indexOf(r),Number(e),Number(o),Number(s),Number(i),a?Math.round(parseFloat(`0.${a}`)*1e3):0);J(e,1,31),J(o,0,23),J(s,0,59),J(i,0,60);let u=new Date(f);return u.setUTCFullYear(Number(n)),u}throw new TypeError(`Invalid RFC7231 date-time value ${t}.`)}});function Rt(t,e,r){if(r<=0||!Number.isInteger(r))throw new Error("Invalid number of delimiters ("+r+") for splitEvery.");let n=t.split(e);if(r===1)return n;let o=[],s="";for(let i=0;i<n.length;i++)s===""?s=n[i]:s+=e+n[i],(i+1)%r===0&&(o.push(s),s="");return s!==""&&o.push(s),o}var Oo=m(()=>{});var Re,Mo=m(()=>{Re=t=>{let e=t.length,r=[],n=!1,o,s=0;for(let i=0;i<e;++i){let a=t[i];switch(a){case'"':o!=="\\"&&(n=!n);break;case",":n||(r.push(t.slice(s,i)),s=i+1);break;default:}o=a}return r.push(t.slice(s)),r.map(i=>{i=i.trim();let a=i.length;return a<2?i:(i[0]==='"'&&i[a-1]==='"'&&(i=i.slice(1,a-1)),i.replace(/\\"/g,'"'))})}});function ko(t){return new le(String(t),"bigDecimal")}var Po,le,Uo=m(()=>{Po=/^-?((0|[1-9]\d*)(\.\d+)?|\.\d+)([eE][+-]?\d+)?$/,le=class t{string;type;constructor(e,r){if(this.string=e,this.type=r,!Po.test(e))throw new Error(`@smithy/core/serde - NumericValue string must conform to the Smithy bigDecimal format. Received: "${e}"`)}toString(){return this.string}static[Symbol.hasInstance](e){if(!e||typeof e!="object")return!1;let r=e;return t.prototype.isPrototypeOf(e)||r.type==="bigDecimal"&&Po.test(r.string)}}});function Nt(t){if(t.length%2!==0)throw new Error("Hex encoded strings must have an even number length");let e=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2){let n=t.slice(r,r+2).toLowerCase();if(n in Or)e[r/2]=Or[n];else throw new Error(`Cannot decode unrecognized sequence ${n} as hexadecimal`)}return e}function U(t){let e="";for(let r=0;r<t.byteLength;r++)e+=Do[t[r]];return e}var Do,Or,Mr=m(()=>{Do={},Or={};for(let t=0;t<256;t++){let e=t.toString(16).toLowerCase();e.length===1&&(e=`0${e}`),Do[t]=e,Or[e]=t}});var Ne,_o,$o=m(()=>{Ne=require("node:fs"),_o=t=>{if(!t)return 0;if(typeof t=="string")return Buffer.byteLength(t);if(typeof t.byteLength=="number")return t.byteLength;if(typeof t.size=="number")return t.size;if(typeof t.start=="number"&&typeof t.end=="number")return t.end+1-t.start;if(t instanceof Ne.ReadStream){if(t.path!=null)return(0,Ne.lstatSync)(t.path).size;if(typeof t.fd=="number")return(0,Ne.fstatSync)(t.fd).size}throw new Error(`Body Length computation failed for ${t}`)}});var Ot,Pr=m(()=>{ht();Ot=t=>t instanceof Uint8Array?t:typeof t=="string"?$(t):ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(t)});function se(t,e){if(e===void 0){e=0;for(let o of t)e+=o.byteLength}let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.byteLength;return r}var Qe=m(()=>{});var Ze=Qn(B=>{var kr;(function(t){t.HEADER="header",t.QUERY="query"})(kr||(kr={}));var Ur;(function(t){t.HEADER="header",t.QUERY="query"})(Ur||(Ur={}));var Dr;(function(t){t.HTTP="http",t.HTTPS="https"})(Dr||(Dr={}));var Xe;(function(t){t.MD5="md5",t.CRC32="crc32",t.CRC32C="crc32c",t.SHA1="sha1",t.SHA256="sha256"})(Xe||(Xe={}));var Pc=t=>{let e=[];return t.sha256!==void 0&&e.push({algorithmId:()=>Xe.SHA256,checksumConstructor:()=>t.sha256}),t.md5!=null&&e.push({algorithmId:()=>Xe.MD5,checksumConstructor:()=>t.md5}),{addChecksumAlgorithm(r){e.push(r)},checksumAlgorithms(){return e}}},kc=t=>{let e={};return t.checksumAlgorithms().forEach(r=>{e[r.algorithmId()]=r.checksumConstructor()}),e},Uc=t=>Pc(t),Dc=t=>kc(t),_r;(function(t){t[t.HEADER=0]="HEADER",t[t.TRAILER=1]="TRAILER"})(_r||(_r={}));var _c="__smithy_context",$r;(function(t){t.PROFILE="profile",t.SSO_SESSION="sso-session",t.SERVICES="services"})($r||($r={}));var Br;(function(t){t.HTTP_0_9="http/0.9",t.HTTP_1_0="http/1.0",t.TDS_8_0="tds/8.0"})(Br||(Br={}));B.AlgorithmId=Xe;B.EndpointURLScheme=Dr;B.FieldPosition=_r;B.HttpApiKeyAuthLocation=Ur;B.HttpAuthLocation=kr;B.IniSectionType=$r;B.RequestHandlerProtocol=Br;B.SMITHY_CONTEXT_KEY=_c;B.getDefaultClientConfiguration=Uc;B.resolveDefaultRuntimeConfig=Dc});var Lr,Fr,Bo=m(()=>{Lr=xe(Ze()),Fr=t=>t[Lr.SMITHY_CONTEXT_KEY]||(t[Lr.SMITHY_CONTEXT_KEY]={})});function $c(t){return Object.keys(t).reduce((e,r)=>{let n=t[r];return{...e,[r]:Array.isArray(n)?[...n]:n}},{})}var P,Lo=m(()=>{P=class t{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(e){this.method=e.method||"GET",this.hostname=e.hostname||"localhost",this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)!==":"?`${e.protocol}:`:e.protocol:"https:",this.path=e.path?e.path.charAt(0)!=="/"?`/${e.path}`:e.path:"/",this.username=e.username,this.password=e.password,this.fragment=e.fragment}static clone(e){let r=new t({...e,headers:{...e.headers}});return r.query&&(r.query=$c(r.query)),r}static isInstance(e){if(!e)return!1;let r=e;return"method"in r&&"protocol"in r&&"hostname"in r&&"path"in r&&typeof r.query=="object"&&typeof r.headers=="object"}clone(){return t.clone(this)}}});var K,Fo=m(()=>{K=class{statusCode;reason;headers;body;constructor(e){this.statusCode=e.statusCode,this.reason=e.reason,this.headers=e.headers||{},this.body=e.body}static isInstance(e){if(!e)return!1;let r=e;return typeof r.statusCode=="number"&&typeof r.headers=="object"}}});function Ye(t){return/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(t)}var zo=m(()=>{});var et,Ho=m(()=>{et=t=>{if(typeof t=="function")return t;let e=Promise.resolve(t);return()=>e}});function tt(t){let e={};if(t=t.replace(/^\?/,""),t)for(let r of t.split("&")){let[n,o=null]=r.split("=");n=decodeURIComponent(n),o&&(o=decodeURIComponent(o)),n in e?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o}return e}var zr=m(()=>{});var he,Hr=m(()=>{zr();he=t=>{if(typeof t=="string")return he(new URL(t));let{hostname:e,pathname:r,port:n,protocol:o,search:s}=t,i;return s&&(i=tt(s)),{hostname:e,port:n?parseInt(n):void 0,protocol:o,path:r,query:i}}});var Q,jo=m(()=>{Hr();Q=t=>{if(typeof t=="object"){if("url"in t){let e=he(t.url);if(t.headers){e.headers={};for(let r in t.headers)e.headers[r.toLowerCase()]=t.headers[r].join(", ")}return e}return t}return he(t)}});var N=m(()=>{Bo();Lo();Fo();zo();Ho();zr();Hr();jo()});var Mt,jr,Vr=m(()=>{N();Mt=(t,e)=>(r,n)=>async o=>{let{response:s}=await r(o);try{let i=await e(s,t);return{response:s,output:i}}catch(i){if(Object.defineProperty(i,"$response",{value:s,enumerable:!1,writable:!1,configurable:!1}),!("$metadata"in i)){let a="Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.";try{i.message+=`
|
|
4
|
-
`+a}catch{!n.logger||n.logger?.constructor?.name==="NoOpLogger"?console.warn(a):n.logger?.warn?.(a)}typeof i.$responseBodyText<"u"&&i.$response&&(i.$response.body=i.$responseBodyText);try{if(K.isInstance(s)){let{headers:c={}}=s,f=Object.entries(c);i.$metadata={httpStatusCode:s.statusCode,requestId:jr(/^x-[\w-]+-request-?id$/,f),extendedRequestId:jr(/^x-[\w-]+-id-2$/,f),cfId:jr(/^x-[\w-]+-cf-id$/,f)}}}catch{}}throw i}},jr=(t,e)=>(e.find(([r])=>r.match(t))||[void 0,void 0])[1]});var Oe,Gr=m(()=>{Oe=class t extends Error{name="ProviderError";tryNextLink;constructor(e,r=!0){let n,o=!0;typeof r=="boolean"?(n=void 0,o=r):r!=null&&typeof r=="object"&&(n=r.logger,o=r.tryNextLink??!0),super(e),this.tryNextLink=o,Object.setPrototypeOf(this,t.prototype),n?.debug?.(`@smithy/property-provider ${o?"->":"(!)"} ${e}`)}static from(e,r=!0){return Object.assign(new this(e.message,r),e)}}});var Me,qr=m(()=>{Gr();Me=class t extends Oe{name="CredentialsProviderError";constructor(e,r=!0){super(e,r),Object.setPrototypeOf(this,t.prototype)}}});var Vo,Go=m(()=>{Gr();Vo=(...t)=>async()=>{if(t.length===0)throw new Oe("No providers in chain");let e;for(let r of t)try{return await r()}catch(n){if(e=n,n?.tryNextLink)continue;throw n}throw e}});var qo,Wo=m(()=>{qo=t=>()=>Promise.resolve(t)});var Jo,Ko=m(()=>{Jo=(t,e,r)=>{let n,o,s,i=!1,a=async()=>{o||(o=t());try{n=await o,s=!0,i=!1}finally{o=void 0}return n};return e===void 0?async c=>((!s||c?.forceRefresh)&&(n=await a()),n):async c=>((!s||c?.forceRefresh)&&(n=await a()),i?n:r&&!r(n)?(i=!0,n):(e(n)&&await a(),n))}});var Pt,Qo=m(()=>{Pt=(t,e,r)=>{if(e in t){if(t[e]==="true")return!0;if(t[e]==="false")return!1;throw new Error(`Cannot load ${r} "${e}". Expected "true" or "false", got ${t[e]}.`)}}});var Pe,Xo=m(()=>{(function(t){t.ENV="env",t.CONFIG="shared config entry"})(Pe||(Pe={}))});var Zo,Yo,Wr,Bc,ke,kt=m(()=>{Zo=require("node:os"),Yo=require("node:path"),Wr={},Bc=()=>process&&process.geteuid?`${process.geteuid()}`:"DEFAULT",ke=()=>{let{HOME:t,USERPROFILE:e,HOMEPATH:r,HOMEDRIVE:n=`C:${Yo.sep}`}=process.env;if(t)return t;if(e)return e;if(r)return`${n}${r}`;let o=Bc();return Wr[o]||(Wr[o]=(0,Zo.homedir)()),Wr[o]}});var Lc,Fc,es,ts=m(()=>{Lc="AWS_PROFILE",Fc="default",es=t=>t.profile||process.env[Lc]||Fc});var Jr,rs,ns=m(()=>{Jr=xe(Ze()),rs=t=>Object.entries(t).filter(([e])=>{let r=e.indexOf(".");return r===-1?!1:Object.values(Jr.IniSectionType).includes(e.substring(0,r))}).reduce((e,[r,n])=>{let o=r.indexOf("."),s=r.substring(0,o)===Jr.IniSectionType.PROFILE?r.substring(o+1):r;return e[s]=n,e},{...t.default&&{default:t.default}})});var os,zc,ss,is=m(()=>{os=require("node:path");kt();zc="AWS_CONFIG_FILE",ss=()=>process.env[zc]||(0,os.join)(ke(),".aws","config")});var as,Hc,cs,fs=m(()=>{as=require("node:path");kt();Hc="AWS_SHARED_CREDENTIALS_FILE",cs=()=>process.env[Hc]||(0,as.join)(ke(),".aws","credentials")});var ms,jc,Vc,Kr,us=m(()=>{ms=xe(Ze()),jc=/^([\w-]+)\s(["'])?([\w-@+.%:/]+)\2$/,Vc=["__proto__","profile __proto__"],Kr=t=>{let e={},r,n;for(let o of t.split(/\r?\n/)){let s=o.split(/(^|\s)[;#]/)[0].trim();if(s[0]==="["&&s[s.length-1]==="]"){r=void 0,n=void 0;let a=s.substring(1,s.length-1),c=jc.exec(a);if(c){let[,f,,u]=c;Object.values(ms.IniSectionType).includes(f)&&(r=[f,u].join("."))}else r=a;if(Vc.includes(a))throw new Error(`Found invalid profile name "${a}"`)}else if(r){let a=s.indexOf("=");if(![0,-1].includes(a)){let[c,f]=[s.substring(0,a).trim(),s.substring(a+1).trim()];if(f==="")n=c;else{n&&o.trimStart()===o&&(n=void 0),e[r]=e[r]||{};let u=n?[n,c].join("."):c;e[r][u]=f}}}}return e}});var ls,Qr,ds,Xr,hs=m(()=>{ls=require("node:fs/promises"),Qr={},ds={},Xr=(t,e)=>ds[t]!==void 0?ds[t]:((!Qr[t]||e?.ignoreCache)&&(Qr[t]=(0,ls.readFile)(t,"utf8")),Qr[t])});var Zr,ps,gs,ys=m(()=>{Zr=require("node:path");ns();is();fs();kt();us();hs();ps=()=>({}),gs=async(t={})=>{let{filepath:e=cs(),configFilepath:r=ss()}=t,n=ke(),o="~/",s=e;e.startsWith(o)&&(s=(0,Zr.join)(n,e.slice(2)));let i=r;r.startsWith(o)&&(i=(0,Zr.join)(n,r.slice(2)));let a=await Promise.all([Xr(i,{ignoreCache:t.ignoreCache}).then(Kr).then(rs).catch(ps),Xr(s,{ignoreCache:t.ignoreCache}).then(Kr).catch(ps)]);return{configFile:a[0],credentialsFile:a[1]}}});function Ut(t){try{let e=new Set(Array.from(t.match(/([A-Z_]){3,}/g)??[]));return e.delete("CONFIG"),e.delete("CONFIG_PREFIX_SEPARATOR"),e.delete("ENV"),[...e].join(", ")}catch{return t}}var Yr=m(()=>{});var Ss,bs=m(()=>{qr();Yr();Ss=(t,e)=>async()=>{try{let r=t(process.env,e);if(r===void 0)throw new Error;return r}catch(r){throw new Me(r.message||`Not found in ENV: ${Ut(t.toString())}`,{logger:e?.logger})}}});var ws,xs=m(()=>{qr();ts();ys();Yr();ws=(t,{preferredFile:e="config",...r}={})=>async()=>{let n=es(r),{configFile:o,credentialsFile:s}=await gs(r),i=s[n]||{},a=o[n]||{},c=e==="config"?{...i,...a}:{...a,...i};try{let u=t(c,e==="config"?o:s);if(u===void 0)throw new Error;return u}catch(f){throw new Me(f.message||`Not found in config files w/ profile [${n}]: ${Ut(t.toString())}`,{logger:r.logger})}}});var Gc,Es,Ts=m(()=>{Wo();Gc=t=>typeof t=="function",Es=t=>Gc(t)?async()=>await t():qo(t)});var Dt,Cs=m(()=>{Go();Ko();bs();xs();Ts();Dt=({environmentVariableSelector:t,configFileSelector:e,default:r},n={})=>{let{signingName:o,logger:s}=n;return Jo(Vo(Ss(t,{signingName:o,logger:s}),ws(e,n),Es(r)))}});var _t,Is=m(()=>{_t=t=>typeof t=="function"?t():t});function V(t){if(typeof t=="object")return t;if(t=t|0,$t[t])return $t[t];let e={},r=0;for(let n of["httpLabel","idempotent","idempotencyToken","sensitive","httpPayload","httpResponseCode","httpQueryParams"])(t>>r++&1)===1&&(e[n]=1);return $t[t]=e}var $t,en=m(()=>{$t=[]});function ot(t,e){if(t instanceof T)return Object.assign(t,{memberName:e,_isMemberSchema:!0});let r=T;return new r(t,e)}var nt,Bt,Lt,T,tn,As,vs=m(()=>{Is();en();nt={it:Symbol.for("@smithy/nor-struct-it"),ns:Symbol.for("@smithy/ns")},Bt=[],Lt={},T=class t{ref;memberName;static symbol=Symbol.for("@smithy/nor");symbol=t.symbol;name;schema;_isMemberSchema;traits;memberTraits;normalizedTraits;constructor(e,r){this.ref=e,this.memberName=r;let n=[],o=e,s=e;for(this._isMemberSchema=!1;tn(o);)n.push(o[1]),o=o[0],s=_t(o),this._isMemberSchema=!0;if(n.length>0){this.memberTraits={};for(let i=n.length-1;i>=0;--i){let a=n[i];Object.assign(this.memberTraits,V(a))}}else this.memberTraits=0;if(s instanceof t){let i=this.memberTraits;Object.assign(this,s),this.memberTraits=Object.assign({},i,s.getMemberTraits(),this.getMemberTraits()),this.normalizedTraits=void 0,this.memberName=r??s.memberName;return}if(this.schema=_t(s),As(this.schema)?(this.name=`${this.schema[1]}#${this.schema[2]}`,this.traits=this.schema[3]):(this.name=this.memberName??String(s),this.traits=0),this._isMemberSchema&&!r)throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(!0)} missing member name.`)}static[Symbol.hasInstance](e){let r=this.prototype.isPrototypeOf(e);return!r&&typeof e=="object"&&e!==null?e.symbol===this.symbol:r}static of(e){let r=typeof e=="function"||typeof e=="object"&&e!==null;if(typeof e=="number"){if(Bt[e])return Bt[e]}else if(typeof e=="string"){if(Lt[e])return Lt[e]}else if(r&&e[nt.ns])return e[nt.ns];let n=_t(e);if(n instanceof t)return n;if(tn(n)){let[s,i]=n;if(s instanceof t)return Object.assign(s.getMergedTraits(),V(i)),s;throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(e,null,2)}.`)}let o=new t(n);return r?e[nt.ns]=o:typeof n=="string"?Lt[n]=o:typeof n=="number"?Bt[n]=o:o}getSchema(){let e=this.schema;return Array.isArray(e)&&e[0]===0?e[4]:e}getName(e=!1){let{name:r}=this;return!e&&r&&r.includes("#")?r.split("#")[1]:r||void 0}getMemberName(){return this.memberName}isMemberSchema(){return this._isMemberSchema}isListSchema(){let e=this.getSchema();return typeof e=="number"?e>=64&&e<128:e[0]===1}isMapSchema(){let e=this.getSchema();return typeof e=="number"?e>=128&&e<=255:e[0]===2}isStructSchema(){let e=this.getSchema();if(typeof e!="object")return!1;let r=e[0];return r===3||r===-3||r===4}isUnionSchema(){let e=this.getSchema();return typeof e!="object"?!1:e[0]===4}isBlobSchema(){let e=this.getSchema();return e===21||e===42}isTimestampSchema(){let e=this.getSchema();return typeof e=="number"&&e>=4&&e<=7}isUnitSchema(){return this.getSchema()==="unit"}isDocumentSchema(){return this.getSchema()===15}isStringSchema(){return this.getSchema()===0}isBooleanSchema(){return this.getSchema()===2}isNumericSchema(){return this.getSchema()===1}isBigIntegerSchema(){return this.getSchema()===17}isBigDecimalSchema(){return this.getSchema()===19}isStreaming(){let{streaming:e}=this.getMergedTraits();return!!e||this.getSchema()===42}isIdempotencyToken(){return!!this.getMergedTraits().idempotencyToken}getMergedTraits(){return this.normalizedTraits??(this.normalizedTraits={...this.getOwnTraits(),...this.getMemberTraits()})}getMemberTraits(){return V(this.memberTraits)}getOwnTraits(){return V(this.traits)}getKeySchema(){let[e,r]=[this.isDocumentSchema(),this.isMapSchema()];if(!e&&!r)throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(!0)}`);let n=this.getSchema(),o=e?15:n[4]??0;return ot([o,0],"key")}getValueSchema(){let e=this.getSchema(),[r,n,o]=[this.isDocumentSchema(),this.isMapSchema(),this.isListSchema()],s=typeof e=="number"?63&e:e&&typeof e=="object"&&(n||o)?e[3+e[0]]:r?15:void 0;if(s!=null)return ot([s,0],n?"value":"member");throw new Error(`@smithy/core/schema - ${this.getName(!0)} has no value member.`)}getMemberSchema(e){let r=this.getSchema();if(this.isStructSchema()&&r[4].includes(e)){let n=r[4].indexOf(e),o=r[5][n];return ot(tn(o)?o:[o,0],e)}if(this.isDocumentSchema())return ot([15,0],e);throw new Error(`@smithy/core/schema - ${this.getName(!0)} has no member=${e}.`)}getMemberSchemas(){let e={};try{for(let[r,n]of this.structIterator())e[r]=n}catch{}return e}getEventStreamMember(){if(this.isStructSchema()){for(let[e,r]of this.structIterator())if(r.isStreaming()&&r.isStructSchema())return e}return""}*structIterator(){if(this.isUnitSchema())return;if(!this.isStructSchema())throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");let e=this.getSchema(),r=e[4].length,n=e[nt.it];if(n&&r===n.length){yield*n;return}n=Array(r);for(let o=0;o<r;++o){let s=e[4][o],i=ot([e[5][o],0],s);yield n[o]=[s,i]}e[nt.it]=n}};tn=t=>Array.isArray(t)&&t.length===2,As=t=>Array.isArray(t)&&t.length>=5});var pe,Rs=m(()=>{pe=class t{namespace;schemas;exceptions;static registries=new Map;constructor(e,r=new Map,n=new Map){this.namespace=e,this.schemas=r,this.exceptions=n}static for(e){return t.registries.has(e)||t.registries.set(e,new t(e)),t.registries.get(e)}copyFrom(e){let{schemas:r,exceptions:n}=this;for(let[o,s]of e.schemas)r.has(o)||r.set(o,s);for(let[o,s]of e.exceptions)n.has(o)||n.set(o,s)}register(e,r){let n=this.normalizeShapeId(e);for(let o of[this,t.for(n.split("#")[0])])o.schemas.set(n,r)}getSchema(e){let r=this.normalizeShapeId(e);if(!this.schemas.has(r)){if(!e.includes("#")){let n="#"+e,o=[];for(let[s,i]of this.schemas.entries())s.endsWith(n)&&o.push(i);if(o.length===1)return o[0]}throw new Error(`@smithy/core/schema - schema not found for ${r}`)}return this.schemas.get(r)}registerError(e,r){let n=e,o=n[1];for(let s of[this,t.for(o)])s.schemas.set(o+"#"+n[2],n),s.exceptions.set(n,r)}getErrorCtor(e){let r=e;return this.exceptions.has(r)?this.exceptions.get(r):t.for(r[1]).exceptions.get(r)}getBaseException(){for(let e of this.exceptions.keys())if(Array.isArray(e)){let[,r,n]=e,o=r+"#"+n;if(o.startsWith("smithy.ts.sdk.synthetic.")&&o.endsWith("ServiceException"))return e}}find(e){for(let r of this.schemas.values())if(e(r))return r}clear(){this.schemas.clear(),this.exceptions.clear()}normalizeShapeId(e){return e.includes("#")?e:this.namespace+"#"+e}}});var X=m(()=>{vs();en();Rs()});var rn=m(()=>{Qo();Xo();Cs()});var Ns,Os,Ms,Ps=m(()=>{Ns="AWS_ENDPOINT_URL",Os="endpoint_url",Ms=t=>({environmentVariableSelector:e=>{let r=t.split(" ").map(s=>s.toUpperCase()),n=e[[Ns,...r].join("_")];if(n)return n;let o=e[Ns];if(o)return o},configFileSelector:(e,r)=>{if(e.services){let o=["services",e.services].join(".");if(!r||!r[o])throw new Error(`The services section "${e.services}" specified in the profile is not present in the shared configuration file.`);let s=r[o],i=t.split(" ").map(c=>c.toLowerCase()),a=s[[i.join("_"),Os].join(".")];if(a)return a}let n=e[Os];if(n)return n},default:void 0})});var qc,Wc,ks,Us=m(()=>{rn();qc="AWS_IGNORE_CONFIGURED_ENDPOINT_URLS",Wc="ignore_configured_endpoint_urls",ks={environmentVariableSelector:t=>Pt(t,qc,Pe.ENV),configFileSelector:t=>Pt(t,Wc,Pe.CONFIG),default:!1}});var st,Ds=m(()=>{rn();Ps();Us();st=async t=>{if(!await Dt(ks)())return Dt(Ms(t??""))()}});var nn,Jc,Kc,Qc,_s,$s,Bs=m(()=>{nn=async t=>{let e=t?.Bucket||"";if(typeof t.Bucket=="string"&&(t.Bucket=e.replace(/#/g,encodeURIComponent("#")).replace(/\?/g,encodeURIComponent("?"))),$s(e)){if(t.ForcePathStyle===!0)throw new Error("Path-style addressing cannot be used with ARN buckets")}else(!_s(e)||e.indexOf(".")!==-1&&!String(t.Endpoint).startsWith("http:")||e.toLowerCase()!==e||e.length<3)&&(t.ForcePathStyle=!0);return t.DisableMultiRegionAccessPoints&&(t.disableMultiRegionAccessPoints=!0,t.DisableMRAP=!0),t},Jc=/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/,Kc=/(\d+\.){3}\d+/,Qc=/\.\./,_s=t=>Jc.test(t)&&!Kc.test(t)&&!Qc.test(t),$s=t=>{let[e,r,n,,,o]=t.split(":"),s=e==="arn"&&t.split(":").length>=6,i=!!(s&&r&&n&&o);if(s&&!i)throw new Error(`Invalid ARN: ${t} was an invalid ARN.`);return i}});var Ls=m(()=>{Bs()});var Fs,zs=m(()=>{Fs=(t,e,r,n=!1)=>{let o=async()=>{let s;return n?s=r.clientContextParams?.[t]??r[t]??r[e]:s=r[t]??r[e],typeof s=="function"?s():s};return t==="credentialScope"||e==="CredentialScope"?async()=>{let s=typeof r.credentials=="function"?await r.credentials():r.credentials;return s?.credentialScope??s?.CredentialScope}:t==="accountId"||e==="AccountId"?async()=>{let s=typeof r.credentials=="function"?await r.credentials():r.credentials;return s?.accountId??s?.AccountId}:t==="endpoint"||e==="endpoint"?async()=>{if(r.isCustomEndpoint===!1)return;let s=await o();if(s&&typeof s=="object"){if("url"in s)return s.url.href;if("hostname"in s){let{protocol:i,hostname:a,port:c,path:f}=s;return`${i}//${a}${c?":"+c:""}${f}`}}return s}:o}});var on=m(()=>{N()});function Ft(t){return async(e,r,n,o)=>{if(!n.isCustomEndpoint&&!n.ignoreConfiguredEndpointUrls){let a;n.serviceConfiguredEndpoint?a=await n.serviceConfiguredEndpoint():a=await t(n.serviceId),a&&(n.endpoint=()=>Promise.resolve(Q(a)),n.isCustomEndpoint=!0,o?.logger?.debug?.(`@smithy/core/endpoints - resolved endpoint from config: ${a}`))}let s=await Xc(e,r,n);if(typeof n.endpointProvider!="function")throw new Error("config.endpointProvider is not set.");let i=n.endpointProvider(s,o);if(n.isCustomEndpoint&&n.endpoint){let a=await n.endpoint();if(a?.headers){i.headers??={};for(let[c,f]of Object.entries(a.headers))i.headers[c]=Array.isArray(f)?f:[f]}}return i}}var Xc,sn=m(()=>{Ls();zs();on();Xc=async(t,e,r)=>{let n={},o=e?.getEndpointParameterInstructions?.()||{};for(let[s,i]of Object.entries(o))switch(i.type){case"staticContextParams":n[s]=i.value;break;case"contextParams":n[s]=t[i.name];break;case"clientContextParams":case"builtInParams":n[s]=await Fs(i.name,s,r,i.type!=="builtInParams")();break;case"operationContextParams":n[s]=i.get(t);break;default:throw new Error("Unrecognized endpoint parameter instruction: "+JSON.stringify(i))}return Object.keys(o).length===0&&Object.assign(n,r),String(r.serviceId).toLowerCase()==="s3"&&await nn(n),n}});function Zc(t,e,r){t.__smithy_context?t.__smithy_context.features||(t.__smithy_context.features={}):t.__smithy_context={features:{}},t.__smithy_context.features[e]=r}function zt(t){let e=Ft(t);return({config:r,instructions:n})=>(o,s)=>async i=>{r.isCustomEndpoint&&Zc(s,"ENDPOINT_OVERRIDE","N");let a=await e(i.input,{getEndpointParameterInstructions(){return n}},{...r},s);s.endpointV2=a,s.authSchemes=a.properties?.authSchemes;let c=s.authSchemes?.[0];if(c){s.signing_region=c.signingRegion,s.signing_service=c.signingName;let u=Fr(s)?.selectedHttpAuthScheme?.httpAuthOption;u&&(u.signingProperties=Object.assign(u.signingProperties||{},{signing_region:c.signingRegion,signingRegion:c.signingRegion,signing_service:c.signingName,signingName:c.signingName,signingRegionSet:c.signingRegionSet},c.properties))}return o({...i})}}var an=m(()=>{N();sn()});function Hs(t){let e=zt(t);return(r,n)=>({applyToStack:o=>{o.addRelativeTo(e({config:r,instructions:n}),ef)}})}var Yc,ef,js=m(()=>{an();Yc={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0},ef={step:"serialize",tags:["ENDPOINT_PARAMETERS","ENDPOINT_V2","ENDPOINT"],name:"endpointV2Middleware",override:!0,relation:"before",toMiddleware:Yc.name}});function Vs(t){return e=>{let r=e.tls??!0,{endpoint:n,useDualstackEndpoint:o,useFipsEndpoint:s}=e,i=n!=null?async()=>Q(await et(n)()):void 0,c=Object.assign(e,{endpoint:i,tls:r,isCustomEndpoint:!!n,useDualstackEndpoint:et(o??!1),useFipsEndpoint:et(s??!1),ignoreConfiguredEndpointUrls:!!e.ignoreConfiguredEndpointUrls}),f;return c.serviceConfiguredEndpoint=async()=>(e.serviceId&&!f&&(f=t(e.serviceId)),f),c}}var Gs=m(()=>{N();on()});var hd,pd,gd,yd,qs=m(()=>{Ds();sn();an();js();Gs();N();hd=Ft(st),pd=Vs(st),gd=zt(st),yd=Hs(st)});var Ht,cn=m(()=>{qs();Ht=(t,e)=>(r,n)=>async o=>{let s=t,i=n.endpointV2?async()=>Q(n.endpointV2):s.endpoint;if(!i)throw new Error("No valid endpoint provider available.");let a=await e(o.input,{...t,endpoint:i});return r({...o,request:a})}});function Ws(t,e,r){return{applyToStack:n=>{n.add(Mt(t,r),fn),n.add(Ht(t,e),mn)}}}var fn,mn,Js=m(()=>{Vr();cn();fn={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:!0},mn={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0}});function Ks(t,e){return Buffer.isBuffer(t)?t:typeof t=="string"?te(t,e):ArrayBuffer.isView(t)?_(t.buffer,t.byteOffset,t.byteLength):_(t)}var Vt,jt,Qs=m(()=>{Vt=require("node:crypto");re();Pr();jt=class{algorithmIdentifier;secret;hash;constructor(e,r){this.algorithmIdentifier=e,this.secret=r,this.reset()}update(e,r){this.hash.update(Ot(Ks(e,r)))}digest(){return Promise.resolve(this.hash.digest())}reset(){this.hash=this.secret?(0,Vt.createHmac)(this.algorithmIdentifier,Ks(this.secret)):(0,Vt.createHash)(this.algorithmIdentifier)}}});var Xs,Ue,un=m(()=>{Xs=require("node:stream");wr();Ue=class extends Xs.Readable{expectedChecksum;checksumSourceLocation;checksum;source;base64Encoder;constructor({expectedChecksum:e,checksum:r,source:n,checksumSourceLocation:o,base64Encoder:s}){if(super(),typeof n.pipe!="function")throw new Error(`@smithy/util-stream: unsupported source type ${n?.constructor?.name??n} in ChecksumStream.`);this.source=n,this.base64Encoder=s??ne,this.expectedChecksum=e,this.checksum=r,this.checksumSourceLocation=o,this.source.on("data",this.onSourceData),this.source.on("end",this.onSourceEnd),this.source.on("error",this.onSourceError),this.source.on("close",this.onSourceClose),this.source.pause()}onSourceData=e=>{if(!this.destroyed){try{this.checksum.update(e)}catch(r){this.destroy(r);return}this.push(e)||this.source.pause()}};onSourceEnd=async()=>{if(!this.destroyed){try{let e=await this.checksum.digest(),r=this.base64Encoder(e);if(this.expectedChecksum!==r){this.destroy(new Error(`Checksum mismatch: expected "${this.expectedChecksum}" but received "${r}" in response header "${this.checksumSourceLocation}".`));return}}catch(e){this.destroy(e);return}this.push(null)}};onSourceError=e=>{this.destroy(e)};onSourceClose=()=>{!this.destroyed&&!this.source.readableEnded&&this.destroy(new Error("Connection lost or stream closed before all data was received."))};_read(e){this.source.resume()}_destroy(e,r){this.source?.removeListener("data",this.onSourceData),this.source?.removeListener("end",this.onSourceEnd),this.source?.removeListener("error",this.onSourceError),this.source?.removeListener("close",this.onSourceClose),this.source?.destroy(),r(e)}}});var I,ie,L=m(()=>{I=t=>typeof ReadableStream=="function"&&(t?.constructor?.name===ReadableStream.name||t instanceof ReadableStream),ie=t=>typeof Blob=="function"&&(t?.constructor?.name===Blob.name||t instanceof Blob)});var Zs,Ys=m(()=>{Zs=t=>new TextEncoder().encode(t)});var ei,Pd,ti,Gt,dn,ri,ni=m(()=>{ei="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pd=Object.entries(ei).reduce((t,[e,r])=>(t[r]=Number(e),t),{}),ti=ei.split(""),Gt=6,dn=8,ri=63});function qt(t){let e;typeof t=="string"?e=Zs(t):e=t;let r=typeof e=="object"&&typeof e.length=="number",n=typeof e=="object"&&typeof e.byteOffset=="number"&&typeof e.byteLength=="number";if(!r&&!n)throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");let o="";for(let s=0;s<e.length;s+=3){let i=0,a=0;for(let f=s,u=Math.min(s+3,e.length);f<u;f++)i|=e[f]<<(u-f-1)*dn,a+=dn;let c=Math.ceil(a/Gt);i<<=c*Gt-a;for(let f=1;f<=c;f++){let u=(c-f)*Gt;o+=ti[(i&ri<<u)>>u]}o+="==".slice(0,4-c)}return o}var ln=m(()=>{Ys();ni()});var tf,Wt,oi=m(()=>{tf=typeof ReadableStream=="function"?ReadableStream:function(){},Wt=class extends tf{}});var si,ii=m(()=>{ln();L();oi();si=({expectedChecksum:t,checksum:e,source:r,checksumSourceLocation:n,base64Encoder:o})=>{if(!I(r))throw new Error(`@smithy/util-stream: unsupported source type ${r?.constructor?.name??r} in ChecksumStream.`);let s=o??qt;if(typeof TransformStream!="function")throw new Error("@smithy/util-stream: unable to instantiate ChecksumStream because API unavailable: ReadableStream/TransformStream.");let i=new TransformStream({start(){},async transform(c,f){e.update(c),f.enqueue(c)},async flush(c){let f=await e.digest(),u=s(f);if(t!==u){let l=new Error(`Checksum mismatch: expected "${t}" but received "${u}" in response header "${n}".`);c.error(l)}else c.terminate()}});r.pipeThrough(i);let a=i.readable;return Object.setPrototypeOf(a,Wt.prototype),a}});function ai(t){return typeof ReadableStream=="function"&&I(t.source)?si(t):new Ue(t)}var ci=m(()=>{L();un();ii()});var ge,hn=m(()=>{ge=class{allocByteArray;byteLength=0;byteArrays=[];constructor(e){this.allocByteArray=e}push(e){this.byteArrays.push(e),this.byteLength+=e.byteLength}flush(){if(this.byteArrays.length===1){let n=this.byteArrays[0];return this.reset(),n}let e=this.allocByteArray(this.byteLength),r=0;for(let n=0;n<this.byteArrays.length;++n){let o=this.byteArrays[n];e.set(o,r),r+=o.byteLength}return this.reset(),e}reset(){this.byteArrays=[],this.byteLength=0}}});function fi(t,e,r){let n=t.getReader(),o=!1,s=0,i=["",new ge(f=>new Uint8Array(f))],a=-1,c=async f=>{let{value:u,done:l}=await n.read(),d=u;if(l){if(a!==-1){let h=ye(i,a);Z(h)>0&&f.enqueue(h)}f.close()}else{let h=gn(d,!1);if(a!==h&&(a>=0&&f.enqueue(ye(i,a)),a=h),a===-1){f.enqueue(d);return}let p=Z(d);s+=p;let g=Z(i[a]);if(p>=e&&g===0)f.enqueue(d);else{let y=pn(i,a,d);!o&&s>e*2&&(o=!0,r?.warn(`@smithy/util-stream - stream chunk size ${p} is below threshold of ${e}, automatically buffering.`)),y>=e?f.enqueue(ye(i,a)):await c(f)}}};return new ReadableStream({pull:c})}function pn(t,e,r){switch(e){case 0:return t[0]+=r,Z(t[0]);case 1:case 2:return t[e].push(r),Z(t[e])}}function ye(t,e){switch(e){case 0:let r=t[0];return t[0]="",r;case 1:case 2:return t[e].flush()}throw new Error(`@smithy/util-stream - invalid index ${e} given to flush()`)}function Z(t){return t?.byteLength??t?.length??0}function gn(t,e=!0){return e&&typeof Buffer<"u"&&t instanceof Buffer?2:t instanceof Uint8Array?1:typeof t=="string"?0:-1}var mi=m(()=>{hn()});function di(t,e,r){if(I(t))return fi(t,e,r);let n=new ui.Readable({read(){}}),o=!1,s=0,i=["",new ge(c=>new Uint8Array(c)),new ge(c=>Buffer.from(new Uint8Array(c)))],a=-1;return t.on("data",c=>{let f=gn(c,!0);if(a!==f&&(a>=0&&n.push(ye(i,a)),a=f),a===-1){n.push(c);return}let u=Z(c);s+=u;let l=Z(i[a]);if(u>=e&&l===0)n.push(c);else{let d=pn(i,a,c);!o&&s>e*2&&(o=!0,r?.warn(`@smithy/util-stream - stream chunk size ${u} is below threshold of ${e}, automatically buffering.`)),d>=e&&n.push(ye(i,a))}}),t.on("end",()=>{if(a!==-1){let c=ye(i,a);Z(c)>0&&n.push(c)}n.push(null)}),n}var ui,li=m(()=>{ui=require("node:stream");hn();mi();L()});var hi,pi=m(()=>{hi=(t,e)=>{let{base64Encoder:r,bodyLengthChecker:n,checksumAlgorithmFn:o,checksumLocationName:s,streamHasher:i}=e,a=r!==void 0&&n!==void 0&&o!==void 0&&s!==void 0&&i!==void 0,c=a?i(o,t):void 0,f=t.getReader();return new ReadableStream({async pull(u){let{value:l,done:d}=await f.read();if(d){if(u.enqueue(`0\r
|
|
3
|
+
`),Ie={warn:console.warn}});function Tt(t){let e=t.getUTCFullYear(),r=t.getUTCMonth(),n=t.getUTCDay(),o=t.getUTCDate(),s=t.getUTCHours(),i=t.getUTCMinutes(),a=t.getUTCSeconds(),c=o<10?`0${o}`:`${o}`,f=s<10?`0${s}`:`${s}`,u=i<10?`0${i}`:`${i}`,d=a<10?`0${a}`:`${a}`;return`${pc[n]}, ${c} ${Ar[r]} ${e} ${f}:${u}:${d} GMT`}var pc,Ar,gc,xo,yc,Eo,Sc,bc,wc,To,Co,Ke,xc,Ec,Tc,Ir,Cc,Ic,Ac,j,vc,Rc,ve,Io=m(()=>{Cr();pc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ar=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];gc=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/),xo=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let e=gc.exec(t);if(!e)throw new TypeError("Invalid RFC-3339 date-time value");let[r,n,o,s,i,a,c,f]=e,u=oe(ve(n)),d=j(o,"month",1,12),l=j(s,"day",1,31);return Ke(u,d,l,{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f})},yc=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}:\d{2})|[zZ])$/),Eo=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let e=yc.exec(t);if(!e)throw new TypeError("Invalid RFC-3339 date-time value");let[r,n,o,s,i,a,c,f,u]=e,d=oe(ve(n)),l=j(o,"month",1,12),h=j(s,"day",1,31),p=Ke(d,l,h,{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f});return u.toUpperCase()!="Z"&&p.setTime(p.getTime()-Rc(u)),p},Sc=new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/),bc=new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/),wc=new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( [1-9]|\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? (\d{4})$/),To=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC-7231 date-times must be expressed as strings");let e=Sc.exec(t);if(e){let[r,n,o,s,i,a,c,f]=e;return Ke(oe(ve(s)),Ir(o),j(n,"day",1,31),{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f})}if(e=bc.exec(t),e){let[r,n,o,s,i,a,c,f]=e;return Tc(Ke(xc(s),Ir(o),j(n,"day",1,31),{hours:i,minutes:a,seconds:c,fractionalMilliseconds:f}))}if(e=wc.exec(t),e){let[r,n,o,s,i,a,c,f]=e;return Ke(oe(ve(f)),Ir(n),j(o.trimLeft(),"day",1,31),{hours:s,minutes:i,seconds:a,fractionalMilliseconds:c})}throw new TypeError("Invalid RFC-7231 date-time value")},Co=t=>{if(t==null)return;let e;if(typeof t=="number")e=t;else if(typeof t=="string")e=Je(t);else if(typeof t=="object"&&t.tag===1)e=t.value;else throw new TypeError("Epoch timestamps must be expressed as floating point numbers or their string representation");if(Number.isNaN(e)||e===1/0||e===-1/0)throw new TypeError("Epoch timestamps must be valid, non-Infinite, non-NaN numerics");return new Date(Math.round(e*1e3))},Ke=(t,e,r,n)=>{let o=e-1;return Ic(t,o,r),new Date(Date.UTC(t,o,r,j(n.hours,"hour",0,23),j(n.minutes,"minute",0,59),j(n.seconds,"seconds",0,60),vc(n.fractionalMilliseconds)))},xc=t=>{let e=new Date().getUTCFullYear(),r=Math.floor(e/100)*100+oe(ve(t));return r<e?r+100:r},Ec=50*365*24*60*60*1e3,Tc=t=>t.getTime()-new Date().getTime()>Ec?new Date(Date.UTC(t.getUTCFullYear()-100,t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())):t,Ir=t=>{let e=Ar.indexOf(t);if(e<0)throw new TypeError(`Invalid month: ${t}`);return e+1},Cc=[31,28,31,30,31,30,31,31,30,31,30,31],Ic=(t,e,r)=>{let n=Cc[e];if(e===1&&Ac(t)&&(n=29),r>n)throw new TypeError(`Invalid day for ${Ar[e]} in ${t}: ${r}`)},Ac=t=>t%4===0&&(t%100!==0||t%400===0),j=(t,e,r,n)=>{let o=Et(ve(t));if(o<r||o>n)throw new TypeError(`${e} must be between ${r} and ${n}, inclusive`);return o},vc=t=>t==null?0:wt("0."+t)*1e3,Rc=t=>{let e=t[0],r=1;if(e=="+")r=1;else if(e=="-")r=-1;else throw new TypeError(`Offset direction, ${e}, must be "+" or "-"`);let n=Number(t.substring(1,3)),o=Number(t.substring(4,6));return r*(n*60+o)*60*1e3},ve=t=>{let e=0;for(;e<t.length-1&&t.charAt(e)==="0";)e++;return e===0?t:t.slice(e)}});var U,Ao=m(()=>{U=function(e){return Object.assign(new String(e),{deserializeJSON(){return JSON.parse(String(e))},toString(){return String(e)},toJSON(){return String(e)}})};U.from=t=>t&&typeof t=="object"&&(t instanceof U||"deserializeJSON"in t)?t:typeof t=="string"||Object.getPrototypeOf(t)===String.prototype?U(String(t)):U(JSON.stringify(t));U.fromObject=U.from});function Ct(t){return(t.includes(",")||t.includes('"'))&&(t=`"${t.replace(/"/g,'\\"')}"`),t}var vo=m(()=>{});function J(t,e,r){let n=Number(t);if(n<e||n>r)throw new Error(`Value ${n} out of range [${e}, ${r}]`)}var vr,Rr,Nr,Ro,No,Nc,Oc,Mc,Pc,kc,It,At,vt,Oo=m(()=>{vr="(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)(?:[ne|u?r]?s?day)?",Rr="(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)",Nr="(\\d?\\d):(\\d{2}):(\\d{2})(?:\\.(\\d+))?",Ro="(\\d?\\d)",No="(\\d{4})",Nc=new RegExp(/^(\d{4})-(\d\d)-(\d\d)[tT](\d\d):(\d\d):(\d\d)(\.(\d+))?(([-+]\d\d:\d\d)|[zZ])$/),Oc=new RegExp(`^${vr}, ${Ro} ${Rr} ${No} ${Nr} GMT$`),Mc=new RegExp(`^${vr}, ${Ro}-${Rr}-(\\d\\d) ${Nr} GMT$`),Pc=new RegExp(`^${vr} ${Rr} ( [1-9]|\\d\\d) ${Nr} ${No}$`),kc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],It=t=>{if(t==null)return;let e=NaN;if(typeof t=="number")e=t;else if(typeof t=="string"){if(!/^-?\d*\.?\d+$/.test(t))throw new TypeError("parseEpochTimestamp - numeric string invalid.");e=Number.parseFloat(t)}else typeof t=="object"&&t.tag===1&&(e=t.value);if(isNaN(e)||Math.abs(e)===1/0)throw new TypeError("Epoch timestamps must be valid finite numbers.");return new Date(Math.round(e*1e3))},At=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC3339 timestamps must be strings");let e=Nc.exec(t);if(!e)throw new TypeError(`Invalid RFC3339 timestamp format ${t}`);let[,r,n,o,s,i,a,,c,f]=e;J(n,1,12),J(o,1,31),J(s,0,23),J(i,0,59),J(a,0,60);let u=new Date(Date.UTC(Number(r),Number(n)-1,Number(o),Number(s),Number(i),Number(a),Number(c)?Math.round(parseFloat(`0.${c}`)*1e3):0));if(u.setUTCFullYear(Number(r)),f.toUpperCase()!="Z"){let[,d,l,h]=/([+-])(\d\d):(\d\d)/.exec(f)||[void 0,"+",0,0],p=d==="-"?1:-1;u.setTime(u.getTime()+p*(Number(l)*60*60*1e3+Number(h)*60*1e3))}return u},vt=t=>{if(t==null)return;if(typeof t!="string")throw new TypeError("RFC7231 timestamps must be strings.");let e,r,n,o,s,i,a,c;if((c=Oc.exec(t))?[,e,r,n,o,s,i,a]=c:(c=Mc.exec(t))?([,e,r,n,o,s,i,a]=c,n=(Number(n)+1900).toString()):(c=Pc.exec(t))&&([,r,e,o,s,i,a,n]=c),n&&i){let f=Date.UTC(Number(n),kc.indexOf(r),Number(e),Number(o),Number(s),Number(i),a?Math.round(parseFloat(`0.${a}`)*1e3):0);J(e,1,31),J(o,0,23),J(s,0,59),J(i,0,60);let u=new Date(f);return u.setUTCFullYear(Number(n)),u}throw new TypeError(`Invalid RFC7231 date-time value ${t}.`)}});function Rt(t,e,r){if(r<=0||!Number.isInteger(r))throw new Error("Invalid number of delimiters ("+r+") for splitEvery.");let n=t.split(e);if(r===1)return n;let o=[],s="";for(let i=0;i<n.length;i++)s===""?s=n[i]:s+=e+n[i],(i+1)%r===0&&(o.push(s),s="");return s!==""&&o.push(s),o}var Mo=m(()=>{});var Re,Po=m(()=>{Re=t=>{let e=t.length,r=[],n=!1,o,s=0;for(let i=0;i<e;++i){let a=t[i];switch(a){case'"':o!=="\\"&&(n=!n);break;case",":n||(r.push(t.slice(s,i)),s=i+1);break;default:}o=a}return r.push(t.slice(s)),r.map(i=>{i=i.trim();let a=i.length;return a<2?i:(i[0]==='"'&&i[a-1]==='"'&&(i=i.slice(1,a-1)),i.replace(/\\"/g,'"'))})}});function Uo(t){return new de(String(t),"bigDecimal")}var ko,de,Do=m(()=>{ko=/^-?((0|[1-9]\d*)(\.\d+)?|\.\d+)([eE][+-]?\d+)?$/,de=class t{string;type;constructor(e,r){if(this.string=e,this.type=r,!ko.test(e))throw new Error(`@smithy/core/serde - NumericValue string must conform to the Smithy bigDecimal format. Received: "${e}"`)}toString(){return this.string}static[Symbol.hasInstance](e){if(!e||typeof e!="object")return!1;let r=e;return t.prototype.isPrototypeOf(e)||r.type==="bigDecimal"&&ko.test(r.string)}}});function Nt(t){if(t.length%2!==0)throw new Error("Hex encoded strings must have an even number length");let e=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2){let n=t.slice(r,r+2).toLowerCase();if(n in Or)e[r/2]=Or[n];else throw new Error(`Cannot decode unrecognized sequence ${n} as hexadecimal`)}return e}function D(t){let e="";for(let r=0;r<t.byteLength;r++)e+=_o[t[r]];return e}var _o,Or,Mr=m(()=>{_o={},Or={};for(let t=0;t<256;t++){let e=t.toString(16).toLowerCase();e.length===1&&(e=`0${e}`),_o[t]=e,Or[e]=t}});var Ne,$o,Bo=m(()=>{Ne=require("node:fs"),$o=t=>{if(!t)return 0;if(typeof t=="string")return Buffer.byteLength(t);if(typeof t.byteLength=="number")return t.byteLength;if(typeof t.size=="number")return t.size;if(typeof t.start=="number"&&typeof t.end=="number")return t.end+1-t.start;if(t instanceof Ne.ReadStream){if(t.path!=null)return(0,Ne.lstatSync)(t.path).size;if(typeof t.fd=="number")return(0,Ne.fstatSync)(t.fd).size}throw new Error(`Body Length computation failed for ${t}`)}});var Ot,Pr=m(()=>{ht();Ot=t=>t instanceof Uint8Array?t:typeof t=="string"?B(t):ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(t)});function se(t,e){if(e===void 0){e=0;for(let o of t)e+=o.byteLength}let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.byteLength;return r}var Qe=m(()=>{});var Ze=Xn(L=>{var kr;(function(t){t.HEADER="header",t.QUERY="query"})(kr||(kr={}));var Ur;(function(t){t.HEADER="header",t.QUERY="query"})(Ur||(Ur={}));var Dr;(function(t){t.HTTP="http",t.HTTPS="https"})(Dr||(Dr={}));var Xe;(function(t){t.MD5="md5",t.CRC32="crc32",t.CRC32C="crc32c",t.SHA1="sha1",t.SHA256="sha256"})(Xe||(Xe={}));var Uc=t=>{let e=[];return t.sha256!==void 0&&e.push({algorithmId:()=>Xe.SHA256,checksumConstructor:()=>t.sha256}),t.md5!=null&&e.push({algorithmId:()=>Xe.MD5,checksumConstructor:()=>t.md5}),{addChecksumAlgorithm(r){e.push(r)},checksumAlgorithms(){return e}}},Dc=t=>{let e={};return t.checksumAlgorithms().forEach(r=>{e[r.algorithmId()]=r.checksumConstructor()}),e},_c=t=>Uc(t),$c=t=>Dc(t),_r;(function(t){t[t.HEADER=0]="HEADER",t[t.TRAILER=1]="TRAILER"})(_r||(_r={}));var Bc="__smithy_context",$r;(function(t){t.PROFILE="profile",t.SSO_SESSION="sso-session",t.SERVICES="services"})($r||($r={}));var Br;(function(t){t.HTTP_0_9="http/0.9",t.HTTP_1_0="http/1.0",t.TDS_8_0="tds/8.0"})(Br||(Br={}));L.AlgorithmId=Xe;L.EndpointURLScheme=Dr;L.FieldPosition=_r;L.HttpApiKeyAuthLocation=Ur;L.HttpAuthLocation=kr;L.IniSectionType=$r;L.RequestHandlerProtocol=Br;L.SMITHY_CONTEXT_KEY=Bc;L.getDefaultClientConfiguration=_c;L.resolveDefaultRuntimeConfig=$c});var Lr,Fr,Lo=m(()=>{Lr=xe(Ze()),Fr=t=>t[Lr.SMITHY_CONTEXT_KEY]||(t[Lr.SMITHY_CONTEXT_KEY]={})});function Lc(t){return Object.keys(t).reduce((e,r)=>{let n=t[r];return{...e,[r]:Array.isArray(n)?[...n]:n}},{})}var P,Fo=m(()=>{P=class t{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(e){this.method=e.method||"GET",this.hostname=e.hostname||"localhost",this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)!==":"?`${e.protocol}:`:e.protocol:"https:",this.path=e.path?e.path.charAt(0)!=="/"?`/${e.path}`:e.path:"/",this.username=e.username,this.password=e.password,this.fragment=e.fragment}static clone(e){let r=new t({...e,headers:{...e.headers}});return r.query&&(r.query=Lc(r.query)),r}static isInstance(e){if(!e)return!1;let r=e;return"method"in r&&"protocol"in r&&"hostname"in r&&"path"in r&&typeof r.query=="object"&&typeof r.headers=="object"}clone(){return t.clone(this)}}});var K,zo=m(()=>{K=class{statusCode;reason;headers;body;constructor(e){this.statusCode=e.statusCode,this.reason=e.reason,this.headers=e.headers||{},this.body=e.body}static isInstance(e){if(!e)return!1;let r=e;return typeof r.statusCode=="number"&&typeof r.headers=="object"}}});function Ye(t){return/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(t)}var Ho=m(()=>{});var et,jo=m(()=>{et=t=>{if(typeof t=="function")return t;let e=Promise.resolve(t);return()=>e}});function tt(t){let e={};if(t=t.replace(/^\?/,""),t)for(let r of t.split("&")){let[n,o=null]=r.split("=");n=decodeURIComponent(n),o&&(o=decodeURIComponent(o)),n in e?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o}return e}var zr=m(()=>{});var he,Hr=m(()=>{zr();he=t=>{if(typeof t=="string")return he(new URL(t));let{hostname:e,pathname:r,port:n,protocol:o,search:s}=t,i;return s&&(i=tt(s)),{hostname:e,port:n?parseInt(n):void 0,protocol:o,path:r,query:i}}});var Q,Vo=m(()=>{Hr();Q=t=>{if(typeof t=="object"){if("url"in t){let e=he(t.url);if(t.headers){e.headers={};for(let r in t.headers)e.headers[r.toLowerCase()]=t.headers[r].join(", ")}return e}return t}return he(t)}});var R=m(()=>{Lo();Fo();zo();Ho();jo();zr();Hr();Vo()});var Mt,jr,Vr=m(()=>{R();Mt=(t,e)=>(r,n)=>async o=>{let{response:s}=await r(o);try{let i=await e(s,t);return{response:s,output:i}}catch(i){if(Object.defineProperty(i,"$response",{value:s,enumerable:!1,writable:!1,configurable:!1}),!("$metadata"in i)){let a="Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.";try{i.message+=`
|
|
4
|
+
`+a}catch{!n.logger||n.logger?.constructor?.name==="NoOpLogger"?console.warn(a):n.logger?.warn?.(a)}typeof i.$responseBodyText<"u"&&i.$response&&(i.$response.body=i.$responseBodyText);try{if(K.isInstance(s)){let{headers:c={}}=s,f=Object.entries(c);i.$metadata={httpStatusCode:s.statusCode,requestId:jr(/^x-[\w-]+-request-?id$/,f),extendedRequestId:jr(/^x-[\w-]+-id-2$/,f),cfId:jr(/^x-[\w-]+-cf-id$/,f)}}}catch{}}throw i}},jr=(t,e)=>(e.find(([r])=>r.match(t))||[void 0,void 0])[1]});var Oe,Gr=m(()=>{Oe=class t extends Error{name="ProviderError";tryNextLink;constructor(e,r=!0){let n,o=!0;typeof r=="boolean"?(n=void 0,o=r):r!=null&&typeof r=="object"&&(n=r.logger,o=r.tryNextLink??!0),super(e),this.tryNextLink=o,Object.setPrototypeOf(this,t.prototype),n?.debug?.(`@smithy/property-provider ${o?"->":"(!)"} ${e}`)}static from(e,r=!0){return Object.assign(new this(e.message,r),e)}}});var Me,qr=m(()=>{Gr();Me=class t extends Oe{name="CredentialsProviderError";constructor(e,r=!0){super(e,r),Object.setPrototypeOf(this,t.prototype)}}});var Go,qo=m(()=>{Gr();Go=(...t)=>async()=>{if(t.length===0)throw new Oe("No providers in chain");let e;for(let r of t)try{return await r()}catch(n){if(e=n,n?.tryNextLink)continue;throw n}throw e}});var Wo,Jo=m(()=>{Wo=t=>()=>Promise.resolve(t)});var Ko,Qo=m(()=>{Ko=(t,e,r)=>{let n,o,s,i=!1,a=async()=>{o||(o=t());try{n=await o,s=!0,i=!1}finally{o=void 0}return n};return e===void 0?async c=>((!s||c?.forceRefresh)&&(n=await a()),n):async c=>((!s||c?.forceRefresh)&&(n=await a()),i?n:r&&!r(n)?(i=!0,n):(e(n)&&await a(),n))}});var Pt,Xo=m(()=>{Pt=(t,e,r)=>{if(e in t){if(t[e]==="true")return!0;if(t[e]==="false")return!1;throw new Error(`Cannot load ${r} "${e}". Expected "true" or "false", got ${t[e]}.`)}}});var Pe,Zo=m(()=>{(function(t){t.ENV="env",t.CONFIG="shared config entry"})(Pe||(Pe={}))});var Yo,es,Wr,Fc,ke,kt=m(()=>{Yo=require("node:os"),es=require("node:path"),Wr={},Fc=()=>process&&process.geteuid?`${process.geteuid()}`:"DEFAULT",ke=()=>{let{HOME:t,USERPROFILE:e,HOMEPATH:r,HOMEDRIVE:n=`C:${es.sep}`}=process.env;if(t)return t;if(e)return e;if(r)return`${n}${r}`;let o=Fc();return Wr[o]||(Wr[o]=(0,Yo.homedir)()),Wr[o]}});var zc,Hc,ts,rs=m(()=>{zc="AWS_PROFILE",Hc="default",ts=t=>t.profile||process.env[zc]||Hc});var Jr,ns,os=m(()=>{Jr=xe(Ze()),ns=t=>Object.entries(t).filter(([e])=>{let r=e.indexOf(".");return r===-1?!1:Object.values(Jr.IniSectionType).includes(e.substring(0,r))}).reduce((e,[r,n])=>{let o=r.indexOf("."),s=r.substring(0,o)===Jr.IniSectionType.PROFILE?r.substring(o+1):r;return e[s]=n,e},{...t.default&&{default:t.default}})});var ss,jc,is,as=m(()=>{ss=require("node:path");kt();jc="AWS_CONFIG_FILE",is=()=>process.env[jc]||(0,ss.join)(ke(),".aws","config")});var cs,Vc,fs,ms=m(()=>{cs=require("node:path");kt();Vc="AWS_SHARED_CREDENTIALS_FILE",fs=()=>process.env[Vc]||(0,cs.join)(ke(),".aws","credentials")});var us,Gc,qc,Kr,ls=m(()=>{us=xe(Ze()),Gc=/^([\w-]+)\s(["'])?([\w-@+.%:/]+)\2$/,qc=["__proto__","profile __proto__"],Kr=t=>{let e={},r,n;for(let o of t.split(/\r?\n/)){let s=o.split(/(^|\s)[;#]/)[0].trim();if(s[0]==="["&&s[s.length-1]==="]"){r=void 0,n=void 0;let a=s.substring(1,s.length-1),c=Gc.exec(a);if(c){let[,f,,u]=c;Object.values(us.IniSectionType).includes(f)&&(r=[f,u].join("."))}else r=a;if(qc.includes(a))throw new Error(`Found invalid profile name "${a}"`)}else if(r){let a=s.indexOf("=");if(![0,-1].includes(a)){let[c,f]=[s.substring(0,a).trim(),s.substring(a+1).trim()];if(f==="")n=c;else{n&&o.trimStart()===o&&(n=void 0),e[r]=e[r]||{};let u=n?[n,c].join("."):c;e[r][u]=f}}}}return e}});var hs,Qr,ds,Xr,ps=m(()=>{hs=require("node:fs/promises"),Qr={},ds={},Xr=(t,e)=>ds[t]!==void 0?ds[t]:((!Qr[t]||e?.ignoreCache)&&(Qr[t]=(0,hs.readFile)(t,"utf8")),Qr[t])});var Zr,gs,ys,Ss=m(()=>{Zr=require("node:path");os();as();ms();kt();ls();ps();gs=()=>({}),ys=async(t={})=>{let{filepath:e=fs(),configFilepath:r=is()}=t,n=ke(),o="~/",s=e;e.startsWith(o)&&(s=(0,Zr.join)(n,e.slice(2)));let i=r;r.startsWith(o)&&(i=(0,Zr.join)(n,r.slice(2)));let a=await Promise.all([Xr(i,{ignoreCache:t.ignoreCache}).then(Kr).then(ns).catch(gs),Xr(s,{ignoreCache:t.ignoreCache}).then(Kr).catch(gs)]);return{configFile:a[0],credentialsFile:a[1]}}});function Ut(t){try{let e=new Set(Array.from(t.match(/([A-Z_]){3,}/g)??[]));return e.delete("CONFIG"),e.delete("CONFIG_PREFIX_SEPARATOR"),e.delete("ENV"),[...e].join(", ")}catch{return t}}var Yr=m(()=>{});var bs,ws=m(()=>{qr();Yr();bs=(t,e)=>async()=>{try{let r=t(process.env,e);if(r===void 0)throw new Error;return r}catch(r){throw new Me(r.message||`Not found in ENV: ${Ut(t.toString())}`,{logger:e?.logger})}}});var xs,Es=m(()=>{qr();rs();Ss();Yr();xs=(t,{preferredFile:e="config",...r}={})=>async()=>{let n=ts(r),{configFile:o,credentialsFile:s}=await ys(r),i=s[n]||{},a=o[n]||{},c=e==="config"?{...i,...a}:{...a,...i};try{let u=t(c,e==="config"?o:s);if(u===void 0)throw new Error;return u}catch(f){throw new Me(f.message||`Not found in config files w/ profile [${n}]: ${Ut(t.toString())}`,{logger:r.logger})}}});var Wc,Ts,Cs=m(()=>{Jo();Wc=t=>typeof t=="function",Ts=t=>Wc(t)?async()=>await t():Wo(t)});var Dt,Is=m(()=>{qo();Qo();ws();Es();Cs();Dt=({environmentVariableSelector:t,configFileSelector:e,default:r},n={})=>{let{signingName:o,logger:s}=n;return Ko(Go(bs(t,{signingName:o,logger:s}),xs(e,n),Ts(r)))}});var _t,As=m(()=>{_t=t=>typeof t=="function"?t():t});function V(t){if(typeof t=="object")return t;if(t=t|0,$t[t])return $t[t];let e={},r=0;for(let n of["httpLabel","idempotent","idempotencyToken","sensitive","httpPayload","httpResponseCode","httpQueryParams"])(t>>r++&1)===1&&(e[n]=1);return $t[t]=e}var $t,en=m(()=>{$t=[]});function ot(t,e){if(t instanceof T)return Object.assign(t,{memberName:e,_isMemberSchema:!0});let r=T;return new r(t,e)}var nt,Bt,Lt,T,tn,vs,Rs=m(()=>{As();en();nt={it:Symbol.for("@smithy/nor-struct-it"),ns:Symbol.for("@smithy/ns")},Bt=[],Lt={},T=class t{ref;memberName;static symbol=Symbol.for("@smithy/nor");symbol=t.symbol;name;schema;_isMemberSchema;traits;memberTraits;normalizedTraits;constructor(e,r){this.ref=e,this.memberName=r;let n=[],o=e,s=e;for(this._isMemberSchema=!1;tn(o);)n.push(o[1]),o=o[0],s=_t(o),this._isMemberSchema=!0;if(n.length>0){this.memberTraits={};for(let i=n.length-1;i>=0;--i){let a=n[i];Object.assign(this.memberTraits,V(a))}}else this.memberTraits=0;if(s instanceof t){let i=this.memberTraits;Object.assign(this,s),this.memberTraits=Object.assign({},i,s.getMemberTraits(),this.getMemberTraits()),this.normalizedTraits=void 0,this.memberName=r??s.memberName;return}if(this.schema=_t(s),vs(this.schema)?(this.name=`${this.schema[1]}#${this.schema[2]}`,this.traits=this.schema[3]):(this.name=this.memberName??String(s),this.traits=0),this._isMemberSchema&&!r)throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(!0)} missing member name.`)}static[Symbol.hasInstance](e){let r=this.prototype.isPrototypeOf(e);return!r&&typeof e=="object"&&e!==null?e.symbol===this.symbol:r}static of(e){let r=typeof e=="function"||typeof e=="object"&&e!==null;if(typeof e=="number"){if(Bt[e])return Bt[e]}else if(typeof e=="string"){if(Lt[e])return Lt[e]}else if(r&&e[nt.ns])return e[nt.ns];let n=_t(e);if(n instanceof t)return n;if(tn(n)){let[s,i]=n;if(s instanceof t)return Object.assign(s.getMergedTraits(),V(i)),s;throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(e,null,2)}.`)}let o=new t(n);return r?e[nt.ns]=o:typeof n=="string"?Lt[n]=o:typeof n=="number"?Bt[n]=o:o}getSchema(){let e=this.schema;return Array.isArray(e)&&e[0]===0?e[4]:e}getName(e=!1){let{name:r}=this;return!e&&r&&r.includes("#")?r.split("#")[1]:r||void 0}getMemberName(){return this.memberName}isMemberSchema(){return this._isMemberSchema}isListSchema(){let e=this.getSchema();return typeof e=="number"?e>=64&&e<128:e[0]===1}isMapSchema(){let e=this.getSchema();return typeof e=="number"?e>=128&&e<=255:e[0]===2}isStructSchema(){let e=this.getSchema();if(typeof e!="object")return!1;let r=e[0];return r===3||r===-3||r===4}isUnionSchema(){let e=this.getSchema();return typeof e!="object"?!1:e[0]===4}isBlobSchema(){let e=this.getSchema();return e===21||e===42}isTimestampSchema(){let e=this.getSchema();return typeof e=="number"&&e>=4&&e<=7}isUnitSchema(){return this.getSchema()==="unit"}isDocumentSchema(){return this.getSchema()===15}isStringSchema(){return this.getSchema()===0}isBooleanSchema(){return this.getSchema()===2}isNumericSchema(){return this.getSchema()===1}isBigIntegerSchema(){return this.getSchema()===17}isBigDecimalSchema(){return this.getSchema()===19}isStreaming(){let{streaming:e}=this.getMergedTraits();return!!e||this.getSchema()===42}isIdempotencyToken(){return!!this.getMergedTraits().idempotencyToken}getMergedTraits(){return this.normalizedTraits??(this.normalizedTraits={...this.getOwnTraits(),...this.getMemberTraits()})}getMemberTraits(){return V(this.memberTraits)}getOwnTraits(){return V(this.traits)}getKeySchema(){let[e,r]=[this.isDocumentSchema(),this.isMapSchema()];if(!e&&!r)throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(!0)}`);let n=this.getSchema(),o=e?15:n[4]??0;return ot([o,0],"key")}getValueSchema(){let e=this.getSchema(),[r,n,o]=[this.isDocumentSchema(),this.isMapSchema(),this.isListSchema()],s=typeof e=="number"?63&e:e&&typeof e=="object"&&(n||o)?e[3+e[0]]:r?15:void 0;if(s!=null)return ot([s,0],n?"value":"member");throw new Error(`@smithy/core/schema - ${this.getName(!0)} has no value member.`)}getMemberSchema(e){let r=this.getSchema();if(this.isStructSchema()&&r[4].includes(e)){let n=r[4].indexOf(e),o=r[5][n];return ot(tn(o)?o:[o,0],e)}if(this.isDocumentSchema())return ot([15,0],e);throw new Error(`@smithy/core/schema - ${this.getName(!0)} has no member=${e}.`)}getMemberSchemas(){let e={};try{for(let[r,n]of this.structIterator())e[r]=n}catch{}return e}getEventStreamMember(){if(this.isStructSchema()){for(let[e,r]of this.structIterator())if(r.isStreaming()&&r.isStructSchema())return e}return""}*structIterator(){if(this.isUnitSchema())return;if(!this.isStructSchema())throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");let e=this.getSchema(),r=e[4].length,n=e[nt.it];if(n&&r===n.length){yield*n;return}n=Array(r);for(let o=0;o<r;++o){let s=e[4][o],i=ot([e[5][o],0],s);yield n[o]=[s,i]}e[nt.it]=n}};tn=t=>Array.isArray(t)&&t.length===2,vs=t=>Array.isArray(t)&&t.length>=5});var pe,Ns=m(()=>{pe=class t{namespace;schemas;exceptions;static registries=new Map;constructor(e,r=new Map,n=new Map){this.namespace=e,this.schemas=r,this.exceptions=n}static for(e){return t.registries.has(e)||t.registries.set(e,new t(e)),t.registries.get(e)}copyFrom(e){let{schemas:r,exceptions:n}=this;for(let[o,s]of e.schemas)r.has(o)||r.set(o,s);for(let[o,s]of e.exceptions)n.has(o)||n.set(o,s)}register(e,r){let n=this.normalizeShapeId(e);for(let o of[this,t.for(n.split("#")[0])])o.schemas.set(n,r)}getSchema(e){let r=this.normalizeShapeId(e);if(!this.schemas.has(r)){if(!e.includes("#")){let n="#"+e,o=[];for(let[s,i]of this.schemas.entries())s.endsWith(n)&&o.push(i);if(o.length===1)return o[0]}throw new Error(`@smithy/core/schema - schema not found for ${r}`)}return this.schemas.get(r)}registerError(e,r){let n=e,o=n[1];for(let s of[this,t.for(o)])s.schemas.set(o+"#"+n[2],n),s.exceptions.set(n,r)}getErrorCtor(e){let r=e;return this.exceptions.has(r)?this.exceptions.get(r):t.for(r[1]).exceptions.get(r)}getBaseException(){for(let e of this.exceptions.keys())if(Array.isArray(e)){let[,r,n]=e,o=r+"#"+n;if(o.startsWith("smithy.ts.sdk.synthetic.")&&o.endsWith("ServiceException"))return e}}find(e){for(let r of this.schemas.values())if(e(r))return r}clear(){this.schemas.clear(),this.exceptions.clear()}normalizeShapeId(e){return e.includes("#")?e:this.namespace+"#"+e}}});var X=m(()=>{Rs();en();Ns()});var rn=m(()=>{Xo();Zo();Is()});var Os,Ms,Ps,ks=m(()=>{Os="AWS_ENDPOINT_URL",Ms="endpoint_url",Ps=t=>({environmentVariableSelector:e=>{let r=t.split(" ").map(s=>s.toUpperCase()),n=e[[Os,...r].join("_")];if(n)return n;let o=e[Os];if(o)return o},configFileSelector:(e,r)=>{if(e.services){let o=["services",e.services].join(".");if(!r||!r[o])throw new Error(`The services section "${e.services}" specified in the profile is not present in the shared configuration file.`);let s=r[o],i=t.split(" ").map(c=>c.toLowerCase()),a=s[[i.join("_"),Ms].join(".")];if(a)return a}let n=e[Ms];if(n)return n},default:void 0})});var Jc,Kc,Us,Ds=m(()=>{rn();Jc="AWS_IGNORE_CONFIGURED_ENDPOINT_URLS",Kc="ignore_configured_endpoint_urls",Us={environmentVariableSelector:t=>Pt(t,Jc,Pe.ENV),configFileSelector:t=>Pt(t,Kc,Pe.CONFIG),default:!1}});var st,_s=m(()=>{rn();ks();Ds();st=async t=>{if(!await Dt(Us)())return Dt(Ps(t??""))()}});var nn,Qc,Xc,Zc,$s,Bs,Ls=m(()=>{nn=async t=>{let e=t?.Bucket||"";if(typeof t.Bucket=="string"&&(t.Bucket=e.replace(/#/g,encodeURIComponent("#")).replace(/\?/g,encodeURIComponent("?"))),Bs(e)){if(t.ForcePathStyle===!0)throw new Error("Path-style addressing cannot be used with ARN buckets")}else(!$s(e)||e.indexOf(".")!==-1&&!String(t.Endpoint).startsWith("http:")||e.toLowerCase()!==e||e.length<3)&&(t.ForcePathStyle=!0);return t.DisableMultiRegionAccessPoints&&(t.disableMultiRegionAccessPoints=!0,t.DisableMRAP=!0),t},Qc=/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/,Xc=/(\d+\.){3}\d+/,Zc=/\.\./,$s=t=>Qc.test(t)&&!Xc.test(t)&&!Zc.test(t),Bs=t=>{let[e,r,n,,,o]=t.split(":"),s=e==="arn"&&t.split(":").length>=6,i=!!(s&&r&&n&&o);if(s&&!i)throw new Error(`Invalid ARN: ${t} was an invalid ARN.`);return i}});var Fs=m(()=>{Ls()});var zs,Hs=m(()=>{zs=(t,e,r,n=!1)=>{let o=async()=>{let s;return n?s=r.clientContextParams?.[t]??r[t]??r[e]:s=r[t]??r[e],typeof s=="function"?s():s};return t==="credentialScope"||e==="CredentialScope"?async()=>{let s=typeof r.credentials=="function"?await r.credentials():r.credentials;return s?.credentialScope??s?.CredentialScope}:t==="accountId"||e==="AccountId"?async()=>{let s=typeof r.credentials=="function"?await r.credentials():r.credentials;return s?.accountId??s?.AccountId}:t==="endpoint"||e==="endpoint"?async()=>{if(r.isCustomEndpoint===!1)return;let s=await o();if(s&&typeof s=="object"){if("url"in s)return s.url.href;if("hostname"in s){let{protocol:i,hostname:a,port:c,path:f}=s;return`${i}//${a}${c?":"+c:""}${f}`}}return s}:o}});var on=m(()=>{R()});function Ft(t){return async(e,r,n,o)=>{if(!n.isCustomEndpoint&&!n.ignoreConfiguredEndpointUrls){let a;n.serviceConfiguredEndpoint?a=await n.serviceConfiguredEndpoint():a=await t(n.serviceId),a&&(n.endpoint=()=>Promise.resolve(Q(a)),n.isCustomEndpoint=!0,o?.logger?.debug?.(`@smithy/core/endpoints - resolved endpoint from config: ${a}`))}let s=await Yc(e,r,n);if(typeof n.endpointProvider!="function")throw new Error("config.endpointProvider is not set.");let i=n.endpointProvider(s,o);if(n.isCustomEndpoint&&n.endpoint){let a=await n.endpoint();if(a?.headers){i.headers??={};for(let[c,f]of Object.entries(a.headers))i.headers[c]=Array.isArray(f)?f:[f]}}return i}}var Yc,sn=m(()=>{Fs();Hs();on();Yc=async(t,e,r)=>{let n={},o=e?.getEndpointParameterInstructions?.()||{};for(let[s,i]of Object.entries(o))switch(i.type){case"staticContextParams":n[s]=i.value;break;case"contextParams":n[s]=t[i.name];break;case"clientContextParams":case"builtInParams":n[s]=await zs(i.name,s,r,i.type!=="builtInParams")();break;case"operationContextParams":n[s]=i.get(t);break;default:throw new Error("Unrecognized endpoint parameter instruction: "+JSON.stringify(i))}return Object.keys(o).length===0&&Object.assign(n,r),String(r.serviceId).toLowerCase()==="s3"&&await nn(n),n}});function ef(t,e,r){t.__smithy_context?t.__smithy_context.features||(t.__smithy_context.features={}):t.__smithy_context={features:{}},t.__smithy_context.features[e]=r}function zt(t){let e=Ft(t);return({config:r,instructions:n})=>(o,s)=>async i=>{r.isCustomEndpoint&&ef(s,"ENDPOINT_OVERRIDE","N");let a=await e(i.input,{getEndpointParameterInstructions(){return n}},{...r},s);s.endpointV2=a,s.authSchemes=a.properties?.authSchemes;let c=s.authSchemes?.[0];if(c){s.signing_region=c.signingRegion,s.signing_service=c.signingName;let u=Fr(s)?.selectedHttpAuthScheme?.httpAuthOption;u&&(u.signingProperties=Object.assign(u.signingProperties||{},{signing_region:c.signingRegion,signingRegion:c.signingRegion,signing_service:c.signingName,signingName:c.signingName,signingRegionSet:c.signingRegionSet},c.properties))}return o({...i})}}var an=m(()=>{R();sn()});function js(t){let e=zt(t);return(r,n)=>({applyToStack:o=>{o.addRelativeTo(e({config:r,instructions:n}),rf)}})}var tf,rf,Vs=m(()=>{an();tf={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0},rf={step:"serialize",tags:["ENDPOINT_PARAMETERS","ENDPOINT_V2","ENDPOINT"],name:"endpointV2Middleware",override:!0,relation:"before",toMiddleware:tf.name}});function Gs(t){return e=>{let r=e.tls??!0,{endpoint:n,useDualstackEndpoint:o,useFipsEndpoint:s}=e,i=n!=null?async()=>Q(await et(n)()):void 0,c=Object.assign(e,{endpoint:i,tls:r,isCustomEndpoint:!!n,useDualstackEndpoint:et(o??!1),useFipsEndpoint:et(s??!1),ignoreConfiguredEndpointUrls:!!e.ignoreConfiguredEndpointUrls}),f;return c.serviceConfiguredEndpoint=async()=>(e.serviceId&&!f&&(f=t(e.serviceId)),f),c}}var qs=m(()=>{R();on()});var gl,yl,Sl,bl,Ws=m(()=>{_s();sn();an();Vs();qs();R();gl=Ft(st),yl=Gs(st),Sl=zt(st),bl=js(st)});var Ht,cn=m(()=>{Ws();Ht=(t,e)=>(r,n)=>async o=>{let s=t,i=n.endpointV2?async()=>Q(n.endpointV2):s.endpoint;if(!i)throw new Error("No valid endpoint provider available.");let a=await e(o.input,{...t,endpoint:i});return r({...o,request:a})}});function Js(t,e,r){return{applyToStack:n=>{n.add(Mt(t,r),fn),n.add(Ht(t,e),mn)}}}var fn,mn,Ks=m(()=>{Vr();cn();fn={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:!0},mn={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0}});function Qs(t,e){return Buffer.isBuffer(t)?t:typeof t=="string"?te(t,e):ArrayBuffer.isView(t)?$(t.buffer,t.byteOffset,t.byteLength):$(t)}var Vt,jt,Xs=m(()=>{Vt=require("node:crypto");re();Pr();jt=class{algorithmIdentifier;secret;hash;constructor(e,r){this.algorithmIdentifier=e,this.secret=r,this.reset()}update(e,r){this.hash.update(Ot(Qs(e,r)))}digest(){return Promise.resolve(this.hash.digest())}reset(){this.hash=this.secret?(0,Vt.createHmac)(this.algorithmIdentifier,Qs(this.secret)):(0,Vt.createHash)(this.algorithmIdentifier)}}});var Zs,Ue,un=m(()=>{Zs=require("node:stream");wr();Ue=class extends Zs.Readable{expectedChecksum;checksumSourceLocation;checksum;source;base64Encoder;constructor({expectedChecksum:e,checksum:r,source:n,checksumSourceLocation:o,base64Encoder:s}){if(super(),typeof n.pipe!="function")throw new Error(`@smithy/util-stream: unsupported source type ${n?.constructor?.name??n} in ChecksumStream.`);this.source=n,this.base64Encoder=s??ne,this.expectedChecksum=e,this.checksum=r,this.checksumSourceLocation=o,this.source.on("data",this.onSourceData),this.source.on("end",this.onSourceEnd),this.source.on("error",this.onSourceError),this.source.on("close",this.onSourceClose),this.source.pause()}onSourceData=e=>{if(!this.destroyed){try{this.checksum.update(e)}catch(r){this.destroy(r);return}this.push(e)||this.source.pause()}};onSourceEnd=async()=>{if(!this.destroyed){try{let e=await this.checksum.digest(),r=this.base64Encoder(e);if(this.expectedChecksum!==r){this.destroy(new Error(`Checksum mismatch: expected "${this.expectedChecksum}" but received "${r}" in response header "${this.checksumSourceLocation}".`));return}}catch(e){this.destroy(e);return}this.push(null)}};onSourceError=e=>{this.destroy(e)};onSourceClose=()=>{!this.destroyed&&!this.source.readableEnded&&this.destroy(new Error("Connection lost or stream closed before all data was received."))};_read(e){this.source.resume()}_destroy(e,r){this.source?.removeListener("data",this.onSourceData),this.source?.removeListener("end",this.onSourceEnd),this.source?.removeListener("error",this.onSourceError),this.source?.removeListener("close",this.onSourceClose),this.source?.destroy(),r(e)}}});var I,ie,F=m(()=>{I=t=>typeof ReadableStream=="function"&&(t?.constructor?.name===ReadableStream.name||t instanceof ReadableStream),ie=t=>typeof Blob=="function"&&(t?.constructor?.name===Blob.name||t instanceof Blob)});var Ys,ei=m(()=>{Ys=t=>new TextEncoder().encode(t)});var ti,Ul,ri,Gt,ln,ni,oi=m(()=>{ti="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ul=Object.entries(ti).reduce((t,[e,r])=>(t[r]=Number(e),t),{}),ri=ti.split(""),Gt=6,ln=8,ni=63});function qt(t){let e;typeof t=="string"?e=Ys(t):e=t;let r=typeof e=="object"&&typeof e.length=="number",n=typeof e=="object"&&typeof e.byteOffset=="number"&&typeof e.byteLength=="number";if(!r&&!n)throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");let o="";for(let s=0;s<e.length;s+=3){let i=0,a=0;for(let f=s,u=Math.min(s+3,e.length);f<u;f++)i|=e[f]<<(u-f-1)*ln,a+=ln;let c=Math.ceil(a/Gt);i<<=c*Gt-a;for(let f=1;f<=c;f++){let u=(c-f)*Gt;o+=ri[(i&ni<<u)>>u]}o+="==".slice(0,4-c)}return o}var dn=m(()=>{ei();oi()});var nf,Wt,si=m(()=>{nf=typeof ReadableStream=="function"?ReadableStream:function(){},Wt=class extends nf{}});var ii,ai=m(()=>{dn();F();si();ii=({expectedChecksum:t,checksum:e,source:r,checksumSourceLocation:n,base64Encoder:o})=>{if(!I(r))throw new Error(`@smithy/util-stream: unsupported source type ${r?.constructor?.name??r} in ChecksumStream.`);let s=o??qt;if(typeof TransformStream!="function")throw new Error("@smithy/util-stream: unable to instantiate ChecksumStream because API unavailable: ReadableStream/TransformStream.");let i=new TransformStream({start(){},async transform(c,f){e.update(c),f.enqueue(c)},async flush(c){let f=await e.digest(),u=s(f);if(t!==u){let d=new Error(`Checksum mismatch: expected "${t}" but received "${u}" in response header "${n}".`);c.error(d)}else c.terminate()}});r.pipeThrough(i);let a=i.readable;return Object.setPrototypeOf(a,Wt.prototype),a}});function ci(t){return typeof ReadableStream=="function"&&I(t.source)?ii(t):new Ue(t)}var fi=m(()=>{F();un();ai()});var ge,hn=m(()=>{ge=class{allocByteArray;byteLength=0;byteArrays=[];constructor(e){this.allocByteArray=e}push(e){this.byteArrays.push(e),this.byteLength+=e.byteLength}flush(){if(this.byteArrays.length===1){let n=this.byteArrays[0];return this.reset(),n}let e=this.allocByteArray(this.byteLength),r=0;for(let n=0;n<this.byteArrays.length;++n){let o=this.byteArrays[n];e.set(o,r),r+=o.byteLength}return this.reset(),e}reset(){this.byteArrays=[],this.byteLength=0}}});function mi(t,e,r){let n=t.getReader(),o=!1,s=0,i=["",new ge(f=>new Uint8Array(f))],a=-1,c=async f=>{let{value:u,done:d}=await n.read(),l=u;if(d){if(a!==-1){let h=ye(i,a);Z(h)>0&&f.enqueue(h)}f.close()}else{let h=gn(l,!1);if(a!==h&&(a>=0&&f.enqueue(ye(i,a)),a=h),a===-1){f.enqueue(l);return}let p=Z(l);s+=p;let g=Z(i[a]);if(p>=e&&g===0)f.enqueue(l);else{let y=pn(i,a,l);!o&&s>e*2&&(o=!0,r?.warn(`@smithy/util-stream - stream chunk size ${p} is below threshold of ${e}, automatically buffering.`)),y>=e?f.enqueue(ye(i,a)):await c(f)}}};return new ReadableStream({pull:c})}function pn(t,e,r){switch(e){case 0:return t[0]+=r,Z(t[0]);case 1:case 2:return t[e].push(r),Z(t[e])}}function ye(t,e){switch(e){case 0:let r=t[0];return t[0]="",r;case 1:case 2:return t[e].flush()}throw new Error(`@smithy/util-stream - invalid index ${e} given to flush()`)}function Z(t){return t?.byteLength??t?.length??0}function gn(t,e=!0){return e&&typeof Buffer<"u"&&t instanceof Buffer?2:t instanceof Uint8Array?1:typeof t=="string"?0:-1}var ui=m(()=>{hn()});function di(t,e,r){if(I(t))return mi(t,e,r);let n=new li.Readable({read(){}}),o=!1,s=0,i=["",new ge(c=>new Uint8Array(c)),new ge(c=>Buffer.from(new Uint8Array(c)))],a=-1;return t.on("data",c=>{let f=gn(c,!0);if(a!==f&&(a>=0&&n.push(ye(i,a)),a=f),a===-1){n.push(c);return}let u=Z(c);s+=u;let d=Z(i[a]);if(u>=e&&d===0)n.push(c);else{let l=pn(i,a,c);!o&&s>e*2&&(o=!0,r?.warn(`@smithy/util-stream - stream chunk size ${u} is below threshold of ${e}, automatically buffering.`)),l>=e&&n.push(ye(i,a))}}),t.on("end",()=>{if(a!==-1){let c=ye(i,a);Z(c)>0&&n.push(c)}n.push(null)}),n}var li,hi=m(()=>{li=require("node:stream");hn();ui();F()});var pi,gi=m(()=>{pi=(t,e)=>{let{base64Encoder:r,bodyLengthChecker:n,checksumAlgorithmFn:o,checksumLocationName:s,streamHasher:i}=e,a=r!==void 0&&n!==void 0&&o!==void 0&&s!==void 0&&i!==void 0,c=a?i(o,t):void 0,f=t.getReader();return new ReadableStream({async pull(u){let{value:d,done:l}=await f.read();if(l){if(u.enqueue(`0\r
|
|
5
5
|
`),a){let h=r(await c);u.enqueue(`${s}:${h}\r
|
|
6
6
|
`),u.enqueue(`\r
|
|
7
|
-
`)}u.close()}else u.enqueue(`${(n(
|
|
8
|
-
${
|
|
9
|
-
`)}})}});function
|
|
10
|
-
`),
|
|
11
|
-
`))}),r.on("end",async()=>{if(
|
|
12
|
-
`),f){let
|
|
13
|
-
`),
|
|
14
|
-
`)}
|
|
15
|
-
If you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body`);return o.stream()};return Object.assign(t,{transformToByteArray:r,transformToString:async o=>{let s=await r();if(o==="base64")return qt(s);if(o==="hex")return U(s);if(o===void 0||o==="utf8"||o==="utf-8")return Ci(s);if(typeof TextDecoder=="function")return new TextDecoder(o).decode(s);throw new Error("TextDecoder is not available, please make sure polyfill is provided.")},transformToWebStream:()=>{if(e)throw new Error(vi);if(e=!0,Ri(t))return n(t);if(I(t))return t;throw new Error(`Cannot transform payload to web stream, got ${t}`)}})},Ri=t=>typeof Blob=="function"&&t instanceof Blob});var Mi,Jt,xn,En=m(()=>{Mi=require("node:stream");Qe();wn();L();Jt=t=>ie(t)?Sn(t):I(t)?bn(t):new Promise((e,r)=>{let n=new xn,o=t;o.pipe(n),o.on("error",s=>{n.end(),r(s)}),n.on("error",r),n.on("finish",function(){let s=se(this.bufferedBytes);e(s)})}),xn=class extends Mi.Writable{bufferedBytes=[];_write(e,r,n){this.bufferedBytes.push(e),n()}}});var Kt,Pi,Qt,ki=m(()=>{Kt=require("node:stream");re();Oi();En();Pi="The stream has already been transformed.",Qt=t=>{if(!(t instanceof Kt.Readable))try{return Ni(t)}catch{let o=t?.__proto__?.constructor?.name||t;throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${o}`)}let e=!1,r=async()=>{if(e)throw new Error(Pi);return e=!0,await Jt(t)};return Object.assign(t,{transformToByteArray:r,transformToString:async n=>{let o=await r();return n===void 0||Buffer.isEncoding(n)?_(o.buffer,o.byteOffset,o.byteLength).toString(n):new TextDecoder(n).decode(o)},transformToWebStream:()=>{if(e)throw new Error(Pi);if(t.readableFlowing!==null)throw new Error("The stream has been consumed by other callbacks.");if(typeof Kt.Readable.toWeb!="function")throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");return e=!0,Kt.Readable.toWeb(t)}})}});async function Ui(t){return typeof t.stream=="function"&&(t=t.stream()),t.tee()}var Di=m(()=>{});async function _i(t){if(I(t)||ie(t))return Ui(t);let e=new Tn.PassThrough,r=new Tn.PassThrough;return t.pipe(e),t.pipe(r),[e,r]}var Tn,$i=m(()=>{Tn=require("node:stream");Di();L()});var Fi={};dt(Fi,{ChecksumStream:()=>Ue,Hash:()=>jt,LazyJsonString:()=>k,NumericValue:()=>le,Uint8ArrayBlobAdapter:()=>Se,_parseEpochTimestamp:()=>It,_parseRfc3339DateTimeWithOffset:()=>At,_parseRfc7231DateTime:()=>vt,calculateBodyLength:()=>_o,concatBytes:()=>se,copyDocumentWithTransform:()=>oo,createBufferedReadable:()=>di,createChecksumStream:()=>ai,dateToUtcString:()=>Tt,deserializerMiddleware:()=>Mt,deserializerMiddlewareOption:()=>fn,expectBoolean:()=>ao,expectByte:()=>St,expectFloat32:()=>We,expectInt:()=>co,expectInt32:()=>gt,expectLong:()=>Ce,expectNonNull:()=>fo,expectNumber:()=>Te,expectObject:()=>Er,expectShort:()=>yt,expectString:()=>mo,expectUnion:()=>uo,fromArrayBuffer:()=>_,fromBase64:()=>Ee,fromHex:()=>Nt,fromString:()=>te,fromUtf8:()=>$,generateIdempotencyToken:()=>Cn,getAwsChunkedEncodingStream:()=>yi,getSerdePlugin:()=>Ws,handleFloat:()=>ho,headStream:()=>Ei,isArrayBuffer:()=>lt,isBlob:()=>ie,isReadableStream:()=>I,limitedParseDouble:()=>xt,limitedParseFloat:()=>po,limitedParseFloat32:()=>go,logger:()=>Ie,nv:()=>ko,parseBoolean:()=>io,parseEpochTimestamp:()=>To,parseRfc3339DateTime:()=>wo,parseRfc3339DateTimeWithOffset:()=>xo,parseRfc7231DateTime:()=>Eo,quoteHeader:()=>Ct,sdkStreamMixin:()=>Qt,serializerMiddleware:()=>Ht,serializerMiddlewareOption:()=>mn,splitEvery:()=>Rt,splitHeader:()=>Re,splitStream:()=>_i,streamCollector:()=>Jt,strictParseByte:()=>Et,strictParseDouble:()=>Je,strictParseFloat:()=>lo,strictParseFloat32:()=>wt,strictParseInt:()=>So,strictParseInt32:()=>bo,strictParseLong:()=>Tr,strictParseShort:()=>oe,toBase64:()=>ne,toHex:()=>U,toUint8Array:()=>Ot,toUtf8:()=>W,v4:()=>Li});var Bi,Se,rf,Li,Cn,G=m(()=>{Bi=require("node:crypto");Zn();wr();eo();ht();to();no();so();Co();Io();Cr();Ao();No();Oo();Mo();Uo();Mr();$o();Pr();Qe();re();br();Vr();Js();cn();Qs();un();ci();li();Si();Ti();ki();$i();L();En();Se=class extends Yn(W,$,ne,Ee){},rf=Bi.getRandomValues,Li=ro(rf),Cn=Li});var q,Xt=m(()=>{G();q=async(t=new Uint8Array,e)=>{if(t instanceof Uint8Array)return Se.mutate(t);if(!t)return Se.mutate(new Uint8Array);let r=e.streamCollector(t);return Se.mutate(await r)}});function ae(t){return encodeURIComponent(t).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}var Zt=m(()=>{});var D,De=m(()=>{D=class{serdeContext;setSerdeContext(e){this.serdeContext=e}}});var zi,In,Yt,Hi=m(()=>{zi=new Uint32Array(256);for(let t=0;t<256;++t){let e=t;for(let r=0;r<8;++r)e=e&1?3988292384^e>>>1:e>>>1;zi[t]=e>>>0}In=4294967295,Yt=class{digestLength=4;checksum=In;update(e){for(let r=0;r<e.length;++r)this.checksum=this.checksum>>>8^zi[(this.checksum^e[r])&255]}digestSync(){return(this.checksum^In)>>>0}async digest(){let e=this.digestSync(),r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e,!1),r}reset(){this.checksum=In}}});function nf(t){return class{digestLength=4;value=0;update(r){this.value=t(r,this.value)}digestSync(){return this.value>>>0}async digest(){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,this.digestSync(),!1),r}reset(){this.value=0}}}var An,ji,_e,Vi=m(()=>{An=xe(require("node:zlib"));Hi();ji=typeof An.crc32=="function"?An.crc32:void 0,_e=ji?nf(ji):Yt});var vn=m(()=>{Vi()});function Gi(t){for(let e=0;e<8;e++)t[e]^=255;for(let e=7;e>-1&&(t[e]++,t[e]===0);e--);}var ce,Rn=m(()=>{G();ce=class t{bytes;constructor(e){if(this.bytes=e,e.byteLength!==8)throw new Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(e){if(e>9223372036854776e3||e<-9223372036854776e3)throw new Error(`${e} is too large (or, if negative, too small) to represent as an Int64`);let r=new Uint8Array(8);for(let n=7,o=Math.abs(Math.round(e));n>-1&&o>0;n--,o/=256)r[n]=o;return e<0&&Gi(r),new t(r)}valueOf(){let e=this.bytes.slice(0),r=e[0]&128;return r&&Gi(e),parseInt(U(e),16)*(r?-1:1)}toString(){return String(this.valueOf())}}});var $e,C,qi,of,sf,af,cf,ff,mf,uf,df,lf,Nn=m(()=>{G();Rn();$e=class{toUtf8;fromUtf8;constructor(e,r){this.toUtf8=e,this.fromUtf8=r}format(e){let r=[];for(let s of Object.keys(e)){let i=this.fromUtf8(s);r.push(Uint8Array.from([i.byteLength]),i,this.formatHeaderValue(e[s]))}let n=new Uint8Array(r.reduce((s,i)=>s+i.byteLength,0)),o=0;for(let s of r)n.set(s,o),o+=s.byteLength;return n}formatHeaderValue(e){switch(e.type){case"boolean":return Uint8Array.from([e.value?C.boolTrue:C.boolFalse]);case"byte":return Uint8Array.from([C.byte,e.value]);case"short":let r=new DataView(new ArrayBuffer(3));return r.setUint8(0,C.short),r.setInt16(1,e.value,!1),new Uint8Array(r.buffer);case"integer":let n=new DataView(new ArrayBuffer(5));return n.setUint8(0,C.integer),n.setInt32(1,e.value,!1),new Uint8Array(n.buffer);case"long":let o=new Uint8Array(9);return o[0]=C.long,o.set(e.value.bytes,1),o;case"binary":let s=new DataView(new ArrayBuffer(3+e.value.byteLength));s.setUint8(0,C.byteArray),s.setUint16(1,e.value.byteLength,!1);let i=new Uint8Array(s.buffer);return i.set(e.value,3),i;case"string":let a=this.fromUtf8(e.value),c=new DataView(new ArrayBuffer(3+a.byteLength));c.setUint8(0,C.string),c.setUint16(1,a.byteLength,!1);let f=new Uint8Array(c.buffer);return f.set(a,3),f;case"timestamp":let u=new Uint8Array(9);return u[0]=C.timestamp,u.set(ce.fromNumber(e.value.valueOf()).bytes,1),u;case"uuid":if(!lf.test(e.value))throw new Error(`Invalid UUID received: ${e.value}`);let l=new Uint8Array(17);return l[0]=C.uuid,l.set(Nt(e.value.replace(/-/g,"")),1),l}}parse(e){let r={},n=0;for(;n<e.byteLength;){let o=e.getUint8(n++),s=this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,o));switch(n+=o,e.getUint8(n++)){case C.boolTrue:r[s]={type:qi,value:!0};break;case C.boolFalse:r[s]={type:qi,value:!1};break;case C.byte:r[s]={type:of,value:e.getInt8(n++)};break;case C.short:r[s]={type:sf,value:e.getInt16(n,!1)},n+=2;break;case C.integer:r[s]={type:af,value:e.getInt32(n,!1)},n+=4;break;case C.long:r[s]={type:cf,value:new ce(new Uint8Array(e.buffer,e.byteOffset+n,8))},n+=8;break;case C.byteArray:let i=e.getUint16(n,!1);n+=2,r[s]={type:ff,value:new Uint8Array(e.buffer,e.byteOffset+n,i)},n+=i;break;case C.string:let a=e.getUint16(n,!1);n+=2,r[s]={type:mf,value:this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,a))},n+=a;break;case C.timestamp:r[s]={type:uf,value:new Date(new ce(new Uint8Array(e.buffer,e.byteOffset+n,8)).valueOf())},n+=8;break;case C.uuid:let c=new Uint8Array(e.buffer,e.byteOffset+n,16);n+=16,r[s]={type:df,value:`${U(c.subarray(0,4))}-${U(c.subarray(4,6))}-${U(c.subarray(6,8))}-${U(c.subarray(8,10))}-${U(c.subarray(10))}`};break;default:throw new Error("Unrecognized header type tag")}}return r}};(function(t){t[t.boolTrue=0]="boolTrue",t[t.boolFalse=1]="boolFalse",t[t.byte=2]="byte",t[t.short=3]="short",t[t.integer=4]="integer",t[t.long=5]="long",t[t.byteArray=6]="byteArray",t[t.string=7]="string",t[t.timestamp=8]="timestamp",t[t.uuid=9]="uuid"})(C||(C={}));qi="boolean",of="byte",sf="short",af="integer",cf="long",ff="binary",mf="string",uf="timestamp",df="uuid",lf=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/});function Ji({byteLength:t,byteOffset:e,buffer:r}){if(t<hf)throw new Error("Provided message too short to accommodate event stream message overhead");let n=new DataView(r,e,t),o=n.getUint32(0,!1);if(t!==o)throw new Error("Reported message length does not match received message length");let s=n.getUint32(Wi,!1),i=n.getUint32(fe,!1),a=n.getUint32(t-be,!1),c=new _e;if(c.update(new Uint8Array(r,e,fe)),i!==c.digestSync())throw new Error(`The prelude checksum specified in the message (${i}) does not match the calculated CRC32 checksum (${c.digestSync()})`);if(c.update(new Uint8Array(r,e+fe,t-(fe+be))),a!==c.digestSync())throw new Error(`The message checksum (${c.digestSync()}) did not match the expected value of ${a}`);return{headers:new DataView(r,e+fe+be,s),body:new Uint8Array(r,e+fe+be+s,o-s-(fe+be+be))}}var Wi,fe,be,hf,Ki=m(()=>{vn();Wi=4,fe=Wi*2,be=4,hf=fe+be*2});var Be,On=m(()=>{vn();Nn();Ki();Be=class{headerMarshaller;messageBuffer;isEndOfStream;constructor(e,r){this.headerMarshaller=new $e(e,r),this.messageBuffer=[],this.isEndOfStream=!1}feed(e){this.messageBuffer.push(this.decode(e))}endOfStream(){this.isEndOfStream=!0}getMessage(){let e=this.messageBuffer.pop(),r=this.isEndOfStream;return{getMessage(){return e},isEndOfStream(){return r}}}getAvailableMessages(){let e=this.messageBuffer;this.messageBuffer=[];let r=this.isEndOfStream;return{getMessages(){return e},isEndOfStream(){return r}}}encode({headers:e,body:r}){let n=this.headerMarshaller.format(e),o=n.byteLength+r.byteLength+16,s=new Uint8Array(o),i=new DataView(s.buffer,s.byteOffset,s.byteLength),a=new _e;return i.setUint32(0,o,!1),i.setUint32(4,n.byteLength,!1),a.update(s.subarray(0,8)),i.setUint32(8,a.digestSync(),!1),s.set(n,12),s.set(r,n.byteLength+12),a.update(s.subarray(8,o-4)),i.setUint32(o-4,a.digestSync(),!1),s}decode(e){let{headers:r,body:n}=Ji(e);return{headers:this.headerMarshaller.parse(r),body:n}}formatHeaders(e){return this.headerMarshaller.format(e)}}});var Le,Mn=m(()=>{Le=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.inputStream)yield this.options.decoder.decode(e)}}});var Fe,Pn=m(()=>{Fe=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.messageStream)yield this.options.encoder.encode(e);this.options.includeEndFrame&&(yield new Uint8Array(0))}}});var ze,kn=m(()=>{ze=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.messageStream){let r=await this.options.deserializer(e);r!==void 0&&(yield r)}}}});var He,Un=m(()=>{He=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.inputStream)yield this.options.serializer(e)}}});function er(t){let e=0,r=0,n=null,o=null,s=a=>{if(typeof a!="number")throw new Error("Attempted to allocate an event message where size was not a number: "+a);e=a,r=4,n=new Uint8Array(a),new DataView(n.buffer).setUint32(0,a,!1)},i=async function*(){let a=t[Symbol.asyncIterator]();for(;;){let{value:c,done:f}=await a.next();if(f){if(e)if(e===r)yield n;else throw new Error("Truncated event message received.");else return;return}let u=c.length,l=0;for(;l<u;){if(!n){let h=u-l;o||(o=new Uint8Array(4));let p=Math.min(4-r,h);if(o.set(c.slice(l,l+p),r),r+=p,l+=p,r<4)break;s(new DataView(o.buffer).getUint32(0,!1)),o=null}let d=Math.min(e-r,u-l);n.set(c.slice(l,l+d),r),r+=d,l+=d,e&&e===r&&(yield n,n=null,e=0,r=0)}}};return{[Symbol.asyncIterator]:i}}var Dn=m(()=>{});function Qi(t,e){let r=it(e.deserializer,e.toUtf8);return{[Symbol.asyncIterator]:async function*(){for await(let n of t){let o=e.eventStreamCodec.decode(n),s=await r(o);s!==void 0&&(yield s)}}}}function it(t,e){return async function(r){let{value:n}=r.headers[":message-type"];if(n==="error"){let o=new Error(r.headers[":error-message"].value||"UnknownError");throw o.name=r.headers[":error-code"].value,o}else if(n==="exception"){let o=r.headers[":exception-type"].value,s={[o]:r},i=await t(s);if(i.$unknown){let a=new Error(e(r.body));throw a.name=o,a}throw i[o]}else if(n==="event"){let o={[r.headers[":event-type"].value]:r},s=await t(o);return s.$unknown?void 0:s}else throw Error(`Unrecognizable event type: ${r.headers[":event-type"].value}`)}}var _n=m(()=>{});var we,Xi,$n=m(()=>{On();Mn();Pn();kn();Un();Dn();_n();we=class{eventStreamCodec;utfEncoder;constructor({utf8Encoder:e,utf8Decoder:r}){this.eventStreamCodec=new Be(e,r),this.utfEncoder=e}deserialize(e,r){let n=er(e);return new ze({messageStream:new Le({inputStream:n,decoder:this.eventStreamCodec}),deserializer:it(r,this.utfEncoder)})}serialize(e,r){return new Fe({messageStream:new He({inputStream:e,serializer:r}),encoder:this.eventStreamCodec,includeEndFrame:!0})}},Xi=t=>new we(t)});async function*pf(t){let e=!1,r=!1,n=new Array;for(t.on("error",o=>{if(e||(e=!0),o)throw o}),t.on("data",o=>{n.push(o)}),t.on("end",()=>{e=!0});!r;){let o=await new Promise(s=>setTimeout(()=>s(n.shift()),0));o&&(yield o),r=e&&n.length===0}}var Zi,at,Yi,ea=m(()=>{Zi=require("node:stream");$n();at=class{universalMarshaller;constructor({utf8Encoder:e,utf8Decoder:r}){this.universalMarshaller=new we({utf8Decoder:r,utf8Encoder:e})}deserialize(e,r){let n=typeof e[Symbol.asyncIterator]=="function"?e:pf(e);return this.universalMarshaller.deserialize(n,r)}serialize(e,r){return Zi.Readable.from(this.universalMarshaller.serialize(e,r))}},Yi=t=>new at(t)});var ta,ra,na=m(()=>{ta=t=>({[Symbol.asyncIterator]:async function*(){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}}),ra=t=>{let e=t[Symbol.asyncIterator]();return new ReadableStream({async pull(r){let{done:n,value:o}=await e.next();if(n)return r.close();r.enqueue(o)}})}});var oa,sa=m(()=>{oa=t=>Object.assign(t,{eventStreamMarshaller:t.eventStreamSerdeProvider(t)})});var tr,ia=m(()=>{X();G();tr=class{marshaller;serializer;deserializer;serdeContext;defaultContentType;compositeErrorRegistry;constructor({marshaller:e,serializer:r,deserializer:n,serdeContext:o,defaultContentType:s,compositeErrorRegistry:i}){this.marshaller=e,this.serializer=r,this.deserializer=n,this.serdeContext=o,this.defaultContentType=s,this.compositeErrorRegistry=i}async serializeEventStream({eventStream:e,requestSchema:r,initialRequest:n}){let o=this.marshaller,s=r.getEventStreamMember(),i=r.getMemberSchema(s),a=this.serializer,c=this.defaultContentType,f=Symbol("initialRequestMarker"),u={async*[Symbol.asyncIterator](){if(n){let l={":event-type":{type:"string",value:"initial-request"},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:c}};a.write(r,n);let d=a.flush();yield{[f]:!0,headers:l,body:d}}for await(let l of e)yield l}};return o.serialize(u,l=>{if(l[f])return{headers:l.headers,body:l.body};let d="";for(let b in l)if(b!=="__type"){d=b;break}let{additionalHeaders:h,body:p,eventType:g,explicitPayloadContentType:y}=this.writeEventBody(d,i,l);return{headers:{":event-type":{type:"string",value:g},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:y??c},...h},body:p}})}async deserializeEventStream({response:e,responseSchema:r,initialResponseContainer:n}){let o=this.marshaller,s=r.getEventStreamMember(),a=r.getMemberSchema(s).getMemberSchemas(),c=Symbol("initialResponseMarker"),f=o.deserialize(e.body,async d=>{let h="";for(let g in d)if(g!=="__type"){h=g;break}let p=d[h].body;if(h==="initial-response"){let g=await this.deserializer.read(r,p);return delete g[s],{[c]:!0,...g}}else if(h in a){let g=a[h];if(g.isStructSchema()){let y={},S=!1;for(let[b,E]of g.structIterator()){let{eventHeader:v,eventPayload:z}=E.getMergedTraits();if(S=S||!!(v||z),z)E.isBlobSchema()?y[b]=p:E.isStringSchema()?y[b]=(this.serdeContext?.utf8Encoder??W)(p):E.isStructSchema()&&(y[b]=await this.deserializer.read(E,p));else if(v){let O=d[h].headers[b]?.value;O!=null&&(E.isNumericSchema()?O&&typeof O=="object"&&"bytes"in O?y[b]=BigInt(O.toString()):y[b]=Number(O):y[b]=O)}}return{[h]:await this.readEventMember(g,p,S,y)}}return{[h]:await this.deserializer.read(g,p)}}else return{$unknown:d}}),u=f[Symbol.asyncIterator](),l=await u.next();if(l.done)return f;if(l.value?.[c]){if(!r)throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");for(let d in l.value)n[d]=l.value[d]}return{async*[Symbol.asyncIterator](){for(l?.value?.[c]||(yield l.value);;){let{done:d,value:h}=await u.next();if(d)break;yield h}}}}async readEventMember(e,r,n,o){let s,i=e.getSchema();if(Array.isArray(i)&&i[0]===-3){let c=i[1],f=pe.for(c);this.compositeErrorRegistry?.copyFrom(f),s=(this.compositeErrorRegistry??f)?.getErrorCtor(i)}let a=n?o:r.byteLength===0?{}:await this.deserializer.read(e,r);if(s){let c=a.message??a.Message??"Unknown",f={},u=e.getMergedTraits().error;return u&&(f.$fault=u),Object.assign(new s({}),f,{message:c},a)}return a}writeEventBody(e,r,n){let o=this.serializer,s=e,i=null,a,c=r.getSchema()[4].includes(e),f={};if(c){let d=r.getMemberSchema(e);if(d.isStructSchema()){for(let[h,p]of d.structIterator()){let{eventHeader:g,eventPayload:y}=p.getMergedTraits();if(y)i=h;else if(g){let S=n[e][h],b="binary";p.isNumericSchema()?(-2)**31<=S&&S<=2**31-1?b="integer":b="long":p.isTimestampSchema()?b="timestamp":p.isStringSchema()?b="string":p.isBooleanSchema()&&(b="boolean"),S!=null&&(f[h]={type:b,value:S},delete n[e][h])}}if(i!==null){let h=d.getMemberSchema(i);h.isBlobSchema()?a="application/octet-stream":h.isStringSchema()&&(a="text/plain"),o.write(h,n[e][i])}else o.write(d,n[e])}else if(d.isUnitSchema())o.write(d,{});else throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.")}else{let[d,h]=n[e];s=d,o.write(15,h)}let u=o.flush()??new Uint8Array;return{body:typeof u=="string"?(this.serdeContext?.utf8Decoder??$)(u):u,eventType:s,explicitPayloadContentType:a,additionalHeaders:f}}}});var aa={};dt(aa,{EventStreamCodec:()=>Be,EventStreamMarshaller:()=>at,EventStreamSerde:()=>tr,HeaderMarshaller:()=>$e,Int64:()=>ce,MessageDecoderStream:()=>Le,MessageEncoderStream:()=>Fe,SmithyMessageDecoderStream:()=>ze,SmithyMessageEncoderStream:()=>He,UniversalEventStreamMarshaller:()=>we,eventStreamSerdeProvider:()=>Yi,getChunkedStream:()=>er,getMessageUnmarshaller:()=>it,getUnmarshalledStream:()=>Qi,iterableToReadableStream:()=>ra,readableStreamToIterable:()=>ta,resolveEventStreamSerdeConfig:()=>oa,universalEventStreamSerdeProvider:()=>Xi});var ca=m(()=>{On();Nn();Rn();Mn();Pn();kn();Un();ea();na();$n();Dn();_n();sa();ia()});var me,rr=m(()=>{X();N();De();me=class extends D{options;compositeErrorRegistry;constructor(e){super(),this.options=e,this.compositeErrorRegistry=pe.for(e.defaultNamespace);for(let r of e.errorTypeRegistries??[])this.compositeErrorRegistry.copyFrom(r)}getRequestType(){return P}getResponseType(){return K}setSerdeContext(e){this.serdeContext=e,this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e),this.getPayloadCodec()&&this.getPayloadCodec().setSerdeContext(e)}updateServiceEndpoint(e,r){if("url"in r){e.protocol=r.url.protocol,e.hostname=r.url.hostname,e.port=r.url.port?Number(r.url.port):void 0,e.path=r.url.pathname,e.fragment=r.url.hash||void 0,e.username=r.url.username||void 0,e.password=r.url.password||void 0,e.query||(e.query={});for(let[n,o]of r.url.searchParams.entries())e.query[n]=o;if(r.headers)for(let n in r.headers)e.headers[n]=r.headers[n].join(", ");return e}else{if(e.protocol=r.protocol,e.hostname=r.hostname,e.port=r.port?Number(r.port):void 0,e.path=r.path,e.query={...r.query},r.headers)for(let n in r.headers)e.headers[n]=r.headers[n];return e}}setHostPrefix(e,r,n){if(this.serdeContext?.disableHostPrefix)return;let o=T.of(r.input),s=V(r.traits??{});if(s.endpoint){let i=s.endpoint?.[0];if(typeof i=="string"){for(let[a,c]of o.structIterator()){if(!c.getMergedTraits().hostLabel)continue;let f=n[a];if(typeof f!="string")throw new Error(`@smithy/core/schema - ${a} in input must be a string as hostLabel.`);i=i.replace(`{${a}}`,f)}if(e.hostname=i+e.hostname,!Ye(e.hostname))throw new Error(`[${e.hostname}] is not a valid hostname.`)}}}deserializeMetadata(e){return{httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}}async serializeEventStream({eventStream:e,requestSchema:r,initialRequest:n}){return(await this.loadEventStreamCapability()).serializeEventStream({eventStream:e,requestSchema:r,initialRequest:n})}async deserializeEventStream({response:e,responseSchema:r,initialResponseContainer:n}){return(await this.loadEventStreamCapability()).deserializeEventStream({response:e,responseSchema:r,initialResponseContainer:n})}async loadEventStreamCapability(){let{EventStreamSerde:e,eventStreamSerdeProvider:r}=await Promise.resolve().then(()=>(ca(),aa)),n=this.resolveEventStreamMarshaller(r);return new e({marshaller:n,serializer:this.serializer,deserializer:this.deserializer,serdeContext:this.serdeContext,defaultContentType:this.getDefaultContentType(),compositeErrorRegistry:this.compositeErrorRegistry})}resolveEventStreamMarshaller(e){let r=this.serdeContext;return r.eventStreamMarshaller?r.eventStreamMarshaller:e(this.serdeContext)}getDefaultContentType(){throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`)}async deserializeHttpMessage(e,r,n,o,s){return[]}getEventStreamMarshaller(){let e=this.serdeContext;if(!e.eventStreamMarshaller)throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");return e.eventStreamMarshaller}}});var nr,fa=m(()=>{X();G();N();rr();Xt();Zt();nr=class extends me{async serializeRequest(e,r,n){let o=r&&typeof r=="object"?r:{},s=this.serializer,i={},a={},c=await n.endpoint(),f=T.of(e?.input),u=[],l=[],d=!1,h,p=new P({protocol:"",hostname:"",port:void 0,path:"",fragment:void 0,query:i,headers:a,body:void 0});if(c){this.updateServiceEndpoint(p,c),this.setHostPrefix(p,e,o);let g=V(e.traits);if(g.http){p.method=g.http[0];let[y,S]=g.http[1].split("?");p.path=="/"?p.path=y:p.path+=y;let b=new URLSearchParams(S??"");for(let[E,v]of b)i[E]=v}}for(let[g,y]of f.structIterator()){let S=y.getMergedTraits()??{},b=o[g];if(b==null&&!y.isIdempotencyToken()){if(S.httpLabel&&(p.path.includes(`{${g}+}`)||p.path.includes(`{${g}}`)))throw new Error(`No value provided for input HTTP label: ${g}.`);continue}if(S.httpPayload)y.isStreaming()?y.isStructSchema()?o[g]&&(h=await this.serializeEventStream({eventStream:o[g],requestSchema:f})):h=b:(s.write(y,b),h=s.flush());else if(S.httpLabel){s.write(y,b);let E=s.flush();p.path.includes(`{${g}+}`)?p.path=p.path.replace(`{${g}+}`,E.split("/").map(ae).join("/")):p.path.includes(`{${g}}`)&&(p.path=p.path.replace(`{${g}}`,ae(E)))}else if(S.httpHeader)s.write(y,b),a[S.httpHeader.toLowerCase()]=String(s.flush());else if(typeof S.httpPrefixHeaders=="string")for(let E in b){let v=b[E],z=S.httpPrefixHeaders+E;s.write([y.getValueSchema(),{httpHeader:z}],v),a[z.toLowerCase()]=s.flush()}else S.httpQuery||S.httpQueryParams?this.serializeQuery(y,b,i):(d=!0,u.push(g),l.push(y))}if(d&&o){let[g,y]=(f.getName(!0)??"#Unknown").split("#"),S=f.getSchema()[6],b=[3,g,y,f.getMergedTraits(),u,l,void 0];S?b[6]=S:b.pop(),s.write(b,o),h=s.flush()}return p.headers=a,p.query=i,p.body=h,p}serializeQuery(e,r,n){let o=this.serializer,s=e.getMergedTraits();if(s.httpQueryParams){for(let i in r)if(!(i in n)){let a=r[i],c=e.getValueSchema();Object.assign(c.getMergedTraits(),{...s,httpQuery:i,httpQueryParams:void 0}),this.serializeQuery(c,a,n)}return}if(e.isListSchema()){let i=!!e.getMergedTraits().sparse,a=[];for(let c of r){o.write([e.getValueSchema(),s],c);let f=o.flush();(i||f!==void 0)&&a.push(f)}n[s.httpQuery]=a}else o.write([e,s],r),n[s.httpQuery]=o.flush()}async deserializeResponse(e,r,n){let o=this.deserializer,s=T.of(e.output),i={};if(n.statusCode>=300){let c=await q(n.body,r);throw c.byteLength>0&&Object.assign(i,await o.read(15,c)),await this.handleError(e,r,n,i,this.deserializeMetadata(n)),new Error("@smithy/core/protocols - HTTP Protocol error handler failed to throw.")}for(let c in n.headers){let f=n.headers[c];delete n.headers[c],n.headers[c.toLowerCase()]=f}let a=await this.deserializeHttpMessage(s,r,n,i);if(a.length){let c=await q(n.body,r);if(c.byteLength>0){let f=await o.read(s,c);for(let u of a)f[u]!=null&&(i[u]=f[u])}}else a.discardResponseBody&&await q(n.body,r);return i.$metadata=this.deserializeMetadata(n),i}async deserializeHttpMessage(e,r,n,o,s){let i;o instanceof Set?i=s:i=o;let a=!0,c=this.deserializer,f=T.of(e),u=[];for(let[l,d]of f.structIterator()){let h=d.getMemberTraits();if(h.httpPayload){if(a=!1,d.isStreaming())d.isStructSchema()?i[l]=await this.deserializeEventStream({response:n,responseSchema:f}):i[l]=Qt(n.body);else if(n.body){let g=await q(n.body,r);g.byteLength>0&&(i[l]=await c.read(d,g))}}else if(h.httpHeader){let p=String(h.httpHeader).toLowerCase(),g=n.headers[p];if(g!=null)if(d.isListSchema()){let y=d.getValueSchema();y.getMergedTraits().httpHeader=p;let S;y.isTimestampSchema()&&y.getSchema()===4?S=Rt(g,",",2):S=Re(g);let b=[];for(let E of S)b.push(await c.read(y,E.trim()));i[l]=b}else i[l]=await c.read(d,g)}else if(h.httpPrefixHeaders!==void 0){i[l]={};for(let p in n.headers)if(p.startsWith(h.httpPrefixHeaders)){let g=n.headers[p],y=d.getValueSchema();y.getMergedTraits().httpHeader=p,i[l][p.slice(h.httpPrefixHeaders.length)]=await c.read(y,g)}}else h.httpResponseCode?i[l]=n.statusCode:u.push(l)}return u.discardResponseBody=a,u}}});var or,ma=m(()=>{X();N();rr();Xt();or=class extends me{async serializeRequest(e,r,n){let o=this.serializer,s={},i={},a=await n.endpoint(),c=T.of(e?.input),f=c.getSchema(),u,l=r&&typeof r=="object"?r:{},d=new P({protocol:"",hostname:"",port:void 0,path:"/",fragment:void 0,query:s,headers:i,body:void 0});if(a&&(this.updateServiceEndpoint(d,a),this.setHostPrefix(d,e,l)),l){let h=c.getEventStreamMember();if(h){if(l[h]){let p={};for(let[g,y]of c.structIterator())g!==h&&l[g]&&(o.write(y,l[g]),p[g]=o.flush());u=await this.serializeEventStream({eventStream:l[h],requestSchema:c,initialRequest:p})}}else o.write(f,l),u=o.flush()}return d.headers=Object.assign(d.headers,i),d.query=s,d.body=u,d.method="POST",d}async deserializeResponse(e,r,n){let o=this.deserializer,s=T.of(e.output),i={};if(n.statusCode>=300){let c=await q(n.body,r);throw c.byteLength>0&&Object.assign(i,await o.read(15,c)),await this.handleError(e,r,n,i,this.deserializeMetadata(n)),new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.")}for(let c in n.headers){let f=n.headers[c];delete n.headers[c],n.headers[c.toLowerCase()]=f}let a=s.getEventStreamMember();if(a)i[a]=await this.deserializeEventStream({response:n,responseSchema:s,initialResponseContainer:i});else{let c=await q(n.body,r);c.byteLength>0&&Object.assign(i,await o.read(s,c))}return i.$metadata=this.deserializeMetadata(n),i}}});var sr,Bn=m(()=>{Zt();sr=(t,e,r,n,o,s)=>{if(e!=null&&e[r]!==void 0){let i=n();if(i==null||i.length<=0)throw new Error("Empty value provided for input HTTP label: "+r+".");t=t.replace(o,s?i.split("/").map(a=>ae(a)).join("/"):ae(i))}else throw new Error("No value provided for input HTTP label: "+r+".");return t}});function ua(t,e){return new ct(t,e)}var ct,da=m(()=>{N();Bn();ct=class{input;context;query={};method="";headers={};path="";body=null;hostname="";resolvePathStack=[];constructor(e,r){this.input=e,this.context=r}async build(){let{hostname:e,protocol:r="https",port:n,path:o}=await this.context.endpoint();this.path=o;for(let s of this.resolvePathStack)s(this.path);return new P({protocol:r,hostname:this.hostname||e,port:n,method:this.method,path:this.path,query:this.query,body:this.body,headers:this.headers})}hn(e){return this.hostname=e,this}bp(e){return this.resolvePathStack.push(r=>{this.path=`${r?.endsWith("/")?r.slice(0,-1):r||""}`+e}),this}p(e,r,n,o){return this.resolvePathStack.push(s=>{this.path=sr(s,this.input,e,r,n,o)}),this}h(e){return this.headers=e,this}q(e){return this.query=e,this}b(e){return this.body=e,this}m(e){return this.method=e,this}}});function je(t,e){if(e.timestampFormat.useTrait&&t.isTimestampSchema()&&(t.getSchema()===5||t.getSchema()===6||t.getSchema()===7))return t.getSchema();let{httpLabel:r,httpPrefixHeaders:n,httpHeader:o,httpQuery:s}=t.getMergedTraits();return(e.httpBindings?typeof n=="string"||o?6:s||r?5:void 0:void 0)??e.timestampFormat.default}var ir=m(()=>{});var Ve,Ln=m(()=>{X();G();De();ir();Ve=class extends D{settings;constructor(e){super(),this.settings=e}read(e,r){let n=T.of(e);if(n.isListSchema())return Re(r).map(o=>this.read(n.getValueSchema(),o));if(n.isBlobSchema())return(this.serdeContext?.base64Decoder??Ee)(r);if(n.isTimestampSchema())switch(je(n,this.settings)){case 5:return At(r);case 6:return vt(r);case 7:return It(r);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",r),new Date(r)}if(n.isStringSchema()){let o=n.getMergedTraits().mediaType,s=r;if(o)return n.getMergedTraits().httpHeader&&(s=this.base64ToUtf8(s)),(o==="application/json"||o.endsWith("+json"))&&(s=k.from(s)),s}return n.isNumericSchema()?Number(r):n.isBigIntegerSchema()?BigInt(r):n.isBigDecimalSchema()?new le(r,"bigDecimal"):n.isBooleanSchema()?String(r).toLowerCase()==="true":r}base64ToUtf8(e){return(this.serdeContext?.utf8Encoder??W)((this.serdeContext?.base64Decoder??Ee)(e))}}});var ar,la=m(()=>{X();G();De();Ln();ar=class extends D{codecDeserializer;stringDeserializer;constructor(e,r){super(),this.codecDeserializer=e,this.stringDeserializer=new Ve(r)}setSerdeContext(e){this.stringDeserializer.setSerdeContext(e),this.codecDeserializer.setSerdeContext(e),this.serdeContext=e}read(e,r){let n=T.of(e),o=n.getMergedTraits(),s=this.serdeContext?.utf8Encoder??W;if(o.httpHeader||o.httpResponseCode)return this.stringDeserializer.read(n,s(r));if(o.httpPayload){if(n.isBlobSchema()){let i=this.serdeContext?.utf8Decoder??$;return typeof r=="string"?i(r):r}else if(n.isStringSchema())return"byteLength"in r?s(r):r}return this.codecDeserializer.read(n,r)}}});var Ge,Fn=m(()=>{X();G();De();ir();Ge=class extends D{settings;stringBuffer="";constructor(e){super(),this.settings=e}write(e,r){let n=T.of(e);switch(typeof r){case"object":if(r===null){this.stringBuffer="null";return}if(n.isTimestampSchema()){if(!(r instanceof Date))throw new Error(`@smithy/core/protocols - received non-Date value ${r} when schema expected Date in ${n.getName(!0)}`);switch(je(n,this.settings)){case 5:this.stringBuffer=r.toISOString().replace(".000Z","Z");break;case 6:this.stringBuffer=Tt(r);break;case 7:this.stringBuffer=String(r.getTime()/1e3);break;default:console.warn("Missing timestamp format, using epoch seconds",r),this.stringBuffer=String(r.getTime()/1e3)}return}if(n.isBlobSchema()&&"byteLength"in r){this.stringBuffer=(this.serdeContext?.base64Encoder??ne)(r);return}if(n.isListSchema()&&Array.isArray(r)){let i="";for(let a of r){this.write([n.getValueSchema(),n.getMergedTraits()],a);let c=this.flush(),f=n.getValueSchema().isTimestampSchema()?c:Ct(c);i!==""&&(i+=", "),i+=f}this.stringBuffer=i;return}this.stringBuffer=JSON.stringify(r,null,2);break;case"string":let o=n.getMergedTraits().mediaType,s=r;if(o&&((o==="application/json"||o.endsWith("+json"))&&(s=k.from(s)),n.getMergedTraits().httpHeader)){this.stringBuffer=(this.serdeContext?.base64Encoder??ne)(s.toString());return}this.stringBuffer=r;break;default:n.isIdempotencyToken()?this.stringBuffer=Cn():this.stringBuffer=String(r)}}flush(){let e=this.stringBuffer;return this.stringBuffer="",e}}});var cr,ha=m(()=>{X();Fn();cr=class{codecSerializer;stringSerializer;buffer;constructor(e,r,n=new Ge(r)){this.codecSerializer=e,this.stringSerializer=n}setSerdeContext(e){this.codecSerializer.setSerdeContext(e),this.stringSerializer.setSerdeContext(e)}write(e,r){let n=T.of(e),o=n.getMergedTraits();if(o.httpHeader||o.httpLabel||o.httpQuery){this.stringSerializer.write(n,r),this.buffer=this.stringSerializer.flush();return}return this.codecSerializer.write(n,r)}flush(){if(this.buffer!==void 0){let e=this.buffer;return this.buffer=void 0,e}return this.codecSerializer.flush()}}});var pa,fr,ga=m(()=>{pa=xe(Ze()),fr=class{name;kind;values;constructor({name:e,kind:r=pa.FieldPosition.HEADER,values:n=[]}){this.name=e,this.kind=r,this.values=n}add(e){this.values.push(e)}set(e){this.values=e}remove(e){this.values=this.values.filter(r=>r!==e)}toString(){return this.values.map(e=>e.includes(",")||e.includes(" ")?`"${e}"`:e).join(", ")}get(){return this.values}}});var mr,ya=m(()=>{mr=class{entries={};encoding;constructor({fields:e=[],encoding:r="utf-8"}){e.forEach(this.setField.bind(this)),this.encoding=r}setField(e){this.entries[e.name.toLowerCase()]=e}getField(e){return this.entries[e.toLowerCase()]}removeField(e){delete this.entries[e.toLowerCase()]}getByType(e){return Object.values(this.entries).filter(r=>r.kind===e)}}});var Sa,ba,wa=m(()=>{Sa=t=>({setHttpHandler(e){t.httpHandler=e},httpHandler(){return t.httpHandler},updateHttpClientConfig(e,r){t.httpHandler?.updateHttpClientConfig(e,r)},httpHandlerConfigs(){return t.httpHandler.httpHandlerConfigs()}}),ba=t=>({httpHandler:t.httpHandler()})});function zn(t){return e=>async r=>{let n=r.request;if(P.isInstance(n)){let{body:o,headers:s}=n;if(o&&Object.keys(s).map(i=>i.toLowerCase()).indexOf(xa)===-1)try{let i=t(o);n.headers={...n.headers,[xa]:String(i)}}catch{}}return e({...r,request:n})}}var xa,Hn,Ea,Ta=m(()=>{N();xa="content-length";Hn={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:!0},Ea=t=>({applyToStack:e=>{e.add(zn(t.bodyLengthChecker),Hn)}})});var ue,gf,ur=m(()=>{ue=t=>encodeURIComponent(t).replace(/[!'()*]/g,gf),gf=t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`});var Ca,Ia=m(()=>{ur();Ca=t=>t.split("/").map(ue).join("/")});function Aa(t){let e=[];for(let r of Object.keys(t).sort()){let n=t[r];if(r=ue(r),Array.isArray(n))for(let o=0,s=n.length;o<s;o++)e.push(`${r}=${ue(n[o])}`);else{let o=r;(n||typeof n=="string")&&(o+=`=${ue(n)}`),e.push(o)}}return e.join("&")}var va=m(()=>{ur()});var Ra={};dt(Ra,{Field:()=>fr,Fields:()=>mr,FromStringShapeDeserializer:()=>Ve,HttpBindingProtocol:()=>nr,HttpInterceptingShapeDeserializer:()=>ar,HttpInterceptingShapeSerializer:()=>cr,HttpProtocol:()=>me,HttpRequest:()=>P,HttpResponse:()=>K,RequestBuilder:()=>ct,RpcProtocol:()=>or,SerdeContext:()=>D,ToStringShapeSerializer:()=>Ge,buildQueryString:()=>Aa,collectBody:()=>q,contentLengthMiddleware:()=>zn,contentLengthMiddlewareOptions:()=>Hn,determineTimestampFormat:()=>je,escapeUri:()=>ue,escapeUriPath:()=>Ca,extendedEncodeURIComponent:()=>ae,getContentLengthPlugin:()=>Ea,getHttpHandlerExtensionConfiguration:()=>Sa,isValidHostname:()=>Ye,parseQueryString:()=>tt,parseUrl:()=>he,requestBuilder:()=>ua,resolveHttpHandlerRuntimeConfig:()=>ba,resolvedPath:()=>sr});var Na=m(()=>{Xt();Zt();fa();rr();ma();da();Bn();Ln();la();ha();Fn();ir();De();ga();ya();N();N();N();wa();Ta();ur();Ia();va();N();N()});var La=Qn(mt=>{var{buildQueryString:Da,HttpResponse:_a}=(Na(),Sr(Ra)),dr=require("node:https"),{Readable:yf}=require("node:stream"),jn=require("node:http2"),{streamCollector:Sf}=(G(),Sr(Fi));mt.streamCollector=Sf;function hr(t){let e=t&&typeof t=="object"&&"reason"in t?t.reason:void 0;if(e){if(e instanceof Error){let o=new Error("Request aborted");return o.name="AbortError",o.cause=e,o}let n=new Error(String(e));return n.name="AbortError",n}let r=new Error("Request aborted");return r.name="AbortError",r}var bf=["ECONNRESET","EPIPE","ETIMEDOUT"],$a=t=>{let e={};for(let r in t){let n=t[r];e[r]=Array.isArray(n)?n.join(","):n}return e},A={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},Oa=1e3,wf=(t,e,r=0)=>{if(!r)return-1;let n=o=>{let s=A.setTimeout(()=>{t.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${r} ms.`),{name:"TimeoutError"}))},r-o),i=a=>{a?.connecting?a.on("connect",()=>{A.clearTimeout(s)}):A.clearTimeout(s)};t.socket?i(t.socket):t.on("socket",i)};return r<2e3?(n(0),0):A.setTimeout(n.bind(null,Oa),Oa)},xf=(t,e,r=0,n,o)=>r?A.setTimeout(()=>{let s=`@smithy/node-http-handler - [${n?"ERROR":"WARN"}] a request has exceeded the configured ${r} ms requestTimeout.`;if(n){let i=Object.assign(new Error(s),{name:"TimeoutError",code:"ETIMEDOUT"});t.destroy(i),e(i)}else s+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",o?.warn?.(s)},r):-1,Ef=3e3,Tf=(t,{keepAlive:e,keepAliveMsecs:r},n=Ef)=>{if(e!==!0)return-1;let o=()=>{t.socket?t.socket.setKeepAlive(e,r||0):t.on("socket",s=>{s.setKeepAlive(e,r||0)})};return n===0?(o(),0):A.setTimeout(o,n)},Ma=3e3,Cf=(t,e,r=0)=>{let n=o=>{let s=r-o,i=()=>{t.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${r} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))};t.socket?(t.socket.setTimeout(s,i),t.on("close",()=>t.socket?.removeListener("timeout",i))):t.setTimeout(s,i)};return 0<r&&r<6e3?(n(0),0):A.setTimeout(n.bind(null,r===0?0:Ma),Ma)},Pa=6e3;async function Ba(t,e,r=Pa,n=!1){let o=e.headers,s=o?o.Expect||o.expect:void 0,i=-1,a=!0;!n&&s==="100-continue"&&(a=await Promise.race([new Promise(c=>{i=Number(A.setTimeout(()=>c(!0),Math.max(Pa,r)))}),new Promise(c=>{t.on("continue",()=>{A.clearTimeout(i),c(!0)}),t.on("response",()=>{A.clearTimeout(i),c(!1)}),t.on("error",()=>{A.clearTimeout(i),c(!1)})})])),a&&If(t,e.body)}function If(t,e){if(e instanceof yf){e.pipe(t);return}if(e){let r=Buffer.isBuffer(e);if(r||typeof e=="string"){r&&e.byteLength===0?t.end():t.end(e);return}let o=e;if(typeof o=="object"&&o.buffer&&typeof o.byteOffset=="number"&&typeof o.byteLength=="number"){t.end(Buffer.from(o.buffer,o.byteOffset,o.byteLength));return}t.end(Buffer.from(e));return}t.end()}var Af=0,lr,ka,Vn=class t{config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(e){return typeof e?.handle=="function"?e:new t(e)}static checkSocketUsage(e,r,n=console){let{sockets:o,requests:s,maxSockets:i}=e;if(typeof i!="number"||i===1/0||Date.now()-15e3<r)return r;if(o&&s)for(let c in o){let f=o[c]?.length??0,u=s[c]?.length??0;if(f>=i&&u>=2*i)return n?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${f} and ${u} additional requests are enqueued.
|
|
7
|
+
`)}u.close()}else u.enqueue(`${(n(d)||0).toString(16)}\r
|
|
8
|
+
${d}\r
|
|
9
|
+
`)}})}});function Si(t,e){let r=t,n=t;if(I(n))return pi(n,e);let{base64Encoder:o,bodyLengthChecker:s,checksumAlgorithmFn:i,checksumLocationName:a,streamHasher:c}=e,f=o!==void 0&&i!==void 0&&a!==void 0&&c!==void 0,u=f?c(i,r):void 0,d=new yi.Readable({read:()=>{}});return r.on("data",l=>{let h=s(l)||0;h!==0&&(d.push(`${h.toString(16)}\r
|
|
10
|
+
`),d.push(l),d.push(`\r
|
|
11
|
+
`))}),r.on("end",async()=>{if(d.push(`0\r
|
|
12
|
+
`),f){let l=o(await u);d.push(`${a}:${l}\r
|
|
13
|
+
`),d.push(`\r
|
|
14
|
+
`)}d.push(null)}),d}var yi,bi=m(()=>{yi=require("node:stream");gi();F()});async function wi(t,e){let r=0,n=[],o=t.getReader(),s=!1;for(;!s;){let{done:c,value:f}=await o.read();if(f&&(n.push(f),r+=f?.byteLength??0),r>=e)break;s=c}o.releaseLock();let i=new Uint8Array(Math.min(e,r)),a=0;for(let c of n){if(c.byteLength>i.byteLength-a){i.set(c.subarray(0,i.byteLength-a),a);break}else i.set(c,a);a+=c.length}return i}var xi=m(()=>{});var Ei,Ti,yn,Ci=m(()=>{Ei=require("node:stream");Qe();xi();F();Ti=(t,e)=>I(t)?wi(t,e):new Promise((r,n)=>{let o=new yn;o.limit=e,t.pipe(o),t.on("error",s=>{o.end(),n(s)}),o.on("error",n),o.on("finish",function(){let s=se(this.buffers);r(s)})}),yn=class extends Ei.Writable{buffers=[];limit=1/0;bytesBuffered=0;_write(e,r,n){if(this.buffers.push(e),this.bytesBuffered+=e.byteLength??0,this.bytesBuffered>=this.limit){let o=this.bytesBuffered-this.limit,s=this.buffers[this.buffers.length-1];this.buffers[this.buffers.length-1]=s.subarray(0,s.byteLength-o),this.emit("finish")}n()}}});var Ii,Ai=m(()=>{Ii=t=>{if(typeof t=="string")return t;if(typeof t!="object"||typeof t.byteOffset!="number"||typeof t.byteLength!="number")throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return new TextDecoder("utf-8").decode(t)}});async function Sn(t){return t.arrayBuffer().then(e=>new Uint8Array(e))}async function bn(t){let e=[],r=t.getReader(),n=0;for(;;){let{done:o,value:s}=await r.read();if(s&&(e.push(s),n+=s.length),o)break}return se(e,n)}var vi,wn=m(()=>{Qe();F();vi=async t=>ie(t)?Sn(t):bn(t)});var Ri,Oi,Ni,Mi=m(()=>{dn();Mr();Ai();wn();F();Ri="The stream has already been transformed.",Oi=t=>{if(!Ni(t)&&!I(t)){let o=t?.__proto__?.constructor?.name||t;throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${o}`)}let e=!1,r=async()=>{if(e)throw new Error(Ri);return e=!0,await vi(t)},n=o=>{if(typeof o.stream!="function")throw new Error(`Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.
|
|
15
|
+
If you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body`);return o.stream()};return Object.assign(t,{transformToByteArray:r,transformToString:async o=>{let s=await r();if(o==="base64")return qt(s);if(o==="hex")return D(s);if(o===void 0||o==="utf8"||o==="utf-8")return Ii(s);if(typeof TextDecoder=="function")return new TextDecoder(o).decode(s);throw new Error("TextDecoder is not available, please make sure polyfill is provided.")},transformToWebStream:()=>{if(e)throw new Error(Ri);if(e=!0,Ni(t))return n(t);if(I(t))return t;throw new Error(`Cannot transform payload to web stream, got ${t}`)}})},Ni=t=>typeof Blob=="function"&&t instanceof Blob});var Pi,Jt,xn,En=m(()=>{Pi=require("node:stream");Qe();wn();F();Jt=t=>ie(t)?Sn(t):I(t)?bn(t):new Promise((e,r)=>{let n=new xn,o=t;o.pipe(n),o.on("error",s=>{n.end(),r(s)}),n.on("error",r),n.on("finish",function(){let s=se(this.bufferedBytes);e(s)})}),xn=class extends Pi.Writable{bufferedBytes=[];_write(e,r,n){this.bufferedBytes.push(e),n()}}});var Kt,ki,Qt,Ui=m(()=>{Kt=require("node:stream");re();Mi();En();ki="The stream has already been transformed.",Qt=t=>{if(!(t instanceof Kt.Readable))try{return Oi(t)}catch{let o=t?.__proto__?.constructor?.name||t;throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${o}`)}let e=!1,r=async()=>{if(e)throw new Error(ki);return e=!0,await Jt(t)};return Object.assign(t,{transformToByteArray:r,transformToString:async n=>{let o=await r();return n===void 0||Buffer.isEncoding(n)?$(o.buffer,o.byteOffset,o.byteLength).toString(n):new TextDecoder(n).decode(o)},transformToWebStream:()=>{if(e)throw new Error(ki);if(t.readableFlowing!==null)throw new Error("The stream has been consumed by other callbacks.");if(typeof Kt.Readable.toWeb!="function")throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");return e=!0,Kt.Readable.toWeb(t)}})}});async function Di(t){return typeof t.stream=="function"&&(t=t.stream()),t.tee()}var _i=m(()=>{});async function $i(t){if(I(t)||ie(t))return Di(t);let e=new Tn.PassThrough,r=new Tn.PassThrough;return t.pipe(e),t.pipe(r),[e,r]}var Tn,Bi=m(()=>{Tn=require("node:stream");_i();F()});var zi={};lt(zi,{ChecksumStream:()=>Ue,Hash:()=>jt,LazyJsonString:()=>U,NumericValue:()=>de,Uint8ArrayBlobAdapter:()=>Se,_parseEpochTimestamp:()=>It,_parseRfc3339DateTimeWithOffset:()=>At,_parseRfc7231DateTime:()=>vt,calculateBodyLength:()=>$o,concatBytes:()=>se,copyDocumentWithTransform:()=>so,createBufferedReadable:()=>di,createChecksumStream:()=>ci,dateToUtcString:()=>Tt,deserializerMiddleware:()=>Mt,deserializerMiddlewareOption:()=>fn,expectBoolean:()=>co,expectByte:()=>St,expectFloat32:()=>We,expectInt:()=>fo,expectInt32:()=>gt,expectLong:()=>Ce,expectNonNull:()=>mo,expectNumber:()=>Te,expectObject:()=>Er,expectShort:()=>yt,expectString:()=>uo,expectUnion:()=>lo,fromArrayBuffer:()=>$,fromBase64:()=>Ee,fromHex:()=>Nt,fromString:()=>te,fromUtf8:()=>B,generateIdempotencyToken:()=>Cn,getAwsChunkedEncodingStream:()=>Si,getSerdePlugin:()=>Js,handleFloat:()=>po,headStream:()=>Ti,isArrayBuffer:()=>dt,isBlob:()=>ie,isReadableStream:()=>I,limitedParseDouble:()=>xt,limitedParseFloat:()=>go,limitedParseFloat32:()=>yo,logger:()=>Ie,nv:()=>Uo,parseBoolean:()=>ao,parseEpochTimestamp:()=>Co,parseRfc3339DateTime:()=>xo,parseRfc3339DateTimeWithOffset:()=>Eo,parseRfc7231DateTime:()=>To,quoteHeader:()=>Ct,sdkStreamMixin:()=>Qt,serializerMiddleware:()=>Ht,serializerMiddlewareOption:()=>mn,splitEvery:()=>Rt,splitHeader:()=>Re,splitStream:()=>$i,streamCollector:()=>Jt,strictParseByte:()=>Et,strictParseDouble:()=>Je,strictParseFloat:()=>ho,strictParseFloat32:()=>wt,strictParseInt:()=>bo,strictParseInt32:()=>wo,strictParseLong:()=>Tr,strictParseShort:()=>oe,toBase64:()=>ne,toHex:()=>D,toUint8Array:()=>Ot,toUtf8:()=>W,v4:()=>Fi});var Li,Se,of,Fi,Cn,G=m(()=>{Li=require("node:crypto");Yn();wr();to();ht();ro();oo();io();Io();Ao();Cr();vo();Oo();Mo();Po();Do();Mr();Bo();Pr();Qe();re();br();Vr();Ks();cn();Xs();un();fi();hi();bi();Ci();Ui();Bi();F();En();Se=class extends eo(W,B,ne,Ee){},of=Li.getRandomValues,Fi=no(of),Cn=Fi});var q,Xt=m(()=>{G();q=async(t=new Uint8Array,e)=>{if(t instanceof Uint8Array)return Se.mutate(t);if(!t)return Se.mutate(new Uint8Array);let r=e.streamCollector(t);return Se.mutate(await r)}});function ae(t){return encodeURIComponent(t).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}var Zt=m(()=>{});var _,De=m(()=>{_=class{serdeContext;setSerdeContext(e){this.serdeContext=e}}});var Hi,In,Yt,ji=m(()=>{Hi=new Uint32Array(256);for(let t=0;t<256;++t){let e=t;for(let r=0;r<8;++r)e=e&1?3988292384^e>>>1:e>>>1;Hi[t]=e>>>0}In=4294967295,Yt=class{digestLength=4;checksum=In;update(e){for(let r=0;r<e.length;++r)this.checksum=this.checksum>>>8^Hi[(this.checksum^e[r])&255]}digestSync(){return(this.checksum^In)>>>0}async digest(){let e=this.digestSync(),r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e,!1),r}reset(){this.checksum=In}}});function sf(t){return class{digestLength=4;value=0;update(r){this.value=t(r,this.value)}digestSync(){return this.value>>>0}async digest(){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,this.digestSync(),!1),r}reset(){this.value=0}}}var An,Vi,_e,Gi=m(()=>{An=xe(require("node:zlib"));ji();Vi=typeof An.crc32=="function"?An.crc32:void 0,_e=Vi?sf(Vi):Yt});var vn=m(()=>{Gi()});function qi(t){for(let e=0;e<8;e++)t[e]^=255;for(let e=7;e>-1&&(t[e]++,t[e]===0);e--);}var ce,Rn=m(()=>{G();ce=class t{bytes;constructor(e){if(this.bytes=e,e.byteLength!==8)throw new Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(e){if(e>9223372036854776e3||e<-9223372036854776e3)throw new Error(`${e} is too large (or, if negative, too small) to represent as an Int64`);let r=new Uint8Array(8);for(let n=7,o=Math.abs(Math.round(e));n>-1&&o>0;n--,o/=256)r[n]=o;return e<0&&qi(r),new t(r)}valueOf(){let e=this.bytes.slice(0),r=e[0]&128;return r&&qi(e),parseInt(D(e),16)*(r?-1:1)}toString(){return String(this.valueOf())}}});var $e,C,Wi,af,cf,ff,mf,uf,lf,df,hf,pf,Nn=m(()=>{G();Rn();$e=class{toUtf8;fromUtf8;constructor(e,r){this.toUtf8=e,this.fromUtf8=r}format(e){let r=[];for(let s of Object.keys(e)){let i=this.fromUtf8(s);r.push(Uint8Array.from([i.byteLength]),i,this.formatHeaderValue(e[s]))}let n=new Uint8Array(r.reduce((s,i)=>s+i.byteLength,0)),o=0;for(let s of r)n.set(s,o),o+=s.byteLength;return n}formatHeaderValue(e){switch(e.type){case"boolean":return Uint8Array.from([e.value?C.boolTrue:C.boolFalse]);case"byte":return Uint8Array.from([C.byte,e.value]);case"short":let r=new DataView(new ArrayBuffer(3));return r.setUint8(0,C.short),r.setInt16(1,e.value,!1),new Uint8Array(r.buffer);case"integer":let n=new DataView(new ArrayBuffer(5));return n.setUint8(0,C.integer),n.setInt32(1,e.value,!1),new Uint8Array(n.buffer);case"long":let o=new Uint8Array(9);return o[0]=C.long,o.set(e.value.bytes,1),o;case"binary":let s=new DataView(new ArrayBuffer(3+e.value.byteLength));s.setUint8(0,C.byteArray),s.setUint16(1,e.value.byteLength,!1);let i=new Uint8Array(s.buffer);return i.set(e.value,3),i;case"string":let a=this.fromUtf8(e.value),c=new DataView(new ArrayBuffer(3+a.byteLength));c.setUint8(0,C.string),c.setUint16(1,a.byteLength,!1);let f=new Uint8Array(c.buffer);return f.set(a,3),f;case"timestamp":let u=new Uint8Array(9);return u[0]=C.timestamp,u.set(ce.fromNumber(e.value.valueOf()).bytes,1),u;case"uuid":if(!pf.test(e.value))throw new Error(`Invalid UUID received: ${e.value}`);let d=new Uint8Array(17);return d[0]=C.uuid,d.set(Nt(e.value.replace(/-/g,"")),1),d}}parse(e){let r={},n=0;for(;n<e.byteLength;){let o=e.getUint8(n++),s=this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,o));switch(n+=o,e.getUint8(n++)){case C.boolTrue:r[s]={type:Wi,value:!0};break;case C.boolFalse:r[s]={type:Wi,value:!1};break;case C.byte:r[s]={type:af,value:e.getInt8(n++)};break;case C.short:r[s]={type:cf,value:e.getInt16(n,!1)},n+=2;break;case C.integer:r[s]={type:ff,value:e.getInt32(n,!1)},n+=4;break;case C.long:r[s]={type:mf,value:new ce(new Uint8Array(e.buffer,e.byteOffset+n,8))},n+=8;break;case C.byteArray:let i=e.getUint16(n,!1);n+=2,r[s]={type:uf,value:new Uint8Array(e.buffer,e.byteOffset+n,i)},n+=i;break;case C.string:let a=e.getUint16(n,!1);n+=2,r[s]={type:lf,value:this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,a))},n+=a;break;case C.timestamp:r[s]={type:df,value:new Date(new ce(new Uint8Array(e.buffer,e.byteOffset+n,8)).valueOf())},n+=8;break;case C.uuid:let c=new Uint8Array(e.buffer,e.byteOffset+n,16);n+=16,r[s]={type:hf,value:`${D(c.subarray(0,4))}-${D(c.subarray(4,6))}-${D(c.subarray(6,8))}-${D(c.subarray(8,10))}-${D(c.subarray(10))}`};break;default:throw new Error("Unrecognized header type tag")}}return r}};(function(t){t[t.boolTrue=0]="boolTrue",t[t.boolFalse=1]="boolFalse",t[t.byte=2]="byte",t[t.short=3]="short",t[t.integer=4]="integer",t[t.long=5]="long",t[t.byteArray=6]="byteArray",t[t.string=7]="string",t[t.timestamp=8]="timestamp",t[t.uuid=9]="uuid"})(C||(C={}));Wi="boolean",af="byte",cf="short",ff="integer",mf="long",uf="binary",lf="string",df="timestamp",hf="uuid",pf=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/});function Ki({byteLength:t,byteOffset:e,buffer:r}){if(t<gf)throw new Error("Provided message too short to accommodate event stream message overhead");let n=new DataView(r,e,t),o=n.getUint32(0,!1);if(t!==o)throw new Error("Reported message length does not match received message length");let s=n.getUint32(Ji,!1),i=n.getUint32(fe,!1),a=n.getUint32(t-be,!1),c=new _e;if(c.update(new Uint8Array(r,e,fe)),i!==c.digestSync())throw new Error(`The prelude checksum specified in the message (${i}) does not match the calculated CRC32 checksum (${c.digestSync()})`);if(c.update(new Uint8Array(r,e+fe,t-(fe+be))),a!==c.digestSync())throw new Error(`The message checksum (${c.digestSync()}) did not match the expected value of ${a}`);return{headers:new DataView(r,e+fe+be,s),body:new Uint8Array(r,e+fe+be+s,o-s-(fe+be+be))}}var Ji,fe,be,gf,Qi=m(()=>{vn();Ji=4,fe=Ji*2,be=4,gf=fe+be*2});var Be,On=m(()=>{vn();Nn();Qi();Be=class{headerMarshaller;messageBuffer;isEndOfStream;constructor(e,r){this.headerMarshaller=new $e(e,r),this.messageBuffer=[],this.isEndOfStream=!1}feed(e){this.messageBuffer.push(this.decode(e))}endOfStream(){this.isEndOfStream=!0}getMessage(){let e=this.messageBuffer.pop(),r=this.isEndOfStream;return{getMessage(){return e},isEndOfStream(){return r}}}getAvailableMessages(){let e=this.messageBuffer;this.messageBuffer=[];let r=this.isEndOfStream;return{getMessages(){return e},isEndOfStream(){return r}}}encode({headers:e,body:r}){let n=this.headerMarshaller.format(e),o=n.byteLength+r.byteLength+16,s=new Uint8Array(o),i=new DataView(s.buffer,s.byteOffset,s.byteLength),a=new _e;return i.setUint32(0,o,!1),i.setUint32(4,n.byteLength,!1),a.update(s.subarray(0,8)),i.setUint32(8,a.digestSync(),!1),s.set(n,12),s.set(r,n.byteLength+12),a.update(s.subarray(8,o-4)),i.setUint32(o-4,a.digestSync(),!1),s}decode(e){let{headers:r,body:n}=Ki(e);return{headers:this.headerMarshaller.parse(r),body:n}}formatHeaders(e){return this.headerMarshaller.format(e)}}});var Le,Mn=m(()=>{Le=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.inputStream)yield this.options.decoder.decode(e)}}});var Fe,Pn=m(()=>{Fe=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.messageStream)yield this.options.encoder.encode(e);this.options.includeEndFrame&&(yield new Uint8Array(0))}}});var ze,kn=m(()=>{ze=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.messageStream){let r=await this.options.deserializer(e);r!==void 0&&(yield r)}}}});var He,Un=m(()=>{He=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.inputStream)yield this.options.serializer(e)}}});function er(t){let e=0,r=0,n=null,o=null,s=a=>{if(typeof a!="number")throw new Error("Attempted to allocate an event message where size was not a number: "+a);e=a,r=4,n=new Uint8Array(a),new DataView(n.buffer).setUint32(0,a,!1)},i=async function*(){let a=t[Symbol.asyncIterator]();for(;;){let{value:c,done:f}=await a.next();if(f){if(e)if(e===r)yield n;else throw new Error("Truncated event message received.");else return;return}let u=c.length,d=0;for(;d<u;){if(!n){let h=u-d;o||(o=new Uint8Array(4));let p=Math.min(4-r,h);if(o.set(c.slice(d,d+p),r),r+=p,d+=p,r<4)break;s(new DataView(o.buffer).getUint32(0,!1)),o=null}let l=Math.min(e-r,u-d);n.set(c.slice(d,d+l),r),r+=l,d+=l,e&&e===r&&(yield n,n=null,e=0,r=0)}}};return{[Symbol.asyncIterator]:i}}var Dn=m(()=>{});function Xi(t,e){let r=it(e.deserializer,e.toUtf8);return{[Symbol.asyncIterator]:async function*(){for await(let n of t){let o=e.eventStreamCodec.decode(n),s=await r(o);s!==void 0&&(yield s)}}}}function it(t,e){return async function(r){let{value:n}=r.headers[":message-type"];if(n==="error"){let o=new Error(r.headers[":error-message"].value||"UnknownError");throw o.name=r.headers[":error-code"].value,o}else if(n==="exception"){let o=r.headers[":exception-type"].value,s={[o]:r},i=await t(s);if(i.$unknown){let a=new Error(e(r.body));throw a.name=o,a}throw i[o]}else if(n==="event"){let o={[r.headers[":event-type"].value]:r},s=await t(o);return s.$unknown?void 0:s}else throw Error(`Unrecognizable event type: ${r.headers[":event-type"].value}`)}}var _n=m(()=>{});var we,Zi,$n=m(()=>{On();Mn();Pn();kn();Un();Dn();_n();we=class{eventStreamCodec;utfEncoder;constructor({utf8Encoder:e,utf8Decoder:r}){this.eventStreamCodec=new Be(e,r),this.utfEncoder=e}deserialize(e,r){let n=er(e);return new ze({messageStream:new Le({inputStream:n,decoder:this.eventStreamCodec}),deserializer:it(r,this.utfEncoder)})}serialize(e,r){return new Fe({messageStream:new He({inputStream:e,serializer:r}),encoder:this.eventStreamCodec,includeEndFrame:!0})}},Zi=t=>new we(t)});async function*yf(t){let e=!1,r=!1,n=new Array;for(t.on("error",o=>{if(e||(e=!0),o)throw o}),t.on("data",o=>{n.push(o)}),t.on("end",()=>{e=!0});!r;){let o=await new Promise(s=>setTimeout(()=>s(n.shift()),0));o&&(yield o),r=e&&n.length===0}}var Yi,at,ea,ta=m(()=>{Yi=require("node:stream");$n();at=class{universalMarshaller;constructor({utf8Encoder:e,utf8Decoder:r}){this.universalMarshaller=new we({utf8Decoder:r,utf8Encoder:e})}deserialize(e,r){let n=typeof e[Symbol.asyncIterator]=="function"?e:yf(e);return this.universalMarshaller.deserialize(n,r)}serialize(e,r){return Yi.Readable.from(this.universalMarshaller.serialize(e,r))}},ea=t=>new at(t)});var ra,na,oa=m(()=>{ra=t=>({[Symbol.asyncIterator]:async function*(){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}}),na=t=>{let e=t[Symbol.asyncIterator]();return new ReadableStream({async pull(r){let{done:n,value:o}=await e.next();if(n)return r.close();r.enqueue(o)}})}});var sa,ia=m(()=>{sa=t=>Object.assign(t,{eventStreamMarshaller:t.eventStreamSerdeProvider(t)})});var tr,aa=m(()=>{X();G();tr=class{marshaller;serializer;deserializer;serdeContext;defaultContentType;compositeErrorRegistry;constructor({marshaller:e,serializer:r,deserializer:n,serdeContext:o,defaultContentType:s,compositeErrorRegistry:i}){this.marshaller=e,this.serializer=r,this.deserializer=n,this.serdeContext=o,this.defaultContentType=s,this.compositeErrorRegistry=i}async serializeEventStream({eventStream:e,requestSchema:r,initialRequest:n}){let o=this.marshaller,s=r.getEventStreamMember(),i=r.getMemberSchema(s),a=this.serializer,c=this.defaultContentType,f=Symbol("initialRequestMarker"),u={async*[Symbol.asyncIterator](){if(n){let d={":event-type":{type:"string",value:"initial-request"},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:c}};a.write(r,n);let l=a.flush();yield{[f]:!0,headers:d,body:l}}for await(let d of e)yield d}};return o.serialize(u,d=>{if(d[f])return{headers:d.headers,body:d.body};let l="";for(let S in d)if(S!=="__type"){l=S;break}let{additionalHeaders:h,body:p,eventType:g,explicitPayloadContentType:y}=this.writeEventBody(l,i,d);return{headers:{":event-type":{type:"string",value:g},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:y??c},...h},body:p}})}async deserializeEventStream({response:e,responseSchema:r,initialResponseContainer:n}){let o=this.marshaller,s=r.getEventStreamMember(),a=r.getMemberSchema(s).getMemberSchemas(),c=Symbol("initialResponseMarker"),f=o.deserialize(e.body,async l=>{let h="";for(let g in l)if(g!=="__type"){h=g;break}let p=l[h].body;if(h==="initial-response"){let g=await this.deserializer.read(r,p);return delete g[s],{[c]:!0,...g}}else if(h in a){let g=a[h];if(g.isStructSchema()){let y={},b=!1;for(let[S,E]of g.structIterator()){let{eventHeader:N,eventPayload:k}=E.getMergedTraits();if(b=b||!!(N||k),k)E.isBlobSchema()?y[S]=p:E.isStringSchema()?y[S]=(this.serdeContext?.utf8Encoder??W)(p):E.isStructSchema()&&(y[S]=await this.deserializer.read(E,p));else if(N){let O=l[h].headers[S]?.value;O!=null&&(E.isNumericSchema()?O&&typeof O=="object"&&"bytes"in O?y[S]=BigInt(O.toString()):y[S]=Number(O):y[S]=O)}}return{[h]:await this.readEventMember(g,p,b,y)}}return{[h]:await this.deserializer.read(g,p)}}else return{$unknown:l}}),u=f[Symbol.asyncIterator](),d=await u.next();if(d.done)return f;if(d.value?.[c]){if(!r)throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");for(let l in d.value)n[l]=d.value[l]}return{async*[Symbol.asyncIterator](){for(d?.value?.[c]||(yield d.value);;){let{done:l,value:h}=await u.next();if(l)break;yield h}}}}async readEventMember(e,r,n,o){let s,i=e.getSchema();if(Array.isArray(i)&&i[0]===-3){let c=i[1],f=pe.for(c);this.compositeErrorRegistry?.copyFrom(f),s=(this.compositeErrorRegistry??f)?.getErrorCtor(i)}let a=n?o:r.byteLength===0?{}:await this.deserializer.read(e,r);if(s){let c=a.message??a.Message??"Unknown",f={},u=e.getMergedTraits().error;return u&&(f.$fault=u),Object.assign(new s({}),f,{message:c},a)}return a}writeEventBody(e,r,n){let o=this.serializer,s=e,i=null,a,c=r.getSchema()[4].includes(e),f={};if(c){let l=r.getMemberSchema(e);if(l.isStructSchema()){for(let[h,p]of l.structIterator()){let{eventHeader:g,eventPayload:y}=p.getMergedTraits();if(y)i=h;else if(g){let b=n[e][h],S="binary";p.isNumericSchema()?(-2)**31<=b&&b<=2**31-1?S="integer":S="long":p.isTimestampSchema()?S="timestamp":p.isStringSchema()?S="string":p.isBooleanSchema()&&(S="boolean"),b!=null&&(f[h]={type:S,value:b},delete n[e][h])}}if(i!==null){let h=l.getMemberSchema(i);h.isBlobSchema()?a="application/octet-stream":h.isStringSchema()&&(a="text/plain"),o.write(h,n[e][i])}else o.write(l,n[e])}else if(l.isUnitSchema())o.write(l,{});else throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.")}else{let[l,h]=n[e];s=l,o.write(15,h)}let u=o.flush()??new Uint8Array;return{body:typeof u=="string"?(this.serdeContext?.utf8Decoder??B)(u):u,eventType:s,explicitPayloadContentType:a,additionalHeaders:f}}}});var ca={};lt(ca,{EventStreamCodec:()=>Be,EventStreamMarshaller:()=>at,EventStreamSerde:()=>tr,HeaderMarshaller:()=>$e,Int64:()=>ce,MessageDecoderStream:()=>Le,MessageEncoderStream:()=>Fe,SmithyMessageDecoderStream:()=>ze,SmithyMessageEncoderStream:()=>He,UniversalEventStreamMarshaller:()=>we,eventStreamSerdeProvider:()=>ea,getChunkedStream:()=>er,getMessageUnmarshaller:()=>it,getUnmarshalledStream:()=>Xi,iterableToReadableStream:()=>na,readableStreamToIterable:()=>ra,resolveEventStreamSerdeConfig:()=>sa,universalEventStreamSerdeProvider:()=>Zi});var fa=m(()=>{On();Nn();Rn();Mn();Pn();kn();Un();ta();oa();$n();Dn();_n();ia();aa()});var me,rr=m(()=>{X();R();De();me=class extends _{options;compositeErrorRegistry;constructor(e){super(),this.options=e,this.compositeErrorRegistry=pe.for(e.defaultNamespace);for(let r of e.errorTypeRegistries??[])this.compositeErrorRegistry.copyFrom(r)}getRequestType(){return P}getResponseType(){return K}setSerdeContext(e){this.serdeContext=e,this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e),this.getPayloadCodec()&&this.getPayloadCodec().setSerdeContext(e)}updateServiceEndpoint(e,r){if("url"in r){e.protocol=r.url.protocol,e.hostname=r.url.hostname,e.port=r.url.port?Number(r.url.port):void 0,e.path=r.url.pathname,e.fragment=r.url.hash||void 0,e.username=r.url.username||void 0,e.password=r.url.password||void 0,e.query||(e.query={});for(let[n,o]of r.url.searchParams.entries())e.query[n]=o;if(r.headers)for(let n in r.headers)e.headers[n]=r.headers[n].join(", ");return e}else{if(e.protocol=r.protocol,e.hostname=r.hostname,e.port=r.port?Number(r.port):void 0,e.path=r.path,e.query={...r.query},r.headers)for(let n in r.headers)e.headers[n]=r.headers[n];return e}}setHostPrefix(e,r,n){if(this.serdeContext?.disableHostPrefix)return;let o=T.of(r.input),s=V(r.traits??{});if(s.endpoint){let i=s.endpoint?.[0];if(typeof i=="string"){for(let[a,c]of o.structIterator()){if(!c.getMergedTraits().hostLabel)continue;let f=n[a];if(typeof f!="string")throw new Error(`@smithy/core/schema - ${a} in input must be a string as hostLabel.`);i=i.replace(`{${a}}`,f)}if(e.hostname=i+e.hostname,!Ye(e.hostname))throw new Error(`[${e.hostname}] is not a valid hostname.`)}}}deserializeMetadata(e){return{httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}}async serializeEventStream({eventStream:e,requestSchema:r,initialRequest:n}){return(await this.loadEventStreamCapability()).serializeEventStream({eventStream:e,requestSchema:r,initialRequest:n})}async deserializeEventStream({response:e,responseSchema:r,initialResponseContainer:n}){return(await this.loadEventStreamCapability()).deserializeEventStream({response:e,responseSchema:r,initialResponseContainer:n})}async loadEventStreamCapability(){let{EventStreamSerde:e,eventStreamSerdeProvider:r}=await Promise.resolve().then(()=>(fa(),ca)),n=this.resolveEventStreamMarshaller(r);return new e({marshaller:n,serializer:this.serializer,deserializer:this.deserializer,serdeContext:this.serdeContext,defaultContentType:this.getDefaultContentType(),compositeErrorRegistry:this.compositeErrorRegistry})}resolveEventStreamMarshaller(e){let r=this.serdeContext;return r.eventStreamMarshaller?r.eventStreamMarshaller:e(this.serdeContext)}getDefaultContentType(){throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`)}async deserializeHttpMessage(e,r,n,o,s){return[]}getEventStreamMarshaller(){let e=this.serdeContext;if(!e.eventStreamMarshaller)throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");return e.eventStreamMarshaller}}});var nr,ma=m(()=>{X();G();R();rr();Xt();Zt();nr=class extends me{async serializeRequest(e,r,n){let o=r&&typeof r=="object"?r:{},s=this.serializer,i={},a={},c=await n.endpoint(),f=T.of(e?.input),u=[],d=[],l=!1,h,p=new P({protocol:"",hostname:"",port:void 0,path:"",fragment:void 0,query:i,headers:a,body:void 0});if(c){this.updateServiceEndpoint(p,c),this.setHostPrefix(p,e,o);let g=V(e.traits);if(g.http){p.method=g.http[0];let[y,b]=g.http[1].split("?");p.path=="/"?p.path=y:p.path+=y;let S=new URLSearchParams(b??"");for(let[E,N]of S)i[E]=N}}for(let[g,y]of f.structIterator()){let b=y.getMergedTraits()??{},S=o[g];if(S==null&&!y.isIdempotencyToken()){if(b.httpLabel&&(p.path.includes(`{${g}+}`)||p.path.includes(`{${g}}`)))throw new Error(`No value provided for input HTTP label: ${g}.`);continue}if(b.httpPayload)y.isStreaming()?y.isStructSchema()?o[g]&&(h=await this.serializeEventStream({eventStream:o[g],requestSchema:f})):h=S:(s.write(y,S),h=s.flush());else if(b.httpLabel){s.write(y,S);let E=s.flush();p.path.includes(`{${g}+}`)?p.path=p.path.replace(`{${g}+}`,E.split("/").map(ae).join("/")):p.path.includes(`{${g}}`)&&(p.path=p.path.replace(`{${g}}`,ae(E)))}else if(b.httpHeader)s.write(y,S),a[b.httpHeader.toLowerCase()]=String(s.flush());else if(typeof b.httpPrefixHeaders=="string")for(let E in S){let N=S[E],k=b.httpPrefixHeaders+E;s.write([y.getValueSchema(),{httpHeader:k}],N),a[k.toLowerCase()]=s.flush()}else b.httpQuery||b.httpQueryParams?this.serializeQuery(y,S,i):(l=!0,u.push(g),d.push(y))}if(l&&o){let[g,y]=(f.getName(!0)??"#Unknown").split("#"),b=f.getSchema()[6],S=[3,g,y,f.getMergedTraits(),u,d,void 0];b?S[6]=b:S.pop(),s.write(S,o),h=s.flush()}return p.headers=a,p.query=i,p.body=h,p}serializeQuery(e,r,n){let o=this.serializer,s=e.getMergedTraits();if(s.httpQueryParams){for(let i in r)if(!(i in n)){let a=r[i],c=e.getValueSchema();Object.assign(c.getMergedTraits(),{...s,httpQuery:i,httpQueryParams:void 0}),this.serializeQuery(c,a,n)}return}if(e.isListSchema()){let i=!!e.getMergedTraits().sparse,a=[];for(let c of r){o.write([e.getValueSchema(),s],c);let f=o.flush();(i||f!==void 0)&&a.push(f)}n[s.httpQuery]=a}else o.write([e,s],r),n[s.httpQuery]=o.flush()}async deserializeResponse(e,r,n){let o=this.deserializer,s=T.of(e.output),i={};if(n.statusCode>=300){let c=await q(n.body,r);throw c.byteLength>0&&Object.assign(i,await o.read(15,c)),await this.handleError(e,r,n,i,this.deserializeMetadata(n)),new Error("@smithy/core/protocols - HTTP Protocol error handler failed to throw.")}for(let c in n.headers){let f=n.headers[c];delete n.headers[c],n.headers[c.toLowerCase()]=f}let a=await this.deserializeHttpMessage(s,r,n,i);if(a.length){let c=await q(n.body,r);if(c.byteLength>0){let f=await o.read(s,c);for(let u of a)f[u]!=null&&(i[u]=f[u])}}else a.discardResponseBody&&await q(n.body,r);return i.$metadata=this.deserializeMetadata(n),i}async deserializeHttpMessage(e,r,n,o,s){let i;o instanceof Set?i=s:i=o;let a=!0,c=this.deserializer,f=T.of(e),u=[];for(let[d,l]of f.structIterator()){let h=l.getMemberTraits();if(h.httpPayload){if(a=!1,l.isStreaming())l.isStructSchema()?i[d]=await this.deserializeEventStream({response:n,responseSchema:f}):i[d]=Qt(n.body);else if(n.body){let g=await q(n.body,r);g.byteLength>0&&(i[d]=await c.read(l,g))}}else if(h.httpHeader){let p=String(h.httpHeader).toLowerCase(),g=n.headers[p];if(g!=null)if(l.isListSchema()){let y=l.getValueSchema();y.getMergedTraits().httpHeader=p;let b;y.isTimestampSchema()&&y.getSchema()===4?b=Rt(g,",",2):b=Re(g);let S=[];for(let E of b)S.push(await c.read(y,E.trim()));i[d]=S}else i[d]=await c.read(l,g)}else if(h.httpPrefixHeaders!==void 0){i[d]={};for(let p in n.headers)if(p.startsWith(h.httpPrefixHeaders)){let g=n.headers[p],y=l.getValueSchema();y.getMergedTraits().httpHeader=p,i[d][p.slice(h.httpPrefixHeaders.length)]=await c.read(y,g)}}else h.httpResponseCode?i[d]=n.statusCode:u.push(d)}return u.discardResponseBody=a,u}}});var or,ua=m(()=>{X();R();rr();Xt();or=class extends me{async serializeRequest(e,r,n){let o=this.serializer,s={},i={},a=await n.endpoint(),c=T.of(e?.input),f=c.getSchema(),u,d=r&&typeof r=="object"?r:{},l=new P({protocol:"",hostname:"",port:void 0,path:"/",fragment:void 0,query:s,headers:i,body:void 0});if(a&&(this.updateServiceEndpoint(l,a),this.setHostPrefix(l,e,d)),d){let h=c.getEventStreamMember();if(h){if(d[h]){let p={};for(let[g,y]of c.structIterator())g!==h&&d[g]&&(o.write(y,d[g]),p[g]=o.flush());u=await this.serializeEventStream({eventStream:d[h],requestSchema:c,initialRequest:p})}}else o.write(f,d),u=o.flush()}return l.headers=Object.assign(l.headers,i),l.query=s,l.body=u,l.method="POST",l}async deserializeResponse(e,r,n){let o=this.deserializer,s=T.of(e.output),i={};if(n.statusCode>=300){let c=await q(n.body,r);throw c.byteLength>0&&Object.assign(i,await o.read(15,c)),await this.handleError(e,r,n,i,this.deserializeMetadata(n)),new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.")}for(let c in n.headers){let f=n.headers[c];delete n.headers[c],n.headers[c.toLowerCase()]=f}let a=s.getEventStreamMember();if(a)i[a]=await this.deserializeEventStream({response:n,responseSchema:s,initialResponseContainer:i});else{let c=await q(n.body,r);c.byteLength>0&&Object.assign(i,await o.read(s,c))}return i.$metadata=this.deserializeMetadata(n),i}}});var sr,Bn=m(()=>{Zt();sr=(t,e,r,n,o,s)=>{if(e!=null&&e[r]!==void 0){let i=n();if(i==null||i.length<=0)throw new Error("Empty value provided for input HTTP label: "+r+".");t=t.replace(o,s?i.split("/").map(a=>ae(a)).join("/"):ae(i))}else throw new Error("No value provided for input HTTP label: "+r+".");return t}});function la(t,e){return new ct(t,e)}var ct,da=m(()=>{R();Bn();ct=class{input;context;query={};method="";headers={};path="";body=null;hostname="";resolvePathStack=[];constructor(e,r){this.input=e,this.context=r}async build(){let{hostname:e,protocol:r="https",port:n,path:o}=await this.context.endpoint();this.path=o;for(let s of this.resolvePathStack)s(this.path);return new P({protocol:r,hostname:this.hostname||e,port:n,method:this.method,path:this.path,query:this.query,body:this.body,headers:this.headers})}hn(e){return this.hostname=e,this}bp(e){return this.resolvePathStack.push(r=>{this.path=`${r?.endsWith("/")?r.slice(0,-1):r||""}`+e}),this}p(e,r,n,o){return this.resolvePathStack.push(s=>{this.path=sr(s,this.input,e,r,n,o)}),this}h(e){return this.headers=e,this}q(e){return this.query=e,this}b(e){return this.body=e,this}m(e){return this.method=e,this}}});function je(t,e){if(e.timestampFormat.useTrait&&t.isTimestampSchema()&&(t.getSchema()===5||t.getSchema()===6||t.getSchema()===7))return t.getSchema();let{httpLabel:r,httpPrefixHeaders:n,httpHeader:o,httpQuery:s}=t.getMergedTraits();return(e.httpBindings?typeof n=="string"||o?6:s||r?5:void 0:void 0)??e.timestampFormat.default}var ir=m(()=>{});var Ve,Ln=m(()=>{X();G();De();ir();Ve=class extends _{settings;constructor(e){super(),this.settings=e}read(e,r){let n=T.of(e);if(n.isListSchema())return Re(r).map(o=>this.read(n.getValueSchema(),o));if(n.isBlobSchema())return(this.serdeContext?.base64Decoder??Ee)(r);if(n.isTimestampSchema())switch(je(n,this.settings)){case 5:return At(r);case 6:return vt(r);case 7:return It(r);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",r),new Date(r)}if(n.isStringSchema()){let o=n.getMergedTraits().mediaType,s=r;if(o)return n.getMergedTraits().httpHeader&&(s=this.base64ToUtf8(s)),(o==="application/json"||o.endsWith("+json"))&&(s=U.from(s)),s}return n.isNumericSchema()?Number(r):n.isBigIntegerSchema()?BigInt(r):n.isBigDecimalSchema()?new de(r,"bigDecimal"):n.isBooleanSchema()?String(r).toLowerCase()==="true":r}base64ToUtf8(e){return(this.serdeContext?.utf8Encoder??W)((this.serdeContext?.base64Decoder??Ee)(e))}}});var ar,ha=m(()=>{X();G();De();Ln();ar=class extends _{codecDeserializer;stringDeserializer;constructor(e,r){super(),this.codecDeserializer=e,this.stringDeserializer=new Ve(r)}setSerdeContext(e){this.stringDeserializer.setSerdeContext(e),this.codecDeserializer.setSerdeContext(e),this.serdeContext=e}read(e,r){let n=T.of(e),o=n.getMergedTraits(),s=this.serdeContext?.utf8Encoder??W;if(o.httpHeader||o.httpResponseCode)return this.stringDeserializer.read(n,s(r));if(o.httpPayload){if(n.isBlobSchema()){let i=this.serdeContext?.utf8Decoder??B;return typeof r=="string"?i(r):r}else if(n.isStringSchema())return"byteLength"in r?s(r):r}return this.codecDeserializer.read(n,r)}}});var Ge,Fn=m(()=>{X();G();De();ir();Ge=class extends _{settings;stringBuffer="";constructor(e){super(),this.settings=e}write(e,r){let n=T.of(e);switch(typeof r){case"object":if(r===null){this.stringBuffer="null";return}if(n.isTimestampSchema()){if(!(r instanceof Date))throw new Error(`@smithy/core/protocols - received non-Date value ${r} when schema expected Date in ${n.getName(!0)}`);switch(je(n,this.settings)){case 5:this.stringBuffer=r.toISOString().replace(".000Z","Z");break;case 6:this.stringBuffer=Tt(r);break;case 7:this.stringBuffer=String(r.getTime()/1e3);break;default:console.warn("Missing timestamp format, using epoch seconds",r),this.stringBuffer=String(r.getTime()/1e3)}return}if(n.isBlobSchema()&&"byteLength"in r){this.stringBuffer=(this.serdeContext?.base64Encoder??ne)(r);return}if(n.isListSchema()&&Array.isArray(r)){let i="";for(let a of r){this.write([n.getValueSchema(),n.getMergedTraits()],a);let c=this.flush(),f=n.getValueSchema().isTimestampSchema()?c:Ct(c);i!==""&&(i+=", "),i+=f}this.stringBuffer=i;return}this.stringBuffer=JSON.stringify(r,null,2);break;case"string":let o=n.getMergedTraits().mediaType,s=r;if(o&&((o==="application/json"||o.endsWith("+json"))&&(s=U.from(s)),n.getMergedTraits().httpHeader)){this.stringBuffer=(this.serdeContext?.base64Encoder??ne)(s.toString());return}this.stringBuffer=r;break;default:n.isIdempotencyToken()?this.stringBuffer=Cn():this.stringBuffer=String(r)}}flush(){let e=this.stringBuffer;return this.stringBuffer="",e}}});var cr,pa=m(()=>{X();Fn();cr=class{codecSerializer;stringSerializer;buffer;constructor(e,r,n=new Ge(r)){this.codecSerializer=e,this.stringSerializer=n}setSerdeContext(e){this.codecSerializer.setSerdeContext(e),this.stringSerializer.setSerdeContext(e)}write(e,r){let n=T.of(e),o=n.getMergedTraits();if(o.httpHeader||o.httpLabel||o.httpQuery){this.stringSerializer.write(n,r),this.buffer=this.stringSerializer.flush();return}return this.codecSerializer.write(n,r)}flush(){if(this.buffer!==void 0){let e=this.buffer;return this.buffer=void 0,e}return this.codecSerializer.flush()}}});var ga,fr,ya=m(()=>{ga=xe(Ze()),fr=class{name;kind;values;constructor({name:e,kind:r=ga.FieldPosition.HEADER,values:n=[]}){this.name=e,this.kind=r,this.values=n}add(e){this.values.push(e)}set(e){this.values=e}remove(e){this.values=this.values.filter(r=>r!==e)}toString(){return this.values.map(e=>e.includes(",")||e.includes(" ")?`"${e}"`:e).join(", ")}get(){return this.values}}});var mr,Sa=m(()=>{mr=class{entries={};encoding;constructor({fields:e=[],encoding:r="utf-8"}){e.forEach(this.setField.bind(this)),this.encoding=r}setField(e){this.entries[e.name.toLowerCase()]=e}getField(e){return this.entries[e.toLowerCase()]}removeField(e){delete this.entries[e.toLowerCase()]}getByType(e){return Object.values(this.entries).filter(r=>r.kind===e)}}});var ba,wa,xa=m(()=>{ba=t=>({setHttpHandler(e){t.httpHandler=e},httpHandler(){return t.httpHandler},updateHttpClientConfig(e,r){t.httpHandler?.updateHttpClientConfig(e,r)},httpHandlerConfigs(){return t.httpHandler.httpHandlerConfigs()}}),wa=t=>({httpHandler:t.httpHandler()})});function zn(t){return e=>async r=>{let n=r.request;if(P.isInstance(n)){let{body:o,headers:s}=n;if(o&&Object.keys(s).map(i=>i.toLowerCase()).indexOf(Ea)===-1)try{let i=t(o);n.headers={...n.headers,[Ea]:String(i)}}catch{}}return e({...r,request:n})}}var Ea,Hn,Ta,Ca=m(()=>{R();Ea="content-length";Hn={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:!0},Ta=t=>({applyToStack:e=>{e.add(zn(t.bodyLengthChecker),Hn)}})});var ue,Sf,ur=m(()=>{ue=t=>encodeURIComponent(t).replace(/[!'()*]/g,Sf),Sf=t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`});var Ia,Aa=m(()=>{ur();Ia=t=>t.split("/").map(ue).join("/")});function va(t){let e=[];for(let r of Object.keys(t).sort()){let n=t[r];if(r=ue(r),Array.isArray(n))for(let o=0,s=n.length;o<s;o++)e.push(`${r}=${ue(n[o])}`);else{let o=r;(n||typeof n=="string")&&(o+=`=${ue(n)}`),e.push(o)}}return e.join("&")}var Ra=m(()=>{ur()});var Na={};lt(Na,{Field:()=>fr,Fields:()=>mr,FromStringShapeDeserializer:()=>Ve,HttpBindingProtocol:()=>nr,HttpInterceptingShapeDeserializer:()=>ar,HttpInterceptingShapeSerializer:()=>cr,HttpProtocol:()=>me,HttpRequest:()=>P,HttpResponse:()=>K,RequestBuilder:()=>ct,RpcProtocol:()=>or,SerdeContext:()=>_,ToStringShapeSerializer:()=>Ge,buildQueryString:()=>va,collectBody:()=>q,contentLengthMiddleware:()=>zn,contentLengthMiddlewareOptions:()=>Hn,determineTimestampFormat:()=>je,escapeUri:()=>ue,escapeUriPath:()=>Ia,extendedEncodeURIComponent:()=>ae,getContentLengthPlugin:()=>Ta,getHttpHandlerExtensionConfiguration:()=>ba,isValidHostname:()=>Ye,parseQueryString:()=>tt,parseUrl:()=>he,requestBuilder:()=>la,resolveHttpHandlerRuntimeConfig:()=>wa,resolvedPath:()=>sr});var Oa=m(()=>{Xt();Zt();ma();rr();ua();da();Bn();Ln();ha();pa();Fn();ir();De();ya();Sa();R();R();R();xa();Ca();ur();Aa();Ra();R();R()});var Fa=Xn(mt=>{var{buildQueryString:_a,HttpResponse:$a}=(Oa(),Sr(Na)),lr=require("node:https"),{Readable:bf}=require("node:stream"),jn=require("node:http2"),{streamCollector:wf}=(G(),Sr(zi));mt.streamCollector=wf;function hr(t){let e=t&&typeof t=="object"&&"reason"in t?t.reason:void 0;if(e){if(e instanceof Error){let o=new Error("Request aborted");return o.name="AbortError",o.cause=e,o}let n=new Error(String(e));return n.name="AbortError",n}let r=new Error("Request aborted");return r.name="AbortError",r}var xf=["ECONNRESET","EPIPE","ETIMEDOUT"],Ba=t=>{let e={};for(let r in t){let n=t[r];e[r]=Array.isArray(n)?n.join(","):n}return e},A={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},Ma=1e3,Ef=(t,e,r=0)=>{if(!r)return-1;let n=o=>{let s=A.setTimeout(()=>{t.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${r} ms.`),{name:"TimeoutError"}))},r-o),i=a=>{a?.connecting?a.on("connect",()=>{A.clearTimeout(s)}):A.clearTimeout(s)};t.socket?i(t.socket):t.on("socket",i)};return r<2e3?(n(0),0):A.setTimeout(n.bind(null,Ma),Ma)},Tf=(t,e,r=0,n,o)=>r?A.setTimeout(()=>{let s=`@smithy/node-http-handler - [${n?"ERROR":"WARN"}] a request has exceeded the configured ${r} ms requestTimeout.`;if(n){let i=Object.assign(new Error(s),{name:"TimeoutError",code:"ETIMEDOUT"});t.destroy(i),e(i)}else s+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",o?.warn?.(s)},r):-1,Cf=3e3,If=(t,{keepAlive:e,keepAliveMsecs:r},n=Cf)=>{if(e!==!0)return-1;let o=()=>{t.socket?t.socket.setKeepAlive(e,r||0):t.on("socket",s=>{s.setKeepAlive(e,r||0)})};return n===0?(o(),0):A.setTimeout(o,n)},Pa=3e3,Af=(t,e,r=0)=>{let n=o=>{let s=r-o,i=()=>{t.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${r} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))};t.socket?(t.socket.setTimeout(s,i),t.on("close",()=>t.socket?.removeListener("timeout",i))):t.setTimeout(s,i)};return 0<r&&r<6e3?(n(0),0):A.setTimeout(n.bind(null,r===0?0:Pa),Pa)},ka=6e3;async function La(t,e,r=ka,n=!1){let o=e.headers,s=o?o.Expect||o.expect:void 0,i=-1,a=!0;!n&&s==="100-continue"&&(a=await Promise.race([new Promise(c=>{i=Number(A.setTimeout(()=>c(!0),Math.max(ka,r)))}),new Promise(c=>{t.on("continue",()=>{A.clearTimeout(i),c(!0)}),t.on("response",()=>{A.clearTimeout(i),c(!1)}),t.on("error",()=>{A.clearTimeout(i),c(!1)})})])),a&&vf(t,e.body)}function vf(t,e){if(e instanceof bf){e.pipe(t);return}if(e){let r=Buffer.isBuffer(e);if(r||typeof e=="string"){r&&e.byteLength===0?t.end():t.end(e);return}let o=e;if(typeof o=="object"&&o.buffer&&typeof o.byteOffset=="number"&&typeof o.byteLength=="number"){t.end(Buffer.from(o.buffer,o.byteOffset,o.byteLength));return}t.end(Buffer.from(e));return}t.end()}var Rf=0,dr,Ua,Vn=class t{config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(e){return typeof e?.handle=="function"?e:new t(e)}static checkSocketUsage(e,r,n=console){let{sockets:o,requests:s,maxSockets:i}=e;if(typeof i!="number"||i===1/0||Date.now()-15e3<r)return r;if(o&&s)for(let c in o){let f=o[c]?.length??0,u=s[c]?.length??0;if(f>=i&&u>=2*i)return n?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${f} and ${u} additional requests are enqueued.
|
|
16
16
|
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
17
|
-
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return r}constructor(e){this.configProvider=new Promise((r,n)=>{typeof e=="function"?e().then(o=>{r(this.resolveDefaultConfig(o))}).catch(n):r(this.resolveDefaultConfig(e))})}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy()}async handle(e,{abortSignal:r,requestTimeout:n}={}){this.config||(this.config=await this.configProvider);let o=this.config,s=e.protocol==="https:";return!s&&!this.config.httpAgent&&(this.config.httpAgent=await this.config.httpAgentProvider()),new Promise((i,a)=>{let c,f=-1,u=-1,l=-1,d=-1,h=-1,p=()=>{A.clearTimeout(f),A.clearTimeout(u),A.clearTimeout(l),A.clearTimeout(d),A.clearTimeout(h)},g=async w=>{await c,p(),i(w)},y=async w=>{await c,p(),a(w)};if(r?.aborted){let w=hr(r);y(w);return}let S=e.headers,b=S?(S.Expect??S.expect)==="100-continue":!1,E=s?o.httpsAgent:o.httpAgent;b&&!this.externalAgent&&(E=new(s?dr.Agent:lr)({keepAlive:!1,maxSockets:1/0})),f=A.setTimeout(()=>{this.socketWarningTimestamp=t.checkSocketUsage(E,this.socketWarningTimestamp,o.logger)},o.socketAcquisitionWarningTimeout??(o.requestTimeout??2e3)+(o.connectionTimeout??1e3));let v=e.query?Da(e.query):"",z;if(e.username!=null||e.password!=null){let w=e.username??"",x=e.password??"";z=`${w}:${x}`}let O=e.path;v&&(O+=`?${v}`),e.fragment&&(O+=`#${e.fragment}`);let Y=e.hostname??"";Y[0]==="["&&Y.endsWith("]")?Y=e.hostname.slice(1,-1):Y=e.hostname;let de={headers:e.headers,host:Y,method:e.method,path:O,port:e.port,agent:E,auth:z},M=(s?dr.request:ka)(de,w=>{let x=new _a({statusCode:w.statusCode||-1,reason:w.statusMessage,headers:$a(w.headers),body:w});g({response:x})});if(M.on("error",w=>{bf.includes(w.code)?y(Object.assign(w,{name:"TimeoutError"})):y(w)}),r){let w=()=>{M.destroy();let x=hr(r);y(x)};if(typeof r.addEventListener=="function"){let x=r;x.addEventListener("abort",w,{once:!0}),M.once("close",()=>x.removeEventListener("abort",w))}else r.onabort=w}let qe=n??o.requestTimeout;u=wf(M,y,o.connectionTimeout),l=xf(M,y,qe,o.throwOnRequestTimeout,o.logger??console),d=Cf(M,y,o.socketTimeout);let ee=de.agent;typeof ee=="object"&&"keepAlive"in ee&&(h=Tf(M,{keepAlive:ee.keepAlive,keepAliveMsecs:ee.keepAliveMsecs})),c=Ba(M,e,qe,this.externalAgent).catch(w=>(p(),a(w)))})}updateHttpClientConfig(e,r){this.config=void 0,this.configProvider=this.configProvider.then(n=>({...n,[e]:r}))}httpHandlerConfigs(){return this.config??{}}resolveDefaultConfig(e){let{requestTimeout:r,connectionTimeout:n,socketTimeout:o,socketAcquisitionWarningTimeout:s,httpAgent:i,httpsAgent:a,throwOnRequestTimeout:c,logger:f}=e||{},u=!0,l=50;return{connectionTimeout:n,requestTimeout:r,socketTimeout:o,socketAcquisitionWarningTimeout:s,throwOnRequestTimeout:c,httpAgentProvider:async()=>{let d=require("node:http"),{Agent:h,request:p}=d.default??d;return ka=p,lr=h,i instanceof lr||typeof i?.destroy=="function"?(this.externalAgent=!0,i):new lr({keepAlive:u,maxSockets:l,...i})},httpsAgent:a instanceof dr.Agent||typeof a?.destroy=="function"?(this.externalAgent=!0,a):new dr.Agent({keepAlive:u,maxSockets:l,...a}),logger:f}}},vf=new Uint16Array(1),ft=class{id=vf[0]++;total=0;max=0;session;refs=0;constructor(e){e.unref(),this.session=e}retain(){if(this.session.destroyed)throw new Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");this.refs+=1,this.total+=1,this.max=Math.max(this.refs,this.max),this.session.ref()}free(){if(!this.session.destroyed&&(this.refs-=1,this.refs===0&&this.session.unref(),this.refs<0))throw new Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.")}deref(){return this.session}close(){this.session.closed||this.session.close()}destroy(){this.refs=0,this.session.destroyed||this.session.destroy()}useCount(){return this.refs}},Gn=class{sessions=[];maxConcurrency=0;constructor(e){this.sessions=(e??[]).map(r=>new ft(r))}poll(){let e=!1;for(let r of this.sessions){if(r.deref().destroyed){e=!0;continue}if(!this.maxConcurrency||r.useCount()<this.maxConcurrency)return r}if(e)for(let r of this.sessions)r.deref().destroyed&&this.remove(r)}offerLast(e){this.sessions.push(e)}remove(e){let r=this.sessions.indexOf(e);r>-1&&this.sessions.splice(r,1)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}setMaxConcurrency(e){this.maxConcurrency=e}destroy(e){this.remove(e),e.destroy()}},qn=class{config;connectOptions;connectionPools=new Map;constructor(e){if(this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw new RangeError("maxConcurrency must be greater than zero.")}lease(e,r){let n=this.getUrlString(e),o=this.getPool(n);if(!this.config.disableConcurrency&&!r.isEventStream){let f=o.poll();if(f)return f.retain(),f}let s=new ft(this.connect(n)),i=s.deref();this.config.maxConcurrency&&i.settings({maxConcurrentStreams:this.config.maxConcurrency},f=>{if(f)throw new Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+e.destination.toString())});let a=()=>{this.removeFromPoolAndClose(n,s)},c=()=>{this.removeFromPoolAndCheckedDestroy(n,s)};return i.on("goaway",a),i.on("error",c),i.on("frameError",c),i.on("close",c),r.requestTimeout&&i.setTimeout(r.requestTimeout,c),o.offerLast(s),s.retain(),s}release(e,r){r.free()}createIsolatedSession(e,r){let n=this.getUrlString(e),o=new ft(this.connect(n)),s=o.deref();s.settings({maxConcurrentStreams:1});let i=()=>{o.destroy()};return s.on("error",i),s.on("frameError",i),s.on("close",i),r.requestTimeout&&s.setTimeout(r.requestTimeout,i),o.retain(),o}destroy(){for(let[e,r]of this.connectionPools){for(let n of[...r])n.destroy();this.connectionPools.delete(e)}}setMaxConcurrentStreams(e){if(e&&e<=0)throw new RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=e;for(let r of this.connectionPools.values())r.setMaxConcurrency(e)}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}setNodeHttp2ConnectOptions(e){this.connectOptions=e}debug(){let e={};for(let[r,n]of this.connectionPools){let o=[];for(let s of n)o.push({id:s.id,active:s.useCount(),maxConcurrent:s.max,totalRequests:s.total});e[r]={sessions:o}}return e}removeFromPoolAndClose(e,r){this.connectionPools.get(e)?.remove(r),r.close()}removeFromPoolAndCheckedDestroy(e,r){this.connectionPools.get(e)?.remove(r),r.destroy()}getPool(e){if(!this.connectionPools.has(e)){let r=new Gn;this.config.maxConcurrency&&r.setMaxConcurrency(this.config.maxConcurrency),this.connectionPools.set(e,r)}return this.connectionPools.get(e)}getUrlString(e){return e.destination.toString()}connect(e){return this.connectOptions===void 0?jn.connect(e):jn.connect(e,this.connectOptions)}},{constants:Ua}=jn,Wn=class t{config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new qn({});static create(e){return typeof e?.handle=="function"?e:new t(e)}constructor(e){this.configProvider=new Promise((r,n)=>{typeof e=="function"?e().then(o=>{r(o||{})}).catch(n):r(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:r,requestTimeout:n,isEventStream:o}={}){if(!this.config){this.config=await this.configProvider;let{disableConcurrentStreams:f,maxConcurrentStreams:u,nodeHttp2ConnectOptions:l}=this.config;this.connectionManager.setDisableConcurrentStreams(f??!1),u&&this.connectionManager.setMaxConcurrentStreams(u),l&&this.connectionManager.setNodeHttp2ConnectOptions(l)}let{requestTimeout:s,disableConcurrentStreams:i}=this.config,a=i||o,c=n??s;return new Promise((f,u)=>{let l=!1,d,h=async x=>{await d,f(x)},p=async x=>{await d,u(x)};if(r?.aborted){l=!0;let x=hr(r);p(x);return}let{hostname:g,method:y,port:S,protocol:b,query:E}=e,v="";if(e.username!=null||e.password!=null){let x=e.username??"",H=e.password??"";v=`${x}:${H}@`}let z=`${b}//${v}${g}${S?`:${S}`:""}`,O={destination:new URL(z)},Y={requestTimeout:this.config?.sessionTimeout,isEventStream:o},de=a?this.connectionManager.createIsolatedSession(O,Y):this.connectionManager.lease(O,Y),yr=de.deref(),M=x=>{a&&de.destroy(),l=!0,p(x)},qe=E?Da(E):"",ee=e.path;qe&&(ee+=`?${qe}`),e.fragment&&(ee+=`#${e.fragment}`);let w=yr.request({...e.headers,[Ua.HTTP2_HEADER_PATH]:ee,[Ua.HTTP2_HEADER_METHOD]:y});if(c&&w.setTimeout(c,()=>{w.close();let x=new Error(`Stream timed out because of no activity for ${c} ms`);x.name="TimeoutError",M(x)}),r){let x=()=>{w.close();let H=hr(r);M(H)};if(typeof r.addEventListener=="function"){let H=r;H.addEventListener("abort",x,{once:!0}),w.once("close",()=>H.removeEventListener("abort",x))}else r.onabort=x}w.on("frameError",(x,H,nc)=>{M(new Error(`Frame type id ${x} in stream id ${nc} has failed with code ${H}.`))}),w.on("error",M),w.on("aborted",()=>{M(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${w.rstCode}.`))}),w.on("response",x=>{let H=new _a({statusCode:x[":status"]??-1,headers:$a(x),body:w});l=!0,h({response:H}),a&&yr.close()}),w.on("close",()=>{a?de.destroy():this.connectionManager.release(O,de),l||M(new Error("Unexpected error: http2 request did not get a response"))}),d=Ba(w,e,c)})}updateHttpClientConfig(e,r){this.config=void 0,this.configProvider=this.configProvider.then(n=>({...n,[e]:r}))}httpHandlerConfigs(){return this.config??{}}};mt.DEFAULT_REQUEST_TIMEOUT=Af;mt.NodeHttp2Handler=Wn;mt.NodeHttpHandler=Vn});var Df={};dt(Df,{createHandler:()=>tc,handler:()=>Uf});module.exports=Sr(Df);var Ya=require("@aws-sdk/client-dynamodb"),gr=require("@aws-sdk/client-sesv2"),F=require("@aws-sdk/lib-dynamodb"),ec=xe(La(),1);function Fa(t){return{pk:`CONFIG#${t}`,sk:"CONFIG"}}function za(t,e){return{pk:`HOUR#${t}`,sk:e}}function Ha(t,e){return{pk:`DAY#${t}`,sk:e}}function pr(t){return{pk:`OUTCOME#${t}`,sk:"OUTCOME"}}function ja(t){return t.toISOString().slice(0,13)}function Va(t){return t.toISOString().slice(0,10)}var Ga=2880*60,qa="wraps-email-tracking";function Jn(t){let e=process.env[t];if(!e)throw new Error(`${t} environment variable not set`);return e}function Rf(t){return typeof t=="object"&&t!==null&&t.name==="ConditionalCheckFailedException"}async function Wa(t,e,r){let n=await t.send(new F.GetCommand({TableName:e,Key:Fa(r)}));return n.Item?{killed:n.Item.killed===!0,emailAddress:String(n.Item.emailAddress??""),policy:n.Item.policy}:null}function Ja(t){return typeof t!="string"||t.length===0||t.length>320?!1:/^[^\s@,]+@[^\s@,]+\.[^\s@,]+$/.test(t)}function Ka(t,e){return typeof t=="string"&&e.length>0&&t.toLowerCase()===e.toLowerCase()}function Nf(t,e){let r=t.toLowerCase(),n=r.split("@")[1]??"";return!!(e.allowedRecipients.some(o=>o.toLowerCase()===r)||e.allowedRecipientDomains.some(o=>o.toLowerCase()===n))}async function Qa(t,e,r,n,o){try{return await t.send(new F.UpdateCommand({TableName:e,Key:r,UpdateExpression:"SET sends = if_not_exists(sends, :z) + :one, expiresAt = if_not_exists(expiresAt, :ttl)",ConditionExpression:"attribute_not_exists(sends) OR sends < :cap",ExpressionAttributeValues:{":z":0,":one":1,":cap":n,":ttl":o}})),!0}catch(s){if(Rf(s))return!1;throw s}}async function Of(t,e,r){try{await t.send(new F.UpdateCommand({TableName:e,Key:r,UpdateExpression:"SET sends = sends - :one",ConditionExpression:"attribute_exists(sends) AND sends > :z",ExpressionAttributeValues:{":one":1,":z":0}}))}catch{}}var Xa="agent-";function Mf(t){let r=(t?.invokedFunctionArn??"").split(":"),n=r.length>=8?r[7]:void 0;return n?.startsWith(Xa)?{kind:"agent",agentId:n.slice(Xa.length)}:{kind:"platform"}}var Kn={status:"blocked",reason:"unauthorized action for caller"};async function Za(t,e,r,n){let o=await t.send(new gr.SendEmailCommand({FromEmailAddress:e.from,Destination:{ToAddresses:[e.to]},Content:{Simple:{Subject:{Data:e.subject},Body:{Html:{Data:e.html},Text:{Data:e.text}}}},ConfigurationSetName:n,EmailTags:[{Name:"agentId",Value:r}]}));if(!o.MessageId)throw new Error("SES SendEmail returned no MessageId");return o.MessageId}function tc(t){let{dynamo:e,sesClient:r}=t,n=t.fetchImpl??fetch;async function o(f,u,l){let d=Jn("WRAPS_API_URL"),h=Jn("WRAPS_AGENT_WEBHOOK_SECRET"),p=await n(`${d}/v1/agents/webhook`,{method:"POST",headers:{"content-type":"application/json","x-wraps-agent-key":h},body:JSON.stringify({agentId:f,event:"pending_approval",payload:u,reason:l})});if(!p.ok)throw new Error(`agent webhook failed: ${p.status}`);return{status:"pending_approval",approvalId:(await p.json()).approvalId,reason:l}}async function s(f,u,l){let d=l.payload;if(!d)return{status:"failed",reason:"missing payload"};if(!Ja(d.to))return{status:"blocked",reason:"invalid recipient"};let h=await Wa(e,f,u);if(!h)return{status:"blocked",reason:"unknown agent"};if(h.killed)return{status:"blocked",reason:"killed"};if(!Ka(d.from,h.emailAddress))return{status:"blocked",reason:"from must be the agent's own address"};if(!Nf(d.to,h.policy))return o(u,d,"recipient not on allowlist");if(h.policy.maxPerHour<=0)return o(u,d,"hourly cap reached");if(h.policy.maxPerDay<=0)return o(u,d,"daily cap reached");let p=new Date,g=Math.floor(p.getTime()/1e3)+Ga,y=za(u,ja(p));if(!await Qa(e,f,y,h.policy.maxPerHour,g))return o(u,d,"hourly cap reached");if(!await Qa(e,f,Ha(u,Va(p)),h.policy.maxPerDay,g))return await Of(e,f,y),o(u,d,"daily cap reached");let E=process.env.CONFIG_SET||qa;try{return{status:"sent",messageId:await Za(r,d,u,E)}}catch(v){return{status:"failed",reason:String(v)}}}async function i(f,u,l,d){await e.send(new F.PutCommand({TableName:f,Item:{...pr(u),agentId:l,status:d.status,messageId:d.messageId,reason:d.reason,expiresAt:Math.floor(Date.now()/1e3)+Ga}}))}async function a(f,u){let l=u.payload,d=u.approvalId;if(!(l&&d))return{status:"failed",reason:"missing payload or approvalId"};let h=await e.send(new F.GetCommand({TableName:f,Key:pr(d)}));if(h.Item)return{status:h.Item.status,messageId:h.Item.messageId,reason:h.Item.reason};let p=await Wa(e,f,u.agentId);if(!p||p.killed)return{status:"blocked",reason:"killed"};if(!Ka(l.from,p.emailAddress))return{status:"blocked",reason:"from must be the agent's own address"};if(!Ja(l.to))return{status:"blocked",reason:"invalid recipient"};let g=process.env.CONFIG_SET||qa;try{let S={status:"sent",messageId:await Za(r,l,u.agentId,g)};return await i(f,d,u.agentId,S),S}catch(y){let S={status:"failed",reason:String(y)};return await i(f,d,u.agentId,S),S}}async function c(f,u,l){let d=l.approvalId;if(!d)return{status:"failed",reason:"missing approvalId"};let h=await e.send(new F.GetCommand({TableName:f,Key:pr(d)}));return!h.Item||h.Item.agentId!==u?{status:"unknown"}:{status:h.Item.status,messageId:h.Item.messageId,reason:h.Item.reason}}return async function(u,l){let d=Jn("POLICY_TABLE"),h=Mf(l);switch(u.action){case"send":return h.kind==="agent"?s(d,h.agentId,u):Kn;case"status":return h.kind==="agent"?c(d,h.agentId,u):Kn;case"execute":return h.kind==="platform"?a(d,u):Kn;default:return{status:"failed",reason:`unknown action: ${u.action}`}}}}var rc={requestHandler:new ec.NodeHttpHandler({requestTimeout:1e4,connectionTimeout:5e3}),maxAttempts:5},Pf=F.DynamoDBDocumentClient.from(new Ya.DynamoDBClient(rc)),kf=new gr.SESv2Client(rc),Uf=tc({dynamo:Pf,sesClient:kf});0&&(module.exports={createHandler,handler});
|
|
17
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return r}constructor(e){this.configProvider=new Promise((r,n)=>{typeof e=="function"?e().then(o=>{r(this.resolveDefaultConfig(o))}).catch(n):r(this.resolveDefaultConfig(e))})}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy()}async handle(e,{abortSignal:r,requestTimeout:n}={}){this.config||(this.config=await this.configProvider);let o=this.config,s=e.protocol==="https:";return!s&&!this.config.httpAgent&&(this.config.httpAgent=await this.config.httpAgentProvider()),new Promise((i,a)=>{let c,f=-1,u=-1,d=-1,l=-1,h=-1,p=()=>{A.clearTimeout(f),A.clearTimeout(u),A.clearTimeout(d),A.clearTimeout(l),A.clearTimeout(h)},g=async w=>{await c,p(),i(w)},y=async w=>{await c,p(),a(w)};if(r?.aborted){let w=hr(r);y(w);return}let b=e.headers,S=b?(b.Expect??b.expect)==="100-continue":!1,E=s?o.httpsAgent:o.httpAgent;S&&!this.externalAgent&&(E=new(s?lr.Agent:dr)({keepAlive:!1,maxSockets:1/0})),f=A.setTimeout(()=>{this.socketWarningTimestamp=t.checkSocketUsage(E,this.socketWarningTimestamp,o.logger)},o.socketAcquisitionWarningTimeout??(o.requestTimeout??2e3)+(o.connectionTimeout??1e3));let N=e.query?_a(e.query):"",k;if(e.username!=null||e.password!=null){let w=e.username??"",x=e.password??"";k=`${w}:${x}`}let O=e.path;N&&(O+=`?${N}`),e.fragment&&(O+=`#${e.fragment}`);let Y=e.hostname??"";Y[0]==="["&&Y.endsWith("]")?Y=e.hostname.slice(1,-1):Y=e.hostname;let le={headers:e.headers,host:Y,method:e.method,path:O,port:e.port,agent:E,auth:k},M=(s?lr.request:Ua)(le,w=>{let x=new $a({statusCode:w.statusCode||-1,reason:w.statusMessage,headers:Ba(w.headers),body:w});g({response:x})});if(M.on("error",w=>{xf.includes(w.code)?y(Object.assign(w,{name:"TimeoutError"})):y(w)}),r){let w=()=>{M.destroy();let x=hr(r);y(x)};if(typeof r.addEventListener=="function"){let x=r;x.addEventListener("abort",w,{once:!0}),M.once("close",()=>x.removeEventListener("abort",w))}else r.onabort=w}let qe=n??o.requestTimeout;u=Ef(M,y,o.connectionTimeout),d=Tf(M,y,qe,o.throwOnRequestTimeout,o.logger??console),l=Af(M,y,o.socketTimeout);let ee=le.agent;typeof ee=="object"&&"keepAlive"in ee&&(h=If(M,{keepAlive:ee.keepAlive,keepAliveMsecs:ee.keepAliveMsecs})),c=La(M,e,qe,this.externalAgent).catch(w=>(p(),a(w)))})}updateHttpClientConfig(e,r){this.config=void 0,this.configProvider=this.configProvider.then(n=>({...n,[e]:r}))}httpHandlerConfigs(){return this.config??{}}resolveDefaultConfig(e){let{requestTimeout:r,connectionTimeout:n,socketTimeout:o,socketAcquisitionWarningTimeout:s,httpAgent:i,httpsAgent:a,throwOnRequestTimeout:c,logger:f}=e||{},u=!0,d=50;return{connectionTimeout:n,requestTimeout:r,socketTimeout:o,socketAcquisitionWarningTimeout:s,throwOnRequestTimeout:c,httpAgentProvider:async()=>{let l=require("node:http"),{Agent:h,request:p}=l.default??l;return Ua=p,dr=h,i instanceof dr||typeof i?.destroy=="function"?(this.externalAgent=!0,i):new dr({keepAlive:u,maxSockets:d,...i})},httpsAgent:a instanceof lr.Agent||typeof a?.destroy=="function"?(this.externalAgent=!0,a):new lr.Agent({keepAlive:u,maxSockets:d,...a}),logger:f}}},Nf=new Uint16Array(1),ft=class{id=Nf[0]++;total=0;max=0;session;refs=0;constructor(e){e.unref(),this.session=e}retain(){if(this.session.destroyed)throw new Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");this.refs+=1,this.total+=1,this.max=Math.max(this.refs,this.max),this.session.ref()}free(){if(!this.session.destroyed&&(this.refs-=1,this.refs===0&&this.session.unref(),this.refs<0))throw new Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.")}deref(){return this.session}close(){this.session.closed||this.session.close()}destroy(){this.refs=0,this.session.destroyed||this.session.destroy()}useCount(){return this.refs}},Gn=class{sessions=[];maxConcurrency=0;constructor(e){this.sessions=(e??[]).map(r=>new ft(r))}poll(){let e=!1;for(let r of this.sessions){if(r.deref().destroyed){e=!0;continue}if(!this.maxConcurrency||r.useCount()<this.maxConcurrency)return r}if(e)for(let r of this.sessions)r.deref().destroyed&&this.remove(r)}offerLast(e){this.sessions.push(e)}remove(e){let r=this.sessions.indexOf(e);r>-1&&this.sessions.splice(r,1)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}setMaxConcurrency(e){this.maxConcurrency=e}destroy(e){this.remove(e),e.destroy()}},qn=class{config;connectOptions;connectionPools=new Map;constructor(e){if(this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw new RangeError("maxConcurrency must be greater than zero.")}lease(e,r){let n=this.getUrlString(e),o=this.getPool(n);if(!this.config.disableConcurrency&&!r.isEventStream){let f=o.poll();if(f)return f.retain(),f}let s=new ft(this.connect(n)),i=s.deref();this.config.maxConcurrency&&i.settings({maxConcurrentStreams:this.config.maxConcurrency},f=>{if(f)throw new Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+e.destination.toString())});let a=()=>{this.removeFromPoolAndClose(n,s)},c=()=>{this.removeFromPoolAndCheckedDestroy(n,s)};return i.on("goaway",a),i.on("error",c),i.on("frameError",c),i.on("close",c),r.requestTimeout&&i.setTimeout(r.requestTimeout,c),o.offerLast(s),s.retain(),s}release(e,r){r.free()}createIsolatedSession(e,r){let n=this.getUrlString(e),o=new ft(this.connect(n)),s=o.deref();s.settings({maxConcurrentStreams:1});let i=()=>{o.destroy()};return s.on("error",i),s.on("frameError",i),s.on("close",i),r.requestTimeout&&s.setTimeout(r.requestTimeout,i),o.retain(),o}destroy(){for(let[e,r]of this.connectionPools){for(let n of[...r])n.destroy();this.connectionPools.delete(e)}}setMaxConcurrentStreams(e){if(e&&e<=0)throw new RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=e;for(let r of this.connectionPools.values())r.setMaxConcurrency(e)}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}setNodeHttp2ConnectOptions(e){this.connectOptions=e}debug(){let e={};for(let[r,n]of this.connectionPools){let o=[];for(let s of n)o.push({id:s.id,active:s.useCount(),maxConcurrent:s.max,totalRequests:s.total});e[r]={sessions:o}}return e}removeFromPoolAndClose(e,r){this.connectionPools.get(e)?.remove(r),r.close()}removeFromPoolAndCheckedDestroy(e,r){this.connectionPools.get(e)?.remove(r),r.destroy()}getPool(e){if(!this.connectionPools.has(e)){let r=new Gn;this.config.maxConcurrency&&r.setMaxConcurrency(this.config.maxConcurrency),this.connectionPools.set(e,r)}return this.connectionPools.get(e)}getUrlString(e){return e.destination.toString()}connect(e){return this.connectOptions===void 0?jn.connect(e):jn.connect(e,this.connectOptions)}},{constants:Da}=jn,Wn=class t{config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new qn({});static create(e){return typeof e?.handle=="function"?e:new t(e)}constructor(e){this.configProvider=new Promise((r,n)=>{typeof e=="function"?e().then(o=>{r(o||{})}).catch(n):r(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:r,requestTimeout:n,isEventStream:o}={}){if(!this.config){this.config=await this.configProvider;let{disableConcurrentStreams:f,maxConcurrentStreams:u,nodeHttp2ConnectOptions:d}=this.config;this.connectionManager.setDisableConcurrentStreams(f??!1),u&&this.connectionManager.setMaxConcurrentStreams(u),d&&this.connectionManager.setNodeHttp2ConnectOptions(d)}let{requestTimeout:s,disableConcurrentStreams:i}=this.config,a=i||o,c=n??s;return new Promise((f,u)=>{let d=!1,l,h=async x=>{await l,f(x)},p=async x=>{await l,u(x)};if(r?.aborted){d=!0;let x=hr(r);p(x);return}let{hostname:g,method:y,port:b,protocol:S,query:E}=e,N="";if(e.username!=null||e.password!=null){let x=e.username??"",H=e.password??"";N=`${x}:${H}@`}let k=`${S}//${N}${g}${b?`:${b}`:""}`,O={destination:new URL(k)},Y={requestTimeout:this.config?.sessionTimeout,isEventStream:o},le=a?this.connectionManager.createIsolatedSession(O,Y):this.connectionManager.lease(O,Y),yr=le.deref(),M=x=>{a&&le.destroy(),d=!0,p(x)},qe=E?_a(E):"",ee=e.path;qe&&(ee+=`?${qe}`),e.fragment&&(ee+=`#${e.fragment}`);let w=yr.request({...e.headers,[Da.HTTP2_HEADER_PATH]:ee,[Da.HTTP2_HEADER_METHOD]:y});if(c&&w.setTimeout(c,()=>{w.close();let x=new Error(`Stream timed out because of no activity for ${c} ms`);x.name="TimeoutError",M(x)}),r){let x=()=>{w.close();let H=hr(r);M(H)};if(typeof r.addEventListener=="function"){let H=r;H.addEventListener("abort",x,{once:!0}),w.once("close",()=>H.removeEventListener("abort",x))}else r.onabort=x}w.on("frameError",(x,H,sc)=>{M(new Error(`Frame type id ${x} in stream id ${sc} has failed with code ${H}.`))}),w.on("error",M),w.on("aborted",()=>{M(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${w.rstCode}.`))}),w.on("response",x=>{let H=new $a({statusCode:x[":status"]??-1,headers:Ba(x),body:w});d=!0,h({response:H}),a&&yr.close()}),w.on("close",()=>{a?le.destroy():this.connectionManager.release(O,le),d||M(new Error("Unexpected error: http2 request did not get a response"))}),l=La(w,e,c)})}updateHttpClientConfig(e,r){this.config=void 0,this.configProvider=this.configProvider.then(n=>({...n,[e]:r}))}httpHandlerConfigs(){return this.config??{}}};mt.DEFAULT_REQUEST_TIMEOUT=Rf;mt.NodeHttp2Handler=Wn;mt.NodeHttpHandler=Vn});var $f={};lt($f,{createHandler:()=>nc,handler:()=>_f});module.exports=Sr($f);var tc=require("@aws-sdk/client-dynamodb"),gr=require("@aws-sdk/client-sesv2"),z=require("@aws-sdk/lib-dynamodb"),rc=xe(Fa(),1);function za(t){return{pk:`CONFIG#${t}`,sk:"CONFIG"}}function Ha(t,e){return{pk:`HOUR#${t}`,sk:e}}function ja(t,e){return{pk:`DAY#${t}`,sk:e}}function pr(t){return{pk:`OUTCOME#${t}`,sk:"OUTCOME"}}function Va(t){return t.toISOString().slice(0,13)}function Ga(t){return t.toISOString().slice(0,10)}var qa=2880*60,Wa="wraps-email-tracking";function Jn(t){let e=process.env[t];if(!e)throw new Error(`${t} environment variable not set`);return e}function Of(t){return typeof t=="object"&&t!==null&&t.name==="ConditionalCheckFailedException"}async function Ja(t,e,r){let n=await t.send(new z.GetCommand({TableName:e,Key:za(r)}));return n.Item?{killed:n.Item.killed===!0,emailAddress:String(n.Item.emailAddress??""),policy:n.Item.policy}:null}function Qn(t){return typeof t!="string"||t.length===0||t.length>320?!1:/^[^\s@,]+@[^\s@,]+\.[^\s@,]+$/.test(t)}function Ka(t){return typeof t=="string"&&t.length>0&&t.length<=998&&/^[\x20-\x7e]+$/.test(t)}function Qa(t,e){return typeof t=="string"&&e.length>0&&t.toLowerCase()===e.toLowerCase()}function Mf(t,e){let r=t.toLowerCase(),n=r.split("@")[1]??"";return!!(e.allowedRecipients.some(o=>o.toLowerCase()===r)||e.allowedRecipientDomains.some(o=>o.toLowerCase()===n))}async function Xa(t,e,r,n,o){try{return await t.send(new z.UpdateCommand({TableName:e,Key:r,UpdateExpression:"SET sends = if_not_exists(sends, :z) + :one, expiresAt = if_not_exists(expiresAt, :ttl)",ConditionExpression:"attribute_not_exists(sends) OR sends < :cap",ExpressionAttributeValues:{":z":0,":one":1,":cap":n,":ttl":o}})),!0}catch(s){if(Of(s))return!1;throw s}}async function Pf(t,e,r){try{await t.send(new z.UpdateCommand({TableName:e,Key:r,UpdateExpression:"SET sends = sends - :one",ConditionExpression:"attribute_exists(sends) AND sends > :z",ExpressionAttributeValues:{":one":1,":z":0}}))}catch{}}function Za(t){return t.replyTo!==void 0&&!Qn(t.replyTo)?"invalid reply-to":t.inReplyTo!==void 0&&!Ka(t.inReplyTo)?"invalid in-reply-to":t.references!==void 0&&!Ka(t.references)?"invalid references":null}var Ya="agent-";function kf(t){let r=(t?.invokedFunctionArn??"").split(":"),n=r.length>=8?r[7]:void 0;return n?.startsWith(Ya)?{kind:"agent",agentId:n.slice(Ya.length)}:{kind:"platform"}}var Kn={status:"blocked",reason:"unauthorized action for caller"};async function ec(t,e,r,n){let o=[...e.inReplyTo?[{Name:"In-Reply-To",Value:e.inReplyTo}]:[],...e.references?[{Name:"References",Value:e.references}]:[]],s=await t.send(new gr.SendEmailCommand({FromEmailAddress:e.from,Destination:{ToAddresses:[e.to]},...e.replyTo?{ReplyToAddresses:[e.replyTo]}:{},Content:{Simple:{Subject:{Data:e.subject},Body:{Html:{Data:e.html},Text:{Data:e.text}},...o.length>0?{Headers:o}:{}}},ConfigurationSetName:n,EmailTags:[{Name:"agentId",Value:r}]}));if(!s.MessageId)throw new Error("SES SendEmail returned no MessageId");return s.MessageId}function nc(t){let{dynamo:e,sesClient:r}=t,n=t.fetchImpl??fetch;async function o(f,u,d){let l=Jn("WRAPS_API_URL"),h=Jn("WRAPS_AGENT_WEBHOOK_SECRET"),p=await n(`${l}/v1/agents/webhook`,{method:"POST",headers:{"content-type":"application/json","x-wraps-agent-key":h},body:JSON.stringify({agentId:f,event:"pending_approval",payload:u,reason:d})});if(!p.ok)throw new Error(`agent webhook failed: ${p.status}`);return{status:"pending_approval",approvalId:(await p.json()).approvalId,reason:d}}async function s(f,u,d){let l=d.payload;if(!l)return{status:"failed",reason:"missing payload"};if(!Qn(l.to))return{status:"blocked",reason:"invalid recipient"};let h=Za(l);if(h)return{status:"blocked",reason:h};let p=await Ja(e,f,u);if(!p)return{status:"blocked",reason:"unknown agent"};if(p.killed)return{status:"blocked",reason:"killed"};if(!Qa(l.from,p.emailAddress))return{status:"blocked",reason:"from must be the agent's own address"};if(!Mf(l.to,p.policy))return o(u,l,"recipient not on allowlist");if(p.policy.maxPerHour<=0)return o(u,l,"hourly cap reached");if(p.policy.maxPerDay<=0)return o(u,l,"daily cap reached");let g=new Date,y=Math.floor(g.getTime()/1e3)+qa,b=Ha(u,Va(g));if(!await Xa(e,f,b,p.policy.maxPerHour,y))return o(u,l,"hourly cap reached");if(!await Xa(e,f,ja(u,Ga(g)),p.policy.maxPerDay,y))return await Pf(e,f,b),o(u,l,"daily cap reached");let N=process.env.CONFIG_SET||Wa;try{return{status:"sent",messageId:await ec(r,l,u,N)}}catch(k){return{status:"failed",reason:String(k)}}}async function i(f,u,d,l){await e.send(new z.PutCommand({TableName:f,Item:{...pr(u),agentId:d,status:l.status,messageId:l.messageId,reason:l.reason,expiresAt:Math.floor(Date.now()/1e3)+qa}}))}async function a(f,u){let d=u.payload,l=u.approvalId;if(!(d&&l))return{status:"failed",reason:"missing payload or approvalId"};let h=await e.send(new z.GetCommand({TableName:f,Key:pr(l)}));if(h.Item)return{status:h.Item.status,messageId:h.Item.messageId,reason:h.Item.reason};let p=await Ja(e,f,u.agentId);if(!p||p.killed)return{status:"blocked",reason:"killed"};if(!Qa(d.from,p.emailAddress))return{status:"blocked",reason:"from must be the agent's own address"};if(!Qn(d.to))return{status:"blocked",reason:"invalid recipient"};let g=Za(d);if(g)return{status:"blocked",reason:g};let y=process.env.CONFIG_SET||Wa;try{let S={status:"sent",messageId:await ec(r,d,u.agentId,y)};return await i(f,l,u.agentId,S),S}catch(b){let S={status:"failed",reason:String(b)};return await i(f,l,u.agentId,S),S}}async function c(f,u,d){let l=d.approvalId;if(!l)return{status:"failed",reason:"missing approvalId"};let h=await e.send(new z.GetCommand({TableName:f,Key:pr(l)}));return!h.Item||h.Item.agentId!==u?{status:"unknown"}:{status:h.Item.status,messageId:h.Item.messageId,reason:h.Item.reason}}return async function(u,d){let l=Jn("POLICY_TABLE"),h=kf(d);switch(u.action){case"send":return h.kind==="agent"?s(l,h.agentId,u):Kn;case"status":return h.kind==="agent"?c(l,h.agentId,u):Kn;case"execute":return h.kind==="platform"?a(l,u):Kn;default:return{status:"failed",reason:`unknown action: ${u.action}`}}}}var oc={requestHandler:new rc.NodeHttpHandler({requestTimeout:1e4,connectionTimeout:5e3}),maxAttempts:5},Uf=z.DynamoDBDocumentClient.from(new tc.DynamoDBClient(oc)),Df=new gr.SESv2Client(oc),_f=nc({dynamo:Uf,sesClient:Df});0&&(module.exports={createHandler,handler});
|