@slycode/slycode 0.2.9 → 0.2.11

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.
Files changed (74) hide show
  1. package/dist/web/.next/BUILD_ID +1 -1
  2. package/dist/web/.next/build-manifest.json +2 -2
  3. package/dist/web/.next/server/app/_global-error.html +2 -2
  4. package/dist/web/.next/server/app/_global-error.rsc +1 -1
  5. package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  8. package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  9. package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/dist/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/dist/web/.next/server/app/_not-found.html +1 -1
  12. package/dist/web/.next/server/app/_not-found.rsc +10 -10
  13. package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +10 -10
  14. package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  15. package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +5 -5
  16. package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  17. package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  18. package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  19. package/dist/web/.next/server/app/api/cli-assets/assistant/route.js.nft.json +1 -1
  20. package/dist/web/.next/server/app/api/cli-assets/fix/route.js.nft.json +1 -1
  21. package/dist/web/.next/server/app/api/cli-assets/import/route.js.nft.json +1 -1
  22. package/dist/web/.next/server/app/api/cli-assets/route.js.nft.json +1 -1
  23. package/dist/web/.next/server/app/api/cli-assets/store/preview/route.js.nft.json +1 -1
  24. package/dist/web/.next/server/app/api/cli-assets/store/route.js.nft.json +1 -1
  25. package/dist/web/.next/server/app/api/cli-assets/sync/route.js.nft.json +1 -1
  26. package/dist/web/.next/server/app/api/cli-assets/updates/route.js.nft.json +1 -1
  27. package/dist/web/.next/server/app/api/dashboard/route.js.nft.json +1 -1
  28. package/dist/web/.next/server/app/api/file/route.js.nft.json +1 -1
  29. package/dist/web/.next/server/app/api/git-status/route.js.nft.json +1 -1
  30. package/dist/web/.next/server/app/api/kanban/route.js.nft.json +1 -1
  31. package/dist/web/.next/server/app/api/kanban/stream/route.js.nft.json +1 -1
  32. package/dist/web/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
  33. package/dist/web/.next/server/app/api/projects/reorder/route.js.nft.json +1 -1
  34. package/dist/web/.next/server/app/api/projects/route.js.nft.json +1 -1
  35. package/dist/web/.next/server/app/api/scheduler/route.js.nft.json +1 -1
  36. package/dist/web/.next/server/app/api/search/route.js.nft.json +1 -1
  37. package/dist/web/.next/server/app/api/sly-actions/invalidate/route.js.nft.json +1 -1
  38. package/dist/web/.next/server/app/api/sly-actions/route.js.nft.json +1 -1
  39. package/dist/web/.next/server/app/api/transcribe/route.js +3 -3
  40. package/dist/web/.next/server/app/api/transcribe/route.js.nft.json +1 -1
  41. package/dist/web/.next/server/app/api/version-check/route.js.nft.json +1 -1
  42. package/dist/web/.next/server/app/page.js.nft.json +1 -1
  43. package/dist/web/.next/server/app/page_client-reference-manifest.js +1 -1
  44. package/dist/web/.next/server/app/project/[id]/page.js.nft.json +1 -1
  45. package/dist/web/.next/server/app/project/[id]/page_client-reference-manifest.js +1 -1
  46. package/dist/web/.next/server/chunks/{[root-of-the-server]__934c9bb4._.js → [root-of-the-server]__0f9b71fd._.js} +1 -1
  47. package/dist/web/.next/server/chunks/[root-of-the-server]__1dec5018._.js +3 -0
  48. package/dist/web/.next/server/chunks/{[root-of-the-server]__e00fb85f._.js → [root-of-the-server]__2605d761._.js} +1 -1
  49. package/dist/web/.next/server/chunks/{[root-of-the-server]__41df0777._.js → [root-of-the-server]__53ef96b9._.js} +2 -2
  50. package/dist/web/.next/server/chunks/{[root-of-the-server]__1cdc76ef._.js → [root-of-the-server]__8ce673c9._.js} +2 -2
  51. package/dist/web/.next/server/chunks/[root-of-the-server]__a43db24d._.js +19 -0
  52. package/dist/web/.next/server/chunks/{[root-of-the-server]__104b2da3._.js → [root-of-the-server]__a4d171b5._.js} +3 -3
  53. package/dist/web/.next/server/chunks/{[root-of-the-server]__3dc5531f._.js → [root-of-the-server]__c7ac3578._.js} +1 -1
  54. package/dist/web/.next/server/chunks/ssr/src_contexts_VoiceContext_tsx_cfba7292._.js +1 -1
  55. package/dist/web/.next/server/pages/404.html +1 -1
  56. package/dist/web/.next/server/pages/500.html +2 -2
  57. package/dist/web/.next/static/chunks/3df3846316317676.css +1 -0
  58. package/dist/web/.next/static/chunks/{0452f599128364c9.js → 8fb2a99c64580de7.js} +1 -1
  59. package/dist/web/.next/static/chunks/{2a22edae0b1198eb.js → b8e0c1aeea4a14bc.js} +1 -1
  60. package/dist/web/package-lock.json +37 -0
  61. package/dist/web/package.json +1 -0
  62. package/dist/web/src/app/api/transcribe/route.ts +7 -1
  63. package/dist/web/src/components/VoiceControlBar.tsx +1 -0
  64. package/dist/web/src/hooks/useVoiceRecorder.ts +7 -5
  65. package/dist/web/src/lib/webm-to-ogg-opus.ts +254 -0
  66. package/dist/web/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +1 -1
  68. package/templates/kanban-seed.json +1 -1
  69. package/dist/web/.next/server/chunks/[root-of-the-server]__3998d59e._.js +0 -19
  70. package/dist/web/.next/server/chunks/[root-of-the-server]__403750fd._.js +0 -3
  71. package/dist/web/.next/static/chunks/f3d7065d54a0b9ac.css +0 -1
  72. /package/dist/web/.next/static/{wK5osty7Iax92ZOE_Skb7 → eGpcv9LfmamGIm1II8SKL}/_buildManifest.js +0 -0
  73. /package/dist/web/.next/static/{wK5osty7Iax92ZOE_Skb7 → eGpcv9LfmamGIm1II8SKL}/_clientMiddlewareManifest.json +0 -0
  74. /package/dist/web/.next/static/{wK5osty7Iax92ZOE_Skb7 → eGpcv9LfmamGIm1II8SKL}/_ssgManifest.js +0 -0
