datastore-s3
Version:
IPFS datastore implementation backed by s3
11 lines • 127 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.DatastoreS3 = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var DatastoreS3=(()=>{var $c=Object.create;var Nt=Object.defineProperty;var Kc=Object.getOwnPropertyDescriptor;var qc=Object.getOwnPropertyNames;var zc=Object.getPrototypeOf,Hc=Object.prototype.hasOwnProperty;var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),M=(e,t)=>{for(var n in t)Nt(e,n,{get:t[n],enumerable:!0})},co=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of qc(t))!Hc.call(e,s)&&s!==n&&Nt(e,s,{get:()=>t[s],enumerable:!(r=Kc(t,s))||r.enumerable});return e};var jc=(e,t,n)=>(n=e!=null?$c(zc(e)):{},co(t||!e||!e.__esModule?Nt(n,"default",{value:e,enumerable:!0}):n,e)),Gc=e=>co(Nt({},"__esModule",{value:!0}),e);var zt=L(ee=>{"use strict";var Vo=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",$l=Vo+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",Wo="["+Vo+"]["+$l+"]*",Kl=new RegExp("^"+Wo+"$"),ql=function(e,t){let n=[],r=t.exec(e);for(;r;){let s=[];s.startIndex=t.lastIndex-r[0].length;let o=r.length;for(let i=0;i<o;i++)s.push(r[i]);n.push(s),r=t.exec(e)}return n},zl=function(e){let t=Kl.exec(e);return!(t===null||typeof t>"u")};ee.isExist=function(e){return typeof e<"u"};ee.isEmptyObject=function(e){return Object.keys(e).length===0};ee.merge=function(e,t,n){if(t){let r=Object.keys(t),s=r.length;for(let o=0;o<s;o++)n==="strict"?e[r[o]]=[t[r[o]]]:e[r[o]]=t[r[o]]}};ee.getValue=function(e){return ee.isExist(e)?e:""};ee.isName=zl;ee.getAllMatches=ql;ee.nameRegexp=Wo});var kr=L(Jo=>{"use strict";var Rr=zt(),Hl={allowBooleanAttributes:!1,unpairedTags:[]};Jo.validate=function(e,t){t=Object.assign({},Hl,t);let n=[],r=!1,s=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let o=0;o<e.length;o++)if(e[o]==="<"&&e[o+1]==="?"){if(o+=2,o=Qo(e,o),o.err)return o}else if(e[o]==="<"){let i=o;if(o++,e[o]==="!"){o=Yo(e,o);continue}else{let c=!1;e[o]==="/"&&(c=!0,o++);let a="";for(;o<e.length&&e[o]!==">"&&e[o]!==" "&&e[o]!==" "&&e[o]!==`
`&&e[o]!=="\r";o++)a+=e[o];if(a=a.trim(),a[a.length-1]==="/"&&(a=a.substring(0,a.length-1),o--),!Zl(a)){let f;return a.trim().length===0?f="Invalid space after '<'.":f="Tag '"+a+"' is an invalid name.",A("InvalidTag",f,D(e,o))}let l=Vl(e,o);if(l===!1)return A("InvalidAttr","Attributes for '"+a+"' have open quote.",D(e,o));let d=l.value;if(o=l.index,d[d.length-1]==="/"){let f=o-d.length;d=d.substring(0,d.length-1);let m=Zo(d,t);if(m===!0)r=!0;else return A(m.err.code,m.err.msg,D(e,f+m.err.line))}else if(c)if(l.tagClosed){if(d.trim().length>0)return A("InvalidTag","Closing tag '"+a+"' can't have attributes or invalid starting.",D(e,i));if(n.length===0)return A("InvalidTag","Closing tag '"+a+"' has not been opened.",D(e,i));{let f=n.pop();if(a!==f.tagName){let m=D(e,f.tagStartPos);return A("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+a+"'.",D(e,i))}n.length==0&&(s=!0)}}else return A("InvalidTag","Closing tag '"+a+"' doesn't have proper closing.",D(e,o));else{let f=Zo(d,t);if(f!==!0)return A(f.err.code,f.err.msg,D(e,o-d.length+f.err.line));if(s===!0)return A("InvalidXml","Multiple possible root nodes found.",D(e,o));t.unpairedTags.indexOf(a)!==-1||n.push({tagName:a,tagStartPos:i}),r=!0}for(o++;o<e.length;o++)if(e[o]==="<")if(e[o+1]==="!"){o++,o=Yo(e,o);continue}else if(e[o+1]==="?"){if(o=Qo(e,++o),o.err)return o}else break;else if(e[o]==="&"){let f=Ql(e,o);if(f==-1)return A("InvalidChar","char '&' is not expected.",D(e,o));o=f}else if(s===!0&&!Xo(e[o]))return A("InvalidXml","Extra text at the end",D(e,o));e[o]==="<"&&o--}}else{if(Xo(e[o]))continue;return A("InvalidChar","char '"+e[o]+"' is not expected.",D(e,o))}if(r){if(n.length==1)return A("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",D(e,n[0].tagStartPos));if(n.length>0)return A("InvalidXml","Invalid '"+JSON.stringify(n.map(o=>o.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return A("InvalidXml","Start tag expected.",1);return!0};function Xo(e){return e===" "||e===" "||e===`
`||e==="\r"}function Qo(e,t){let n=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let r=e.substr(n,t-n);if(t>5&&r==="xml")return A("InvalidXml","XML declaration allowed only at the start of the document.",D(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function Yo(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let n=1;for(t+=8;t<e.length;t++)if(e[t]==="<")n++;else if(e[t]===">"&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var jl='"',Gl="'";function Vl(e,t){let n="",r="",s=!1;for(;t<e.length;t++){if(e[t]===jl||e[t]===Gl)r===""?r=e[t]:r!==e[t]||(r="");else if(e[t]===">"&&r===""){s=!0;break}n+=e[t]}return r!==""?!1:{value:n,index:t,tagClosed:s}}var Wl=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Zo(e,t){let n=Rr.getAllMatches(e,Wl),r={};for(let s=0;s<n.length;s++){if(n[s][1].length===0)return A("InvalidAttr","Attribute '"+n[s][2]+"' has no space in starting.",nt(n[s]));if(n[s][3]!==void 0&&n[s][4]===void 0)return A("InvalidAttr","Attribute '"+n[s][2]+"' is without value.",nt(n[s]));if(n[s][3]===void 0&&!t.allowBooleanAttributes)return A("InvalidAttr","boolean attribute '"+n[s][2]+"' is not allowed.",nt(n[s]));let o=n[s][2];if(!Yl(o))return A("InvalidAttr","Attribute '"+o+"' is an invalid name.",nt(n[s]));if(!r.hasOwnProperty(o))r[o]=1;else return A("InvalidAttr","Attribute '"+o+"' is repeated.",nt(n[s]))}return!0}function Xl(e,t){let n=/\d/;for(e[t]==="x"&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(n))break}return-1}function Ql(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,Xl(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===";")break;return-1}return t}function A(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function Yl(e){return Rr.isName(e)}function Zl(e){return Rr.isName(e)}function D(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function nt(e){return e.startIndex+e[1].length}});var ti=L(Or=>{var ei={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e}},Jl=function(e){return Object.assign({},ei,e)};Or.buildOptions=Jl;Or.defaultOptions=ei});var ri=L((d0,ni)=>{"use strict";var Ir=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,n){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:n})}addChild(t){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child})}};ni.exports=Ir});var oi=L((f0,si)=>{var ed=zt();function td(e,t){let n={};if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,s=!1,o=!1,i="";for(;t<e.length;t++)if(e[t]==="<"&&!o){if(s&&sd(e,t))t+=7,[entityName,val,t]=nd(e,t+1),val.indexOf("&")===-1&&(n[cd(entityName)]={regx:RegExp(`&${entityName};`,"g"),val});else if(s&&od(e,t))t+=8;else if(s&&id(e,t))t+=8;else if(s&&ad(e,t))t+=9;else if(rd)o=!0;else throw new Error("Invalid DOCTYPE");r++,i=""}else if(e[t]===">"){if(o?e[t-1]==="-"&&e[t-2]==="-"&&(o=!1,r--):r--,r===0)break}else e[t]==="["?s=!0:i+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:t}}function nd(e,t){let n="";for(;t<e.length&&e[t]!=="'"&&e[t]!=='"';t++)n+=e[t];if(n=n.trim(),n.indexOf(" ")!==-1)throw new Error("External entites are not supported");let r=e[t++],s="";for(;t<e.length&&e[t]!==r;t++)s+=e[t];return[n,s,t]}function rd(e,t){return e[t+1]==="!"&&e[t+2]==="-"&&e[t+3]==="-"}function sd(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="N"&&e[t+4]==="T"&&e[t+5]==="I"&&e[t+6]==="T"&&e[t+7]==="Y"}function od(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="L"&&e[t+4]==="E"&&e[t+5]==="M"&&e[t+6]==="E"&&e[t+7]==="N"&&e[t+8]==="T"}function id(e,t){return e[t+1]==="!"&&e[t+2]==="A"&&e[t+3]==="T"&&e[t+4]==="T"&&e[t+5]==="L"&&e[t+6]==="I"&&e[t+7]==="S"&&e[t+8]==="T"}function ad(e,t){return e[t+1]==="!"&&e[t+2]==="N"&&e[t+3]==="O"&&e[t+4]==="T"&&e[t+5]==="A"&&e[t+6]==="T"&&e[t+7]==="I"&&e[t+8]==="O"&&e[t+9]==="N"}function cd(e){if(ed.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}si.exports=td});var ai=L((m0,ii)=>{var ld=/^[-+]?0x[a-fA-F0-9]+$/,dd=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,fd={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function md(e,t={}){if(t=Object.assign({},fd,t),!e||typeof e!="string")return e;let n=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(n))return e;if(e==="0")return 0;if(t.hex&&ld.test(n))return hd(n,16);if(n.search(/[eE]/)!==-1){let r=n.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(r){if(t.leadingZeros)n=(r[1]||"")+r[3];else if(!(r[2]==="0"&&r[3][0]==="."))return e;return t.eNotation?Number(n):e}else return e}else{let r=dd.exec(n);if(r){let s=r[1],o=r[2],i=ud(r[3]);if(!t.leadingZeros&&o.length>0&&s&&n[2]!==".")return e;if(!t.leadingZeros&&o.length>0&&!s&&n[1]!==".")return e;if(t.leadingZeros&&o===e)return 0;{let c=Number(n),a=""+c;return a.search(/[eE]/)!==-1?t.eNotation?c:e:n.indexOf(".")!==-1?a==="0"&&i===""||a===i||s&&a==="-"+i?c:e:o?i===a||s+i===a?c:e:n===a||n===s+a?c:e}}else return e}}function ud(e){return e&&e.indexOf(".")!==-1&&(e=e.replace(/0+$/,""),e==="."?e="0":e[0]==="."?e="0"+e:e[e.length-1]==="."&&(e=e.substr(0,e.length-1))),e}function hd(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}ii.exports=md});var di=L((u0,li)=>{"use strict";var ci=zt(),rt=ri(),yd=oi(),gd=ai(),Pr=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,16))}},this.addExternalEntities=xd,this.parseXml=_d,this.parseTextData=bd,this.resolveNameSpace=Cd,this.buildAttributesMap=Ed,this.isItStopNode=Bd,this.replaceEntitiesValue=wd,this.readStopNodeData=Rd,this.saveTextToParentTag=Ad,this.addChild=Sd}};function xd(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:e[r]}}}function bd(e,t,n,r,s,o,i){if(e!==void 0&&(this.options.trimValues&&!r&&(e=e.trim()),e.length>0)){i||(e=this.replaceEntitiesValue(e));let c=this.options.tagValueProcessor(t,e,n,s,o);return c==null?e:typeof c!=typeof e||c!==e?c:this.options.trimValues?Dr(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?Dr(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function Cd(e){if(this.options.removeNSPrefix){let t=e.split(":"),n=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=n+t[1])}return e}var pd=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Ed(e,t,n){if(!this.options.ignoreAttributes&&typeof e=="string"){let r=ci.getAllMatches(e,pd),s=r.length,o={};for(let i=0;i<s;i++){let c=this.resolveNameSpace(r[i][1]),a=r[i][4],l=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l==="__proto__"&&(l="#__proto__"),a!==void 0){this.options.trimValues&&(a=a.trim()),a=this.replaceEntitiesValue(a);let d=this.options.attributeValueProcessor(c,a,t);d==null?o[l]=a:typeof d!=typeof a||d!==a?o[l]=d:o[l]=Dr(a,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[l]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){let i={};return i[this.options.attributesGroupName]=o,i}return o}}var _d=function(e){e=e.replace(/\r\n?/g,`
`);let t=new rt("!xml"),n=t,r="",s="";for(let o=0;o<e.length;o++)if(e[o]==="<")if(e[o+1]==="/"){let c=be(e,">",o,"Closing Tag is not closed."),a=e.substring(o+2,c).trim();if(this.options.removeNSPrefix){let f=a.indexOf(":");f!==-1&&(a=a.substr(f+1))}this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&(r=this.saveTextToParentTag(r,n,s));let l=s.substring(s.lastIndexOf(".")+1);if(a&&this.options.unpairedTags.indexOf(a)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${a}>`);let d=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(d=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):d=s.lastIndexOf("."),s=s.substring(0,d),n=this.tagsNodeStack.pop(),r="",o=c}else if(e[o+1]==="?"){let c=Nr(e,o,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,s),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){let a=new rt(c.tagName);a.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(a[":@"]=this.buildAttributesMap(c.tagExp,s,c.tagName)),this.addChild(n,a,s)}o=c.closeIndex+1}else if(e.substr(o+1,3)==="!--"){let c=be(e,"-->",o+4,"Comment is not closed.");if(this.options.commentPropName){let a=e.substring(o+4,c-2);r=this.saveTextToParentTag(r,n,s),n.add(this.options.commentPropName,[{[this.options.textNodeName]:a}])}o=c}else if(e.substr(o+1,2)==="!D"){let c=yd(e,o);this.docTypeEntities=c.entities,o=c.i}else if(e.substr(o+1,2)==="!["){let c=be(e,"]]>",o,"CDATA is not closed.")-2,a=e.substring(o+9,c);r=this.saveTextToParentTag(r,n,s);let l=this.parseTextData(a,n.tagname,s,!0,!1,!0,!0);l==null&&(l=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:a}]):n.add(this.options.textNodeName,l),o=c+2}else{let c=Nr(e,o,this.options.removeNSPrefix),a=c.tagName,l=c.rawTagName,d=c.tagExp,f=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,s,!1));let h=n;if(h&&this.options.unpairedTags.indexOf(h.tagname)!==-1&&(n=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),a!==t.tagname&&(s+=s?"."+a:a),this.isItStopNode(this.options.stopNodes,s,a)){let u="";if(d.length>0&&d.lastIndexOf("/")===d.length-1)a[a.length-1]==="/"?(a=a.substr(0,a.length-1),s=s.substr(0,s.length-1),d=a):d=d.substr(0,d.length-1),o=c.closeIndex;else if(this.options.unpairedTags.indexOf(a)!==-1)o=c.closeIndex;else{let y=this.readStopNodeData(e,l,m+1);if(!y)throw new Error(`Unexpected end of ${l}`);o=y.i,u=y.tagContent}let g=new rt(a);a!==d&&f&&(g[":@"]=this.buildAttributesMap(d,s,a)),u&&(u=this.parseTextData(u,a,s,!0,f,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),g.add(this.options.textNodeName,u),this.addChild(n,g,s)}else{if(d.length>0&&d.lastIndexOf("/")===d.length-1){a[a.length-1]==="/"?(a=a.substr(0,a.length-1),s=s.substr(0,s.length-1),d=a):d=d.substr(0,d.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));let u=new rt(a);a!==d&&f&&(u[":@"]=this.buildAttributesMap(d,s,a)),this.addChild(n,u,s),s=s.substr(0,s.lastIndexOf("."))}else{let u=new rt(a);this.tagsNodeStack.push(n),a!==d&&f&&(u[":@"]=this.buildAttributesMap(d,s,a)),this.addChild(n,u,s),n=u}r="",o=m}}else r+=e[o];return t.child};function Sd(e,t,n){let r=this.options.updateTag(t.tagname,n,t[":@"]);r===!1||(typeof r=="string"&&(t.tagname=r),e.addChild(t))}var wd=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let n=this.docTypeEntities[t];e=e.replace(n.regx,n.val)}for(let t in this.lastEntities){let n=this.lastEntities[t];e=e.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let n=this.htmlEntities[t];e=e.replace(n.regex,n.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function Ad(e,t,n,r){return e&&(r===void 0&&(r=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,n,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,r),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function Bd(e,t,n){let r="*."+n;for(let s in e){let o=e[s];if(r===o||t===o)return!0}return!1}function Td(e,t,n=">"){let r,s="";for(let o=t;o<e.length;o++){let i=e[o];if(r)i===r&&(r="");else if(i==='"'||i==="'")r=i;else if(i===n[0])if(n[1]){if(e[o+1]===n[1])return{data:s,index:o}}else return{data:s,index:o};else i===" "&&(i=" ");s+=i}}function be(e,t,n,r){let s=e.indexOf(t,n);if(s===-1)throw new Error(r);return s+t.length-1}function Nr(e,t,n,r=">"){let s=Td(e,t+1,r);if(!s)return;let o=s.data,i=s.index,c=o.search(/\s/),a=o,l=!0;c!==-1&&(a=o.substring(0,c),o=o.substring(c+1).trimStart());let d=a;if(n){let f=a.indexOf(":");f!==-1&&(a=a.substr(f+1),l=a!==s.data.substr(f+1))}return{tagName:a,tagExp:o,closeIndex:i,attrExpPresent:l,rawTagName:d}}function Rd(e,t,n){let r=n,s=1;for(;n<e.length;n++)if(e[n]==="<")if(e[n+1]==="/"){let o=be(e,">",n,`${t} is not closed`);if(e.substring(n+2,o).trim()===t&&(s--,s===0))return{tagContent:e.substring(r,n),i:o};n=o}else if(e[n+1]==="?")n=be(e,"?>",n+1,"StopNode is not closed.");else if(e.substr(n+1,3)==="!--")n=be(e,"-->",n+3,"StopNode is not closed.");else if(e.substr(n+1,2)==="![")n=be(e,"]]>",n,"StopNode is not closed.")-2;else{let o=Nr(e,n,">");o&&((o&&o.tagName)===t&&o.tagExp[o.tagExp.length-1]!=="/"&&s++,n=o.closeIndex)}}function Dr(e,t,n){if(t&&typeof e=="string"){let r=e.trim();return r==="true"?!0:r==="false"?!1:gd(e,n)}else return ci.isExist(e)?e:""}li.exports=Pr});var ui=L(mi=>{"use strict";function kd(e,t){return fi(e,t)}function fi(e,t,n){let r,s={};for(let o=0;o<e.length;o++){let i=e[o],c=Od(i),a="";if(n===void 0?a=c:a=n+"."+c,c===t.textNodeName)r===void 0?r=i[c]:r+=""+i[c];else{if(c===void 0)continue;if(i[c]){let l=fi(i[c],t,a),d=Pd(l,t);i[":@"]?Id(l,i[":@"],a,t):Object.keys(l).length===1&&l[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?l=l[t.textNodeName]:Object.keys(l).length===0&&(t.alwaysCreateTextNode?l[t.textNodeName]="":l=""),s[c]!==void 0&&s.hasOwnProperty(c)?(Array.isArray(s[c])||(s[c]=[s[c]]),s[c].push(l)):t.isArray(c,a,d)?s[c]=[l]:s[c]=l}}}return typeof r=="string"?r.length>0&&(s[t.textNodeName]=r):r!==void 0&&(s[t.textNodeName]=r),s}function Od(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(r!==":@")return r}}function Id(e,t,n,r){if(t){let s=Object.keys(t),o=s.length;for(let i=0;i<o;i++){let c=s[i];r.isArray(c,n+"."+c,!0,!0)?e[c]=[t[c]]:e[c]=t[c]}}}function Pd(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return!!(r===0||r===1&&(e[n]||typeof e[n]=="boolean"||e[n]===0))}mi.prettify=kd});var yi=L((y0,hi)=>{var{buildOptions:Nd}=ti(),Dd=di(),{prettify:vd}=ui(),Md=kr(),vr=class{constructor(t){this.externalEntities={},this.options=Nd(t)}parse(t,n){if(typeof t!="string")if(t.toString)t=t.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});let o=Md.validate(t,n);if(o!==!0)throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`)}let r=new Dd(this.options);r.addExternalEntities(this.externalEntities);let s=r.parseXml(t);return this.options.preserveOrder||s===void 0?s:vd(s,this.options)}addEntity(t,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=n}};hi.exports=vr});var pi=L((g0,Ci)=>{var Ld=`
`;function Fd(e,t){let n="";return t.format&&t.indentBy.length>0&&(n=Ld),xi(e,t,"",n)}function xi(e,t,n,r){let s="",o=!1;for(let i=0;i<e.length;i++){let c=e[i],a=Ud(c);if(a===void 0)continue;let l="";if(n.length===0?l=a:l=`${n}.${a}`,a===t.textNodeName){let u=c[a];$d(l,t)||(u=t.tagValueProcessor(a,u),u=bi(u,t)),o&&(s+=r),s+=u,o=!1;continue}else if(a===t.cdataPropName){o&&(s+=r),s+=`<![CDATA[${c[a][0][t.textNodeName]}]]>`,o=!1;continue}else if(a===t.commentPropName){s+=r+`<!--${c[a][0][t.textNodeName]}-->`,o=!0;continue}else if(a[0]==="?"){let u=gi(c[":@"],t),g=a==="?xml"?"":r,y=c[a][0][t.textNodeName];y=y.length!==0?" "+y:"",s+=g+`<${a}${y}${u}?>`,o=!0;continue}let d=r;d!==""&&(d+=t.indentBy);let f=gi(c[":@"],t),m=r+`<${a}${f}`,h=xi(c[a],t,l,d);t.unpairedTags.indexOf(a)!==-1?t.suppressUnpairedNode?s+=m+">":s+=m+"/>":(!h||h.length===0)&&t.suppressEmptyNode?s+=m+"/>":h&&h.endsWith(">")?s+=m+`>${h}${r}</${a}>`:(s+=m+">",h&&r!==""&&(h.includes("/>")||h.includes("</"))?s+=r+t.indentBy+h+r:s+=h,s+=`</${a}>`),o=!0}return s}function Ud(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(e.hasOwnProperty(r)&&r!==":@")return r}}function gi(e,t){let n="";if(e&&!t.ignoreAttributes)for(let r in e){if(!e.hasOwnProperty(r))continue;let s=t.attributeValueProcessor(r,e[r]);s=bi(s,t),s===!0&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${s}"`}return n}function $d(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let n=e.substr(e.lastIndexOf(".")+1);for(let r in t.stopNodes)if(t.stopNodes[r]===e||t.stopNodes[r]==="*."+n)return!0;return!1}function bi(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){let r=t.entities[n];e=e.replace(r.regex,r.val)}return e}Ci.exports=Fd});var _i=L((x0,Ei)=>{"use strict";var Kd=pi(),qd={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function fe(e){this.options=Object.assign({},qd,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=jd),this.processTextOrObjNode=zd,this.options.format?(this.indentate=Hd,this.tagEndChar=`>
`,this.newLine=`
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}fe.prototype.build=function(e){return this.options.preserveOrder?Kd(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};fe.prototype.j2x=function(e,t){let n="",r="";for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s))if(typeof e[s]>"u")this.isAttribute(s)&&(r+="");else if(e[s]===null)this.isAttribute(s)?r+="":s[0]==="?"?r+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:r+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(e[s]instanceof Date)r+=this.buildTextValNode(e[s],s,"",t);else if(typeof e[s]!="object"){let o=this.isAttribute(s);if(o)n+=this.buildAttrPairStr(o,""+e[s]);else if(s===this.options.textNodeName){let i=this.options.tagValueProcessor(s,""+e[s]);r+=this.replaceEntitiesValue(i)}else r+=this.buildTextValNode(e[s],s,"",t)}else if(Array.isArray(e[s])){let o=e[s].length,i="",c="";for(let a=0;a<o;a++){let l=e[s][a];if(!(typeof l>"u"))if(l===null)s[0]==="?"?r+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:r+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(typeof l=="object")if(this.options.oneListGroup){let d=this.j2x(l,t+1);i+=d.val,this.options.attributesGroupName&&l.hasOwnProperty(this.options.attributesGroupName)&&(c+=d.attrStr)}else i+=this.processTextOrObjNode(l,s,t);else if(this.options.oneListGroup){let d=this.options.tagValueProcessor(s,l);d=this.replaceEntitiesValue(d),i+=d}else i+=this.buildTextValNode(l,s,"",t)}this.options.oneListGroup&&(i=this.buildObjectNode(i,s,c,t)),r+=i}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName){let o=Object.keys(e[s]),i=o.length;for(let c=0;c<i;c++)n+=this.buildAttrPairStr(o[c],""+e[s][o[c]])}else r+=this.processTextOrObjNode(e[s],s,t);return{attrStr:n,val:r}};fe.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t==="true"?" "+e:" "+e+'="'+t+'"'};function zd(e,t,n){let r=this.j2x(e,n+1);return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,r.attrStr,n):this.buildObjectNode(r.val,t,r.attrStr,n)}fe.prototype.buildObjectNode=function(e,t,n,r){if(e==="")return t[0]==="?"?this.indentate(r)+"<"+t+n+"?"+this.tagEndChar:this.indentate(r)+"<"+t+n+this.closeTag(t)+this.tagEndChar;{let s="</"+t+this.tagEndChar,o="";return t[0]==="?"&&(o="?",s=""),(n||n==="")&&e.indexOf("<")===-1?this.indentate(r)+"<"+t+n+o+">"+e+s:this.options.commentPropName!==!1&&t===this.options.commentPropName&&o.length===0?this.indentate(r)+`<!--${e}-->`+this.newLine:this.indentate(r)+"<"+t+n+o+this.tagEndChar+e+this.indentate(r)+s}};fe.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};fe.prototype.buildTextValNode=function(e,t,n,r){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(r)+`<!--${e}-->`+this.newLine;if(t[0]==="?")return this.indentate(r)+"<"+t+n+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(t,e);return s=this.replaceEntitiesValue(s),s===""?this.indentate(r)+"<"+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+"<"+t+n+">"+s+"</"+t+this.tagEndChar}};fe.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};function Hd(e){return this.options.indentBy.repeat(e)}function jd(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}Ei.exports=fe});var wi=L((b0,Si)=>{"use strict";var Gd=kr(),Vd=yi(),Wd=_i();Si.exports={XMLParser:Vd,XMLValidator:Gd,XMLBuilder:Wd}});var ah={};M(ah,{S3Datastore:()=>ao});var lo;(function(e){e.HEADER="header",e.QUERY="query"})(lo||(lo={}));var dr;(function(e){e.HEADER="header",e.QUERY="query"})(dr||(dr={}));var fo;(function(e){e.HTTP="http",e.HTTPS="https"})(fo||(fo={}));var Dt;(function(e){e.MD5="md5",e.CRC32="crc32",e.CRC32C="crc32c",e.SHA1="sha1",e.SHA256="sha256"})(Dt||(Dt={}));var fr;(function(e){e[e.HEADER=0]="HEADER",e[e.TRAILER=1]="TRAILER"})(fr||(fr={}));var Se="__smithy_context";var mo;(function(e){e.PROFILE="profile",e.SSO_SESSION="sso-session",e.SERVICES="services"})(mo||(mo={}));var uo;(function(e){e.HTTP_0_9="http/0.9",e.HTTP_1_0="http/1.0",e.TDS_8_0="tds/8.0"})(uo||(uo={}));var O=class e{constructor(t){this.method=t.method||"GET",this.hostname=t.hostname||"localhost",this.port=t.port,this.query=t.query||{},this.headers=t.headers||{},this.body=t.body,this.protocol=t.protocol?t.protocol.slice(-1)!==":"?`${t.protocol}:`:t.protocol:"https:",this.path=t.path?t.path.charAt(0)!=="/"?`/${t.path}`:t.path:"/",this.username=t.username,this.password=t.password,this.fragment=t.fragment}static clone(t){let n=new e({...t,headers:{...t.headers}});return n.query&&(n.query=Vc(n.query)),n}static isInstance(t){if(!t)return!1;let n=t;return"method"in n&&"protocol"in n&&"hostname"in n&&"path"in n&&typeof n.query=="object"&&typeof n.headers=="object"}clone(){return e.clone(this)}};function Vc(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return{...t,[n]:Array.isArray(r)?[...r]:r}},{})}var X=class{constructor(t){this.statusCode=t.statusCode,this.reason=t.reason,this.headers=t.headers||{},this.body=t.body}static isInstance(t){if(!t)return!1;let n=t;return typeof n.statusCode=="number"&&typeof n.headers=="object"}};var z={WHEN_SUPPORTED:"WHEN_SUPPORTED",WHEN_REQUIRED:"WHEN_REQUIRED"},yo=z.WHEN_SUPPORTED,ze={WHEN_SUPPORTED:"WHEN_SUPPORTED",WHEN_REQUIRED:"WHEN_REQUIRED"},go=z.WHEN_SUPPORTED,C;(function(e){e.MD5="MD5",e.CRC32="CRC32",e.CRC32C="CRC32C",e.CRC64NVME="CRC64NVME",e.SHA1="SHA1",e.SHA256="SHA256"})(C||(C={}));var ho;(function(e){e.HEADER="header",e.TRAILER="trailer"})(ho||(ho={}));var He=C.CRC32;var vt;(function(e){e.ENV="env",e.CONFIG="shared config entry"})(vt||(vt={}));var mr={CrtCrc64Nvme:null};function K(e,t,n){e.__aws_sdk_context?e.__aws_sdk_context.features||(e.__aws_sdk_context.features={}):e.__aws_sdk_context={features:{}},e.__aws_sdk_context.features[t]=n}var je=e=>e[Se]||(e[Se]={});var xo=(e,t)=>(n,r)=>async s=>{let{response:o}=await n(s);try{let i=await t(o,e);return{response:o,output:i}}catch(i){if(Object.defineProperty(i,"$response",{value:o}),!("$metadata"in i)){let c="Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.";try{i.message+=`
`+c}catch{!r.logger||r.logger?.constructor?.name==="NoOpLogger"?console.warn(c):r.logger?.warn?.(c)}typeof i.$responseBodyText<"u"&&i.$response&&(i.$response.body=i.$responseBodyText);try{if(X.isInstance(o)){let{headers:a={}}=o,l=Object.entries(a);i.$metadata={httpStatusCode:o.statusCode,requestId:ur(/^x-[\w-]+-request-?id$/,l),extendedRequestId:ur(/^x-[\w-]+-id-2$/,l),cfId:ur(/^x-[\w-]+-cf-id$/,l)}}}catch{}}throw i}},ur=(e,t)=>(t.find(([n])=>n.match(e))||[void 0,void 0])[1];var bo=(e,t)=>(n,r)=>async s=>{let o=e,i=r.endpointV2?.url&&o.urlParser?async()=>o.urlParser(r.endpointV2.url):o.endpoint;if(!i)throw new Error("No valid endpoint provider available.");let c=await t(s.input,{...e,endpoint:i});return n({...s,request:c})};var Qc={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:!0},Ge={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0};function F(e,t,n){return{applyToStack:r=>{r.add(xo(e,n),Qc),r.add(bo(e,t),Ge)}}}var Dg={step:"serialize",tags:["HTTP_AUTH_SCHEME"],name:"httpAuthSchemeMiddleware",override:!0,relation:"before",toMiddleware:Ge.name};var Q={},ue=new Array(64);for(let e=0,t=65,n=90;e+t<=n;e++){let r=String.fromCharCode(e+t);Q[r]=e,ue[e]=r}for(let e=0,t=97,n=122;e+t<=n;e++){let r=String.fromCharCode(e+t),s=e+26;Q[r]=s,ue[s]=r}for(let e=0;e<10;e++){Q[e.toString(10)]=e+52;let t=e.toString(10),n=e+52;Q[t]=n,ue[n]=t}Q["+"]=62;ue[62]="+";Q["/"]=63;ue[63]="/";var oe=6,he=8,Co=63;var hr=e=>{let t=e.length/4*3;e.slice(-2)==="=="?t-=2:e.slice(-1)==="="&&t--;let n=new ArrayBuffer(t),r=new DataView(n);for(let s=0;s<e.length;s+=4){let o=0,i=0;for(let l=s,d=s+3;l<=d;l++)if(e[l]!=="="){if(!(e[l]in Q))throw new TypeError(`Invalid character ${e[l]} in base64 string.`);o|=Q[e[l]]<<(d-l)*oe,i+=oe}else o>>=oe;let c=s/4*3;o>>=i%he;let a=Math.floor(i/he);for(let l=0;l<a;l++){let d=(a-l-1)*he;r.setUint8(c+l,(o&255<<d)>>d)}}return new Uint8Array(n)};var ye=e=>new TextEncoder().encode(e);var we=e=>typeof e=="string"?ye(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e);var yr=e=>{if(typeof e=="string")return e;if(typeof e!="object"||typeof e.byteOffset!="number"||typeof e.byteLength!="number")throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return new TextDecoder("utf-8").decode(e)};function Ve(e){let t;typeof e=="string"?t=ye(e):t=e;let n=typeof t=="object"&&typeof t.length=="number",r=typeof t=="object"&&typeof t.byteOffset=="number"&&typeof t.byteLength=="number";if(!n&&!r)throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");let s="";for(let o=0;o<t.length;o+=3){let i=0,c=0;for(let l=o,d=Math.min(o+3,t.length);l<d;l++)i|=t[l]<<(d-l-1)*he,c+=he;let a=Math.ceil(c/oe);i<<=a*oe-c;for(let l=1;l<=a;l++){let d=(a-l)*oe;s+=ue[(i&Co<<d)>>d]}s+="==".slice(0,4-a)}return s}function po(e,t="utf-8"){return t==="base64"?Ve(e):yr(e)}function Eo(e,t){return t==="base64"?Y.mutate(hr(e)):Y.mutate(ye(e))}var Y=class e extends Uint8Array{static fromString(t,n="utf-8"){switch(typeof t){case"string":return Eo(t,n);default:throw new Error(`Unsupported conversion from ${typeof t} to Uint8ArrayBlobAdapter.`)}}static mutate(t){return Object.setPrototypeOf(t,e.prototype),t}transformToString(t="utf-8"){return po(this,t)}};var Yc=typeof ReadableStream=="function"?ReadableStream:function(){},Mt=class extends Yc{};var gr=e=>typeof ReadableStream=="function"&&(e?.constructor?.name===ReadableStream.name||e instanceof ReadableStream);var _o=({expectedChecksum:e,checksum:t,source:n,checksumSourceLocation:r,base64Encoder:s})=>{if(!gr(n))throw new Error(`@smithy/util-stream: unsupported source type ${n?.constructor?.name??n} in ChecksumStream.`);let o=s??Ve;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(a,l){t.update(a),l.enqueue(a)},async flush(a){let l=await t.digest(),d=o(l);if(e!==d){let f=new Error(`Checksum mismatch: expected "${e}" but received "${d}" in response header "${r}".`);a.error(f)}else a.terminate()}});n.pipeThrough(i);let c=i.readable;return Object.setPrototypeOf(c,Mt.prototype),c};var Lt=class{constructor(t){this.allocByteArray=t,this.byteLength=0,this.byteArrays=[]}push(t){this.byteArrays.push(t),this.byteLength+=t.byteLength}flush(){if(this.byteArrays.length===1){let r=this.byteArrays[0];return this.reset(),r}let t=this.allocByteArray(this.byteLength),n=0;for(let r=0;r<this.byteArrays.length;++r){let s=this.byteArrays[r];t.set(s,n),n+=s.byteLength}return this.reset(),t}reset(){this.byteArrays=[],this.byteLength=0}};function Zc(e,t,n){let r=e.getReader(),s=!1,o=0,i=["",new Lt(l=>new Uint8Array(l))],c=-1,a=async l=>{let{value:d,done:f}=await r.read(),m=d;if(f){if(c!==-1){let h=xr(i,c);We(h)>0&&l.enqueue(h)}l.close()}else{let h=el(m,!1);if(c!==h&&(c>=0&&l.enqueue(xr(i,c)),c=h),c===-1){l.enqueue(m);return}let u=We(m);o+=u;let g=We(i[c]);if(u>=t&&g===0)l.enqueue(m);else{let y=Jc(i,c,m);!s&&o>t*2&&(s=!0,n?.warn(`@smithy/util-stream - stream chunk size ${u} is below threshold of ${t}, automatically buffering.`)),y>=t?l.enqueue(xr(i,c)):await a(l)}}};return new ReadableStream({pull:a})}var So=Zc;function Jc(e,t,n){switch(t){case 0:return e[0]+=n,We(e[0]);case 1:case 2:return e[t].push(n),We(e[t])}}function xr(e,t){switch(t){case 0:let n=e[0];return e[0]="",n;case 1:case 2:return e[t].flush()}throw new Error(`@smithy/util-stream - invalid index ${t} given to flush()`)}function We(e){return e?.byteLength??e?.length??0}function el(e,t=!0){return t&&typeof Buffer<"u"&&e instanceof Buffer?2:e instanceof Uint8Array?1:typeof e=="string"?0:-1}async function wo(e,t){let n=0,r=[],s=e.getReader(),o=!1;for(;!o;){let{done:a,value:l}=await s.read();if(l&&(r.push(l),n+=l?.byteLength??0),n>=t)break;o=a}s.releaseLock();let i=new Uint8Array(Math.min(t,n)),c=0;for(let a of r){if(a.byteLength>i.byteLength-c){i.set(a.subarray(0,i.byteLength-c),c);break}else i.set(a,c);c+=a.length}return i}var tl={},nl={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),tl[e]=t,nl[t]=e}async function Ao(e){return typeof e.stream=="function"&&(e=e.stream()),e.tee()}var ie=async(e=new Uint8Array,t)=>{if(e instanceof Uint8Array)return Y.mutate(e);if(!e)return Y.mutate(new Uint8Array);let n=t.streamCollector(e);return Y.mutate(await n)};function Ft(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}var Cr=(e,t,n,r,s,o)=>{if(t!=null&&t[n]!==void 0){let i=r();if(i.length<=0)throw new Error("Empty value provided for input HTTP label: "+n+".");e=e.replace(s,o?i.split("/").map(c=>Ft(c)).join("/"):Ft(i))}else throw new Error("No value provided for input HTTP label: "+n+".");return e};function ae(e,t){return new pr(e,t)}var pr=class{constructor(t,n){this.input=t,this.context=n,this.query={},this.method="",this.headers={},this.path="",this.body=null,this.hostname="",this.resolvePathStack=[]}async build(){let{hostname:t,protocol:n="https",port:r,path:s}=await this.context.endpoint();this.path=s;for(let o of this.resolvePathStack)o(this.path);return new O({protocol:n,hostname:this.hostname||t,port:r,method:this.method,path:this.path,query:this.query,body:this.body,headers:this.headers})}hn(t){return this.hostname=t,this}bp(t){return this.resolvePathStack.push(n=>{this.path=`${n?.endsWith("/")?n.slice(0,-1):n||""}`+t}),this}p(t,n,r,s){return this.resolvePathStack.push(o=>{this.path=Cr(o,this.input,t,n,r,s)}),this}h(t){return this.headers=t,this}q(t){return this.query=t,this}b(t){return this.body=t,this}m(t){return this.method=t,this}};function Bo(e,t,n){e.__smithy_context?e.__smithy_context.features||(e.__smithy_context.features={}):e.__smithy_context={features:{}},e.__smithy_context.features[t]=n}var rl=e=>t=>sl(t)&&t.expiration.getTime()-Date.now()<e;var Wb=rl(3e5),sl=e=>e.expiration!==void 0;var To="X-Amz-Date";var Ro="X-Amz-Signature",ko="X-Amz-Security-Token";var ol=To.toLowerCase();var il=Ro.toLowerCase();var al=ko.toLowerCase();var cl=60*60*24*7;var Er=e=>typeof ArrayBuffer=="function"&&e instanceof ArrayBuffer||Object.prototype.toString.call(e)==="[object ArrayBuffer]";var Oo;(function(e){e[e.boolTrue=0]="boolTrue",e[e.boolFalse=1]="boolFalse",e[e.byte=2]="byte",e[e.short=3]="short",e[e.integer=4]="integer",e[e.long=5]="long",e[e.byteArray=6]="byteArray",e[e.string=7]="string",e[e.timestamp=8]="timestamp",e[e.uuid=9]="uuid"})(Oo||(Oo={}));var ge=(e,t)=>{let n=[];if(e&&n.push(e),t)for(let r of t)n.push(r);return n},ce=(e,t)=>`${e||"anonymous"}${t&&t.length>0?` (a.k.a. ${t.join(",")})`:""}`,Qe=()=>{let e=[],t=[],n=!1,r=new Set,s=f=>f.sort((m,h)=>Po[h.step]-Po[m.step]||No[h.priority||"normal"]-No[m.priority||"normal"]),o=f=>{let m=!1,h=u=>{let g=ge(u.name,u.aliases);if(g.includes(f)){m=!0;for(let y of g)r.delete(y);return!1}return!0};return e=e.filter(h),t=t.filter(h),m},i=f=>{let m=!1,h=u=>{if(u.middleware===f){m=!0;for(let g of ge(u.name,u.aliases))r.delete(g);return!1}return!0};return e=e.filter(h),t=t.filter(h),m},c=f=>(e.forEach(m=>{f.add(m.middleware,{...m})}),t.forEach(m=>{f.addRelativeTo(m.middleware,{...m})}),f.identifyOnResolve?.(d.identifyOnResolve()),f),a=f=>{let m=[];return f.before.forEach(h=>{h.before.length===0&&h.after.length===0?m.push(h):m.push(...a(h))}),m.push(f),f.after.reverse().forEach(h=>{h.before.length===0&&h.after.length===0?m.push(h):m.push(...a(h))}),m},l=(f=!1)=>{let m=[],h=[],u={};return e.forEach(y=>{let x={...y,before:[],after:[]};for(let b of ge(x.name,x.aliases))u[b]=x;m.push(x)}),t.forEach(y=>{let x={...y,before:[],after:[]};for(let b of ge(x.name,x.aliases))u[b]=x;h.push(x)}),h.forEach(y=>{if(y.toMiddleware){let x=u[y.toMiddleware];if(x===void 0){if(f)return;throw new Error(`${y.toMiddleware} is not found when adding ${ce(y.name,y.aliases)} middleware ${y.relation} ${y.toMiddleware}`)}y.relation==="after"&&x.after.push(y),y.relation==="before"&&x.before.push(y)}}),s(m).map(a).reduce((y,x)=>(y.push(...x),y),[])},d={add:(f,m={})=>{let{name:h,override:u,aliases:g}=m,y={step:"initialize",priority:"normal",middleware:f,...m},x=ge(h,g);if(x.length>0){if(x.some(b=>r.has(b))){if(!u)throw new Error(`Duplicate middleware name '${ce(h,g)}'`);for(let b of x){let S=e.findIndex(B=>B.name===b||B.aliases?.some(I=>I===b));if(S===-1)continue;let E=e[S];if(E.step!==y.step||y.priority!==E.priority)throw new Error(`"${ce(E.name,E.aliases)}" middleware with ${E.priority} priority in ${E.step} step cannot be overridden by "${ce(h,g)}" middleware with ${y.priority} priority in ${y.step} step.`);e.splice(S,1)}}for(let b of x)r.add(b)}e.push(y)},addRelativeTo:(f,m)=>{let{name:h,override:u,aliases:g}=m,y={middleware:f,...m},x=ge(h,g);if(x.length>0){if(x.some(b=>r.has(b))){if(!u)throw new Error(`Duplicate middleware name '${ce(h,g)}'`);for(let b of x){let S=t.findIndex(B=>B.name===b||B.aliases?.some(I=>I===b));if(S===-1)continue;let E=t[S];if(E.toMiddleware!==y.toMiddleware||E.relation!==y.relation)throw new Error(`"${ce(E.name,E.aliases)}" middleware ${E.relation} "${E.toMiddleware}" middleware cannot be overridden by "${ce(h,g)}" middleware ${y.relation} "${y.toMiddleware}" middleware.`);t.splice(S,1)}}for(let b of x)r.add(b)}t.push(y)},clone:()=>c(Qe()),use:f=>{f.applyToStack(d)},remove:f=>typeof f=="string"?o(f):i(f),removeByTag:f=>{let m=!1,h=u=>{let{tags:g,name:y,aliases:x}=u;if(g&&g.includes(f)){let b=ge(y,x);for(let S of b)r.delete(S);return m=!0,!1}return!0};return e=e.filter(h),t=t.filter(h),m},concat:f=>{let m=c(Qe());return m.use(f),m.identifyOnResolve(n||m.identifyOnResolve()||(f.identifyOnResolve?.()??!1)),m},applyToStack:c,identify:()=>l(!0).map(f=>{let m=f.step??f.relation+" "+f.toMiddleware;return ce(f.name,f.aliases)+" - "+m}),identifyOnResolve(f){return typeof f=="boolean"&&(n=f),n},resolve:(f,m)=>{for(let h of l().map(u=>u.middleware).reverse())f=h(f,m);return n&&console.log(d.identify()),f}};return d},Po={initialize:5,serialize:4,build:3,finalizeRequest:2,deserialize:1},No={high:3,normal:2,low:1};var N=class{constructor(){this.middlewareStack=Qe()}static classBuilder(){return new _r}resolveMiddlewareWithContext(t,n,r,{middlewareFn:s,clientName:o,commandName:i,inputFilterSensitiveLog:c,outputFilterSensitiveLog:a,smithyContext:l,additionalContext:d,CommandCtor:f}){for(let y of s.bind(this)(f,t,n,r))this.middlewareStack.use(y);let m=t.concat(this.middlewareStack),{logger:h}=n,u={logger:h,clientName:o,commandName:i,inputFilterSensitiveLog:c,outputFilterSensitiveLog:a,[Se]:{commandInstance:this,...l},...d},{requestHandler:g}=n;return m.resolve(y=>g.handle(y.request,r||{}),u)}},_r=class{constructor(){this._init=()=>{},this._ep={},this._middlewareFn=()=>[],this._commandName="",this._clientName="",this._additionalContext={},this._smithyContext={},this._inputFilterSensitiveLog=t=>t,this._outputFilterSensitiveLog=t=>t,this._serializer=null,this._deserializer=null}init(t){this._init=t}ep(t){return this._ep=t,this}m(t){return this._middlewareFn=t,this}s(t,n,r={}){return this._smithyContext={service:t,operation:n,...r},this}c(t={}){return this._additionalContext=t,this}n(t,n){return this._clientName=t,this._commandName=n,this}f(t=r=>r,n=r=>r){return this._inputFilterSensitiveLog=t,this._outputFilterSensitiveLog=n,this}ser(t){return this._serializer=t,this}de(t){return this._deserializer=t,this}build(){let t=this,n;return n=class extends N{static getEndpointParameterInstructions(){return t._ep}constructor(...[r]){super(),this.serialize=t._serializer,this.deserialize=t._deserializer,this.input=r??{},t._init(this)}resolveMiddleware(r,s,o){return this.resolveMiddlewareWithContext(r,s,o,{CommandCtor:n,middlewareFn:t._middlewareFn,clientName:t._clientName,commandName:t._commandName,inputFilterSensitiveLog:t._inputFilterSensitiveLog,outputFilterSensitiveLog:t._outputFilterSensitiveLog,smithyContext:t._smithyContext,additionalContext:t._additionalContext})}}}};var q="***SensitiveInformation***";var Ut=class e extends Error{constructor(t){super(t.message),Object.setPrototypeOf(this,Object.getPrototypeOf(this).constructor.prototype),this.name=t.name,this.$fault=t.$fault,this.$metadata=t.$metadata}static isInstance(t){if(!t)return!1;let n=t;return e.prototype.isPrototypeOf(n)||!!n.$fault&&!!n.$metadata&&(n.$fault==="client"||n.$fault==="server")}static[Symbol.hasInstance](t){if(!t)return!1;let n=t;return this===e?e.isInstance(t):e.isInstance(t)?n.name&&this.name?this.prototype.isPrototypeOf(t)||n.name===this.name:this.prototype.isPrototypeOf(t):!1}},P=(e,t={})=>{Object.entries(t).filter(([,r])=>r!==void 0).forEach(([r,s])=>{(e[r]==null||e[r]==="")&&(e[r]=s)});let n=e.message||e.Message||"UnknownError";return e.message=n,delete e.Message,e};var xl=({output:e,parsedBody:t,exceptionCtor:n,errorCode:r})=>{let s=bl(e),o=s.httpStatusCode?s.httpStatusCode+"":void 0,i=new n({name:t?.code||t?.Code||r||o||"UnknownError",$fault:"client",$metadata:s});throw P(i,t)},Do=e=>({output:t,parsedBody:n,errorCode:r})=>{xl({output:t,parsedBody:n,exceptionCtor:e,errorCode:r})},bl=e=>({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"]});var $t=e=>Array.isArray(e)?e:[e];var Sr=e=>{let t="#text";for(let n in e)e.hasOwnProperty(n)&&e[n][t]!==void 0?e[n]=e[n][t]:typeof e[n]=="object"&&e[n]!==null&&(e[n]=Sr(e[n]));return e};var w=e=>e!=null;var Kt=class{trace(){}debug(){}info(){}warn(){}error(){}};function p(e,t,n){let r,s,o;if(typeof t>"u"&&typeof n>"u")r={},o=e;else{if(r=e,typeof t=="function")return s=t,o=n,Cl(r,s,o);o=t}for(let i of Object.keys(o)){if(!Array.isArray(o[i])){r[i]=o[i];continue}pl(r,null,o,i)}return r}var Cl=(e,t,n)=>p(e,Object.entries(n).reduce((r,[s,o])=>(Array.isArray(o)?r[s]=o:typeof o=="function"?r[s]=[t,o()]:r[s]=[t,o],r),{})),pl=(e,t,n,r)=>{if(t!==null){let i=n[r];typeof i=="function"&&(i=[,i]);let[c=El,a=_l,l=r]=i;(typeof c=="function"&&c(t[l])||typeof c!="function"&&c)&&(e[r]=a(t[l]));return}let[s,o]=n[r];if(typeof o=="function"){let i,c=s===void 0&&(i=o())!=null,a=typeof s=="function"&&!!s(void 0)||typeof s!="function"&&!!s;c?e[r]=i:a&&(e[r]=o())}else{let i=s===void 0&&o!=null,c=typeof s=="function"&&!!s(o)||typeof s!="function"&&!!s;(i||c)&&(e[r]=o)}},El=e=>e!=null,_l=e=>e;var vo=e=>e.toISOString().replace(".000Z","Z");var Z=e=>{switch(e){case"true":return!0;case"false":return!1;default:throw new Error(`Unable to parse boolean value "${e}"`)}};var Sl=e=>{if(e!=null){if(typeof e=="string"){let t=parseFloat(e);if(!Number.isNaN(t))return String(t)!==String(e)&&Ho.warn(zo(`Expected number but observed string: ${e}`)),t}if(typeof e=="number")return e;throw new TypeError(`Expected number, got ${typeof e}: ${e}`)}},wl=Math.ceil(34028234663852886e22),Mo=e=>{let t=Sl(e);if(t!==void 0&&!Number.isNaN(t)&&t!==1/0&&t!==-1/0&&Math.abs(t)>wl)throw new TypeError(`Expected 32-bit float, got ${e}`);return t},wr=e=>{if(e!=null){if(Number.isInteger(e)&&!Number.isNaN(e))return e;throw new TypeError(`Expected integer, got ${typeof e}: ${e}`)}};var Lo=e=>Ar(e,32),Fo=e=>Ar(e,16),Uo=e=>Ar(e,8),Ar=(e,t)=>{let n=wr(e);if(n!==void 0&&Al(n,t)!==n)throw new TypeError(`Expected ${t}-bit integer, got ${e}`);return n},Al=(e,t)=>{switch(t){case 32:return Int32Array.of(e)[0];case 16:return Int16Array.of(e)[0];case 8:return Int8Array.of(e)[0]}},H=(e,t)=>{if(e==null)throw t?new TypeError(`Expected a non-null value for ${t}`):new TypeError("Expected a non-null value");return e},$o=e=>{if(e==null)return;if(typeof e=="object"&&!Array.isArray(e))return e;let t=Array.isArray(e)?"array":typeof e;throw new TypeError(`Expected object, got ${t}: ${e}`)},k=e=>{if(e!=null){if(typeof e=="string")return e;if(["boolean","number","bigint"].includes(typeof e))return Ho.warn(zo(`Expected string, got ${typeof e}: ${e}`)),String(e);throw new TypeError(`Expected string, got ${typeof e}: ${e}`)}};var Ko=e=>Mo(typeof e=="string"?Ye(e):e),Bl=/(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|(-?Infinity)|(NaN)/g,Ye=e=>{let t=e.match(Bl);if(t===null||t[0].length!==e.length)throw new TypeError("Expected real number, got implicit NaN");return parseFloat(e)};var Ze=e=>wr(typeof e=="string"?Ye(e):e);var le=e=>Lo(typeof e=="string"?Ye(e):e),Je=e=>Fo(typeof e=="string"?Ye(e):e),qo=e=>Uo(typeof e=="string"?Ye(e):e),zo=e=>String(new TypeError(e).stack||e).split(`
`).slice(0,5).filter(t=>!t.includes("stackTraceWarning")).join(`
`),Ho={warn:console.warn};var Tl=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Tr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function J(e){let t=e.getUTCFullYear(),n=e.getUTCMonth(),r=e.getUTCDay(),s=e.getUTCDate(),o=e.getUTCHours(),i=e.getUTCMinutes(),c=e.getUTCSeconds(),a=s<10?`0${s}`:`${s}`,l=o<10?`0${o}`:`${o}`,d=i<10?`0${i}`:`${i}`,f=c<10?`0${c}`:`${c}`;return`${Tl[r]}, ${a} ${Tr[n]} ${t} ${l}:${d}:${f} GMT`}var SE=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/);var Rl=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}\:\d{2})|[zZ])$/),tt=e=>{if(e==null)return;if(typeof e!="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let t=Rl.exec