@@ -0,0 +1,19 @@
1
+ module.exports=[37374,e=>{e.v({name:"@aws-sdk/client-transcribe-streaming",description:"AWS SDK for JavaScript Transcribe Streaming Client for Node.js, Browser and React Native",version:"3.1012.0",scripts:{build:"concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs","build:cjs":"node ../../scripts/compilation/inline client-transcribe-streaming","build:es":"tsc -p tsconfig.es.json","build:include:deps":'yarn g:turbo run build -F="$npm_package_name"',"build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo transcribe-streaming",test:"yarn g:vitest run --passWithNoTests","test:browser":"yarn g:vitest run -c vitest.config.browser.e2e.mts","test:browser:watch":"yarn g:vitest watch -c vitest.config.browser.e2e.mts","test:e2e":"yarn g:vitest run -c vitest.config.e2e.mts --mode development","test:e2e:watch":"yarn g:vitest watch -c vitest.config.e2e.mts","test:index":"tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs","test:integration":"yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts","test:integration:watch":"yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts","test:watch":"yarn g:vitest watch --passWithNoTests"},main:"./dist-cjs/index.js",types:"./dist-types/index.d.ts",module:"./dist-es/index.js",sideEffects:!1,dependencies:{"@aws-crypto/sha256-browser":"5.2.0","@aws-crypto/sha256-js":"5.2.0","@aws-sdk/core":"^3.973.21","@aws-sdk/credential-provider-node":"^3.972.22","@aws-sdk/eventstream-handler-node":"^3.972.11","@aws-sdk/middleware-eventstream":"^3.972.8","@aws-sdk/middleware-host-header":"^3.972.8","@aws-sdk/middleware-logger":"^3.972.8","@aws-sdk/middleware-recursion-detection":"^3.972.8","@aws-sdk/middleware-sdk-transcribe-streaming":"^3.972.8","@aws-sdk/middleware-user-agent":"^3.972.22","@aws-sdk/middleware-websocket":"^3.972.13","@aws-sdk/region-config-resolver":"^3.972.8","@aws-sdk/types":"^3.973.6","@aws-sdk/util-endpoints":"^3.996.5","@aws-sdk/util-user-agent-browser":"^3.972.8","@aws-sdk/util-user-agent-node":"^3.973.8","@smithy/config-resolver":"^4.4.11","@smithy/core":"^3.23.12","@smithy/eventstream-serde-browser":"^4.2.12","@smithy/eventstream-serde-config-resolver":"^4.3.12","@smithy/eventstream-serde-node":"^4.2.12","@smithy/fetch-http-handler":"^5.3.15","@smithy/hash-node":"^4.2.12","@smithy/invalid-dependency":"^4.2.12","@smithy/middleware-content-length":"^4.2.12","@smithy/middleware-endpoint":"^4.4.26","@smithy/middleware-retry":"^4.4.43","@smithy/middleware-serde":"^4.2.15","@smithy/middleware-stack":"^4.2.12","@smithy/node-config-provider":"^4.3.12","@smithy/node-http-handler":"^4.5.0","@smithy/protocol-http":"^5.3.12","@smithy/smithy-client":"^4.12.6","@smithy/types":"^4.13.1","@smithy/url-parser":"^4.2.12","@smithy/util-base64":"^4.3.2","@smithy/util-body-length-browser":"^4.2.2","@smithy/util-body-length-node":"^4.2.3","@smithy/util-defaults-mode-browser":"^4.3.42","@smithy/util-defaults-mode-node":"^4.2.45","@smithy/util-endpoints":"^3.3.3","@smithy/util-middleware":"^4.2.12","@smithy/util-retry":"^4.2.12","@smithy/util-utf8":"^4.2.2",tslib:"^2.6.2"},devDependencies:{"@smithy/snapshot-testing":"^2.0.3","@tsconfig/node20":"20.1.8","@types/node":"^20.14.8",concurrently:"7.0.0","downlevel-dts":"0.10.1",premove:"4.0.0",typescript:"~5.8.3",vitest:"^4.0.17"},engines:{node:">=20.0.0"},typesVersions:{"<4.5":{"dist-types/*":["dist-types/ts3.4/*"]}},files:["dist-*/**"],author:{name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/javascript/"},license:"Apache-2.0",browser:{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},homepage:"https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-transcribe-streaming",repository:{type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"clients/client-transcribe-streaming"}})},46479,(e,t,n)=>{t.exports=e.x("node:http2",()=>require("node:http2"))},70722,(e,t,n)=>{t.exports=e.x("tty",()=>require("tty"))},36599,(e,t,n)=>{function r(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}t.exports=function(e,t){t=t||{};var n,i,s=typeof e;if("string"===s&&e.length>0){var a=e;if(!((a=String(a)).length>100)){var o=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a);if(o){var l=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*l;case"days":case"day":case"d":return 864e5*l;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*l;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*l;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*l;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:break}}}return}if("number"===s&&!1===isNaN(e)){return t.long?r(n=e,864e5,"day")||r(n,36e5,"hour")||r(n,6e4,"minute")||r(n,1e3,"second")||n+" ms":(i=e)>=864e5?Math.round(i/864e5)+"d":i>=36e5?Math.round(i/36e5)+"h":i>=6e4?Math.round(i/6e4)+"m":i>=1e3?Math.round(i/1e3)+"s":i+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},14069,(e,t,n)=>{function r(e){var t;function r(){if(r.enabled){var e=+new Date;r.diff=e-(t||e),r.prev=t,r.curr=e,t=e;for(var i=Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];i[0]=n.coerce(i[0]),"string"!=typeof i[0]&&i.unshift("%O");var a=0;i[0]=i[0].replace(/%([a-zA-Z%])/g,function(e,t){if("%%"===e)return e;a++;var s=n.formatters[t];if("function"==typeof s){var o=i[a];e=s.call(r,o),i.splice(a,1),a--}return e}),n.formatArgs.call(r,i),(r.log||n.log||console.log.bind(console)).apply(r,i)}}return r.namespace=e,r.enabled=n.enabled(e),r.useColors=n.useColors(),r.color=function(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t)|0;return n.colors[Math.abs(r)%n.colors.length]}(e),r.destroy=i,"function"==typeof n.init&&n.init(r),n.instances.push(r),r}function i(){var e=n.instances.indexOf(this);return -1!==e&&(n.instances.splice(e,1),!0)}(n=t.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e),n.names=[],n.skips=[];var t,r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t<i;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(RegExp("^"+e.substr(1)+"$")):n.names.push(RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){var s=n.instances[t];s.enabled=n.enabled(s.namespace)}},n.enabled=function(e){var t,r;if("*"===e[e.length-1])return!0;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e.r(36599),n.instances=[],n.names=[],n.skips=[],n.formatters={}},55225,(e,t,n)=>{"use strict";t.exports=(e,t=process.argv)=>{let n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),i=t.indexOf("--");return -1!==r&&(-1===i||r<i)}},81042,(e,t,n)=>{"use strict";let r;e.r(46786);let i=e.r(70722),s=e.r(55225),{env:a}=process;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(0===r)return 0;if(s("color=16m")||s("color=full")||s("color=truecolor"))return 3;if(s("color=256"))return 2;if(e&&!t&&void 0===r)return 0;let n=r||0;if("dumb"===a.TERM)return n;if("CI"in a)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in a)||"codeship"===a.CI_NAME?1:n;if("TEAMCITY_VERSION"in a)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION);if("truecolor"===a.COLORTERM)return 3;if("TERM_PROGRAM"in a){let e=parseInt((a.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(a.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||"COLORTERM"in a?1:n}s("no-color")||s("no-colors")||s("color=false")||s("color=never")?r=0:(s("color")||s("colors")||s("color=true")||s("color=always"))&&(r=1),"FORCE_COLOR"in a&&(r="true"===a.FORCE_COLOR?1:"false"===a.FORCE_COLOR?0:0===a.FORCE_COLOR.length?1:Math.min(parseInt(a.FORCE_COLOR,10),3)),t.exports={supportsColor:function(e){return o(l(e,e&&e.isTTY))},stdout:o(l(!0,i.isatty(1))),stderr:o(l(!0,i.isatty(2)))}},20659,(e,t,n)=>{var r=e.r(70722),i=e.r(24361);(n=t.exports=e.r(14069)).init=function(e){e.inspectOpts={};for(var t=Object.keys(n.inspectOpts),r=0;r<t.length;r++)e.inspectOpts[t[r]]=n.inspectOpts[t[r]]},n.log=function(){return process.stderr.write(i.format.apply(i,arguments)+"\n")},n.formatArgs=function(e){var t=this.namespace;if(this.useColors){var r=this.color,i="\x1b[3"+(r<8?r:"8;5;"+r),s=" "+i+";1m"+t+" \x1b[0m";e[0]=s+e[0].split("\n").join("\n"+s),e.push(i+"m+"+n.humanize(this.diff)+"\x1b[0m")}else e[0]=(n.inspectOpts.hideDate?"":new Date().toISOString()+" ")+t+" "+e[0]},n.save=function(e){null==e?delete process.env.DEBUG:process.env.DEBUG=e},n.load=a,n.useColors=function(){return"colors"in n.inspectOpts?!!n.inspectOpts.colors:r.isatty(process.stderr.fd)},n.colors=[6,2,3,4,5,1];try{var s=e.r(81042);s&&s.level>=2&&(n.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}function a(){return process.env.DEBUG}n.inspectOpts=Object.keys(process.env).filter(function(e){return/^debug_/i.test(e)}).reduce(function(e,t){var n=t.substring(6).toLowerCase().replace(/_([a-z])/g,function(e,t){return t.toUpperCase()}),r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,e},{}),n.formatters.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split("\n").map(function(e){return e.trim()}).join(" ")},n.formatters.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)},n.enable(a())},98888,(e,t,n)=>{function r(){var e;try{e=n.storage.debug}catch(e){}return!e&&"u">typeof process&&"env"in process&&(e=process.env.DEBUG),e}(n=t.exports=e.r(14069)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},n.formatArgs=function(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),t){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,s=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(s=i))}),e.splice(s,0,r)}},n.save=function(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}},n.load=r,n.useColors=function(){return!("u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("u">typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage="u">typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(r())},88539,(e,t,n)=>{"u"<typeof process||"renderer"===process.type?t.exports=e.r(98888):t.exports=e.r(20659)},63403,e=>{"use strict";var t,n,r,i,s,a=e.g,o=[],l=[],c="u">typeof Uint8Array?Uint8Array:Array,u=!1;function h(){u=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;t<n;++t)o[t]=e[t],l[e.charCodeAt(t)]=t;l[45]=62,l[95]=63}function d(e){u||h();for(var t,n=e.length,r=n%3,i="",s=[],a=0,l=n-r;a<l;a+=16383)s.push(function(e,t,n){for(var r,i=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(o[r>>18&63]+o[r>>12&63]+o[r>>6&63]+o[63&r]);return i.join("")}(e,a,a+16383>l?l:a+16383));return 1===r?(i+=o[(t=e[n-1])>>2],i+=o[t<<4&63],i+="=="):2===r&&(i+=o[(t=(e[n-2]<<8)+e[n-1])>>10],i+=o[t>>4&63],i+=o[t<<2&63],i+="="),s.push(i),s.join("")}function f(e,t,n,r,i){var s,a,o=8*i-r-1,l=(1<<o)-1,c=l>>1,u=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,s=f&(1<<-u)-1,f>>=-u,u+=o;u>0;s=256*s+e[t+h],h+=d,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=r;u>0;a=256*a+e[t+h],h+=d,u-=8);if(0===s)s=1-c;else{if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),s-=c}return(f?-1:1)*a*Math.pow(2,s-r)}function p(e,t,n,r,i,s){var a,o,l,c=8*s-i-1,u=(1<<c)-1,h=u>>1,d=5960464477539062e-23*(23===i),f=r?0:s-1,p=r?1:-1,m=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+h>=1?t+=d/l:t+=d*Math.pow(2,1-h),t*l>=2&&(a++,l/=2),a+h>=u?(o=0,a=u):a+h>=1?(o=(t*l-1)*Math.pow(2,i),a+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[n+f]=255&o,f+=p,o/=256,i-=8);for(a=a<<i|o,c+=i;c>0;e[n+f]=255&a,f+=p,a/=256,c-=8);e[n+f-p]|=128*m}var m={}.toString,g=Array.isArray||function(e){return"[object Array]"==m.call(e)};function y(){return v.TYPED_ARRAY_SUPPORT?0x7fffffff:0x3fffffff}function b(e,t){if(y()<t)throw RangeError("Invalid typed array length");return v.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=v.prototype:(null===e&&(e=new v(t)),e.length=t),e}function v(e,t,n){if(!v.TYPED_ARRAY_SUPPORT&&!(this instanceof v))return new v(e,t,n);if("number"==typeof e){if("string"==typeof t)throw Error("If encoding is specified then the first argument must be a string");return S(this,e)}return w(this,e,t,n)}function w(e,t,n,r){if("number"==typeof t)throw TypeError('"value" argument must not be a number');return"u">typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),v.TYPED_ARRAY_SUPPORT?(e=t).__proto__=v.prototype:e=x(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if(("string"!=typeof n||""===n)&&(n="utf8"),!v.isEncoding(n))throw TypeError('"encoding" must be a valid string encoding');var r=0|C(t,n),i=(e=b(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(k(t)){var n,r=0|E(t.length);return 0===(e=b(e,r)).length||t.copy(e,0,0,r),e}if(t){if("u">typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t){return"number"!=typeof t.length||(n=t.length)!=n?b(e,0):x(e,t)}if("Buffer"===t.type&&g(t.data))return x(e,t.data)}throw TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function _(e){if("number"!=typeof e)throw TypeError('"size" argument must be a number');if(e<0)throw RangeError('"size" argument must not be negative')}function S(e,t){if(_(t),e=b(e,t<0?0:0|E(t)),!v.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function x(e,t){var n=t.length<0?0:0|E(t.length);e=b(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function E(e){if(e>=y())throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+y().toString(16)+" bytes");return 0|e}function k(e){return!!(null!=e&&e._isBuffer)}function C(e,t){if(k(e))return e.length;if("u">typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return H(e).length;default:if(r)return F(e).length;t=(""+t).toLowerCase(),r=!0}}function T(e,t,n){var r,i,s,a=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===n||n>this.length)&&(n=this.length),n<=0||(n>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,n){var r,i=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>i)&&(n=i);for(var s="",a=t;a<n;++a){s+=(r=e[a])<16?"0"+r.toString(16):r.toString(16)}return s}(this,t,n);case"utf8":case"utf-8":return O(this,t,n);case"ascii":return function(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}(this,t,n);case"latin1":case"binary":return function(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}(this,t,n);case"base64":return r=this,i=t,s=n,0===i&&s===r.length?d(r):d(r.slice(i,s));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}(this,t,n);default:if(a)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}function A(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function R(e,t,n,r,i){if(0===e.length)return -1;if("string"==typeof n?(r=n,n=0):n>0x7fffffff?n=0x7fffffff:n<-0x80000000&&(n=-0x80000000),isNaN(n*=1)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length)if(i)return -1;else n=e.length-1;else if(n<0)if(!i)return -1;else n=0;if("string"==typeof t&&(t=v.from(t,r)),k(t))return 0===t.length?-1:I(e,t,n,r,i);if("number"==typeof t){if(t&=255,v.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf)if(i)return Uint8Array.prototype.indexOf.call(e,t,n);else return Uint8Array.prototype.lastIndexOf.call(e,t,n);return I(e,[t],n,r,i)}throw TypeError("val must be string, number or Buffer")}function I(e,t,n,r,i){var s,a=1,o=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return -1;a=2,o/=2,l/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var u=-1;for(s=n;s<o;s++)if(c(e,s)===c(t,-1===u?0:s-u)){if(-1===u&&(u=s),s-u+1===l)return u*a}else -1!==u&&(s-=s-u),u=-1}else for(n+l>o&&(n=o-l),s=n;s>=0;s--){for(var h=!0,d=0;d<l;d++)if(c(e,s+d)!==c(t,d)){h=!1;break}if(h)return s}return -1}v.TYPED_ARRAY_SUPPORT=void 0===a.TYPED_ARRAY_SUPPORT||a.TYPED_ARRAY_SUPPORT,v.poolSize=8192,v._augment=function(e){return e.__proto__=v.prototype,e},v.from=function(e,t,n){return w(null,e,t,n)},v.TYPED_ARRAY_SUPPORT&&(v.prototype.__proto__=Uint8Array.prototype,v.__proto__=Uint8Array),v.alloc=function(e,t,n){return(_(e),e<=0)?b(null,e):void 0!==t?"string"==typeof n?b(null,e).fill(t,n):b(null,e).fill(t):b(null,e)},v.allocUnsafe=function(e){return S(null,e)},v.allocUnsafeSlow=function(e){return S(null,e)},v.isBuffer=q,v.compare=function(e,t){if(!k(e)||!k(t))throw TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},v.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},v.concat=function(e,t){if(!g(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return v.alloc(0);if(void 0===t)for(n=0,t=0;n<e.length;++n)t+=e[n].length;var n,r=v.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!k(s))throw TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},v.byteLength=C,v.prototype._isBuffer=!0,v.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)A(this,t,t+1);return this},v.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)A(this,t,t+3),A(this,t+1,t+2);return this},v.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)A(this,t,t+7),A(this,t+1,t+6),A(this,t+2,t+5),A(this,t+3,t+4);return this},v.prototype.toString=function(){var e=0|this.length;return 0===e?"":0==arguments.length?O(this,0,e):T.apply(this,arguments)},v.prototype.equals=function(e){if(!k(e))throw TypeError("Argument must be a Buffer");return this===e||0===v.compare(this,e)},v.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},v.prototype.compare=function(e,t,n,r,i){if(!k(e))throw TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var s=i-r,a=n-t,o=Math.min(s,a),l=this.slice(r,i),c=e.slice(t,n),u=0;u<o;++u)if(l[u]!==c[u]){s=l[u],a=c[u];break}return s<a?-1:+(a<s)},v.prototype.includes=function(e,t,n){return -1!==this.indexOf(e,t,n)},v.prototype.indexOf=function(e,t,n){return R(this,e,t,n,!0)},v.prototype.lastIndexOf=function(e,t,n){return R(this,e,t,n,!1)};function O(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,a,o,l,c=e[i],u=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=n)switch(h){case 1:c<128&&(u=c);break;case 2:(192&(s=e[i+1]))==128&&(l=(31&c)<<6|63&s)>127&&(u=l);break;case 3:s=e[i+1],a=e[i+2],(192&s)==128&&(192&a)==128&&(l=(15&c)<<12|(63&s)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:s=e[i+1],a=e[i+2],o=e[i+3],(192&s)==128&&(192&a)==128&&(192&o)==128&&(l=(15&c)<<18|(63&s)<<12|(63&a)<<6|63&o)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=h}var d=r,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",m=0;m<f;)p+=String.fromCharCode.apply(String,d.slice(m,m+=4096));return p}function P(e,t,n){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>n)throw RangeError("Trying to access beyond buffer length")}function M(e,t,n,r,i,s){if(!k(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw RangeError('"value" argument is out of bounds');if(n+r>e.length)throw RangeError("Index out of range")}function D(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}function L(e,t,n,r){t<0&&(t=0xffffffff+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>(r?i:3-i)*8&255}function $(e,t,n,r,i,s){if(n+r>e.length||n<0)throw RangeError("Index out of range")}function N(e,t,n,r,i){return i||$(e,t,n,4,34028234663852886e22,-34028234663852886e22),p(e,t,n,r,23,4),n+4}function U(e,t,n,r,i){return i||$(e,t,n,8,17976931348623157e292,-17976931348623157e292),p(e,t,n,r,52,8),n+8}v.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,s,a,o,l,c,u,h,d=this.length-t;if((void 0===n||n>d)&&(n=d),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var f=!1;;)switch(r){case"hex":return function(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;if(s%2!=0)throw TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var a=0;a<r;++a){var o=parseInt(t.substr(2*a,2),16);if(isNaN(o))break;e[n+a]=o}return a}(this,e,t,n);case"utf8":case"utf-8":return i=t,s=n,W(F(e,this.length-i),this,i,s);case"ascii":return a=t,o=n,W(j(e),this,a,o);case"latin1":case"binary":return function(e,t,n,r){return W(j(t),e,n,r)}(this,e,t,n);case"base64":return l=t,c=n,W(H(e),this,l,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u=t,h=n,W(function(e,t){for(var n,r,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i.push(n%256),i.push(r);return i}(e,this.length-u),this,u,h);default:if(f)throw TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),f=!0}},v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},v.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),v.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=v.prototype;else{var i=t-e;n=new v(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},v.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},v.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},v.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},v.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},v.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},v.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},v.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},v.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},v.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},v.prototype.readInt8=function(e,t){return(t||P(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},v.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?0xffff0000|n:n},v.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?0xffff0000|n:n},v.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},v.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},v.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),f(this,e,!0,23,4)},v.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),f(this,e,!1,23,4)},v.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),f(this,e,!0,52,8)},v.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),f(this,e,!1,52,8)},v.prototype.writeUIntLE=function(e,t,n,r){if(e*=1,t|=0,n|=0,!r){var i=Math.pow(2,8*n)-1;M(this,e,t,n,i,0)}var s=1,a=0;for(this[t]=255&e;++a<n&&(s*=256);)this[t+a]=e/s&255;return t+n},v.prototype.writeUIntBE=function(e,t,n,r){if(e*=1,t|=0,n|=0,!r){var i=Math.pow(2,8*n)-1;M(this,e,t,n,i,0)}var s=n-1,a=1;for(this[t+s]=255&e;--s>=0&&(a*=256);)this[t+s]=e/a&255;return t+n},v.prototype.writeUInt8=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,1,255,0),v.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},v.prototype.writeUInt16LE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,2,65535,0),v.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},v.prototype.writeUInt16BE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,2,65535,0),v.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},v.prototype.writeUInt32LE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,4,0xffffffff,0),v.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},v.prototype.writeUInt32BE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,4,0xffffffff,0),v.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},v.prototype.writeIntLE=function(e,t,n,r){if(e*=1,t|=0,!r){var i=Math.pow(2,8*n-1);M(this,e,t,n,i-1,-i)}var s=0,a=1,o=0;for(this[t]=255&e;++s<n&&(a*=256);)e<0&&0===o&&0!==this[t+s-1]&&(o=1),this[t+s]=(e/a|0)-o&255;return t+n},v.prototype.writeIntBE=function(e,t,n,r){if(e*=1,t|=0,!r){var i=Math.pow(2,8*n-1);M(this,e,t,n,i-1,-i)}var s=n-1,a=1,o=0;for(this[t+s]=255&e;--s>=0&&(a*=256);)e<0&&0===o&&0!==this[t+s+1]&&(o=1),this[t+s]=(e/a|0)-o&255;return t+n},v.prototype.writeInt8=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,1,127,-128),v.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},v.prototype.writeInt16LE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,2,32767,-32768),v.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},v.prototype.writeInt16BE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,2,32767,-32768),v.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},v.prototype.writeInt32LE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,4,0x7fffffff,-0x80000000),v.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},v.prototype.writeInt32BE=function(e,t,n){return e*=1,t|=0,n||M(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),v.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},v.prototype.writeFloatLE=function(e,t,n){return N(this,e,t,!0,n)},v.prototype.writeFloatBE=function(e,t,n){return N(this,e,t,!1,n)},v.prototype.writeDoubleLE=function(e,t,n){return U(this,e,t,!0,n)},v.prototype.writeDoubleBE=function(e,t,n){return U(this,e,t,!1,n)},v.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw RangeError("sourceStart out of bounds");if(r<0)throw RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!v.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},v.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i,s=e.charCodeAt(0);s<256&&(e=s)}if(void 0!==r&&"string"!=typeof r)throw TypeError("encoding must be a string");if("string"==typeof r&&!v.isEncoding(r))throw TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw RangeError("Out of range index");if(n<=t)return this;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var a=k(e)?e:F(new v(e,r).toString()),o=a.length;for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};var B=/[^+\/0-9A-Za-z-_]/g;function F(e,t){t=t||1/0;for(var n,r=e.length,i=null,s=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319||a+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else if(n<1114112){if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}else throw Error("Invalid code point")}return s}function j(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function H(e){return function(e){u||h();var t,n,r,i,s,a,o=e.length;if(o%4>0)throw Error("Invalid string. Length must be a multiple of 4");s="="===e[o-2]?2:+("="===e[o-1]),a=new c(3*o/4-s),r=s>0?o-4:o;var d=0;for(t=0,n=0;t<r;t+=4,n+=3)i=l[e.charCodeAt(t)]<<18|l[e.charCodeAt(t+1)]<<12|l[e.charCodeAt(t+2)]<<6|l[e.charCodeAt(t+3)],a[d++]=i>>16&255,a[d++]=i>>8&255,a[d++]=255&i;return 2===s?(i=l[e.charCodeAt(t)]<<2|l[e.charCodeAt(t+1)]>>4,a[d++]=255&i):1===s&&(i=l[e.charCodeAt(t)]<<10|l[e.charCodeAt(t+1)]<<4|l[e.charCodeAt(t+2)]>>2,a[d++]=i>>8&255,a[d++]=255&i),a}(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length)&&!(i>=e.length);++i)t[i+n]=e[i];return i}function q(e){var t;return null!=e&&(!!e._isBuffer||z(e)||"function"==typeof(t=e).readFloatLE&&"function"==typeof t.slice&&z(t.slice(0,0)))}function z(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function V(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function K(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Y(e,t,n){return t&&K(e.prototype,t),n&&K(e,n),e}function G(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){G(e,t,n[t])})}return e}function J(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Z(e,t)}function Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Z(e,t){return(Z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ee(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function et(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function en(e,t){return t&&("object"==typeof t||"function"==typeof t)?t:et(e)}function er(e){return function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance")}()}var ei=function(e){return"object"==typeof e?null!==e:"function"==typeof e},es=function(e){if(!ei(e))throw TypeError(e+" is not an object!");return e},ea=function(e){try{return!!e()}catch(e){return!0}},eo=!ea(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a});function el(e,t){return e(t={exports:{}},t.exports),t.exports}var ec=el(function(e){var t=e.exports="u">typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)}),eu=ec.document,eh=ei(eu)&&ei(eu.createElement),ed=function(e){return eh?eu.createElement(e):{}},ef=!eo&&!ea(function(){return 7!=Object.defineProperty(ed("div"),"a",{get:function(){return 7}}).a}),ep=function(e,t){var n,r;if(!ei(e))return e;if(t&&"function"==typeof(n=e.toString)&&!ei(r=n.call(e))||"function"==typeof(n=e.valueOf)&&!ei(r=n.call(e))||!t&&"function"==typeof(n=e.toString)&&!ei(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},em=Object.defineProperty,eg=eo?Object.defineProperty:function(e,t,n){if(es(e),t=ep(t,!0),es(n),ef)try{return em(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e},ey=Function.prototype,eb=/^\s*function ([^ (]*)/,ev="name";ev in ey||eo&&eg(ey,ev,{configurable:!0,get:function(){try{return(""+this).match(eb)[1]}catch(e){return""}}});var ew=el(function(e){var t=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=t)});ew.version;var e_=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},eS=eo?function(e,t,n){return eg(e,t,e_(1,n))}:function(e,t,n){return e[t]=n,e},ex={}.hasOwnProperty,eE=function(e,t){return ex.call(e,t)},ek=0,eC=Math.random(),eT=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++ek+eC).toString(36))},eA=el(function(e){var t=eT("src"),n="toString",r=Function[n],i=(""+r).split(n);ew.inspectSource=function(e){return r.call(e)},(e.exports=function(e,n,r,s){var a="function"==typeof r;a&&(eE(r,"name")||eS(r,"name",n)),e[n]!==r&&(a&&(eE(r,t)||eS(r,t,e[n]?""+e[n]:i.join(String(n)))),e===ec?e[n]=r:s?e[n]?e[n]=r:eS(e,n,r):(delete e[n],eS(e,n,r)))})(Function.prototype,n,function(){return"function"==typeof this&&this[t]||r.call(this)})}),eR=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},eI=function(e,t,n){if(eR(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}},eO="prototype",eP=function(e,t,n){var r,i,s,a,o=e&eP.F,l=e&eP.G,c=e&eP.S,u=e&eP.P,h=e&eP.B,d=l?ec:c?ec[t]||(ec[t]={}):(ec[t]||{})[eO],f=l?ew:ew[t]||(ew[t]={}),p=f[eO]||(f[eO]={});for(r in l&&(n=t),n)s=((i=!o&&d&&void 0!==d[r])?d:n)[r],a=h&&i?eI(s,ec):u&&"function"==typeof s?eI(Function.call,s):s,d&&eA(d,r,s,e&eP.U),f[r]!=s&&eS(f,r,a),u&&p[r]!=s&&(p[r]=s)};ec.core=ew,eP.F=1,eP.G=2,eP.S=4,eP.P=8,eP.B=16,eP.W=32,eP.U=64,eP.R=128;var eM=Math.ceil,eD=Math.floor,eL=function(e){return isNaN(e*=1)?0:(e>0?eD:eM)(e)},e$=Math.min,eN=function(e){return e>0?e$(eL(e),0x1fffffffffffff):0},eU=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e},eB=function(e){var t=String(eU(this)),n="",r=eL(e);if(r<0||r==1/0)throw RangeError("Count can't be negative");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},eF=function(e,t,n,r){var i=String(eU(e)),s=i.length,a=void 0===n?" ":String(n),o=eN(t);if(o<=s||""==a)return i;var l=o-s,c=eB.call(a,Math.ceil(l/a.length));return c.length>l&&(c=c.slice(0,l)),r?c+i:i+c},ej=ec.navigator,eH=ej&&ej.userAgent||"";eP(eP.P+eP.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(eH),"String",{padStart:function(e){return eF(this,e,arguments.length>1?arguments[1]:void 0,!0)}});var eW={}.toString,eq=function(e){return eW.call(e).slice(8,-1)},ez={f:{}.propertyIsEnumerable},eV=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==eq(e)?e.split(""):Object(e)},eK=function(e){return eV(eU(e))},eY=Object.getOwnPropertyDescriptor,eG=eo?eY:function(e,t){if(e=eK(e),t=ep(t,!0),ef)try{return eY(e,t)}catch(e){}if(eE(e,t))return e_(!ez.f.call(e,t),e[t])},eX=function(e,t){if(es(e),!ei(t)&&null!==t)throw TypeError(t+": can't set as prototype!")},eJ={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,n){try{(n=eI(Function.call,eG(Object.prototype,"__proto__").set,2))(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,r){return eX(e,r),t?e.__proto__=r:n(e,r),e}}({},!1):void 0),check:eX}.set,eQ=function(e,t,n){var r,i=t.constructor;return i!==n&&"function"==typeof i&&(r=i.prototype)!==n.prototype&&ei(r)&&eJ&&eJ(e,r),e},eZ=Math.max,e0=Math.min,e1=el(function(e){var t="__core-js_shared__",n=ec[t]||(ec[t]={});(e.exports=function(e,t){return n[e]||(n[e]=void 0!==t?t:{})})("versions",[]).push({version:ew.version,mode:"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})}),e2=e1("keys"),e3=function(e){return e2[e]||(e2[e]=eT(e))},e6=function(e,t,n){var r,i,s=eK(e),a=eN(s.length),o=(r=eL(r=n))<0?eZ(r+a,0):e0(r,a);1;for(;a>o;o++)if(o in s&&s[o]===t)return o||0;return -1},e8=e3("IE_PROTO"),e4=function(e,t){var n,r=eK(e),i=0,s=[];for(n in r)n!=e8&&eE(r,n)&&s.push(n);for(;t.length>i;)eE(r,n=t[i++])&&(~e6(s,n)||s.push(n));return s},e5="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),e9=e5.concat("length","prototype"),e7=Object.getOwnPropertyNames||function(e){return e4(e,e9)},te=" \n\v\f\r   ᠎              \u2028\u2029\uFEFF",tt="["+te+"]",tn="​…",tr=RegExp("^"+tt+tt+"*"),ti=RegExp(tt+tt+"*$"),ts=function(e,t,n){var r={},i=ea(function(){return!!te[e]()||tn[e]()!=tn}),s=r[e]=i?t(ta):te[e];n&&(r[n]=s),eP(eP.P+eP.F*i,"String",r)},ta=ts.trim=function(e,t){return e=String(eU(e)),1&t&&(e=e.replace(tr,"")),2&t&&(e=e.replace(ti,"")),e},to=Object.keys||function(e){return e4(e,e5)},tl=eo?Object.defineProperties:function(e,t){es(e);for(var n,r=to(t),i=r.length,s=0;i>s;)eg(e,n=r[s++],t[n]);return e},tc=ec.document,tu=tc&&tc.documentElement,th=e3("IE_PROTO"),td=function(){},tf="prototype",tp=function(){var e,t=ed("iframe"),n=e5.length;for(t.style.display="none",tu.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("<script>document.F=Object</script>"),e.close(),tp=e.F;n--;)delete tp[tf][e5[n]];return tp()},tm=Object.create||function(e,t){var n;return null!==e?(td[tf]=es(e),n=new td,td[tf]=null,n[th]=e):n=tp(),void 0===t?n:tl(n,t)},tg=ts.trim,ty="Number",tb=ec[ty],tv=tb,tw=tb.prototype,t_=eq(tm(tw))==ty,tS="trim"in String.prototype,tx=function(e){var t=ep(e,!1);if("string"==typeof t&&t.length>2){var n=(t=tS?t.trim():tg(t,3)).charCodeAt(0);if(43===n||45===n){if(88===(r=t.charCodeAt(2))||120===r)return NaN}else if(48===n){switch(t.charCodeAt(1)){case 66:case 98:i=2,s=49;break;case 79:case 111:i=8,s=55;break;default:return+t}for(var r,i,s,a,o=t.slice(2),l=0,c=o.length;l<c;l++)if((a=o.charCodeAt(l))<48||a>s)return NaN;return parseInt(o,i)}}return+t};if(!tb(" 0o1")||!tb("0b1")||tb("+0x1")){tb=function(e){var t=arguments.length<1?0:e,n=this;return n instanceof tb&&(t_?ea(function(){tw.valueOf.call(n)}):eq(n)!=ty)?eQ(new tv(tx(t)),n,tb):tx(t)};for(var tE,tk=eo?e7(tv):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),tC=0;tk.length>tC;tC++)eE(tv,tE=tk[tC])&&!eE(tb,tE)&&eg(tb,tE,eG(tv,tE));tb.prototype=tw,tw.constructor=tb,eA(ec,ty,tb)}var tT=function(){var e=es(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t};eo&&"g"!=/./g.flags&&eg(RegExp.prototype,"flags",{configurable:!0,get:tT});var tA="toString",tR=/./[tA],tI=function(e){eA(RegExp.prototype,tA,e,!0)};ea(function(){return"/a/b"!=tR.call({source:"a",flags:"b"})})?tI(function(){var e=es(this);return"/".concat(e.source,"/","flags"in e?e.flags:!eo&&e instanceof RegExp?tT.call(e):void 0)}):tR.name!=tA&&tI(function(){return tR.call(this)});var tO=function(e){return Object(eU(e))},tP=function(e,t,n,r){try{return r?t(es(n)[0],n[1]):t(n)}catch(t){var i=e.return;throw void 0!==i&&es(i.call(e)),t}},tM={},tD=el(function(e){var t=e1("wks"),n=ec.Symbol,r="function"==typeof n;(e.exports=function(e){return t[e]||(t[e]=r&&n[e]||(r?n:eT)("Symbol."+e))}).store=t}),tL=tD("iterator"),t$=Array.prototype,tN=function(e){return void 0!==e&&(tM.Array===e||t$[tL]===e)},tU=function(e,t,n){t in e?eg(e,t,e_(0,n)):e[t]=n},tB=tD("toStringTag"),tF="Arguments"==eq(function(){return arguments}()),tj=function(e,t){try{return e[t]}catch(e){}},tH=function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=tj(t=Object(e),tB))?n:tF?eq(t):"Object"==(r=eq(t))&&"function"==typeof t.callee?"Arguments":r},tW=tD("iterator"),tq=ew.getIteratorMethod=function(e){if(void 0!=e)return e[tW]||e["@@iterator"]||tM[tH(e)]},tz=tD("iterator"),tV=!1;try{[7][tz]().return=function(){tV=!0}}catch(e){}var tK=function(e,t){if(!t&&!tV)return!1;var n=!1;try{var r=[7],i=r[tz]();i.next=function(){return{done:n=!0}},r[tz]=function(){return i},e(r)}catch(e){}return n};eP(eP.S+!tK(function(e){})*eP.F,"Array",{from:function(e){var t,n,r,i,s=tO(e),a="function"==typeof this?this:Array,o=arguments.length,l=o>1?arguments[1]:void 0,c=void 0!==l,u=0,h=tq(s);if(c&&(l=eI(l,o>2?arguments[2]:void 0,2)),void 0==h||a==Array&&tN(h))for(n=new a(t=eN(s.length));t>u;u++)tU(n,u,c?l(s[u],u):s[u]);else for(i=h.call(s),n=new a;!(r=i.next()).done;u++)tU(n,u,c?tP(i,l,[r.value,u],!0):r.value);return n.length=u,n}}),eP(eP.S,"Math",{log2:function(e){return Math.log(e)/Math.LN2}});var tY=function(){function e(){V(this,e)}return Y(e,null,[{key:"readVint",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=8-Math.floor(Math.log2(t[n]));if(r>8){var i=e.readHexString(t,n,n+r);throw Error("Unrepresentable length: ".concat(r," ").concat(i))}if(n+r>t.length)return null;for(var s=t[n]&(1<<8-r)-1,a=1;a<r;a+=1){if(7===a&&s>=256&&t[n+7]>0)return{length:r,value:-1};s*=256,s+=t[n+a]}return{length:r,value:s}}},{key:"writeVint",value:function(e){if(e<0||e>0x20000000000000)throw Error("Unrepresentable value: ".concat(e));var t=1;for(t=1;t<=8&&!(e<Math.pow(2,7*t)-1);t+=1);for(var n=v.alloc(t),r=e,i=1;i<=t;i+=1){var s=255&r;n[t-i]=s,r-=s,r/=256}return n[0]|=1<<8-t,n}},{key:"concatenate",value:function(e,t){return e&&0!==e.byteLength?t&&0!==t.byteLength?v.from(er(e).concat(er(t))):e:t}},{key:"readHexString",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.byteLength;return Array.from(e.slice(t,n)).map(function(e){return Number(e).toString(16)}).reduce(function(e,t){return"".concat(e).concat(t.padStart(2,"0"))},"")}},{key:"readUtf8",value:function(e){try{return v.from(e).toString("utf8")}catch(e){return null}}},{key:"readUnsigned",value:function(t){var n=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 1:return n.getUint8(0);case 2:return n.getUint16(0);case 4:return n.getUint32(0)}return t.byteLength<=6?t.reduce(function(e,t){return 256*e+t},0):e.readHexString(t,0,t.byteLength)}},{key:"readSigned",value:function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 1:return t.getInt8(0);case 2:return t.getInt16(0);case 4:return t.getInt32(0);default:return NaN}}},{key:"readFloat",value:function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return t.getFloat32(0);case 8:return t.getFloat64(0);default:return NaN}}},{key:"readDataFromTag",value:function(t,n){var r,i=t.type,s=t.name,a=t.track,o=t.discardable||!1,l=t.keyframe||!1,c=null;switch(i){case"u":r=e.readUnsigned(n);break;case"f":r=e.readFloat(n);break;case"i":r=e.readSigned(n);break;case"s":r=String.fromCharCode.apply(String,er(n));break;case"8":r=e.readUtf8(n)}if("SimpleBlock"===s||"Block"===s){var u=0,h=e.readVint(n,u),d=h.length,f=h.value;u+=d,a=f,r=e.readSigned(n.subarray(u,u+2)),u+=2,"SimpleBlock"===s&&(l=!!(128&n[d+2]),o=!!(1&n[d+2])),u+=1,c=n.subarray(u)}return X({},t,{data:n,discardable:o,keyframe:l,payload:c,track:a,value:r})}}]),e}(),tG=tD("unscopables"),tX=Array.prototype;void 0==tX[tG]&&eS(tX,tG,{});var tJ=function(e){tX[tG][e]=!0},tQ=function(e,t){return{value:t,done:!!e}},tZ=tD("toStringTag"),t0=function(e,t,n){e&&!eE(e=n?e:e.prototype,tZ)&&eg(e,tZ,{configurable:!0,value:t})},t1={};eS(t1,tD("iterator"),function(){return this});var t2=function(e,t,n){e.prototype=tm(t1,{next:e_(1,n)}),t0(e,t+" Iterator")},t3=e3("IE_PROTO"),t6=Object.prototype,t8=Object.getPrototypeOf||function(e){return eE(e=tO(e),t3)?e[t3]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?t6:null},t4=tD("iterator"),t5=!([].keys&&"next"in[].keys()),t9="keys",t7="values",ne=function(){return this},nt=function(e,t,n,r,i,s,a){t2(n,t,r);var o,l,c,u=function(e){if(!t5&&e in p)return p[e];switch(e){case t9:case t7:return function(){return new n(this,e)}}return function(){return new n(this,e)}},h=t+" Iterator",d=i==t7,f=!1,p=e.prototype,m=p[t4]||p["@@iterator"]||i&&p[i],g=m||u(i),y=i?d?u("entries"):g:void 0,b="Array"==t&&p.entries||m;if(b&&(c=t8(b.call(new e)))!==Object.prototype&&c.next&&(t0(c,h,!0),"function"!=typeof c[t4]&&eS(c,t4,ne)),d&&m&&m.name!==t7&&(f=!0,g=function(){return m.call(this)}),(t5||f||!p[t4])&&eS(p,t4,g),tM[t]=g,tM[h]=ne,i)if(o={values:d?g:u(t7),keys:s?g:u(t9),entries:y},a)for(l in o)l in p||eA(p,l,o[l]);else eP(eP.P+eP.F*(t5||f),t,o);return o},nn=nt(Array,"Array",function(e,t){this._t=eK(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,tQ(1)):"keys"==t?tQ(0,n):"values"==t?tQ(0,e[n]):tQ(0,[n,e[n]])},"values");tM.Arguments=tM.Array,tJ("keys"),tJ("values"),tJ("entries");for(var nr=tD("iterator"),ni=tD("toStringTag"),ns=tM.Array,na={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},no=to(na),nl=0;nl<no.length;nl++){var nc,nu=no[nl],nh=na[nu],nd=ec[nu],nf=nd&&nd.prototype;if(nf&&(nf[nr]||eS(nf,nr,ns),nf[ni]||eS(nf,ni,nu),tM[nu]=ns,nh))for(nc in nn)nf[nc]||eA(nf,nc,nn[nc],!0)}var np=function(e,t,n){for(var r in t)eA(e,r,t[r],n);return e},nm=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e},ng=el(function(e){var t={},n={},r=e.exports=function(e,r,i,s,a){var o,l,c,u,h=a?function(){return e}:tq(e),d=eI(i,s,r?2:1),f=0;if("function"!=typeof h)throw TypeError(e+" is not iterable!");if(tN(h)){for(o=eN(e.length);o>f;f++)if((u=r?d(es(l=e[f])[0],l[1]):d(e[f]))===t||u===n)return u}else for(c=h.call(e);!(l=c.next()).done;)if((u=tP(c,d,l.value,r))===t||u===n)return u};r.BREAK=t,r.RETURN=n}),ny=tD("species"),nb=function(e){var t=ec[e];eo&&t&&!t[ny]&&eg(t,ny,{configurable:!0,get:function(){return this}})},nv=el(function(e){var t=eT("meta"),n=0,r=Object.isExtensible||function(){return!0},i=!ea(function(){return r(Object.preventExtensions({}))}),s=function(e){eg(e,t,{value:{i:"O"+ ++n,w:{}}})},a=e.exports={KEY:t,NEED:!1,fastKey:function(e,n){if(!ei(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!eE(e,t)){if(!r(e))return"F";if(!n)return"E";s(e)}return e[t].i},getWeak:function(e,n){if(!eE(e,t)){if(!r(e))return!0;if(!n)return!1;s(e)}return e[t].w},onFreeze:function(e){return i&&a.NEED&&r(e)&&!eE(e,t)&&s(e),e}}});nv.KEY,nv.NEED,nv.fastKey,nv.getWeak,nv.onFreeze;var nw=function(e,t){if(!ei(e)||e._t!==t)throw TypeError("Incompatible receiver, "+t+" required!");return e},n_=nv.fastKey,nS=eo?"_s":"size",nx=function(e,t){var n,r=n_(t);if("F"!==r)return e._i[r];for(n=e._f;n;n=n.n)if(n.k==t)return n},nE={getConstructor:function(e,t,n,r){var i=e(function(e,s){nm(e,i,t,"_i"),e._t=t,e._i=tm(null),e._f=void 0,e._l=void 0,e[nS]=0,void 0!=s&&ng(s,n,e[r],e)});return np(i.prototype,{clear:function(){for(var e=nw(this,t),n=e._i,r=e._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];e._f=e._l=void 0,e[nS]=0},delete:function(e){var n=nw(this,t),r=nx(n,e);if(r){var i=r.n,s=r.p;delete n._i[r.i],r.r=!0,s&&(s.n=i),i&&(i.p=s),n._f==r&&(n._f=i),n._l==r&&(n._l=s),n[nS]--}return!!r},forEach:function(e){nw(this,t);for(var n,r=eI(e,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(e){return!!nx(nw(this,t),e)}}),eo&&eg(i.prototype,"size",{get:function(){return nw(this,t)[nS]}}),i},def:function(e,t,n){var r,i,s=nx(e,t);return s?s.v=n:(e._l=s={i:i=n_(t,!0),k:t,v:n,p:r=e._l,n:void 0,r:!1},e._f||(e._f=s),r&&(r.n=s),e[nS]++,"F"!==i&&(e._i[i]=s)),e},getEntry:nx,setStrong:function(e,t,n){nt(e,t,function(e,n){this._t=nw(e,t),this._k=n,this._l=void 0},function(){for(var e=this._k,t=this._l;t&&t.r;)t=t.p;return this._t&&(this._l=t=t?t.n:this._t._f)?"keys"==e?tQ(0,t.k):"values"==e?tQ(0,t.v):tQ(0,[t.k,t.v]):(this._t=void 0,tQ(1))},n?"entries":"values",!n,!0),nb(t)}};!function(e,t,n,r,i,s){var a=ec.Map,o=a,l=i?"set":"add",c=o&&o.prototype,u={},h=function(e){var t=c[e];eA(c,e,"delete"==e?function(e){return t.call(this,0===e?0:e)}:"has"==e?function(e){return t.call(this,0===e?0:e)}:"get"==e?function(e){return t.call(this,0===e?0:e)}:"add"==e?function(e){return t.call(this,0===e?0:e),this}:function(e,n){return t.call(this,0===e?0:e,n),this})};if("function"==typeof o&&c.forEach&&!ea(function(){new o().entries().next()})){var d=new o,f=d[l](-0,1)!=d,p=ea(function(){d.has(1)}),m=tK(function(e){new o(e)}),g=ea(function(){for(var e=new o,t=5;t--;)e[l](t,t);return!e.has(-0)});m||((o=t(function(e,t){nm(e,o,"Map");var n=eQ(new a,e,o);return void 0!=t&&ng(t,i,n[l],n),n})).prototype=c,c.constructor=o),(p||g)&&(h("delete"),h("has"),i&&h("get")),(g||f)&&h(l)}else np((o=r.getConstructor(t,"Map",i,l)).prototype,n),nv.NEED=!0;t0(o,"Map"),u.Map=o,eP(eP.G+eP.W+eP.F*(o!=a),u),r.setStrong(o,"Map",i)}(0,function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{get:function(e){var t=nE.getEntry(nw(this,"Map"),e);return t&&t.v},set:function(e,t){return nE.def(nw(this,"Map"),0===e?0:e,t)}},nE,!0);var nk=new Map([[128,{name:"ChapterDisplay",level:4,type:"m",multiple:!0,minver:1,webm:!0,description:"Contains all possible strings to use for the chapter display."}],[131,{name:"TrackType",level:3,type:"u",multiple:!1,mandatory:!0,minver:1,range:"1-254",description:"A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).",webm:!1}],[133,{name:"ChapString",cppname:"ChapterString",level:5,type:"8",multiple:!1,mandatory:!0,minver:1,webm:!0,description:"Contains the string to use as the chapter atom."}],[134,{name:"CodecID",level:3,type:"s",mandatory:!0,minver:1,description:"An ID corresponding to the codec, see the codec page for more info.",multiple:!1,webm:!1}],[136,{name:"FlagDefault",cppname:"TrackFlagDefault",level:3,type:"u",mandatory:!0,minver:1,default:1,range:"0-1",description:"Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)",multiple:!1,webm:!1}],[137,{name:"ChapterTrackNumber",level:5,type:"u",mandatory:!0,multiple:!0,minver:1,webm:!1,range:"not 0",description:"UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks."}],[145,{name:"ChapterTimeStart",level:4,type:"u",mandatory:!0,minver:1,webm:!0,description:"Timestamp of the start of Chapter (not scaled).",multiple:!1}],[146,{name:"ChapterTimeEnd",level:4,type:"u",minver:1,webm:!1,description:"Timestamp of the end of Chapter (timestamp excluded, not scaled).",multiple:!1}],[150,{name:"CueRefTime",level:5,type:"u",mandatory:!0,minver:2,webm:!1,description:"Timestamp of the referenced Block.",multiple:!1}],[151,{name:"CueRefCluster",level:5,type:"u",mandatory:!0,webm:!1,description:"The Position of the Cluster containing the referenced Block.",minver:0,multiple:!1}],[152,{name:"ChapterFlagHidden",level:4,type:"u",mandatory:!0,minver:1,webm:!1,default:0,range:"0-1",description:"If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)",multiple:!1}],[16980,{name:"ContentCompAlgo",level:6,type:"u",mandatory:!0,minver:1,webm:!1,default:0,br:["","","",""],del:["1 - bzlib,","2 - lzo1x"],description:"The compression algorithm used. Algorithms that have been specified so far are: 0 - zlib, 3 - Header Stripping",multiple:!1}],[16981,{name:"ContentCompSettings",level:6,type:"b",minver:1,webm:!1,description:"Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.",multiple:!1}],[17026,{name:"DocType",level:1,type:"s",mandatory:!0,default:"matroska",minver:1,description:"A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files.",multiple:!1,webm:!1}],[17029,{name:"DocTypeReadVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The minimum DocType version an interpreter has to support to read this file.",multiple:!1,webm:!1}],[17030,{name:"EBMLVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The version of EBML parser used to create the file.",multiple:!1,webm:!1}],[17031,{name:"DocTypeVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The version of DocType interpreter used to create the file.",multiple:!1,webm:!1}],[17476,{name:"SegmentFamily",level:2,type:"b",multiple:!0,minver:1,webm:!1,bytesize:16,description:"A randomly generated unique ID that all segments related to each other must use (128 bits)."}],[17505,{name:"DateUTC",level:2,type:"d",minver:1,description:"Date of the origin of timestamp (value 0), i.e. production date.",multiple:!1,webm:!1}],[17540,{name:"TagDefault",level:4,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"0-1",description:"Indication to know if this is the default/original language to use for the given tag. (1 bit)",multiple:!1}],[17541,{name:"TagBinary",level:4,type:"b",minver:1,webm:!1,description:"The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString.",multiple:!1}],[17543,{name:"TagString",level:4,type:"8",minver:1,webm:!1,description:"The value of the Tag.",multiple:!1}],[17545,{name:"Duration",level:2,type:"f",minver:1,range:"> 0",description:"Duration of the segment (based on TimecodeScale).",multiple:!1,webm:!1}],[17816,{name:"ChapterFlagEnabled",level:4,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"0-1",description:"Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter (see flag notes). (1 bit)",multiple:!1}],[18016,{name:"FileMimeType",level:3,type:"s",mandatory:!0,minver:1,webm:!1,description:"MIME type of the file.",multiple:!1}],[18017,{name:"FileUsedStartTime",level:3,type:"u",divx:!0,description:"DivX font extension",multiple:!1}],[18018,{name:"FileUsedEndTime",level:3,type:"u",divx:!0,multiple:!1,description:"DivX font extension"}],[18037,{name:"FileReferral",level:3,type:"b",webm:!1,description:"A binary value that a track/codec can refer to when the attachment is needed.",multiple:!1}],[20529,{name:"ContentEncodingOrder",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:0,multiple:!1,description:"Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment."}],[20530,{name:"ContentEncodingScope",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"not 0",br:["","",""],description:"A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values: 1 - all frame contents, 2 - the track's private data, 4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)",multiple:!1}],[20531,{name:"ContentEncodingType",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:0,br:["",""],description:"A value describing what kind of transformation has been done. Possible values: 0 - compression, 1 - encryption",multiple:!1}],[20532,{name:"ContentCompression",level:5,type:"m",minver:1,webm:!1,description:"Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.",multiple:!1}],[20533,{name:"ContentEncryption",level:5,type:"m",minver:1,webm:!1,description:"Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.",multiple:!1}],[21368,{name:"CueBlockNumber",level:4,type:"u",minver:1,default:1,range:"not 0",description:"Number of the Block in the specified Cluster.",multiple:!1}],[22100,{name:"ChapterStringUID",level:4,type:"8",mandatory:!1,minver:3,webm:!0,description:"A unique string ID to identify the Chapter. Use for WebVTT cue identifier storage.",multiple:!1}],[22337,{name:"WritingApp",level:2,type:"8",mandatory:!0,minver:1,multiple:!1,description:'Writing application ("mkvmerge-0.3.3").'}],[22612,{name:"SilentTracks",cppname:"ClusterSilentTracks",level:2,type:"m",minver:1,multiple:!1,webm:!1,description:"The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use."}],[25152,{name:"ContentEncoding",level:4,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Settings for one content encoding like compression or encryption."}],[25188,{name:"BitDepth",cppname:"AudioBitDepth",level:4,type:"u",minver:1,range:"not 0",multiple:!1,description:"Bits per sample, mostly used for PCM."}],[25906,{name:"SignedElement",level:3,type:"b",multiple:!0,webm:!1,description:"An element ID whose data will be used to compute the signature."}],[26148,{name:"TrackTranslate",level:3,type:"m",multiple:!0,minver:1,webm:!1,description:"The track identification for the given Chapter Codec."}],[26897,{name:"ChapProcessCommand",cppname:"ChapterProcessCommand",level:5,type:"m",multiple:!0,minver:1,webm:!1,description:"Contains all the commands associated to the Atom."}],[26914,{name:"ChapProcessTime",cppname:"ChapterProcessTime",level:6,type:"u",mandatory:!0,minver:1,webm:!1,description:"Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter)."}],[26916,{name:"ChapterTranslate",level:2,type:"m",multiple:!0,minver:1,webm:!1,description:"A tuple of corresponding ID used by chapter codecs to represent this segment."}],[26931,{name:"ChapProcessData",cppname:"ChapterProcessData",level:6,type:"b",mandatory:!0,minver:1,webm:!1,description:"Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands."}],[26948,{name:"ChapProcess",cppname:"ChapterProcess",level:4,type:"m",multiple:!0,minver:1,webm:!1,description:"Contains all the commands associated to the Atom."}],[26965,{name:"ChapProcessCodecID",cppname:"ChapterProcessCodecID",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later."}],[29555,{name:"Tag",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Element containing elements specific to Tracks/Chapters."}],[29572,{name:"SegmentFilename",level:2,type:"8",minver:1,webm:!1,description:"A filename corresponding to this segment."}],[29766,{name:"AttachmentLink",cppname:"TrackAttachmentLink",level:3,type:"u",minver:1,webm:!1,range:"not 0",description:"The UID of an attachment that is used by this codec."}],[2459272,{name:"CodecName",level:3,type:"8",minver:1,description:"A human-readable string specifying the codec."}],[0x18538067,{name:"Segment",level:0,type:"m",mandatory:!0,multiple:!0,minver:1,description:"This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment."}],[17530,{name:"TagLanguage",level:4,type:"s",mandatory:!0,minver:1,webm:!1,default:"und",description:"Specifies the language of the tag specified, in the Matroska languages form."}],[17827,{name:"TagName",level:4,type:"8",mandatory:!0,minver:1,webm:!1,description:"The name of the Tag that is going to be stored."}],[26568,{name:"SimpleTag",cppname:"TagSimple",level:3,recursive:!0,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Contains general information about the target."}],[25542,{name:"TagAttachmentUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment."}],[25540,{name:"TagChapterUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment."}],[25545,{name:"TagEditionUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment."}],[25541,{name:"TagTrackUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment."}],[25546,{name:"TargetType",cppname:"TagTargetType",level:4,type:"s",minver:1,webm:!1,strong:"informational",description:'An string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType).'}],[26826,{name:"TargetTypeValue",cppname:"TagTargetTypeValue",level:4,type:"u",minver:1,webm:!1,default:50,description:"A number to indicate the logical level of the target (see TargetType)."}],[25536,{name:"Targets",cppname:"TagTargets",level:3,type:"m",mandatory:!0,minver:1,webm:!1,description:"Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment."}],[0x1254c367,{name:"Tags",level:1,type:"m",multiple:!0,minver:1,webm:!1,description:"Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here."}],[17677,{name:"ChapProcessPrivate",cppname:"ChapterProcessPrivate",level:5,type:"b",minver:1,webm:!1,description:'Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent.'}],[17278,{name:"ChapCountry",cppname:"ChapterCountry",level:5,type:"s",multiple:!0,minver:1,webm:!1,description:"The countries corresponding to the string, same 2 octets as in Internet domains."}],[17276,{name:"ChapLanguage",cppname:"ChapterLanguage",level:5,type:"s",mandatory:!0,multiple:!0,minver:1,webm:!0,default:"eng",description:"The languages corresponding to the string, in the bibliographic ISO-639-2 form."}],[143,{name:"ChapterTrack",level:4,type:"m",minver:1,webm:!1,description:"List of tracks on which the chapter applies. If this element is not present, all tracks apply"}],[25539,{name:"ChapterPhysicalEquiv",level:4,type:"u",minver:1,webm:!1,description:'Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values.'}],[28348,{name:"ChapterSegmentEditionUID",level:4,type:"u",minver:1,webm:!1,range:"not 0",description:"The EditionUID to play from the segment linked in ChapterSegmentUID."}],[28263,{name:"ChapterSegmentUID",level:4,type:"b",minver:1,webm:!1,range:">0",bytesize:16,description:"A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used."}],[29636,{name:"ChapterUID",level:4,type:"u",mandatory:!0,minver:1,webm:!0,range:"not 0",description:"A unique ID to identify the Chapter."}],[182,{name:"ChapterAtom",level:3,recursive:!0,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!0,description:"Contains the atom information to use as the chapter atom (apply to all tracks)."}],[17885,{name:"EditionFlagOrdered",level:3,type:"u",minver:1,webm:!1,default:0,range:"0-1",description:"Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)"}],[17883,{name:"EditionFlagDefault",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,range:"0-1",description:"If a flag is set (1) the edition should be used as the default one. (1 bit)"}],[17853,{name:"EditionFlagHidden",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,range:"0-1",description:"If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)"}],[17852,{name:"EditionUID",level:3,type:"u",minver:1,webm:!1,range:"not 0",description:"A unique ID to identify the edition. It's useful for tagging an edition."}],[17849,{name:"EditionEntry",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!0,description:"Contains all information about a segment edition."}],[0x1043a770,{name:"Chapters",level:1,type:"m",minver:1,webm:!0,description:"A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation."}],[18094,{name:"FileUID",level:3,type:"u",mandatory:!0,minver:1,webm:!1,range:"not 0",description:"Unique ID representing the file, as random as possible."}],[18012,{name:"FileData",level:3,type:"b",mandatory:!0,minver:1,webm:!1,description:"The data of the file."}],[18030,{name:"FileName",level:3,type:"8",mandatory:!0,minver:1,webm:!1,description:"Filename of the attached file."}],[18046,{name:"FileDescription",level:3,type:"8",minver:1,webm:!1,description:"A human-friendly name for the attached file."}],[24999,{name:"AttachedFile",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"An attached file."}],[0x1941a469,{name:"Attachments",level:1,type:"m",minver:1,webm:!1,description:"Contain attached files."}],[235,{name:"CueRefCodecState",level:5,type:"u",webm:!1,default:0,description:"The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry."}],[21343,{name:"CueRefNumber",level:5,type:"u",webm:!1,default:1,range:"not 0",description:"Number of the referenced Block of Track X in the specified Cluster."}],[219,{name:"CueReference",level:4,type:"m",multiple:!0,minver:2,webm:!1,description:"The Clusters containing the required referenced Blocks."}],[234,{name:"CueCodecState",level:4,type:"u",minver:2,webm:!1,default:0,description:"The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry."}],[178,{name:"CueDuration",level:4,type:"u",mandatory:!1,minver:4,webm:!1,description:"The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues."}],[240,{name:"CueRelativePosition",level:4,type:"u",mandatory:!1,minver:4,webm:!1,description:"The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster."}],[241,{name:"CueClusterPosition",level:4,type:"u",mandatory:!0,minver:1,description:"The position of the Cluster containing the required Block."}],[247,{name:"CueTrack",level:4,type:"u",mandatory:!0,minver:1,range:"not 0",description:"The track for which a position is given."}],[183,{name:"CueTrackPositions",level:3,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contain positions for different tracks corresponding to the timestamp."}],[179,{name:"CueTime",level:3,type:"u",mandatory:!0,minver:1,description:"Absolute timestamp according to the segment time base."}],[187,{name:"CuePoint",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contains all information relative to a seek point in the segment."}],[0x1c53bb6b,{name:"Cues",level:1,type:"m",minver:1,description:'A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.'}],[18406,{name:"ContentSigHashAlgo",level:6,type:"u",minver:1,webm:!1,default:0,br:["",""],description:"The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - SHA1-160 2 - MD5"}],[18405,{name:"ContentSigAlgo",level:6,type:"u",minver:1,webm:!1,default:0,br:"",description:"The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - RSA"}],[18404,{name:"ContentSigKeyID",level:6,type:"b",minver:1,webm:!1,description:"This is the ID of the private key the data was signed with."}],[18403,{name:"ContentSignature",level:6,type:"b",minver:1,webm:!1,description:"A cryptographic signature of the contents."}],[18402,{name:"ContentEncKeyID",level:6,type:"b",minver:1,webm:!1,description:"For public key algorithms this is the ID of the public key the the data was encrypted with."}],[18401,{name:"ContentEncAlgo",level:6,type:"u",minver:1,webm:!1,default:0,br:"",description:"The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: 1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES"}],[28032,{name:"ContentEncodings",level:3,type:"m",minver:1,webm:!1,description:"Settings for several content encoding mechanisms like compression or encryption."}],[196,{name:"TrickMasterTrackSegmentUID",level:3,type:"b",divx:!0,bytesize:16,description:"DivX trick track extenstions"}],[199,{name:"TrickMasterTrackUID",level:3,type:"u",divx:!0,description:"DivX trick track extenstions"}],[198,{name:"TrickTrackFlag",level:3,type:"u",divx:!0,default:0,description:"DivX trick track extenstions"}],[193,{name:"TrickTrackSegmentUID",level:3,type:"b",divx:!0,bytesize:16,description:"DivX trick track extenstions"}],[192,{name:"TrickTrackUID",level:3,type:"u",divx:!0,description:"DivX trick track extenstions"}],[237,{name:"TrackJoinUID",level:5,type:"u",mandatory:!0,multiple:!0,minver:3,webm:!1,range:"not 0",description:"The trackUID number of a track whose blocks are used to create this virtual track."}],[233,{name:"TrackJoinBlocks",level:4,type:"m",minver:3,webm:!1,description:"Contains the list of all tracks whose Blocks need to be combined to create this virtual track"}],[230,{name:"TrackPlaneType",level:6,type:"u",mandatory:!0,minver:3,webm:!1,description:"The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background)."}],[229,{name:"TrackPlaneUID",level:6,type:"u",mandatory:!0,minver:3,webm:!1,range:"not 0",description:"The trackUID number of the track representing the plane."}],[228,{name:"TrackPlane",level:5,type:"m",mandatory:!0,multiple:!0,minver:3,webm:!1,description:"Contains a video plane track that need to be combined to create this 3D track"}],[227,{name:"TrackCombinePlanes",level:4,type:"m",minver:3,webm:!1,description:"Contains the list of all video plane tracks that need to be combined to create this 3D track"}],[226,{name:"TrackOperation",level:3,type:"m",minver:3,webm:!1,description:"Operation that needs to be applied on tracks to create this virtual track. For more details look at the Specification Notes on the subject."}],[32123,{name:"ChannelPositions",cppname:"AudioPosition",level:4,type:"b",webm:!1,description:"Table of horizontal angles for each successive channel, see appendix."}],[159,{name:"Channels",cppname:"AudioChannels",level:4,type:"u",mandatory:!0,minver:1,default:1,range:"not 0",description:"Numbers of channels in the track."}],[30901,{name:"OutputSamplingFrequency",cppname:"AudioOutputSamplingFreq",level:4,type:"f",minver:1,default:"Sampling Frequency",range:"> 0",description:"Real output sampling frequency in Hz (used for SBR techniques)."}],[181,{name:"SamplingFrequency",cppname:"AudioSamplingFreq",level:4,type:"f",mandatory:!0,minver:1,default:"8000.0",range:"> 0",description:"Sampling frequency in Hz."}],[225,{name:"Audio",cppname:"TrackAudio",level:3,type:"m",minver:1,description:"Audio settings."}],[2327523,{name:"FrameRate",cppname:"VideoFrameRate",level:4,type:"f",range:"> 0",strong:"Informational",description:"Number of frames per second. only."}],[3126563,{name:"GammaValue",cppname:"VideoGamma",level:4,type:"f",webm:!1,range:"> 0",description:"Gamma Value."}],[3061028,{name:"ColourSpace",cppname:"VideoColourSpace",level:4,type:"b",minver:1,webm:!1,bytesize:4,description:"Same value as in AVI (32 bits)."}],[21683,{name:"AspectRatioType",cppname:"VideoAspectRatio",level:4,type:"u",minver:1,default:0,description:"Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed)."}],[21682,{name:"DisplayUnit",cppname:"VideoDisplayUnit",level:4,type:"u",minver:1,default:0,description:"How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio)."}],[21690,{name:"DisplayHeight",cppname:"VideoDisplayHeight",level:4,type:"u",minver:1,default:"PixelHeight",range:"not 0",description:"Height of the video frames to display. The default value is only valid when DisplayUnit is 0."}],[21680,{name:"DisplayWidth",cppname:"VideoDisplayWidth",level:4,type:"u",minver:1,default:"PixelWidth",range:"not 0",description:"Width of the video frames to display. The default value is only valid when DisplayUnit is 0."}],[21725,{name:"PixelCropRight",cppname:"VideoPixelCropRight",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove on the right of the image."}],[21708,{name:"PixelCropLeft",cppname:"VideoPixelCropLeft",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove on the left of the image."}],[21691,{name:"PixelCropTop",cppname:"VideoPixelCropTop",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove at the top of the image."}],[21674,{name:"PixelCropBottom",cppname:"VideoPixelCropBottom",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove at the bottom of the image (for HDTV content)."}],[186,{name:"PixelHeight",cppname:"VideoPixelHeight",level:4,type:"u",mandatory:!0,minver:1,range:"not 0",description:"Height of the encoded video frames in pixels."}],[176,{name:"PixelWidth",cppname:"VideoPixelWidth",level:4,type:"u",mandatory:!0,minver:1,range:"not 0",description:"Width of the encoded video frames in pixels."}],[21433,{name:"OldStereoMode",level:4,type:"u",maxver:"0",webm:!1,divx:!1,description:"DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes)."}],[21440,{name:"AlphaMode",cppname:"VideoAlphaMode",level:4,type:"u",minver:3,webm:!0,default:0,description:"Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data."}],[21432,{name:"StereoMode",cppname:"VideoStereoMode",level:4,type:"u",minver:3,webm:!0,default:0,description:"Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on 3D support in the Specification Notes."}],[154,{name:"FlagInterlaced",cppname:"VideoFlagInterlaced",level:4,type:"u",mandatory:!0,minver:2,webm:!0,default:0,range:"0-1",description:"Set if the video is interlaced. (1 bit)"}],[224,{name:"Video",cppname:"TrackVideo",level:3,type:"m",minver:1,description:"Video settings."}],[26277,{name:"TrackTranslateTrackID",level:4,type:"b",mandatory:!0,minver:1,webm:!1,description:"The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used."}],[26303,{name:"TrackTranslateCodec",level:4,type:"u",mandatory:!0,minver:1,webm:!1,description:"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)."}],[26364,{name:"TrackTranslateEditionUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,description:"Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment."}],[22203,{name:"SeekPreRoll",level:3,type:"u",mandatory:!0,multiple:!1,default:0,minver:4,webm:!0,description:"After a discontinuity, SeekPreRoll is the duration in nanoseconds of the data the decoder must decode before the decoded data is valid."}],[22186,{name:"CodecDelay",level:3,type:"u",multiple:!1,default:0,minver:4,webm:!0,description:"CodecDelay is The codec-built-in delay in nanoseconds. This value must be subtracted from each block timestamp in order to get the actual timestamp. The value should be small so the muxing of tracks with the same actual timestamp are in the same Cluster."}],[28587,{name:"TrackOverlay",level:3,type:"u",multiple:!0,minver:1,webm:!1,description:"Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc."}],[170,{name:"CodecDecodeAll",level:3,type:"u",mandatory:!0,minver:2,webm:!1,default:1,range:"0-1",description:"The codec can decode potentially damaged data (1 bit)."}],[2536e3,{name:"CodecDownloadURL",level:3,type:"s",multiple:!0,webm:!1,description:"A URL to download about the codec used."}],[3883072,{name:"CodecInfoURL",level:3,type:"s",multiple:!0,webm:!1,description:"A URL to find information about the codec used."}],[3839639,{name:"CodecSettings",level:3,type:"8",webm:!1,description:"A string describing the encoding setting used."}],[25506,{name:"CodecPrivate",level:3,type:"b",minver:1,description:"Private data only known to the codec."}],[2274716,{name:"Language",cppname:"TrackLanguage",level:3,type:"s",minver:1,default:"eng",description:"Specifies the language of the track in the Matroska languages form."}],[21358,{name:"Name",cppname:"TrackName",level:3,type:"8",minver:1,description:"A human-readable track name."}],[21998,{name:"MaxBlockAdditionID",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"The maximum value of BlockAdditions for this track."}],[21375,{name:"TrackOffset",level:3,type:"i",webm:!1,default:0,description:"A value to add to the Block's Timestamp. This can be used to adjust the playback offset of a track."}],[2306383,{name:"TrackTimecodeScale",level:3,type:"f",mandatory:!0,minver:1,maxver:"3",webm:!1,default:"1.0",range:"> 0",description:"DEPRECATED, DO NOT USE. The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs)."}],[2313850,{name:"DefaultDecodedFieldDuration",cppname:"TrackDefaultDecodedFieldDuration",level:3,type:"u",minver:4,range:"not 0",description:"The period in nanoseconds (not scaled by TimcodeScale)\nbetween two successive fields at the output of the decoding process (see the notes)"}],[2352003,{name:"DefaultDuration",cppname:"TrackDefaultDuration",level:3,type:"u",minver:1,range:"not 0",description:"Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block)."}],[28152,{name:"MaxCache",cppname:"TrackMaxCache",level:3,type:"u",minver:1,webm:!1,description:"The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed."}],[28135,{name:"MinCache",cppname:"TrackMinCache",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used."}],[156,{name:"FlagLacing",cppname:"TrackFlagLacing",level:3,type:"u",mandatory:!0,minver:1,default:1,range:"0-1",description:"Set if the track may contain blocks using lacing. (1 bit)"}],[21930,{name:"FlagForced",cppname:"TrackFlagForced",level:3,type:"u",mandatory:!0,minver:1,default:0,range:"0-1",description:"Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit)"}],[185,{name:"FlagEnabled",cppname:"TrackFlagEnabled",level:3,type:"u",mandatory:!0,minver:2,webm:!0,default:1,range:"0-1",description:"Set if the track is usable. (1 bit)"}],[29637,{name:"TrackUID",level:3,type:"u",mandatory:!0,minver:1,range:"not 0",description:"A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file."}],[215,{name:"TrackNumber",level:3,type:"u",mandatory:!0,minver:1,range:"not 0",description:"The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number)."}],[174,{name:"TrackEntry",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Describes a track with all elements."}],[0x1654ae6b,{name:"Tracks",level:1,type:"m",multiple:!0,minver:1,description:"A top-level block of information with many tracks described."}],[175,{name:"EncryptedBlock",level:2,type:"b",multiple:!0,webm:!1,description:"Similar to EncryptedBlock Structure)"}],[202,{name:"ReferenceTimeCode",level:4,type:"u",multiple:!1,mandatory:!0,minver:0,webm:!1,divx:!0,description:"DivX trick track extenstions"}],[201,{name:"ReferenceOffset",level:4,type:"u",multiple:!1,mandatory:!0,minver:0,webm:!1,divx:!0,description:"DivX trick track extenstions"}],[200,{name:"ReferenceFrame",level:3,type:"m",multiple:!1,minver:0,webm:!1,divx:!0,description:"DivX trick track extenstions"}],[207,{name:"SliceDuration",level:5,type:"u",default:0,description:"The (scaled) duration to apply to the element."}],[206,{name:"Delay",cppname:"SliceDelay",level:5,type:"u",default:0,description:"The (scaled) delay to apply to the element."}],[203,{name:"BlockAdditionID",cppname:"SliceBlockAddID",level:5,type:"u",default:0,description:"The ID of the BlockAdditional element (0 is the main Block)."}],[205,{name:"FrameNumber",cppname:"SliceFrameNumber",level:5,type:"u",default:0,description:"The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame)."}],[204,{name:"LaceNumber",cppname:"SliceLaceNumber",level:5,type:"u",minver:1,default:0,divx:!1,description:"The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback."}],[232,{name:"TimeSlice",level:4,type:"m",multiple:!0,minver:1,divx:!1,description:"Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback."}],[142,{name:"Slices",level:3,type:"m",minver:1,divx:!1,description:"Contains slices description."}],[30114,{name:"DiscardPadding",level:3,type:"i",minver:4,webm:!0,description:"Duration in nanoseconds of the silent data added to the Block (padding at the end of the Block for positive value, at the beginning of the Block for negative value). The duration of DiscardPadding is not calculated in the duration of the TrackEntry and should be discarded during playback."}],[164,{name:"CodecState",level:3,type:"b",minver:2,webm:!1,description:"The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry."}],[253,{name:"ReferenceVirtual",level:3,type:"i",webm:!1,description:"Relative position of the data that should be in position of the virtual block."}],[251,{name:"ReferenceBlock",level:3,type:"i",multiple:!0,minver:1,description:"Timestamp of another frame used as a reference (ie: B or P frame). The timestamp is relative to the block it's attached to."}],[250,{name:"ReferencePriority",cppname:"FlagReferenced",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced."}],[155,{name:"BlockDuration",level:3,type:"u",minver:1,default:"TrackDuration",description:'The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timestamp of this Block and the timestamp of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe.'}],[165,{name:"BlockAdditional",level:5,type:"b",mandatory:!0,minver:1,webm:!1,description:"Interpreted by the codec as it wishes (using the BlockAddID)."}],[238,{name:"BlockAddID",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"not 0",description:"An ID to identify the BlockAdditional level."}],[166,{name:"BlockMore",level:4,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Contain the BlockAdditional and some parameters."}],[30113,{name:"BlockAdditions",level:3,type:"m",minver:1,webm:!1,description:"Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data."}],[162,{name:"BlockVirtual",level:3,type:"b",webm:!1,description:"A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual)"}],[161,{name:"Block",level:3,type:"b",mandatory:!0,minver:1,description:"Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)"}],[160,{name:"BlockGroup",level:2,type:"m",multiple:!0,minver:1,description:"Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock."}],[163,{name:"SimpleBlock",level:2,type:"b",multiple:!0,minver:2,webm:!0,divx:!0,description:"Similar to SimpleBlock Structure)"}],[171,{name:"PrevSize",cppname:"ClusterPrevSize",level:2,type:"u",minver:1,description:"Size of the previous Cluster, in octets. Can be useful for backward playing."}],[167,{name:"Position",cppname:"ClusterPosition",level:2,type:"u",minver:1,webm:!1,description:"The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams."}],[22743,{name:"SilentTrackNumber",cppname:"ClusterSilentTrackNumber",level:3,type:"u",multiple:!0,minver:1,webm:!1,description:"One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster."}],[231,{name:"Timecode",cppname:"ClusterTimecode",level:2,type:"u",mandatory:!0,minver:1,description:"Absolute timestamp of the cluster (based on TimecodeScale)."}],[0x1f43b675,{name:"Cluster",level:1,type:"m",multiple:!0,minver:1,description:"The lower level element containing the (monolithic) Block structure."}],[19840,{name:"MuxingApp",level:2,type:"8",mandatory:!0,minver:1,description:'Muxing application or library ("libmatroska-0.4.3").'}],[31657,{name:"Title",level:2,type:"8",minver:1,webm:!1,description:"General name of the segment."}],[2807730,{name:"TimecodeScaleDenominator",level:2,type:"u",mandatory:!0,minver:4,default:1e9,description:"Timestamp scale numerator, see TimecodeScale."}],[2807729,{name:"TimecodeScale",level:2,type:"u",mandatory:!0,minver:1,default:1e6,description:"Timestamp scale in nanoseconds (1.000.000 means all timestamps in the segment are expressed in milliseconds)."}],[27045,{name:"ChapterTranslateID",level:3,type:"b",mandatory:!0,minver:1,webm:!1,description:"The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used."}],[27071,{name:"ChapterTranslateCodec",level:3,type:"u",mandatory:!0,minver:1,webm:!1,description:"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)."}],[27132,{name:"ChapterTranslateEditionUID",level:3,type:"u",multiple:!0,minver:1,webm:!1,description:"Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment."}],[4096955,{name:"NextFilename",level:2,type:"8",minver:1,webm:!1,description:"An escaped filename corresponding to the next segment."}],[4110627,{name:"NextUID",level:2,type:"b",minver:1,webm:!1,bytesize:16,description:"A unique ID to identify the next chained segment (128 bits)."}],[3965867,{name:"PrevFilename",level:2,type:"8",minver:1,webm:!1,description:"An escaped filename corresponding to the previous segment."}],[3979555,{name:"PrevUID",level:2,type:"b",minver:1,webm:!1,bytesize:16,description:"A unique ID to identify the previous chained segment (128 bits)."}],[29604,{name:"SegmentUID",level:2,type:"b",minver:1,webm:!1,range:"not 0",bytesize:16,description:"A randomly generated unique ID to identify the current segment between many others (128 bits)."}],[0x1549a966,{name:"Info",level:1,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contains miscellaneous general information and statistics on the file."}],[21420,{name:"SeekPosition",level:3,type:"u",mandatory:!0,minver:1,description:"The position of the element in the segment in octets (0 = first level 1 element)."}],[21419,{name:"SeekID",level:3,type:"b",mandatory:!0,minver:1,description:"The binary ID corresponding to the element name."}],[19899,{name:"Seek",cppname:"SeekPoint",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contains a single seek entry to an EBML element."}],[0x114d9b74,{name:"SeekHead",cppname:"SeekHeader",level:1,type:"m",multiple:!0,minver:1,description:"Contains the position of other level 1 elements."}],[32379,{name:"SignatureElementList",level:2,type:"m",multiple:!0,webm:!1,i:"Cluster|Block|BlockAdditional",description:"A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: means that the BlockAdditional of all Blocks in all Clusters is used for encryption."}],[32347,{name:"SignatureElements",level:1,type:"m",webm:!1,description:"Contains elements that will be used to compute the signature."}],[32437,{name:"Signature",level:1,type:"b",webm:!1,description:"The signature of the data (until a new."}],[32421,{name:"SignaturePublicKey",level:1,type:"b",webm:!1,description:"The public key to use with the algorithm (in the case of a PKI-based signature)."}],[32410,{name:"SignatureHash",level:1,type:"u",webm:!1,description:"Hash algorithm used (1=SHA1-160, 2=MD5)."}],[32394,{name:"SignatureAlgo",level:1,type:"u",webm:!1,description:"Signature algorithm used (1=RSA, 2=elliptic)."}],[0x1b538667,{name:"SignatureSlot",level:-1,type:"m",multiple:!0,webm:!1,description:"Contain signature of some (coming) elements in the stream."}],[191,{name:"CRC-32",level:-1,type:"b",minver:1,webm:!1,description:"The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian"}],[236,{name:"Void",level:-1,type:"b",minver:1,description:"Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use."}],[17139,{name:"EBMLMaxSizeLength",level:1,type:"u",mandatory:!0,default:8,minver:1,description:"The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid."}],[17138,{name:"EBMLMaxIDLength",level:1,type:"u",mandatory:!0,default:4,minver:1,description:"The maximum length of the IDs you'll find in this file (4 or less in Matroska)."}],[17143,{name:"EBMLReadVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The minimum EBML version a parser has to support to read this file."}],[0x1a45dfa3,{name:"EBML",level:0,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Set the EBML characteristics of the data to follow. Each EBML document has to start with this."}]]),nC=Math.floor;eP(eP.S,"Number",{isInteger:function(e){return!ei(e)&&isFinite(e)&&nC(e)===e}});var nT=ec.parseInt,nA=ts.trim,nR=/^[-+]?0[xX]/,nI=8!==nT(te+"08")||22!==nT(te+"0x16")?function(e,t){var n=nA(String(e),3);return nT(n,t>>>0||(nR.test(n)?16:10))}:nT;function nO(){}function nP(){nP.init.call(this)}function nM(e){return void 0===e._maxListeners?nP.defaultMaxListeners:e._maxListeners}function nD(e,t,n,r){if("function"!=typeof n)throw TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new nO,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(s=nM(e))&&s>0&&o.length>s){o.warned=!0;var i,s,a,o,l=Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,i=l,"function"==typeof console.warn?console.warn(i):console.log(i)}}else o=a[t]=n,++e._eventsCount;return e}function nL(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function n$(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function nN(e,t){for(var n=Array(t);t--;)n[t]=e[t];return n}function nU(){throw Error("setTimeout has not been defined")}function nB(){throw Error("clearTimeout has not been defined")}eP(eP.S+eP.F*(Number.parseInt!=nI),"Number",{parseInt:nI}),nO.prototype=Object.create(null),nP.EventEmitter=nP,nP.usingDomains=!1,nP.prototype.domain=void 0,nP.prototype._events=void 0,nP.prototype._maxListeners=void 0,nP.defaultMaxListeners=10,nP.init=function(){this.domain=null,nP.usingDomains&&r.active&&r.Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new nO,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},nP.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},nP.prototype.getMaxListeners=function(){return nM(this)},nP.prototype.emit=function(e){var t,n,r,i,s,a,o,l="error"===e;if(a=this._events)l=l&&null==a.error;else if(!l)return!1;if(o=this.domain,l){if(t=arguments[1],o)t||(t=Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=o,t.domainThrown=!1,o.emit("error",t);else if(t instanceof Error)throw t;else{var c=Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return!1}if(!(n=a[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=nN(e,r),s=0;s<r;++s)i[s].call(n)}(n,u,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=nN(e,i),a=0;a<i;++a)s[a].call(n,r)}(n,u,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,a=nN(e,s),o=0;o<s;++o)a[o].call(n,r,i)}(n,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var a=e.length,o=nN(e,a),l=0;l<a;++l)o[l].call(n,r,i,s)}(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(s=1,i=Array(r-1);s<r;s++)i[s-1]=arguments[s];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=nN(e,i),a=0;a<i;++a)s[a].apply(n,r)}(n,u,this,i)}return!0},nP.prototype.addListener=function(e,t){return nD(this,e,t,!1)},nP.prototype.on=nP.prototype.addListener,nP.prototype.prependListener=function(e,t){return nD(this,e,t,!0)},nP.prototype.once=function(e,t){if("function"!=typeof t)throw TypeError('"listener" argument must be a function');return this.on(e,nL(this,e,t)),this},nP.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw TypeError('"listener" argument must be a function');return this.prependListener(e,nL(this,e,t)),this},nP.prototype.removeListener=function(e,t){var n,r,i,s,a;if("function"!=typeof t)throw TypeError('"listener" argument must be a function');if(!(r=this._events)||!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new nO:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new nO,this;delete r[e]}else{for(var o=n,l=i,c=l,u=c+1,h=o.length;u<h;c+=1,u+=1)o[c]=o[u];o.pop()}r.removeListener&&this.emit("removeListener",e,a||t)}return this},nP.prototype.removeAllListeners=function(e){if(!(n=this._events))return this;if(!n.removeListener)return 0==arguments.length?(this._events=new nO,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new nO:delete n[e]),this;if(0==arguments.length){for(var t,n,r,i=Object.keys(n),s=0;s<i.length;++s)"removeListener"!==(r=i[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new nO,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do this.removeListener(e,t[t.length-1]);while(t[0])return this},nP.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[]},nP.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):n$.call(e,t)},nP.prototype.listenerCount=n$,nP.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var nF=nU,nj=nB;function nH(e){if(nF===setTimeout)return setTimeout(e,0);if((nF===nU||!nF)&&setTimeout)return nF=setTimeout,setTimeout(e,0);try{return nF(e,0)}catch(t){try{return nF.call(null,e,0)}catch(t){return nF.call(this,e,0)}}}"function"==typeof a.setTimeout&&(nF=setTimeout),"function"==typeof a.clearTimeout&&(nj=clearTimeout);var nW=[],nq=!1,nz=-1;function nV(){nq&&i&&(nq=!1,i.length?nW=i.concat(nW):nz=-1,nW.length&&nK())}function nK(){if(!nq){var e=nH(nV);nq=!0;for(var t=nW.length;t;){for(i=nW,nW=[];++nz<t;)i&&i[nz].run();nz=-1,t=nW.length}i=null,nq=!1,function(e){if(nj===clearTimeout)return clearTimeout(e);if((nj===nB||!nj)&&clearTimeout)return nj=clearTimeout,clearTimeout(e);try{nj(e)}catch(t){try{return nj.call(null,e)}catch(t){return nj.call(this,e)}}}(e)}}function nY(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];nW.push(new nG(e,t)),1!==nW.length||nq||nH(nK)}function nG(e,t){this.fun=e,this.array=t}nG.prototype.run=function(){this.fun.apply(null,this.array)};var nX=a.performance||{},nJ=(nX.now||nX.mozNow||nX.msNow||nX.oNow||nX.webkitNow,"function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}),nQ=/%[sdj%]/g;function nZ(e){if(!n9(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(n1(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,i=r.length,s=String(e).replace(nQ,function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),a=r[n];n<i;a=r[++n])null!==a&&rt(a)?s+=" "+n1(a):s+=" "+a;return s}var n0={};function n1(e,t){var n={seen:[],stylize:n3};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),n5(t)?n.showHidden=t:t&&function(e,t){if(t&&rt(t))for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]]}(n,t),n7(n.showHidden)&&(n.showHidden=!1),n7(n.depth)&&(n.depth=2),n7(n.colors)&&(n.colors=!1),n7(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=n2),n6(n,e,n.depth)}function n2(e,t){var n=n1.styles[t];return n?"\x1b["+n1.colors[n][0]+"m"+e+"\x1b["+n1.colors[n][1]+"m":e}function n3(e,t){return e}function n6(e,t,n){if(e.customInspect&&t&&ri(t.inspect)&&t.inspect!==n1&&!(t.constructor&&t.constructor.prototype===t)){var r,i,s,a,o,l=t.inspect(n,e);return n9(l)||(l=n6(e,l,n)),l}var c=function(e,t){if(n7(t))return e.stylize("undefined","undefined");if(n9(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return"number"==typeof t?e.stylize(""+t,"number"):n5(t)?e.stylize(""+t,"boolean"):function(e){return null===e}(t)?e.stylize("null","null"):void 0}(e,t);if(c)return c;var u=Object.keys(t),h=(a={},u.forEach(function(e,t){a[e]=!0}),a);if(e.showHidden&&(u=Object.getOwnPropertyNames(t)),rr(t)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return n8(t);if(0===u.length){if(ri(t)){var d=t.name?": "+t.name:"";return e.stylize("[Function"+d+"]","special")}if(re(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(rn(t))return e.stylize(Date.prototype.toString.call(t),"date");if(rr(t))return n8(t)}var f="",p=!1,m=["{","}"];if(Array.isArray(t)&&(p=!0,m=["[","]"]),ri(t)&&(f=" [Function"+(t.name?": "+t.name:"")+"]"),re(t)&&(f=" "+RegExp.prototype.toString.call(t)),rn(t)&&(f=" "+Date.prototype.toUTCString.call(t)),rr(t)&&(f=" "+n8(t)),0===u.length&&(!p||0==t.length))return m[0]+f+m[1];if(n<0)if(re(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");else return e.stylize("[Object]","special");return e.seen.push(t),o=p?function(e,t,n,r,i){for(var s=[],a=0,o=t.length;a<o;++a)ra(t,String(a))?s.push(n4(e,t,n,r,String(a),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(n4(e,t,n,r,i,!0))}),s}(e,t,n,h,u):u.map(function(r){return n4(e,t,n,h,r,p)}),e.seen.pop(),r=o,i=f,s=m,r.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?s[0]+(""===i?"":i+"\n ")+" "+r.join(",\n ")+" "+s[1]:s[0]+i+" "+r.join(", ")+" "+s[1]}function n8(e){return"["+Error.prototype.toString.call(e)+"]"}function n4(e,t,n,r,i,s){var a,o,l;if((l=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?o=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(o=e.stylize("[Setter]","special")),ra(r,i)||(a="["+i+"]"),!o&&(0>e.seen.indexOf(l.value)?(o=null===n?n6(e,l.value,null):n6(e,l.value,n-1)).indexOf("\n")>-1&&(o=s?o.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return" "+e}).join("\n")):o=e.stylize("[Circular]","special")),n7(a)){if(s&&i.match(/^\d+$/))return o;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+o}function n5(e){return"boolean"==typeof e}n1.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},n1.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function n9(e){return"string"==typeof e}function n7(e){return void 0===e}function re(e){return rt(e)&&"[object RegExp]"===rs(e)}function rt(e){return"object"==typeof e&&null!==e}function rn(e){return rt(e)&&"[object Date]"===rs(e)}function rr(e){return rt(e)&&("[object Error]"===rs(e)||e instanceof Error)}function ri(e){return"function"==typeof e}function rs(e){return Object.prototype.toString.call(e)}function ra(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ro(){this.head=null,this.tail=null,this.length=0}ro.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},ro.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},ro.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},ro.prototype.clear=function(){this.head=this.tail=null,this.length=0},ro.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},ro.prototype.concat=function(e){if(0===this.length)return v.alloc(0);if(1===this.length)return this.head.data;for(var t=v.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t};var rl=v.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function rc(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");if(e&&!rl(e))throw Error("Unknown encoding: "+e);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=rh;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=rd;break;default:this.write=ru;return}this.charBuffer=new v(6),this.charReceived=0,this.charLength=0}function ru(e){return e.toString(this.encoding)}function rh(e){this.charReceived=e.length%2,this.charLength=2*!!this.charReceived}function rd(e){this.charReceived=e.length%3,this.charLength=3*!!this.charReceived}rc.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";e=e.slice(n,e.length);var r=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1);if(r>=55296&&r<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived);var i=(t+=e.toString(this.encoding,0,i)).length-1,r=t.charCodeAt(i);if(r>=55296&&r<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),e.copy(this.charBuffer,0,0,s),t.substring(0,i)}return t},rc.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},rc.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t},rm.ReadableState=rp;var rf=(t="stream",n7(s)&&(s=""),n0[t=t.toUpperCase()]||(RegExp("\\b"+t+"\\b","i").test(s)?n0[t]=function(){var e=nZ.apply(null,arguments);console.error("%s %d: %s",t,0,e)}:n0[t]=function(){}),n0[t]);function rp(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof rH&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new ro,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new rc(e.encoding),this.encoding=e.encoding)}function rm(e){if(!(this instanceof rm))return new rm(e);this._readableState=new rp(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),nP.call(this)}function rg(e,t,n,r,i){var s,a,o,l=(c=t,h=null,q(u=n)||"string"==typeof u||null==u||c.objectMode||(h=TypeError("Invalid non-string/buffer chunk")),h);if(l)e.emit("error",l);else if(null===n)t.reading=!1,function(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,rb(e)}}(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var c,u,h,d,f=Error("stream.push() after EOF");e.emit("error",f)}else if(t.endEmitted&&i){var p=Error("stream.unshift() after end event");e.emit("error",p)}else{!t.decoder||i||r||(n=t.decoder.write(n),d=!t.objectMode&&0===n.length),i||(t.reading=!1),!d&&(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&rb(e))),s=e,(a=t).readingMore||(a.readingMore=!0,nY(rw,s,a))}else i||(t.reading=!1);return!(o=t).ended&&(o.needReadable||o.length<o.highWaterMark||0===o.length)}function ry(e,t){var n;if(e<=0||0===t.length&&t.ended)return 0;if(t.objectMode)return 1;if(e!=e)if(t.flowing&&t.length)return t.buffer.head.data.length;else return t.length;return(e>t.highWaterMark&&((n=e)>=8388608?n=8388608:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),t.highWaterMark=n),e<=t.length)?e:t.ended?t.length:(t.needReadable=!0,0)}function rb(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(rf("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?nY(rv,e):rv(e))}function rv(e){rf("emit readable"),e.emit("readable"),rx(e)}function rw(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(rf("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function r_(e){rf("readable nexttick read 0"),e.read(0)}function rS(e,t){t.reading||(rf("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),rx(e),t.flowing&&!t.reading&&e.read(0)}function rx(e){var t=e._readableState;for(rf("flow",t.flowing);t.flowing&&null!==e.read(););}function rE(e,t){var n,r,i,s,a;return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):(r=e,i=t.buffer,s=t.decoder,r<i.head.data.length?(a=i.head.data.slice(0,r),i.head.data=i.head.data.slice(r)):a=r===i.head.data.length?i.shift():s?function(e,t){var n=t.head,r=1,i=n.data;for(e-=i.length;n=n.next;){var s=n.data,a=e>s.length?s.length:e;if(a===s.length?i+=s:i+=s.slice(0,e),0==(e-=a)){a===s.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(a));break}++r}return t.length-=r,i}(r,i):function(e,t){var n=v.allocUnsafe(e),r=t.head,i=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var s=r.data,a=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,a),0==(e-=a)){a===s.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(a));break}++i}return t.length-=i,n}(r,i),n=a),n)}function rk(e){var t=e._readableState;if(t.length>0)throw Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,nY(rC,t,e))}function rC(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function rT(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return -1}function rA(){}function rR(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function rI(e,t){Object.defineProperty(this,"buffer",{get:function e(t,n){if(n7(a.process))return function(){return e(t,n).apply(this,arguments)};var r=!1;return function(){return r||(console.error(n),r=!0),t.apply(this,arguments)}}(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof rH&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=!1===e.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(n.writing=!1,n.writecb=null,n.length-=n.writelen,n.writelen=0,t)--n.pendingcb,r?nY(i,t):i(t),e._writableState.errorEmitted=!0,e.emit("error",t);else{var s=rL(n);s||n.corked||n.bufferProcessing||!n.bufferedRequest||rD(e,n),r?nY(rM,e,n,s,i):rM(e,n,s,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new rU(this)}function rO(e){if(!(this instanceof rO)&&!(this instanceof rH))return new rO(e);this._writableState=new rI(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),nP.call(this)}function rP(e,t,n,r,i,s,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,s,t.onwrite),t.sync=!1}function rM(e,t,n,r){var i,s;n||(i=e,0===(s=t).length&&s.needDrain&&(s.needDrain=!1,i.emit("drain"))),t.pendingcb--,r(),rN(e,t)}function rD(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=Array(t.bufferedRequestCount),i=t.corkedRequestsFree;i.entry=n;for(var s=0;n;)r[s]=n,n=n.next,s+=1;rP(e,t,!0,t.length,r,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new rU(t)}else{for(;n;){var a=n.chunk,o=n.encoding,l=n.callback,c=t.objectMode?1:a.length;if(rP(e,t,!1,c,a,o,l),n=n.next,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=n,t.bufferProcessing=!1}function rL(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function r$(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function rN(e,t){var n=rL(t);return n&&(0===t.pendingcb?(r$(e,t),t.finished=!0,e.emit("finish")):r$(e,t)),n}function rU(e){var t=this;this.next=null,this.entry=null,this.finish=function(n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}nJ(rm,nP),rm.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding)!==n.encoding&&(e=v.from(e,t),t=""),rg(this,n,e,t,!1)},rm.prototype.unshift=function(e){return rg(this,this._readableState,e,"",!0)},rm.prototype.isPaused=function(){return!1===this._readableState.flowing},rm.prototype.setEncoding=function(e){return this._readableState.decoder=new rc(e),this._readableState.encoding=e,this},rm.prototype.read=function(e){rf("read",e),e=parseInt(e,10);var t,n=this._readableState,r=e;if(0!==e&&(n.emittedReadable=!1),0===e&&n.needReadable&&(n.length>=n.highWaterMark||n.ended))return rf("read: emitReadable",n.length,n.ended),0===n.length&&n.ended?rk(this):rb(this),null;if(0===(e=ry(e,n))&&n.ended)return 0===n.length&&rk(this),null;var i=n.needReadable;return rf("need readable",i),(0===n.length||n.length-e<n.highWaterMark)&&rf("length less than watermark",i=!0),n.ended||n.reading?rf("reading or ended",i=!1):i&&(rf("do read"),n.reading=!0,n.sync=!0,0===n.length&&(n.needReadable=!0),this._read(n.highWaterMark),n.sync=!1,n.reading||(e=ry(r,n))),null===(t=e>0?rE(e,n):null)?(n.needReadable=!0,e=0):n.length-=e,0===n.length&&(n.ended||(n.needReadable=!0),r!==e&&n.ended&&rk(this)),null!==t&&this.emit("data",t),t},rm.prototype._read=function(e){this.emit("error",Error("not implemented"))},rm.prototype.pipe=function(e,t){var n,r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,rf("pipe count=%d opts=%j",i.pipesCount,t);var s=t&&!1===t.end?u:o;function a(e){rf("onunpipe"),e===r&&u()}function o(){rf("onend"),e.end()}i.endEmitted?nY(s):r.once("end",s),e.on("unpipe",a);var l=(n=r,function(){var e=n._readableState;rf("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&n.listeners("data").length&&(e.flowing=!0,rx(n))});e.on("drain",l);var c=!1;function u(){rf("cleanup"),e.removeListener("close",p),e.removeListener("finish",m),e.removeListener("drain",l),e.removeListener("error",f),e.removeListener("unpipe",a),r.removeListener("end",o),r.removeListener("end",u),r.removeListener("data",d),c=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&l()}var h=!1;function d(t){rf("ondata"),h=!1,!1!==e.write(t)||h||((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==rT(i.pipes,e))&&!c&&(rf("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,h=!0),r.pause())}function f(t){rf("onerror",t),g(),e.removeListener("error",f),0===e.listeners("error").length&&e.emit("error",t)}function p(){e.removeListener("finish",m),g()}function m(){rf("onfinish"),e.removeListener("close",p),g()}function g(){rf("unpipe"),r.unpipe(e)}return r.on("data",d),!function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",f),e.once("close",p),e.once("finish",m),e.emit("pipe",r),i.flowing||(rf("pipe resume"),r.resume()),e},rm.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var s=rT(t.pipes,e);return -1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this)),this},rm.prototype.on=function(e,t){var n=nP.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&rb(this,r):nY(r_,this))}return n},rm.prototype.addListener=rm.prototype.on,rm.prototype.resume=function(){var e,t,n=this._readableState;return n.flowing||(rf("resume"),n.flowing=!0,e=this,(t=n).resumeScheduled||(t.resumeScheduled=!0,nY(rS,e,t))),this},rm.prototype.pause=function(){return rf("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(rf("pause"),this._readableState.flowing=!1,this.emit("pause")),this},rm.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;for(var i in e.on("end",function(){if(rf("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){rf("wrapped data"),t.decoder&&(i=t.decoder.write(i)),t.objectMode&&null==i||(t.objectMode||i&&i.length)&&(r.push(i)||(n=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));return function(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)}(["error","close","destroy","pause","resume"],function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){rf("wrapped _read",t),n&&(n=!1,e.resume())},r},rm._fromList=rE,rO.WritableState=rI,nJ(rO,nP),rI.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},rO.prototype.pipe=function(){this.emit("error",Error("Cannot pipe, not readable"))},rO.prototype.write=function(e,t,n){var r,i,s,a,o,l=this._writableState,c=!1;return("function"==typeof t&&(n=t,t=null),v.isBuffer(e)?t="buffer":t||(t=l.defaultEncoding),"function"!=typeof n&&(n=rA),l.ended)?(r=n,i=Error("write after end"),this.emit("error",i),nY(r,i)):(s=n,a=!0,o=!1,null===e?o=TypeError("May not write null values to stream"):v.isBuffer(e)||"string"==typeof e||void 0===e||l.objectMode||(o=TypeError("Invalid non-string/buffer chunk")),o&&(this.emit("error",o),nY(s,o),a=!1),a&&(l.pendingcb++,c=function(e,t,n,r,i){s=n,a=r,t.objectMode||!1===t.decodeStrings||"string"!=typeof s||(s=v.from(s,a)),n=s,v.isBuffer(n)&&(r="buffer");var s,a,o=t.objectMode?1:n.length;t.length+=o;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var c=t.lastBufferedRequest;t.lastBufferedRequest=new rR(n,r,i),c?c.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else rP(e,t,!1,o,n,r,i);return l}(this,l,e,t,n))),c},rO.prototype.cork=function(){var e=this._writableState;e.corked++},rO.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||rD(this,e))},rO.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},rO.prototype._write=function(e,t,n){n(Error("not implemented"))},rO.prototype._writev=null,rO.prototype.end=function(e,t,n){var r,i,s,a=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),a.corked&&(a.corked=1,this.uncork()),a.ending||a.finished||(r=this,i=a,s=n,i.ending=!0,rN(r,i),s&&(i.finished?nY(s):r.once("finish",s)),i.ended=!0,r.writable=!1)},nJ(rH,rm);for(var rB=Object.keys(rO.prototype),rF=0;rF<rB.length;rF++){var rj=rB[rF];rH.prototype[rj]||(rH.prototype[rj]=rO.prototype[rj])}function rH(e){if(!(this instanceof rH))return new rH(e);rm.call(this,e),rO.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",rW)}function rW(){this.allowHalfOpen||this._writableState.ended||nY(rq,this)}function rq(e){e.end()}function rz(e){this.afterTransform=function(t,n){var r=e,i=t,s=n,a=r._transformState;a.transforming=!1;var o=a.writecb;if(!o)return r.emit("error",Error("no writecb in Transform class"));a.writechunk=null,a.writecb=null,null!=s&&r.push(s),o(i);var l=r._readableState;l.reading=!1,(l.needReadable||l.length<l.highWaterMark)&&r._read(l.highWaterMark)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function rV(e){if(!(this instanceof rV))return new rV(e);rH.call(this,e),this._transformState=new rz(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(e){rK(t,e)}):rK(t)})}function rK(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=e._transformState;if(n.length)throw Error("Calling transform done when ws.length != 0");if(r.transforming)throw Error("Calling transform done when still transforming");return e.push(null)}function rY(e){if(!(this instanceof rY))return new rY(e);rV.call(this,e)}function rG(){nP.call(this)}nJ(rV,rH),rV.prototype.push=function(e,t){return this._transformState.needTransform=!1,rH.prototype.push.call(this,e,t)},rV.prototype._transform=function(e,t,n){throw Error("Not implemented")},rV.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},rV.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},nJ(rY,rV),rY.prototype._transform=function(e,t,n){n(null,e)},nJ(rG,nP),rG.Readable=rm,rG.Writable=rO,rG.Duplex=rH,rG.Transform=rV,rG.PassThrough=rY,rG.Stream=rG,rG.prototype.pipe=function(e,t){var n=this;function r(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function i(){n.readable&&n.resume&&n.resume()}n.on("data",r),e.on("drain",i),e._isStdio||t&&!1===t.end||(n.on("end",a),n.on("close",o));var s=!1;function a(){s||(s=!0,e.end())}function o(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(c(),0===nP.listenerCount(this,"error"))throw e}function c(){n.removeListener("data",r),e.removeListener("drain",i),n.removeListener("end",a),n.removeListener("close",o),n.removeListener("error",l),e.removeListener("error",l),n.removeListener("end",c),n.removeListener("close",c),e.removeListener("close",c)}return n.on("error",l),e.on("error",l),n.on("end",c),n.on("close",c),e.on("close",c),e.emit("pipe",n),e};var rX=e.r(88539)("ebml:decoder"),rJ=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return V(this,t),G(et(et(e=en(this,Q(t).call(this,X({},n,{readableObjectMode:!0}))))),"mBuffer",null),G(et(et(e)),"mTagStack",[]),G(et(et(e)),"mState",1),G(et(et(e)),"mCursor",0),G(et(et(e)),"mTotal",0),e}return J(t,e),Y(t,[{key:"_transform",value:function(e,t,n){for(this.buffer?this.buffer=tY.concatenate(this.buffer,v.from(e)):this.buffer=v.from(e);this.cursor<this.buffer.length&&(1!==this.state||this.readTag())&&(2!==this.state||this.readSize())&&(3!==this.state||this.readContent()););n()}},{key:"readTag",value:function(){if(rX.enabled&&rX("parsing tag"),this.cursor>=this.buffer.length)return rX.enabled&&rX("waiting for more data"),!1;var e=this.total,n=tY.readVint(this.buffer,this.cursor);if(null==n)return rX.enabled&&rX("waiting for more data"),!1;var r=tY.readHexString(this.buffer,this.cursor,this.cursor+n.length),i=Number.parseInt(r,16);this.cursor+=n.length,this.total+=n.length,this.state=2;var s={tag:n.value,tagStr:r,type:t.getSchemaInfo(i).type,name:t.getSchemaInfo(i).name,start:e,end:e+n.length};return this.tagStack.push(s),rX.enabled&&rX("read tag: ".concat(r)),!0}},{key:"readSize",value:function(){var e=this.tagStack[this.tagStack.length-1];if(rX.enabled&&rX("parsing size for tag: ".concat(e.tagStr)),this.cursor>=this.buffer.length)return rX.enabled&&rX("waiting for more data"),!1;var t=tY.readVint(this.buffer,this.cursor);return null==t?(rX.enabled&&rX("waiting for more data"),!1):(this.cursor+=t.length,this.total+=t.length,this.state=3,e.dataSize=t.value,-1===t.value?e.end=-1:e.end+=t.value+t.length,rX.enabled&&rX("read size: ".concat(t.value)),!0)}},{key:"readContent",value:function(){var e=this.tagStack[this.tagStack.length-1],t=e.tagStr,n=e.type,r=e.dataSize,i=ee(e,["tagStr","type","dataSize"]);if(rX.enabled&&rX("parsing content for tag: ".concat(t)),"m"===n)return rX.enabled&&rX("content should be tags"),this.push(["start",X({tagStr:t,type:n,dataSize:r},i)]),this.state=1,!0;if(this.buffer.length<this.cursor+r)return rX.enabled&&(rX("got: ".concat(this.buffer.length)),rX("need: ".concat(this.cursor+r)),rX("waiting for more data")),!1;var s=this.buffer.subarray(this.cursor,this.cursor+r);for(this.total+=r,this.state=1,this.buffer=this.buffer.subarray(this.cursor+r),this.cursor=0,this.tagStack.pop(),this.push(["tag",tY.readDataFromTag(X({tagStr:t,type:n,dataSize:r},i),v.from(s))]);this.tagStack.length>0;){var a=this.tagStack[this.tagStack.length-1];if(this.total<a.end)break;this.push(["end",a]),this.tagStack.pop()}return rX.enabled&&rX("read data: ".concat(s.toString("hex"))),!0}},{key:"buffer",get:function(){return this.mBuffer},set:function(e){this.mBuffer=e}},{key:"cursor",get:function(){return this.mCursor},set:function(e){this.mCursor=e}},{key:"state",get:function(){return this.mState},set:function(e){this.mState=e}},{key:"tagStack",get:function(){return this.mTagStack}},{key:"total",get:function(){return this.mTotal},set:function(e){this.mTotal=e}}],[{key:"getSchemaInfo",value:function(e){return Number.isInteger(e)&&nk.has(e)?nk.get(e):{type:null,name:"unknown",description:"",level:-1,minver:-1,multiple:!1,webm:!1}}}]),t}(rV),rQ=Array.isArray||function(e){return"Array"==eq(e)},rZ=tD("species"),r0=function(e){var t;return rQ(e)&&("function"==typeof(t=e.constructor)&&(t===Array||rQ(t.prototype))&&(t=void 0),ei(t)&&null===(t=t[rZ])&&(t=void 0)),void 0===t?Array:t},r1=(n=function(e,t){return new(r0(e))(t)},function(e,t,n){for(var r,i,s=tO(e),a=eV(s),o=eI(t,n,3),l=eN(a.length),c=0,u=void 0;l>c;c++)if(i=o(r=a[c],c,s),1)if(1){if(i)return r;else if(0)return!1}else u[c]=i;return u}),r2="find",r3=!0;r2 in[]&&[,][r2](function(){r3=!1}),eP(eP.P+eP.F*r3,"Array",{find:function(e){return r1(this,e,arguments.length>1?arguments[1]:void 0)}}),tJ(r2);var r6=r8;function r8(e){if(!(this instanceof r8))return new r8(e);this.buffers=e||[],this.length=this.buffers.reduce(function(e,t){return e+t.length},0)}r8.prototype.push=function(){for(var e=0;e<arguments.length;e++)if(!q(arguments[e]))throw TypeError("Tried to push a non-buffer");for(var e=0;e<arguments.length;e++){var t=arguments[e];this.buffers.push(t),this.length+=t.length}return this.length},r8.prototype.unshift=function(){for(var e=0;e<arguments.length;e++)if(!q(arguments[e]))throw TypeError("Tried to unshift a non-buffer");for(var e=0;e<arguments.length;e++){var t=arguments[e];this.buffers.unshift(t),this.length+=t.length}return this.length},r8.prototype.copy=function(e,t,n,r){return this.slice(n,r).copy(e,t,0,r-n)},r8.prototype.splice=function(e,t){var n=this.buffers,r=e>=0?e:this.length-e,i=[].slice.call(arguments,2);void 0===t?t=this.length-r:t>this.length-r&&(t=this.length-r);for(var e=0;e<i.length;e++)this.length+=i[e].length;for(var s=new r8,a=0,o=0;o<n.length&&a+n[o].length<r;o++)a+=n[o].length;if(r-a>0){var l=r-a;if(l+t<n[o].length){s.push(n[o].slice(l,l+t));for(var c=n[o],u=new v(l),e=0;e<l;e++)u[e]=c[e];for(var h=new v(c.length-l-t),e=l+t;e<c.length;e++)h[e-t-l]=c[e];if(i.length>0){var d=i.slice();d.unshift(u),d.push(h),n.splice.apply(n,[o,1].concat(d)),o+=d.length,i=[]}else n.splice(o,1,u,h),o+=2}else s.push(n[o].slice(l)),n[o]=n[o].slice(0,l),o++}for(i.length>0&&(n.splice.apply(n,[o,0].concat(i)),o+=i.length);s.length<t;){var f=n[o],p=f.length,m=Math.min(p,t-s.length);m===p?(s.push(f),n.splice(o,1)):(s.push(f.slice(0,m)),n[o]=n[o].slice(m))}return this.length-=s.length,s},r8.prototype.slice=function(e,t){var n=this.buffers;void 0===t&&(t=this.length),void 0===e&&(e=0),t>this.length&&(t=this.length);for(var r=0,i=0;i<n.length&&r+n[i].length<=e;i++)r+=n[i].length;for(var s=new v(t-e),a=0,o=i;a<t-e&&o<n.length;o++){var l=n[o].length,c=0===a?e-r:0,u=a+l>=t-e?Math.min(c+(t-e)-a,l):l;n[o].copy(s,a,c,u),a+=u-c}return s},r8.prototype.pos=function(e){if(e<0||e>=this.length)throw Error("oob");for(var t=e,n=0,r=null;;){if(t<(r=this.buffers[n]).length)return{buf:n,offset:t};t-=r.length,n++}},r8.prototype.get=function(e){var t=this.pos(e);return this.buffers[t.buf].get(t.offset)},r8.prototype.set=function(e,t){var n=this.pos(e);return this.buffers[n.buf].set(n.offset,t)},r8.prototype.indexOf=function(e,t){if("string"==typeof e)e=new v(e);else if(e instanceof v);else throw Error("Invalid type for a search string");if(!e.length)return 0;if(!this.length)return -1;var n,r=0,i=0,s=0,a=0;if(t){var o=this.pos(t);r=o.buf,i=o.offset,a=t}for(;;){for(;i>=this.buffers[r].length;)if(i=0,++r>=this.buffers.length)return -1;if(this.buffers[r][i]==e[s]){if(0==s&&(n={i:r,j:i,pos:a}),++s==e.length)return n.pos}else 0!=s&&(r=n.i,i=n.j,a=n.pos,s=0);i++,a++}},r8.prototype.toBuffer=function(){return this.slice()},r8.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)};var r4=e.r(88539)("ebml:encoder");function r5(e,t,n){return -1===n?r6([e,v.from("01ffffffffffffff","hex"),t]):r6([e,tY.writeVint(t.length),t])}var r9=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return V(this,t),G(et(et(e=en(this,Q(t).call(this,X({},n,{writableObjectMode:!0}))))),"mBuffer",null),G(et(et(e)),"mCorked",!1),G(et(et(e)),"mStack",[]),e}return J(t,e),Y(t,[{key:"_transform",value:function(e,t,n){var r=function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,s=void 0;try{for(var a,o=e[Symbol.iterator]();!(r=(a=o.next()).done)&&(n.push(a.value),2!==n.length);r=!0);}catch(e){i=!0,s=e}finally{try{r||null==o.return||o.return()}finally{if(i)throw s}}return n}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance")}(),i=r[0],s=r[1],a=s.data,o=s.name,l=ee(s,["data","name"]);switch(r4.enabled&&r4("encode ".concat(i," ").concat(o)),i){case"start":this.startTag(o,X({name:o,data:a},l));break;case"tag":this.writeTag(o,a);break;case"end":this.endTag()}n()}},{key:"flush",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};if(!this.buffer||this.corked){r4.enabled&&r4("no buffer/nothing pending"),e();return}r4.enabled&&r4("writing ".concat(this.buffer.length," bytes"));var t=v.from(this.buffer);this.buffer=null,this.push(t),e()}},{key:"bufferAndFlush",value:function(e){this.buffer?this.buffer=tY.concatenate(this.buffer,e):this.buffer=r6(e),this.flush()}},{key:"_flush",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this.flush(e)}},{key:"_bufferAndFlush",value:function(e){this.bufferAndFlush(e)}},{key:"cork",value:function(){this.corked=!0}},{key:"uncork",value:function(){this.corked=!1,this.flush()}},{key:"writeTag",value:function(e,n){var r=t.getSchemaInfo(e);if(!r)throw Error("No schema entry found for ".concat(e));if(n){var i=r5(r,n);this.stack.length>0?this.stack[this.stack.length-1].children.push({data:i}):this.bufferAndFlush(i.buffer)}}},{key:"startTag",value:function(e,n){var r=n.end,i=t.getSchemaInfo(e);if(!i)throw Error("No schema entry found for ".concat(e));var s={data:null,id:i,name:e,end:r,children:[]};this.stack.length>0&&this.stack[this.stack.length-1].children.push(s),this.stack.push(s)}},{key:"endTag",value:function(){var e=this.stack.pop(),t=e.children.map(function(e){return e.data});e.data=r5(e.id,r6(t),e.end),this.stack.length<1&&this.bufferAndFlush(e.data.buffer),this.end()}},{key:"buffer",get:function(){return this.mBuffer},set:function(e){this.mBuffer=e}},{key:"corked",get:function(){return this.mCorked},set:function(e){this.mCorked=e}},{key:"stack",get:function(){return this.mStack},set:function(e){this.mStack=e}}],[{key:"getSchemaInfo",value:function(e){var t=Array.from(nk.keys()).find(function(t){return nk.get(t).name===e});return t||null}}]),t}(rV);e.s(["Decoder",()=>rJ,"Encoder",()=>r9,"schema",()=>nk,"tools",()=>tY])},99567,e=>{"use strict";let t,n,r,i;var s,a,o,l,c,u,h,d,f,p,m,g,y,b,v,w,_,S,x,E,k,C,T,A,R,I,O,P,M,D,L,$,N,U,B,F,j,H,W,q,z,V,K,Y,G,X,J,Q,Z,ee,et,en,er,ei,es,ea,eo,el,ec,eu,eh,ed,ef,ep,em,eg,ey,eb,ev,ew,e_,eS,ex,eE,ek,eC,eT,eA,eR=e.i(47909),eI=e.i(74017),eO=e.i(96250),eP=e.i(59756),eM=e.i(61916),eD=e.i(74677),eL=e.i(69741),e$=e.i(16795),eN=e.i(87718),eU=e.i(95169),eB=e.i(47587),eF=e.i(66012),ej=e.i(70101),eH=e.i(74838),eW=e.i(10372),eq=e.i(93695);e.i(52474);var ez=e.i(220),eV=e.i(89171);function eK(e,t,n,r,i){if("m"===r)throw TypeError("Private method is not writable");if("a"===r&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function eY(e,t,n,r){if("a"===n&&!r)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}let eG=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return eG=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function eX(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}let eJ=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};class eQ extends Error{}class eZ extends eQ{constructor(e,t,n,r){super(`${eZ.makeMessage(e,t,n)}`),this.status=e,this.headers=r,this.requestID=r?.get("x-request-id"),this.error=t,this.code=t?.code,this.param=t?.param,this.type=t?.type}static makeMessage(e,t,n){let r=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||"(no status code or body)"}static generate(e,t,n,r){if(!e||!r)return new e1({message:n,cause:eJ(t)});let i=t?.error;return 400===e?new e3(e,i,n,r):401===e?new e6(e,i,n,r):403===e?new e8(e,i,n,r):404===e?new e4(e,i,n,r):409===e?new e5(e,i,n,r):422===e?new e9(e,i,n,r):429===e?new e7(e,i,n,r):e>=500?new te(e,i,n,r):new eZ(e,i,n,r)}}class e0 extends eZ{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class e1 extends eZ{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class e2 extends e1{constructor({message:e}={}){super({message:e??"Request timed out."})}}class e3 extends eZ{}class e6 extends eZ{}class e8 extends eZ{}class e4 extends eZ{}class e5 extends eZ{}class e9 extends eZ{}class e7 extends eZ{}class te extends eZ{}class tt extends eQ{constructor(){super("Could not parse response content as the length limit was reached")}}class tn extends eQ{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class tr extends Error{constructor(e){super(e)}}let ti=/^[a-z][a-z0-9+.-]*:/i,ts=e=>(ts=Array.isArray)(e),ta=ts;function to(e){return"object"!=typeof e?{}:e??{}}function tl(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}let tc=e=>new Promise(t=>setTimeout(t,e)),tu="6.23.0",th=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",td=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";function tf(...e){let t=globalThis.ReadableStream;if(void 0===t)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function tp(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return tf({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function tm(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function tg(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await e[Symbol.asyncIterator]().return?.();let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}let ty=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),tb="RFC3986",tv=e=>String(e),tw={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:tv},t_=(e,t)=>(t_=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty))(e,t),tS=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();function tx(e,t){if(ts(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}let tE={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},tk=function(e,t){Array.prototype.push.apply(e,ts(t)?t:[t])},tC={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,n,r,i)=>{if(0===e.length)return e;let s=e;if("symbol"==typeof e?s=Symbol.prototype.toString.call(e):"string"!=typeof e&&(s=String(e)),"iso-8859-1"===n)return escape(s).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});let a="";for(let e=0;e<s.length;e+=1024){let t=s.length>=1024?s.slice(e,e+1024):s,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(45===r||46===r||95===r||126===r||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||"RFC1738"===i&&(40===r||41===r)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=tS[r];continue}if(r<2048){n[n.length]=tS[192|r>>6]+tS[128|63&r];continue}if(r<55296||r>=57344){n[n.length]=tS[224|r>>12]+tS[128|r>>6&63]+tS[128|63&r];continue}e+=1,r=65536+((1023&r)<<10|1023&t.charCodeAt(e)),n[n.length]=tS[240|r>>18]+tS[128|r>>12&63]+tS[128|r>>6&63]+tS[128|63&r]}a+=n.join("")}return a},encodeValuesOnly:!1,format:tb,formatter:tv,indices:!1,serializeDate:e=>(n??(n=Function.prototype.call.bind(Date.prototype.toISOString)))(e),skipNulls:!1,strictNullHandling:!1},tT={};function tA(e){let t;return(r??(r=(t=new globalThis.TextEncoder).encode.bind(t)))(e)}function tR(e){let t;return(i??(i=(t=new globalThis.TextDecoder).decode.bind(t)))(e)}class tI{constructor(){a.set(this,void 0),o.set(this,void 0),eK(this,a,new Uint8Array,"f"),eK(this,o,null,"f")}decode(e){let t;if(null==e)return[];let n=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?tA(e):e;eK(this,a,function(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}([eY(this,a,"f"),n]),"f");let r=[];for(;null!=(t=function(e,t){for(let n=t??0;n<e.length;n++){if(10===e[n])return{preceding:n,index:n+1,carriage:!1};if(13===e[n])return{preceding:n,index:n+1,carriage:!0}}return null}(eY(this,a,"f"),eY(this,o,"f")));){if(t.carriage&&null==eY(this,o,"f")){eK(this,o,t.index,"f");continue}if(null!=eY(this,o,"f")&&(t.index!==eY(this,o,"f")+1||t.carriage)){r.push(tR(eY(this,a,"f").subarray(0,eY(this,o,"f")-1))),eK(this,a,eY(this,a,"f").subarray(eY(this,o,"f")),"f"),eK(this,o,null,"f");continue}let e=null!==eY(this,o,"f")?t.preceding-1:t.preceding,n=tR(eY(this,a,"f").subarray(0,e));r.push(n),eK(this,a,eY(this,a,"f").subarray(t.index),"f"),eK(this,o,null,"f")}return r}flush(){return eY(this,a,"f").length?this.decode("\n"):[]}}a=new WeakMap,o=new WeakMap,tI.NEWLINE_CHARS=new Set(["\n","\r"]),tI.NEWLINE_REGEXP=/\r\n|[\n\r]/g;let tO={off:0,error:200,warn:300,info:400,debug:500},tP=(e,t,n)=>{if(e){if(Object.prototype.hasOwnProperty.call(tO,e))return e;tN(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(tO))}`)}};function tM(){}function tD(e,t,n){return!t||tO[e]>tO[n]?tM:t[e].bind(t)}let tL={error:tM,warn:tM,info:tM,debug:tM},t$=new WeakMap;function tN(e){let t=e.logger,n=e.logLevel??"off";if(!t)return tL;let r=t$.get(t);if(r&&r[0]===n)return r[1];let i={error:tD("error",t,n),warn:tD("warn",t,n),info:tD("info",t,n),debug:tD("debug",t,n)};return t$.set(t,[n,i]),i}let tU=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);class tB{constructor(e,t,n){this.iterator=e,l.set(this,void 0),this.controller=t,eK(this,l,n,"f")}static fromSSEResponse(e,t,n){let r=!1,i=n?tN(n):console;async function*s(){if(r)throw new eQ("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let n=!1;try{for await(let r of tF(e,t))if(!n){if(r.data.startsWith("[DONE]")){n=!0;continue}if(null!==r.event&&r.event.startsWith("thread.")){let e;try{e=JSON.parse(r.data)}catch(e){throw console.error("Could not parse message into JSON:",r.data),console.error("From chunk:",r.raw),e}if("error"==r.event)throw new eZ(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}else{let t;try{t=JSON.parse(r.data)}catch(e){throw i.error("Could not parse message into JSON:",r.data),i.error("From chunk:",r.raw),e}if(t&&t.error)throw new eZ(void 0,t.error,void 0,e.headers);yield t}}n=!0}catch(e){if(eX(e))return;throw e}finally{n||t.abort()}}return new tB(s,t,n)}static fromReadableStream(e,t,n){let r=!1;async function*i(){let t=new tI;for await(let n of tm(e))for(let e of t.decode(n))yield e;for(let e of t.flush())yield e}return new tB(async function*(){if(r)throw new eQ("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let e=!1;try{for await(let t of i())!e&&t&&(yield JSON.parse(t));e=!0}catch(e){if(eX(e))return;throw e}finally{e||t.abort()}},t,n)}[(l=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],n=this.iterator(),r=r=>({next:()=>{if(0===r.length){let r=n.next();e.push(r),t.push(r)}return r.shift()}});return[new tB(()=>r(e),this.controller,eY(this,l,"f")),new tB(()=>r(t),this.controller,eY(this,l,"f"))]}toReadableStream(){let e,t=this;return tf({async start(){e=t[Symbol.asyncIterator]()},async pull(t){try{let{value:n,done:r}=await e.next();if(r)return t.close();let i=tA(JSON.stringify(n)+"\n");t.enqueue(i)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}}async function*tF(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new eQ("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new eQ("Attempted to iterate over a response with no body")}let n=new tH,r=new tI;for await(let t of tj(tm(e.body)))for(let e of r.decode(t)){let t=n.decode(e);t&&(yield t)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*tj(e){let t=new Uint8Array;for await(let n of e){let e;if(null==n)continue;let r=n instanceof ArrayBuffer?new Uint8Array(n):"string"==typeof n?tA(n):n,i=new Uint8Array(t.length+r.length);for(i.set(t),i.set(r,t.length),t=i;-1!==(e=function(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1]||13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return -1}(t));)yield t.slice(0,e),t=t.slice(e)}t.length>0&&(yield t)}class tH{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){var t;let n;if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,i,s]=-1!==(n=(t=e).indexOf(":"))?[t.substring(0,n),":",t.substring(n+1)]:[t,"",""];return s.startsWith(" ")&&(s=s.substring(1)),"event"===r?this.event=s:"data"===r&&this.data.push(s),null}}async function tW(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:s}=t,a=await (async()=>{if(t.options.stream)return(tN(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass)?t.options.__streamClass.fromSSEResponse(n,t.controller,e):tB.fromSSEResponse(n,t.controller,e);if(204===n.status)return null;if(t.options.__binaryResponse)return n;let r=n.headers.get("content-type"),i=r?.split(";")[0]?.trim();if(i?.includes("application/json")||i?.endsWith("+json")){if("0"===n.headers.get("content-length"))return;return tq(await n.json(),n)}return await n.text()})();return tN(e).debug(`[${r}] response parsed`,tU({retryOfRequestLogID:i,url:n.url,status:n.status,body:a,durationMs:Date.now()-s})),a}function tq(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}class tz extends Promise{constructor(e,t,n=tW){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,c.set(this,void 0),eK(this,c,e,"f")}_thenUnwrap(e){return new tz(eY(this,c,"f"),this.responsePromise,async(t,n)=>tq(e(await this.parseResponse(t,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(eY(this,c,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}c=new WeakMap;class tV{constructor(e,t,n,r){u.set(this,void 0),eK(this,u,e,"f"),this.options=r,this.response=t,this.body=n}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new eQ("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await eY(this,u,"f").requestAPIList(this.constructor,e)}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[(u=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}class tK extends tz{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await tW(e,t),t.options))}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}class tY extends tV{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class tG extends tV{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...to(this.options.query),after:t}}:null}}class tX extends tV{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...to(this.options.query),after:e}}:null}}let tJ=()=>{if("u"<typeof File){let{process:e}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof e?.versions?.node&&20>parseInt(e.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function tQ(e,t,n){return tJ(),new File(e,t??"unknown_file",n)}function tZ(e){return("object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}let t0=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],t1=async(e,t)=>t4(e.body)?{...e,body:await t6(e.body,t)}:e,t2=async(e,t)=>({...e,body:await t6(e.body,t)}),t3=new WeakMap,t6=async(e,t)=>{if(!await function(e){let t="function"==typeof e?e:e.fetch,n=t3.get(t);if(n)return n;let r=(async()=>{try{let e="Response"in t?t.Response:(await t("data:,")).constructor,n=new FormData;if(n.toString()===await new e(n).text())return!1;return!0}catch{return!0}})();return t3.set(t,r),r}(t))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let n=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>t5(n,e,t))),n},t8=e=>e instanceof Blob&&"name"in e,t4=e=>{if("object"==typeof e&&null!==e&&(e instanceof Response||t0(e)||t8(e)))return!0;if(Array.isArray(e))return e.some(t4);if(e&&"object"==typeof e){for(let t in e)if(t4(e[t]))return!0}return!1},t5=async(e,t,n)=>{if(void 0!==n){if(null==n)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)e.append(t,String(n));else if(n instanceof Response)e.append(t,tQ([await n.blob()],tZ(n)));else if(t0(n))e.append(t,tQ([await new Response(tp(n)).blob()],tZ(n)));else if(t8(n))e.append(t,n,tZ(n));else if(Array.isArray(n))await Promise.all(n.map(n=>t5(e,t+"[]",n)));else if("object"==typeof n)await Promise.all(Object.entries(n).map(([n,r])=>t5(e,`${t}[${n}]`,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},t9=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function t7(e,t,n){let r,i;if(tJ(),null!=(r=e=await e)&&"object"==typeof r&&"string"==typeof r.name&&"number"==typeof r.lastModified&&t9(r))return e instanceof File?e:tQ([await e.arrayBuffer()],e.name);if(null!=(i=e)&&"object"==typeof i&&"string"==typeof i.url&&"function"==typeof i.blob){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),tQ(await ne(r),t,n)}let s=await ne(e);if(t||(t=tZ(e)),!n?.type){let e=s.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(n={...n,type:e})}return tQ(s,t,n)}async function ne(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(t9(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(t0(e))for await(let n of e)t.push(...await ne(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";let t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}return t}class nt{constructor(e){this._client=e}}function nn(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}let nr=Object.freeze(Object.create(null)),ni=((e=nn)=>function(t,...n){let r;if(1===t.length)return t[0];let i=!1,s=[],a=t.reduce((t,r,a)=>{/[?#]/.test(r)&&(i=!0);let o=n[a],l=(i?encodeURIComponent:e)(""+o);return a!==n.length&&(null==o||"object"==typeof o&&o.toString===Object.getPrototypeOf(Object.getPrototypeOf(o.hasOwnProperty??nr)??nr)?.toString)&&(l=o+"",s.push({start:t.length+r.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(o).slice(8,-1)} is not a valid path parameter`})),t+r+(a===n.length?"":l)},""),o=a.split(/[?#]/,1)[0],l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(r=l.exec(o));)s.push({start:r.index,length:r[0].length,error:`Value "${r[0]}" can't be safely passed as a path parameter`});if(s.sort((e,t)=>e.start-t.start),s.length>0){let e=0,t=s.reduce((t,n)=>{let r=" ".repeat(n.start-e),i="^".repeat(n.length);return e=n.start+n.length,t+r+i},"");throw new eQ(`Path parameters result in path with invalid segments:
2
+ ${s.map(e=>e.error).join("\n")}
3
+ ${a}
4
+ ${t}`)}return a})(nn);class ns extends nt{list(e,t={},n){return this._client.getAPIList(ni`/chat/completions/${e}/messages`,tG,{query:t,...n})}}function na(e){return void 0!==e&&"function"in e&&void 0!==e.function}function no(e){return e?.$brand==="auto-parseable-response-format"}function nl(e){return e?.$brand==="auto-parseable-tool"}function nc(e,t){let n=e.choices.map(e=>{var n,r;if("length"===e.finish_reason)throw new tt;if("content_filter"===e.finish_reason)throw new tn;return nh(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>{var n,r;let i;return n=t,r=e,i=n.tools?.find(e=>na(e)&&e.function?.name===r.function.name),{...r,function:{...r.function,parsed_arguments:nl(i)?i.$parseRaw(r.function.arguments):i?.function.strict?JSON.parse(r.function.arguments):null}}})??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?(n=t,r=e.message.content,n.response_format?.type!=="json_schema"?null:n.response_format?.type==="json_schema"?"$parseRaw"in n.response_format?n.response_format.$parseRaw(r):JSON.parse(r):null):null}}});return{...e,choices:n}}function nu(e){return!!no(e.response_format)||(e.tools?.some(e=>nl(e)||"function"===e.type&&!0===e.function.strict)??!1)}function nh(e){for(let t of e||[])if("function"!==t.type)throw new eQ(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}let nd=e=>e?.role==="assistant",nf=e=>e?.role==="tool";class np{constructor(){h.add(this),this.controller=new AbortController,d.set(this,void 0),f.set(this,()=>{}),p.set(this,()=>{}),m.set(this,void 0),g.set(this,()=>{}),y.set(this,()=>{}),b.set(this,{}),v.set(this,!1),w.set(this,!1),_.set(this,!1),S.set(this,!1),eK(this,d,new Promise((e,t)=>{eK(this,f,e,"f"),eK(this,p,t,"f")}),"f"),eK(this,m,new Promise((e,t)=>{eK(this,g,e,"f"),eK(this,y,t,"f")}),"f"),eY(this,d,"f").catch(()=>{}),eY(this,m,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},eY(this,h,"m",x).bind(this))},0)}_connected(){this.ended||(eY(this,f,"f").call(this),this._emit("connect"))}get ended(){return eY(this,v,"f")}get errored(){return eY(this,w,"f")}get aborted(){return eY(this,_,"f")}abort(){this.controller.abort()}on(e,t){return(eY(this,b,"f")[e]||(eY(this,b,"f")[e]=[])).push({listener:t}),this}off(e,t){let n=eY(this,b,"f")[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(eY(this,b,"f")[e]||(eY(this,b,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{eK(this,S,!0,"f"),"error"!==e&&this.once("error",n),this.once(e,t)})}async done(){eK(this,S,!0,"f"),await eY(this,m,"f")}_emit(e,...t){if(eY(this,v,"f"))return;"end"===e&&(eK(this,v,!0,"f"),eY(this,g,"f").call(this));let n=eY(this,b,"f")[e];if(n&&(eY(this,b,"f")[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];eY(this,S,"f")||n?.length||Promise.reject(e),eY(this,p,"f").call(this,e),eY(this,y,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];eY(this,S,"f")||n?.length||Promise.reject(e),eY(this,p,"f").call(this,e),eY(this,y,"f").call(this,e),this._emit("end")}}_emitFinal(){}}d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,g=new WeakMap,y=new WeakMap,b=new WeakMap,v=new WeakMap,w=new WeakMap,_=new WeakMap,S=new WeakMap,h=new WeakSet,x=function(e){if(eK(this,w,!0,"f"),e instanceof Error&&"AbortError"===e.name&&(e=new e0),e instanceof e0)return eK(this,_,!0,"f"),this._emit("abort",e);if(e instanceof eQ)return this._emit("error",e);if(e instanceof Error){let t=new eQ(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new eQ(String(e)))};class nm extends np{constructor(){super(...arguments),E.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);let t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t){if(this._emit("message",e),nf(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(nd(e)&&e.tool_calls)for(let t of e.tool_calls)"function"===t.type&&this._emit("functionToolCall",t.function)}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new eQ("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),eY(this,E,"m",k).call(this)}async finalMessage(){return await this.done(),eY(this,E,"m",C).call(this)}async finalFunctionToolCall(){return await this.done(),eY(this,E,"m",T).call(this)}async finalFunctionToolCallResult(){return await this.done(),eY(this,E,"m",A).call(this)}async totalUsage(){return await this.done(),eY(this,E,"m",R).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);let t=eY(this,E,"m",C).call(this);t&&this._emit("finalMessage",t);let n=eY(this,E,"m",k).call(this);n&&this._emit("finalContent",n);let r=eY(this,E,"m",T).call(this);r&&this._emit("finalFunctionToolCall",r);let i=eY(this,E,"m",A).call(this);null!=i&&this._emit("finalFunctionToolCallResult",i),this._chatCompletions.some(e=>e.usage)&&this._emit("totalUsage",eY(this,E,"m",R).call(this))}async _createChatCompletion(e,t,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),eY(this,E,"m",I).call(this,t);let i=await e.chat.completions.create({...t,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(nc(i,t))}async _runChatCompletion(e,t,n){for(let e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,n)}async _runTools(e,t,n){let r="tool",{tool_choice:i="auto",stream:s,...a}=t,o="string"!=typeof i&&"function"===i.type&&i?.function?.name,{maxChatCompletions:l=10}=n||{},c=t.tools.map(e=>{if(nl(e)){if(!e.$callback)throw new eQ("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:e.$callback,name:e.function.name,description:e.function.description||"",parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e}),u={};for(let e of c)"function"===e.type&&(u[e.function.name||e.function.function.name]=e.function);let h="tools"in t?c.map(e=>"function"===e.type?{type:"function",function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e):void 0;for(let e of t.messages)this._addMessage(e,!1);for(let t=0;t<l;++t){let t=await this._createChatCompletion(e,{...a,tool_choice:i,tools:h,messages:[...this.messages]},n),s=t.choices[0]?.message;if(!s)throw new eQ("missing message in ChatCompletion response");if(!s.tool_calls?.length)break;for(let e of s.tool_calls){let t;if("function"!==e.type)continue;let n=e.id,{name:i,arguments:s}=e.function,a=u[i];if(a){if(o&&o!==i){let e=`Invalid tool_call: ${JSON.stringify(i)}. ${JSON.stringify(o)} requested. Please try again`;this._addMessage({role:r,tool_call_id:n,content:e});continue}}else{let e=`Invalid tool_call: ${JSON.stringify(i)}. Available options are: ${Object.keys(u).map(e=>JSON.stringify(e)).join(", ")}. Please try again`;this._addMessage({role:r,tool_call_id:n,content:e});continue}try{t="function"==typeof a.parse?await a.parse(s):s}catch(t){let e=t instanceof Error?t.message:String(t);this._addMessage({role:r,tool_call_id:n,content:e});continue}let l=await a.function(t,this),c=eY(this,E,"m",O).call(this,l);if(this._addMessage({role:r,tool_call_id:n,content:c}),o)return}}}}E=new WeakSet,k=function(){return eY(this,E,"m",C).call(this).content??null},C=function(){let e=this.messages.length;for(;e-- >0;){let t=this.messages[e];if(nd(t))return{...t,content:t.content??null,refusal:t.refusal??null}}throw new eQ("stream ended without producing a ChatCompletionMessage with role=assistant")},T=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(nd(t)&&t?.tool_calls?.length)return t.tool_calls.filter(e=>"function"===e.type).at(-1)?.function}},A=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(nf(t)&&null!=t.content&&"string"==typeof t.content&&this.messages.some(e=>"assistant"===e.role&&e.tool_calls?.some(e=>"function"===e.type&&e.id===t.tool_call_id)))return t.content}},R=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},I=function(e){if(null!=e.n&&e.n>1)throw new eQ("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},O=function(e){return"string"==typeof e?e:void 0===e?"undefined":JSON.stringify(e)};class ng extends nm{static runTools(e,t,n){let r=new ng,i={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return r._run(()=>r._runTools(e,t,i)),r}_addMessage(e,t=!0){super._addMessage(e,t),nd(e)&&e.content&&this._emit("content",e.content)}}let ny=511;class nb extends Error{}class nv extends Error{}let nw=e=>(function(e,t=ny){var n,r;let i,s,a,o,l,c,u,h,d,f;if("string"!=typeof e)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return n=e.trim(),r=t,i=n.length,s=0,a=e=>{throw new nb(`${e} at position ${s}`)},o=e=>{throw new nv(`${e} at position ${s}`)},l=()=>(f(),s>=i&&a("Unexpected end of input"),'"'===n[s])?c():"{"===n[s]?u():"["===n[s]?h():"null"===n.substring(s,s+4)||16&r&&i-s<4&&"null".startsWith(n.substring(s))?(s+=4,null):"true"===n.substring(s,s+4)||32&r&&i-s<4&&"true".startsWith(n.substring(s))?(s+=4,!0):"false"===n.substring(s,s+5)||32&r&&i-s<5&&"false".startsWith(n.substring(s))?(s+=5,!1):"Infinity"===n.substring(s,s+8)||128&r&&i-s<8&&"Infinity".startsWith(n.substring(s))?(s+=8,1/0):"-Infinity"===n.substring(s,s+9)||256&r&&1<i-s&&i-s<9&&"-Infinity".startsWith(n.substring(s))?(s+=9,-1/0):"NaN"===n.substring(s,s+3)||64&r&&i-s<3&&"NaN".startsWith(n.substring(s))?(s+=3,NaN):d(),c=()=>{let e=s,t=!1;for(s++;s<i&&('"'!==n[s]||t&&"\\"===n[s-1]);)t="\\"===n[s]&&!t,s++;if('"'==n.charAt(s))try{return JSON.parse(n.substring(e,++s-Number(t)))}catch(e){o(String(e))}else if(1&r)try{return JSON.parse(n.substring(e,s-Number(t))+'"')}catch(t){return JSON.parse(n.substring(e,n.lastIndexOf("\\"))+'"')}a("Unterminated string literal")},u=()=>{s++,f();let e={};try{for(;"}"!==n[s];){if(f(),s>=i&&8&r)return e;let t=c();f(),s++;try{let n=l();Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}catch(t){if(8&r)return e;throw t}f(),","===n[s]&&s++}}catch(t){if(8&r)return e;a("Expected '}' at end of object")}return s++,e},h=()=>{s++;let e=[];try{for(;"]"!==n[s];)e.push(l()),f(),","===n[s]&&s++}catch(t){if(4&r)return e;a("Expected ']' at end of array")}return s++,e},d=()=>{if(0===s){"-"===n&&2&r&&a("Not sure what '-' is");try{return JSON.parse(n)}catch(e){if(2&r)try{if("."===n[n.length-1])return JSON.parse(n.substring(0,n.lastIndexOf(".")));return JSON.parse(n.substring(0,n.lastIndexOf("e")))}catch(e){}o(String(e))}}let e=s;for("-"===n[s]&&s++;n[s]&&!",]}".includes(n[s]);)s++;s!=i||2&r||a("Unterminated number literal");try{return JSON.parse(n.substring(e,s))}catch(t){"-"===n.substring(e,s)&&2&r&&a("Not sure what '-' is");try{return JSON.parse(n.substring(e,n.lastIndexOf("e")))}catch(e){o(String(e))}}},f=()=>{for(;s<i&&" \n\r ".includes(n[s]);)s++},l()})(e,2^ny);class n_ extends nm{constructor(e){super(),P.add(this),M.set(this,void 0),D.set(this,void 0),L.set(this,void 0),eK(this,M,e,"f"),eK(this,D,[],"f")}get currentChatCompletionSnapshot(){return eY(this,L,"f")}static fromReadableStream(e){let t=new n_(null);return t._run(()=>t._fromReadableStream(e)),t}static createChatCompletion(e,t,n){let r=new n_(t);return r._run(()=>r._runChatCompletion(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createChatCompletion(e,t,n){super._createChatCompletion;let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),eY(this,P,"m",$).call(this);let i=await e.chat.completions.create({...t,stream:!0},{...n,signal:this.controller.signal});for await(let e of(this._connected(),i))eY(this,P,"m",U).call(this,e);if(i.controller.signal?.aborted)throw new e0;return this._addChatCompletion(eY(this,P,"m",j).call(this))}async _fromReadableStream(e,t){let n,r=t?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),eY(this,P,"m",$).call(this),this._connected();let i=tB.fromReadableStream(e,this.controller);for await(let e of i)n&&n!==e.id&&this._addChatCompletion(eY(this,P,"m",j).call(this)),eY(this,P,"m",U).call(this,e),n=e.id;if(i.controller.signal?.aborted)throw new e0;return this._addChatCompletion(eY(this,P,"m",j).call(this))}[(M=new WeakMap,D=new WeakMap,L=new WeakMap,P=new WeakSet,$=function(){this.ended||eK(this,L,void 0,"f")},N=function(e){let t=eY(this,D,"f")[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},eY(this,D,"f")[e.index]=t),t},U=function(e){if(this.ended)return;let t=eY(this,P,"m",W).call(this,e);for(let n of(this._emit("chunk",e,t),e.choices)){let e=t.choices[n.index];null!=n.delta.content&&e.message?.role==="assistant"&&e.message?.content&&(this._emit("content",n.delta.content,e.message.content),this._emit("content.delta",{delta:n.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),null!=n.delta.refusal&&e.message?.role==="assistant"&&e.message?.refusal&&this._emit("refusal.delta",{delta:n.delta.refusal,snapshot:e.message.refusal}),n.logprobs?.content!=null&&e.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:n.logprobs?.content,snapshot:e.logprobs?.content??[]}),n.logprobs?.refusal!=null&&e.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:n.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});let r=eY(this,P,"m",N).call(this,e);for(let t of(e.finish_reason&&(eY(this,P,"m",F).call(this,e),null!=r.current_tool_call_index&&eY(this,P,"m",B).call(this,e,r.current_tool_call_index)),n.delta.tool_calls??[]))r.current_tool_call_index!==t.index&&(eY(this,P,"m",F).call(this,e),null!=r.current_tool_call_index&&eY(this,P,"m",B).call(this,e,r.current_tool_call_index)),r.current_tool_call_index=t.index;for(let t of n.delta.tool_calls??[]){let n=e.message.tool_calls?.[t.index];n?.type&&(n?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:n.function?.name,index:t.index,arguments:n.function.arguments,parsed_arguments:n.function.parsed_arguments,arguments_delta:t.function?.arguments??""}):nE(n?.type))}}},B=function(e,t){if(eY(this,P,"m",N).call(this,e).done_tool_calls.has(t))return;let n=e.message.tool_calls?.[t];if(!n)throw Error("no tool call snapshot");if(!n.type)throw Error("tool call snapshot missing `type`");if("function"===n.type){let e=eY(this,M,"f")?.tools?.find(e=>na(e)&&e.function.name===n.function.name);this._emit("tool_calls.function.arguments.done",{name:n.function.name,index:t,arguments:n.function.arguments,parsed_arguments:nl(e)?e.$parseRaw(n.function.arguments):e?.function.strict?JSON.parse(n.function.arguments):null})}else nE(n.type)},F=function(e){let t=eY(this,P,"m",N).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;let n=eY(this,P,"m",H).call(this);this._emit("content.done",{content:e.message.content,parsed:n?n.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit("refusal.done",{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:e.logprobs.refusal}))},j=function(){if(this.ended)throw new eQ("stream has ended, this shouldn't happen");let e=eY(this,L,"f");if(!e)throw new eQ("request ended without sending any chunks");return eK(this,L,void 0,"f"),eK(this,D,[],"f"),function(e,t){var n;let{id:r,choices:i,created:s,model:a,system_fingerprint:o,...l}=e;return n={...l,id:r,choices:i.map(({message:t,finish_reason:n,index:r,logprobs:i,...s})=>{if(!n)throw new eQ(`missing finish_reason for choice ${r}`);let{content:a=null,function_call:o,tool_calls:l,...c}=t,u=t.role;if(!u)throw new eQ(`missing role for choice ${r}`);if(o){let{arguments:e,name:l}=o;if(null==e)throw new eQ(`missing function_call.arguments for choice ${r}`);if(!l)throw new eQ(`missing function_call.name for choice ${r}`);return{...s,message:{content:a,function_call:{arguments:e,name:l},role:u,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}return l?{...s,index:r,finish_reason:n,logprobs:i,message:{...c,role:u,content:a,refusal:t.refusal??null,tool_calls:l.map((t,n)=>{let{function:i,type:s,id:a,...o}=t,{arguments:l,name:c,...u}=i||{};if(null==a)throw new eQ(`missing choices[${r}].tool_calls[${n}].id
5
+ ${nS(e)}`);if(null==s)throw new eQ(`missing choices[${r}].tool_calls[${n}].type
6
+ ${nS(e)}`);if(null==c)throw new eQ(`missing choices[${r}].tool_calls[${n}].function.name
7
+ ${nS(e)}`);if(null==l)throw new eQ(`missing choices[${r}].tool_calls[${n}].function.arguments
8
+ ${nS(e)}`);return{...o,id:a,type:s,function:{...u,name:c,arguments:l}}})}}:{...s,message:{...c,content:a,role:u,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}),created:s,model:a,object:"chat.completion",...o?{system_fingerprint:o}:{}},t&&nu(t)?nc(n,t):{...n,choices:n.choices.map(e=>(nh(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}}(e,eY(this,M,"f"))},H=function(){let e=eY(this,M,"f")?.response_format;return no(e)?e:null},W=function(e){var t,n,r,i;let s=eY(this,L,"f"),{choices:a,...o}=e;for(let{delta:a,finish_reason:l,index:c,logprobs:u=null,...h}of(s?Object.assign(s,o):s=eK(this,L,{...o,choices:[]},"f"),e.choices)){let e=s.choices[c];if(e||(e=s.choices[c]={finish_reason:l,index:c,message:{},logprobs:u,...h}),u)if(e.logprobs){let{content:r,refusal:i,...s}=u;nx(s),Object.assign(e.logprobs,s),r&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...r)),i&&((n=e.logprobs).refusal??(n.refusal=[]),e.logprobs.refusal.push(...i))}else e.logprobs=Object.assign({},u);if(l&&(e.finish_reason=l,eY(this,M,"f")&&nu(eY(this,M,"f")))){if("length"===l)throw new tt;if("content_filter"===l)throw new tn}if(Object.assign(e,h),!a)continue;let{content:o,refusal:d,function_call:f,role:p,tool_calls:m,...g}=a;if(nx(g),Object.assign(e.message,g),d&&(e.message.refusal=(e.message.refusal||"")+d),p&&(e.message.role=p),f&&(e.message.function_call?(f.name&&(e.message.function_call.name=f.name),f.arguments&&((r=e.message.function_call).arguments??(r.arguments=""),e.message.function_call.arguments+=f.arguments)):e.message.function_call=f),o&&(e.message.content=(e.message.content||"")+o,!e.message.refusal&&eY(this,P,"m",H).call(this)&&(e.message.parsed=nw(e.message.content))),m)for(let{index:t,id:n,type:r,function:s,...a}of(e.message.tool_calls||(e.message.tool_calls=[]),m)){let o=(i=e.message.tool_calls)[t]??(i[t]={});Object.assign(o,a),n&&(o.id=n),r&&(o.type=r),s&&(o.function??(o.function={name:s.name??"",arguments:""})),s?.name&&(o.function.name=s.name),s?.arguments&&(o.function.arguments+=s.arguments,function(e,t){if(!e||!("tools"in e)||!e.tools)return!1;let n=e.tools?.find(e=>na(e)&&e.function?.name===t.function.name);return na(n)&&(nl(n)||n?.function.strict||!1)}(eY(this,M,"f"),o)&&(o.function.parsed_arguments=nw(o.function.arguments)))}}return s},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on("chunk",n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on("end",()=>{for(let e of(n=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let r of(n=!0,t))r.reject(e);t.length=0}),this.on("error",e=>{for(let r of(n=!0,t))r.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new tB(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function nS(e){return JSON.stringify(e)}function nx(e){}function nE(e){}class nk extends n_{static fromReadableStream(e){let t=new nk(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,n){let r=new nk(t),i={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return r._run(()=>r._runTools(e,t,i)),r}}class nC extends nt{constructor(){super(...arguments),this.messages=new ns(this._client)}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}retrieve(e,t){return this._client.get(ni`/chat/completions/${e}`,t)}update(e,t,n){return this._client.post(ni`/chat/completions/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/chat/completions",tG,{query:e,...t})}delete(e,t){return this._client.delete(ni`/chat/completions/${e}`,t)}parse(e,t){for(let t of e.tools??[]){if("function"!==t.type)throw new eQ(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new eQ(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}return this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(t=>nc(t,e))}runTools(e,t){return e.stream?nk.runTools(this._client,e,t):ng.runTools(this._client,e,t)}stream(e,t){return n_.createChatCompletion(this._client,e,t)}}nC.Messages=ns;class nT extends nt{constructor(){super(...arguments),this.completions=new nC(this._client)}}nT.Completions=nC,e.s([],98546);let nA=Symbol("brand.privateNullableHeaders"),nR=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,s]of function*(e){let t;if(!e)return;if(nA in e){let{values:t,nulls:n}=e;for(let e of(yield*t.entries(),n))yield[e,null];return}let n=!1;for(let r of(e instanceof Headers?t=e.entries():ta(e)?t=e:(n=!0,t=Object.entries(e??{})),t)){let e=r[0];if("string"!=typeof e)throw TypeError("expected header name to be a string");let t=ta(r[1])?r[1]:[r[1]],i=!1;for(let r of t)void 0!==r&&(n&&!i&&(i=!0,yield[e,null]),yield[e,r])}}(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),null===s?(t.delete(i),n.add(r)):(t.append(i,s),n.delete(r))}}return{[nA]:!0,values:t,nulls:n}};class nI extends nt{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:nR([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:!0})}}class nO extends nt{create(e,t){return this._client.post("/audio/transcriptions",t2({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}class nP extends nt{create(e,t){return this._client.post("/audio/translations",t2({body:e,...t,__metadata:{model:e.model}},this._client))}}class nM extends nt{constructor(){super(...arguments),this.transcriptions=new nO(this._client),this.translations=new nP(this._client),this.speech=new nI(this._client)}}nM.Transcriptions=nO,nM.Translations=nP,nM.Speech=nI;class nD extends nt{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(ni`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",tG,{query:e,...t})}cancel(e,t){return this._client.post(ni`/batches/${e}/cancel`,t)}}class nL extends nt{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ni`/assistants/${e}`,{...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(ni`/assistants/${e}`,{body:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",tG,{query:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(ni`/assistants/${e}`,{...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class n$ extends nt{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class nN extends nt{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class nU extends nt{constructor(){super(...arguments),this.sessions=new n$(this._client),this.transcriptionSessions=new nN(this._client)}}nU.Sessions=n$,nU.TranscriptionSessions=nN;class nB extends nt{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:nR([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(ni`/chatkit/sessions/${e}/cancel`,{...t,headers:nR([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}}class nF extends nt{retrieve(e,t){return this._client.get(ni`/chatkit/threads/${e}`,{...t,headers:nR([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",tX,{query:e,...t,headers:nR([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(ni`/chatkit/threads/${e}`,{...t,headers:nR([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},n){return this._client.getAPIList(ni`/chatkit/threads/${e}/items`,tX,{query:t,...n,headers:nR([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}}class nj extends nt{constructor(){super(...arguments),this.sessions=new nB(this._client),this.threads=new nF(this._client)}}nj.Sessions=nB,nj.Threads=nF;class nH extends nt{create(e,t,n){return this._client.post(ni`/threads/${e}/messages`,{body:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(ni`/threads/${r}/messages/${e}`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(ni`/threads/${r}/messages/${e}`,{body:i,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(ni`/threads/${e}/messages`,tG,{query:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t,n){let{thread_id:r}=t;return this._client.delete(ni`/threads/${r}/messages/${e}`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}class nW extends nt{retrieve(e,t,n){let{thread_id:r,run_id:i,...s}=t;return this._client.get(ni`/threads/${r}/runs/${i}/steps/${e}`,{query:s,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t,n){let{thread_id:r,...i}=t;return this._client.getAPIList(ni`/threads/${r}/runs/${e}/steps`,tG,{query:i,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}let nq=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;class nz extends np{constructor(){super(...arguments),q.add(this),V.set(this,[]),K.set(this,{}),Y.set(this,{}),G.set(this,void 0),X.set(this,void 0),J.set(this,void 0),Q.set(this,void 0),Z.set(this,void 0),ee.set(this,void 0),et.set(this,void 0),en.set(this,void 0),er.set(this,void 0)}[(V=new WeakMap,K=new WeakMap,Y=new WeakMap,G=new WeakMap,X=new WeakMap,J=new WeakMap,Q=new WeakMap,Z=new WeakMap,ee=new WeakMap,et=new WeakMap,en=new WeakMap,er=new WeakMap,q=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on("event",n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on("end",()=>{for(let e of(n=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let r of(n=!0,t))r.reject(e);t.length=0}),this.on("error",e=>{for(let r of(n=!0,t))r.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new z;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),this._connected();let r=tB.fromReadableStream(e,this.controller);for await(let e of r)eY(this,q,"m",ei).call(this,e);if(r.controller.signal?.aborted)throw new e0;return this._addRun(eY(this,q,"m",es).call(this))}toReadableStream(){return new tB(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,r){let i=new z;return i._run(()=>i._runToolAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createToolAssistantStream(e,t,n,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let s={...n,stream:!0},a=await e.submitToolOutputs(t,s,{...r,signal:this.controller.signal});for await(let e of(this._connected(),a))eY(this,q,"m",ei).call(this,e);if(a.controller.signal?.aborted)throw new e0;return this._addRun(eY(this,q,"m",es).call(this))}static createThreadAssistantStream(e,t,n){let r=new z;return r._run(()=>r._threadAssistantStream(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}static createAssistantStream(e,t,n,r){let i=new z;return i._run(()=>i._runAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}currentEvent(){return eY(this,et,"f")}currentRun(){return eY(this,en,"f")}currentMessageSnapshot(){return eY(this,G,"f")}currentRunStepSnapshot(){return eY(this,er,"f")}async finalRunSteps(){return await this.done(),Object.values(eY(this,K,"f"))}async finalMessages(){return await this.done(),Object.values(eY(this,Y,"f"))}async finalRun(){if(await this.done(),!eY(this,X,"f"))throw Error("Final run was not received.");return eY(this,X,"f")}async _createThreadAssistantStream(e,t,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));let i={...t,stream:!0},s=await e.createAndRun(i,{...n,signal:this.controller.signal});for await(let e of(this._connected(),s))eY(this,q,"m",ei).call(this,e);if(s.controller.signal?.aborted)throw new e0;return this._addRun(eY(this,q,"m",es).call(this))}async _createAssistantStream(e,t,n,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let s={...n,stream:!0},a=await e.create(t,s,{...r,signal:this.controller.signal});for await(let e of(this._connected(),a))eY(this,q,"m",ei).call(this,e);if(a.controller.signal?.aborted)throw new e0;return this._addRun(eY(this,q,"m",es).call(this))}static accumulateDelta(e,t){for(let[n,r]of Object.entries(t)){if(!e.hasOwnProperty(n)){e[n]=r;continue}let t=e[n];if(null==t||"index"===n||"type"===n){e[n]=r;continue}if("string"==typeof t&&"string"==typeof r)t+=r;else if("number"==typeof t&&"number"==typeof r)t+=r;else if(tl(t)&&tl(r))t=this.accumulateDelta(t,r);else if(Array.isArray(t)&&Array.isArray(r)){if(t.every(e=>"string"==typeof e||"number"==typeof e)){t.push(...r);continue}for(let e of r){if(!tl(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let n=e.index;if(null==n)throw console.error(e),Error("Expected array delta entry to have an `index` property");if("number"!=typeof n)throw Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);let r=t[n];null==r?t.push(e):t[n]=this.accumulateDelta(r,e)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${r}, accValue: ${t}`);e[n]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,n){return await this._createThreadAssistantStream(t,e,n)}async _runAssistantStream(e,t,n,r){return await this._createAssistantStream(t,e,n,r)}async _runToolAssistantStream(e,t,n,r){return await this._createToolAssistantStream(t,e,n,r)}}z=nz,ei=function(e){if(!this.ended)switch(eK(this,et,e,"f"),eY(this,q,"m",el).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":eY(this,q,"m",ed).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":eY(this,q,"m",eo).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":eY(this,q,"m",ea).call(this,e);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier")}},es=function(){if(this.ended)throw new eQ("stream has ended, this shouldn't happen");if(!eY(this,X,"f"))throw Error("Final run has not been received");return eY(this,X,"f")},ea=function(e){let[t,n]=eY(this,q,"m",eu).call(this,e,eY(this,G,"f"));for(let e of(eK(this,G,t,"f"),eY(this,Y,"f")[t.id]=t,n)){let n=t.content[e.index];n?.type=="text"&&this._emit("textCreated",n.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(let n of e.data.delta.content){if("text"==n.type&&n.text){let e=n.text,r=t.content[n.index];if(r&&"text"==r.type)this._emit("textDelta",e,r.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(n.index!=eY(this,J,"f")){if(eY(this,Q,"f"))switch(eY(this,Q,"f").type){case"text":this._emit("textDone",eY(this,Q,"f").text,eY(this,G,"f"));break;case"image_file":this._emit("imageFileDone",eY(this,Q,"f").image_file,eY(this,G,"f"))}eK(this,J,n.index,"f")}eK(this,Q,t.content[n.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==eY(this,J,"f")){let t=e.data.content[eY(this,J,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,eY(this,G,"f"));break;case"text":this._emit("textDone",t.text,eY(this,G,"f"))}}eY(this,G,"f")&&this._emit("messageDone",e.data),eK(this,G,void 0,"f")}},eo=function(e){let t=eY(this,q,"m",ec).call(this,e);switch(eK(this,er,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let n=e.data.delta;if(n.step_details&&"tool_calls"==n.step_details.type&&n.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(let e of n.step_details.tool_calls)e.index==eY(this,Z,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(eY(this,ee,"f")&&this._emit("toolCallDone",eY(this,ee,"f")),eK(this,Z,e.index,"f"),eK(this,ee,t.step_details.tool_calls[e.index],"f"),eY(this,ee,"f")&&this._emit("toolCallCreated",eY(this,ee,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":eK(this,er,void 0,"f"),"tool_calls"==e.data.step_details.type&&eY(this,ee,"f")&&(this._emit("toolCallDone",eY(this,ee,"f")),eK(this,ee,void 0,"f")),this._emit("runStepDone",e.data,t)}},el=function(e){eY(this,V,"f").push(e),this._emit("event",e)},ec=function(e){switch(e.event){case"thread.run.step.created":return eY(this,K,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=eY(this,K,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let n=e.data;if(n.delta){let r=z.accumulateDelta(t,n.delta);eY(this,K,"f")[e.data.id]=r}return eY(this,K,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":eY(this,K,"f")[e.data.id]=e.data}if(eY(this,K,"f")[e.data.id])return eY(this,K,"f")[e.data.id];throw Error("No snapshot available")},eu=function(e,t){let n=[];switch(e.event){case"thread.message.created":return[e.data,n];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let r=e.data;if(r.delta.content)for(let e of r.delta.content)if(e.index in t.content){let n=t.content[e.index];t.content[e.index]=eY(this,q,"m",eh).call(this,e,n)}else t.content[e.index]=e,n.push(e);return[t,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},eh=function(e,t){return z.accumulateDelta(t,e)},ed=function(e){switch(eK(this,en,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":eK(this,X,e.data,"f"),eY(this,ee,"f")&&(this._emit("toolCallDone",eY(this,ee,"f")),eK(this,ee,void 0,"f"))}};class nV extends nt{constructor(){super(...arguments),this.steps=new nW(this._client)}create(e,t,n){let{include:r,...i}=t;return this._client.post(ni`/threads/${e}/runs`,{query:{include:r},body:i,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(ni`/threads/${r}/runs/${e}`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(ni`/threads/${r}/runs/${e}`,{body:i,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(ni`/threads/${e}/runs`,tG,{query:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,t,n){let{thread_id:r}=t;return this._client.post(ni`/threads/${r}/runs/${e}/cancel`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(r.id,{thread_id:e},n)}createAndStream(e,t,n){return nz.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){let r=nR([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:s}=await this.retrieve(e,t,{...n,headers:{...n?.headers,...r}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let e=s.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await tc(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(e,t,n){return nz.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){let{thread_id:r,...i}=t;return this._client.post(ni`/threads/${r}/runs/${e}/submit_tool_outputs`,{body:i,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1})}async submitToolOutputsAndPoll(e,t,n){let r=await this.submitToolOutputs(e,t,n);return await this.poll(r.id,t,n)}submitToolOutputsStream(e,t,n){return nz.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}}nV.Steps=nW;class nK extends nt{constructor(){super(...arguments),this.runs=new nV(this._client),this.messages=new nH(this._client)}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ni`/threads/${e}`,{...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(ni`/threads/${e}`,{body:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t){return this._client.delete(ni`/threads/${e}`,{...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??!1})}async createAndRunPoll(e,t){let n=await this.createAndRun(e,t);return await this.runs.poll(n.id,{thread_id:n.thread_id},t)}createAndRunStream(e,t){return nz.createThreadAssistantStream(e,this._client.beta.threads,t)}}nK.Runs=nV,nK.Messages=nH;class nY extends nt{constructor(){super(...arguments),this.realtime=new nU(this._client),this.chatkit=new nj(this._client),this.assistants=new nL(this._client),this.threads=new nK(this._client)}}nY.Realtime=nU,nY.ChatKit=nj,nY.Assistants=nL,nY.Threads=nK;class nG extends nt{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class nX extends nt{retrieve(e,t,n){let{container_id:r}=t;return this._client.get(ni`/containers/${r}/files/${e}/content`,{...n,headers:nR([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}}class nJ extends nt{constructor(){super(...arguments),this.content=new nX(this._client)}create(e,t,n){return this._client.post(ni`/containers/${e}/files`,t1({body:t,...n},this._client))}retrieve(e,t,n){let{container_id:r}=t;return this._client.get(ni`/containers/${r}/files/${e}`,n)}list(e,t={},n){return this._client.getAPIList(ni`/containers/${e}/files`,tG,{query:t,...n})}delete(e,t,n){let{container_id:r}=t;return this._client.delete(ni`/containers/${r}/files/${e}`,{...n,headers:nR([{Accept:"*/*"},n?.headers])})}}nJ.Content=nX;class nQ extends nt{constructor(){super(...arguments),this.files=new nJ(this._client)}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(ni`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",tG,{query:e,...t})}delete(e,t){return this._client.delete(ni`/containers/${e}`,{...t,headers:nR([{Accept:"*/*"},t?.headers])})}}nQ.Files=nJ;class nZ extends nt{create(e,t,n){let{include:r,...i}=t;return this._client.post(ni`/conversations/${e}/items`,{query:{include:r},body:i,...n})}retrieve(e,t,n){let{conversation_id:r,...i}=t;return this._client.get(ni`/conversations/${r}/items/${e}`,{query:i,...n})}list(e,t={},n){return this._client.getAPIList(ni`/conversations/${e}/items`,tX,{query:t,...n})}delete(e,t,n){let{conversation_id:r}=t;return this._client.delete(ni`/conversations/${r}/items/${e}`,n)}}class n0 extends nt{constructor(){super(...arguments),this.items=new nZ(this._client)}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(ni`/conversations/${e}`,t)}update(e,t,n){return this._client.post(ni`/conversations/${e}`,{body:t,...n})}delete(e,t){return this._client.delete(ni`/conversations/${e}`,t)}}n0.Items=nZ;class n1 extends nt{create(e,t){let n=!!e.encoding_format,r=n?e.encoding_format:"base64";n&&tN(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);let i=this._client.post("/embeddings",{body:{...e,encoding_format:r},...t});return n?i:(tN(this._client).debug("embeddings/decoding base64 embeddings from base64"),i._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{let t=e.embedding;e.embedding=(e=>{if("u">typeof Buffer){let t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}{let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return Array.from(new Float32Array(r.buffer))}})(t)}),e)))}}class n2 extends nt{retrieve(e,t,n){let{eval_id:r,run_id:i}=t;return this._client.get(ni`/evals/${r}/runs/${i}/output_items/${e}`,n)}list(e,t,n){let{eval_id:r,...i}=t;return this._client.getAPIList(ni`/evals/${r}/runs/${e}/output_items`,tG,{query:i,...n})}}class n3 extends nt{constructor(){super(...arguments),this.outputItems=new n2(this._client)}create(e,t,n){return this._client.post(ni`/evals/${e}/runs`,{body:t,...n})}retrieve(e,t,n){let{eval_id:r}=t;return this._client.get(ni`/evals/${r}/runs/${e}`,n)}list(e,t={},n){return this._client.getAPIList(ni`/evals/${e}/runs`,tG,{query:t,...n})}delete(e,t,n){let{eval_id:r}=t;return this._client.delete(ni`/evals/${r}/runs/${e}`,n)}cancel(e,t,n){let{eval_id:r}=t;return this._client.post(ni`/evals/${r}/runs/${e}`,n)}}n3.OutputItems=n2;class n6 extends nt{constructor(){super(...arguments),this.runs=new n3(this._client)}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(ni`/evals/${e}`,t)}update(e,t,n){return this._client.post(ni`/evals/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/evals",tG,{query:e,...t})}delete(e,t){return this._client.delete(ni`/evals/${e}`,t)}}n6.Runs=n3;class n8 extends nt{create(e,t){return this._client.post("/files",t2({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ni`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",tG,{query:e,...t})}delete(e,t){return this._client.delete(ni`/files/${e}`,t)}content(e,t){return this._client.get(ni`/files/${e}/content`,{...t,headers:nR([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=18e5}={}){let r=new Set(["processed","error","deleted"]),i=Date.now(),s=await this.retrieve(e);for(;!s.status||!r.has(s.status);)if(await tc(t),s=await this.retrieve(e),Date.now()-i>n)throw new e2({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return s}}class n4 extends nt{}class n5 extends nt{run(e,t){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...t})}validate(e,t){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...t})}}class n9 extends nt{constructor(){super(...arguments),this.graders=new n5(this._client)}}n9.Graders=n5;class n7 extends nt{create(e,t,n){return this._client.getAPIList(ni`/fine_tuning/checkpoints/${e}/permissions`,tY,{body:t,method:"post",...n})}retrieve(e,t={},n){return this._client.get(ni`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...n})}delete(e,t,n){let{fine_tuned_model_checkpoint:r}=t;return this._client.delete(ni`/fine_tuning/checkpoints/${r}/permissions/${e}`,n)}}class re extends nt{constructor(){super(...arguments),this.permissions=new n7(this._client)}}re.Permissions=n7;class rt extends nt{list(e,t={},n){return this._client.getAPIList(ni`/fine_tuning/jobs/${e}/checkpoints`,tG,{query:t,...n})}}class rn extends nt{constructor(){super(...arguments),this.checkpoints=new rt(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(ni`/fine_tuning/jobs/${e}`,t)}list(e={},t){return this._client.getAPIList("/fine_tuning/jobs",tG,{query:e,...t})}cancel(e,t){return this._client.post(ni`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},n){return this._client.getAPIList(ni`/fine_tuning/jobs/${e}/events`,tG,{query:t,...n})}pause(e,t){return this._client.post(ni`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(ni`/fine_tuning/jobs/${e}/resume`,t)}}rn.Checkpoints=rt;class rr extends nt{constructor(){super(...arguments),this.methods=new n4(this._client),this.jobs=new rn(this._client),this.checkpoints=new re(this._client),this.alpha=new n9(this._client)}}rr.Methods=n4,rr.Jobs=rn,rr.Checkpoints=re,rr.Alpha=n9;class ri extends nt{}class rs extends nt{constructor(){super(...arguments),this.graderModels=new ri(this._client)}}rs.GraderModels=ri;class ra extends nt{createVariation(e,t){return this._client.post("/images/variations",t2({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",t2({body:e,...t,stream:e.stream??!1},this._client))}generate(e,t){return this._client.post("/images/generations",{body:e,...t,stream:e.stream??!1})}}class ro extends nt{retrieve(e,t){return this._client.get(ni`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",tY,e)}delete(e,t){return this._client.delete(ni`/models/${e}`,t)}}class rl extends nt{create(e,t){return this._client.post("/moderations",{body:e,...t})}}class rc extends nt{accept(e,t,n){return this._client.post(ni`/realtime/calls/${e}/accept`,{body:t,...n,headers:nR([{Accept:"*/*"},n?.headers])})}hangup(e,t){return this._client.post(ni`/realtime/calls/${e}/hangup`,{...t,headers:nR([{Accept:"*/*"},t?.headers])})}refer(e,t,n){return this._client.post(ni`/realtime/calls/${e}/refer`,{body:t,...n,headers:nR([{Accept:"*/*"},n?.headers])})}reject(e,t={},n){return this._client.post(ni`/realtime/calls/${e}/reject`,{body:t,...n,headers:nR([{Accept:"*/*"},n?.headers])})}}class ru extends nt{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}}class rh extends nt{constructor(){super(...arguments),this.clientSecrets=new ru(this._client),this.calls=new rc(this._client)}}function rd(e,t){let n=e.output.map(e=>{if("function_call"===e.type)return{...e,parsed_arguments:function(e,t){var n,r;let i=(n=e.tools??[],r=t.name,n.find(e=>"function"===e.type&&e.name===r));return{...t,...t,parsed_arguments:i?.$brand==="auto-parseable-tool"?i.$parseRaw(t.arguments):i?.strict?JSON.parse(t.arguments):null}}(t,e)};if("message"===e.type){let n=e.content.map(e=>{var n,r;return"output_text"===e.type?{...e,parsed:(n=t,r=e.text,n.text?.format?.type!=="json_schema"?null:"$parseRaw"in n.text?.format?(n.text?.format).$parseRaw(r):JSON.parse(r))}:e});return{...e,content:n}}return e}),r=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,"output_text")||rf(r),Object.defineProperty(r,"output_parsed",{enumerable:!0,get(){for(let e of r.output)if("message"===e.type){for(let t of e.content)if("output_text"===t.type&&null!==t.parsed)return t.parsed}return null}}),r}function rf(e){let t=[];for(let n of e.output)if("message"===n.type)for(let e of n.content)"output_text"===e.type&&t.push(e.text);e.output_text=t.join("")}rh.ClientSecrets=ru,rh.Calls=rc;class rp extends np{constructor(e){super(),ef.add(this),ep.set(this,void 0),em.set(this,void 0),eg.set(this,void 0),eK(this,ep,e,"f")}static createResponse(e,t,n){let r=new rp(t);return r._run(()=>r._createOrRetrieveResponse(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createOrRetrieveResponse(e,t,n){let r,i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),eY(this,ef,"m",ey).call(this);let s=null;for await(let i of("response_id"in t?(r=await e.responses.retrieve(t.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),s=t.starting_after??null):r=await e.responses.create({...t,stream:!0},{...n,signal:this.controller.signal}),this._connected(),r))eY(this,ef,"m",eb).call(this,i,s);if(r.controller.signal?.aborted)throw new e0;return eY(this,ef,"m",ev).call(this)}[(ep=new WeakMap,em=new WeakMap,eg=new WeakMap,ef=new WeakSet,ey=function(){this.ended||eK(this,em,void 0,"f")},eb=function(e,t){if(this.ended)return;let n=(e,n)=>{(null==t||n.sequence_number>t)&&this._emit(e,n)},r=eY(this,ef,"m",ew).call(this,e);switch(n("event",e),e.type){case"response.output_text.delta":{let t=r.output[e.output_index];if(!t)throw new eQ(`missing output at index ${e.output_index}`);if("message"===t.type){let r=t.content[e.content_index];if(!r)throw new eQ(`missing content at index ${e.content_index}`);if("output_text"!==r.type)throw new eQ(`expected content to be 'output_text', got ${r.type}`);n("response.output_text.delta",{...e,snapshot:r.text})}break}case"response.function_call_arguments.delta":{let t=r.output[e.output_index];if(!t)throw new eQ(`missing output at index ${e.output_index}`);"function_call"===t.type&&n("response.function_call_arguments.delta",{...e,snapshot:t.arguments});break}default:n(e.type,e)}},ev=function(){if(this.ended)throw new eQ("stream has ended, this shouldn't happen");let e=eY(this,em,"f");if(!e)throw new eQ("request ended without sending any events");eK(this,em,void 0,"f");let t=function(e,t){var n;return t&&(n=t,no(n.text?.format))?rd(e,t):{...e,output_parsed:null,output:e.output.map(e=>"function_call"===e.type?{...e,parsed_arguments:null}:"message"===e.type?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}}(e,eY(this,ep,"f"));return eK(this,eg,t,"f"),t},ew=function(e){let t=eY(this,em,"f");if(!t){if("response.created"!==e.type)throw new eQ(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return eK(this,em,e.response,"f")}switch(e.type){case"response.output_item.added":t.output.push(e.item);break;case"response.content_part.added":{let n=t.output[e.output_index];if(!n)throw new eQ(`missing output at index ${e.output_index}`);let r=n.type,i=e.part;"message"===r&&"reasoning_text"!==i.type?n.content.push(i):"reasoning"===r&&"reasoning_text"===i.type&&(n.content||(n.content=[]),n.content.push(i));break}case"response.output_text.delta":{let n=t.output[e.output_index];if(!n)throw new eQ(`missing output at index ${e.output_index}`);if("message"===n.type){let t=n.content[e.content_index];if(!t)throw new eQ(`missing content at index ${e.content_index}`);if("output_text"!==t.type)throw new eQ(`expected content to be 'output_text', got ${t.type}`);t.text+=e.delta}break}case"response.function_call_arguments.delta":{let n=t.output[e.output_index];if(!n)throw new eQ(`missing output at index ${e.output_index}`);"function_call"===n.type&&(n.arguments+=e.delta);break}case"response.reasoning_text.delta":{let n=t.output[e.output_index];if(!n)throw new eQ(`missing output at index ${e.output_index}`);if("reasoning"===n.type){let t=n.content?.[e.content_index];if(!t)throw new eQ(`missing content at index ${e.content_index}`);if("reasoning_text"!==t.type)throw new eQ(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case"response.completed":eK(this,em,e.response,"f")}return t},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on("event",n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on("end",()=>{for(let e of(n=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let r of(n=!0,t))r.reject(e);t.length=0}),this.on("error",e=>{for(let r of(n=!0,t))r.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=eY(this,eg,"f");if(!e)throw new eQ("stream ended without producing a ChatCompletion");return e}}class rm extends nt{list(e,t={},n){return this._client.getAPIList(ni`/responses/${e}/input_items`,tG,{query:t,...n})}}class rg extends nt{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}}class ry extends nt{constructor(){super(...arguments),this.inputItems=new rm(this._client),this.inputTokens=new rg(this._client)}create(e,t){return this._client.post("/responses",{body:e,...t,stream:e.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&rf(e),e))}retrieve(e,t={},n){return this._client.get(ni`/responses/${e}`,{query:t,...n,stream:t?.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&rf(e),e))}delete(e,t){return this._client.delete(ni`/responses/${e}`,{...t,headers:nR([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>rd(t,e))}stream(e,t){return rp.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(ni`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}}ry.InputItems=rm,ry.InputTokens=rg;class rb extends nt{retrieve(e,t){return this._client.get(ni`/skills/${e}/content`,{...t,headers:nR([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}}class rv extends nt{retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(ni`/skills/${r}/versions/${e}/content`,{...n,headers:nR([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}}class rw extends nt{constructor(){super(...arguments),this.content=new rv(this._client)}create(e,t={},n){return this._client.post(ni`/skills/${e}/versions`,t1({body:t,...n},this._client))}retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(ni`/skills/${r}/versions/${e}`,n)}list(e,t={},n){return this._client.getAPIList(ni`/skills/${e}/versions`,tG,{query:t,...n})}delete(e,t,n){let{skill_id:r}=t;return this._client.delete(ni`/skills/${r}/versions/${e}`,n)}}rw.Content=rv;class r_ extends nt{constructor(){super(...arguments),this.content=new rb(this._client),this.versions=new rw(this._client)}create(e={},t){return this._client.post("/skills",t1({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ni`/skills/${e}`,t)}update(e,t,n){return this._client.post(ni`/skills/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/skills",tG,{query:e,...t})}delete(e,t){return this._client.delete(ni`/skills/${e}`,t)}}r_.Content=rb,r_.Versions=rw;class rS extends nt{create(e,t,n){return this._client.post(ni`/uploads/${e}/parts`,t2({body:t,...n},this._client))}}class rx extends nt{constructor(){super(...arguments),this.parts=new rS(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(ni`/uploads/${e}/cancel`,t)}complete(e,t,n){return this._client.post(ni`/uploads/${e}/complete`,{body:t,...n})}}rx.Parts=rS;let rE=async e=>{let t=await Promise.allSettled(e),n=t.filter(e=>"rejected"===e.status);if(n.length){for(let e of n)console.error(e.reason);throw Error(`${n.length} promise(s) failed - see the above errors`)}let r=[];for(let e of t)"fulfilled"===e.status&&r.push(e.value);return r};class rk extends nt{create(e,t,n){return this._client.post(ni`/vector_stores/${e}/file_batches`,{body:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(ni`/vector_stores/${r}/file_batches/${e}`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,t,n){let{vector_store_id:r}=t;return this._client.post(ni`/vector_stores/${r}/file_batches/${e}/cancel`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){let r=await this.create(e,t);return await this.poll(e,r.id,n)}listFiles(e,t,n){let{vector_store_id:r,...i}=t;return this._client.getAPIList(ni`/vector_stores/${r}/file_batches/${e}/files`,tG,{query:i,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async poll(e,t,n){let r=nR([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:s}=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse();switch(i.status){case"in_progress":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let e=s.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await tc(a);break;case"failed":case"cancelled":case"completed":return i}}}async uploadAndPoll(e,{files:t,fileIds:n=[]},r){if(null==t||0==t.length)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let i=Math.min(r?.maxConcurrency??5,t.length),s=this._client,a=t.values(),o=[...n];async function l(e){for(let t of e){let e=await s.files.create({file:t,purpose:"assistants"},r);o.push(e.id)}}let c=Array(i).fill(a).map(l);return await rE(c),await this.createAndPoll(e,{file_ids:o})}}class rC extends nt{create(e,t,n){return this._client.post(ni`/vector_stores/${e}/files`,{body:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(ni`/vector_stores/${r}/files/${e}`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){let{vector_store_id:r,...i}=t;return this._client.post(ni`/vector_stores/${r}/files/${e}`,{body:i,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(ni`/vector_stores/${e}/files`,tG,{query:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t,n){let{vector_store_id:r}=t;return this._client.delete(ni`/vector_stores/${r}/files/${e}`,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(e,r.id,n)}async poll(e,t,n){let r=nR([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let i=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse(),s=i.data;switch(s.status){case"in_progress":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let e=i.response.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await tc(a);break;case"failed":case"completed":return s}}}async upload(e,t,n){let r=await this._client.files.create({file:t,purpose:"assistants"},n);return this.create(e,{file_id:r.id},n)}async uploadAndPoll(e,t,n){let r=await this.upload(e,t,n);return await this.poll(e,r.id,n)}content(e,t,n){let{vector_store_id:r}=t;return this._client.getAPIList(ni`/vector_stores/${r}/files/${e}/content`,tY,{...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}class rT extends nt{constructor(){super(...arguments),this.files=new rC(this._client),this.fileBatches=new rk(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ni`/vector_stores/${e}`,{...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(ni`/vector_stores/${e}`,{body:t,...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",tG,{query:e,...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(ni`/vector_stores/${e}`,{...t,headers:nR([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,n){return this._client.getAPIList(ni`/vector_stores/${e}/search`,tY,{body:t,method:"post",...n,headers:nR([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}rT.Files=rC,rT.FileBatches=rk;class rA extends nt{create(e,t){return this._client.post("/videos",t1({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ni`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",tX,{query:e,...t})}delete(e,t){return this._client.delete(ni`/videos/${e}`,t)}downloadContent(e,t={},n){return this._client.get(ni`/videos/${e}/content`,{query:t,...n,headers:nR([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}remix(e,t,n){return this._client.post(ni`/videos/${e}/remix`,t1({body:t,...n},this._client))}}class rR extends nt{constructor(){super(...arguments),e_.add(this)}async unwrap(e,t,n=this._client.webhookSecret,r=300){return await this.verifySignature(e,t,n,r),JSON.parse(e)}async verifySignature(e,t,n=this._client.webhookSecret,r=300){if("u"<typeof crypto||"function"!=typeof crypto.subtle.importKey||"function"!=typeof crypto.subtle.verify)throw Error("Webhook signature verification is only supported when the `crypto` global is defined");eY(this,e_,"m",eS).call(this,n);let i=nR([t]).values,s=eY(this,e_,"m",ex).call(this,i,"webhook-signature"),a=eY(this,e_,"m",ex).call(this,i,"webhook-timestamp"),o=eY(this,e_,"m",ex).call(this,i,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new tr("Invalid webhook timestamp format");let c=Math.floor(Date.now()/1e3);if(c-l>r)throw new tr("Webhook timestamp is too old");if(l>c+r)throw new tr("Webhook timestamp is too new");let u=s.split(" ").map(e=>e.startsWith("v1,")?e.substring(3):e),h=n.startsWith("whsec_")?Buffer.from(n.replace("whsec_",""),"base64"):Buffer.from(n,"utf-8"),d=o?`${o}.${a}.${e}`:`${a}.${e}`,f=await crypto.subtle.importKey("raw",h,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let e of u)try{let t=Buffer.from(e,"base64");if(await crypto.subtle.verify("HMAC",f,t,new TextEncoder().encode(d)))return}catch{continue}throw new tr("The given webhook signature does not match the expected signature")}}e_=new WeakSet,eS=function(e){if("string"!=typeof e||0===e.length)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},ex=function(e,t){if(!e)throw Error("Headers are required");let n=e.get(t);if(null==n)throw Error(`Missing required header: ${t}`);return n},e.i(98546);class rI{constructor({baseURL:e=nq("OPENAI_BASE_URL"),apiKey:t=nq("OPENAI_API_KEY"),organization:n=nq("OPENAI_ORG_ID")??null,project:r=nq("OPENAI_PROJECT_ID")??null,webhookSecret:i=nq("OPENAI_WEBHOOK_SECRET")??null,...s}={}){if(eE.add(this),eC.set(this,void 0),this.completions=new nG(this),this.chat=new nT(this),this.embeddings=new n1(this),this.files=new n8(this),this.images=new ra(this),this.audio=new nM(this),this.moderations=new rl(this),this.models=new ro(this),this.fineTuning=new rr(this),this.graders=new rs(this),this.vectorStores=new rT(this),this.webhooks=new rR(this),this.beta=new nY(this),this.batches=new nD(this),this.uploads=new rx(this),this.responses=new ry(this),this.realtime=new rh(this),this.conversations=new n0(this),this.evals=new n6(this),this.containers=new nQ(this),this.skills=new r_(this),this.videos=new rA(this),void 0===t)throw new eQ("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:t,organization:n,project:r,webhookSecret:i,...s,baseURL:e||"https://api.openai.com/v1"};a.dangerouslyAllowBrowser,this.baseURL=a.baseURL,this.timeout=a.timeout??ek.DEFAULT_TIMEOUT,this.logger=a.logger??console;const o="warn";this.logLevel=o,this.logLevel=tP(a.logLevel,"ClientOptions.logLevel",this)??tP(nq("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??o,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??function(){if("u">typeof fetch)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),eK(this,eC,ty,"f"),this._options=a,this.apiKey="string"==typeof t?t:"Missing Key",this.organization=n,this.project=r,this.webhookSecret=i}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){}async authHeaders(e){return nR([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return function(e,t={}){let n,r=e,i=function(e=tC){let t;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw TypeError("Encoder has to be a function.");let n=e.charset||tC.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=tb;if(void 0!==e.format){if(!t_(tw,e.format))throw TypeError("Unknown format option provided.");r=e.format}let i=tw[r],s=tC.filter;if(("function"==typeof e.filter||ts(e.filter))&&(s=e.filter),t=e.arrayFormat&&e.arrayFormat in tE?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":tC.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let a=void 0===e.allowDots?!0==!!e.encodeDotInKeys||tC.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:tC.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:tC.allowEmptyArrays,arrayFormat:t,charset:n,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:tC.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?tC.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:tC.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:tC.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:tC.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:tC.encodeValuesOnly,filter:s,format:r,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:tC.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:tC.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:tC.strictNullHandling}}(t);"function"==typeof i.filter?r=(0,i.filter)("",r):ts(i.filter)&&(n=i.filter);let s=[];if("object"!=typeof r||null===r)return"";let a=tE[i.arrayFormat],o="comma"===a&&i.commaRoundTrip;n||(n=Object.keys(r)),i.sort&&n.sort(i.sort);let l=new WeakMap;for(let e=0;e<n.length;++e){let t=n[e];i.skipNulls&&null===r[t]||tk(s,function e(t,n,r,i,s,a,o,l,c,u,h,d,f,p,m,g,y,b){var v,w;let _,S=t,x=b,E=0,k=!1;for(;void 0!==(x=x.get(tT))&&!k;){let e=x.get(t);if(E+=1,void 0!==e)if(e===E)throw RangeError("Cyclic object value");else k=!0;void 0===x.get(tT)&&(E=0)}if("function"==typeof u?S=u(n,S):S instanceof Date?S=f?.(S):"comma"===r&&ts(S)&&(S=tx(S,function(e){return e instanceof Date?f?.(e):e})),null===S){if(a)return c&&!g?c(n,tC.encoder,y,"key",p):n;S=""}if("string"==typeof(v=S)||"number"==typeof v||"boolean"==typeof v||"symbol"==typeof v||"bigint"==typeof v||(w=S)&&"object"==typeof w&&w.constructor&&w.constructor.isBuffer&&w.constructor.isBuffer(w)){if(c){let e=g?n:c(n,tC.encoder,y,"key",p);return[m?.(e)+"="+m?.(c(S,tC.encoder,y,"value",p))]}return[m?.(n)+"="+m?.(String(S))]}let C=[];if(void 0===S)return C;if("comma"===r&&ts(S))g&&c&&(S=tx(S,c)),_=[{value:S.length>0?S.join(",")||null:void 0}];else if(ts(u))_=u;else{let e=Object.keys(S);_=h?e.sort(h):e}let T=l?String(n).replace(/\./g,"%2E"):String(n),A=i&&ts(S)&&1===S.length?T+"[]":T;if(s&&ts(S)&&0===S.length)return A+"[]";for(let n=0;n<_.length;++n){let v=_[n],w="object"==typeof v&&void 0!==v.value?v.value:S[v];if(o&&null===w)continue;let x=d&&l?v.replace(/\./g,"%2E"):v,k=ts(S)?"function"==typeof r?r(A,x):A:A+(d?"."+x:"["+x+"]");b.set(t,E);let T=new WeakMap;T.set(tT,b),tk(C,e(w,k,r,i,s,a,o,l,"comma"===r&&g&&ts(S)?null:c,u,h,d,f,p,m,g,y,T))}return C}(r[t],t,a,o,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,l))}let c=s.join(i.delimiter),u=!0===i.addQueryPrefix?"?":"";return i.charsetSentinel&&("iso-8859-1"===i.charset?u+="utf8=%26%2310003%3B&":u+="utf8=%E2%9C%93&"),c.length>0?u+c:""}(e,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${tu}`}defaultIdempotencyKey(){return`stainless-node-retry-${eG()}`}makeStatusError(e,t,n,r){return eZ.generate(e,t,n,r)}async _callApiKey(){let e,t=this._options.apiKey;if("function"!=typeof t)return!1;try{e=await t()}catch(e){if(e instanceof eQ)throw e;throw new eQ(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if("string"!=typeof e||!e)throw new eQ(`Expected 'apiKey' function argument to return a string but it returned ${e}`);return this.apiKey=e,!0}buildURL(e,t,n){let r=!eY(this,eE,"m",eT).call(this)&&n||this.baseURL,i=new URL(ti.test(e)?e:r+(r.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery();return!function(e){if(!e)return!0;for(let t in e)return!1;return!0}(s)&&(t={...s,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new tz(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;null==t&&(t=i),await this.prepareOptions(r);let{req:s,url:a,timeout:o}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(s,{url:a,options:r});let l="log_"+(0x1000000*Math.random()|0).toString(16).padStart(6,"0"),c=void 0===n?"":`, retryOf: ${n}`,u=Date.now();if(tN(this).debug(`[${l}] sending request`,tU({retryOfRequestLogID:n,method:r.method,url:a,options:r,headers:s.headers})),r.signal?.aborted)throw new e0;let h=new AbortController,d=await this.fetchWithTimeout(a,s,o,h).catch(eJ),f=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new e0;let i=eX(d)||/timed? ?out/i.test(String(d)+("cause"in d?String(d.cause):""));if(t)return tN(this).info(`[${l}] connection ${i?"timed out":"failed"} - ${e}`),tN(this).debug(`[${l}] connection ${i?"timed out":"failed"} (${e})`,tU({retryOfRequestLogID:n,url:a,durationMs:f-u,message:d.message})),this.retryRequest(r,t,n??l);if(tN(this).info(`[${l}] connection ${i?"timed out":"failed"} - error; no more retries left`),tN(this).debug(`[${l}] connection ${i?"timed out":"failed"} (error; no more retries left)`,tU({retryOfRequestLogID:n,url:a,durationMs:f-u,message:d.message})),i)throw new e2;throw new e1({cause:d})}let p=[...d.headers.entries()].filter(([e])=>"x-request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),m=`[${l}${c}${p}] ${s.method} ${a} ${d.ok?"succeeded":"failed"} with status ${d.status} in ${f-u}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await tg(d.body),tN(this).info(`${m} - ${e}`),tN(this).debug(`[${l}] response error (${e})`,tU({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),this.retryRequest(r,t,n??l,d.headers)}let i=e?"error; no more retries left":"error; not retryable";tN(this).info(`${m} - ${i}`);let s=await d.text().catch(e=>eJ(e).message),a=(e=>{try{return JSON.parse(e)}catch(e){return}})(s),o=a?void 0:s;throw tN(this).debug(`[${l}] response error (${i})`,tU({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,message:o,durationMs:Date.now()-u})),this.makeStatusError(d.status,a,o,d.headers)}return tN(this).info(m),tN(this).debug(`[${l}] response start`,tU({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),{response:d,options:r,controller:h,requestLogID:l,retryOfRequestLogID:n,startTime:u}}getAPIList(e,t,n){return this.requestAPIList(t,n&&"then"in n?n.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...n})}requestAPIList(e,t){return new tK(this,this.makeRequest(t,null,void 0),e)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:s,...a}=t||{},o=this._makeAbort(r);i&&i.addEventListener("abort",o,{once:!0});let l=setTimeout(o,n),c=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||"object"==typeof a.body&&null!==a.body&&Symbol.asyncIterator in a.body,u={signal:r.signal,...c?{duplex:"half"}:{},method:"GET",...a};s&&(u.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||409===e.status||429===e.status||!!(e.status>=500))}async retryRequest(e,t,n,r){let i,s=r?.get("retry-after-ms");if(s){let e=parseFloat(s);Number.isNaN(e)||(i=e)}let a=r?.get("retry-after");if(a&&!i){let e=parseFloat(a);i=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}if(!(i&&0<=i&&i<6e4)){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await tc(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){return Math.min(.5*Math.pow(2,t-e),8)*(1-.25*Math.random())*1e3}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:s,defaultBaseURL:a}=n,o=this.buildURL(i,s,a);"timeout"in n&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new eQ(`${e} must be an integer`);if(t<0)throw new eQ(`${e} must be a positive integer`)})("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:c}=this.buildBody({options:n}),u=await this.buildHeaders({options:e,method:r,bodyHeaders:l,retryCount:t});return{req:{method:r,headers:u,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&c instanceof globalThis.ReadableStream&&{duplex:"half"},...c&&{body:c},...this.fetchOptions??{},...n.fetchOptions??{}},url:o,timeout:n.timeout}}async buildHeaders({options:e,method:n,bodyHeaders:r,retryCount:i}){let s={};this.idempotencyHeader&&"get"!==n&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let a=nR([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...t??(t=(()=>{let e="u">typeof Deno&&null!=Deno.build?"deno":"u">typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":tu,"X-Stainless-OS":td(Deno.build.os),"X-Stainless-Arch":th(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("u">typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":tu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":tu,"X-Stainless-OS":td(globalThis.process.platform??"unknown"),"X-Stainless-Arch":th(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=function(){if("u"<typeof navigator||!navigator)return null;for(let{key:e,pattern:t}of[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n){let t=n[1]||0,r=n[2]||0,i=n[3]||0;return{browser:e,version:`${t}.${r}.${i}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":tu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":tu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}})()),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=nR([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:tp(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===n.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:eY(this,eC,"f").call(this,{body:e,headers:n})}}ek=rI,eC=new WeakMap,eE=new WeakSet,eT=function(){return"https://api.openai.com/v1"!==this.baseURL},rI.OpenAI=ek,rI.DEFAULT_TIMEOUT=6e5,rI.OpenAIError=eQ,rI.APIError=eZ,rI.APIConnectionError=e1,rI.APIConnectionTimeoutError=e2,rI.APIUserAbortError=e0,rI.NotFoundError=e4,rI.ConflictError=e5,rI.RateLimitError=e7,rI.BadRequestError=e3,rI.AuthenticationError=e6,rI.InternalServerError=te,rI.PermissionDeniedError=e8,rI.UnprocessableEntityError=e9,rI.InvalidWebhookSignatureError=tr,rI.toFile=t7,rI.Completions=nG,rI.Chat=nT,rI.Embeddings=n1,rI.Files=n8,rI.Images=ra,rI.Audio=nM,rI.Moderations=rl,rI.Models=ro,rI.FineTuning=rr,rI.Graders=rs,rI.VectorStores=rT,rI.Webhooks=rR,rI.Beta=nY,rI.Batches=nD,rI.Uploads=rx,rI.Responses=ry,rI.Realtime=rh,rI.Conversations=n0,rI.Evals=n6,rI.Containers=nQ,rI.Skills=r_,rI.Videos=rA;var rO=e.i(22734),rP=e.i(14747),rM=e.i(33405),rD=e.i(7367),rL=e.i(96632),r$=e.i(48505),rN=e.i(56524),rU=e.i(49852),rB=e.i(9881),rF=e.i(89073);class rj{signer;constructor(e){this.signer=e.signer}presign(e,t={}){return this.signer.presign(e,t)}async sign(e,t){return rF.HttpRequest.isInstance(e)&&("ws:"===e.protocol||"wss:"===e.protocol)?{...await this.signer.presign({...e,body:""},{...t,expiresIn:60,unsignableHeaders:new Set(Object.keys(e.headers).filter(e=>"host"!==e))}),body:e.body}:this.signer.sign(e,t)}signMessage(e,t){return this.signer.signMessage(e,t)}}var rH=e.i(24642),rW=e.i(81335),rq=e.i(92457),rz=e.i(37383),rV=e.i(76105),rK=e.i(64919),rY=e.i(14722),rG=e.i(68103),rX=e.i(53525),rJ=e.i(29556),rQ=e.i(10455),rZ=e.i(80768),r0=e.i(74016);let r1=async(e,t,n)=>({operation:(0,rZ.getSmithyContext)(t).operation,region:await (0,r0.normalizeProvider)(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()}),r2=e=>{let t=[];return e.operation,t.push({schemeId:"aws.auth#sigv4",signingProperties:{name:"transcribe",region:e.region},propertiesExtractor:(e,t)=>({signingProperties:{config:e,context:t}})}),t},r3={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}};var r6=e.i(37374),r8=e.i(32710),r4=e.i(88832),r5=e.i(7335),r9=e.i(60400),r7=e.i(81355),ie=e.i(39866);let it="AWS_EC2_METADATA_DISABLED",ir=async t=>{let{ENV_CMDS_FULL_URI:n,ENV_CMDS_RELATIVE_URI:r,fromContainerMetadata:i,fromInstanceMetadata:s}=await e.A(14277);if(process.env[r]||process.env[n]){t.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromHttp/fromContainerMetadata");let{fromHttp:n}=await e.A(93306);return(0,ie.chain)(n(t),i(t))}return process.env[it]&&"false"!==process.env[it]?async()=>{throw new r9.CredentialsProviderError("EC2 Instance Metadata Service access disabled",{logger:t.logger})}:(t.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromInstanceMetadata"),s(t))},ii=!1,is=(t={})=>{let n,r,i,s,a,o;return o=[async()=>{if(t.profile??process.env[r7.ENV_PROFILE])throw process.env[r5.ENV_KEY]&&process.env[r5.ENV_SECRET]&&!ii&&((t.logger?.warn&&t.logger?.constructor?.name!=="NoOpLogger"?t.logger.warn.bind(t.logger):console.warn)(`@aws-sdk/credential-provider-node - defaultProvider::fromEnv WARNING:
9
+ Multiple credential sources detected:
10
+ Both AWS_PROFILE and the pair AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY static credentials are set.
11
+ This SDK will proceed with the AWS_PROFILE value.
12
+
13
+ However, a future version may change this behavior to prefer the ENV static credentials.
14
+ Please ensure that your environment only sets either the AWS_PROFILE or the
15
+ AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY pair.
16
+ `),ii=!0),new r9.CredentialsProviderError("AWS_PROFILE is set, skipping fromEnv provider.",{logger:t.logger,tryNextLink:!0});return t.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromEnv"),(0,r5.fromEnv)(t)()},async n=>{t.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromSSO");let{ssoStartUrl:r,ssoAccountId:i,ssoRegion:s,ssoRoleName:a,ssoSession:o}=t;if(!r&&!i&&!s&&!a&&!o)throw new r9.CredentialsProviderError("Skipping SSO provider in default chain (inputs do not include SSO fields).",{logger:t.logger});let{fromSSO:l}=await e.A(14115);return l(t)(n)},async n=>{t.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromIni");let{fromIni:r}=await e.A(9193);return r(t)(n)},async n=>{t.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromProcess");let{fromProcess:r}=await e.A(85365);return r(t)(n)},async n=>{t.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromTokenFile");let{fromTokenFile:r}=await e.A(52170);return r(t)(n)},async()=>(t.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::remoteProvider"),(await ir(t))()),async()=>{throw new r9.CredentialsProviderError("Could not load credentials from any providers",{tryNextLink:!1,logger:t.logger})}],s=async e=>{let t;for(let n of o)try{return await n(e)}catch(e){if(t=e,e?.tryNextLink)continue;throw e}throw t},a=async e=>{if(e?.forceRefresh)return await s(e);if(i?.expiration&&i?.expiration?.getTime()<Date.now()&&(i=void 0),n)await n;else if(!i||ia?.(i))if(!i)return n=s(e).then(e=>{i=e}).finally(()=>{n=void 0}),a(e);else r||(r=s(e).then(e=>{i=e}).finally(()=>{r=void 0}));return i}},ia=e=>e?.expiration!==void 0&&e.expiration.getTime()-Date.now()<3e5;var io=("function"==typeof SuppressedError&&SuppressedError,e.i(874)),il="u">typeof Buffer&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:e=>{let t=((e,t)=>{if("string"!=typeof e)throw TypeError(`The "input" argument must be of type string. Received type ${typeof e} (${e})`);return t?io.Buffer.from(e,t):io.Buffer.from(e)})(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT)};function ic(){this.crc32=new iu}ic.prototype.update=function(e){("string"==typeof e?0===e.length:0===e.byteLength)||this.crc32.update(e instanceof Uint8Array?e:"string"==typeof e?il(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e))},ic.prototype.digest=function(){var e,t,n,r;return e=this,t=void 0,n=void 0,r=function(){return function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(l){var c=[o,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,r=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===c[0]||2===c[0])){s=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(6===c[0]&&s.label<i[1]){s.label=i[1],i=c;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(c);break}i[2]&&s.ops.pop(),s.trys.pop();continue}c=t.call(e,s)}catch(e){c=[6,e],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){var t;return[2,new Uint8Array([(0xff000000&(t=this.crc32.digest()))>>24,(0xff0000&t)>>16,(65280&t)>>8,255&t])]})},new(n||(n=Promise))(function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,o)}l((r=r.apply(e,t||[])).next())})},ic.prototype.reset=function(){this.crc32=new iu};var iu=function(){function e(){this.checksum=0xffffffff}return e.prototype.update=function(e){var t,n;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),i=r.next();!i.done;i=r.next()){var s=i.value;this.checksum=this.checksum>>>8^ih[(this.checksum^s)&255]}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return this},e.prototype.digest=function(){return(0xffffffff^this.checksum)>>>0},e}(),ih=function(e){if(!Uint32Array.from){for(var t=new Uint32Array(e.length),n=0;n<e.length;)t[n]=e[n],n+=1;return t}return Uint32Array.from(e)}([0,0x77073096,0xee0e612c,0x990951ba,0x76dc419,0x706af48f,0xe963a535,0x9e6495a3,0xedb8832,0x79dcb8a4,0xe0d5e91e,0x97d2d988,0x9b64c2b,0x7eb17cbd,0xe7b82d07,0x90bf1d91,0x1db71064,0x6ab020f2,0xf3b97148,0x84be41de,0x1adad47d,0x6ddde4eb,0xf4d4b551,0x83d385c7,0x136c9856,0x646ba8c0,0xfd62f97a,0x8a65c9ec,0x14015c4f,0x63066cd9,0xfa0f3d63,0x8d080df5,0x3b6e20c8,0x4c69105e,0xd56041e4,0xa2677172,0x3c03e4d1,0x4b04d447,0xd20d85fd,0xa50ab56b,0x35b5a8fa,0x42b2986c,0xdbbbc9d6,0xacbcf940,0x32d86ce3,0x45df5c75,0xdcd60dcf,0xabd13d59,0x26d930ac,0x51de003a,0xc8d75180,0xbfd06116,0x21b4f4b5,0x56b3c423,0xcfba9599,0xb8bda50f,0x2802b89e,0x5f058808,0xc60cd9b2,0xb10be924,0x2f6f7c87,0x58684c11,0xc1611dab,0xb6662d3d,0x76dc4190,0x1db7106,0x98d220bc,0xefd5102a,0x71b18589,0x6b6b51f,0x9fbfe4a5,0xe8b8d433,0x7807c9a2,0xf00f934,0x9609a88e,0xe10e9818,0x7f6a0dbb,0x86d3d2d,0x91646c97,0xe6635c01,0x6b6b51f4,0x1c6c6162,0x856530d8,0xf262004e,0x6c0695ed,0x1b01a57b,0x8208f4c1,0xf50fc457,0x65b0d9c6,0x12b7e950,0x8bbeb8ea,0xfcb9887c,0x62dd1ddf,0x15da2d49,0x8cd37cf3,0xfbd44c65,0x4db26158,0x3ab551ce,0xa3bc0074,0xd4bb30e2,0x4adfa541,0x3dd895d7,0xa4d1c46d,0xd3d6f4fb,0x4369e96a,0x346ed9fc,0xad678846,0xda60b8d0,0x44042d73,0x33031de5,0xaa0a4c5f,0xdd0d7cc9,0x5005713c,0x270241aa,0xbe0b1010,0xc90c2086,0x5768b525,0x206f85b3,0xb966d409,0xce61e49f,0x5edef90e,0x29d9c998,0xb0d09822,0xc7d7a8b4,0x59b33d17,0x2eb40d81,0xb7bd5c3b,0xc0ba6cad,0xedb88320,0x9abfb3b6,0x3b6e20c,0x74b1d29a,0xead54739,0x9dd277af,0x4db2615,0x73dc1683,0xe3630b12,0x94643b84,0xd6d6a3e,0x7a6a5aa8,0xe40ecf0b,0x9309ff9d,0xa00ae27,0x7d079eb1,0xf00f9344,0x8708a3d2,0x1e01f268,0x6906c2fe,0xf762575d,0x806567cb,0x196c3671,0x6e6b06e7,0xfed41b76,0x89d32be0,0x10da7a5a,0x67dd4acc,0xf9b9df6f,0x8ebeeff9,0x17b7be43,0x60b08ed5,0xd6d6a3e8,0xa1d1937e,0x38d8c2c4,0x4fdff252,0xd1bb67f1,0xa6bc5767,0x3fb506dd,0x48b2364b,0xd80d2bda,0xaf0a1b4c,0x36034af6,0x41047a60,0xdf60efc3,0xa867df55,0x316e8eef,0x4669be79,0xcb61b38c,0xbc66831a,0x256fd2a0,0x5268e236,0xcc0c7795,0xbb0b4703,0x220216b9,0x5505262f,0xc5ba3bbe,0xb2bd0b28,0x2bb45a92,0x5cb36a04,0xc2d7ffa7,0xb5d0cf31,0x2cd99e8b,0x5bdeae1d,0x9b64c2b0,0xec63f226,0x756aa39c,0x26d930a,0x9c0906a9,0xeb0e363f,0x72076785,0x5005713,0x95bf4a82,0xe2b87a14,0x7bb12bae,0xcb61b38,0x92d28e9b,0xe5d5be0d,0x7cdcefb7,0xbdbdf21,0x86d3d2d4,0xf1d4e242,0x68ddb3f8,0x1fda836e,0x81be16cd,0xf6b9265b,0x6fb077e1,0x18b74777,0x88085ae6,0xff0f6a70,0x66063bca,0x11010b5c,0x8f659eff,0xf862ae69,0x616bffd3,0x166ccf45,0xa00ae278,0xd70dd2ee,0x4e048354,0x3903b3c2,0xa7672661,0xd06016f7,0x4969474d,0x3e6e77db,0xaed16a4a,0xd9d65adc,0x40df0b66,936918e3,0xa9bcae53,0xdebb9ec5,0x47b2cf7f,0x30b5ffe9,0xbdbdf21c,0xcabac28a,0x53b39330,0x24b4a3a6,0xbad03605,0xcdd70693,0x54de5729,0x23d967bf,0xb3667a2e,0xc4614ab8,0x5d681b02,0x2a6f2b94,0xb40bbe37,0xc30c8ea1,0x5a05df1b,0x2d02ef8d]),id=e.i(83784);class ip{bytes;constructor(e){if(this.bytes=e,8!==e.byteLength)throw Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(e){if(e>0x8000000000000000||e<-0x8000000000000000)throw Error(`${e} is too large (or, if negative, too small) to represent as an Int64`);let t=new Uint8Array(8);for(let n=7,r=Math.abs(Math.round(e));n>-1&&r>0;n--,r/=256)t[n]=r;return e<0&&im(t),new ip(t)}valueOf(){let e=this.bytes.slice(0),t=128&e[0];return t&&im(e),parseInt((0,id.toHex)(e),16)*(t?-1:1)}toString(){return String(this.valueOf())}}function im(e){for(let t=0;t<8;t++)e[t]^=255;for(let t=7;t>-1&&(e[t]++,0===e[t]);t--);}class ig{toUtf8;fromUtf8;constructor(e,t){this.toUtf8=e,this.fromUtf8=t}format(e){let t=[];for(let n of Object.keys(e)){let r=this.fromUtf8(n);t.push(Uint8Array.from([r.byteLength]),r,this.formatHeaderValue(e[n]))}let n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}formatHeaderValue(e){switch(e.type){case"boolean":return Uint8Array.from([+!e.value]);case"byte":return Uint8Array.from([2,e.value]);case"short":let t=new DataView(new ArrayBuffer(3));return t.setUint8(0,3),t.setInt16(1,e.value,!1),new Uint8Array(t.buffer);case"integer":let n=new DataView(new ArrayBuffer(5));return n.setUint8(0,4),n.setInt32(1,e.value,!1),new Uint8Array(n.buffer);case"long":let r=new Uint8Array(9);return r[0]=5,r.set(e.value.bytes,1),r;case"binary":let i=new DataView(new ArrayBuffer(3+e.value.byteLength));i.setUint8(0,6),i.setUint16(1,e.value.byteLength,!1);let s=new Uint8Array(i.buffer);return s.set(e.value,3),s;case"string":let a=this.fromUtf8(e.value),o=new DataView(new ArrayBuffer(3+a.byteLength));o.setUint8(0,7),o.setUint16(1,a.byteLength,!1);let l=new Uint8Array(o.buffer);return l.set(a,3),l;case"timestamp":let c=new Uint8Array(9);return c[0]=8,c.set(ip.fromNumber(e.value.valueOf()).bytes,1),c;case"uuid":if(!iC.test(e.value))throw Error(`Invalid UUID received: ${e.value}`);let u=new Uint8Array(17);return u[0]=9,u.set((0,id.fromHex)(e.value.replace(/\-/g,"")),1),u}}parse(e){let t={},n=0;for(;n<e.byteLength;){let r=e.getUint8(n++),i=this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,r));switch(n+=r,e.getUint8(n++)){case 0:t[i]={type:iy,value:!0};break;case 1:t[i]={type:iy,value:!1};break;case 2:t[i]={type:ib,value:e.getInt8(n++)};break;case 3:t[i]={type:iv,value:e.getInt16(n,!1)},n+=2;break;case 4:t[i]={type:iw,value:e.getInt32(n,!1)},n+=4;break;case 5:t[i]={type:i_,value:new ip(new Uint8Array(e.buffer,e.byteOffset+n,8))},n+=8;break;case 6:let s=e.getUint16(n,!1);n+=2,t[i]={type:iS,value:new Uint8Array(e.buffer,e.byteOffset+n,s)},n+=s;break;case 7:let a=e.getUint16(n,!1);n+=2,t[i]={type:ix,value:this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,a))},n+=a;break;case 8:t[i]={type:iE,value:new Date(new ip(new Uint8Array(e.buffer,e.byteOffset+n,8)).valueOf())},n+=8;break;case 9:let o=new Uint8Array(e.buffer,e.byteOffset+n,16);n+=16,t[i]={type:ik,value:`${(0,id.toHex)(o.subarray(0,4))}-${(0,id.toHex)(o.subarray(4,6))}-${(0,id.toHex)(o.subarray(6,8))}-${(0,id.toHex)(o.subarray(8,10))}-${(0,id.toHex)(o.subarray(10))}`};break;default:throw Error("Unrecognized header type tag")}}return t}}(s=eA||(eA={}))[s.boolTrue=0]="boolTrue",s[s.boolFalse=1]="boolFalse",s[s.byte=2]="byte",s[s.short=3]="short",s[s.integer=4]="integer",s[s.long=5]="long",s[s.byteArray=6]="byteArray",s[s.string=7]="string",s[s.timestamp=8]="timestamp",s[s.uuid=9]="uuid";let iy="boolean",ib="byte",iv="short",iw="integer",i_="long",iS="binary",ix="string",iE="timestamp",ik="uuid",iC=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/,iT=16;class iA{headerMarshaller;messageBuffer;isEndOfStream;constructor(e,t){this.headerMarshaller=new ig(e,t),this.messageBuffer=[],this.isEndOfStream=!1}feed(e){this.messageBuffer.push(this.decode(e))}endOfStream(){this.isEndOfStream=!0}getMessage(){let e=this.messageBuffer.pop(),t=this.isEndOfStream;return{getMessage:()=>e,isEndOfStream:()=>t}}getAvailableMessages(){let e=this.messageBuffer;this.messageBuffer=[];let t=this.isEndOfStream;return{getMessages:()=>e,isEndOfStream:()=>t}}encode({headers:e,body:t}){let n=this.headerMarshaller.format(e),r=n.byteLength+t.byteLength+16,i=new Uint8Array(r),s=new DataView(i.buffer,i.byteOffset,i.byteLength),a=new iu;return s.setUint32(0,r,!1),s.setUint32(4,n.byteLength,!1),s.setUint32(8,a.update(i.subarray(0,8)).digest(),!1),i.set(n,12),i.set(t,n.byteLength+12),s.setUint32(r-4,a.update(i.subarray(8,r-4)).digest(),!1),i}decode(e){let{headers:t,body:n}=function({byteLength:e,byteOffset:t,buffer:n}){if(e<iT)throw Error("Provided message too short to accommodate event stream message overhead");let r=new DataView(n,t,e),i=r.getUint32(0,!1);if(e!==i)throw Error("Reported message length does not match received message length");let s=r.getUint32(4,!1),a=r.getUint32(8,!1),o=r.getUint32(e-4,!1),l=new iu().update(new Uint8Array(n,t,8));if(a!==l.digest())throw Error(`The prelude checksum specified in the message (${a}) does not match the calculated CRC32 checksum (${l.digest()})`);if(l.update(new Uint8Array(n,t+8,e-12)),o!==l.digest())throw Error(`The message checksum (${l.digest()}) did not match the expected value of ${o}`);return{headers:new DataView(n,t+8+4,s),body:new Uint8Array(n,t+8+4+s,i-s-16)}}(e);return{headers:this.headerMarshaller.parse(t),body:n}}formatHeaders(e){return this.headerMarshaller.format(e)}}var iR=e.i(81111),iI=iR;class iO extends iI.Transform{priorSignature;messageSigner;eventStreamCodec;systemClockOffsetProvider;constructor(e){super({autoDestroy:!0,readableObjectMode:!0,writableObjectMode:!0,...e}),this.priorSignature=e.priorSignature,this.eventStreamCodec=e.eventStreamCodec,this.messageSigner=e.messageSigner,this.systemClockOffsetProvider=e.systemClockOffsetProvider}async _transform(e,t,n){try{var r;let t,i=new Date(Date.now()+await this.systemClockOffsetProvider()),s={":date":{type:"timestamp",value:i}},a=await this.messageSigner.sign({message:{body:e,headers:s},priorSignature:this.priorSignature},{signingDate:i});this.priorSignature=a.signature;let o=this.eventStreamCodec.encode({headers:{...s,":chunk-signature":{type:"binary",value:(r=a.signature,t=Buffer.from(r,"hex"),new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT))}},body:e});return this.push(o),n()}catch(e){n(e)}}}class iP{messageSigner;eventStreamCodec;systemClockOffsetProvider;constructor(e){this.messageSigner=e.messageSigner,this.eventStreamCodec=new iA(e.utf8Encoder,e.utf8Decoder),this.systemClockOffsetProvider=async()=>e.systemClockOffset??0}async handle(e,t,n={}){let r,i,s=t.request,{body:a,query:o}=s;if(!(a instanceof iR.Readable))throw Error("Eventstream payload must be a Readable stream.");s.body=new iR.PassThrough({objectMode:!0});let l=s.headers?.authorization?.match(/Signature=([\w]+)$/),c=l?.[1]??o?.["X-Amz-Signature"]??"";n.__staticSignature&&(c="");let u=new iO({priorSignature:c,eventStreamCodec:this.eventStreamCodec,messageSigner:await this.messageSigner(),systemClockOffsetProvider:this.systemClockOffsetProvider}),h=new Promise((e,t)=>{r=()=>e(void 0),(0,iR.pipeline)(a,u,s.body,e=>{e&&t(Error(`Pipeline error in @aws-sdk/eventstream-handler-node: ${e.message}`,{cause:e}))})});try{i=await Promise.race([e(t),h])}catch(e){throw s.body.end(),e}finally{r()}return i}}let iM=e=>new iP(e);var iD=e.i(39587),iL=e.i(97773),i$=e.i(10334),iN=e.i(44010),iU=e.i(13401);class iB{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async *asyncIterator(){for await(let e of this.options.inputStream){let t=this.options.decoder.decode(e);yield t}}}class iF{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async *asyncIterator(){for await(let e of this.options.messageStream){let t=this.options.encoder.encode(e);yield t}this.options.includeEndFrame&&(yield new Uint8Array(0))}}class ij{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async *asyncIterator(){for await(let e of this.options.messageStream){let t=await this.options.deserializer(e);void 0!==t&&(yield t)}}}class iH{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async *asyncIterator(){for await(let e of this.options.inputStream){let t=this.options.serializer(e);yield t}}}class iW{eventStreamCodec;utfEncoder;constructor({utf8Encoder:e,utf8Decoder:t}){this.eventStreamCodec=new iA(e,t),this.utfEncoder=e}deserialize(e,t){var n;let r,i,s,a,o;return new ij({messageStream:new iB({inputStream:(r=0,i=0,s=null,a=null,o=e=>{if("number"!=typeof e)throw Error("Attempted to allocate an event message where size was not a number: "+e);r=e,i=4,new DataView((s=new Uint8Array(e)).buffer).setUint32(0,e,!1)},{[Symbol.asyncIterator]:async function*(){let t=e[Symbol.asyncIterator]();for(;;){let{value:e,done:n}=await t.next();if(n){if(r)if(r===i)yield s;else throw Error("Truncated event message received.");return}let l=e.length,c=0;for(;c<l;){if(!s){let t=l-c;a||(a=new Uint8Array(4));let n=Math.min(4-i,t);if(a.set(e.slice(c,c+n),i),i+=n,c+=n,i<4)break;o(new DataView(a.buffer).getUint32(0,!1)),a=null}let t=Math.min(r-i,l-c);s.set(e.slice(c,c+t),i),i+=t,c+=t,r&&r===i&&(yield s,s=null,r=0,i=0)}}}}),decoder:this.eventStreamCodec}),deserializer:(n=this.utfEncoder,async function(e){let{value:r}=e.headers[":message-type"];if("error"===r){let t=Error(e.headers[":error-message"].value||"UnknownError");throw t.name=e.headers[":error-code"].value,t}if("exception"===r){let r=e.headers[":exception-type"].value,i=await t({[r]:e});if(i.$unknown){let t=Error(n(e.body));throw t.name=r,t}throw i[r]}if("event"===r){let n={[e.headers[":event-type"].value]:e},r=await t(n);if(r.$unknown)return;return r}throw Error(`Unrecognizable event type: ${e.headers[":event-type"].value}`)})})}serialize(e,t){return new iF({messageStream:new iH({inputStream:e,serializer:t}),encoder:this.eventStreamCodec,includeEndFrame:!0})}}var iq=e.i(88947);async function*iz(e){let t=!1,n=!1,r=[];for(e.on("error",e=>{if(t||(t=!0),e)throw e}),e.on("data",e=>{r.push(e)}),e.on("end",()=>{t=!0});!n;){let e=await new Promise(e=>setTimeout(()=>e(r.shift()),0));e&&(yield e),n=t&&0===r.length}}class iV{universalMarshaller;constructor({utf8Encoder:e,utf8Decoder:t}){this.universalMarshaller=new iW({utf8Decoder:t,utf8Encoder:e})}deserialize(e,t){let n="function"==typeof e[Symbol.asyncIterator]?e:iz(e);return this.universalMarshaller.deserialize(n,t)}serialize(e,t){return iq.Readable.from(this.universalMarshaller.serialize(e,t))}}let iK=e=>new iV(e);var iY=e.i(77524),iG=e.i(15189),iX=e.i(31875),iJ=e.i(84540),iQ=e.i(46479),iZ=e.i(63886),i0=e.i(3130);class i1{sessions=[];constructor(e){this.sessions=e??[]}poll(){if(this.sessions.length>0)return this.sessions.shift()}offerLast(e){this.sessions.push(e)}contains(e){return this.sessions.includes(e)}remove(e){this.sessions=this.sessions.filter(t=>t!==e)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}destroy(e){for(let t of this.sessions)t!==e||t.destroyed||t.destroy()}}class i2{constructor(e){if(this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw RangeError("maxConcurrency must be greater than zero.")}config;sessionCache=new Map;lease(e,t){let n=this.getUrlString(e),r=this.sessionCache.get(n);if(r){let e=r.poll();if(e&&!this.config.disableConcurrency)return e}let i=iQ.default.connect(n);this.config.maxConcurrency&&i.settings({maxConcurrentStreams:this.config.maxConcurrency},t=>{if(t)throw Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+e.destination.toString())}),i.unref();let s=()=>{i.destroy(),this.deleteSession(n,i)};i.on("goaway",s),i.on("error",s),i.on("frameError",s),i.on("close",()=>this.deleteSession(n,i)),t.requestTimeout&&i.setTimeout(t.requestTimeout,s);let a=this.sessionCache.get(n)||new i1;return a.offerLast(i),this.sessionCache.set(n,a),i}deleteSession(e,t){let n=this.sessionCache.get(e);!n||n.contains(t)&&(n.remove(t),this.sessionCache.set(e,n))}release(e,t){let n=this.getUrlString(e);this.sessionCache.get(n)?.offerLast(t)}destroy(){for(let[e,t]of this.sessionCache){for(let e of t)e.destroyed||e.destroy(),t.remove(e);this.sessionCache.delete(e)}}setMaxConcurrentStreams(e){if(e&&e<=0)throw RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=e}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}getUrlString(e){return e.destination.toString()}}var i3=e.i(88895);class i6{config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new i2({});static create(e){return"function"==typeof e?.handle?e:new i6(e)}constructor(e){this.configProvider=new Promise((t,n)=>{"function"==typeof e?e().then(e=>{t(e||{})}).catch(n):t(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:t,requestTimeout:n}={}){!this.config&&(this.config=await this.configProvider,this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams||!1),this.config.maxConcurrentStreams&&this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams));let{requestTimeout:r,disableConcurrentStreams:i}=this.config,s=n??r;return new Promise((n,r)=>{let a,o=!1,l=async e=>{await a,n(e)},c=async e=>{await a,r(e)};if(t?.aborted){o=!0,c((0,iZ.buildAbortError)(t));return}let{hostname:u,method:h,port:d,protocol:f,query:p}=e,m="";if(null!=e.username||null!=e.password){let t=e.username??"",n=e.password??"";m=`${t}:${n}@`}let g=`${f}//${m}${u}${d?`:${d}`:""}`,y={destination:new URL(g)},b=this.connectionManager.lease(y,{requestTimeout:this.config?.sessionTimeout,disableConcurrentStreams:i||!1}),v=e=>{i&&this.destroySession(b),o=!0,c(e)},w=(0,iJ.buildQueryString)(p||{}),_=e.path;w&&(_+=`?${w}`),e.fragment&&(_+=`#${e.fragment}`);let S=b.request({...e.headers,[iQ.constants.HTTP2_HEADER_PATH]:_,[iQ.constants.HTTP2_HEADER_METHOD]:h});if(b.ref(),S.on("response",e=>{let t=new iX.HttpResponse({statusCode:e[":status"]||-1,headers:(0,i0.getTransformedHeaders)(e),body:S});o=!0,l({response:t}),i&&(b.close(),this.connectionManager.deleteSession(g,b))}),s&&S.setTimeout(s,()=>{S.close();let e=Error(`Stream timed out because of no activity for ${s} ms`);e.name="TimeoutError",v(e)}),t){let e=()=>{S.close(),v((0,iZ.buildAbortError)(t))};"function"==typeof t.addEventListener?(t.addEventListener("abort",e,{once:!0}),S.once("close",()=>t.removeEventListener("abort",e))):t.onabort=e}S.on("frameError",(e,t,n)=>{v(Error(`Frame type id ${e} in stream id ${n} has failed with code ${t}.`))}),S.on("error",v),S.on("aborted",()=>{v(Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${S.rstCode}.`))}),S.on("close",()=>{b.unref(),i&&b.destroy(),o||v(Error("Unexpected error: http2 request did not get a response"))}),a=(0,i3.writeRequestBody)(S,e,s)})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then(n=>({...n,[e]:t}))}httpHandlerConfigs(){return this.config??{}}destroySession(e){e.destroyed||e.destroy()}}var i8=e.i(56884),i4=e.i(68992),i5=e.i(15557),i9=e.i(58570),i7=e.i(85512),se=e.i(92898),st=e.i(44426),sn=e.i(38604),sr=e.i(57759),si=e.i(41175),ss=e.i(49151),sa=e.i(71225),so=e.i(55103),sl=e.i(25145);e.i(79787);var sc=e.i(25923),su=e.i(46717),sh=e.i(16116),sd=e.i(35525);let sf="required",sp="argv",sm="isSet",sg="booleanEquals",sy="error",sb="endpoint",sv="tree",sw="PartitionResult",s_={[sf]:!1,type:"string"},sS={[sf]:!0,default:!1,type:"boolean"},sx={ref:"Endpoint"},sE={fn:sg,[sp]:[{ref:"UseFIPS"},!0]},sk={fn:sg,[sp]:[{ref:"UseDualStack"},!0]},sC={},sT={fn:"getAttr",[sp]:[{ref:sw},"supportsFIPS"]},sA={fn:sg,[sp]:[!0,{fn:"getAttr",[sp]:[{ref:sw},"supportsDualStack"]}]},sR=[sE],sI=[sk],sO=[{ref:"Region"}],sP={version:"1.0",parameters:{Region:s_,UseDualStack:sS,UseFIPS:sS,Endpoint:s_},rules:[{conditions:[{fn:sm,[sp]:[sx]}],rules:[{conditions:sR,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:sy},{conditions:sI,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:sy},{endpoint:{url:sx,properties:sC,headers:sC},type:sb}],type:sv},{conditions:[{fn:sm,[sp]:sO}],rules:[{conditions:[{fn:"aws.partition",[sp]:sO,assign:sw}],rules:[{conditions:[sE,sk],rules:[{conditions:[{fn:sg,[sp]:[!0,sT]},sA],rules:[{endpoint:{url:"https://transcribestreaming-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:sC,headers:sC},type:sb}],type:sv},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:sy}],type:sv},{conditions:sR,rules:[{conditions:[{fn:sg,[sp]:[sT,!0]}],rules:[{endpoint:{url:"https://transcribestreaming-fips.{Region}.{PartitionResult#dnsSuffix}",properties:sC,headers:sC},type:sb}],type:sv},{error:"FIPS is enabled but this partition does not support FIPS",type:sy}],type:sv},{conditions:sI,rules:[{conditions:[sA],rules:[{endpoint:{url:"https://transcribestreaming.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:sC,headers:sC},type:sb}],type:sv},{error:"DualStack is enabled but this partition does not support DualStack",type:sy}],type:sv},{endpoint:{url:"https://transcribestreaming.{Region}.{PartitionResult#dnsSuffix}",properties:sC,headers:sC},type:sb}],type:sv}],type:sv},{error:"Invalid Configuration: Missing Region",type:sy}]},sM=new sh.EndpointCache({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),sD=(e,t={})=>sM.get(e,()=>(0,sd.resolveEndpoint)(sP,{endpointParams:e,logger:t.logger}));su.customEndpointFunctions.aws=sc.awsEndpointFunctions;var sL=e.i(6973),s$=e.i(19483);class sN extends s$.ServiceException{constructor(e){super(e),Object.setPrototypeOf(this,sN.prototype)}}class sU extends sN{name="BadRequestException";$fault="client";Message;constructor(e){super({name:"BadRequestException",$fault:"client",...e}),Object.setPrototypeOf(this,sU.prototype),this.Message=e.Message}}class sB extends sN{name="ConflictException";$fault="client";Message;constructor(e){super({name:"ConflictException",$fault:"client",...e}),Object.setPrototypeOf(this,sB.prototype),this.Message=e.Message}}class sF extends sN{name="InternalFailureException";$fault="server";Message;constructor(e){super({name:"InternalFailureException",$fault:"server",...e}),Object.setPrototypeOf(this,sF.prototype),this.Message=e.Message}}class sj extends sN{name="LimitExceededException";$fault="client";Message;constructor(e){super({name:"LimitExceededException",$fault:"client",...e}),Object.setPrototypeOf(this,sj.prototype),this.Message=e.Message}}class sH extends sN{name="ServiceUnavailableException";$fault="server";Message;constructor(e){super({name:"ServiceUnavailableException",$fault:"server",...e}),Object.setPrototypeOf(this,sH.prototype),this.Message=e.Message}}class sW extends sN{name="ResourceNotFoundException";$fault="client";Message;constructor(e){super({name:"ResourceNotFoundException",$fault:"client",...e}),Object.setPrototypeOf(this,sW.prototype),this.Message=e.Message}}let sq="AudioChunk",sz="AudioEvent",sV="AudioStream",sK="Alternatives",sY="BeginAudioTime",sG="BeginOffsetMillis",sX="BadRequestException",sJ="Category",sQ="ChannelDefinitions",sZ="ConflictException",s0="CategoryEvent",s1="ConfigurationEvent",s2="ChannelId",s3="ContentIdentificationType",s6="ClinicalNoteGenerationResult",s8="ClinicalNoteGenerationSettings",s4="CharacterOffsets",s5="ContentRedactionType",s9="Content",s7="Confidence",ae="Entities",at="EndAudioTime",an="EnableChannelIdentification",ar="EndOffsetMillis",ai="EnablePartialResultsStabilization",as="EncryptionSettings",aa="EndTime",ao="Items",al="IssuesDetected",ac="InternalFailureException",au="IdentifyLanguage",ah="IdentifyMultipleLanguages",ad="IsPartial",af="LanguageCode",ap="LimitExceededException",am="LanguageIdentification",ag="LanguageModelName",ay="LanguageOptions",ab="Message",av="MediaEncoding",aw="MedicalScribeContext",a_="MediaSampleRateHertz",aS="NumberOfChannels",ax="Pronouns",aE="PostCallAnalyticsSettings",ak="PiiEntityTypes",aC="PreferredLanguage",aT="ParticipantRole",aA="PartialResultsStability",aR="PostStreamAnalyticsSettings",aI="Results",aO="ResourceAccessRoleArn",aP="ResultId",aM="Stable",aD="SessionId",aL="SessionResumeWindow",a$="ShowSpeakerLabel",aN="StartTime",aU="ServiceUnavailableException",aB="Score",aF="Speaker",aj="Transcript",aH="TranscriptEvent",aW="TimestampRanges",aq="TranscriptResultStream",az="Type",aV="UtteranceEvent",aK="VocabularyFilterMatch",aY="VocabularyFilterMethod",aG="VocabularyFilterName",aX="VocabularyFilterNames",aJ="VocabularyName",aQ="VocabularyNames",aZ="client",a0="error",a1="eventPayload",a2="httpError",a3="httpHeader",a6="smithy.ts.sdk.synthetic.com.amazonaws.transcribestreaming",a8="server",a4="streaming",a5="x-amzn-transcribe-content-identification-type",a9="x-amzn-transcribe-content-redaction-type",a7="x-amzn-transcribe-enable-channel-identification",oe="x-amzn-transcribe-enable-partial-results-stabilization",ot="x-amzn-transcribe-identify-language",on="x-amzn-transcribe-identify-multiple-languages",or="x-amzn-transcribe-language-code",oi="x-amzn-transcribe-language-model-name",os="x-amzn-transcribe-language-options",oa="x-amzn-transcribe-media-encoding",oo="x-amzn-transcribe-number-of-channels",ol="x-amzn-transcribe-pii-entity-types",oc="x-amzn-transcribe-preferred-language",ou="x-amzn-transcribe-partial-results-stability",oh="x-amzn-transcribe-session-id",od="x-amzn-transcribe-sample-rate",of="x-amzn-transcribe-session-resume-window",op="x-amzn-transcribe-show-speaker-label",om="x-amzn-transcribe-vocabulary-filter-method",og="x-amzn-transcribe-vocabulary-filter-name",oy="x-amzn-transcribe-vocabulary-filter-names",ob="x-amzn-transcribe-vocabulary-name",ov="x-amzn-transcribe-vocabulary-names",ow="com.amazonaws.transcribestreaming",o_=sL.TypeRegistry.for(a6);var oS=[-3,a6,"TranscribeStreamingServiceException",0,[],[]];o_.registerError(oS,sN);let ox=sL.TypeRegistry.for(ow);var oE=[-3,ow,sX,{[a0]:aZ,[a2]:400},[ab],[0]];ox.registerError(oE,sU);var ok=[-3,ow,sZ,{[a0]:aZ,[a2]:409},[ab],[0]];ox.registerError(ok,sB);var oC=[-3,ow,ac,{[a0]:a8,[a2]:500},[ab],[0]];ox.registerError(oC,sF);var oT=[-3,ow,ap,{[a0]:aZ,[a2]:429},[ab],[0]];ox.registerError(oT,sj);var oA=[-3,ow,"ResourceNotFoundException",{[a0]:aZ,[a2]:404},[ab],[0]];ox.registerError(oA,sW);var oR=[-3,ow,aU,{[a0]:a8,[a2]:503},[ab],[0]];ox.registerError(oR,sH);let oI=[o_,ox];var oO=[0,ow,ax,8,0],oP=[3,ow,"Alternative",0,[aj,ao,ae],[0,()=>ly,()=>lm]],oM=[3,ow,sz,0,[sq],[[21,{[a1]:1}]]],oD=[3,ow,"CallAnalyticsEntity",0,[sG,ar,sJ,az,s9,s7],[1,1,0,0,0,1]],oL=[3,ow,"CallAnalyticsItem",0,[sG,ar,az,s9,s7,aK,aM],[1,1,0,0,1,2,2]],o$=[3,ow,"CallAnalyticsLanguageWithScore",0,[af,aB],[0,1]],oN=[3,ow,s0,0,["MatchedCategories","MatchedDetails"],[64,()=>lT]],oU=[3,ow,"ChannelDefinition",0,[s2,aT],[1,0],2],oB=[3,ow,s4,0,["Begin","End"],[1,1]],oF=[3,ow,s6,0,["ClinicalNoteOutputLocation","TranscriptOutputLocation","Status","FailureReason"],[0,0,0,0]],oj=[3,ow,s8,0,["OutputBucketName","NoteTemplate"],[0,0],1],oH=[3,ow,s1,0,[sQ,aE],[()=>lp,()=>ln]],oW=[3,ow,"Entity",0,[aN,aa,sJ,az,s9,s7],[1,1,0,0,0,1]],oq=[3,ow,"IssueDetected",0,[s4],[()=>oB]],oz=[3,ow,"Item",0,[aN,aa,az,s9,aK,aF,s7,aM],[1,1,0,0,2,0,1,2]],oV=[3,ow,"LanguageWithScore",0,[af,aB],[0,1]],oK=[3,ow,"MedicalAlternative",0,[aj,ao,ae],[0,()=>l_,()=>lw]],oY=[3,ow,"MedicalEntity",0,[aN,aa,sJ,s9,s7],[1,1,0,0,1]],oG=[3,ow,"MedicalItem",0,[aN,aa,az,s9,s7,aF],[1,1,0,0,1,0]],oX=[3,ow,"MedicalResult",0,[aP,aN,aa,ad,sK,s2],[0,1,1,2,()=>lv,0]],oJ=[3,ow,"MedicalScribeAudioEvent",0,[sq],[[21,{[a1]:1}]],1],oQ=[3,ow,"MedicalScribeChannelDefinition",0,[s2,aT],[1,0],2],oZ=[3,ow,"MedicalScribeConfigurationEvent",0,[aO,aR,aJ,aG,aY,sQ,as,aw],[0,()=>o6,0,0,0,()=>lx,()=>o1,[()=>o0,0]],2],o0=[3,ow,aw,0,["PatientContext"],[[()=>o2,0]]],o1=[3,ow,"MedicalScribeEncryptionSettings",0,["KmsKeyId","KmsEncryptionContext"],[0,128],1],o2=[3,ow,"MedicalScribePatientContext",0,[ax],[[()=>oO,0]]],o3=[3,ow,"MedicalScribePostStreamAnalyticsResult",0,[s6],[()=>oF]],o6=[3,ow,"MedicalScribePostStreamAnalyticsSettings",0,[s8],[()=>oj],1],o8=[3,ow,"MedicalScribeSessionControlEvent",0,[az],[0],1],o4=[3,ow,"MedicalScribeTranscriptEvent",0,["TranscriptSegment"],[()=>o9]],o5=[3,ow,"MedicalScribeTranscriptItem",0,[sY,at,az,s7,s9,aK],[1,1,0,1,0,2]],o9=[3,ow,"MedicalScribeTranscriptSegment",0,["SegmentId",sY,at,s9,ao,ad,s2],[0,1,1,0,()=>lE,2,0]],o7=[3,ow,"MedicalTranscript",0,[aI],[()=>lS]],le=[3,ow,"MedicalTranscriptEvent",0,[aj],[()=>o7]],lt=[3,ow,"PointsOfInterest",0,[aW],[()=>lC]],ln=[3,ow,aE,0,["OutputLocation","DataAccessRoleArn","ContentRedactionOutput","OutputEncryptionKMSKeyId"],[0,0,0,0],2],lr=[3,ow,"Result",0,[aP,aN,aa,ad,sK,s2,af,am],[0,1,1,2,()=>lu,0,0,()=>lb]],li=[3,ow,"StartStreamTranscriptionRequest",0,[a_,av,sV,af,aJ,aD,aG,aY,a$,an,aS,ai,aA,s3,s5,ak,ag,au,ay,aC,ah,aQ,aX,aL],[[1,{[a3]:od}],[0,{[a3]:oa}],[()=>lA,16],[0,{[a3]:or}],[0,{[a3]:ob}],[0,{[a3]:oh}],[0,{[a3]:og}],[0,{[a3]:om}],[2,{[a3]:op}],[2,{[a3]:a7}],[1,{[a3]:oo}],[2,{[a3]:oe}],[0,{[a3]:ou}],[0,{[a3]:a5}],[0,{[a3]:a9}],[0,{[a3]:ol}],[0,{[a3]:oi}],[2,{[a3]:ot}],[0,{[a3]:os}],[0,{[a3]:oc}],[2,{[a3]:on}],[0,{[a3]:ov}],[0,{[a3]:oy}],[1,{[a3]:of}]],3],ls=[3,ow,"StartStreamTranscriptionResponse",0,["RequestId",af,a_,av,aJ,aD,aq,aG,aY,a$,an,aS,ai,aA,s3,s5,ak,ag,au,ay,aC,ah,aQ,aX,aL],[[0,{[a3]:"x-amzn-request-id"}],[0,{[a3]:or}],[1,{[a3]:od}],[0,{[a3]:oa}],[0,{[a3]:ob}],[0,{[a3]:oh}],[()=>lR,16],[0,{[a3]:og}],[0,{[a3]:om}],[2,{[a3]:op}],[2,{[a3]:a7}],[1,{[a3]:oo}],[2,{[a3]:oe}],[0,{[a3]:ou}],[0,{[a3]:a5}],[0,{[a3]:a9}],[0,{[a3]:ol}],[0,{[a3]:oi}],[2,{[a3]:ot}],[0,{[a3]:os}],[0,{[a3]:oc}],[2,{[a3]:on}],[0,{[a3]:ov}],[0,{[a3]:oy}],[1,{[a3]:of}]]],la=[3,ow,"TimestampRange",0,[sG,ar],[1,1]],lo=[3,ow,aj,0,[aI],[()=>lk]],ll=[3,ow,aH,0,[aj],[()=>lo]],lc=[3,ow,aV,0,["UtteranceId",ad,aT,sG,ar,aj,ao,ae,"Sentiment",al,af,am],[0,2,0,1,1,0,()=>ld,()=>lh,0,()=>lg,0,()=>lf]],lu=[1,ow,"AlternativeList",0,()=>oP],lh=[1,ow,"CallAnalyticsEntityList",0,()=>oD],ld=[1,ow,"CallAnalyticsItemList",0,()=>oL],lf=[1,ow,"CallAnalyticsLanguageIdentification",0,()=>o$],lp=[1,ow,sQ,0,()=>oU],lm=[1,ow,"EntityList",0,()=>oW],lg=[1,ow,al,0,()=>oq],ly=[1,ow,"ItemList",0,()=>oz],lb=[1,ow,am,0,()=>oV],lv=[1,ow,"MedicalAlternativeList",0,()=>oK],lw=[1,ow,"MedicalEntityList",0,()=>oY],l_=[1,ow,"MedicalItemList",0,()=>oG],lS=[1,ow,"MedicalResultList",0,()=>oX],lx=[1,ow,"MedicalScribeChannelDefinitions",0,()=>oQ],lE=[1,ow,"MedicalScribeTranscriptItemList",0,()=>o5],lk=[1,ow,"ResultList",0,()=>lr],lC=[1,ow,aW,0,()=>la],lT=[2,ow,"MatchedCategoryDetails",0,0,()=>lt],lA=[4,ow,sV,{[a4]:1},[sz,s1],[[()=>oM,0],()=>oH]],lR=[4,ow,aq,{[a4]:1},[aH,sX,ap,ac,sZ,aU],[()=>ll,[()=>oE,0],[()=>oT,0],[()=>oC,0],[()=>ok,0],[()=>oR,0]]],lI=[9,ow,"StartStreamTranscription",{http:["POST","/stream-transcription",200]},()=>li,()=>ls],lO=e.i(74376),lP=e.i(32519),lM=e.i(70917);class lD extends rJ.Client{config;constructor(...[e]){const t=(e=>{(0,i4.emitWarningIfUnsupportedVersion)(process.version);let t=(0,i7.resolveDefaultsModeConfig)(e),n=()=>t().then(i5.loadConfigsForDefaultMode),r={apiVersion:"2017-10-26",base64Decoder:e?.base64Decoder??ss.fromBase64,base64Encoder:e?.base64Encoder??sa.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??sD,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??r2,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:e=>e.getIdentityProvider("aws.auth#sigv4"),signer:new st.AwsSdkSigV4Signer}],logger:e?.logger??new sr.NoOpLogger,protocol:e?.protocol??sn.AwsRestJsonProtocol,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.transcribestreaming",errorTypeRegistries:oI,version:"2017-10-26",serviceTarget:"Transcribe"},serviceId:e?.serviceId??"Transcribe Streaming",urlParser:e?.urlParser??si.parseUrl,utf8Decoder:e?.utf8Decoder??so.fromUtf8,utf8Encoder:e?.utf8Encoder??sl.toUtf8};(0,r8.emitWarningIfUnsupportedVersion)(process.version);let i={profile:e?.profile,logger:r.logger};return{...r,...e,runtime:"node",defaultsMode:t,authSchemePreference:e?.authSchemePreference??(0,iG.loadConfig)(r4.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS,i),bodyLengthChecker:e?.bodyLengthChecker??i9.calculateBodyLength,credentialDefaultProvider:e?.credentialDefaultProvider??is,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,iD.createDefaultUserAgentProvider)({serviceId:r.serviceId,clientVersion:r6.default.version}),eventStreamPayloadHandlerProvider:e?.eventStreamPayloadHandlerProvider??iM,eventStreamSerdeProvider:e?.eventStreamSerdeProvider??iK,maxAttempts:e?.maxAttempts??(0,iG.loadConfig)(rX.NODE_MAX_ATTEMPT_CONFIG_OPTIONS,e),region:e?.region??(0,iG.loadConfig)(i$.NODE_REGION_CONFIG_OPTIONS,{...i$.NODE_REGION_CONFIG_FILE_OPTIONS,...i}),requestHandler:i6.create(e?.requestHandler??(async()=>({...await n(),disableConcurrentStreams:!0}))),retryMode:e?.retryMode??(0,iG.loadConfig)({...rX.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await n()).retryMode||se.DEFAULT_RETRY_MODE},e),sha256:e?.sha256??iY.Hash.bind(null,"sha256"),streamCollector:e?.streamCollector??i8.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,iG.loadConfig)(iN.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS,i),useFipsEndpoint:e?.useFipsEndpoint??(0,iG.loadConfig)(iU.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,i),userAgentAppId:e?.userAgentAppId??(0,iG.loadConfig)(iL.NODE_APP_ID_CONFIG_OPTIONS,i)}})(e||{});super(t),this.initConfig=t;const n=(e=>Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"transcribe"}))(t),r=(0,rB.resolveUserAgentConfig)(n),i=(0,rX.resolveRetryConfig)(r),s=(0,rH.resolveRegionConfig)(i),a=(0,rL.resolveHostHeaderConfig)(s),o=((e,t)=>{let n,r,i,s=Object.assign((0,lO.getAwsRegionExtensionConfiguration)(e),(0,lM.getDefaultExtensionConfiguration)(e),(0,lP.getHttpHandlerExtensionConfiguration)(e),(n=e.httpAuthSchemes,r=e.httpAuthSchemeProvider,i=e.credentials,{setHttpAuthScheme(e){let t=n.findIndex(t=>t.schemeId===e.schemeId);-1===t?n.push(e):n.splice(t,1,e)},httpAuthSchemes:()=>n,setHttpAuthSchemeProvider(e){r=e},httpAuthSchemeProvider:()=>r,setCredentials(e){i=e},credentials:()=>i}));return t.forEach(e=>e.configure(s)),Object.assign(e,(0,lO.resolveAwsRegionExtensionConfiguration)(s),(0,lM.resolveDefaultRuntimeConfig)(s),(0,lP.resolveHttpHandlerRuntimeConfig)(s),{httpAuthSchemes:s.httpAuthSchemes(),httpAuthSchemeProvider:s.httpAuthSchemeProvider(),credentials:s.credentials()})})((e=>{let{signer:t}=e;return Object.assign(e,{signer:async e=>{let n=await t(e);if(n)return new rj({signer:n});throw Error("Expected WebsocketSignatureV4 signer, please check the client constructor.")}})})(function(e){let t=e.signer,n=e.signer,r=Object.assign(e,{eventSigner:t,messageSigner:n}),i=r.eventStreamPayloadHandlerProvider(r);return Object.assign(r,{eventStreamPayloadHandler:i})}((e=>Object.assign((0,rQ.resolveAwsSdkSigV4Config)(e),{authSchemePreference:(0,r0.normalizeProvider)(e.authSchemePreference??[])}))((e=>Object.assign(e,{eventStreamMarshaller:e.eventStreamSerdeProvider(e)}))((0,rY.resolveEndpointConfig)(a))))),e?.extensions||[]);this.config=o,this.middlewareStack.use((0,rV.getSchemaSerdePlugin)(this.config)),this.middlewareStack.use((0,rU.getUserAgentPlugin)(this.config)),this.middlewareStack.use((0,rG.getRetryPlugin)(this.config)),this.middlewareStack.use((0,rK.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,rL.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,r$.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,rN.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,rq.getHttpAuthSchemeEndpointRuleSetPlugin)(this.config,{httpAuthSchemeParametersProvider:r1,identityProviderConfigProvider:async e=>new rW.DefaultIdentityProviderConfig({"aws.auth#sigv4":e.credentials})})),this.middlewareStack.use((0,rz.getHttpSigningPlugin)(this.config))}destroy(){super.destroy()}}let lL={tags:["EVENT_STREAM","SIGNATURE","HANDLE"],name:"eventStreamHandlingMiddleware",relation:"after",toMiddleware:"awsAuthMiddleware",override:!0},l$=e=>async t=>{let{request:n}=t;return rF.HttpRequest.isInstance(n)?(n.headers={...n.headers,"content-type":"application/vnd.amazon.eventstream","x-amz-content-sha256":"STREAMING-AWS4-HMAC-SHA256-EVENTS"},e({...t,request:n})):e(t)},lN={step:"build",tags:["EVENT_STREAM","HEADER","CONTENT_TYPE","CONTENT_SHA256"],name:"eventStreamHeaderMiddleware",override:!0},lU=e=>({applyToStack:t=>{t.addRelativeTo((t,n)=>async r=>{let{request:i}=r;return rF.HttpRequest.isInstance(i)?e.eventStreamPayloadHandler.handle(t,r,n):t(r)},lL),t.add(l$,lN)}});var lB=e.i(878);let lF={step:"initialize",name:"injectResponseValuesMiddleware",tags:["WEBSOCKET","EVENT_STREAM"],override:!0},lj={name:"websocketPortMiddleware",tags:["WEBSOCKET","EVENT_STREAM","PORT"],relation:"after",toMiddleware:"eventStreamHeaderMiddleware",override:!0},lH=e=>({applyToStack:t=>{t.addRelativeTo(t=>n=>{let{request:r}=n;return rF.HttpRequest.isInstance(r)&&e.requestHandler.metadata?.handlerProtocol?.includes("websocket")&&(r.hostname=`${r.hostname}:8443`,r.headers.host=r.hostname),t(n)},lj),t.add(t=>async n=>{let r;void 0===n.input.SessionId&&(r=e,r.requestHandler.metadata?.handlerProtocol?.includes("websocket"))&&(n.input.SessionId=(0,lB.v4)());let i={...n.input},s=await t(n),a=s.output;for(let e of Object.keys(a))void 0===a[e]&&i[e]&&(a[e]=i[e]);return s},lF)}}),lW={name:"websocketEndpointMiddleware",tags:["WEBSOCKET","EVENT_STREAM"],relation:"after",toMiddleware:"eventStreamHeaderMiddleware",override:!0},lq={step:"initialize",name:"injectSessionIdMiddleware",tags:["WEBSOCKET","EVENT_STREAM"],override:!0},lz=(e,t)=>({applyToStack:n=>{n.addRelativeTo(n=>r=>{let{request:i}=r;if(rF.HttpRequest.isInstance(i)&&e.requestHandler.metadata?.handlerProtocol?.toLowerCase().includes("websocket")){i.protocol="wss:",i.method="GET",i.path=`${i.path}-websocket`;let{headers:e}=i;for(let n of(delete e["content-type"],delete e["x-amz-content-sha256"],Object.keys(e)))if(0===n.indexOf(t.headerPrefix)){let r=n.replace(t.headerPrefix,"");i.query[r]=e[n]}e["x-amz-user-agent"]&&(i.query["user-agent"]=e["x-amz-user-agent"]),i.headers={host:e.host??i.hostname}}return n(r)},lW),n.add(e=>async t=>{let n={...t.input},r=await e(t),i=r.output;return n.SessionId&&null==i.SessionId&&(i.SessionId=n.SessionId),r},lq)}});var lV=e.i(55038),lK=e.i(63413);class lY extends lK.Command.classBuilder().ep(r3).m(function(e,t,n,r){return[(0,lV.getEndpointPlugin)(n,e.getEndpointParameterInstructions()),lU(n),lz(n,{headerPrefix:"x-amzn-transcribe-"}),lH(n)]}).s("Transcribe","StartStreamTranscription",{eventStream:{input:!0,output:!0}}).n("TranscribeStreamingClient","StartStreamTranscriptionCommand").sc(lI).build(){}let{Decoder:lG}=e.r(63403),lX=new Uint32Array(256);for(let e=0;e<256;e++){let t=e<<24;for(let e=0;e<8;e++)t=(0x80000000&t?t<<1^0x4c11db7:t<<1)>>>0;lX[e]=t}function lJ(e,t,n,r,i){let s=[];for(let e of i){let t=e.length;for(;t>=255;)s.push(255),t-=255;s.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=27+s.length,l=Buffer.alloc(o+a);l.write("OggS",0),l[4]=0,l[5]=r,l.writeBigInt64LE(n,6),l.writeUInt32LE(e,14),l.writeUInt32LE(t,18),l.writeUInt32LE(0,22),l[26]=s.length;for(let e=0;e<s.length;e++)l[27+e]=s[e];let c=o;for(let e of i)Buffer.from(e).copy(l,c),c+=e.length;let u=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<8^lX[(t>>>24^e[n])&255])>>>0;return t}(l);return l.writeUInt32LE(u,22),l}let lQ=null,lZ=null,l0=!1,l1={};async function l2(){if(l0)return l1;l0=!0;try{let e=rP.default.join((0,rD.getSlycodeRoot)(),".env");for(let t of(await rO.promises.readFile(e,"utf-8")).split("\n")){let e=t.match(/^([A-Z_]+)=(.+)$/);e&&(l1[e[1]]=e[2].trim(),new Set(["BRIDGE_URL","BRIDGE_PORT","WEB_PORT","MESSAGING_SERVICE_PORT"]).has(e[1])||process.env[e[1]]||(process.env[e[1]]=l1[e[1]]))}}catch{}return l1}async function l3(){if(!lQ){let e=await l2(),t=process.env.OPENAI_API_KEY||e.OPENAI_API_KEY;if(!t)throw Error("OPENAI_API_KEY not configured");lQ=new rI({apiKey:t})}return lQ}function l6(e,t,n){return new Promise((r,i)=>{(0,rM.execFile)(e,t,{...n,windowsHide:!0},(e,t,n)=>{e?i(Error(`${e.message}
17
+ ${n}`)):r("string"==typeof t?t:String(t))})})}async function l8(e,t,n,r){let i=process.env.TMPDIR||"/tmp",s=rP.default.join(i,`whisper_${Date.now()}.${t}`),a=s.replace(/\.[^.]+$/,".wav");try{return await rO.promises.writeFile(s,e),await l6("ffmpeg",["-i",s,"-ar","16000","-ac","1","-y",a],{timeout:3e4}),(await l6(n,["-m",r,"-f",a,"--no-timestamps","--output-txt"],{timeout:12e4,encoding:"utf-8"})).trim()}finally{await rO.promises.unlink(s).catch(()=>{}),await rO.promises.unlink(a).catch(()=>{})}}async function l4(e,t,n,r){var i;let s,a,o,l=(i=n||void 0,lZ||(lZ=new lD(i?{region:i}:{})),lZ),c=null;if("ogg"===t||"oga"===t)s=e,a="ogg-opus",o=48e3;else if("webm"===t)s=function(e){let{opusHead:t,codecDelay:n,packets:r}=function(e){let t=new lG,n=null,r=0,i=1,s=[],a=!1,o=0,l="",c=[];for(let[u,h]of(t.on("data",e=>c.push(e)),t.write(e),t.end(),c)){let e=h.name;if("start"===u&&"TrackEntry"===e&&(a=!0,o=0,l=""),"end"===u&&"TrackEntry"===e&&("A_OPUS"===l&&o>0&&(i=o),a=!1),"tag"===u&&a&&("TrackNumber"===e&&(o=h.value),"CodecID"===e&&(l=h.value),"CodecPrivate"===e&&(n=Buffer.from(h.data)),"CodecDelay"===e&&(r=h.value)),"tag"===u&&"SimpleBlock"===e){let e=h.track,t=h.payload;e===i&&t&&t.length>0&&s.push(Uint8Array.from(t))}}if(!n)throw Error("No Opus CodecPrivate (OpusHead) found in WebM");if(0===s.length)throw Error("No Opus audio packets found in WebM");return{opusHead:n,codecDelay:r,packets:s}}(e),i=Math.floor(0xffffffff*Math.random()),s=0,a=t.readUInt16LE(10),o=n>0?Math.round(n/1e9*48e3):a,l=Buffer.from(t);o!==a&&l.writeUInt16LE(o,10);let c=[];c.push(lJ(i,s++,BigInt(0),2,[l]));let u=Buffer.from("remux"),h=Buffer.alloc(12+u.length+4);h.write("OpusTags",0),h.writeUInt32LE(u.length,8),u.copy(h,12),h.writeUInt32LE(0,12+u.length),c.push(lJ(i,s++,BigInt(0),0,[h]));let d=BigInt(o);for(let e=0;e<r.length;e++){d+=BigInt(function(e){let t,n;if(e.length<1)return 960;let r=e[0],i=r>>3&31;switch(t=i<=11?[480,960,1920,2880][i%4]:i<=15?[480,960][(i-12)%2]:[120,240,480,960][(i-16)%4],3&r){case 0:default:n=1;break;case 1:case 2:n=2;break;case 3:n=e.length>=2?63&e[1]:1}return t*n}(r[e]));let t=e===r.length-1;c.push(lJ(i,s++,d,4*!!t,[r[e]]))}return Buffer.concat(c)}(e),a="ogg-opus",o=48e3;else{let n=process.env.TMPDIR||"/tmp",r=rP.default.join(n,`transcribe_${Date.now()}.${t}`);c=r.replace(/\.[^.]+$/,".pcm");try{await rO.promises.writeFile(r,e),await l6("ffmpeg",["-i",r,"-ar","16000","-ac","1","-f","s16le","-y",c],{timeout:3e4}),s=await rO.promises.readFile(c),await rO.promises.unlink(r).catch(()=>{})}catch(e){throw await rO.promises.unlink(r).catch(()=>{}),Error(`ffmpeg conversion to PCM failed: ${e.message}`)}a="pcm",o=16e3}async function*u(){for(let e=0;e<s.length;e+=4096)yield{AudioEvent:{AudioChunk:s.subarray(e,e+4096)}}}try{let e=await l.send(new lY({LanguageCode:r,MediaEncoding:a,MediaSampleRateHertz:o,AudioStream:u()})),t=[];if(e.TranscriptResultStream){for await(let n of e.TranscriptResultStream)if(n.TranscriptEvent?.Transcript?.Results)for(let e of n.TranscriptEvent.Transcript.Results)!e.IsPartial&&e.Alternatives?.[0]?.Transcript&&t.push(e.Alternatives[0].Transcript)}return t.join(" ").trim()}finally{c&&await rO.promises.unlink(c).catch(()=>{})}}async function l5(e){try{let t,n=(await e.formData()).get("audio");if(!n||!(n instanceof Blob))return eV.NextResponse.json({error:'Missing "audio" file in form data'},{status:400});let r=Buffer.from(await n.arrayBuffer()),i=n.type.includes("mp4")?"mp4":n.type.includes("ogg")?"ogg":"webm",s=await l2(),a=process.env.STT_BACKEND||s.STT_BACKEND||"openai";if("local"===a){let e=process.env.WHISPER_CLI_PATH||s.WHISPER_CLI_PATH,t=process.env.WHISPER_MODEL_PATH||s.WHISPER_MODEL_PATH;if(!e||!t)return eV.NextResponse.json({error:"Local STT not configured: set WHISPER_CLI_PATH and WHISPER_MODEL_PATH"},{status:401});let n=await l8(r,i,e,t);return eV.NextResponse.json({text:n})}if("aws-transcribe"===a){let e=process.env.AWS_TRANSCRIBE_REGION||s.AWS_TRANSCRIBE_REGION||"",t=process.env.AWS_TRANSCRIBE_LANGUAGE||s.AWS_TRANSCRIBE_LANGUAGE||"en-AU",n=await l4(r,i,e,t);return eV.NextResponse.json({text:n})}try{t=await l3()}catch{return eV.NextResponse.json({error:"OPENAI_API_KEY not configured"},{status:401})}let o=await t7(r,`recording.${i}`,{type:n.type}),l=await t.audio.transcriptions.create({file:o,model:"whisper-1"});return eV.NextResponse.json({text:l.text})}catch(t){let e=t.message||"Transcription failed";return eV.NextResponse.json({error:e},{status:502})}}e.s(["POST",()=>l5],14779);var l9=e.i(14779);let l7=new eR.AppRouteRouteModule({definition:{kind:eI.RouteKind.APP_ROUTE,page:"/api/transcribe/route",pathname:"/api/transcribe",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/transcribe/route.ts",nextConfigOutput:"standalone",userland:l9}),{workAsyncStorage:ce,workUnitAsyncStorage:ct,serverHooks:cn}=l7;function cr(){return(0,eO.patchFetch)({workAsyncStorage:ce,workUnitAsyncStorage:ct})}async function ci(e,t,n){l7.isDev&&(0,eP.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let r="/api/transcribe/route";r=r.replace(/\/index$/,"")||"/";let i=await l7.prepare(e,t,{srcPage:r,multiZoneDraftMode:!1});if(!i)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:s,params:a,nextConfig:o,parsedUrl:l,isDraftMode:c,prerenderManifest:u,routerServerContext:h,isOnDemandRevalidate:d,revalidateOnlyGenerated:f,resolvedPathname:p,clientReferenceManifest:m,serverActionsManifest:g}=i,y=(0,eL.normalizeAppPath)(r),b=!!(u.dynamicRoutes[y]||u.routes[p]),v=async()=>((null==h?void 0:h.render404)?await h.render404(e,t,l,!1):t.end("This page could not be found"),null);if(b&&!c){let e=!!u.routes[p],t=u.dynamicRoutes[y];if(t&&!1===t.fallback&&!e){if(o.experimental.adapterPath)return await v();throw new eq.NoFallbackError}}let w=null;!b||l7.isDev||c||(w="/index"===(w=p)?"/":w);let _=!0===l7.isDev||!b,S=b&&!_;g&&m&&(0,eD.setManifestsSingleton)({page:r,clientReferenceManifest:m,serverActionsManifest:g});let x=e.method||"GET",E=(0,eM.getTracer)(),k=E.getActiveScopeSpan(),C={params:a,prerenderManifest:u,renderOpts:{experimental:{authInterrupts:!!o.experimental.authInterrupts},cacheComponents:!!o.cacheComponents,supportsDynamicResponse:_,incrementalCache:(0,eP.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:o.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,n,r,i)=>l7.onRequestError(e,t,r,i,h)},sharedContext:{buildId:s}},T=new e$.NodeNextRequest(e),A=new e$.NodeNextResponse(t),R=eN.NextRequestAdapter.fromNodeNextRequest(T,(0,eN.signalFromNodeResponse)(t));try{let i=async e=>l7.handle(R,C).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let n=E.getRootSpanAttributes();if(!n)return;if(n.get("next.span_type")!==eU.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${n.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let i=n.get("next.route");if(i){let t=`${x} ${i}`;e.setAttributes({"next.route":i,"http.route":i,"next.span_name":t}),e.updateName(t)}else e.updateName(`${x} ${r}`)}),s=!!(0,eP.getRequestMeta)(e,"minimalMode"),a=async a=>{var l,p;let m=async({previousCacheEntry:o})=>{try{if(!s&&d&&f&&!o)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let r=await i(a);e.fetchMetrics=C.renderOpts.fetchMetrics;let l=C.renderOpts.pendingWaitUntil;l&&n.waitUntil&&(n.waitUntil(l),l=void 0);let c=C.renderOpts.collectedTags;if(!b)return await (0,eF.sendResponse)(T,A,r,C.renderOpts.pendingWaitUntil),null;{let e=await r.blob(),t=(0,ej.toNodeOutgoingHttpHeaders)(r.headers);c&&(t[eW.NEXT_CACHE_TAGS_HEADER]=c),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let n=void 0!==C.renderOpts.collectedRevalidate&&!(C.renderOpts.collectedRevalidate>=eW.INFINITE_CACHE)&&C.renderOpts.collectedRevalidate,i=void 0===C.renderOpts.collectedExpire||C.renderOpts.collectedExpire>=eW.INFINITE_CACHE?void 0:C.renderOpts.collectedExpire;return{value:{kind:ez.CachedRouteKind.APP_ROUTE,status:r.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:n,expire:i}}}}catch(t){throw(null==o?void 0:o.isStale)&&await l7.onRequestError(e,t,{routerKind:"App Router",routePath:r,routeType:"route",revalidateReason:(0,eB.getRevalidateReason)({isStaticGeneration:S,isOnDemandRevalidate:d})},!1,h),t}},g=await l7.handleResponse({req:e,nextConfig:o,cacheKey:w,routeKind:eI.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:u,isRoutePPREnabled:!1,isOnDemandRevalidate:d,revalidateOnlyGenerated:f,responseGenerator:m,waitUntil:n.waitUntil,isMinimalMode:s});if(!b)return null;if((null==g||null==(l=g.value)?void 0:l.kind)!==ez.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==g||null==(p=g.value)?void 0:p.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});s||t.setHeader("x-nextjs-cache",d?"REVALIDATED":g.isMiss?"MISS":g.isStale?"STALE":"HIT"),c&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let y=(0,ej.fromNodeOutgoingHttpHeaders)(g.value.headers);return s&&b||y.delete(eW.NEXT_CACHE_TAGS_HEADER),!g.cacheControl||t.getHeader("Cache-Control")||y.get("Cache-Control")||y.set("Cache-Control",(0,eH.getCacheControlHeader)(g.cacheControl)),await (0,eF.sendResponse)(T,A,new Response(g.value.body,{headers:y,status:g.value.status||200})),null};k?await a(k):await E.withPropagatedContext(e.headers,()=>E.trace(eU.BaseServerSpan.handleRequest,{spanName:`${x} ${r}`,kind:eM.SpanKind.SERVER,attributes:{"http.method":x,"http.target":e.url}},a))}catch(t){if(t instanceof eq.NoFallbackError||await l7.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,eB.getRevalidateReason)({isStaticGeneration:S,isOnDemandRevalidate:d})},!1,h),b)throw t;return await (0,eF.sendResponse)(T,A,new Response(null,{status:500})),null}}e.s(["handler",()=>ci,"patchFetch",()=>cr,"routeModule",()=>l7,"serverHooks",()=>cn,"workAsyncStorage",()=>ce,"workUnitAsyncStorage",()=>ct],99567)}];
18
+
19
+ //# sourceMappingURL=%5Broot-of-the-server%5D__a43db24d._.js.map