scribe-widget 1.0.9 → 1.0.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.
package/dist/scribe-widget.es.js
CHANGED
|
@@ -35497,7 +35497,7 @@ class ChunkedRecorder {
|
|
|
35497
35497
|
if (!e.upload_url)
|
|
35498
35498
|
throw new Error("Upload URL is required for chunked recording");
|
|
35499
35499
|
const c = {};
|
|
35500
|
-
s != null && s.accessToken && (c.Authorization = `Bearer ${s.accessToken}`), this.fileManager.setSessionInfo({
|
|
35500
|
+
console.log(s, "initialize - WIDGET"), s != null && s.accessToken && (c.Authorization = `Bearer ${s.accessToken}`), this.fileManager.setSessionInfo({
|
|
35501
35501
|
sessionId: e.session_id,
|
|
35502
35502
|
uploadUrl: e.upload_url,
|
|
35503
35503
|
uploadHeaders: c
|
|
@@ -35904,7 +35904,7 @@ function useScribeSession(i) {
|
|
|
35904
35904
|
}
|
|
35905
35905
|
try {
|
|
35906
35906
|
s("recording"), await et.current.startRecording({
|
|
35907
|
-
templates:
|
|
35907
|
+
templates: ["eka_emr_template"],
|
|
35908
35908
|
languageHint: i.languageHint
|
|
35909
35909
|
}), a.current = Date.now(), o.current = 0, h(0), g(), d("Recording started");
|
|
35910
35910
|
} catch (dt) {
|
|
@@ -1848,4 +1848,4 @@ ${j}
|
|
|
1848
1848
|
`);const nt=this.glContext.compileShader(j,this.glContext.gl.FRAGMENT_SHADER),et=this.glContext.createProgram(this.vertexShader,nt);return this.glContext.deleteShader(nt),et}bindOutput(j){const nt=j.width,et=j.height;h.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${nt}/${et}, shape=${j.shape}, type=${j.tensor.type}`),this.glContext.attachFramebuffer(j.texture,nt,et)}bindAttributes(j){const nt=j.position,et=j.textureCoord;this.glContext.setVertexAttributes(nt,et),this.attributesBound=!0}bindUniforms(j,nt,et){var b;const a=this.glContext.gl;let o=0;for(const{name:d,type:g,location:rt,arrayLength:st}of j){const tt=(b=nt.find(ot=>ot.name===d))===null||b===void 0?void 0:b.data;if(g!=="sampler2D"&&!tt)throw new Error(`variable '${d}' does not have data defined in program info`);switch(g){case"sampler2D":this.bindTexture(et[o],rt,o),o++;break;case"float":st?a.uniform1fv(rt,tt):a.uniform1f(rt,tt);break;case"int":st?a.uniform1iv(rt,tt):a.uniform1i(rt,tt);break;default:throw new Error(`Uniform not implemented: ${g}`)}}}bindTexture(j,nt,et){this.glContext.bindTextureToUniform(j.texture,et,nt)}getAttribLocations(j){return{position:this.getAttribLocation(j,"position"),textureCoord:this.getAttribLocation(j,"textureCoord")}}getUniformLocations(j,nt,et){const b=[];if(nt)for(const a of nt)b.push({name:a,type:"sampler2D",location:this.getUniformLocation(j,a)});if(et)for(const a of et)b.push(Object.assign(Object.assign({},a),{location:this.getUniformLocation(j,a.name)}));return b}getUniformLocation(j,nt){const et=this.glContext.gl.getUniformLocation(j,nt);if(et===null)throw new Error(`Uniform ${nt} not found.`);return et}getAttribLocation(j,nt){return this.glContext.gl.getAttribLocation(j,nt)}}},6416:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLSessionHandler=void 0;const c=s(6231),h=s(1047),$=s(8316),_=s(1640),j=s(1958),nt=s(7859),et=s(5702);e.WebGLSessionHandler=class{constructor(b,a){this.backend=b,this.context=a,this.layoutStrategy=new nt.PreferLogicalStrategy(b.glContext.maxTextureSize),this.programManager=new j.ProgramManager(this.context.profiler,b.glContext,this.layoutStrategy),this.textureManager=new et.TextureManager(b.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:b.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=b.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new $.WebGLInferenceHandler(this)}onGraphInitialized(b){const a=b.getValues().filter(o=>o.from===-1&&o.tensor).map(o=>o.tensor.dataId);this.initializers=new Set(a)}isInitializer(b){return!!this.initializers&&this.initializers.has(b)}addInitializer(b){this.initializers.add(b)}getTextureData(b,a){return a?this.packedTextureDataCache.get(b):this.unpackedTextureDataCache.get(b)}setTextureData(b,a,o=!1){c.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),o?this.packedTextureDataCache.set(b,a):this.unpackedTextureDataCache.set(b,a)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(b=>this.textureManager.releaseTexture(b,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(b=>this.textureManager.releaseTexture(b,!0)),this.unpackedTextureDataCache=new Map}resolve(b,a,o){const d=(0,h.resolveOperator)(b,a,_.WEBGL_OP_RESOLVE_RULES);return{impl:d.opImpl,context:d.opInit?d.opInit(b,o):b}}}},7769:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Uint8DataEncoder=e.RGBAFloatDataEncoder=e.RedFloat32DataEncoder=void 0;const c=s(6231);e.RedFloat32DataEncoder=class{constructor(h,$=1){if($===1)this.internalFormat=h.R32F,this.format=h.RED,this.textureType=h.FLOAT,this.channelSize=$;else{if($!==4)throw new Error(`Invalid number of channels: ${$}`);this.internalFormat=h.RGBA32F,this.format=h.RGBA,this.textureType=h.FLOAT,this.channelSize=$}}encode(h,$){let _,j;return h.constructor!==Float32Array&&(c.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),j=new Float32Array(h)),$*this.channelSize>h.length?(c.Logger.warning("Encoder","Source data too small. Allocating larger array"),j=h,_=this.allocate($*this.channelSize),j.forEach((nt,et)=>_[et]=nt)):(j=h,_=j),_}allocate(h){return new Float32Array(4*h)}decode(h,$){return this.channelSize===1?h.filter((_,j)=>j%4==0).subarray(0,$):h.subarray(0,$)}},e.RGBAFloatDataEncoder=class{constructor(h,$=1,_){if($!==1&&$!==4)throw new Error(`Invalid number of channels: ${$}`);this.internalFormat=h.RGBA,this.format=h.RGBA,this.channelSize=$,this.textureType=_||h.FLOAT}encode(h,$){let _=h;return this.channelSize===1&&(c.Logger.verbose("Encoder","Exploding into a larger array"),_=this.allocate($),h.forEach((j,nt)=>_[4*nt]=j)),_}allocate(h){return new Float32Array(4*h)}decode(h,$){return this.channelSize===1?h.filter((_,j)=>j%4==0).subarray(0,$):h.subarray(0,$)}},e.Uint8DataEncoder=class{constructor(h,$=1){if(this.channelSize=4,$===1)this.internalFormat=h.ALPHA,this.format=h.ALPHA,this.textureType=h.UNSIGNED_BYTE,this.channelSize=$;else{if($!==4)throw new Error(`Invalid number of channels: ${$}`);this.internalFormat=h.RGBA,this.format=h.RGBA,this.textureType=h.UNSIGNED_BYTE,this.channelSize=$}}encode(h,$){return new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}allocate(h){return new Uint8Array(h*this.channelSize)}decode(h,$){if(h instanceof Uint8Array)return h.subarray(0,$);throw new Error(`Invalid array type: ${h.constructor}`)}}},7859:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getBatchDim=e.sizeToSquarishShape=e.getRowsCols=e.sizeFromShape=e.isInt=e.parseAxisParam=e.squeezeShape=e.PreferLogicalStrategy=e.AlwaysKeepOriginalSizeStrategy=void 0;const c=s(6231),h=s(2517);function $(b,a){const o=[],d=[],g=a!=null&&Array.isArray(a)&&a.length===0,rt=a==null||g?null:_(a,b).sort();let st=0;for(let tt=0;tt<b.length;++tt){if(rt!=null){if(rt[st]===tt&&b[tt]!==1)throw new Error(`Can't squeeze axis ${tt} since its dim '${b[tt]}' is not 1`);(rt[st]==null||rt[st]>tt)&&b[tt]===1&&(o.push(b[tt]),d.push(tt)),rt[st]<=tt&&st++}b[tt]!==1&&(o.push(b[tt]),d.push(tt))}return{newShape:o,keptDims:d}}function _(b,a){const o=a.length;return b=b==null?a.map((d,g)=>g):[].concat(b),(0,h.assert)(b.every(d=>d>=-o&&d<o),()=>`All values in axis param must be in range [-${o}, ${o}) but got axis ${b}`),(0,h.assert)(b.every(j),()=>`All values in axis param must be integers but got axis ${b}`),b.map(d=>d<0?o+d:d)}function j(b){return b%1==0}function nt(b){if(b.length===0)return 1;let a=b[0];for(let o=1;o<b.length;o++)a*=b[o];return a}function et(b){const a=Math.ceil(Math.sqrt(b));return[a,Math.ceil(b/a)]}e.AlwaysKeepOriginalSizeStrategy=class{constructor(b){this.maxTextureSize=b}computeTextureWH(b,a){if(b.length===0)return[1,1];const o=this.maxTextureSize;if(a&&a.breakAxis!==void 0){const rt=a.breakAxis>=b.length?1:b.slice(a.breakAxis).reduce((tt,ot)=>tt*ot),st=a.breakAxis<=0?1:b.slice(0,a.breakAxis).reduce((tt,ot)=>tt*ot);if(!(rt>o||st>o))return[rt,st];c.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${b}, breakAxis:${a.breakAxis}`)}const d=b.reduce((rt,st)=>rt*st);let g=Math.floor(Math.sqrt(d));for(;g<o&&g<d&&d%g!=0;g++);if(g>=o||d%g!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${b}`);return[g,d/g]}},e.PreferLogicalStrategy=class{constructor(b){this.maxTextureSize=b}computeTextureWH(b,a){const o=this.computeTexture(b,a);return a&&a.isPacked&&(o[0]/=2,o[1]/=2),a&&a.reverseWH?[o[1],o[0]]:o}computeTexture(b,a){const o=a&&a.isPacked;if(b.length===0)return o?[2,2]:[1,1];let d=this.maxTextureSize;if(a&&a.breakAxis!==void 0){const st=a.breakAxis>=b.length?1:b.slice(a.breakAxis).reduce((ot,it)=>ot*it),tt=a.breakAxis<=0?1:b.slice(0,a.breakAxis).reduce((ot,it)=>ot*it);if(!(st>d||tt>d))return[st,tt];c.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${b}, breakAxis:${a.breakAxis}`)}let g=b.slice(0);o&&(d*=2,g=g.map((st,tt)=>tt>=g.length-2?g[tt]%2==0?g[tt]:g[tt]+1:g[tt]),g.length===1&&(g=[2,g[0]])),g.length!==2&&(g=$(g).newShape);const rt=nt(g);return g.length<=1&&rt<=d?[1,rt]:g.length===2&&g[0]<=d&&g[1]<=d?g:g.length===3&&g[0]*g[1]<=d&&g[2]<=d?[g[0]*g[1],g[2]]:g.length===3&&g[0]<=d&&g[1]*g[2]<=d?[g[0],g[1]*g[2]]:g.length===4&&g[0]*g[1]*g[2]<=d&&g[3]<=d?[g[0]*g[1]*g[2],g[3]]:g.length===4&&g[0]<=d&&g[1]*g[2]*g[3]<=d?[g[0],g[1]*g[2]*g[3]]:o?et(rt/4).map(st=>2*st):et(rt)}},e.squeezeShape=$,e.parseAxisParam=_,e.isInt=j,e.sizeFromShape=nt,e.getRowsCols=function(b){if(b.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[b.length>1?b[b.length-2]:1,b[b.length-1]]},e.sizeToSquarishShape=et,e.getBatchDim=function(b,a=2){return nt(b.slice(0,b.length-a))}},4057:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createTextureLayoutFromShape=e.calculateTextureWidthAndHeight=e.createTextureLayoutFromTextureType=void 0;const c=s(2517),h=s(2039);e.createTextureLayoutFromTextureType=($,_,j)=>{const nt=j===h.TextureType.unpacked||j===h.TextureType.unpackedReversed?1:4,et=j===h.TextureType.packed,b=j===h.TextureType.unpackedReversed||j===h.TextureType.packed,a=j===h.TextureType.packedLastDimension?_.length-1:void 0,o=j===h.TextureType.packedLastDimension?_.map((d,g)=>g===_.length-1?4*d:d):void 0;return(0,e.createTextureLayoutFromShape)($,_,nt,o,{isPacked:et,reverseWH:b,breakAxis:a})},e.calculateTextureWidthAndHeight=($,_,j)=>{const nt=(0,e.createTextureLayoutFromTextureType)($,_,j);return[nt.width,nt.height]},e.createTextureLayoutFromShape=($,_,j=1,nt,et)=>{const b=!(!et||!et.isPacked),[a,o]=$.computeTextureWH(b&&nt||_,et),d=_.length;let g=_.slice(0);if(d===0&&(g=[1]),j===1)nt=_;else if(b){if(j!==4)throw new Error("a packed texture must be 4-channel");nt=_,d>0&&(g[d-1]=Math.ceil(g[d-1]/2)),d>1&&(g[d-2]=Math.ceil(g[d-2]/2))}else if(!nt)throw new Error("Unpacked shape is needed when using channels > 1");return{width:a,height:o,channels:j,isPacked:b,shape:g,strides:c.ShapeUtil.computeStrides(g),unpackedShape:nt,reversedWH:et&&et.reverseWH}}},5702:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TextureManager=void 0;const c=s(6231);e.TextureManager=class{constructor(h,$,_,j){this.glContext=h,this.layoutStrategy=$,this.profiler=_,this.config=j,this.pendingRead=new Map,j.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(h,$,_,j){const nt=this.toEncoderType(h),et=this.glContext.getEncoder(nt,$.channels||1,j);if($.isPacked&&j===1)throw new Error("not implemented");const b=$.width,a=$.height;let o,d;if(this.config.reuseTextures){o=`${b}x${a}_${et.format}_${et.internalFormat}_${et.textureType}`,d=this.inUseTextures.get(o),d||(d=[],this.inUseTextures.set(o,d));const rt=this.idleTextures.get(o);if(rt&&rt.length>0){const st=rt.pop();return d.push(st),j===1&&this.glContext.updateTexture(st,b,a,et,this.toTextureData(h,_)),st}}c.Logger.verbose("TextureManager",`Creating new texture of size ${$.width}x${$.height}`);const g=this.glContext.allocateTexture(b,a,et,this.toTextureData(h,_));return this.config.reuseTextures&&(d.push(g),this.textureLookup.set(g,o)),g}readTexture(h,$,_){return _||(_=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const j=h.shape.reduce((et,b)=>et*b)*_,nt=this.glContext.readTexture(h.texture,h.width,h.height,j,this.toEncoderType($),_);return this.toTensorData($,nt)})}async readTextureAsync(h,$,_){const j=h.tensor.dataId;if(_||(_=1),this.pendingRead.has(j)){const nt=this.pendingRead.get(j);return new Promise(et=>nt==null?void 0:nt.push(et))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(j,[]);const nt=h.shape.reduce((o,d)=>o*d)*_;await this.glContext.createAndWaitForFence();const et=this.glContext.readTexture(h.texture,h.width,h.height,nt,this.toEncoderType($),_),b=this.toTensorData($,et),a=this.pendingRead.get(j);return this.pendingRead.delete(j),a==null||a.forEach(o=>o(b)),b})}readUint8TextureAsFloat(h){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const $=h.shape.reduce((j,nt)=>j*nt),_=this.glContext.readTexture(h.texture,h.width,h.height,4*$,"byte",4);return new Float32Array(_.buffer,_.byteOffset,$)})}releaseTexture(h,$){let _;if(this.config.reuseTextures&&(_=this.textureLookup.get(h.texture),_)){$&&this.textureLookup.delete(_);const j=this.inUseTextures.get(_);if(j){const nt=j.indexOf(h.texture);if(nt!==-1){j.splice(nt,1);let et=this.idleTextures.get(_);et||(et=[],this.idleTextures.set(_,et)),et.push(h.texture)}}}_&&!$||(c.Logger.verbose("TextureManager",`Deleting texture of size ${h.width}x${h.height}`),this.glContext.deleteTexture(h.texture))}toTensorData(h,$){switch(h){case"int16":return $ instanceof Int16Array?$:Int16Array.from($);case"int32":return $ instanceof Int32Array?$:Int32Array.from($);case"int8":return $ instanceof Int8Array?$:Int8Array.from($);case"uint16":return $ instanceof Uint16Array?$:Uint16Array.from($);case"uint32":return $ instanceof Uint32Array?$:Uint32Array.from($);case"uint8":case"bool":return $ instanceof Uint8Array?$:Uint8Array.from($);case"float32":return $ instanceof Float32Array?$:Float32Array.from($);case"float64":return $ instanceof Float64Array?$:Float64Array.from($);default:throw new Error(`TensorData type ${h} is not supported`)}}toTextureData(h,$){if($)return $ instanceof Float32Array?$:new Float32Array($)}toEncoderType(h){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},2039:(i,e)=>{var s;Object.defineProperty(e,"__esModule",{value:!0}),e.TextureType=void 0,(s=e.TextureType||(e.TextureType={}))[s.unpacked=0]="unpacked",s[s.unpackedReversed=1]="unpackedReversed",s[s.packed=2]="packed",s[s.downloadUint8AsFloat=3]="downloadUint8AsFloat",s[s.packedLastDimension=4]="packedLastDimension"},9390:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getGlChannels=e.getCoordsDataType=e.getSqueezedParams=e.squeezeInputShape=e.generateShaderFuncNameFromInputSamplerNameAtOutCoords=e.generateShaderFuncNameFromInputSamplerName=e.repeatedTry=e.getPackedShape=void 0;const c=s(2517);e.getPackedShape=function(h){const $=h.length;return h.slice(0,$-1).concat(h[$-1]/4)},e.repeatedTry=async function(h,$=j=>0,_){return new Promise((j,nt)=>{let et=0;const b=()=>{if(h())return void j();et++;const a=$(et);_!=null&&et>=_?nt():setTimeout(b,a)};b()})},e.generateShaderFuncNameFromInputSamplerName=function(h){return(0,c.assert)(h!==void 0&&h.length!==0,()=>"empty string found for sampler name"),"get"+h.charAt(0).toUpperCase()+h.slice(1)},e.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(h){return(0,c.assert)(h!==void 0&&h.length!==0,()=>"empty string found for sampler name"),"get"+h.charAt(0).toUpperCase()+h.slice(1)+"AtOutCoords"},e.squeezeInputShape=function(h,$){let _=JSON.parse(JSON.stringify(h));return _=$,_},e.getSqueezedParams=function(h,$){return $.map(_=>h[_]).join(", ")},e.getCoordsDataType=function(h){if(h<=1)return"int";if(h===2)return"ivec2";if(h===3)return"ivec3";if(h===4)return"ivec4";if(h===5)return"ivec5";if(h===6)return"ivec6";throw Error(`GPU for rank ${h} is not yet supported`)},e.getGlChannels=function(h=6){return["x","y","z","w","u","v"].slice(0,h)}},7305:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createNewWebGLContext=e.createWebGLContext=void 0;const c=s(6231),h=s(1713),$={};function _(j){const nt=function(){if(typeof document>"u"){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}const a=document.createElement("canvas");return a.width=1,a.height=1,a}();let et;const b={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!j||j==="webgl2")&&(et=nt.getContext("webgl2",b),et))try{return new h.WebGLContext(et,2)}catch(a){c.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${a}`)}if((!j||j==="webgl")&&(et=nt.getContext("webgl",b)||nt.getContext("experimental-webgl",b),et))try{return new h.WebGLContext(et,1)}catch(a){c.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${a}`)}throw new Error("WebGL is not supported")}e.createWebGLContext=function j(nt){let et;nt&&nt!=="webgl2"||!("webgl2"in $)?nt&&nt!=="webgl"||!("webgl"in $)||(et=$.webgl):et=$.webgl2,et=et||_(nt),nt=nt||et.version===1?"webgl":"webgl2";const b=et.gl;return $[nt]=et,b.isContextLost()?(delete $[nt],j(nt)):(b.disable(b.DEPTH_TEST),b.disable(b.STENCIL_TEST),b.disable(b.BLEND),b.disable(b.DITHER),b.disable(b.POLYGON_OFFSET_FILL),b.disable(b.SAMPLE_COVERAGE),b.enable(b.SCISSOR_TEST),b.enable(b.CULL_FACE),b.cullFace(b.BACK),et)},e.createNewWebGLContext=_},1713:function(i,e,s){var c=this&&this.__createBinding||(Object.create?function(b,a,o,d){d===void 0&&(d=o);var g=Object.getOwnPropertyDescriptor(a,o);g&&!("get"in g?!a.__esModule:g.writable||g.configurable)||(g={enumerable:!0,get:function(){return a[o]}}),Object.defineProperty(b,d,g)}:function(b,a,o,d){d===void 0&&(d=o),b[d]=a[o]}),h=this&&this.__setModuleDefault||(Object.create?function(b,a){Object.defineProperty(b,"default",{enumerable:!0,value:a})}:function(b,a){b.default=a}),$=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var a={};if(b!=null)for(var o in b)o!=="default"&&Object.prototype.hasOwnProperty.call(b,o)&&c(a,b,o);return h(a,b),a};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLContext=e.linearSearchLastTrue=void 0;const _=s(1670),j=$(s(7769)),nt=s(9390);function et(b){let a=0;for(;a<b.length&&b[a]();++a);return a-1}e.linearSearchLastTrue=et,e.WebGLContext=class{constructor(b,a){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=b,this.version=a,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(b,a,o,d){const g=this.gl,rt=g.createTexture();g.bindTexture(g.TEXTURE_2D,rt),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,g.NEAREST),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,g.NEAREST),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE);const st=d?o.encode(d,b*a):null;return g.texImage2D(g.TEXTURE_2D,0,o.internalFormat,b,a,0,o.format,o.textureType,st),this.checkError(),rt}updateTexture(b,a,o,d,g){const rt=this.gl;rt.bindTexture(rt.TEXTURE_2D,b);const st=d.encode(g,a*o);rt.texSubImage2D(rt.TEXTURE_2D,0,0,0,a,o,d.format,d.textureType,st),this.checkError()}attachFramebuffer(b,a,o){const d=this.gl;d.bindTexture(d.TEXTURE_2D,b),d.bindFramebuffer(d.FRAMEBUFFER,this.framebuffer),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,b,0),this.checkError(),d.viewport(0,0,a,o),d.scissor(0,0,a,o)}readTexture(b,a,o,d,g,rt){const st=this.gl;rt||(rt=1),this.frameBufferBound||this.attachFramebuffer(b,a,o);const tt=this.getEncoder(g,rt),ot=tt.allocate(a*o);return st.bindTexture(st.TEXTURE_2D,b),st.framebufferTexture2D(st.FRAMEBUFFER,st.COLOR_ATTACHMENT0,st.TEXTURE_2D,b,0),st.readPixels(0,0,a,o,st.RGBA,tt.textureType,ot),this.checkError(),tt.decode(ot,d)}isFramebufferReady(){return!0}getActiveTexture(){const b=this.gl;return"TEXTURE"+(b.getParameter(this.gl.ACTIVE_TEXTURE)-b.TEXTURE0)}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(b,a){const o=this.gl;o.vertexAttribPointer(b,3,o.FLOAT,!1,20,0),o.enableVertexAttribArray(b),a!==-1&&(o.vertexAttribPointer(a,2,o.FLOAT,!1,20,12),o.enableVertexAttribArray(a)),this.checkError()}createProgram(b,a){const o=this.gl,d=o.createProgram();return o.attachShader(d,b),o.attachShader(d,a),o.linkProgram(d),d}compileShader(b,a){const o=this.gl,d=o.createShader(a);if(!d)throw new Error(`createShader() returned null with type ${a}`);if(o.shaderSource(d,b),o.compileShader(d),o.getShaderParameter(d,o.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${o.getShaderInfoLog(d)}
|
|
1849
1849
|
Shader source:
|
|
1850
1850
|
${b}`);return d}deleteShader(b){this.gl.deleteShader(b)}bindTextureToUniform(b,a,o){const d=this.gl;d.activeTexture(d.TEXTURE0+a),this.checkError(),d.bindTexture(d.TEXTURE_2D,b),this.checkError(),d.uniform1i(o,a),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(_.env.debug){const b=this.gl,a=b.getError();let o="";switch(a){case b.NO_ERROR:return;case b.INVALID_ENUM:o="INVALID_ENUM";break;case b.INVALID_VALUE:o="INVALID_VALUE";break;case b.INVALID_OPERATION:o="INVALID_OPERATION";break;case b.INVALID_FRAMEBUFFER_OPERATION:o="INVALID_FRAMEBUFFER_OPERATION";break;case b.OUT_OF_MEMORY:o="OUT_OF_MEMORY";break;case b.CONTEXT_LOST_WEBGL:o="CONTEXT_LOST_WEBGL";break;default:o=`Unknown WebGL Error: ${a.toString(16)}`}throw new Error(o)}}deleteTexture(b){this.gl.deleteTexture(b)}deleteProgram(b){this.gl.deleteProgram(b)}getEncoder(b,a,o=0){if(this.version===2)return new j.RedFloat32DataEncoder(this.gl,a);switch(b){case"float":return o===1||this.isRenderFloat32Supported?new j.RGBAFloatDataEncoder(this.gl,a):new j.RGBAFloatDataEncoder(this.gl,a,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new j.Uint8DataEncoder(this.gl,a);default:throw new Error(`Invalid dataType: ${b}`)}}clearActiveTextures(){const b=this.gl;for(let a=0;a<this.maxTextureImageUnits;++a)b.activeTexture(b.TEXTURE0+a),b.bindTexture(b.TEXTURE_2D,null)}dispose(){if(this.disposed)return;const b=this.gl;b.bindFramebuffer(b.FRAMEBUFFER,null),b.deleteFramebuffer(this.framebuffer),b.bindBuffer(b.ARRAY_BUFFER,null),b.deleteBuffer(this.vertexbuffer),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,null),b.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){const b=this.gl,a=b.createBuffer();if(!a)throw new Error("createBuffer() returned null");const o=this.createDefaultGeometry();return b.bindBuffer(b.ARRAY_BUFFER,a),b.bufferData(b.ARRAY_BUFFER,o,b.STATIC_DRAW),this.checkError(),a}createFramebuffer(){const b=this.gl.createFramebuffer();if(!b)throw new Error("createFramebuffer returned null");return b}queryVitalParameters(){const b=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),this.version===1&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=b.getParameter(b.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=b.getParameter(b.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){this.version===2?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){const b=this.gl,a=b.createTexture();b.bindTexture(b.TEXTURE_2D,a);const o=this.version===2?b.RGBA32F:b.RGBA;b.texImage2D(b.TEXTURE_2D,0,o,1,1,0,b.RGBA,b.FLOAT,null);const d=b.createFramebuffer();b.bindFramebuffer(b.FRAMEBUFFER,d),b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,a,0);const g=b.checkFramebufferStatus(b.FRAMEBUFFER)===b.FRAMEBUFFER_COMPLETE;return b.bindTexture(b.TEXTURE_2D,null),b.bindFramebuffer(b.FRAMEBUFFER,null),b.deleteTexture(a),b.deleteFramebuffer(d),g}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){const b=this.gl;let a,o,d,g,rt;try{a=b.createTexture(),o=b.createFramebuffer(),b.bindTexture(b.TEXTURE_2D,a);const st=this.version===2?b.RGBA32F:b.RGBA;return b.texImage2D(b.TEXTURE_2D,0,st,1,1,0,b.RGBA,b.FLOAT,null),b.bindFramebuffer(b.FRAMEBUFFER,o),b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,a,0),b.enable(b.BLEND),d=b.createShader(b.VERTEX_SHADER),!!d&&(b.shaderSource(d,"void main(){}"),b.compileShader(d),g=b.createShader(b.FRAGMENT_SHADER),!!g&&(b.shaderSource(g,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),b.compileShader(g),rt=b.createProgram(),!!rt&&(b.attachShader(rt,d),b.attachShader(rt,g),b.linkProgram(rt),b.useProgram(rt),b.drawArrays(b.POINTS,0,1),b.getError()===b.NO_ERROR)))}finally{b.disable(b.BLEND),rt&&b.deleteProgram(rt),d&&b.deleteShader(d),g&&b.deleteShader(g),o&&(b.bindFramebuffer(b.FRAMEBUFFER,null),b.deleteFramebuffer(o)),a&&(b.bindTexture(b.TEXTURE_2D,null),b.deleteTexture(a))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const b=this.gl,a=this.disjointTimerQueryWebgl2Extension,o=b.createQuery();return b.beginQuery(a.TIME_ELAPSED_EXT,o),o}throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const b=this.gl,a=this.disjointTimerQueryWebgl2Extension;b.endQuery(a.TIME_ELAPSED_EXT)}}isTimerResultAvailable(b){let a=!1,o=!1;if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const d=this.gl,g=this.disjointTimerQueryWebgl2Extension;a=d.getQueryParameter(b,d.QUERY_RESULT_AVAILABLE),o=d.getParameter(g.GPU_DISJOINT_EXT)}return a&&!o}getTimerResult(b){let a=0;if(this.version!==2)throw new Error("WebGL1 profiling currently not supported");{const o=this.gl;a=o.getQueryParameter(b,o.QUERY_RESULT),o.deleteQuery(b)}return a/1e6}async waitForQueryAndGetTime(b){return await(0,nt.repeatedTry)(()=>this.isTimerResultAvailable(b)),this.getTimerResult(b)}async createAndWaitForFence(){const b=this.createFence(this.gl);return this.pollFence(b)}createFence(b){let a;const o=b,d=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);return b.flush(),a=d===null?()=>!0:()=>{const g=o.clientWaitSync(d,0,0);return g===o.ALREADY_SIGNALED||g===o.CONDITION_SATISFIED},{query:d,isFencePassed:a}}async pollFence(b){return new Promise(a=>{this.addItemToPoll(()=>b.isFencePassed(),()=>a())})}pollItems(){const b=et(this.itemsToPoll.map(a=>a.isDoneFn));for(let a=0;a<=b;++a){const{resolveFn:o}=this.itemsToPoll[a];o()}this.itemsToPoll=this.itemsToPoll.slice(b+1)}async addItemToPoll(b,a){this.itemsToPoll.push({isDoneFn:b,resolveFn:a}),this.itemsToPoll.length>1||await(0,nt.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},1036:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExecutionPlan=void 0;const c=s(6231);class h{constructor(_,j){this.op=_,this.node=j}}e.ExecutionPlan=class{constructor($,_,j){this.graph=$,this.profiler=j,this.initialize(_)}initialize($){this.profiler.event("session","ExecutionPlan.initialize",()=>{const _=this.graph.getNodes();if(_.length!==$.length)throw new Error("The size of nodes and OPs do not match.");this._ops=$.map((j,nt)=>new h(j,_[nt])),this.reset(),this._starter=[],this._ops.forEach((j,nt)=>{let et=!0;for(const b of j.node.inputs)if(!this._values[b]&&this.graph.getInputIndices().indexOf(b)===-1){et=!1;break}et&&this._starter.push(nt)})})}reset(){this._values=this.graph.getValues().map($=>$.tensor)}async execute($,_){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const j=$.createInferenceHandler(),nt=this.graph.getInputIndices();if(_.length!==nt.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${_.length} expected: ${nt.length}`);_.forEach((g,rt)=>{const st=nt[rt];this._values[st]=g});const et=this._starter.slice(0),b=this.graph.getValues(),a=this.graph.getNodes();let o=0;for(;o<et.length;){const g=et[o++],rt=this._ops[g],st=rt.node.inputs.map(at=>this._values[at]);if(st.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${rt.node}`);const tt=st;c.Logger.verbose("ExecPlan",`Runing op:${rt.node.name} (${tt.map((at,ut)=>`'${rt.node.inputs[ut]}': ${at.type}[${at.dims.join(",")}]`).join(", ")})`);const ot=await this.profiler.event("node",rt.node.name,async()=>rt.op.impl(j,tt,rt.op.context));if(ot.length!==rt.node.outputs.length)throw new Error("the size of output does not match model definition.");ot.forEach((at,ut)=>{const lt=rt.node.outputs[ut];if(this._values[lt])throw new Error(`output [${lt}] already has value: op:${rt.node.name}`);this._values[lt]=at});const it=new Set;ot.forEach((at,ut)=>{const lt=rt.node.outputs[ut];for(const ct of b[lt].to){const ft=a[ct];let dt=!0;for(const yt of ft.inputs)if(!this._values[yt]){dt=!1;break}dt&&it.add(ct)}}),et.push(...it)}const d=[];for(let g=0;g<this.graph.getOutputIndices().length;g++){const rt=this.graph.getOutputIndices()[g],st=this._values[rt];if(st===void 0)throw new Error(`required output [${rt}] does not have value`);rt===0?await st.getData():st.data,d.push(st)}return c.Logger.verbose("ExecPlan","disposing of inferenceHandler"),j.dispose(),d})}}},7070:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Graph=void 0;const c=s(1446),h=s(7778),$=s(9395),_=s(9162),j=s(2517);var nt=$.onnxruntime.experimental.fbs;e.Graph={from:(o,d)=>new a(o,d)};class et{constructor(d){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,d&&(this.type=j.ProtoUtil.tensorValueTypeFromProto(d.type.tensorType))}get from(){return this._from}get to(){return this._to}}class b{constructor(d,g){d instanceof c.onnx.NodeProto?(this.name=d.name,this.opType=d.opType,this.attributes=new h.Attribute(d.attribute)):d instanceof nt.Node&&(this.name=g??d.name(),this.opType=d.opType(),this.attributes=new h.Attribute(j.ProtoUtil.tensorAttributesFromORTFormat(d))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class a{constructor(d,g){if(!d)throw new TypeError("graph is empty");this.buildGraph(d),this.transformGraph(g),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(d){if(d instanceof c.onnx.GraphProto)this.buildGraphFromOnnxFormat(d);else{if(!(d instanceof nt.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(d)}}buildGraphFromOnnxFormat(d){const g=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const rt=new Map;if(!d.input)throw new Error("missing information in graph: input");const st=[];for(const tt of d.input){if(g.has(tt.name))throw new Error(`duplicated input name: ${tt.name}`);const ot=this._allData.push(new et(tt))-1;g.set(tt.name,ot),st.push(tt.name)}if(!d.initializer)throw new Error("missing information in graph: initializer");for(const tt of d.initializer){let ot=g.get(tt.name);if(ot===void 0){const it=new et;it.type={shape:{dims:j.ProtoUtil.tensorDimsFromProto(tt.dims)},tensorType:j.ProtoUtil.tensorDataTypeFromProto(tt.dataType)},ot=this._allData.push(it)-1,g.set(tt.name,ot)}this._allData[ot]._from=-1,this._allData[ot].tensor=_.Tensor.fromProto(tt)}for(let tt=0;tt<this._allData.length;tt++)this._allData[tt].tensor||(this._allInputIndices.push(tt),this._allInputNames.push(st[tt]));if(!d.output)throw new Error("missing information in graph: output");for(const tt of d.output){if(g.has(tt.name))throw new Error(`duplicated output name: ${tt.name}`);const ot=this._allData.push(new et(tt))-1;g.set(tt.name,ot),this._allOutputIndices.push(ot),this._allOutputNames.push(tt.name)}if(!d.node)throw new Error("missing information in graph: node");for(const tt of d.node){if(!tt.name)for(let it=0;;it++){const at=`unnamed_${tt.opType}_${it}`;if(!rt.has(at)){tt.name=at;break}}if(rt.has(tt.name))throw new Error(`duplicated node name: ${tt.name}`);const ot=this._nodes.push(new b(tt))-1;rt.set(tt.name,ot)}for(let tt=0;tt<this._nodes.length;tt++){const ot=this._nodes[tt],it=d.node[tt];if(!it.output)throw new Error(`missing output for node: ${it.name}`);for(const at of it.output){let ut=g.get(at);if(ut===void 0&&(ut=this._allData.push(new et)-1,g.set(at,ut)),ot.outputs.push(ut),this._allData[ut]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${ut}`);if(this._allData[ut]._from=tt,it.opType==="Constant"){if(!it.attribute||it.attribute.length!==1||!it.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!it.output||it.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");ot.outputs.pop(),ot.executeNode=!1,this._allData[ut]._from=-1,this._allData[ut].tensor=_.Tensor.fromProto(it.attribute[0].t)}}}for(let tt=0;tt<this._nodes.length;tt++){const ot=this._nodes[tt],it=d.node[tt];if(!it.input)throw new Error(`missing input for node: ${it.name}`);for(const at of it.input){const ut=g.get(at);if(ut===void 0){if(at===""&&it.input.length===3&&it.opType==="Resize")continue;throw new Error(`unrecognized input '${at}' for node: ${it.name}`)}ot.inputs.push(ut),this._allData[ut]._to.push(tt)}}return!0}buildGraphFromOrtFormat(d){var g,rt,st;const tt=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const ot=new Map,it=[];for(let at=0;at<d.inputsLength();at++){const ut=d.inputs(at);if(tt.has(ut))throw new Error(`duplicated input name: ${ut}`);for(let lt=0;lt<d.nodeArgsLength();lt++)if(((g=d.nodeArgs(lt))===null||g===void 0?void 0:g.name())===ut){const ct=new et;if(((st=(rt=d.nodeArgs(lt))===null||rt===void 0?void 0:rt.type())===null||st===void 0?void 0:st.valueType())!==nt.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");const ft=d.nodeArgs(lt).type().value(new nt.TensorTypeAndShape),dt=j.ProtoUtil.tensorDataTypeFromProto(ft.elemType()),yt=ft.shape(),St=[];for(let Tt=0;Tt<yt.dimLength();Tt++)St.push(j.LongUtil.longToNumber(yt.dim(Tt).value().dimValue()));ct.type={shape:{dims:St},tensorType:dt};const bt=this._allData.push(ct)-1;tt.set(ut,bt),it.push(ut)}}for(let at=0;at<d.initializersLength();at++){const ut=d.initializers(at);let lt=tt.get(ut.name());if(lt===void 0){const ct=new et,ft=j.ProtoUtil.tensorDimsFromORTFormat(ut),dt=j.ProtoUtil.tensorDataTypeFromProto(ut.dataType());ct.type={shape:{dims:ft},tensorType:dt},lt=this._allData.push(ct)-1,tt.set(ut.name(),lt)}this._allData[lt]._from=-1,this._allData[lt].tensor=_.Tensor.fromOrtTensor(ut)}for(let at=0;at<this._allData.length;at++)this._allData[at].tensor||(this._allInputIndices.push(at),this._allInputNames.push(it[at]));for(let at=0;at<d.outputsLength();at++){const ut=d.outputs(at);if(tt.has(ut))throw new Error(`duplicated output name: ${ut}`);const lt=this._allData.push(new et)-1;tt.set(ut,lt),this._allOutputIndices.push(lt),this._allOutputNames.push(ut)}if(!d.nodes)throw new Error("missing information in graph: node");for(let at=0;at<d.nodesLength();at++){const ut=d.nodes(at);let lt=ut.name();if(!lt)for(let ft=0;lt=`unnamed_${ut.opType()}_${ft}`,ot.has(lt);ft++);if(ot.has(lt))throw new Error(`duplicated node name: ${lt}`);const ct=this._nodes.push(new b(ut,lt))-1;ot.set(lt,ct)}for(let at=0;at<this._nodes.length;at++){const ut=this._nodes[at],lt=d.nodes(at);if(lt==null)throw new Error(`No node exists at index ${at}`);if((lt==null?void 0:lt.outputsLength())===0)throw new Error(`missing output for node: ${lt.name}`);for(let ct=0;ct<(lt==null?void 0:lt.outputsLength());ct++){const ft=lt==null?void 0:lt.outputs(ct);let dt=tt.get(ft);if(dt===void 0&&(dt=this._allData.push(new et)-1,tt.set(ft,dt)),ut.outputs.push(dt),this._allData[dt]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${dt}`);if(this._allData[dt]._from=at,lt.opType()==="Constant"){if(lt.attributesLength()!==1||!lt.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(lt.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");ut.outputs.pop(),ut.executeNode=!1,this._allData[dt]._from=-1,this._allData[dt].tensor=_.Tensor.fromOrtTensor(lt.attributes(0).t())}}}for(let at=0;at<this._nodes.length;at++){const ut=this._nodes[at],lt=d.nodes(at);if(lt.inputsLength()===0)throw new Error(`missing input for node: ${lt.name}`);for(let ct=0;ct<lt.inputsLength();ct++){const ft=lt.inputs(ct),dt=tt.get(ft);if(dt===void 0)throw new Error(`unrecognized input '${ft}' for node: ${lt.name()}`);ut.inputs.push(dt),this._allData[dt]._to.push(at)}}}checkIsAcyclic(){const d=new Set;this._allInputIndices.forEach(st=>{this._allData[st]._to.forEach(tt=>{d.add(tt)})});const g=Array.from(d),rt=new Array(this._nodes.length).fill("white");for(;g.length>0;){const st=g.pop();rt[st]==="gray"?rt[st]="black":(g.push(st),rt[st]="gray",this._nodes[st].outputs.forEach(tt=>{const ot=this._allData[tt];if(ot.tensor!==void 0)throw new Error("node outputs should not be initialized");if(ot._from!==st)throw new Error("from property of the Value object doesn't match index of Node being processed");ot._to.forEach(it=>{if(rt[it]==="gray")throw new Error("model graph is cyclic");rt[it]==="white"&&g.push(it)})}))}}transformGraph(d){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),d&&d.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let d=0;for(let g=0;g<this._nodes.length;g++)this._nodes[g].executeNode?d>0&&(this._nodes[g].inputs.forEach(rt=>{const st=this._allData[rt]._to.indexOf(g+d);st!==-1&&(this._allData[rt]._to[st]=g)}),this._nodes[g].outputs.forEach(rt=>{this._allData[rt]._from&&this._allData[rt]._from===g+d&&(this._allData[rt]._from=g)})):(d++,this._nodes[g].outputs.forEach(rt=>{this._allData[rt]._from=-2}),this._nodes.splice(g,1),g--);d=0;for(let g=0;g<this._allData.length;g++)if(this._allData[g].from!==-2||this._allOutputIndices.indexOf(g+d)!==-1){if(d>0){let rt=-1;this._allData[g].from!==void 0&&this._allData[g].from!==-1?(rt=this._nodes[this._allData[g].from].outputs.indexOf(g+d),rt!==-1&&(this._nodes[this._allData[g].from].outputs[rt]=g)):(rt=this._allInputIndices.indexOf(g+d),rt!==-1&&(this._allInputIndices[rt]=g)),this._allData[g].to.forEach(st=>{rt=this._nodes[st].inputs.indexOf(g+d),rt!==-1&&(this._nodes[st].inputs[rt]=g)}),this._allData[g].to.length===0&&(rt=this._allOutputIndices.indexOf(g+d),rt!==-1&&(this._allOutputIndices[rt]=g))}}else d++,this._allData.splice(g,1),g--}deleteNode(d){const g=this._nodes[d];if(g.outputs.length>1){for(let at=1;at<g.outputs.length;at++)if(this._allData[g.outputs[at]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}g.executeNode=!1;const rt=g.inputs[0],st=g.outputs[0],tt=this._allData[st].to,ot=this._allData[rt].to.indexOf(d);if(ot===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[rt].to.splice(ot,1),this._allData[st]._to=[];const it=this._allOutputIndices.indexOf(st);if(it!==-1&&(this._allOutputIndices[it]=rt),tt&&tt.length>0)for(const at of tt){const ut=this._nodes[at].inputs.indexOf(st);if(ut===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[at].inputs[ut]=rt,this._allData[rt].to.push(at)}}removeAllDropoutNodes(){let d=0;for(const g of this._nodes){if(g.opType==="Dropout"){if(g.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(g.outputs.length!==1&&g.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(g.outputs.length===2&&this._allData[g.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(d)}d++}}removeAllIdentityNodes(){let d=0;for(const g of this._nodes)g.opType==="Identity"&&this.deleteNode(d),d++}isActivation(d){switch(d.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const d of this._nodes)if(d.opType==="Conv"){const g=this._allData[d.outputs[0]]._to;if(g.length===1&&this.isActivation(this._nodes[g[0]])){const rt=this._nodes[g[0]];if(rt.opType==="Clip")if(rt.inputs.length===1)try{d.attributes.set("activation_params","floats",[rt.attributes.getFloat("min"),rt.attributes.getFloat("max")])}catch{d.attributes.set("activation_params","floats",[j.MIN_CLIP,j.MAX_CLIP])}else{if(!(rt.inputs.length>=3&&this._allData[rt.inputs[1]].tensor!==void 0&&this._allData[rt.inputs[2]].tensor!==void 0))continue;d.attributes.set("activation_params","floats",[this._allData[rt.inputs[1]].tensor.floatData[0],this._allData[rt.inputs[2]].tensor.floatData[0]])}d.attributes.set("activation","string",rt.opType),this.deleteNode(g[0])}}}}},6231:(i,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.now=e.Profiler=e.Logger=void 0;const s={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},c={none:new class{log(b,a,o){}},console:new class{log(b,a,o){console.log(`${this.color(b)} ${o?"\x1B[35m"+o+"\x1B[0m ":""}${a}`)}color(b){switch(b){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${b}`)}}}},h={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let $={"":h};function _(b,a,o,d){if(a===void 0)return g=b,{verbose:_.verbose.bind(null,g),info:_.info.bind(null,g),warning:_.warning.bind(null,g),error:_.error.bind(null,g),fatal:_.fatal.bind(null,g)};if(o===void 0)j(b,a);else if(typeof o=="number"&&d===void 0)j(b,a);else if(typeof o=="string"&&d===void 0)j(b,o,0,a);else{if(typeof o!="string"||typeof d!="number")throw new TypeError("input is valid");j(b,o,0,a)}var g}function j(b,a,o,d){const g=$[d||""]||$[""];s[b]<s[g.minimalSeverity]||(g.logDateTime&&(a=`${new Date().toISOString()}|${a}`),g.logSourceLocation,c[g.provider].log(b,a,d))}(function(b){function a(d){$={},o("",d||{})}function o(d,g){if(d==="*")a(g);else{const rt=$[d]||h;$[d]={provider:g.provider||rt.provider,minimalSeverity:g.minimalSeverity||rt.minimalSeverity,logDateTime:g.logDateTime===void 0?rt.logDateTime:g.logDateTime,logSourceLocation:g.logSourceLocation===void 0?rt.logSourceLocation:g.logSourceLocation}}}b.verbose=function(d,g){b("verbose",d,g)},b.info=function(d,g){b("info",d,g)},b.warning=function(d,g){b("warning",d,g)},b.error=function(d,g){b("error",d,g)},b.fatal=function(d,g){b("fatal",d,g)},b.reset=a,b.set=o,b.setWithEnv=function(d){const g={};d.logLevel&&(g.minimalSeverity=d.logLevel),o("",g)}})(_||(_={})),e.Logger=_;class nt{constructor(a,o,d,g,rt,st){this.category=a,this.name=o,this.startTime=d,this.endCallback=g,this.timer=rt,this.ctx=st}end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}}class et{constructor(a,o,d,g){this.category=a,this.name=o,this.startTime=d,this.endTime=g}}e.Profiler=class{static create(b){return b===void 0?new this:new this(b.maxNumberEvents,b.flushBatchSize,b.flushIntervalInMilliseconds)}constructor(b,a,o){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=b===void 0?1e4:b,this._flushBatchSize=a===void 0?10:a,this._flushIntervalInMilliseconds=o===void 0?5e3:o}start(){this._started=!0,this._timingEvents=[],this._flushTime=(0,e.now)(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(b,a,o,d){const g=this._started?this.begin(b,a,d):void 0;let rt=!1;const st=o();if(st&&typeof st.then=="function")return rt=!0,new Promise((tt,ot)=>{st.then(async it=>{g&&await g.end(),tt(it)},async it=>{g&&await g.end(),ot(it)})});if(!rt&&g){const tt=g.end();if(tt&&typeof tt.then=="function")return new Promise((ot,it)=>{tt.then(()=>{ot(st)},at=>{it(at)})})}return st}begin(b,a,o){if(!this._started)throw new Error("profiler is not started yet");if(o===void 0){const d=(0,e.now)();return this.flush(d),new nt(b,a,d,g=>this.endSync(g))}{const d=o.beginTimer();return new nt(b,a,0,async g=>this.end(g),d,o)}}async end(b){const a=await b.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new et(b.category,b.name,b.startTime,a)),this.flush(a))}endSync(b){const a=(0,e.now)();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new et(b.category,b.name,b.startTime,a)),this.flush(a))}logOneEvent(b){e.Logger.verbose(`Profiler.${b.category}`,`${(b.endTime-b.startTime).toFixed(2)}ms on event '${b.name}' at ${b.endTime.toFixed(2)}`)}flush(b){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||b-this._flushTime>=this._flushIntervalInMilliseconds){for(const a=this._flushPointer;this._flushPointer<a+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=(0,e.now)()}}get started(){return this._started}},e.now=typeof performance<"u"&&performance.now?()=>performance.now():Date.now},2644:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Model=void 0;const c=s(5686),h=s(1446),$=s(7070),_=s(9395),j=s(2517);var nt=_.onnxruntime.experimental.fbs;e.Model=class{constructor(){}load(et,b,a){if(!a)try{return void this.loadFromOnnxFormat(et,b)}catch(o){if(a!==void 0)throw o}this.loadFromOrtFormat(et,b)}loadFromOnnxFormat(et,b){const a=h.onnx.ModelProto.decode(et);if(j.LongUtil.longToNumber(a.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=a.opsetImport.map(o=>({domain:o.domain,version:j.LongUtil.longToNumber(o.version)})),this._graph=$.Graph.from(a.graph,b)}loadFromOrtFormat(et,b){const a=new c.flatbuffers.ByteBuffer(et),o=nt.InferenceSession.getRootAsInferenceSession(a).model();if(j.LongUtil.longToNumber(o.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let d=0;d<o.opsetImportLength();d++){const g=o.opsetImport(d);this._opsets.push({domain:g==null?void 0:g.domain(),version:j.LongUtil.longToNumber(g.version())})}this._graph=$.Graph.from(o.graph(),b)}get graph(){return this._graph}get opsets(){return this._opsets}}},782:(i,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FLOAT_TYPES=e.INT_TYPES=e.NUMBER_TYPES=void 0,e.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],e.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],e.FLOAT_TYPES=["float32","float64"]},1047:(i,e)=>{function s(c,h){if(h.endsWith("+")){const $=Number.parseInt(h.substring(0,h.length-1),10);return!isNaN($)&&$<=c}if(h.split("-").length===2){const $=h.split("-"),_=Number.parseInt($[0],10),j=Number.parseInt($[1],10);return!isNaN(_)&&!isNaN(j)&&_<=c&&c<=j}return Number.parseInt(h,10)===c}Object.defineProperty(e,"__esModule",{value:!0}),e.resolveOperator=void 0,e.resolveOperator=function(c,h,$){for(const _ of $){const j=_[0],nt=_[1],et=_[2],b=_[3],a=_[4];if(c.opType===j){for(const o of h)if((o.domain===nt||o.domain==="ai.onnx"&&nt==="")&&s(o.version,et))return{opImpl:b,opInit:a}}}throw new TypeError(`cannot resolve operator '${c.opType}' with opsets: ${h.map(_=>`${_.domain||"ai.onnx"} v${_.version}`).join(", ")}`)}},9395:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.onnxruntime=void 0;const c=s(5686);var h,$;h=e.onnxruntime||(e.onnxruntime={}),function(_){(function(j){j[j.UNDEFINED=0]="UNDEFINED",j[j.FLOAT=1]="FLOAT",j[j.INT=2]="INT",j[j.STRING=3]="STRING",j[j.TENSOR=4]="TENSOR",j[j.GRAPH=5]="GRAPH",j[j.FLOATS=6]="FLOATS",j[j.INTS=7]="INTS",j[j.STRINGS=8]="STRINGS",j[j.TENSORS=9]="TENSORS",j[j.GRAPHS=10]="GRAPHS",j[j.SPARSE_TENSOR=11]="SPARSE_TENSOR",j[j.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(_.AttributeType||(_.AttributeType={}))}(($=h.experimental||(h.experimental={})).fbs||($.fbs={})),function(_){(function(j){(function(nt){(function(et){et[et.UNKNOWN=0]="UNKNOWN",et[et.VALUE=1]="VALUE",et[et.PARAM=2]="PARAM"})(nt.DimensionValueType||(nt.DimensionValueType={}))})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){(function(et){et[et.UNDEFINED=0]="UNDEFINED",et[et.FLOAT=1]="FLOAT",et[et.UINT8=2]="UINT8",et[et.INT8=3]="INT8",et[et.UINT16=4]="UINT16",et[et.INT16=5]="INT16",et[et.INT32=6]="INT32",et[et.INT64=7]="INT64",et[et.STRING=8]="STRING",et[et.BOOL=9]="BOOL",et[et.FLOAT16=10]="FLOAT16",et[et.DOUBLE=11]="DOUBLE",et[et.UINT32=12]="UINT32",et[et.UINT64=13]="UINT64",et[et.COMPLEX64=14]="COMPLEX64",et[et.COMPLEX128=15]="COMPLEX128",et[et.BFLOAT16=16]="BFLOAT16"})(nt.TensorDataType||(nt.TensorDataType={}))})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){(function(et){et[et.Primitive=0]="Primitive",et[et.Fused=1]="Fused"})(nt.NodeType||(nt.NodeType={}))})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){(function(et){et[et.NONE=0]="NONE",et[et.tensor_type=1]="tensor_type",et[et.sequence_type=2]="sequence_type",et[et.map_type=3]="map_type"})(nt.TypeInfoValue||(nt.TypeInfoValue={}))})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsShape(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsShape(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}dim(a,o){let d=this.bb.__offset(this.bb_pos,4);return d?(o||new _.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}dimLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}static startShape(a){a.startObject(1)}static addDim(a,o){a.addFieldOffset(0,o,0)}static createDimVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startDimVector(a,o){a.startVector(4,o,4)}static endShape(a){return a.endObject()}static createShape(a,o){return et.startShape(a),et.addDim(a,o),et.endShape(a)}}nt.Shape=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsDimension(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsDimension(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}value(a){let o=this.bb.__offset(this.bb_pos,4);return o?(a||new _.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}denotation(a){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,a):null}static startDimension(a){a.startObject(2)}static addValue(a,o){a.addFieldOffset(0,o,0)}static addDenotation(a,o){a.addFieldOffset(1,o,0)}static endDimension(a){return a.endObject()}static createDimension(a,o,d){return et.startDimension(a),et.addValue(a,o),et.addDenotation(a,d),et.endDimension(a)}}nt.Dimension=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsDimensionValue(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsDimensionValue(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}dimType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt8(this.bb_pos+a):_.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}dimParam(a){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__string(this.bb_pos+o,a):null}static startDimensionValue(a){a.startObject(3)}static addDimType(a,o){a.addFieldInt8(0,o,_.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(a,o){a.addFieldInt64(1,o,a.createLong(0,0))}static addDimParam(a,o){a.addFieldOffset(2,o,0)}static endDimensionValue(a){return a.endObject()}static createDimensionValue(a,o,d,g){return et.startDimensionValue(a),et.addDimType(a,o),et.addDimValue(a,d),et.addDimParam(a,g),et.endDimensionValue(a)}}nt.DimensionValue=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsTensorTypeAndShape(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTensorTypeAndShape(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}elemType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt32(this.bb_pos+a):_.experimental.fbs.TensorDataType.UNDEFINED}shape(a){let o=this.bb.__offset(this.bb_pos,6);return o?(a||new _.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startTensorTypeAndShape(a){a.startObject(2)}static addElemType(a,o){a.addFieldInt32(0,o,_.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(a,o){a.addFieldOffset(1,o,0)}static endTensorTypeAndShape(a){return a.endObject()}static createTensorTypeAndShape(a,o,d){return et.startTensorTypeAndShape(a),et.addElemType(a,o),et.addShape(a,d),et.endTensorTypeAndShape(a)}}nt.TensorTypeAndShape=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsMapType(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsMapType(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}keyType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt32(this.bb_pos+a):_.experimental.fbs.TensorDataType.UNDEFINED}valueType(a){let o=this.bb.__offset(this.bb_pos,6);return o?(a||new _.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startMapType(a){a.startObject(2)}static addKeyType(a,o){a.addFieldInt32(0,o,_.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(a,o){a.addFieldOffset(1,o,0)}static endMapType(a){return a.endObject()}static createMapType(a,o,d){return et.startMapType(a),et.addKeyType(a,o),et.addValueType(a,d),et.endMapType(a)}}nt.MapType=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsSequenceType(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSequenceType(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}elemType(a){let o=this.bb.__offset(this.bb_pos,4);return o?(a||new _.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startSequenceType(a){a.startObject(1)}static addElemType(a,o){a.addFieldOffset(0,o,0)}static endSequenceType(a){return a.endObject()}static createSequenceType(a,o){return et.startSequenceType(a),et.addElemType(a,o),et.endSequenceType(a)}}nt.SequenceType=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(j.fbs||(j.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(nt,et){return this.bb_pos=nt,this.bb=et,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(nt,et,b,a){return nt.prep(4,12),nt.writeInt32(a),nt.writeInt32(b),nt.writeInt32(et),nt.offset()}}})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsNodeEdge(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsNodeEdge(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}nodeIndex(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readUint32(this.bb_pos+a):0}inputEdges(a,o){let d=this.bb.__offset(this.bb_pos,6);return d?(o||new _.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+d)+12*a,this.bb):null}inputEdgesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}outputEdges(a,o){let d=this.bb.__offset(this.bb_pos,8);return d?(o||new _.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+d)+12*a,this.bb):null}outputEdgesLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}static startNodeEdge(a){a.startObject(3)}static addNodeIndex(a,o){a.addFieldInt32(0,o,0)}static addInputEdges(a,o){a.addFieldOffset(1,o,0)}static startInputEdgesVector(a,o){a.startVector(12,o,4)}static addOutputEdges(a,o){a.addFieldOffset(2,o,0)}static startOutputEdgesVector(a,o){a.startVector(12,o,4)}static endNodeEdge(a){return a.endObject()}static createNodeEdge(a,o,d,g){return et.startNodeEdge(a),et.addNodeIndex(a,o),et.addInputEdges(a,d),et.addOutputEdges(a,g),et.endNodeEdge(a)}}nt.NodeEdge=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsNode(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsNode(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}name(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}docString(a){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,a):null}domain(a){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__string(this.bb_pos+o,a):null}sinceVersion(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readInt32(this.bb_pos+a):0}index(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readUint32(this.bb_pos+a):0}opType(a){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__string(this.bb_pos+o,a):null}type(){let a=this.bb.__offset(this.bb_pos,16);return a?this.bb.readInt32(this.bb_pos+a):_.experimental.fbs.NodeType.Primitive}executionProviderType(a){let o=this.bb.__offset(this.bb_pos,18);return o?this.bb.__string(this.bb_pos+o,a):null}inputs(a,o){let d=this.bb.__offset(this.bb_pos,20);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*a,o):null}inputsLength(){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__vector_len(this.bb_pos+a):0}outputs(a,o){let d=this.bb.__offset(this.bb_pos,22);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*a,o):null}outputsLength(){let a=this.bb.__offset(this.bb_pos,22);return a?this.bb.__vector_len(this.bb_pos+a):0}attributes(a,o){let d=this.bb.__offset(this.bb_pos,24);return d?(o||new _.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}attributesLength(){let a=this.bb.__offset(this.bb_pos,24);return a?this.bb.__vector_len(this.bb_pos+a):0}inputArgCounts(a){let o=this.bb.__offset(this.bb_pos,26);return o?this.bb.readInt32(this.bb.__vector(this.bb_pos+o)+4*a):0}inputArgCountsLength(){let a=this.bb.__offset(this.bb_pos,26);return a?this.bb.__vector_len(this.bb_pos+a):0}inputArgCountsArray(){let a=this.bb.__offset(this.bb_pos,26);return a?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}implicitInputs(a,o){let d=this.bb.__offset(this.bb_pos,28);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*a,o):null}implicitInputsLength(){let a=this.bb.__offset(this.bb_pos,28);return a?this.bb.__vector_len(this.bb_pos+a):0}static startNode(a){a.startObject(13)}static addName(a,o){a.addFieldOffset(0,o,0)}static addDocString(a,o){a.addFieldOffset(1,o,0)}static addDomain(a,o){a.addFieldOffset(2,o,0)}static addSinceVersion(a,o){a.addFieldInt32(3,o,0)}static addIndex(a,o){a.addFieldInt32(4,o,0)}static addOpType(a,o){a.addFieldOffset(5,o,0)}static addType(a,o){a.addFieldInt32(6,o,_.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(a,o){a.addFieldOffset(7,o,0)}static addInputs(a,o){a.addFieldOffset(8,o,0)}static createInputsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startInputsVector(a,o){a.startVector(4,o,4)}static addOutputs(a,o){a.addFieldOffset(9,o,0)}static createOutputsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startOutputsVector(a,o){a.startVector(4,o,4)}static addAttributes(a,o){a.addFieldOffset(10,o,0)}static createAttributesVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startAttributesVector(a,o){a.startVector(4,o,4)}static addInputArgCounts(a,o){a.addFieldOffset(11,o,0)}static createInputArgCountsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addInt32(o[d]);return a.endVector()}static startInputArgCountsVector(a,o){a.startVector(4,o,4)}static addImplicitInputs(a,o){a.addFieldOffset(12,o,0)}static createImplicitInputsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startImplicitInputsVector(a,o){a.startVector(4,o,4)}static endNode(a){return a.endObject()}static createNode(a,o,d,g,rt,st,tt,ot,it,at,ut,lt,ct,ft){return et.startNode(a),et.addName(a,o),et.addDocString(a,d),et.addDomain(a,g),et.addSinceVersion(a,rt),et.addIndex(a,st),et.addOpType(a,tt),et.addType(a,ot),et.addExecutionProviderType(a,it),et.addInputs(a,at),et.addOutputs(a,ut),et.addAttributes(a,lt),et.addInputArgCounts(a,ct),et.addImplicitInputs(a,ft),et.endNode(a)}}nt.Node=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsValueInfo(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsValueInfo(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}name(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}docString(a){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,a):null}type(a){let o=this.bb.__offset(this.bb_pos,8);return o?(a||new _.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startValueInfo(a){a.startObject(3)}static addName(a,o){a.addFieldOffset(0,o,0)}static addDocString(a,o){a.addFieldOffset(1,o,0)}static addType(a,o){a.addFieldOffset(2,o,0)}static endValueInfo(a){return a.endObject()}static createValueInfo(a,o,d,g){return et.startValueInfo(a),et.addName(a,o),et.addDocString(a,d),et.addType(a,g),et.endValueInfo(a)}}nt.ValueInfo=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsTypeInfo(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTypeInfo(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}denotation(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}valueType(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readUint8(this.bb_pos+a):_.experimental.fbs.TypeInfoValue.NONE}value(a){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__union(a,this.bb_pos+o):null}static startTypeInfo(a){a.startObject(3)}static addDenotation(a,o){a.addFieldOffset(0,o,0)}static addValueType(a,o){a.addFieldInt8(1,o,_.experimental.fbs.TypeInfoValue.NONE)}static addValue(a,o){a.addFieldOffset(2,o,0)}static endTypeInfo(a){return a.endObject()}static createTypeInfo(a,o,d,g){return et.startTypeInfo(a),et.addDenotation(a,o),et.addValueType(a,d),et.addValue(a,g),et.endTypeInfo(a)}}nt.TypeInfo=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsOperatorSetId(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsOperatorSetId(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}domain(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}version(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}static startOperatorSetId(a){a.startObject(2)}static addDomain(a,o){a.addFieldOffset(0,o,0)}static addVersion(a,o){a.addFieldInt64(1,o,a.createLong(0,0))}static endOperatorSetId(a){return a.endObject()}static createOperatorSetId(a,o,d){return et.startOperatorSetId(a),et.addDomain(a,o),et.addVersion(a,d),et.endOperatorSetId(a)}}nt.OperatorSetId=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsTensor(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTensor(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}name(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}docString(a){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,a):null}dims(a){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt64(this.bb.__vector(this.bb_pos+o)+8*a):this.bb.createLong(0,0)}dimsLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}dataType(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readInt32(this.bb_pos+a):_.experimental.fbs.TensorDataType.UNDEFINED}rawData(a){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.readUint8(this.bb.__vector(this.bb_pos+o)+a):0}rawDataLength(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__vector_len(this.bb_pos+a):0}rawDataArray(){let a=this.bb.__offset(this.bb_pos,12);return a?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}stringData(a,o){let d=this.bb.__offset(this.bb_pos,14);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*a,o):null}stringDataLength(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__vector_len(this.bb_pos+a):0}static startTensor(a){a.startObject(6)}static addName(a,o){a.addFieldOffset(0,o,0)}static addDocString(a,o){a.addFieldOffset(1,o,0)}static addDims(a,o){a.addFieldOffset(2,o,0)}static createDimsVector(a,o){a.startVector(8,o.length,8);for(let d=o.length-1;d>=0;d--)a.addInt64(o[d]);return a.endVector()}static startDimsVector(a,o){a.startVector(8,o,8)}static addDataType(a,o){a.addFieldInt32(3,o,_.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(a,o){a.addFieldOffset(4,o,0)}static createRawDataVector(a,o){a.startVector(1,o.length,1);for(let d=o.length-1;d>=0;d--)a.addInt8(o[d]);return a.endVector()}static startRawDataVector(a,o){a.startVector(1,o,1)}static addStringData(a,o){a.addFieldOffset(5,o,0)}static createStringDataVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startStringDataVector(a,o){a.startVector(4,o,4)}static endTensor(a){return a.endObject()}static createTensor(a,o,d,g,rt,st,tt){return et.startTensor(a),et.addName(a,o),et.addDocString(a,d),et.addDims(a,g),et.addDataType(a,rt),et.addRawData(a,st),et.addStringData(a,tt),et.endTensor(a)}}nt.Tensor=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsSparseTensor(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSparseTensor(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}values(a){let o=this.bb.__offset(this.bb_pos,4);return o?(a||new _.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}indices(a){let o=this.bb.__offset(this.bb_pos,6);return o?(a||new _.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}dims(a){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.readInt64(this.bb.__vector(this.bb_pos+o)+8*a):this.bb.createLong(0,0)}dimsLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}static startSparseTensor(a){a.startObject(3)}static addValues(a,o){a.addFieldOffset(0,o,0)}static addIndices(a,o){a.addFieldOffset(1,o,0)}static addDims(a,o){a.addFieldOffset(2,o,0)}static createDimsVector(a,o){a.startVector(8,o.length,8);for(let d=o.length-1;d>=0;d--)a.addInt64(o[d]);return a.endVector()}static startDimsVector(a,o){a.startVector(8,o,8)}static endSparseTensor(a){return a.endObject()}static createSparseTensor(a,o,d,g){return et.startSparseTensor(a),et.addValues(a,o),et.addIndices(a,d),et.addDims(a,g),et.endSparseTensor(a)}}nt.SparseTensor=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsAttribute(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsAttribute(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}name(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}docString(a){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.__string(this.bb_pos+o,a):null}type(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.readInt32(this.bb_pos+a):_.experimental.fbs.AttributeType.UNDEFINED}f(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readFloat32(this.bb_pos+a):0}i(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}s(a){let o=this.bb.__offset(this.bb_pos,14);return o?this.bb.__string(this.bb_pos+o,a):null}t(a){let o=this.bb.__offset(this.bb_pos,16);return o?(a||new _.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}g(a){let o=this.bb.__offset(this.bb_pos,18);return o?(a||new _.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}floats(a){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.readFloat32(this.bb.__vector(this.bb_pos+o)+4*a):0}floatsLength(){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__vector_len(this.bb_pos+a):0}floatsArray(){let a=this.bb.__offset(this.bb_pos,20);return a?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}ints(a){let o=this.bb.__offset(this.bb_pos,22);return o?this.bb.readInt64(this.bb.__vector(this.bb_pos+o)+8*a):this.bb.createLong(0,0)}intsLength(){let a=this.bb.__offset(this.bb_pos,22);return a?this.bb.__vector_len(this.bb_pos+a):0}strings(a,o){let d=this.bb.__offset(this.bb_pos,24);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*a,o):null}stringsLength(){let a=this.bb.__offset(this.bb_pos,24);return a?this.bb.__vector_len(this.bb_pos+a):0}tensors(a,o){let d=this.bb.__offset(this.bb_pos,26);return d?(o||new _.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}tensorsLength(){let a=this.bb.__offset(this.bb_pos,26);return a?this.bb.__vector_len(this.bb_pos+a):0}graphs(a,o){let d=this.bb.__offset(this.bb_pos,28);return d?(o||new _.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}graphsLength(){let a=this.bb.__offset(this.bb_pos,28);return a?this.bb.__vector_len(this.bb_pos+a):0}static startAttribute(a){a.startObject(13)}static addName(a,o){a.addFieldOffset(0,o,0)}static addDocString(a,o){a.addFieldOffset(1,o,0)}static addType(a,o){a.addFieldInt32(2,o,_.experimental.fbs.AttributeType.UNDEFINED)}static addF(a,o){a.addFieldFloat32(3,o,0)}static addI(a,o){a.addFieldInt64(4,o,a.createLong(0,0))}static addS(a,o){a.addFieldOffset(5,o,0)}static addT(a,o){a.addFieldOffset(6,o,0)}static addG(a,o){a.addFieldOffset(7,o,0)}static addFloats(a,o){a.addFieldOffset(8,o,0)}static createFloatsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addFloat32(o[d]);return a.endVector()}static startFloatsVector(a,o){a.startVector(4,o,4)}static addInts(a,o){a.addFieldOffset(9,o,0)}static createIntsVector(a,o){a.startVector(8,o.length,8);for(let d=o.length-1;d>=0;d--)a.addInt64(o[d]);return a.endVector()}static startIntsVector(a,o){a.startVector(8,o,8)}static addStrings(a,o){a.addFieldOffset(10,o,0)}static createStringsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startStringsVector(a,o){a.startVector(4,o,4)}static addTensors(a,o){a.addFieldOffset(11,o,0)}static createTensorsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startTensorsVector(a,o){a.startVector(4,o,4)}static addGraphs(a,o){a.addFieldOffset(12,o,0)}static createGraphsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startGraphsVector(a,o){a.startVector(4,o,4)}static endAttribute(a){return a.endObject()}static createAttribute(a,o,d,g,rt,st,tt,ot,it,at,ut,lt,ct,ft){return et.startAttribute(a),et.addName(a,o),et.addDocString(a,d),et.addType(a,g),et.addF(a,rt),et.addI(a,st),et.addS(a,tt),et.addT(a,ot),et.addG(a,it),et.addFloats(a,at),et.addInts(a,ut),et.addStrings(a,lt),et.addTensors(a,ct),et.addGraphs(a,ft),et.endAttribute(a)}}nt.Attribute=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsGraph(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsGraph(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}initializers(a,o){let d=this.bb.__offset(this.bb_pos,4);return d?(o||new _.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}initializersLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}nodeArgs(a,o){let d=this.bb.__offset(this.bb_pos,6);return d?(o||new _.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}nodeArgsLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}nodes(a,o){let d=this.bb.__offset(this.bb_pos,8);return d?(o||new _.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}nodesLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}maxNodeIndex(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readUint32(this.bb_pos+a):0}nodeEdges(a,o){let d=this.bb.__offset(this.bb_pos,12);return d?(o||new _.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}nodeEdgesLength(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__vector_len(this.bb_pos+a):0}inputs(a,o){let d=this.bb.__offset(this.bb_pos,14);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*a,o):null}inputsLength(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__vector_len(this.bb_pos+a):0}outputs(a,o){let d=this.bb.__offset(this.bb_pos,16);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*a,o):null}outputsLength(){let a=this.bb.__offset(this.bb_pos,16);return a?this.bb.__vector_len(this.bb_pos+a):0}sparseInitializers(a,o){let d=this.bb.__offset(this.bb_pos,18);return d?(o||new _.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}sparseInitializersLength(){let a=this.bb.__offset(this.bb_pos,18);return a?this.bb.__vector_len(this.bb_pos+a):0}static startGraph(a){a.startObject(8)}static addInitializers(a,o){a.addFieldOffset(0,o,0)}static createInitializersVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startInitializersVector(a,o){a.startVector(4,o,4)}static addNodeArgs(a,o){a.addFieldOffset(1,o,0)}static createNodeArgsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startNodeArgsVector(a,o){a.startVector(4,o,4)}static addNodes(a,o){a.addFieldOffset(2,o,0)}static createNodesVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startNodesVector(a,o){a.startVector(4,o,4)}static addMaxNodeIndex(a,o){a.addFieldInt32(3,o,0)}static addNodeEdges(a,o){a.addFieldOffset(4,o,0)}static createNodeEdgesVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startNodeEdgesVector(a,o){a.startVector(4,o,4)}static addInputs(a,o){a.addFieldOffset(5,o,0)}static createInputsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startInputsVector(a,o){a.startVector(4,o,4)}static addOutputs(a,o){a.addFieldOffset(6,o,0)}static createOutputsVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startOutputsVector(a,o){a.startVector(4,o,4)}static addSparseInitializers(a,o){a.addFieldOffset(7,o,0)}static createSparseInitializersVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startSparseInitializersVector(a,o){a.startVector(4,o,4)}static endGraph(a){return a.endObject()}static createGraph(a,o,d,g,rt,st,tt,ot,it){return et.startGraph(a),et.addInitializers(a,o),et.addNodeArgs(a,d),et.addNodes(a,g),et.addMaxNodeIndex(a,rt),et.addNodeEdges(a,st),et.addInputs(a,tt),et.addOutputs(a,ot),et.addSparseInitializers(a,it),et.endGraph(a)}}nt.Graph=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsModel(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsModel(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}irVersion(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}opsetImport(a,o){let d=this.bb.__offset(this.bb_pos,6);return d?(o||new _.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}opsetImportLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}producerName(a){let o=this.bb.__offset(this.bb_pos,8);return o?this.bb.__string(this.bb_pos+o,a):null}producerVersion(a){let o=this.bb.__offset(this.bb_pos,10);return o?this.bb.__string(this.bb_pos+o,a):null}domain(a){let o=this.bb.__offset(this.bb_pos,12);return o?this.bb.__string(this.bb_pos+o,a):null}modelVersion(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}docString(a){let o=this.bb.__offset(this.bb_pos,16);return o?this.bb.__string(this.bb_pos+o,a):null}graph(a){let o=this.bb.__offset(this.bb_pos,18);return o?(a||new _.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}graphDocString(a){let o=this.bb.__offset(this.bb_pos,20);return o?this.bb.__string(this.bb_pos+o,a):null}static startModel(a){a.startObject(9)}static addIrVersion(a,o){a.addFieldInt64(0,o,a.createLong(0,0))}static addOpsetImport(a,o){a.addFieldOffset(1,o,0)}static createOpsetImportVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startOpsetImportVector(a,o){a.startVector(4,o,4)}static addProducerName(a,o){a.addFieldOffset(2,o,0)}static addProducerVersion(a,o){a.addFieldOffset(3,o,0)}static addDomain(a,o){a.addFieldOffset(4,o,0)}static addModelVersion(a,o){a.addFieldInt64(5,o,a.createLong(0,0))}static addDocString(a,o){a.addFieldOffset(6,o,0)}static addGraph(a,o){a.addFieldOffset(7,o,0)}static addGraphDocString(a,o){a.addFieldOffset(8,o,0)}static endModel(a){return a.endObject()}static createModel(a,o,d,g,rt,st,tt,ot,it,at){return et.startModel(a),et.addIrVersion(a,o),et.addOpsetImport(a,d),et.addProducerName(a,g),et.addProducerVersion(a,rt),et.addDomain(a,st),et.addModelVersion(a,tt),et.addDocString(a,ot),et.addGraph(a,it),et.addGraphDocString(a,at),et.endModel(a)}}nt.Model=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsKernelCreateInfos(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsKernelCreateInfos(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}nodeIndices(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.readUint32(this.bb.__vector(this.bb_pos+o)+4*a):0}nodeIndicesLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}nodeIndicesArray(){let a=this.bb.__offset(this.bb_pos,4);return a?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}kernelDefHashes(a){let o=this.bb.__offset(this.bb_pos,6);return o?this.bb.readUint64(this.bb.__vector(this.bb_pos+o)+8*a):this.bb.createLong(0,0)}kernelDefHashesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}static startKernelCreateInfos(a){a.startObject(2)}static addNodeIndices(a,o){a.addFieldOffset(0,o,0)}static createNodeIndicesVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addInt32(o[d]);return a.endVector()}static startNodeIndicesVector(a,o){a.startVector(4,o,4)}static addKernelDefHashes(a,o){a.addFieldOffset(1,o,0)}static createKernelDefHashesVector(a,o){a.startVector(8,o.length,8);for(let d=o.length-1;d>=0;d--)a.addInt64(o[d]);return a.endVector()}static startKernelDefHashesVector(a,o){a.startVector(8,o,8)}static endKernelCreateInfos(a){return a.endObject()}static createKernelCreateInfos(a,o,d){return et.startKernelCreateInfos(a),et.addNodeIndices(a,o),et.addKernelDefHashes(a,d),et.endKernelCreateInfos(a)}}nt.KernelCreateInfos=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsSubGraphSessionState(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSubGraphSessionState(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}graphId(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}sessionState(a){let o=this.bb.__offset(this.bb_pos,6);return o?(a||new _.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startSubGraphSessionState(a){a.startObject(2)}static addGraphId(a,o){a.addFieldOffset(0,o,0)}static addSessionState(a,o){a.addFieldOffset(1,o,0)}static endSubGraphSessionState(a){let o=a.endObject();return a.requiredField(o,4),o}static createSubGraphSessionState(a,o,d){return et.startSubGraphSessionState(a),et.addGraphId(a,o),et.addSessionState(a,d),et.endSubGraphSessionState(a)}}nt.SubGraphSessionState=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsSessionState(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSessionState(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}kernels(a){let o=this.bb.__offset(this.bb_pos,4);return o?(a||new _.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}subGraphSessionStates(a,o){let d=this.bb.__offset(this.bb_pos,6);return d?(o||new _.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*a),this.bb):null}subGraphSessionStatesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}static startSessionState(a){a.startObject(2)}static addKernels(a,o){a.addFieldOffset(0,o,0)}static addSubGraphSessionStates(a,o){a.addFieldOffset(1,o,0)}static createSubGraphSessionStatesVector(a,o){a.startVector(4,o.length,4);for(let d=o.length-1;d>=0;d--)a.addOffset(o[d]);return a.endVector()}static startSubGraphSessionStatesVector(a,o){a.startVector(4,o,4)}static endSessionState(a){return a.endObject()}static createSessionState(a,o,d){return et.startSessionState(a),et.addKernels(a,o),et.addSubGraphSessionStates(a,d),et.endSessionState(a)}}nt.SessionState=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(_){(function(j){(function(nt){class et{constructor(){this.bb=null,this.bb_pos=0}__init(a,o){return this.bb_pos=a,this.bb=o,this}static getRootAsInferenceSession(a,o){return(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsInferenceSession(a,o){return a.setPosition(a.position()+c.flatbuffers.SIZE_PREFIX_LENGTH),(o||new et).__init(a.readInt32(a.position())+a.position(),a)}static bufferHasIdentifier(a){return a.__has_identifier("ORTM")}ortVersion(a){let o=this.bb.__offset(this.bb_pos,4);return o?this.bb.__string(this.bb_pos+o,a):null}model(a){let o=this.bb.__offset(this.bb_pos,6);return o?(a||new _.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}sessionState(a){let o=this.bb.__offset(this.bb_pos,8);return o?(a||new _.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+o),this.bb):null}static startInferenceSession(a){a.startObject(3)}static addOrtVersion(a,o){a.addFieldOffset(0,o,0)}static addModel(a,o){a.addFieldOffset(1,o,0)}static addSessionState(a,o){a.addFieldOffset(2,o,0)}static endInferenceSession(a){return a.endObject()}static finishInferenceSessionBuffer(a,o){a.finish(o,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(a,o){a.finish(o,"ORTM",!0)}static createInferenceSession(a,o,d,g){return et.startInferenceSession(a),et.addOrtVersion(a,o),et.addModel(a,d),et.addSessionState(a,g),et.endInferenceSession(a)}}nt.InferenceSession=et})(j.fbs||(j.fbs={}))})(_.experimental||(_.experimental={}))}(e.onnxruntime||(e.onnxruntime={}))},7448:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxjsSessionHandler=void 0;const c=s(1670),h=s(9162);e.OnnxjsSessionHandler=class{constructor($){this.session=$,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run($,_,j){const nt=new Map;for(const a in $)if(Object.hasOwnProperty.call($,a)){const o=$[a];nt.set(a,new h.Tensor(o.dims,o.type,void 0,void 0,o.data))}const et=await this.session.run(nt),b={};return et.forEach((a,o)=>{b[o]=new c.Tensor(a.type,a.data,a.dims)}),b}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6919:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Session=void 0;const c=s(7067),h=s(1296),$=s(7091),_=s(1036),j=s(6231),nt=s(2644);e.Session=class{constructor(et={}){this._initialized=!1,this.backendHint=et.backendHint,this.profiler=j.Profiler.create(et.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(et,b,a){await this.profiler.event("session","Session.loadModel",async()=>{const o=await(0,$.resolveBackend)(this.backendHint);if(this.sessionHandler=o.createSessionHandler(this.context),this._model=new nt.Model,typeof et=="string"){const d=et.endsWith(".ort");if(typeof fetch>"u"){const g=await(0,h.promisify)(c.readFile)(et);this.initialize(g,d)}else{const g=await fetch(et),rt=await g.arrayBuffer();this.initialize(new Uint8Array(rt),d)}}else if(ArrayBuffer.isView(et))this.initialize(et);else{const d=new Uint8Array(et,b||0,a||et.byteLength);this.initialize(d)}})}initialize(et,b){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const a=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(et,a,b),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new _.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(et){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const b=this.normalizeAndValidateInputs(et),a=await this._executionPlan.execute(this.sessionHandler,b);return this.createOutput(a)})}normalizeAndValidateInputs(et){const b=this._model.graph.getInputNames();if(Array.isArray(et)){if(et.length!==b.length)throw new Error(`incorrect input array length: expected ${b.length} but got ${et.length}`)}else{if(et.size!==b.length)throw new Error(`incorrect input map size: expected ${b.length} but got ${et.size}`);const a=new Array(et.size);let o=0;for(let d=0;d<b.length;++d){const g=et.get(b[d]);if(!g)throw new Error(`missing input tensor for: '${name}'`);a[o++]=g}et=a}if(this.context.graphInputTypes&&this.context.graphInputTypes.length!==0&&this.context.graphInputDims&&this.context.graphInputDims.length!==0)this.validateInputTensorDims(this.context.graphInputDims,et,!1);else{const a=this._model.graph.getInputIndices(),o=this._model.graph.getValues(),d=new Array(a.length);for(let g=0;g<a.length;++g){const rt=o[a[g]];d[g]=rt.type.shape.dims,this.context.graphInputTypes.push(rt.type.tensorType),this.context.graphInputDims.push(et[g].dims)}this.validateInputTensorDims(d,et,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,et),et}validateInputTensorTypes(et,b){for(let a=0;a<b.length;a++){const o=et[a],d=b[a].type;if(o!==d)throw new Error(`input tensor[${a}] check failed: expected type '${o}' but got ${d}`)}}validateInputTensorDims(et,b,a){for(let o=0;o<b.length;o++){const d=et[o],g=b[o].dims;if(!this.compareTensorDims(d,g,a))throw new Error(`input tensor[${o}] check failed: expected shape '[${d.join(",")}]' but got [${g.join(",")}]`)}}compareTensorDims(et,b,a){if(et.length!==b.length)return!1;for(let o=0;o<et.length;++o)if(et[o]!==b[o]&&(!a||et[o]!==0))return!1;return!0}createOutput(et){const b=this._model.graph.getOutputNames();if(et.length!==b.length)throw new Error("expected number of outputs do not match number of generated outputs");const a=new Map;for(let o=0;o<b.length;++o)a.set(b[o],et[o]);return a}initializeOps(et){const b=et.getNodes();this._ops=new Array(b.length);for(let a=0;a<b.length;a++)this._ops[a]=this.sessionHandler.resolve(b[a],this._model.opsets,et)}}},9162:function(i,e,s){var c=this&&this.__importDefault||function(rt){return rt&&rt.__esModule?rt:{default:rt}};Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const h=s(3442),$=c(s(3720)),_=s(1446),j=s(9395),nt=s(2517);var et=j.onnxruntime.experimental.fbs;class b{get data(){if(this.cache===void 0){const st=this.dataProvider(this.dataId);if(st.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=st}return this.cache}get stringData(){if(this.type!=="string")throw new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if(this.type!=="string")return this.data;throw new TypeError("type cannot be non-number (string)")}get(st){return this.data[nt.ShapeUtil.indicesToOffset(st,this.strides)]}set(st,tt){this.data[nt.ShapeUtil.indicesToOffset(st,this.strides)]=tt}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=nt.ShapeUtil.computeStrides(this.dims)),this._strides}constructor(st,tt,ot,it,at,ut=h.Guid.create()){this.dims=st,this.type=tt,this.dataProvider=ot,this.asyncDataProvider=it,this.cache=at,this.dataId=ut,this.size=nt.ShapeUtil.validateDimsAndCalcSize(st);const lt=this.size,ct=ot===void 0&&it===void 0&&at===void 0;if(at!==void 0&&at.length!==lt)throw new RangeError("Input dims doesn't match data length.");if(tt==="string"){if(!(at===void 0||Array.isArray(at)&&at.every(ft=>typeof ft=="string")))throw new TypeError("cache should be a string array");ct&&(this.cache=new Array(lt))}else{if(at!==void 0){const ft=o(tt);if(!(at instanceof ft))throw new TypeError(`cache should be type ${ft.name}`)}if(ct){const ft=new ArrayBuffer(lt*function(dt){switch(dt){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${dt}`)}}(tt));this.cache=function(dt,yt){return new(o(yt))(dt)}(ft,tt)}}}static fromProto(st){if(!st)throw new Error("cannot construct Value from an empty tensor");const tt=nt.ProtoUtil.tensorDataTypeFromProto(st.dataType),ot=nt.ProtoUtil.tensorDimsFromProto(st.dims),it=new b(ot,tt);if(tt==="string")st.stringData.forEach((at,ut)=>{it.data[ut]=(0,nt.decodeUtf8String)(at)});else if(st.rawData&&typeof st.rawData.byteLength=="number"&&st.rawData.byteLength>0){const at=it.data,ut=new DataView(st.rawData.buffer,st.rawData.byteOffset,st.rawData.byteLength),lt=a(st.dataType),ct=st.rawData.byteLength/lt;if(st.rawData.byteLength%lt!=0)throw new Error("invalid buffer length");if(at.length!==ct)throw new Error("buffer length mismatch");for(let ft=0;ft<ct;ft++){const dt=g(ut,st.dataType,ft*lt);at[ft]=dt}}else{let at;switch(st.dataType){case _.onnx.TensorProto.DataType.FLOAT:at=st.floatData;break;case _.onnx.TensorProto.DataType.INT32:case _.onnx.TensorProto.DataType.INT16:case _.onnx.TensorProto.DataType.UINT16:case _.onnx.TensorProto.DataType.INT8:case _.onnx.TensorProto.DataType.UINT8:case _.onnx.TensorProto.DataType.BOOL:at=st.int32Data;break;case _.onnx.TensorProto.DataType.INT64:at=st.int64Data;break;case _.onnx.TensorProto.DataType.DOUBLE:at=st.doubleData;break;case _.onnx.TensorProto.DataType.UINT32:case _.onnx.TensorProto.DataType.UINT64:at=st.uint64Data;break;default:throw new Error("unspecific error")}if(at==null)throw new Error("failed to populate data from a tensorproto value");const ut=it.data;if(ut.length!==at.length)throw new Error("array length mismatch");for(let lt=0;lt<at.length;lt++){const ct=at[lt];$.default.isLong(ct)?ut[lt]=d(ct,st.dataType):ut[lt]=ct}}return it}static fromData(st,tt,ot){return new b(tt,ot,void 0,void 0,st)}static fromOrtTensor(st){if(!st)throw new Error("cannot construct Value from an empty tensor");const tt=nt.ProtoUtil.tensorDimsFromORTFormat(st),ot=nt.ProtoUtil.tensorDataTypeFromProto(st.dataType()),it=new b(tt,ot);if(ot==="string")for(let at=0;at<st.stringDataLength();at++)it.data[at]=st.stringData(at);else if(st.rawDataArray()&&typeof st.rawDataLength()=="number"&&st.rawDataLength()>0){const at=it.data,ut=new DataView(st.rawDataArray().buffer,st.rawDataArray().byteOffset,st.rawDataLength()),lt=a(st.dataType()),ct=st.rawDataLength()/lt;if(st.rawDataLength()%lt!=0)throw new Error("invalid buffer length");if(at.length!==ct)throw new Error("buffer length mismatch");for(let ft=0;ft<ct;ft++){const dt=g(ut,st.dataType(),ft*lt);at[ft]=dt}}return it}}function a(rt){switch(rt){case _.onnx.TensorProto.DataType.UINT8:case _.onnx.TensorProto.DataType.INT8:case _.onnx.TensorProto.DataType.BOOL:return 1;case _.onnx.TensorProto.DataType.UINT16:case _.onnx.TensorProto.DataType.INT16:return 2;case _.onnx.TensorProto.DataType.FLOAT:case _.onnx.TensorProto.DataType.INT32:case _.onnx.TensorProto.DataType.UINT32:return 4;case _.onnx.TensorProto.DataType.INT64:case _.onnx.TensorProto.DataType.DOUBLE:case _.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${_.onnx.TensorProto.DataType[rt]}`)}}function o(rt){switch(rt){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function d(rt,st){if(st===_.onnx.TensorProto.DataType.INT64||st===et.TensorDataType.INT64){if(rt.greaterThanOrEqual(2147483648)||rt.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else{if(st!==_.onnx.TensorProto.DataType.UINT32&&st!==et.TensorDataType.UINT32&&st!==_.onnx.TensorProto.DataType.UINT64&&st!==et.TensorDataType.UINT64)throw new TypeError(`not a LONG type: ${_.onnx.TensorProto.DataType[st]}`);if(rt.greaterThanOrEqual(4294967296)||rt.lessThan(0))throw new TypeError("uint64 is not supported")}return rt.toNumber()}function g(rt,st,tt){switch(st){case _.onnx.TensorProto.DataType.BOOL:case _.onnx.TensorProto.DataType.UINT8:return rt.getUint8(tt);case _.onnx.TensorProto.DataType.INT8:return rt.getInt8(tt);case _.onnx.TensorProto.DataType.UINT16:return rt.getUint16(tt,!0);case _.onnx.TensorProto.DataType.INT16:return rt.getInt16(tt,!0);case _.onnx.TensorProto.DataType.FLOAT:return rt.getFloat32(tt,!0);case _.onnx.TensorProto.DataType.INT32:return rt.getInt32(tt,!0);case _.onnx.TensorProto.DataType.UINT32:return rt.getUint32(tt,!0);case _.onnx.TensorProto.DataType.INT64:return d($.default.fromBits(rt.getUint32(tt,!0),rt.getUint32(tt+4,!0),!1),st);case _.onnx.TensorProto.DataType.DOUBLE:return rt.getFloat64(tt,!0);case _.onnx.TensorProto.DataType.UINT64:return d($.default.fromBits(rt.getUint32(tt,!0),rt.getUint32(tt+4,!0),!0),st);default:throw new Error(`cannot read from DataView for type ${_.onnx.TensorProto.DataType[st]}`)}}e.Tensor=b},2517:function(i,e,s){var c=this&&this.__importDefault||function(st){return st&&st.__esModule?st:{default:st}};Object.defineProperty(e,"__esModule",{value:!0}),e.decodeUtf8String=e.MAX_CLIP=e.MIN_CLIP=e.PoolConvUtil=e.ReduceUtil=e.SplitUtil=e.MathUtil=e.ShapeUtil=e.LongUtil=e.ProtoUtil=e.GemmUtil=e.arrayCopyHelper=e.BroadcastUtil=e.MatMulUtil=e.ArrayUtil=e.assert=e.checkInputsShape=void 0;const h=s(5686),$=c(s(3720)),_=s(1446),j=s(9162);e.checkInputsShape=function(st,...tt){if(!st||st.length!==tt.length)return!1;for(let ot=0;ot<st.length;ot++)if(!st[ot].dims||st[ot].dims.length!==tt[ot])return!1;return!0},e.assert=function(st,tt){if(!st)throw new Error(typeof tt=="string"?tt:tt())},e.ArrayUtil=class{static arraysEqual(st,tt){if(st.length!==tt.length)return!1;for(let ot=0;ot<st.length;ot++)if(st[ot]!==tt[ot])return!1;return!0}};class nt{static preprocessInputShapes(tt,ot){return[tt.length===1?[1,tt[0]]:tt,ot.length===1?[ot[0],1]:ot]}static postprocessOutputShape(tt,ot,it){ot===1&&tt.splice(tt.length-2,1),it===1&&tt.pop()}static calcMatMulShape(tt,ot){return tt[1]!==ot[0]?void 0:[tt[0],ot[1]]}}e.MatMulUtil=nt;class et{static calcShape(tt,ot,it=!1){const at=tt.length,ut=ot.length;if(at===0)return ot;if(ut===0)return tt;const lt=Math.max(tt.length,ot.length),ct=new Array(lt);if(it){if(at<2||ut<2)return;const ft=nt.calcMatMulShape([tt[at-2],tt[at-1]],[ot[ut-2],ot[ut-1]]);if(ft===void 0)return;[ct[lt-2],ct[lt-1]]=ft}for(let ft=it?3:1;ft<=lt;ft++){const dt=at-ft<0?1:tt[at-ft],yt=ut-ft<0?1:ot[ut-ft];if(dt!==yt&&dt>1&&yt>1)return;ct[lt-ft]=Math.max(dt,yt)}return ct}static index(tt,ot){const it=new Array(ot.length);return et.fillIndex(tt,ot,it),it}static fillIndex(tt,ot,it){const at=tt.length-ot.length;for(let ut=0;ut<ot.length;ut++)it[ut]=tt[at+ut]%ot[ut]}static calc(tt,ot,it,at,ut){const lt=et.calcShape(tt.dims,ot.dims);if(lt){if(at&&!o.areEqual(lt,tt.dims))return;const ct=o.size(lt),ft=at?tt:new j.Tensor(lt,ut||tt.type);if(lt.length===0)ft.set([],it(tt.get([]),ot.get([])));else{const dt=new Array(lt.length),yt=new Array(tt.dims.length),St=new Array(ot.dims.length);let bt,Tt=0,vt=0,$t=!1,At=!1;tt.dims.length===0&&(Tt=tt.get([]),$t=!0),ot.dims.length===0&&(vt=ot.get([]),At=!0);for(let Ot=0;Ot<ct;Ot++){bt=Ot;for(let It=lt.length-1;It>=0;It--)dt[It]=bt%lt[It],bt=Math.floor(bt/lt[It]);$t||(et.fillIndex(dt,tt.dims,yt),Tt=tt.get(yt)),At||(et.fillIndex(dt,ot.dims,St),vt=ot.get(St)),ft.set(dt,it(Tt,vt))}}return ft}}static isValidBroadcast(tt,ot){const it=tt.length,at=ot.length;if(it>at)return!1;for(let ut=1;ut<=it;ut++)if(tt[it-ut]!==1&&tt[it-ut]!==ot[at-ut])return!1;return!0}static getBroadcastDims(tt,ot){const it=tt.length,at=[];for(let ut=0;ut<it;ut++){const lt=it-1-ut,ct=tt[lt]||1;(ot[ot.length-1-ut]||1)>1&&ct===1&&at.unshift(lt)}return at}}e.BroadcastUtil=et,e.arrayCopyHelper=function(st,tt,ot,it,at){if(it<0||it>=tt.length)throw new Error("sourceIndex out of bounds");if(ot<0||ot>=st.length)throw new Error("targetIndex out of bounds");if(it+at>tt.length)throw new Error("source indices to be copied are outside bounds");if(ot+at>st.length)throw new Error("target array is too small to hold result");for(let ut=0;ut<at;ut++)st[ot+ut]=tt[it+ut]},e.GemmUtil=class{static getShapeOfGemmResult(st,tt,ot,it,at){if(st.length!==2||ot.length!==2)throw new Error("shape need to be of size 2");let ut,lt,ct;tt?(ut=st[1],lt=st[0]):(ut=st[0],lt=st[1]);let ft=-1;if(it?(ct=ot[0],ft=1):(ct=ot[1],ft=0),ot[ft]!==lt)throw new Error("dimension mismatch");if(ut<=0||ct<=0||lt<=0)throw new Error("invalid shape specified");if(at&&!et.isValidBroadcast(at,[ut,ct]))throw new Error("gemm: invalid bias shape for broadcast");return[ut,ct,lt]}};class b{static tensorDataTypeFromProto(tt){switch(tt){case _.onnx.TensorProto.DataType.INT8:return"int8";case _.onnx.TensorProto.DataType.UINT8:return"uint8";case _.onnx.TensorProto.DataType.BOOL:return"bool";case _.onnx.TensorProto.DataType.INT16:return"int16";case _.onnx.TensorProto.DataType.UINT16:return"uint16";case _.onnx.TensorProto.DataType.INT32:return"int32";case _.onnx.TensorProto.DataType.UINT32:return"uint32";case _.onnx.TensorProto.DataType.FLOAT:return"float32";case _.onnx.TensorProto.DataType.DOUBLE:return"float64";case _.onnx.TensorProto.DataType.STRING:return"string";case _.onnx.TensorProto.DataType.INT64:return"int32";case _.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${_.onnx.TensorProto.DataType[tt]}`)}}static tensorDataTypeStringToEnum(tt){switch(tt){case"int8":return _.onnx.TensorProto.DataType.INT8;case"uint8":return _.onnx.TensorProto.DataType.UINT8;case"bool":return _.onnx.TensorProto.DataType.BOOL;case"int16":return _.onnx.TensorProto.DataType.INT16;case"uint16":return _.onnx.TensorProto.DataType.UINT16;case"int32":return _.onnx.TensorProto.DataType.INT32;case"uint32":return _.onnx.TensorProto.DataType.UINT32;case"float32":return _.onnx.TensorProto.DataType.FLOAT;case"float64":return _.onnx.TensorProto.DataType.DOUBLE;case"string":return _.onnx.TensorProto.DataType.STRING;case"int64":return _.onnx.TensorProto.DataType.INT64;case"uint64":return _.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${tt}`)}}static tensorDimsFromProto(tt){return tt.map(ot=>$.default.isLong(ot)?ot.toNumber():ot)}static tensorValueTypeFromProto(tt){return{tensorType:b.tensorDataTypeFromProto(tt.elemType),shape:{dims:b.tensorDimsFromProto(tt.shape.dim.map(ot=>ot.dimValue))}}}static tensorDimsFromORTFormat(tt){const ot=[];for(let it=0;it<tt.dimsLength();it++)ot.push(a.longToNumber(tt.dims(it)));return ot}static tensorAttributesFromORTFormat(tt){const ot=[];for(let it=0;it<tt.attributesLength();it++)ot.push(tt.attributes(it));return ot}}e.ProtoUtil=b;class a{static longToNumber(tt,ot){return $.default.isLong(tt)?tt.toNumber():tt instanceof h.flatbuffers.Long?$.default.fromValue({low:tt.low,high:tt.high,unsigned:ot!=null&&ot}).toNumber():tt}static isLong(tt){return $.default.isLong(tt)||tt instanceof h.flatbuffers.Long}}e.LongUtil=a;class o{static size(tt){return o.getSizeFromDimensionRange(tt,0,tt.length)}static sizeFromDimension(tt,ot){if(ot<0||ot>tt.length)throw new Error(`invalid dimension of ${ot} for sizeFromDimension as Tensor has ${tt.length} dimensions.`);return o.getSizeFromDimensionRange(tt,ot,tt.length)}static sizeToDimension(tt,ot){if(ot<0||ot>tt.length)throw new Error(`invalid dimension of ${ot} for sizeToDimension as Tensor has ${tt.length} dimensions.`);return o.getSizeFromDimensionRange(tt,0,ot)}static getSizeFromDimensionRange(tt,ot,it){let at=1;for(let ut=ot;ut<it;ut++){if(tt[ut]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");at*=tt[ut]}return at}static computeStrides(tt){const ot=tt.length;if(ot===0)return[];if(ot===1)return[1];const it=new Array(ot);it[ot-1]=1,it[ot-2]=tt[ot-1];for(let at=ot-3;at>=0;--at)it[at]=it[at+1]*tt[at+1];return it}static transpose(tt){return tt.slice().reverse()}static indicesToOffset(tt,ot,it){it===void 0&&(it=tt.length);let at=0;for(let ut=0;ut<it;++ut)at+=ot[ut]*tt[ut];return at}static offsetToIndices(tt,ot){const it=ot.length;if(it===0)return[];if(it===1)return[tt*ot[0]];const at=new Array(ot.length);for(let ut=0;ut<at.length-1;++ut)at[ut]=Math.floor(tt/ot[ut]),tt-=at[ut]*ot[ut];return at[at.length-1]=tt,at}static normalizeAxis(tt,ot){if(tt<-ot&&tt>=ot)throw new Error("unsupported axis for this operation.");return tt<0?tt+ot:tt}static normalizeAxes(tt,ot){return tt.map(it=>this.normalizeAxis(it,ot))}static incrementIndex(tt,ot,it){if(ot.length===0||tt.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(it===void 0)it=ot.length;else if(it<=0||it>ot.length)throw new Error("Incorrect axis to increment on");for(let at=it-1;at>=0&&(tt[at]++,!(tt[at]<ot[at]));--at)tt[at]=0}static calculateReshapedDims(tt,ot){if(ot.length===0){if(tt.length===0||o.size(tt)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}const it=ot.length,at=new Array(it);let ut=-1,lt=1;for(let ft=0;ft<it;ft++){if(ot[ft]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(ot[ft]===-1){if(ut!==-1)throw new Error("at most one dimension in shape hints can be -1");ut=ft}else{if(ot[ft]===0){if(ft>=tt.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");at[ft]=tt[ft]}else at[ft]=ot[ft];lt*=at[ft]}}const ct=o.size(tt);if(ut!==-1){if(ct%lt!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${tt}] Output shape: [${ot}]`);at[ut]=ct/lt}else if(lt!==ct)throw new Error("reshapedDims and originalDims don't have matching sizes");return at}static sortBasedOnPerm(tt,ot){return ot?ot.map(it=>tt[it]):tt.slice().reverse()}static padShape(tt,ot){const it=tt.length;return tt.map((at,ut)=>at+ot[ut]+ot[ut+it])}static areEqual(tt,ot){return tt.length===ot.length&&tt.every((it,at)=>it===ot[at])}static validateDimsAndCalcSize(tt){if(tt.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let ot=1;for(const it of tt){if(!Number.isInteger(it))throw new TypeError(`Invalid shape: ${it} is not an integer`);if(it<0||it>2147483647)throw new TypeError(`Invalid shape: length ${it} is not allowed`);ot*=it}return ot}static flattenShape(tt,ot){ot<0&&(ot+=tt.length);const it=tt.reduce((ut,lt)=>ut*lt,1),at=tt.slice(ot).reduce((ut,lt)=>ut*lt,1);return[it/at,at]}static squeezeShape(tt,ot){const it=new Array;ot=o.normalizeAxes(ot,tt.length);for(let at=0;at<tt.length;at++){const ut=ot.indexOf(at)>=0;if(ut&&tt[at]!==1)throw new Error("squeeze an axis of size different than 1");(ot.length===0&&tt[at]>1||ot.length>0&&!ut)&&it.push(tt[at])}return it}static unsqueezeShape(tt,ot){const it=new Array(tt.length+ot.length);it.fill(0);for(let ut=0;ut<ot.length;ut++){const lt=o.normalizeAxis(ot[ut],it.length);if(lt>=it.length)throw new Error("'axes' has an out of range axis");if(it[lt]!==0)throw new Error("'axes' has a duplicate axis");it[lt]=1}let at=0;for(let ut=0;ut<it.length;ut++)it[ut]===0&&(it[ut]=tt[at++]);if(at!==tt.length)throw new Error("the unsqueezed dimension could not be established");return it}}e.ShapeUtil=o,e.MathUtil=class{static sqr(st,tt,ot,it,at){if(it<0||it>=tt.length)throw new Error("sourceIndex out of bounds");if(ot<0||ot>=st.length)throw new Error("targetIndex out of bounds");if(it+at>tt.length)throw new Error("source indices to be copied are outside bounds");if(ot+at>st.length)throw new Error("target array is too small to hold result");for(let ut=0;ut<at;ut++)st[ot+ut]+=Math.pow(tt[it+ut],2)}static axpy(st,tt,ot,it,at,ut){if(it<0||it>=tt.length)throw new Error("sourceIndex out of bounds");if(ot<0||ot>=st.length)throw new Error("targetIndex out of bounds");if(it+at>tt.length)throw new Error("source indices to be copied are outside bounds");if(ot+at>st.length)throw new Error("target array is too small to hold result");for(let lt=0;lt<at;lt++)st[ot+lt]+=ut*tt[it+lt]}static powx(st,tt,ot,it,at,ut){if(it<0||it>=tt.length)throw new Error("sourceIndex out of bounds");if(ot<0||ot>=st.length)throw new Error("targetIndex out of bounds");if(it+at>tt.length)throw new Error("source indices to be copied are outside bounds");if(ot+at>st.length)throw new Error("target array is too small to hold result");for(let lt=0;lt<at;lt++)st[ot+lt]=Math.pow(tt[it+lt],ut)}static mul(st,tt,ot,it,at){if(it<0||it>=tt.length)throw new Error("sourceIndex out of bounds");if(ot<0||ot>=st.length)throw new Error("targetIndex out of bounds");if(it+at>tt.length)throw new Error("source indices to be copied are outside bounds");if(ot+at>st.length)throw new Error("target array is too small to hold result");for(let ut=0;ut<at;ut++)st[ot+ut]=tt[it+ut]*st[ot+ut]}};class d{static splitShape(tt,ot,it,at){if(it.length===0){if(!at)throw new Error("need to know number of outputs when the 'split' attribute is not specified");d.determineSplit(tt[ot],at,it)}const ut=[],lt=[0];for(let ct=0;ct<it.length;++ct){ct!==0&<.push(lt[ct-1]+it[ct-1]);const ft=tt.slice();ft[ot]=it[ct],ut.push(ft)}return[ut,lt]}static determineSplit(tt,ot,it){if(tt%ot!=0)throw new Error("cannot split tensor to equal sized parts");for(let at=0;at<ot;++at)it.push(tt/ot)}}e.SplitUtil=d;class g{static calcReduce(tt,ot,it,at,ut){const lt=tt.dims.slice(0);ot.length===0&<.forEach((Tt,vt)=>ot.push(vt));const ct=g.calcReduceShape(lt,ot,!0),ft=o.size(ct),dt=new j.Tensor(ct,tt.type),yt=o.computeStrides(ct),St=o.computeStrides(lt),bt=new Array(lt.length);for(let Tt=0;Tt<ft;Tt++){const vt=o.offsetToIndices(Tt,yt);et.fillIndex(vt,lt,bt),dt.set(vt,g.calcReduceByAxis(tt.numberData,ot,lt,0,o.indicesToOffset(bt,St),at,ut))}return it?dt:new j.Tensor(g.calcReduceShape(lt,ot,it),dt.type,void 0,void 0,dt.data,dt.dataId)}static calcReduceByAxis(tt,ot,it,at,ut,lt,ct){let ft=0;if(at>=ot.length)return lt(tt[ut]);const dt=ot[at],yt=dt>=it.length?1:o.size(it.slice(dt+1));for(let St=0;St<it[dt];St++)ft=St===0?g.calcReduceByAxis(tt,ot,it,at+1,ut,lt,ct):ct(ft,g.calcReduceByAxis(tt,ot,it,at+1,ut,lt,ct)),ut+=yt;return ft}static calcReduceShape(tt,ot,it){const at=tt.slice();for(let ut=0;ut<ot.length;ut++)at[ot[ut]]=it?1:0;return at.filter(ut=>ut!==0)}}e.ReduceUtil=g;class rt{static adjustPoolAttributes(tt,ot,it,at,ut,lt){if(!tt&&it.length!==ot.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(tt)for(let ct=0;ct<ot.length-2;ct++)ct>=it.length?it.push(ot[ct+2]):it[ct]=ot[ct+2];for(let ct=0;ct<it.length;ct++)if(ct<at.length){if(at[ct]<0)throw new Error("strides should be greater than or equal to 1")}else at.push(1);for(let ct=0;ct<it.length;ct++)if(ct<ut.length){if(ut[ct]<0)throw new Error("dilations should be greater than or equal to 1")}else ut.push(1);for(let ct=0;ct<2*it.length;ct++)if(ct<lt.length){if(lt[ct]<0)throw new Error("pad should be greater than or equal to 1")}else lt.push(0);for(let ct=0;ct<it.length;ct++){if(it[ct]<=0)throw new Error("kernel shapes need to be greater than 0");if(lt[ct]>=it[ct]||lt[ct+it.length]>=it[ct])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(tt,ot,it,at,ut,lt){if(lt){if(ut.length!==2*(tt.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(ot.length!==tt.length-2)throw new Error("length of strides should be the length of data dimensions");if(at.length!==tt.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let ct=0;ct<tt.length-2;ct++)rt.adjustPadAndReturnShape(tt[ct+2],ot[ct],it[ct],at[ct],ut,ct,ct+tt.length-2,lt)}}static computePoolOutputShape(tt,ot,it,at,ut,lt,ct){if(ot.length<=0)throw new Error("input shape must be of size greater than 0");const ft=[ot[0],ot[1]];return rt.computeShapeHelper(tt,ot,ft,it,at,ut,lt,ct),ft}static computeConvOutputShape(tt,ot,it,at,ut,lt,ct){if(tt.length<=0||ot.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const ft=[tt[0],ot[0]];return rt.computeShapeHelper(!1,tt,ft,it,at,ut,lt,ct),ft}static computeShapeHelper(tt,ot,it,at,ut,lt,ct,ft){if(tt)for(let dt=0;dt<ot.length-2;dt++)it.push(1);else for(let dt=0;dt<ot.length-2;dt++)it.push(rt.adjustPadAndReturnShape(ot[dt+2],at[dt],ut[dt],lt[dt],ct,dt,dt+ot.length-2,ft))}static adjustPadAndReturnShape(tt,ot,it,at,ut,lt,ct,ft){const dt=it*(at-1)+1;if(!ft||ft==="NOTSET")return Math.floor((tt+ut[lt]+ut[ct]-dt)/ot+1);switch(ft){case"VALID":return ut[lt]=0,ut[ct]=0,Math.floor((tt-dt)/ot+1);case"SAME_LOWER":case"SAME_UPPER":if(it!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{const yt=((tt+ot-1)/ot-1)*ot+at-tt;return ut[lt]=Math.floor(ft==="SAME_LOWER"?(yt+1)/2:yt/2),ut[ct]=yt-ut[lt],Math.floor((tt+yt-at)/ot+1)}default:throw new Error("Unsupported AutoPad type")}}}e.PoolConvUtil=rt,e.MIN_CLIP=-34028234663852886e22,e.MAX_CLIP=34028234663852886e22,e.decodeUtf8String=function(st){return new TextDecoder().decode(st)}},7967:(i,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.iterateExtraOptions=void 0,e.iterateExtraOptions=(s,c,h,$)=>{if(typeof s=="object"&&s!==null){if(h.has(s))throw new Error("Circular reference in options");h.add(s)}Object.entries(s).forEach(([_,j])=>{const nt=c?c+_:_;if(typeof j=="object")(0,e.iterateExtraOptions)(j,nt+".",h,$);else if(typeof j=="string"||typeof j=="number")$(nt,j.toString());else{if(typeof j!="boolean")throw new Error("Can't handle extra config type: "+typeof j);$(nt,j?"1":"0")}})}},2157:function(i,e,s){var c,h=this&&this.__createBinding||(Object.create?function(yt,St,bt,Tt){Tt===void 0&&(Tt=bt);var vt=Object.getOwnPropertyDescriptor(St,bt);vt&&!("get"in vt?!St.__esModule:vt.writable||vt.configurable)||(vt={enumerable:!0,get:function(){return St[bt]}}),Object.defineProperty(yt,Tt,vt)}:function(yt,St,bt,Tt){Tt===void 0&&(Tt=bt),yt[Tt]=St[bt]}),$=this&&this.__setModuleDefault||(Object.create?function(yt,St){Object.defineProperty(yt,"default",{enumerable:!0,value:St})}:function(yt,St){yt.default=St}),_=this&&this.__importStar||function(yt){if(yt&&yt.__esModule)return yt;var St={};if(yt!=null)for(var bt in yt)bt!=="default"&&Object.prototype.hasOwnProperty.call(yt,bt)&&h(St,yt,bt);return $(St,yt),St};Object.defineProperty(e,"__esModule",{value:!0}),e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initOrt=e.initWasm=void 0;const j=s(1670),nt=_(s(349)),et=s(6361),b=()=>!!j.env.wasm.proxy&&typeof document<"u";let a,o,d,g=!1,rt=!1,st=!1;const tt=[],ot=[],it=[],at=[],ut=[],lt=[],ct=()=>{if(g||!rt||st||!a)throw new Error("worker not ready")},ft=yt=>{switch(yt.data.type){case"init-wasm":g=!1,yt.data.err?(st=!0,o[1](yt.data.err)):(rt=!0,o[0]());break;case"init-ort":yt.data.err?d[1](yt.data.err):d[0]();break;case"create_allocate":yt.data.err?tt.shift()[1](yt.data.err):tt.shift()[0](yt.data.out);break;case"create_finalize":yt.data.err?ot.shift()[1](yt.data.err):ot.shift()[0](yt.data.out);break;case"create":yt.data.err?it.shift()[1](yt.data.err):it.shift()[0](yt.data.out);break;case"release":yt.data.err?at.shift()[1](yt.data.err):at.shift()[0]();break;case"run":yt.data.err?ut.shift()[1](yt.data.err):ut.shift()[0](yt.data.out);break;case"end-profiling":yt.data.err?lt.shift()[1](yt.data.err):lt.shift()[0]()}},dt=typeof document<"u"?(c=document==null?void 0:document.currentScript)===null||c===void 0?void 0:c.src:void 0;e.initWasm=async()=>{if(b()){if(rt)return;if(g)throw new Error("multiple calls to 'initWasm()' detected.");if(st)throw new Error("previous call to 'initWasm()' failed.");return g=!0,j.env.wasm.wasmPaths===void 0&&dt&&dt.indexOf("blob:")!==0&&(j.env.wasm.wasmPaths=dt.substr(0,+dt.lastIndexOf("/")+1)),new Promise((yt,St)=>{a==null||a.terminate(),a=s(9710).Z(),a.onmessage=ft,o=[yt,St];const bt={type:"init-wasm",in:j.env.wasm};a.postMessage(bt)})}return(0,et.initializeWebAssembly)(j.env.wasm)},e.initOrt=async(yt,St)=>{if(b())return ct(),new Promise((bt,Tt)=>{d=[bt,Tt];const vt={type:"init-ort",in:{numThreads:yt,loggingLevel:St}};a.postMessage(vt)});nt.initOrt(yt,St)},e.createSessionAllocate=async yt=>b()?(ct(),new Promise((St,bt)=>{tt.push([St,bt]);const Tt={type:"create_allocate",in:{model:yt}};a.postMessage(Tt,[yt.buffer])})):nt.createSessionAllocate(yt),e.createSessionFinalize=async(yt,St)=>b()?(ct(),new Promise((bt,Tt)=>{ot.push([bt,Tt]);const vt={type:"create_finalize",in:{modeldata:yt,options:St}};a.postMessage(vt)})):nt.createSessionFinalize(yt,St),e.createSession=async(yt,St)=>b()?(ct(),new Promise((bt,Tt)=>{it.push([bt,Tt]);const vt={type:"create",in:{model:yt,options:St}};a.postMessage(vt,[yt.buffer])})):nt.createSession(yt,St),e.releaseSession=async yt=>{if(b())return ct(),new Promise((St,bt)=>{at.push([St,bt]);const Tt={type:"release",in:yt};a.postMessage(Tt)});nt.releaseSession(yt)},e.run=async(yt,St,bt,Tt,vt)=>b()?(ct(),new Promise(($t,At)=>{ut.push([$t,At]);const Ot={type:"run",in:{sessionId:yt,inputIndices:St,inputs:bt,outputIndices:Tt,options:vt}};a.postMessage(Ot,nt.extractTransferableBuffers(bt))})):nt.run(yt,St,bt,Tt,vt),e.endProfiling=async yt=>{if(b())return ct(),new Promise((St,bt)=>{lt.push([St,bt]);const Tt={type:"end-profiling",in:yt};a.postMessage(Tt)});nt.endProfiling(yt)}},586:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const c=s(7967),h=s(4983),$=s(6361);e.setRunOptions=_=>{const j=(0,$.getInstance)();let nt=0;const et=[],b=_||{};try{if((_==null?void 0:_.logSeverityLevel)===void 0)b.logSeverityLevel=2;else if(typeof _.logSeverityLevel!="number"||!Number.isInteger(_.logSeverityLevel)||_.logSeverityLevel<0||_.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${_.logSeverityLevel}`);if((_==null?void 0:_.logVerbosityLevel)===void 0)b.logVerbosityLevel=0;else if(typeof _.logVerbosityLevel!="number"||!Number.isInteger(_.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${_.logVerbosityLevel}`);(_==null?void 0:_.terminate)===void 0&&(b.terminate=!1);let a=0;if((_==null?void 0:_.tag)!==void 0&&(a=(0,h.allocWasmString)(_.tag,et)),nt=j._OrtCreateRunOptions(b.logSeverityLevel,b.logVerbosityLevel,!!b.terminate,a),nt===0)throw new Error("Can't create run options");return(_==null?void 0:_.extra)!==void 0&&(0,c.iterateExtraOptions)(_.extra,"",new WeakSet,(o,d)=>{const g=(0,h.allocWasmString)(o,et),rt=(0,h.allocWasmString)(d,et);if(j._OrtAddRunConfigEntry(nt,g,rt)!==0)throw new Error(`Can't set a run config entry: ${o} - ${d}`)}),[nt,et]}catch(a){throw nt!==0&&j._OrtReleaseRunOptions(nt),et.forEach(j._free),a}}},2306:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxruntimeWebAssemblySessionHandler=void 0;const c=s(2806),h=s(1670),$=s(2850),_=s(2157);let j;e.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(nt){const et=await fetch(nt),b=await et.arrayBuffer();return(0,_.createSessionAllocate)(new Uint8Array(b))}async loadModel(nt,et){if(j||(await(0,_.initOrt)(h.env.wasm.numThreads,(b=>{switch(b){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${b}`)}})(h.env.logLevel)),j=!0),typeof nt=="string")if(typeof fetch>"u"){const b=await(0,$.promisify)(c.readFile)(nt);[this.sessionId,this.inputNames,this.outputNames]=await(0,_.createSession)(b,et)}else{const b=await this.createSessionAllocate(nt);[this.sessionId,this.inputNames,this.outputNames]=await(0,_.createSessionFinalize)(b,et)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,_.createSession)(nt,et)}async dispose(){return(0,_.releaseSession)(this.sessionId)}async run(nt,et,b){const a=[],o=[];Object.entries(nt).forEach(st=>{const tt=st[0],ot=st[1],it=this.inputNames.indexOf(tt);if(it===-1)throw new Error(`invalid input '${tt}'`);a.push(ot),o.push(it)});const d=[];Object.entries(et).forEach(st=>{const tt=st[0],ot=this.outputNames.indexOf(tt);if(ot===-1)throw new Error(`invalid output '${tt}'`);d.push(ot)});const g=await(0,_.run)(this.sessionId,o,a.map(st=>[st.type,st.dims,st.data]),d,b),rt={};for(let st=0;st<g.length;st++)rt[this.outputNames[d[st]]]=new h.Tensor(g[st][0],g[st][2],g[st][1]);return rt}startProfiling(){}endProfiling(){(0,_.endProfiling)(this.sessionId)}}},4919:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const c=s(7967),h=s(4983),$=s(6361);e.setSessionOptions=_=>{const j=(0,$.getInstance)();let nt=0;const et=[],b=_||{};(a=>{a.extra||(a.extra={}),a.extra.session||(a.extra.session={});const o=a.extra.session;o.use_ort_model_bytes_directly||(o.use_ort_model_bytes_directly="1")})(b);try{(_==null?void 0:_.graphOptimizationLevel)===void 0&&(b.graphOptimizationLevel="all");const a=(g=>{switch(g){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${g}`)}})(b.graphOptimizationLevel);(_==null?void 0:_.enableCpuMemArena)===void 0&&(b.enableCpuMemArena=!0),(_==null?void 0:_.enableMemPattern)===void 0&&(b.enableMemPattern=!0),(_==null?void 0:_.executionMode)===void 0&&(b.executionMode="sequential");const o=(g=>{switch(g){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${g}`)}})(b.executionMode);let d=0;if((_==null?void 0:_.logId)!==void 0&&(d=(0,h.allocWasmString)(_.logId,et)),(_==null?void 0:_.logSeverityLevel)===void 0)b.logSeverityLevel=2;else if(typeof _.logSeverityLevel!="number"||!Number.isInteger(_.logSeverityLevel)||_.logSeverityLevel<0||_.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${_.logSeverityLevel}`);if((_==null?void 0:_.logVerbosityLevel)===void 0)b.logVerbosityLevel=0;else if(typeof _.logVerbosityLevel!="number"||!Number.isInteger(_.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${_.logVerbosityLevel}`);if((_==null?void 0:_.enableProfiling)===void 0&&(b.enableProfiling=!1),nt=j._OrtCreateSessionOptions(a,!!b.enableCpuMemArena,!!b.enableMemPattern,o,!!b.enableProfiling,0,d,b.logSeverityLevel,b.logVerbosityLevel),nt===0)throw new Error("Can't create session options");return _!=null&&_.executionProviders&&((g,rt,st)=>{for(const tt of rt){let ot=typeof tt=="string"?tt:tt.name;switch(ot){case"xnnpack":ot="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${ot}`)}const it=(0,h.allocWasmString)(ot,st);if((0,$.getInstance)()._OrtAppendExecutionProvider(g,it)!==0)throw new Error(`Can't append execution provider: ${ot}`)}})(nt,_.executionProviders,et),(_==null?void 0:_.extra)!==void 0&&(0,c.iterateExtraOptions)(_.extra,"",new WeakSet,(g,rt)=>{const st=(0,h.allocWasmString)(g,et),tt=(0,h.allocWasmString)(rt,et);if(j._OrtAddSessionConfigEntry(nt,st,tt)!==0)throw new Error(`Can't set a session config entry: ${g} - ${rt}`)}),[nt,et]}catch(a){throw nt!==0&&j._OrtReleaseSessionOptions(nt),et.forEach(j._free),a}}},4983:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.allocWasmString=void 0;const c=s(6361);e.allocWasmString=(h,$)=>{const _=(0,c.getInstance)(),j=_.lengthBytesUTF8(h)+1,nt=_._malloc(j);return _.stringToUTF8(h,nt,j),$.push(nt),nt}},349:(i,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extractTransferableBuffers=e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initOrt=void 0;const c=s(586),h=s(4919),$=s(4983),_=s(6361);e.initOrt=(a,o)=>{const d=(0,_.getInstance)()._OrtInit(a,o);if(d!==0)throw new Error(`Can't initialize onnxruntime. error code = ${d}`)};const j=new Map;e.createSessionAllocate=a=>{const o=(0,_.getInstance)(),d=o._malloc(a.byteLength);return o.HEAPU8.set(a,d),[d,a.byteLength]},e.createSessionFinalize=(a,o)=>{const d=(0,_.getInstance)();let g=0,rt=0,st=[];try{if([rt,st]=(0,h.setSessionOptions)(o),g=d._OrtCreateSession(a[0],a[1],rt),g===0)throw new Error("Can't create a session")}finally{d._free(a[0]),d._OrtReleaseSessionOptions(rt),st.forEach(d._free)}const tt=d._OrtGetInputCount(g),ot=d._OrtGetOutputCount(g),it=[],at=[],ut=[],lt=[];for(let ct=0;ct<tt;ct++){const ft=d._OrtGetInputName(g,ct);if(ft===0)throw new Error("Can't get an input name");at.push(ft),it.push(d.UTF8ToString(ft))}for(let ct=0;ct<ot;ct++){const ft=d._OrtGetOutputName(g,ct);if(ft===0)throw new Error("Can't get an output name");lt.push(ft),ut.push(d.UTF8ToString(ft))}return j.set(g,[g,at,lt]),[g,it,ut]},e.createSession=(a,o)=>{const d=(0,e.createSessionAllocate)(a);return(0,e.createSessionFinalize)(d,o)},e.releaseSession=a=>{const o=(0,_.getInstance)(),d=j.get(a);if(!d)throw new Error("invalid session id");const g=d[0],rt=d[1],st=d[2];rt.forEach(o._OrtFree),st.forEach(o._OrtFree),o._OrtReleaseSession(g),j.delete(a)};const nt=a=>{switch(a){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${a}`)}},et=a=>{switch(a){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${a}`)}},b=a=>{switch(a){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${a}`)}};e.run=(a,o,d,g,rt)=>{const st=(0,_.getInstance)(),tt=j.get(a);if(!tt)throw new Error("invalid session id");const ot=tt[0],it=tt[1],at=tt[2],ut=o.length,lt=g.length;let ct=0,ft=[];const dt=[],yt=[];try{[ct,ft]=(0,c.setRunOptions)(rt);for(let At=0;At<ut;At++){const Ot=d[At][0],It=d[At][1],jt=d[At][2];let Et,mt;if(Array.isArray(jt)){mt=4*jt.length,Et=st._malloc(mt),yt.push(Et);let pt=Et/4;for(let _t=0;_t<jt.length;_t++){if(typeof jt[_t]!="string")throw new TypeError(`tensor data at index ${_t} is not a string`);st.HEAPU32[pt++]=(0,$.allocWasmString)(jt[_t],yt)}}else mt=jt.byteLength,Et=st._malloc(mt),yt.push(Et),st.HEAPU8.set(new Uint8Array(jt.buffer,jt.byteOffset,mt),Et);const gt=st.stackSave(),ht=st.stackAlloc(4*It.length);try{let pt=ht/4;It.forEach(Ct=>st.HEAP32[pt++]=Ct);const _t=st._OrtCreateTensor(nt(Ot),Et,mt,ht,It.length);if(_t===0)throw new Error("Can't create a tensor");dt.push(_t)}finally{st.stackRestore(gt)}}const St=st.stackSave(),bt=st.stackAlloc(4*ut),Tt=st.stackAlloc(4*ut),vt=st.stackAlloc(4*lt),$t=st.stackAlloc(4*lt);try{let At=bt/4,Ot=Tt/4,It=vt/4,jt=$t/4;for(let gt=0;gt<ut;gt++)st.HEAPU32[At++]=dt[gt],st.HEAPU32[Ot++]=it[o[gt]];for(let gt=0;gt<lt;gt++)st.HEAPU32[It++]=0,st.HEAPU32[jt++]=at[g[gt]];let Et=st._OrtRun(ot,Tt,bt,ut,$t,lt,vt,ct);const mt=[];if(Et===0)for(let gt=0;gt<lt;gt++){const ht=st.HEAPU32[vt/4+gt],pt=st.stackSave(),_t=st.stackAlloc(16);let Ct,zt=0;try{if(Et=st._OrtGetTensorData(ht,_t,_t+4,_t+8,_t+12),Et!==0)throw new Error(`Can't access output tensor data. error code = ${Et}`);let Nt=_t/4;const Ht=st.HEAPU32[Nt++];zt=st.HEAPU32[Nt++];const Jt=st.HEAPU32[Nt++],un=st.HEAPU32[Nt++],yn=[];for(let mn=0;mn<un;mn++)yn.push(st.HEAPU32[Jt/4+mn]);st._OrtFree(Jt);const vn=yn.length===0?1:yn.reduce((mn,Tn)=>mn*Tn);if(Ct=et(Ht),Ct==="string"){const mn=[];let Tn=zt/4;for(let kn=0;kn<vn;kn++){const Gn=st.HEAPU32[Tn++],wr=kn===vn-1?void 0:st.HEAPU32[Tn]-Gn;mn.push(st.UTF8ToString(Gn,wr))}mt.push([Ct,yn,mn])}else{const mn=new(b(Ct))(vn);new Uint8Array(mn.buffer,mn.byteOffset,mn.byteLength).set(st.HEAPU8.subarray(zt,zt+mn.byteLength)),mt.push([Ct,yn,mn])}}finally{st.stackRestore(pt),Ct==="string"&&zt&&st._free(zt),st._OrtReleaseTensor(ht)}}if(Et===0)return mt;throw new Error(`failed to call OrtRun(). error code = ${Et}.`)}finally{st.stackRestore(St)}}finally{dt.forEach(st._OrtReleaseTensor),yt.forEach(st._free),st._OrtReleaseRunOptions(ct),ft.forEach(st._free)}},e.endProfiling=a=>{const o=(0,_.getInstance)(),d=j.get(a);if(!d)throw new Error("invalid session id");const g=d[0],rt=o._OrtEndProfiling(g);if(rt===0)throw new Error("Can't get an profile file name");o._OrtFree(rt)},e.extractTransferableBuffers=a=>{const o=[];for(const d of a){const g=d[2];!Array.isArray(g)&&g.buffer&&o.push(g.buffer)}return o}},6361:function(i,e,s){var c=this&&this.__createBinding||(Object.create?function(rt,st,tt,ot){ot===void 0&&(ot=tt);var it=Object.getOwnPropertyDescriptor(st,tt);it&&!("get"in it?!st.__esModule:it.writable||it.configurable)||(it={enumerable:!0,get:function(){return st[tt]}}),Object.defineProperty(rt,ot,it)}:function(rt,st,tt,ot){ot===void 0&&(ot=tt),rt[ot]=st[tt]}),h=this&&this.__setModuleDefault||(Object.create?function(rt,st){Object.defineProperty(rt,"default",{enumerable:!0,value:st})}:function(rt,st){rt.default=st}),$=this&&this.__importStar||function(rt){if(rt&&rt.__esModule)return rt;var st={};if(rt!=null)for(var tt in rt)tt!=="default"&&Object.prototype.hasOwnProperty.call(rt,tt)&&c(st,rt,tt);return h(st,rt),st},_=this&&this.__importDefault||function(rt){return rt&&rt.__esModule?rt:{default:rt}};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const j=$(s(6449)),nt=_(s(932)),et=s(3474);let b,a=!1,o=!1,d=!1;const g=(rt,st)=>st?rt?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":rt?"ort-wasm-simd.wasm":"ort-wasm.wasm";e.initializeWebAssembly=async rt=>{if(a)return Promise.resolve();if(o)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(d)throw new Error("previous call to 'initializeWebAssembly()' failed.");o=!0;const st=rt.initTimeout,tt=rt.numThreads,ot=rt.simd,it=tt>1&&(()=>{try{return typeof SharedArrayBuffer<"u"&&(typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch{return!1}})(),at=ot&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}})(),ut=typeof rt.wasmPaths=="string"?rt.wasmPaths:void 0,lt=g(!1,it),ct=g(at,it),ft=typeof rt.wasmPaths=="object"?rt.wasmPaths[ct]:void 0;let dt=!1;const yt=[];if(st>0&&yt.push(new Promise(St=>{setTimeout(()=>{dt=!0,St()},st)})),yt.push(new Promise((St,bt)=>{const Tt=it?et:nt.default,vt={locateFile:($t,At)=>it&&$t.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([s(4154)],{type:"text/javascript"})):$t===lt?ft??(ut??At)+ct:At+$t};if(it)if(typeof Blob>"u")vt.mainScriptUrlOrBlob=j.join("/","ort-wasm-threaded.js");else{const $t=`var ortWasmThreaded=(function(){var _scriptDir;return ${Tt.toString()}})();`;vt.mainScriptUrlOrBlob=new Blob([$t],{type:"text/javascript"})}Tt(vt).then($t=>{o=!1,a=!0,b=$t,St()},$t=>{o=!1,d=!0,bt($t)})})),await Promise.race(yt),dt)throw new Error(`WebAssembly backend initializing failed due to timeout: ${st}ms`)},e.getInstance=()=>{if(a&&b)return b;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var rt;!a||o||d||(o=!0,(rt=b.PThread)===null||rt===void 0||rt.terminateAllThreads(),b=void 0,o=!1,a=!1,d=!0)}},9710:(i,e,s)=>{s.d(e,{Z:()=>$});var c=s(477),h=s.n(c);function $(){return h()('/*!\n* ONNX Runtime Web v1.14.0\n* Copyright (c) Microsoft Corporation. All rights reserved.\n* Licensed under the MIT License.\n*/\n(()=>{var t={474:(t,e,n)=>{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){function e(){return j.buffer!=D&&N(j.buffer),P}function r(){return j.buffer!=D&&N(j.buffer),U}function a(){return j.buffer!=D&&N(j.buffer),F}function i(){return j.buffer!=D&&N(j.buffer),I}function o(){return j.buffer!=D&&N(j.buffer),W}var u,c,s;t=t||{},u||(u=void 0!==t?t:{}),u.ready=new Promise((function(t,e){c=t,s=e}));var l,f,p,h,d,y,b=Object.assign({},u),m="./this.program",g=(t,e)=>{throw e},v="object"==typeof window,w="function"==typeof importScripts,_="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,O=u.ENVIRONMENT_IS_PTHREAD||!1,A="";function S(t){return u.locateFile?u.locateFile(t,A):A+t}if(_){let e;A=w?n(908).dirname(A)+"/":"//",y=()=>{d||(h=n(384),d=n(908))},l=function(t,e){return y(),t=d.normalize(t),h.readFileSync(t,e?void 0:"utf8")},p=t=>((t=l(t,!0)).buffer||(t=new Uint8Array(t)),t),f=(t,e,n)=>{y(),t=d.normalize(t),h.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1<process.argv.length&&(m=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof ct))throw t})),process.on("unhandledRejection",(function(t){throw t})),g=(t,e)=>{if(Q())throw process.exitCode=t,e;e instanceof ct||x("exiting due to exception: "+e),process.exit(t)},u.inspect=function(){return"[Emscripten Module object]"};try{e=n(925)}catch(t){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),t}n.g.Worker=e.Worker}else(v||w)&&(w?A=self.location.href:"undefined"!=typeof document&&document.currentScript&&(A=document.currentScript.src),_scriptDir&&(A=_scriptDir),A=0!==A.indexOf("blob:")?A.substr(0,A.replace(/[?#].*/,"").lastIndexOf("/")+1):"",_||(l=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},w&&(p=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),f=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)}));_&&"undefined"==typeof performance&&(n.g.performance=n(953).performance);var T=console.log.bind(console),E=console.warn.bind(console);_&&(y(),T=t=>h.writeSync(1,t+"\\n"),E=t=>h.writeSync(2,t+"\\n"));var M,C=u.print||T,x=u.printErr||E;Object.assign(u,b),b=null,u.thisProgram&&(m=u.thisProgram),u.quit&&(g=u.quit),u.wasmBinary&&(M=u.wasmBinary);var R=u.noExitRuntime||!1;"object"!=typeof WebAssembly&&at("no native wasm support detected");var j,k,D,P,U,F,I,W,H=!1,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function z(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16<n-e&&t.buffer&&L)return L.decode(t.buffer instanceof SharedArrayBuffer?t.slice(e,n):t.subarray(e,n));for(r="";e<n;){var a=t[e++];if(128&a){var i=63&t[e++];if(192==(224&a))r+=String.fromCharCode((31&a)<<6|i);else{var o=63&t[e++];65536>(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function Y(t,e){return(t>>>=0)?z(r(),t,e):""}function B(t,e,n,r){if(!(0<r))return 0;var a=n>>>=0;r=n+r-1;for(var i=0;i<t.length;++i){var o=t.charCodeAt(i);if(55296<=o&&57343>=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function G(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);127>=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function N(t){D=t,u.HEAP8=P=new Int8Array(t),u.HEAP16=new Int16Array(t),u.HEAP32=F=new Int32Array(t),u.HEAPU8=U=new Uint8Array(t),u.HEAPU16=new Uint16Array(t),u.HEAPU32=I=new Uint32Array(t),u.HEAPF32=new Float32Array(t),u.HEAPF64=W=new Float64Array(t)}O&&(D=u.buffer);var V=u.INITIAL_MEMORY||16777216;if(O)j=u.wasmMemory,D=u.buffer;else if(u.wasmMemory)j=u.wasmMemory;else if(!((j=new WebAssembly.Memory({initial:V/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw x("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),_&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");j&&(D=j.buffer),V=D.byteLength,N(D);var $,q=[],X=[],J=[],Z=[];function Q(){return R||!1}function K(){var t=u.preRun.shift();q.unshift(t)}var tt,et=0,nt=null,rt=null;function at(t){throw O?postMessage({cmd:"onAbort",arg:t}):u.onAbort&&u.onAbort(t),x(t="Aborted("+t+")"),H=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),s(t),t}function it(){return tt.startsWith("data:application/octet-stream;base64,")}function ot(){var t=tt;try{if(t==tt&&M)return new Uint8Array(M);if(p)return p(t);throw"both async and sync fetching of the wasm failed"}catch(t){at(t)}}tt="ort-wasm-threaded.wasm",it()||(tt=S(tt));var ut={};function ct(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function st(t){(t=ht.Vb[t])||at(),ht.mc(t)}function lt(t){var e=ht.Cc();if(!e)return 6;ht.ac.push(e),ht.Vb[t.Ub]=e,e.Ub=t.Ub;var n={cmd:"run",start_routine:t.Ic,arg:t.zc,pthread_ptr:t.Ub};return e.$b=()=>{n.time=performance.now(),e.postMessage(n,t.Nc)},e.loaded&&(e.$b(),delete e.$b),0}function ft(t){if(O)return $t(1,1,t);Q()||(ht.oc(),u.onExit&&u.onExit(t),H=!0),g(t,new ct(t))}function pt(t,e){if(!e&&O)throw bt(t),"unwind";Q()||O||(me(),dt(J),be(0),re[1].length&&ae(1,10),re[2].length&&ae(2,10),ht.oc()),ft(t)}var ht={Yb:[],ac:[],qc:[],Vb:{},fc:function(){O&&ht.Ec()},Pc:function(){},Ec:function(){ht.receiveObjectTransfer=ht.Gc,ht.threadInitTLS=ht.pc,ht.setExitStatus=ht.nc,R=!1},nc:function(){},oc:function(){for(var t of Object.values(ht.Vb))ht.mc(t);for(t of ht.Yb)t.terminate();ht.Yb=[]},mc:function(t){var e=t.Ub;delete ht.Vb[e],ht.Yb.push(t),ht.ac.splice(ht.ac.indexOf(t),1),t.Ub=0,Oe(e)},Gc:function(){},pc:function(){ht.qc.forEach((t=>t()))},Fc:function(t,e){t.onmessage=n=>{var r=(n=n.data).cmd;if(t.Ub&&(ht.Bc=t.Ub),n.targetThread&&n.targetThread!=he()){var a=ht.Vb[n.Qc];a?a.postMessage(n,n.transferList):x(\'Internal error! Worker sent a message "\'+r+\'" to target pthread \'+n.targetThread+", but that thread no longer exists!")}else"processProxyingQueue"===r?zt(n.queue):"spawnThread"===r?lt(n):"cleanupThread"===r?st(n.thread):"killThread"===r?(n=n.thread,r=ht.Vb[n],delete ht.Vb[n],r.terminate(),Oe(n),ht.ac.splice(ht.ac.indexOf(r),1),r.Ub=0):"cancelThread"===r?ht.Vb[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(t.loaded=!0,e&&e(t),t.$b&&(t.$b(),delete t.$b)):"print"===r?C("Thread "+n.threadId+": "+n.text):"printErr"===r?x("Thread "+n.threadId+": "+n.text):"alert"===r?alert("Thread "+n.threadId+": "+n.text):"setimmediate"===n.target?t.postMessage(n):"onAbort"===r?u.onAbort&&u.onAbort(n.arg):r&&x("worker sent an unknown command "+r);ht.Bc=void 0},t.onerror=t=>{throw x("worker sent an error! "+t.filename+":"+t.lineno+": "+t.message),t},_&&(t.on("message",(function(e){t.onmessage({data:e})})),t.on("error",(function(e){t.onerror(e)})),t.on("detachedExit",(function(){}))),t.postMessage({cmd:"load",urlOrBlob:u.mainScriptUrlOrBlob||_scriptDir,wasmMemory:j,wasmModule:k})},yc:function(){var t=S("ort-wasm-threaded.worker.js");ht.Yb.push(new Worker(t))},Cc:function(){return 0==ht.Yb.length&&(ht.yc(),ht.Fc(ht.Yb[0])),ht.Yb.pop()}};function dt(t){for(;0<t.length;)t.shift()(u)}function yt(t){var e=Ee();return t=t(),Me(e),t}function bt(t){if(O)return $t(2,0,t);try{pt(t)}catch(t){t instanceof ct||"unwind"==t||g(1,t)}}u.PThread=ht,u.establishStackSpace=function(){var t=he(),e=a()[t+44>>2>>>0];t=a()[t+48>>2>>>0],Te(e,e-t),Me(e)};var mt=[];function gt(t){var e=mt[t];return e||(t>=mt.length&&(mt.length=t+1),mt[t]=e=$.get(t)),e}u.invokeEntryPoint=function(t,e){t=gt(t)(e),Q()?ht.nc(t):Ae(t)};var vt,wt,_t=[],Ot=0,At=0;function St(t){this.Zb=t,this.Sb=t-24,this.xc=function(t){i()[this.Sb+4>>2>>>0]=t},this.bc=function(){return i()[this.Sb+4>>2>>>0]},this.wc=function(t){i()[this.Sb+8>>2>>>0]=t},this.Dc=function(){return i()[this.Sb+8>>2>>>0]},this.rc=function(){a()[this.Sb>>2>>>0]=0},this.hc=function(t){t=t?1:0,e()[this.Sb+12>>0>>>0]=t},this.uc=function(){return 0!=e()[this.Sb+12>>0>>>0]},this.ic=function(t){t=t?1:0,e()[this.Sb+13>>0>>>0]=t},this.kc=function(){return 0!=e()[this.Sb+13>>0>>>0]},this.fc=function(t,e){this.cc(0),this.xc(t),this.wc(e),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(a(),this.Sb>>2,1)},this.Hc=function(){return 1===Atomics.sub(a(),this.Sb>>2,1)},this.cc=function(t){i()[this.Sb+16>>2>>>0]=t},this.tc=function(){return i()[this.Sb+16>>2>>>0]},this.vc=function(){if(Re(this.bc()))return i()[this.Zb>>2>>>0];var t=this.tc();return 0!==t?t:this.Zb}}function Tt(t){return ye(new St(t).Sb)}function Et(t,e,n,r){return O?$t(3,1,t,e,n,r):Mt(t,e,n,r)}function Mt(t,e,n,r){if("undefined"==typeof SharedArrayBuffer)return x("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];return O&&0===a.length?Et(t,e,n,r):(t={Ic:n,Ub:t,zc:r,Nc:a},O?(t.Oc="spawnThread",postMessage(t,a),0):lt(t))}function Ct(t,e,n){return O?$t(4,1,t,e,n):0}function xt(t,e){if(O)return $t(5,1,t,e)}function Rt(t,e){if(O)return $t(6,1,t,e)}function jt(t,e,n){if(O)return $t(7,1,t,e,n)}function kt(t,e,n){return O?$t(8,1,t,e,n):0}function Dt(t,e){if(O)return $t(9,1,t,e)}function Pt(t,e,n){if(O)return $t(10,1,t,e,n)}function Ut(t,e,n,r){if(O)return $t(11,1,t,e,n,r)}function Ft(t,e,n,r){if(O)return $t(12,1,t,e,n,r)}function It(t,e,n,r){if(O)return $t(13,1,t,e,n,r)}function Wt(t){if(O)return $t(14,1,t)}function Ht(t,e){if(O)return $t(15,1,t,e)}function Lt(t,e,n){if(O)return $t(16,1,t,e,n)}function zt(t){Atomics.store(a(),t>>2,1),he()&&_e(t),Atomics.compareExchange(a(),t>>2,1,0)}function Yt(t){return i()[t>>>2]+4294967296*a()[t+4>>>2]}function Bt(t,e,n,r,a,i){return O?$t(17,1,t,e,n,r,a,i):-52}function Gt(t,e,n,r,a,i){if(O)return $t(18,1,t,e,n,r,a,i)}function Nt(t){var n=G(t)+1,r=de(n);return r&&B(t,e(),r,n),r}function Vt(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}if(O)return $t(19,1,t,e,n);var o=(new Date).getFullYear(),u=new Date(o,0,1),c=new Date(o,6,1);o=u.getTimezoneOffset();var s=c.getTimezoneOffset(),l=Math.max(o,s);a()[t>>2>>>0]=60*l,a()[e>>2>>>0]=Number(o!=s),t=r(u),e=r(c),t=Nt(t),e=Nt(e),s<o?(i()[n>>2>>>0]=t,i()[n+4>>2>>>0]=e):(i()[n>>2>>>0]=e,i()[n+4>>2>>>0]=t)}function $t(t,e){var n=arguments.length-2,r=arguments;return yt((()=>{for(var a=Ce(8*n),i=a>>3,u=0;u<n;u++){var c=r[2+u];o()[i+u>>>0]=c}return we(t,n,a,e)}))}u.executeNotifiedProxyingQueue=zt,wt=_?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:O?()=>performance.now()-u.__performance_now_clock_drift:()=>performance.now();var qt,Xt=[],Jt={};function Zt(){if(!qt){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:m||"./this.program"};for(t in Jt)void 0===Jt[t]?delete e[t]:e[t]=Jt[t];var n=[];for(t in e)n.push(t+"="+e[t]);qt=n}return qt}function Qt(t,n){if(O)return $t(20,1,t,n);var r=0;return Zt().forEach((function(a,o){var u=n+r;for(o=i()[t+4*o>>2>>>0]=u,u=0;u<a.length;++u)e()[o++>>0>>>0]=a.charCodeAt(u);e()[o>>0>>>0]=0,r+=a.length+1})),0}function Kt(t,e){if(O)return $t(21,1,t,e);var n=Zt();i()[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),i()[e>>2>>>0]=r,0}function te(t){return O?$t(22,1,t):52}function ee(t,e,n,r){return O?$t(23,1,t,e,n,r):52}function ne(t,e,n,r,a){return O?$t(24,1,t,e,n,r,a):70}var re=[null,[],[]];function ae(t,e){var n=re[t];0===e||10===e?((1===t?C:x)(z(n,0)),n.length=0):n.push(e)}function ie(t,e,n,a){if(O)return $t(25,1,t,e,n,a);for(var o=0,u=0;u<n;u++){var c=i()[e>>2>>>0],s=i()[e+4>>2>>>0];e+=8;for(var l=0;l<s;l++)ae(t,r()[c+l>>>0]);o+=s}return i()[a>>2>>>0]=o,0}var oe=0;function ue(t){return 0==t%4&&(0!=t%100||0==t%400)}var ce=[31,29,31,30,31,30,31,31,30,31,30,31],se=[31,28,31,30,31,30,31,31,30,31,30,31];function le(t,n,r,i){function o(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.length<e;)t=n[0]+t;return t}function u(t,e){return o(t,e,"0")}function c(t,e){function n(t){return 0>t?-1:0<t?1:0}var r;return 0===(r=n(t.getFullYear()-e.getFullYear()))&&0===(r=n(t.getMonth()-e.getMonth()))&&(r=n(t.getDate()-e.getDate())),r}function s(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function l(t){var e=t.Wb;for(t=new Date(new Date(t.Xb+1900,0,1).getTime());0<e;){var n=t.getMonth(),r=(ue(t.getFullYear())?ce:se)[n];if(!(e>r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=s(new Date(t.getFullYear(),0,4)),n=s(n),0>=c(e,t)?0>=c(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var f=a()[i+40>>2>>>0];for(var p in i={Lc:a()[i>>2>>>0],Kc:a()[i+4>>2>>>0],dc:a()[i+8>>2>>>0],jc:a()[i+12>>2>>>0],ec:a()[i+16>>2>>>0],Xb:a()[i+20>>2>>>0],Tb:a()[i+24>>2>>>0],Wb:a()[i+28>>2>>>0],Rc:a()[i+32>>2>>>0],Jc:a()[i+36>>2>>>0],Mc:f?Y(f):""},r=Y(r),f={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(p,"g"),f[p]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(p in f={"%a":function(t){return h[t.Tb].substring(0,3)},"%A":function(t){return h[t.Tb]},"%b":function(t){return d[t.ec].substring(0,3)},"%B":function(t){return d[t.ec]},"%C":function(t){return u((t.Xb+1900)/100|0,2)},"%d":function(t){return u(t.jc,2)},"%e":function(t){return o(t.jc,2," ")},"%g":function(t){return l(t).toString().substring(2)},"%G":function(t){return l(t)},"%H":function(t){return u(t.dc,2)},"%I":function(t){return 0==(t=t.dc)?t=12:12<t&&(t-=12),u(t,2)},"%j":function(t){for(var e=0,n=0;n<=t.ec-1;e+=(ue(t.Xb+1900)?ce:se)[n++]);return u(t.jc+e,3)},"%m":function(t){return u(t.ec+1,2)},"%M":function(t){return u(t.Kc,2)},"%n":function(){return"\\n"},"%p":function(t){return 0<=t.dc&&12>t.dc?"AM":"PM"},"%S":function(t){return u(t.Lc,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Tb||7},"%U":function(t){return u(Math.floor((t.Wb+7-t.Tb)/7),2)},"%V":function(t){var e=Math.floor((t.Wb+7-(t.Tb+6)%7)/7);if(2>=(t.Tb+371-t.Wb-2)%7&&e++,e)53==e&&(4==(n=(t.Tb+371-t.Wb)%7)||3==n&&ue(t.Xb)||(e=1));else{e=52;var n=(t.Tb+7-t.Wb-1)%7;(4==n||5==n&&ue(t.Xb%400-1))&&e++}return u(e,2)},"%w":function(t){return t.Tb},"%W":function(t){return u(Math.floor((t.Wb+7-(t.Tb+6)%7)/7),2)},"%y":function(t){return(t.Xb+1900).toString().substring(2)},"%Y":function(t){return t.Xb+1900},"%z":function(t){var e=0<=(t=t.Jc);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.Mc},"%%":function(){return"%"}},r=r.replace(/%%/g,"\\0\\0"),f)r.includes(p)&&(r=r.replace(new RegExp(p,"g"),f[p](i)));return p=function(t){var e=Array(G(t)+1);return B(t,e,0,e.length),e}(r=r.replace(/\\0\\0/g,"%")),p.length>n?0:(function(t,n){e().set(t,n>>>0)}(p,t),p.length-1)}ht.fc();var fe=[null,ft,bt,Et,Ct,xt,Rt,jt,kt,Dt,Pt,Ut,Ft,It,Wt,Ht,Lt,Bt,Gt,Vt,Qt,Kt,te,ee,ne,ie],pe={b:function(t){return de(t+24)+24},n:function(t){return(t=new St(t)).uc()||(t.hc(!0),Ot--),t.ic(!1),_t.push(t),t.sc(),t.vc()},ma:function(t){throw x("Unexpected exception thrown, this is not properly supported - aborting"),H=!0,t},x:function(){Se(0);var t=_t.pop();if(t.Hc()&&!t.kc()){var e=t.Dc();e&>(e)(t.Zb),Tt(t.Zb)}At=0},e:function(){var t=At;if(!t)return oe=0;var e=new St(t);e.cc(t);var n=e.bc();if(!n)return oe=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(xe(i,n,e.Sb+16))return oe=i,t}return oe=n,t},l:function(){var t=At;if(!t)return oe=0;var e=new St(t);e.cc(t);var n=e.bc();if(!n)return oe=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(xe(i,n,e.Sb+16))return oe=i,t}return oe=n,t},h:function(){var t=At;if(!t)return oe=0;var e=new St(t);e.cc(t);var n=e.bc();if(!n)return oe=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(xe(i,n,e.Sb+16))return oe=i,t}return oe=n,t},t:Tt,M:function(){var t=_t.pop();t||at("no exception to throw");var e=t.Zb;throw t.kc()||(_t.push(t),t.ic(!0),t.hc(!1),Ot++),At=e,e},c:function(t,e,n){throw new St(t).fc(e,n),At=t,Ot++,t},pa:function(){return Ot},Fa:function(t){ge(t,!w,1,!v),ht.pc()},T:function(t){O?postMessage({cmd:"cleanupThread",thread:t}):st(t)},xa:Mt,j:function(t){throw At||(At=t),t},H:Ct,Ma:xt,ua:Rt,wa:jt,oa:kt,Ka:Dt,Ca:Pt,Ja:Ut,V:Ft,va:It,sa:Wt,La:Ht,ta:Lt,Ta:function(){},X:function(){at("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},Ua:function(){at("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},W:function(){return Date.now()},ya:function(){return 2097152},Oa:function(){return!0},za:function(t,e,n,r){if(t==e)setTimeout((()=>zt(r)));else if(O)postMessage({targetThread:t,cmd:"processProxyingQueue",queue:r});else{if(!(t=ht.Vb[t]))return;t.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},Ea:function(){return-1},Pa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getUTCSeconds(),a()[e+4>>2>>>0]=t.getUTCMinutes(),a()[e+8>>2>>>0]=t.getUTCHours(),a()[e+12>>2>>>0]=t.getUTCDate(),a()[e+16>>2>>>0]=t.getUTCMonth(),a()[e+20>>2>>>0]=t.getUTCFullYear()-1900,a()[e+24>>2>>>0]=t.getUTCDay(),t=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[e+28>>2>>>0]=t},Qa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getSeconds(),a()[e+4>>2>>>0]=t.getMinutes(),a()[e+8>>2>>>0]=t.getHours(),a()[e+12>>2>>>0]=t.getDate(),a()[e+16>>2>>>0]=t.getMonth(),a()[e+20>>2>>>0]=t.getFullYear()-1900,a()[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1),r=(t.getTime()-n.getTime())/864e5|0;a()[e+28>>2>>>0]=r,a()[e+36>>2>>>0]=-60*t.getTimezoneOffset(),r=new Date(t.getFullYear(),6,1).getTimezoneOffset(),t=0|(r!=(n=n.getTimezoneOffset())&&t.getTimezoneOffset()==Math.min(n,r)),a()[e+32>>2>>>0]=t},Ra:function(t){var e=new Date(a()[t+20>>2>>>0]+1900,a()[t+16>>2>>>0],a()[t+12>>2>>>0],a()[t+8>>2>>>0],a()[t+4>>2>>>0],a()[t>>2>>>0],0),n=a()[t+32>>2>>>0],r=e.getTimezoneOffset(),i=new Date(e.getFullYear(),0,1),o=new Date(e.getFullYear(),6,1).getTimezoneOffset(),u=i.getTimezoneOffset(),c=Math.min(u,o);return 0>n?a()[t+32>>2>>>0]=Number(o!=u&&c==r):0<n!=(c==r)&&(o=Math.max(u,o),e.setTime(e.getTime()+6e4*((0<n?c:o)-r))),a()[t+24>>2>>>0]=e.getDay(),n=(e.getTime()-i.getTime())/864e5|0,a()[t+28>>2>>>0]=n,a()[t>>2>>>0]=e.getSeconds(),a()[t+4>>2>>>0]=e.getMinutes(),a()[t+8>>2>>>0]=e.getHours(),a()[t+12>>2>>>0]=e.getDate(),a()[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},Aa:Bt,Ba:Gt,Sa:function t(e,n,r){t.Ac||(t.Ac=!0,Vt(e,n,r))},y:function(){at("")},U:function(){if(!_&&!w){var t="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";vt||(vt={}),vt[t]||(vt[t]=1,_&&(t="warning: "+t),x(t))}},ra:function(){return 4294901760},B:wt,Ia:function(t,e,n){r().copyWithin(t>>>0,e>>>0,e+n>>>0)},F:function(){return _?n(993).cpus().length:navigator.hardwareConcurrency},Da:function(t,e,n){Xt.length=e,n>>=3;for(var r=0;r<e;r++)Xt[r]=o()[n+r>>>0];return(0>t?ut[-t-1]:fe[t]).apply(null,Xt)},qa:function(t){var e=r().length;if((t>>>=0)<=e||4294901760<t)return!1;for(var n=1;4>=n;n*=2){var a=e*(1+.2/n);a=Math.min(a,t+100663296);var i=Math;a=Math.max(t,a),i=i.min.call(i,4294901760,a+(65536-a%65536)%65536);t:{try{j.grow(i-D.byteLength+65535>>>16),N(j.buffer);var o=1;break t}catch(t){}o=void 0}if(o)return!0}return!1},Na:function(){throw"unwind"},Ga:Qt,Ha:Kt,J:pt,I:te,S:ee,ga:ne,R:ie,d:function(){return oe},na:function t(r,a){t.lc||(t.lc=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(_)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>at("randomDevice")}());for(var i=0;i<a;i++)e()[r+i>>0>>>0]=t.lc();return 0},ia:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ja:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},K:function(t){var e=Ee();try{return gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},f:function(t,e){var n=Ee();try{return gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},P:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},Q:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},k:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},p:function(t,e,n,r){var a=Ee();try{return gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},q:function(t,e,n,r,a){var i=Ee();try{return gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},N:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},s:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},w:function(t,e,n,r,a,i,o){var u=Ee();try{return gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},L:function(t,e,n,r,a,i,o,u){var c=Ee();try{return gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},E:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{return gt(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=Ee();try{return He(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},_:function(t,e,n,r,a,i,o){var u=Ee();try{return ke(t,e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},Z:function(t,e,n,r,a){var i=Ee();try{return Le(t,e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},ca:function(t,e,n,r){var a=Ee();try{return Ie(t,e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},$:function(t){var e=Ee();try{return je(t)}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},ba:function(t,e){var n=Ee();try{return We(t,e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},Y:function(t,e,n){var r=Ee();try{return De(t,e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},g:function(t){var e=Ee();try{gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},r:function(t,e){var n=Ee();try{gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},i:function(t,e,n){var r=Ee();try{gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ha:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},m:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},v:function(t,e,n,r,a){var i=Ee();try{gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},u:function(t,e,n,r,a,i){var o=Ee();try{gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},O:function(t,e,n,r,a,i,o){var u=Ee();try{gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},A:function(t,e,n,r,a,i,o,u){var c=Ee();try{gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},ka:function(t,e,n,r,a,i,o,u,c){var s=Ee();try{gt(t)(e,n,r,a,i,o,u,c)}catch(t){if(Me(s),t!==t+0)throw t;Se(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l){var f=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(Me(f),t!==t+0)throw t;Se(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(Me(b),t!==t+0)throw t;Se(1,0)}},fa:function(t,e,n,r,a,i,o,u){var c=Ee();try{Pe(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},da:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{Fe(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},ea:function(t,e,n,r,a,i){var o=Ee();try{Ue(t,e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},o:function(t){return t},a:j||u.wasmMemory,G:function(t){oe=t},la:le,z:function(t,e,n,r){return le(t,e,n,r)}};!function(){function t(t,e){u.asm=t.exports,ht.qc.push(u.asm.sb),$=u.asm.ub,X.unshift(u.asm.Va),k=e,O||(et--,u.monitorRunDependencies&&u.monitorRunDependencies(et),0==et&&(null!==nt&&(clearInterval(nt),nt=null),rt&&(t=rt,rt=null,t())))}function e(e){t(e.instance,e.module)}function n(t){return function(){if(!M&&(v||w)){if("function"==typeof fetch&&!tt.startsWith("file://"))return fetch(tt,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+tt+"\'";return t.arrayBuffer()})).catch((function(){return ot()}));if(f)return new Promise((function(t,e){f(tt,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return ot()}))}().then((function(t){return WebAssembly.instantiate(t,r)})).then((function(t){return t})).then(t,(function(t){x("failed to asynchronously prepare wasm: "+t),at(t)}))}var r={a:pe};if(O||(et++,u.monitorRunDependencies&&u.monitorRunDependencies(et)),u.instantiateWasm)try{return u.instantiateWasm(r,t)}catch(t){return x("Module.instantiateWasm callback failed with error: "+t),!1}(M||"function"!=typeof WebAssembly.instantiateStreaming||it()||tt.startsWith("file://")||_||"function"!=typeof fetch?n(e):fetch(tt,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,r).then(e,(function(t){return x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation"),n(e)}))}))).catch(s)}(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.Va).apply(null,arguments)},u._OrtInit=function(){return(u._OrtInit=u.asm.Wa).apply(null,arguments)},u._OrtCreateSessionOptions=function(){return(u._OrtCreateSessionOptions=u.asm.Xa).apply(null,arguments)},u._OrtAppendExecutionProvider=function(){return(u._OrtAppendExecutionProvider=u.asm.Ya).apply(null,arguments)},u._OrtAddSessionConfigEntry=function(){return(u._OrtAddSessionConfigEntry=u.asm.Za).apply(null,arguments)},u._OrtReleaseSessionOptions=function(){return(u._OrtReleaseSessionOptions=u.asm._a).apply(null,arguments)},u._OrtCreateSession=function(){return(u._OrtCreateSession=u.asm.$a).apply(null,arguments)},u._OrtReleaseSession=function(){return(u._OrtReleaseSession=u.asm.ab).apply(null,arguments)},u._OrtGetInputCount=function(){return(u._OrtGetInputCount=u.asm.bb).apply(null,arguments)},u._OrtGetOutputCount=function(){return(u._OrtGetOutputCount=u.asm.cb).apply(null,arguments)},u._OrtGetInputName=function(){return(u._OrtGetInputName=u.asm.db).apply(null,arguments)},u._OrtGetOutputName=function(){return(u._OrtGetOutputName=u.asm.eb).apply(null,arguments)},u._OrtFree=function(){return(u._OrtFree=u.asm.fb).apply(null,arguments)},u._OrtCreateTensor=function(){return(u._OrtCreateTensor=u.asm.gb).apply(null,arguments)},u._OrtGetTensorData=function(){return(u._OrtGetTensorData=u.asm.hb).apply(null,arguments)},u._OrtReleaseTensor=function(){return(u._OrtReleaseTensor=u.asm.ib).apply(null,arguments)},u._OrtCreateRunOptions=function(){return(u._OrtCreateRunOptions=u.asm.jb).apply(null,arguments)},u._OrtAddRunConfigEntry=function(){return(u._OrtAddRunConfigEntry=u.asm.kb).apply(null,arguments)},u._OrtReleaseRunOptions=function(){return(u._OrtReleaseRunOptions=u.asm.lb).apply(null,arguments)},u._OrtRun=function(){return(u._OrtRun=u.asm.mb).apply(null,arguments)},u._OrtEndProfiling=function(){return(u._OrtEndProfiling=u.asm.nb).apply(null,arguments)};var he=u._pthread_self=function(){return(he=u._pthread_self=u.asm.ob).apply(null,arguments)},de=u._malloc=function(){return(de=u._malloc=u.asm.pb).apply(null,arguments)},ye=u._free=function(){return(ye=u._free=u.asm.qb).apply(null,arguments)},be=u._fflush=function(){return(be=u._fflush=u.asm.rb).apply(null,arguments)};u.__emscripten_tls_init=function(){return(u.__emscripten_tls_init=u.asm.sb).apply(null,arguments)};var me=u.___funcs_on_exit=function(){return(me=u.___funcs_on_exit=u.asm.tb).apply(null,arguments)},ge=u.__emscripten_thread_init=function(){return(ge=u.__emscripten_thread_init=u.asm.vb).apply(null,arguments)};u.__emscripten_thread_crashed=function(){return(u.__emscripten_thread_crashed=u.asm.wb).apply(null,arguments)};var ve,we=u._emscripten_run_in_main_runtime_thread_js=function(){return(we=u._emscripten_run_in_main_runtime_thread_js=u.asm.xb).apply(null,arguments)},_e=u.__emscripten_proxy_execute_task_queue=function(){return(_e=u.__emscripten_proxy_execute_task_queue=u.asm.yb).apply(null,arguments)},Oe=u.__emscripten_thread_free_data=function(){return(Oe=u.__emscripten_thread_free_data=u.asm.zb).apply(null,arguments)},Ae=u.__emscripten_thread_exit=function(){return(Ae=u.__emscripten_thread_exit=u.asm.Ab).apply(null,arguments)},Se=u._setThrew=function(){return(Se=u._setThrew=u.asm.Bb).apply(null,arguments)},Te=u._emscripten_stack_set_limits=function(){return(Te=u._emscripten_stack_set_limits=u.asm.Cb).apply(null,arguments)},Ee=u.stackSave=function(){return(Ee=u.stackSave=u.asm.Db).apply(null,arguments)},Me=u.stackRestore=function(){return(Me=u.stackRestore=u.asm.Eb).apply(null,arguments)},Ce=u.stackAlloc=function(){return(Ce=u.stackAlloc=u.asm.Fb).apply(null,arguments)},xe=u.___cxa_can_catch=function(){return(xe=u.___cxa_can_catch=u.asm.Gb).apply(null,arguments)},Re=u.___cxa_is_pointer_type=function(){return(Re=u.___cxa_is_pointer_type=u.asm.Hb).apply(null,arguments)},je=u.dynCall_j=function(){return(je=u.dynCall_j=u.asm.Ib).apply(null,arguments)},ke=u.dynCall_iiiiij=function(){return(ke=u.dynCall_iiiiij=u.asm.Jb).apply(null,arguments)},De=u.dynCall_jii=function(){return(De=u.dynCall_jii=u.asm.Kb).apply(null,arguments)},Pe=u.dynCall_viiiiij=function(){return(Pe=u.dynCall_viiiiij=u.asm.Lb).apply(null,arguments)},Ue=u.dynCall_vjji=function(){return(Ue=u.dynCall_vjji=u.asm.Mb).apply(null,arguments)},Fe=u.dynCall_viiijjjii=function(){return(Fe=u.dynCall_viiijjjii=u.asm.Nb).apply(null,arguments)},Ie=u.dynCall_iij=function(){return(Ie=u.dynCall_iij=u.asm.Ob).apply(null,arguments)},We=u.dynCall_ji=function(){return(We=u.dynCall_ji=u.asm.Pb).apply(null,arguments)},He=u.dynCall_iiiiiij=function(){return(He=u.dynCall_iiiiiij=u.asm.Qb).apply(null,arguments)},Le=u.dynCall_iiij=function(){return(Le=u.dynCall_iiij=u.asm.Rb).apply(null,arguments)};function ze(){function t(){if(!ve&&(ve=!0,u.calledRun=!0,!H)&&(O||dt(X),c(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),!O)){if(u.postRun)for("function"==typeof u.postRun&&(u.postRun=[u.postRun]);u.postRun.length;){var t=u.postRun.shift();Z.unshift(t)}dt(Z)}}if(!(0<et))if(O)c(u),O||dt(X),postMessage({cmd:"loaded"});else{if(u.preRun)for("function"==typeof u.preRun&&(u.preRun=[u.preRun]);u.preRun.length;)K();dt(q),0<et||(u.setStatus?(u.setStatus("Running..."),setTimeout((function(){setTimeout((function(){u.setStatus("")}),1),t()}),1)):t())}}if(u.UTF8ToString=Y,u.stringToUTF8=function(t,e,n){return B(t,r(),e,n)},u.lengthBytesUTF8=G,u.keepRuntimeAlive=Q,u.wasmMemory=j,u.stackSave=Ee,u.stackRestore=Me,u.stackAlloc=Ce,u.ExitStatus=ct,u.PThread=ht,rt=function t(){ve||ze(),ve||(rt=t)},u.preInit)for("function"==typeof u.preInit&&(u.preInit=[u.preInit]);0<u.preInit.length;)u.preInit.pop()();return ze(),t.ready});t.exports=r},932:(t,e,n)=>{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){var e,r,a;t=t||{},e||(e=void 0!==t?t:{}),e.ready=new Promise((function(t,e){r=t,a=e}));var i,o,u,c,s,l,f=Object.assign({},e),p="./this.program",h=(t,e)=>{throw e},d="object"==typeof window,y="function"==typeof importScripts,b="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,m="";b?(m=y?n(908).dirname(m)+"/":"//",l=()=>{s||(c=n(384),s=n(908))},i=function(t,e){return l(),t=s.normalize(t),c.readFileSync(t,e?void 0:"utf8")},u=t=>((t=i(t,!0)).buffer||(t=new Uint8Array(t)),t),o=(t,e,n)=>{l(),t=s.normalize(t),c.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1<process.argv.length&&(p=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof J))throw t})),process.on("unhandledRejection",(function(t){throw t})),h=(t,e)=>{if(_||0<L)throw process.exitCode=t,e;e instanceof J||w("exiting due to exception: "+e),process.exit(t)},e.inspect=function(){return"[Emscripten Module object]"}):(d||y)&&(y?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),_scriptDir&&(m=_scriptDir),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},y&&(u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),o=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var g,v=e.print||console.log.bind(console),w=e.printErr||console.warn.bind(console);Object.assign(e,f),f=null,e.thisProgram&&(p=e.thisProgram),e.quit&&(h=e.quit),e.wasmBinary&&(g=e.wasmBinary);var _=e.noExitRuntime||!1;"object"!=typeof WebAssembly&&V("no native wasm support detected");var O,A,S,T,E,M,C=!1,x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function R(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16<n-e&&t.buffer&&x)return x.decode(t.subarray(e,n));for(r="";e<n;){var a=t[e++];if(128&a){var i=63&t[e++];if(192==(224&a))r+=String.fromCharCode((31&a)<<6|i);else{var o=63&t[e++];65536>(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function j(t,e){return(t>>>=0)?R(T,t,e):""}function k(t,e,n,r){if(!(0<r))return 0;var a=n>>>=0;r=n+r-1;for(var i=0;i<t.length;++i){var o=t.charCodeAt(i);if(55296<=o&&57343>=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function D(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);127>=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function P(){var t=O.buffer;A=t,e.HEAP8=S=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=E=new Int32Array(t),e.HEAPU8=T=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=M=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}var U,F=[],I=[],W=[],H=[],L=0;function z(){var t=e.preRun.shift();F.unshift(t)}var Y,B=0,G=null,N=null;function V(t){throw e.onAbort&&e.onAbort(t),w(t="Aborted("+t+")"),C=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),a(t),t}function $(){return Y.startsWith("data:application/octet-stream;base64,")}if(Y="ort-wasm.wasm",!$()){var q=Y;Y=e.locateFile?e.locateFile(q,m):m+q}function X(){var t=Y;try{if(t==Y&&g)return new Uint8Array(g);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}catch(t){V(t)}}function J(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function Z(t){for(;0<t.length;)t.shift()(e)}var Q=[],K=0,tt=0;function et(t){this.Db=t,this.zb=t-24,this.Ub=function(t){M[this.zb+4>>2>>>0]=t},this.Eb=function(){return M[this.zb+4>>2>>>0]},this.Sb=function(t){M[this.zb+8>>2>>>0]=t},this.Wb=function(){return M[this.zb+8>>2>>>0]},this.Tb=function(){E[this.zb>>2>>>0]=0},this.Ib=function(t){S[this.zb+12>>0>>>0]=t?1:0},this.Pb=function(){return 0!=S[this.zb+12>>0>>>0]},this.Jb=function(t){S[this.zb+13>>0>>>0]=t?1:0},this.Lb=function(){return 0!=S[this.zb+13>>0>>>0]},this.Rb=function(t,e){this.Fb(0),this.Ub(t),this.Sb(e),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){E[this.zb>>2>>>0]+=1},this.Xb=function(){var t=E[this.zb>>2>>>0];return E[this.zb>>2>>>0]=t-1,1===t},this.Fb=function(t){M[this.zb+16>>2>>>0]=t},this.Ob=function(){return M[this.zb+16>>2>>>0]},this.Qb=function(){if(Mt(this.Eb()))return M[this.Db>>2>>>0];var t=this.Ob();return 0!==t?t:this.Db}}function nt(t){return vt(new et(t).zb)}var rt=[];function at(t){var e=rt[t];return e||(t>=rt.length&&(rt.length=t+1),rt[t]=e=U.get(t)),e}function it(t){var e=D(t)+1,n=gt(e);return n&&k(t,S,n,e),n}var ot={};function ut(){if(!ct){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:p||"./this.program"};for(t in ot)void 0===ot[t]?delete e[t]:e[t]=ot[t];var n=[];for(t in e)n.push(t+"="+e[t]);ct=n}return ct}var ct,st=[null,[],[]];function lt(t,e){var n=st[t];0===e||10===e?((1===t?v:w)(R(n,0)),n.length=0):n.push(e)}var ft=0;function pt(t){return 0==t%4&&(0!=t%100||0==t%400)}var ht=[31,29,31,30,31,30,31,31,30,31,30,31],dt=[31,28,31,30,31,30,31,31,30,31,30,31];function yt(t,e,n,r){function a(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.length<e;)t=n[0]+t;return t}function i(t,e){return a(t,e,"0")}function o(t,e){function n(t){return 0>t?-1:0<t?1:0}var r;return 0===(r=n(t.getFullYear()-e.getFullYear()))&&0===(r=n(t.getMonth()-e.getMonth()))&&(r=n(t.getDate()-e.getDate())),r}function u(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function c(t){var e=t.Bb;for(t=new Date(new Date(t.Cb+1900,0,1).getTime());0<e;){var n=t.getMonth(),r=(pt(t.getFullYear())?ht:dt)[n];if(!(e>r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=u(new Date(t.getFullYear(),0,4)),n=u(n),0>=o(e,t)?0>=o(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var s=E[r+40>>2>>>0];for(var l in r={$b:E[r>>2>>>0],Zb:E[r+4>>2>>>0],Gb:E[r+8>>2>>>0],Kb:E[r+12>>2>>>0],Hb:E[r+16>>2>>>0],Cb:E[r+20>>2>>>0],Ab:E[r+24>>2>>>0],Bb:E[r+28>>2>>>0],bc:E[r+32>>2>>>0],Yb:E[r+36>>2>>>0],ac:s?j(s):""},n=j(n),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(l,"g"),s[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(l in s={"%a":function(t){return f[t.Ab].substring(0,3)},"%A":function(t){return f[t.Ab]},"%b":function(t){return p[t.Hb].substring(0,3)},"%B":function(t){return p[t.Hb]},"%C":function(t){return i((t.Cb+1900)/100|0,2)},"%d":function(t){return i(t.Kb,2)},"%e":function(t){return a(t.Kb,2," ")},"%g":function(t){return c(t).toString().substring(2)},"%G":function(t){return c(t)},"%H":function(t){return i(t.Gb,2)},"%I":function(t){return 0==(t=t.Gb)?t=12:12<t&&(t-=12),i(t,2)},"%j":function(t){for(var e=0,n=0;n<=t.Hb-1;e+=(pt(t.Cb+1900)?ht:dt)[n++]);return i(t.Kb+e,3)},"%m":function(t){return i(t.Hb+1,2)},"%M":function(t){return i(t.Zb,2)},"%n":function(){return"\\n"},"%p":function(t){return 0<=t.Gb&&12>t.Gb?"AM":"PM"},"%S":function(t){return i(t.$b,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Ab||7},"%U":function(t){return i(Math.floor((t.Bb+7-t.Ab)/7),2)},"%V":function(t){var e=Math.floor((t.Bb+7-(t.Ab+6)%7)/7);if(2>=(t.Ab+371-t.Bb-2)%7&&e++,e)53==e&&(4==(n=(t.Ab+371-t.Bb)%7)||3==n&&pt(t.Cb)||(e=1));else{e=52;var n=(t.Ab+7-t.Bb-1)%7;(4==n||5==n&&pt(t.Cb%400-1))&&e++}return i(e,2)},"%w":function(t){return t.Ab},"%W":function(t){return i(Math.floor((t.Bb+7-(t.Ab+6)%7)/7),2)},"%y":function(t){return(t.Cb+1900).toString().substring(2)},"%Y":function(t){return t.Cb+1900},"%z":function(t){var e=0<=(t=t.Yb);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.ac},"%%":function(){return"%"}},n=n.replace(/%%/g,"\\0\\0"),s)n.includes(l)&&(n=n.replace(new RegExp(l,"g"),s[l](r)));return l=function(t){var e=Array(D(t)+1);return k(t,e,0,e.length),e}(n=n.replace(/\\0\\0/g,"%")),l.length>e?0:(S.set(l,t>>>0),l.length-1)}var bt={a:function(t){return gt(t+24)+24},m:function(t){return(t=new et(t)).Pb()||(t.Ib(!0),K--),t.Jb(!1),Q.push(t),t.Nb(),t.Qb()},ia:function(t){throw w("Unexpected exception thrown, this is not properly supported - aborting"),C=!0,t},w:function(){Ot(0);var t=Q.pop();if(t.Xb()&&!t.Lb()){var e=t.Wb();e&&at(e)(t.Db),nt(t.Db)}tt=0},d:function(){var t=tt;if(!t)return ft=0;var e=new et(t);e.Fb(t);var n=e.Eb();if(!n)return ft=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(Et(i,n,e.zb+16))return ft=i,t}return ft=n,t},k:function(){var t=tt;if(!t)return ft=0;var e=new et(t);e.Fb(t);var n=e.Eb();if(!n)return ft=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(Et(i,n,e.zb+16))return ft=i,t}return ft=n,t},g:function(){var t=tt;if(!t)return ft=0;var e=new et(t);e.Fb(t);var n=e.Eb();if(!n)return ft=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a<r.length;a++){var i=r[a];if(0===i||i===n)break;if(Et(i,n,e.zb+16))return ft=i,t}return ft=n,t},s:nt,L:function(){var t=Q.pop();t||V("no exception to throw");var e=t.Db;throw t.Lb()||(Q.push(t),t.Jb(!0),t.Ib(!1),K++),tt=e,e},b:function(t,e,n){throw new et(t).Rb(e,n),tt=t,K++,t},la:function(){return K},i:function(t){throw tt||(tt=t),t},H:function(){return 0},Ba:function(){},pa:function(){},ra:function(){},ka:function(){return 0},za:function(){},ua:function(){},ya:function(){},R:function(){},qa:function(){},na:function(){},Aa:function(){},oa:function(){},Ha:function(){},Ja:function(){V("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},Ia:function(){V("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},S:function(){return Date.now()},Ca:function(){return!0},Da:function(t,e){t=new Date(1e3*(M[t>>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getUTCSeconds(),E[e+4>>2>>>0]=t.getUTCMinutes(),E[e+8>>2>>>0]=t.getUTCHours(),E[e+12>>2>>>0]=t.getUTCDate(),E[e+16>>2>>>0]=t.getUTCMonth(),E[e+20>>2>>>0]=t.getUTCFullYear()-1900,E[e+24>>2>>>0]=t.getUTCDay(),E[e+28>>2>>>0]=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(t,e){t=new Date(1e3*(M[t>>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getSeconds(),E[e+4>>2>>>0]=t.getMinutes(),E[e+8>>2>>>0]=t.getHours(),E[e+12>>2>>>0]=t.getDate(),E[e+16>>2>>>0]=t.getMonth(),E[e+20>>2>>>0]=t.getFullYear()-1900,E[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1);E[e+28>>2>>>0]=(t.getTime()-n.getTime())/864e5|0,E[e+36>>2>>>0]=-60*t.getTimezoneOffset();var r=new Date(t.getFullYear(),6,1).getTimezoneOffset();n=n.getTimezoneOffset(),E[e+32>>2>>>0]=0|(r!=n&&t.getTimezoneOffset()==Math.min(n,r))},Fa:function(t){var e=new Date(E[t+20>>2>>>0]+1900,E[t+16>>2>>>0],E[t+12>>2>>>0],E[t+8>>2>>>0],E[t+4>>2>>>0],E[t>>2>>>0],0),n=E[t+32>>2>>>0],r=e.getTimezoneOffset(),a=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear(),6,1).getTimezoneOffset(),o=a.getTimezoneOffset(),u=Math.min(o,i);return 0>n?E[t+32>>2>>>0]=Number(i!=o&&u==r):0<n!=(u==r)&&(i=Math.max(o,i),e.setTime(e.getTime()+6e4*((0<n?u:i)-r))),E[t+24>>2>>>0]=e.getDay(),E[t+28>>2>>>0]=(e.getTime()-a.getTime())/864e5|0,E[t>>2>>>0]=e.getSeconds(),E[t+4>>2>>>0]=e.getMinutes(),E[t+8>>2>>>0]=e.getHours(),E[t+12>>2>>>0]=e.getDate(),E[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function t(e,n,r){t.Vb||(t.Vb=!0,function(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}var a=(new Date).getFullYear(),i=new Date(a,0,1),o=new Date(a,6,1);a=i.getTimezoneOffset();var u=o.getTimezoneOffset();E[t>>2>>>0]=60*Math.max(a,u),E[e>>2>>>0]=Number(a!=u),t=r(i),e=r(o),t=it(t),e=it(e),u<a?(M[n>>2>>>0]=t,M[n+4>>2>>>0]=e):(M[n>>2>>>0]=e,M[n+4>>2>>>0]=t)}(e,n,r))},B:function(){V("")},ma:function(){return 4294901760},I:b?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:()=>performance.now(),xa:function(t,e,n){T.copyWithin(t>>>0,e>>>0,e+n>>>0)},G:function(t){var e=T.length;if(4294901760<(t>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=e*(1+.2/n);r=Math.min(r,t+100663296);var a=Math;r=Math.max(t,r),a=a.min.call(a,4294901760,r+(65536-r%65536)%65536);t:{try{O.grow(a-A.byteLength+65535>>>16),P();var i=1;break t}catch(t){}i=void 0}if(i)return!0}return!1},va:function(t,e){var n=0;return ut().forEach((function(r,a){var i=e+n;for(a=M[t+4*a>>2>>>0]=i,i=0;i<r.length;++i)S[a++>>0>>>0]=r.charCodeAt(i);S[a>>0>>>0]=0,n+=r.length+1})),0},wa:function(t,e){var n=ut();M[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),M[e>>2>>>0]=r,0},ba:function(t){_||0<L||(_t(),Z(W),wt(0),st[1].length&<(1,10),st[2].length&<(2,10)),_||0<L||(e.onExit&&e.onExit(t),C=!0),h(t,new J(t))},E:function(){return 52},Q:function(){return 52},ca:function(){return 70},P:function(t,e,n,r){for(var a=0,i=0;i<n;i++){var o=M[e>>2>>>0],u=M[e+4>>2>>>0];e+=8;for(var c=0;c<u;c++)lt(t,T[o+c>>>0]);a+=u}return M[r>>2>>>0]=a,0},c:function(){return ft},ja:function t(e,r){t.Mb||(t.Mb=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(b)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>V("randomDevice")}());for(var a=0;a<r;a++)S[e+a>>0>>>0]=t.Mb();return 0},ea:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},fa:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},J:function(t){var e=At();try{return at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},e:function(t,e){var n=At();try{return at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},N:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},O:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},j:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},o:function(t,e,n,r){var a=At();try{return at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},p:function(t,e,n,r,a){var i=At();try{return at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},M:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},r:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},v:function(t,e,n,r,a,i,o){var u=At();try{return at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},K:function(t,e,n,r,a,i,o,u){var c=At();try{return at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{return at(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},X:function(t,e,n,r,a,i,o,u){var c=At();try{return Ft(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},V:function(t,e,n,r,a,i,o){var u=At();try{return xt(t,e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},U:function(t,e,n,r,a){var i=At();try{return It(t,e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},Z:function(t,e,n,r){var a=At();try{return Pt(t,e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},W:function(t){var e=At();try{return Ct(t)}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},Y:function(t,e){var n=At();try{return Ut(t,e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},T:function(t,e,n){var r=At();try{return Rt(t,e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},f:function(t){var e=At();try{at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},q:function(t,e){var n=At();try{at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},h:function(t,e,n){var r=At();try{at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},da:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},l:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},t:function(t,e,n,r,a){var i=At();try{at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},u:function(t,e,n,r,a,i){var o=At();try{at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},x:function(t,e,n,r,a,i,o){var u=At();try{at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},z:function(t,e,n,r,a,i,o,u){var c=At();try{at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},ga:function(t,e,n,r,a,i,o,u,c){var s=At();try{at(t)(e,n,r,a,i,o,u,c)}catch(t){if(St(s),t!==t+0)throw t;Ot(1,0)}},A:function(t,e,n,r,a,i,o,u,c,s,l){var f=At();try{at(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(St(f),t!==t+0)throw t;Ot(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=At();try{at(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(St(b),t!==t+0)throw t;Ot(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=At();try{jt(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},_:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{Dt(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},$:function(t,e,n,r,a,i){var o=At();try{kt(t,e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},n:function(t){return t},F:function(t){ft=t},ha:yt,y:function(t,e,n,r){return yt(t,e,n,r)}};!function(){function t(t){e.asm=t.exports,O=e.asm.Ka,P(),U=e.asm.ib,I.unshift(e.asm.La),B--,e.monitorRunDependencies&&e.monitorRunDependencies(B),0==B&&(null!==G&&(clearInterval(G),G=null),N&&(t=N,N=null,t()))}function n(e){t(e.instance)}function r(t){return function(){if(!g&&(d||y)){if("function"==typeof fetch&&!Y.startsWith("file://"))return fetch(Y,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+Y+"\'";return t.arrayBuffer()})).catch((function(){return X()}));if(o)return new Promise((function(t,e){o(Y,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return X()}))}().then((function(t){return WebAssembly.instantiate(t,i)})).then((function(t){return t})).then(t,(function(t){w("failed to asynchronously prepare wasm: "+t),V(t)}))}var i={a:bt};if(B++,e.monitorRunDependencies&&e.monitorRunDependencies(B),e.instantiateWasm)try{return e.instantiateWasm(i,t)}catch(t){return w("Module.instantiateWasm callback failed with error: "+t),!1}(g||"function"!=typeof WebAssembly.instantiateStreaming||$()||Y.startsWith("file://")||b||"function"!=typeof fetch?r(n):fetch(Y,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(n,(function(t){return w("wasm streaming compile failed: "+t),w("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(a)}(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.La).apply(null,arguments)},e._OrtInit=function(){return(e._OrtInit=e.asm.Ma).apply(null,arguments)},e._OrtCreateSessionOptions=function(){return(e._OrtCreateSessionOptions=e.asm.Na).apply(null,arguments)},e._OrtAppendExecutionProvider=function(){return(e._OrtAppendExecutionProvider=e.asm.Oa).apply(null,arguments)},e._OrtAddSessionConfigEntry=function(){return(e._OrtAddSessionConfigEntry=e.asm.Pa).apply(null,arguments)},e._OrtReleaseSessionOptions=function(){return(e._OrtReleaseSessionOptions=e.asm.Qa).apply(null,arguments)},e._OrtCreateSession=function(){return(e._OrtCreateSession=e.asm.Ra).apply(null,arguments)},e._OrtReleaseSession=function(){return(e._OrtReleaseSession=e.asm.Sa).apply(null,arguments)},e._OrtGetInputCount=function(){return(e._OrtGetInputCount=e.asm.Ta).apply(null,arguments)},e._OrtGetOutputCount=function(){return(e._OrtGetOutputCount=e.asm.Ua).apply(null,arguments)},e._OrtGetInputName=function(){return(e._OrtGetInputName=e.asm.Va).apply(null,arguments)},e._OrtGetOutputName=function(){return(e._OrtGetOutputName=e.asm.Wa).apply(null,arguments)},e._OrtFree=function(){return(e._OrtFree=e.asm.Xa).apply(null,arguments)},e._OrtCreateTensor=function(){return(e._OrtCreateTensor=e.asm.Ya).apply(null,arguments)},e._OrtGetTensorData=function(){return(e._OrtGetTensorData=e.asm.Za).apply(null,arguments)},e._OrtReleaseTensor=function(){return(e._OrtReleaseTensor=e.asm._a).apply(null,arguments)},e._OrtCreateRunOptions=function(){return(e._OrtCreateRunOptions=e.asm.$a).apply(null,arguments)},e._OrtAddRunConfigEntry=function(){return(e._OrtAddRunConfigEntry=e.asm.ab).apply(null,arguments)},e._OrtReleaseRunOptions=function(){return(e._OrtReleaseRunOptions=e.asm.bb).apply(null,arguments)},e._OrtRun=function(){return(e._OrtRun=e.asm.cb).apply(null,arguments)},e._OrtEndProfiling=function(){return(e._OrtEndProfiling=e.asm.db).apply(null,arguments)};var mt,gt=e._malloc=function(){return(gt=e._malloc=e.asm.eb).apply(null,arguments)},vt=e._free=function(){return(vt=e._free=e.asm.fb).apply(null,arguments)},wt=e._fflush=function(){return(wt=e._fflush=e.asm.gb).apply(null,arguments)},_t=e.___funcs_on_exit=function(){return(_t=e.___funcs_on_exit=e.asm.hb).apply(null,arguments)},Ot=e._setThrew=function(){return(Ot=e._setThrew=e.asm.jb).apply(null,arguments)},At=e.stackSave=function(){return(At=e.stackSave=e.asm.kb).apply(null,arguments)},St=e.stackRestore=function(){return(St=e.stackRestore=e.asm.lb).apply(null,arguments)},Tt=e.stackAlloc=function(){return(Tt=e.stackAlloc=e.asm.mb).apply(null,arguments)},Et=e.___cxa_can_catch=function(){return(Et=e.___cxa_can_catch=e.asm.nb).apply(null,arguments)},Mt=e.___cxa_is_pointer_type=function(){return(Mt=e.___cxa_is_pointer_type=e.asm.ob).apply(null,arguments)},Ct=e.dynCall_j=function(){return(Ct=e.dynCall_j=e.asm.pb).apply(null,arguments)},xt=e.dynCall_iiiiij=function(){return(xt=e.dynCall_iiiiij=e.asm.qb).apply(null,arguments)},Rt=e.dynCall_jii=function(){return(Rt=e.dynCall_jii=e.asm.rb).apply(null,arguments)},jt=e.dynCall_viiiiij=function(){return(jt=e.dynCall_viiiiij=e.asm.sb).apply(null,arguments)},kt=e.dynCall_vjji=function(){return(kt=e.dynCall_vjji=e.asm.tb).apply(null,arguments)},Dt=e.dynCall_viiijjjii=function(){return(Dt=e.dynCall_viiijjjii=e.asm.ub).apply(null,arguments)},Pt=e.dynCall_iij=function(){return(Pt=e.dynCall_iij=e.asm.vb).apply(null,arguments)},Ut=e.dynCall_ji=function(){return(Ut=e.dynCall_ji=e.asm.wb).apply(null,arguments)},Ft=e.dynCall_iiiiiij=function(){return(Ft=e.dynCall_iiiiiij=e.asm.xb).apply(null,arguments)},It=e.dynCall_iiij=function(){return(It=e.dynCall_iiij=e.asm.yb).apply(null,arguments)};function Wt(){function t(){if(!mt&&(mt=!0,e.calledRun=!0,!C)){if(Z(I),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;){var t=e.postRun.shift();H.unshift(t)}Z(H)}}if(!(0<B)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)z();Z(F),0<B||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),t()}),1)):t())}}if(e.UTF8ToString=j,e.stringToUTF8=function(t,e,n){return k(t,T,e,n)},e.lengthBytesUTF8=D,e.stackSave=At,e.stackRestore=St,e.stackAlloc=Tt,N=function t(){mt||Wt(),mt||(N=t)},e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return Wt(),t.ready});t.exports=r},967:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iterateExtraOptions=void 0,e.iterateExtraOptions=(t,n,r,a)=>{if("object"==typeof t&&null!==t){if(r.has(t))throw new Error("Circular reference in options");r.add(t)}Object.entries(t).forEach((([t,i])=>{const o=n?n+t:t;if("object"==typeof i)(0,e.iterateExtraOptions)(i,o+".",r,a);else if("string"==typeof i||"number"==typeof i)a(o,i.toString());else{if("boolean"!=typeof i)throw new Error("Can\'t handle extra config type: "+typeof i);a(o,i?"1":"0")}}))}},586:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setRunOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};try{if(void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);void 0===(null==t?void 0:t.terminate)&&(u.terminate=!1);let i=0;if(void 0!==(null==t?void 0:t.tag)&&(i=(0,a.allocWasmString)(t.tag,o)),n=e._OrtCreateRunOptions(u.logSeverityLevel,u.logVerbosityLevel,!!u.terminate,i),0===n)throw new Error("Can\'t create run options");return void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddRunConfigEntry(n,i,u))throw new Error(`Can\'t set a run config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseRunOptions(n),o.forEach(e._free),t}}},919:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setSessionOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};(t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});const e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1")})(u);try{void 0===(null==t?void 0:t.graphOptimizationLevel)&&(u.graphOptimizationLevel="all");const c=(t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}})(u.graphOptimizationLevel);void 0===(null==t?void 0:t.enableCpuMemArena)&&(u.enableCpuMemArena=!0),void 0===(null==t?void 0:t.enableMemPattern)&&(u.enableMemPattern=!0),void 0===(null==t?void 0:t.executionMode)&&(u.executionMode="sequential");const s=(t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}})(u.executionMode);let l=0;if(void 0!==(null==t?void 0:t.logId)&&(l=(0,a.allocWasmString)(t.logId,o)),void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);if(void 0===(null==t?void 0:t.enableProfiling)&&(u.enableProfiling=!1),n=e._OrtCreateSessionOptions(c,!!u.enableCpuMemArena,!!u.enableMemPattern,s,!!u.enableProfiling,0,l,u.logSeverityLevel,u.logVerbosityLevel),0===n)throw new Error("Can\'t create session options");return(null==t?void 0:t.executionProviders)&&((t,e,n)=>{for(const r of e){let e="string"==typeof r?r:r.name;switch(e){case"xnnpack":e="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${e}`)}const o=(0,a.allocWasmString)(e,n);if(0!==(0,i.getInstance)()._OrtAppendExecutionProvider(t,o))throw new Error(`Can\'t append execution provider: ${e}`)}})(n,t.executionProviders,o),void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddSessionConfigEntry(n,i,u))throw new Error(`Can\'t set a session config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseSessionOptions(n),o.forEach(e._free),t}}},983:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.allocWasmString=void 0;const r=n(361);e.allocWasmString=(t,e)=>{const n=(0,r.getInstance)(),a=n.lengthBytesUTF8(t)+1,i=n._malloc(a);return n.stringToUTF8(t,i,a),e.push(i),i}},349:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extractTransferableBuffers=e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initOrt=void 0;const r=n(586),a=n(919),i=n(983),o=n(361);e.initOrt=(t,e)=>{const n=(0,o.getInstance)()._OrtInit(t,e);if(0!==n)throw new Error(`Can\'t initialize onnxruntime. error code = ${n}`)};const u=new Map;e.createSessionAllocate=t=>{const e=(0,o.getInstance)(),n=e._malloc(t.byteLength);return e.HEAPU8.set(t,n),[n,t.byteLength]},e.createSessionFinalize=(t,e)=>{const n=(0,o.getInstance)();let r=0,i=0,c=[];try{if([i,c]=(0,a.setSessionOptions)(e),r=n._OrtCreateSession(t[0],t[1],i),0===r)throw new Error("Can\'t create a session")}finally{n._free(t[0]),n._OrtReleaseSessionOptions(i),c.forEach(n._free)}const s=n._OrtGetInputCount(r),l=n._OrtGetOutputCount(r),f=[],p=[],h=[],d=[];for(let t=0;t<s;t++){const e=n._OrtGetInputName(r,t);if(0===e)throw new Error("Can\'t get an input name");p.push(e),f.push(n.UTF8ToString(e))}for(let t=0;t<l;t++){const e=n._OrtGetOutputName(r,t);if(0===e)throw new Error("Can\'t get an output name");d.push(e),h.push(n.UTF8ToString(e))}return u.set(r,[r,p,d]),[r,f,h]},e.createSession=(t,n)=>{const r=(0,e.createSessionAllocate)(t);return(0,e.createSessionFinalize)(r,n)},e.releaseSession=t=>{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=n[1],i=n[2];a.forEach(e._OrtFree),i.forEach(e._OrtFree),e._OrtReleaseSession(r),u.delete(t)};const c=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${t}`)}},s=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${t}`)}},l=t=>{switch(t){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}};e.run=(t,e,n,a,f)=>{const p=(0,o.getInstance)(),h=u.get(t);if(!h)throw new Error("invalid session id");const d=h[0],y=h[1],b=h[2],m=e.length,g=a.length;let v=0,w=[];const _=[],O=[];try{[v,w]=(0,r.setRunOptions)(f);for(let t=0;t<m;t++){const e=n[t][0],r=n[t][1],a=n[t][2];let o,u;if(Array.isArray(a)){u=4*a.length,o=p._malloc(u),O.push(o);let t=o/4;for(let e=0;e<a.length;e++){if("string"!=typeof a[e])throw new TypeError(`tensor data at index ${e} is not a string`);p.HEAPU32[t++]=(0,i.allocWasmString)(a[e],O)}}else u=a.byteLength,o=p._malloc(u),O.push(o),p.HEAPU8.set(new Uint8Array(a.buffer,a.byteOffset,u),o);const s=p.stackSave(),l=p.stackAlloc(4*r.length);try{let t=l/4;r.forEach((e=>p.HEAP32[t++]=e));const n=p._OrtCreateTensor(c(e),o,u,l,r.length);if(0===n)throw new Error("Can\'t create a tensor");_.push(n)}finally{p.stackRestore(s)}}const t=p.stackSave(),o=p.stackAlloc(4*m),u=p.stackAlloc(4*m),h=p.stackAlloc(4*g),A=p.stackAlloc(4*g);try{let n=o/4,r=u/4,i=h/4,c=A/4;for(let t=0;t<m;t++)p.HEAPU32[n++]=_[t],p.HEAPU32[r++]=y[e[t]];for(let t=0;t<g;t++)p.HEAPU32[i++]=0,p.HEAPU32[c++]=b[a[t]];let f=p._OrtRun(d,u,o,m,A,g,h,v);const w=[];if(0===f)for(let t=0;t<g;t++){const e=p.HEAPU32[h/4+t],n=p.stackSave(),r=p.stackAlloc(16);let a,i=0;try{if(f=p._OrtGetTensorData(e,r,r+4,r+8,r+12),0!==f)throw new Error(`Can\'t access output tensor data. error code = ${f}`);let t=r/4;const o=p.HEAPU32[t++];i=p.HEAPU32[t++];const u=p.HEAPU32[t++],c=p.HEAPU32[t++],h=[];for(let t=0;t<c;t++)h.push(p.HEAPU32[u/4+t]);p._OrtFree(u);const d=0===h.length?1:h.reduce(((t,e)=>t*e));if(a=s(o),"string"===a){const t=[];let e=i/4;for(let n=0;n<d;n++){const r=p.HEAPU32[e++],a=n===d-1?void 0:p.HEAPU32[e]-r;t.push(p.UTF8ToString(r,a))}w.push([a,h,t])}else{const t=new(l(a))(d);new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(p.HEAPU8.subarray(i,i+t.byteLength)),w.push([a,h,t])}}finally{p.stackRestore(n),"string"===a&&i&&p._free(i),p._OrtReleaseTensor(e)}}if(0===f)return w;throw new Error(`failed to call OrtRun(). error code = ${f}.`)}finally{p.stackRestore(t)}}finally{_.forEach(p._OrtReleaseTensor),O.forEach(p._free),p._OrtReleaseRunOptions(v),w.forEach(p._free)}},e.endProfiling=t=>{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=e._OrtEndProfiling(r);if(0===a)throw new Error("Can\'t get an profile file name");e._OrtFree(a)},e.extractTransferableBuffers=t=>{const e=[];for(const n of t){const t=n[2];!Array.isArray(t)&&t.buffer&&e.push(t.buffer)}return e}},361:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return a(e,t),e},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const u=i(n(449)),c=o(n(932)),s=n(474);let l,f=!1,p=!1,h=!1;const d=(t,e)=>e?t?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":t?"ort-wasm-simd.wasm":"ort-wasm.wasm";e.initializeWebAssembly=async t=>{if(f)return Promise.resolve();if(p)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(h)throw new Error("previous call to \'initializeWebAssembly()\' failed.");p=!0;const e=t.initTimeout,r=t.numThreads,a=t.simd,i=r>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(t){return!1}})(),o=a&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(t){return!1}})(),y="string"==typeof t.wasmPaths?t.wasmPaths:void 0,b=d(!1,i),m=d(o,i),g="object"==typeof t.wasmPaths?t.wasmPaths[m]:void 0;let v=!1;const w=[];if(e>0&&w.push(new Promise((t=>{setTimeout((()=>{v=!0,t()}),e)}))),w.push(new Promise(((t,e)=>{const r=i?s:c.default,a={locateFile:(t,e)=>i&&t.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([n(154)],{type:"text/javascript"})):t===b?null!=g?g:(null!=y?y:e)+m:e+t};if(i)if("undefined"==typeof Blob)a.mainScriptUrlOrBlob=u.join("/","ort-wasm-threaded.js");else{const t=`var ortWasmThreaded=(function(){var _scriptDir;return ${r.toString()}})();`;a.mainScriptUrlOrBlob=new Blob([t],{type:"text/javascript"})}r(a).then((e=>{p=!1,f=!0,l=e,t()}),(t=>{p=!1,h=!0,e(t)}))}))),await Promise.race(w),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},e.getInstance=()=>{if(f&&l)return l;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var t;!f||p||h||(p=!0,null===(t=l.PThread)||void 0===t||t.terminateAllThreads(),l=void 0,p=!1,f=!1,h=!0)}},154:t=>{"use strict";t.exports=\'"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}};\\n\'},384:()=>{},993:()=>{},908:()=>{},953:()=>{},925:()=>{},449:()=>{}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{"use strict";const t=n(349),e=n(361);self.onmessage=n=>{switch(n.data.type){case"init-wasm":(0,e.initializeWebAssembly)(n.data.in).then((()=>postMessage({type:"init-wasm"})),(t=>postMessage({type:"init-wasm",err:t})));break;case"init-ort":try{const{numThreads:e,loggingLevel:r}=n.data.in;(0,t.initOrt)(e,r),postMessage({type:"init-ort"})}catch(t){postMessage({type:"init-ort",err:t})}break;case"create_allocate":try{const{model:e}=n.data.in,r=(0,t.createSessionAllocate)(e);postMessage({type:"create_allocate",out:r})}catch(t){postMessage({type:"create_allocate",err:t})}break;case"create_finalize":try{const{modeldata:e,options:r}=n.data.in,a=(0,t.createSessionFinalize)(e,r);postMessage({type:"create_finalize",out:a})}catch(t){postMessage({type:"create_finalize",err:t})}break;case"create":try{const{model:e,options:r}=n.data.in,a=(0,t.createSession)(e,r);postMessage({type:"create",out:a})}catch(t){postMessage({type:"create",err:t})}break;case"release":try{const e=n.data.in;(0,t.releaseSession)(e),postMessage({type:"release"})}catch(t){postMessage({type:"release",err:t})}break;case"run":try{const{sessionId:e,inputIndices:r,inputs:a,outputIndices:i,options:o}=n.data.in,u=(0,t.run)(e,r,a,i,o);postMessage({type:"run",out:u},(0,t.extractTransferableBuffers)(u))}catch(t){postMessage({type:"run",err:t})}break;case"end-profiling":try{const e=n.data.in;(0,t.endProfiling)(e),postMessage({type:"end-profiling"})}catch(t){postMessage({type:"end-profiling",err:t})}}}})()})();\n',"Worker",void 0,void 0)}},477:i=>{i.exports=function(e,s,c,h){var $=self||window;try{try{var _;try{_=new $.Blob([e])}catch{(_=new($.BlobBuilder||$.WebKitBlobBuilder||$.MozBlobBuilder||$.MSBlobBuilder)).append(e),_=_.getBlob()}var j=$.URL||$.webkitURL,nt=j.createObjectURL(_),et=new $[s](nt,c);return j.revokeObjectURL(nt),et}catch{return new $[s]("data:application/javascript,".concat(encodeURIComponent(e)),c)}}catch{if(!h)throw Error("Inline worker is not supported");return new $[s](h,c)}}},4154:i=>{i.exports=`"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}};
|
|
1851
|
-
`},1670:i=>{i.exports=__WEBPACK_EXTERNAL_MODULE__1670__},7067:()=>{},1296:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(i,e,s)=>{s.r(e),s.d(e,{flatbuffers:()=>c});var c={};c.Offset,c.Table,c.SIZEOF_SHORT=2,c.SIZEOF_INT=4,c.FILE_IDENTIFIER_LENGTH=4,c.SIZE_PREFIX_LENGTH=4,c.Encoding={UTF8_BYTES:1,UTF16_STRING:2},c.int32=new Int32Array(2),c.float32=new Float32Array(c.int32.buffer),c.float64=new Float64Array(c.int32.buffer),c.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,c.Long=function(h,$){this.low=0|h,this.high=0|$},c.Long.create=function(h,$){return h==0&&$==0?c.Long.ZERO:new c.Long(h,$)},c.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},c.Long.prototype.equals=function(h){return this.low==h.low&&this.high==h.high},c.Long.ZERO=new c.Long(0,0),c.Builder=function(h){if(h)$=h;else var $=1024;this.bb=c.ByteBuffer.allocate($),this.space=$,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},c.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},c.Builder.prototype.forceDefaults=function(h){this.force_defaults=h},c.Builder.prototype.dataBuffer=function(){return this.bb},c.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},c.Builder.prototype.prep=function(h,$){h>this.minalign&&(this.minalign=h);for(var _=1+~(this.bb.capacity()-this.space+$)&h-1;this.space<_+h+$;){var j=this.bb.capacity();this.bb=c.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-j}this.pad(_)},c.Builder.prototype.pad=function(h){for(var $=0;$<h;$++)this.bb.writeInt8(--this.space,0)},c.Builder.prototype.writeInt8=function(h){this.bb.writeInt8(this.space-=1,h)},c.Builder.prototype.writeInt16=function(h){this.bb.writeInt16(this.space-=2,h)},c.Builder.prototype.writeInt32=function(h){this.bb.writeInt32(this.space-=4,h)},c.Builder.prototype.writeInt64=function(h){this.bb.writeInt64(this.space-=8,h)},c.Builder.prototype.writeFloat32=function(h){this.bb.writeFloat32(this.space-=4,h)},c.Builder.prototype.writeFloat64=function(h){this.bb.writeFloat64(this.space-=8,h)},c.Builder.prototype.addInt8=function(h){this.prep(1,0),this.writeInt8(h)},c.Builder.prototype.addInt16=function(h){this.prep(2,0),this.writeInt16(h)},c.Builder.prototype.addInt32=function(h){this.prep(4,0),this.writeInt32(h)},c.Builder.prototype.addInt64=function(h){this.prep(8,0),this.writeInt64(h)},c.Builder.prototype.addFloat32=function(h){this.prep(4,0),this.writeFloat32(h)},c.Builder.prototype.addFloat64=function(h){this.prep(8,0),this.writeFloat64(h)},c.Builder.prototype.addFieldInt8=function(h,$,_){(this.force_defaults||$!=_)&&(this.addInt8($),this.slot(h))},c.Builder.prototype.addFieldInt16=function(h,$,_){(this.force_defaults||$!=_)&&(this.addInt16($),this.slot(h))},c.Builder.prototype.addFieldInt32=function(h,$,_){(this.force_defaults||$!=_)&&(this.addInt32($),this.slot(h))},c.Builder.prototype.addFieldInt64=function(h,$,_){!this.force_defaults&&$.equals(_)||(this.addInt64($),this.slot(h))},c.Builder.prototype.addFieldFloat32=function(h,$,_){(this.force_defaults||$!=_)&&(this.addFloat32($),this.slot(h))},c.Builder.prototype.addFieldFloat64=function(h,$,_){(this.force_defaults||$!=_)&&(this.addFloat64($),this.slot(h))},c.Builder.prototype.addFieldOffset=function(h,$,_){(this.force_defaults||$!=_)&&(this.addOffset($),this.slot(h))},c.Builder.prototype.addFieldStruct=function(h,$,_){$!=_&&(this.nested($),this.slot(h))},c.Builder.prototype.nested=function(h){if(h!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},c.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},c.Builder.prototype.slot=function(h){this.vtable[h]=this.offset()},c.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},c.Builder.growByteBuffer=function(h){var $=h.capacity();if(3221225472&$)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var _=$<<1,j=c.ByteBuffer.allocate(_);return j.setPosition(_-$),j.bytes().set(h.bytes(),_-$),j},c.Builder.prototype.addOffset=function(h){this.prep(c.SIZEOF_INT,0),this.writeInt32(this.offset()-h+c.SIZEOF_INT)},c.Builder.prototype.startObject=function(h){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=h;for(var $=0;$<h;$++)this.vtable[$]=0;this.isNested=!0,this.object_start=this.offset()},c.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var h=this.offset(),$=this.vtable_in_use-1;$>=0&&this.vtable[$]==0;$--);for(var _=$+1;$>=0;$--)this.addInt16(this.vtable[$]!=0?h-this.vtable[$]:0);this.addInt16(h-this.object_start);var j=(_+2)*c.SIZEOF_SHORT;this.addInt16(j);var nt=0,et=this.space;e:for($=0;$<this.vtables.length;$++){var b=this.bb.capacity()-this.vtables[$];if(j==this.bb.readInt16(b)){for(var a=c.SIZEOF_SHORT;a<j;a+=c.SIZEOF_SHORT)if(this.bb.readInt16(et+a)!=this.bb.readInt16(b+a))continue e;nt=this.vtables[$];break}}return nt?(this.space=this.bb.capacity()-h,this.bb.writeInt32(this.space,nt-h)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-h,this.offset()-h)),this.isNested=!1,h},c.Builder.prototype.finish=function(h,$,_){var j=_?c.SIZE_PREFIX_LENGTH:0;if($){var nt=$;if(this.prep(this.minalign,c.SIZEOF_INT+c.FILE_IDENTIFIER_LENGTH+j),nt.length!=c.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+c.FILE_IDENTIFIER_LENGTH);for(var et=c.FILE_IDENTIFIER_LENGTH-1;et>=0;et--)this.writeInt8(nt.charCodeAt(et))}this.prep(this.minalign,c.SIZEOF_INT+j),this.addOffset(h),j&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},c.Builder.prototype.finishSizePrefixed=function(h,$){this.finish(h,$,!0)},c.Builder.prototype.requiredField=function(h,$){var _=this.bb.capacity()-h,j=_-this.bb.readInt32(_);if(this.bb.readInt16(j+$)==0)throw new Error("FlatBuffers: field "+$+" must be set")},c.Builder.prototype.startVector=function(h,$,_){this.notNested(),this.vector_num_elems=$,this.prep(c.SIZEOF_INT,h*$),this.prep(_,h*$)},c.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},c.Builder.prototype.createString=function(h){if(h instanceof Uint8Array)var $=h;else{$=[];for(var _=0;_<h.length;){var j,nt=h.charCodeAt(_++);(j=nt<55296||nt>=56320?nt:(nt<<10)+h.charCodeAt(_++)+-56613888)<128?$.push(j):(j<2048?$.push(j>>6&31|192):(j<65536?$.push(j>>12&15|224):$.push(j>>18&7|240,j>>12&63|128),$.push(j>>6&63|128)),$.push(63&j|128))}}this.addInt8(0),this.startVector(1,$.length,1),this.bb.setPosition(this.space-=$.length),_=0;for(var et=this.space,b=this.bb.bytes();_<$.length;_++)b[et++]=$[_];return this.endVector()},c.Builder.prototype.createLong=function(h,$){return c.Long.create(h,$)},c.ByteBuffer=function(h){this.bytes_=h,this.position_=0},c.ByteBuffer.allocate=function(h){return new c.ByteBuffer(new Uint8Array(h))},c.ByteBuffer.prototype.clear=function(){this.position_=0},c.ByteBuffer.prototype.bytes=function(){return this.bytes_},c.ByteBuffer.prototype.position=function(){return this.position_},c.ByteBuffer.prototype.setPosition=function(h){this.position_=h},c.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},c.ByteBuffer.prototype.readInt8=function(h){return this.readUint8(h)<<24>>24},c.ByteBuffer.prototype.readUint8=function(h){return this.bytes_[h]},c.ByteBuffer.prototype.readInt16=function(h){return this.readUint16(h)<<16>>16},c.ByteBuffer.prototype.readUint16=function(h){return this.bytes_[h]|this.bytes_[h+1]<<8},c.ByteBuffer.prototype.readInt32=function(h){return this.bytes_[h]|this.bytes_[h+1]<<8|this.bytes_[h+2]<<16|this.bytes_[h+3]<<24},c.ByteBuffer.prototype.readUint32=function(h){return this.readInt32(h)>>>0},c.ByteBuffer.prototype.readInt64=function(h){return new c.Long(this.readInt32(h),this.readInt32(h+4))},c.ByteBuffer.prototype.readUint64=function(h){return new c.Long(this.readUint32(h),this.readUint32(h+4))},c.ByteBuffer.prototype.readFloat32=function(h){return c.int32[0]=this.readInt32(h),c.float32[0]},c.ByteBuffer.prototype.readFloat64=function(h){return c.int32[c.isLittleEndian?0:1]=this.readInt32(h),c.int32[c.isLittleEndian?1:0]=this.readInt32(h+4),c.float64[0]},c.ByteBuffer.prototype.writeInt8=function(h,$){this.bytes_[h]=$},c.ByteBuffer.prototype.writeUint8=function(h,$){this.bytes_[h]=$},c.ByteBuffer.prototype.writeInt16=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8},c.ByteBuffer.prototype.writeUint16=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8},c.ByteBuffer.prototype.writeInt32=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8,this.bytes_[h+2]=$>>16,this.bytes_[h+3]=$>>24},c.ByteBuffer.prototype.writeUint32=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8,this.bytes_[h+2]=$>>16,this.bytes_[h+3]=$>>24},c.ByteBuffer.prototype.writeInt64=function(h,$){this.writeInt32(h,$.low),this.writeInt32(h+4,$.high)},c.ByteBuffer.prototype.writeUint64=function(h,$){this.writeUint32(h,$.low),this.writeUint32(h+4,$.high)},c.ByteBuffer.prototype.writeFloat32=function(h,$){c.float32[0]=$,this.writeInt32(h,c.int32[0])},c.ByteBuffer.prototype.writeFloat64=function(h,$){c.float64[0]=$,this.writeInt32(h,c.int32[c.isLittleEndian?0:1]),this.writeInt32(h+4,c.int32[c.isLittleEndian?1:0])},c.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+c.SIZEOF_INT+c.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var h="",$=0;$<c.FILE_IDENTIFIER_LENGTH;$++)h+=String.fromCharCode(this.readInt8(this.position_+c.SIZEOF_INT+$));return h},c.ByteBuffer.prototype.__offset=function(h,$){var _=h-this.readInt32(h);return $<this.readInt16(_)?this.readInt16(_+$):0},c.ByteBuffer.prototype.__union=function(h,$){return h.bb_pos=$+this.readInt32($),h.bb=this,h},c.ByteBuffer.prototype.__string=function(h,$){h+=this.readInt32(h);var _=this.readInt32(h),j="",nt=0;if(h+=c.SIZEOF_INT,$===c.Encoding.UTF8_BYTES)return this.bytes_.subarray(h,h+_);for(;nt<_;){var et,b=this.readUint8(h+nt++);if(b<192)et=b;else{var a=this.readUint8(h+nt++);if(b<224)et=(31&b)<<6|63&a;else{var o=this.readUint8(h+nt++);et=b<240?(15&b)<<12|(63&a)<<6|63&o:(7&b)<<18|(63&a)<<12|(63&o)<<6|63&this.readUint8(h+nt++)}}et<65536?j+=String.fromCharCode(et):(et-=65536,j+=String.fromCharCode(55296+(et>>10),56320+(1023&et)))}return j},c.ByteBuffer.prototype.__indirect=function(h){return h+this.readInt32(h)},c.ByteBuffer.prototype.__vector=function(h){return h+this.readInt32(h)+c.SIZEOF_INT},c.ByteBuffer.prototype.__vector_len=function(h){return this.readInt32(h+this.readInt32(h))},c.ByteBuffer.prototype.__has_identifier=function(h){if(h.length!=c.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+c.FILE_IDENTIFIER_LENGTH);for(var $=0;$<c.FILE_IDENTIFIER_LENGTH;$++)if(h.charCodeAt($)!=this.readInt8(this.position_+c.SIZEOF_INT+$))return!1;return!0},c.ByteBuffer.prototype.createLong=function(h,$){return c.Long.create(h,$)}}},__webpack_module_cache__={};function __webpack_require__(i){var e=__webpack_module_cache__[i];if(e!==void 0)return e.exports;var s=__webpack_module_cache__[i]={exports:{}};return __webpack_modules__[i].call(s.exports,s,s.exports,__webpack_require__),s.exports}__webpack_require__.n=i=>{var e=i&&i.__esModule?()=>i.default:()=>i;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(i,e)=>{for(var s in e)__webpack_require__.o(e,s)&&!__webpack_require__.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:e[s]})},__webpack_require__.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),__webpack_require__.o=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),__webpack_require__.r=i=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6018);return __webpack_exports__})())})(ortWeb_min);var ortWeb_minExports=ortWeb_min.exports,assetPath={};Object.defineProperty(assetPath,"__esModule",{value:!0}),assetPath.baseAssetPath=void 0;const isWeb=typeof window<"u"&&typeof window.document<"u",currentScript=isWeb?window.document.currentScript:null;let basePath="/";currentScript&&(basePath=currentScript.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),assetPath.baseAssetPath=basePath;var defaultModelFetcher$1={};Object.defineProperty(defaultModelFetcher$1,"__esModule",{value:!0}),defaultModelFetcher$1.defaultModelFetcher=void 0;const defaultModelFetcher=i=>fetch(i).then(e=>e.arrayBuffer());defaultModelFetcher$1.defaultModelFetcher=defaultModelFetcher;var frameProcessor={},logging={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.log=i.LOG_PREFIX=void 0,i.LOG_PREFIX="[VAD]";const e=["error","debug","warn"];function s(h){return(...$)=>{console[h](i.LOG_PREFIX,...$)}}const c=e.reduce((h,$)=>(h[$]=s($),h),{});i.log=c})(logging);var messages={};Object.defineProperty(messages,"__esModule",{value:!0}),messages.Message=void 0;var Message;(function(i){i.AudioFrame="AUDIO_FRAME",i.SpeechStart="SPEECH_START",i.VADMisfire="VAD_MISFIRE",i.SpeechEnd="SPEECH_END",i.SpeechStop="SPEECH_STOP"})(Message||(messages.Message=Message={})),Object.defineProperty(frameProcessor,"__esModule",{value:!0}),frameProcessor.FrameProcessor=frameProcessor.validateOptions=frameProcessor.defaultV5FrameProcessorOptions=frameProcessor.defaultLegacyFrameProcessorOptions=void 0;const logging_1$3=logging,messages_1=messages,RECOMMENDED_FRAME_SAMPLES=[512,1024,1536];frameProcessor.defaultLegacyFrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:1,redemptionFrames:8,frameSamples:1536,minSpeechFrames:3,submitUserSpeechOnPause:!1},frameProcessor.defaultV5FrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:3,redemptionFrames:24,frameSamples:512,minSpeechFrames:9,submitUserSpeechOnPause:!1};function validateOptions(i){RECOMMENDED_FRAME_SAMPLES.includes(i.frameSamples)||logging_1$3.log.warn("You are using an unusual frame size"),(i.positiveSpeechThreshold<0||i.positiveSpeechThreshold>1)&&logging_1$3.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(i.negativeSpeechThreshold<0||i.negativeSpeechThreshold>i.positiveSpeechThreshold)&&logging_1$3.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),i.preSpeechPadFrames<0&&logging_1$3.log.error("preSpeechPadFrames should be positive"),i.redemptionFrames<0&&logging_1$3.log.error("redemptionFrames should be positive")}frameProcessor.validateOptions=validateOptions;const concatArrays=i=>{const e=i.reduce((c,h)=>(c.push(c.at(-1)+h.length),c),[0]),s=new Float32Array(e.at(-1));return i.forEach((c,h)=>{const $=e[h];s.set(c,$)}),s};class FrameProcessor{constructor(e,s,c){this.modelProcessFunc=e,this.modelResetFunc=s,this.options=c,this.speaking=!1,this.redemptionCounter=0,this.active=!1,this.reset=()=>{this.speaking=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0},this.pause=()=>(this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment():(this.reset(),{})),this.resume=()=>{this.active=!0},this.endSegment=()=>{const h=this.audioBuffer;this.audioBuffer=[];const $=this.speaking;this.reset();const _=h.reduce((j,nt)=>j+ +nt.isSpeech,0);if($)if(_>=this.options.minSpeechFrames){const j=concatArrays(h.map(nt=>nt.frame));return{msg:messages_1.Message.SpeechEnd,audio:j}}else return{msg:messages_1.Message.VADMisfire};return{}},this.process=async h=>{if(!this.active)return{};const $=await this.modelProcessFunc(h);if(this.audioBuffer.push({frame:h,isSpeech:$.isSpeech>=this.options.positiveSpeechThreshold}),$.isSpeech>=this.options.positiveSpeechThreshold&&this.redemptionCounter&&(this.redemptionCounter=0),$.isSpeech>=this.options.positiveSpeechThreshold&&!this.speaking)return this.speaking=!0,{probs:$,msg:messages_1.Message.SpeechStart,frame:h};if($.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.options.redemptionFrames){this.redemptionCounter=0,this.speaking=!1;const _=this.audioBuffer;if(this.audioBuffer=[],_.reduce((nt,et)=>nt+ +et.isSpeech,0)>=this.options.minSpeechFrames){const nt=concatArrays(_.map(et=>et.frame));return{probs:$,msg:messages_1.Message.SpeechEnd,audio:nt,frame:h}}else return{probs:$,msg:messages_1.Message.VADMisfire,frame:h}}if(!this.speaking)for(;this.audioBuffer.length>this.options.preSpeechPadFrames;)this.audioBuffer.shift();return{probs:$,frame:h}},this.audioBuffer=[],this.reset()}}frameProcessor.FrameProcessor=FrameProcessor;var nonRealTimeVad={},models={},common={};Object.defineProperty(common,"__esModule",{value:!0});var legacy={},_a$1;Object.defineProperty(legacy,"__esModule",{value:!0}),legacy.SileroLegacy=void 0;const logging_1$2=logging;class SileroLegacy{constructor(e,s,c,h,$){this.ortInstance=e,this._session=s,this._h=c,this._c=h,this._sr=$,this.reset_state=()=>{const _=Array(128).fill(0);this._h=new this.ortInstance.Tensor("float32",_,[2,1,64]),this._c=new this.ortInstance.Tensor("float32",_,[2,1,64])},this.process=async _=>{var o;const nt={input:new this.ortInstance.Tensor("float32",_,[1,_.length]),h:this._h,c:this._c,sr:this._sr},et=await this._session.run(nt);this._h=et.hn,this._c=et.cn;const[b]=(o=et.output)==null?void 0:o.data;return{notSpeech:1-b,isSpeech:b}}}}legacy.SileroLegacy=SileroLegacy,_a$1=SileroLegacy,SileroLegacy.new=async(i,e)=>{logging_1$2.log.debug("initializing vad");const s=await e(),c=await i.InferenceSession.create(s),h=new i.Tensor("int64",[16000n]),$=Array(2*64).fill(0),_=new i.Tensor("float32",$,[2,1,64]),j=new i.Tensor("float32",$,[2,1,64]);return logging_1$2.log.debug("vad is initialized"),new _a$1(i,c,_,j,h)};var v5={},_a;Object.defineProperty(v5,"__esModule",{value:!0}),v5.SileroV5=void 0;const logging_1$1=logging;function getNewState(i){const e=Array(256).fill(0);return new i.Tensor("float32",e,[2,1,128])}class SileroV5{constructor(e,s,c,h){this._session=e,this._state=s,this._sr=c,this.ortInstance=h,this.reset_state=()=>{this._state=getNewState(this.ortInstance)},this.process=async $=>{var a;const j={input:new this.ortInstance.Tensor("float32",$,[1,$.length]),state:this._state,sr:this._sr},nt=await this._session.run(j);this._state=nt.stateN;const[et]=(a=nt.output)==null?void 0:a.data;return{notSpeech:1-et,isSpeech:et}}}}v5.SileroV5=SileroV5,_a=SileroV5,SileroV5.new=async(i,e)=>{logging_1$1.log.debug("Loading VAD...");const s=await e(),c=await i.InferenceSession.create(s),h=new i.Tensor("int64",[16000n]),$=getNewState(i);return logging_1$1.log.debug("...finished loading VAD"),new _a(c,$,h,i)},function(i){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function($,_,j,nt){nt===void 0&&(nt=j);var et=Object.getOwnPropertyDescriptor(_,j);(!et||("get"in et?!_.__esModule:et.writable||et.configurable))&&(et={enumerable:!0,get:function(){return _[j]}}),Object.defineProperty($,nt,et)}:function($,_,j,nt){nt===void 0&&(nt=j),$[nt]=_[j]}),s=commonjsGlobal&&commonjsGlobal.__exportStar||function($,_){for(var j in $)j!=="default"&&!Object.prototype.hasOwnProperty.call(_,j)&&e(_,$,j)};Object.defineProperty(i,"__esModule",{value:!0}),i.SileroV5=i.SileroLegacy=void 0,s(common,i);var c=legacy;Object.defineProperty(i,"SileroLegacy",{enumerable:!0,get:function(){return c.SileroLegacy}});var h=v5;Object.defineProperty(i,"SileroV5",{enumerable:!0,get:function(){return h.SileroV5}})}(models);var resampler={};Object.defineProperty(resampler,"__esModule",{value:!0}),resampler.Resampler=void 0;const logging_1=logging;class Resampler{constructor(e){this.options=e,this.process=s=>{const c=[];for(const h of s)for(this.inputBuffer.push(h);this.hasEnoughDataForFrame();){const $=this.generateOutputFrame();c.push($)}return c},this.stream=async function*(s){for(const c of s)for(this.inputBuffer.push(c);this.hasEnoughDataForFrame();)yield this.generateOutputFrame()},e.nativeSampleRate<16e3&&logging_1.log.error("nativeSampleRate is too low. Should have 16000 = targetSampleRate <= nativeSampleRate"),this.inputBuffer=[]}hasEnoughDataForFrame(){return this.inputBuffer.length*this.options.targetSampleRate/this.options.nativeSampleRate>=this.options.targetFrameSize}generateOutputFrame(){const e=new Float32Array(this.options.targetFrameSize);let s=0,c=0;for(;s<this.options.targetFrameSize;){let h=0,$=0;for(;c<Math.min(this.inputBuffer.length,(s+1)*this.options.nativeSampleRate/this.options.targetSampleRate);){const _=this.inputBuffer[c];_!==void 0&&(h+=_,$++),c++}e[s]=h/$,s++}return this.inputBuffer=this.inputBuffer.slice(c),e}}resampler.Resampler=Resampler,function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.PlatformAgnosticNonRealTimeVAD=i.defaultNonRealTimeVADOptions=void 0;const e=frameProcessor,s=messages,c=models,h=resampler;i.defaultNonRealTimeVADOptions={...e.defaultLegacyFrameProcessorOptions,ortConfig:void 0};class ${static async _new(j,nt,et={}){const b={...i.defaultNonRealTimeVADOptions,...et};b.ortConfig!==void 0&&b.ortConfig(nt);const a=new this(j,nt,b);return await a.init(),a}constructor(j,nt,et){this.modelFetcher=j,this.ort=nt,this.options=et,this.init=async()=>{const b=await c.SileroLegacy.new(this.ort,this.modelFetcher);this.frameProcessor=new e.FrameProcessor(b.process,b.reset_state,{frameSamples:this.options.frameSamples,positiveSpeechThreshold:this.options.positiveSpeechThreshold,negativeSpeechThreshold:this.options.negativeSpeechThreshold,redemptionFrames:this.options.redemptionFrames,preSpeechPadFrames:this.options.preSpeechPadFrames,minSpeechFrames:this.options.minSpeechFrames,submitUserSpeechOnPause:this.options.submitUserSpeechOnPause}),this.frameProcessor.resume()},this.run=async function*(b,a){const o={nativeSampleRate:a,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples},d=new h.Resampler(o);let g=0,rt=0,st=0;for await(const it of d.stream(b)){const{msg:at,audio:ut}=await this.frameProcessor.process(it);switch(at){case s.Message.SpeechStart:g=st*this.options.frameSamples/16;break;case s.Message.SpeechEnd:rt=(st+1)*this.options.frameSamples/16,yield{audio:ut,start:g,end:rt};break}st++}const{msg:tt,audio:ot}=this.frameProcessor.endSegment();tt==s.Message.SpeechEnd&&(yield{audio:ot,start:g,end:st*this.options.frameSamples/16})},(0,e.validateOptions)(et)}}i.PlatformAgnosticNonRealTimeVAD=$}(nonRealTimeVad);var utils={};Object.defineProperty(utils,"__esModule",{value:!0}),utils.audioFileToArray=utils.encodeWAV=utils.arrayBufferToBase64=utils.minFramesForTargetMS=void 0;function minFramesForTargetMS(i,e,s=16e3){return Math.ceil(i*s/1e3/e)}utils.minFramesForTargetMS=minFramesForTargetMS;function arrayBufferToBase64(i){const e=new Uint8Array(i),s=e.byteLength,c=new Array(s);for(var h=0;h<s;h++){const $=e[h];if($===void 0)break;c[h]=String.fromCharCode($)}return btoa(c.join(""))}utils.arrayBufferToBase64=arrayBufferToBase64;function encodeWAV(i,e=3,s=16e3,c=1,h=32){var $=h/8,_=c*$,j=new ArrayBuffer(44+i.length*$),nt=new DataView(j);return writeString(nt,0,"RIFF"),nt.setUint32(4,36+i.length*$,!0),writeString(nt,8,"WAVE"),writeString(nt,12,"fmt "),nt.setUint32(16,16,!0),nt.setUint16(20,e,!0),nt.setUint16(22,c,!0),nt.setUint32(24,s,!0),nt.setUint32(28,s*_,!0),nt.setUint16(32,_,!0),nt.setUint16(34,h,!0),writeString(nt,36,"data"),nt.setUint32(40,i.length*$,!0),e===1?floatTo16BitPCM(nt,44,i):writeFloat32(nt,44,i),j}utils.encodeWAV=encodeWAV;function writeFloat32(i,e,s){for(var c=0;c<s.length;c++,e+=4)i.setFloat32(e,s[c],!0)}function floatTo16BitPCM(i,e,s){for(var c=0;c<s.length;c++,e+=2){var h=Math.max(-1,Math.min(1,s[c]));i.setInt16(e,h<0?h*32768:h*32767,!0)}}function writeString(i,e,s){for(var c=0;c<s.length;c++)i.setUint8(e+c,s.charCodeAt(c))}async function audioFileToArray(i){const e=new OfflineAudioContext(1,1,44100),s=new FileReader;let c=null;if(await new Promise(_=>{s.addEventListener("loadend",j=>{const nt=s.result;e.decodeAudioData(nt,et=>{c=et,e.startRendering().then(b=>{console.log("Rendering completed successfully"),_()}).catch(b=>{console.error(`Rendering failed: ${b}`)})},et=>{console.log(`Error with decoding audio data: ${et}`)})}),s.readAsArrayBuffer(i)}),c===null)throw Error("some shit");let h=c,$=new Float32Array(h.length);for(let _=0;_<h.length;_++)for(let j=0;j<h.numberOfChannels;j++)$[_]+=h.getChannelData(j)[_];return{audio:$,sampleRate:h.sampleRate}}utils.audioFileToArray=audioFileToArray;var realTimeVad={};(function(i){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(tt,ot,it,at){at===void 0&&(at=it);var ut=Object.getOwnPropertyDescriptor(ot,it);(!ut||("get"in ut?!ot.__esModule:ut.writable||ut.configurable))&&(ut={enumerable:!0,get:function(){return ot[it]}}),Object.defineProperty(tt,at,ut)}:function(tt,ot,it,at){at===void 0&&(at=it),tt[at]=ot[it]}),s=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(tt,ot){Object.defineProperty(tt,"default",{enumerable:!0,value:ot})}:function(tt,ot){tt.default=ot}),c=commonjsGlobal&&commonjsGlobal.__importStar||function(tt){if(tt&&tt.__esModule)return tt;var ot={};if(tt!=null)for(var it in tt)it!=="default"&&Object.prototype.hasOwnProperty.call(tt,it)&&e(ot,tt,it);return s(ot,tt),ot};Object.defineProperty(i,"__esModule",{value:!0}),i.AudioNodeVAD=i.MicVAD=i.getDefaultRealTimeVADOptions=i.ort=i.DEFAULT_MODEL=void 0;const h=c(ortWeb_minExports),$=defaultModelFetcher$1,_=frameProcessor,j=logging,nt=messages,et=models,b=resampler;i.DEFAULT_MODEL="legacy",i.ort=h;const a="vad.worklet.bundle.min.js",o="silero_vad_v5.onnx",d="silero_vad_legacy.onnx",g=tt=>({...tt==="v5"?_.defaultV5FrameProcessorOptions:_.defaultLegacyFrameProcessorOptions,onFrameProcessed:it=>{},onVADMisfire:()=>{j.log.debug("VAD misfire")},onSpeechStart:()=>{j.log.debug("Detected speech start")},onSpeechEnd:()=>{j.log.debug("Detected speech end")},baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.22/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/",stream:void 0,ortConfig:void 0,model:i.DEFAULT_MODEL,workletOptions:{}});i.getDefaultRealTimeVADOptions=g;class rt{static async new(ot={}){const it={...(0,i.getDefaultRealTimeVADOptions)(ot.model??i.DEFAULT_MODEL),...ot};(0,_.validateOptions)(it);let at;it.stream===void 0?at=await navigator.mediaDevices.getUserMedia({audio:{...it.additionalAudioConstraints,channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}):at=it.stream;const ut=new AudioContext,lt=new MediaStreamAudioSourceNode(ut,{mediaStream:at}),ct=await st.new(ut,it);return ct.receive(lt),new rt(it,ut,at,ct,lt)}constructor(ot,it,at,ut,lt,ct=!1){this.options=ot,this.audioContext=it,this.stream=at,this.audioNodeVAD=ut,this.sourceNode=lt,this.listening=ct,this.pause=()=>{this.audioNodeVAD.pause(),this.listening=!1},this.start=()=>{this.audioNodeVAD.start(),this.listening=!0},this.destroy=()=>{this.listening&&this.pause(),this.options.stream===void 0&&this.stream.getTracks().forEach(ft=>ft.stop()),this.sourceNode.disconnect(),this.audioNodeVAD.destroy(),this.audioContext.close()}}}i.MicVAD=rt;class st{static async new(ot,it={}){const at={...(0,i.getDefaultRealTimeVADOptions)(it.model??i.DEFAULT_MODEL),...it};(0,_.validateOptions)(at),i.ort.env.wasm.wasmPaths=at.onnxWASMBasePath,at.ortConfig!==void 0&&at.ortConfig(i.ort);const ut=at.model==="v5"?o:d,lt=at.baseAssetPath+ut,ct=at.model==="v5"?et.SileroV5.new:et.SileroLegacy.new;let ft;try{ft=await ct(i.ort,()=>(0,$.defaultModelFetcher)(lt))}catch(St){throw console.error(`Encountered an error while loading model file ${lt}`),St}const dt=new _.FrameProcessor(ft.process,ft.reset_state,{frameSamples:at.frameSamples,positiveSpeechThreshold:at.positiveSpeechThreshold,negativeSpeechThreshold:at.negativeSpeechThreshold,redemptionFrames:at.redemptionFrames,preSpeechPadFrames:at.preSpeechPadFrames,minSpeechFrames:at.minSpeechFrames,submitUserSpeechOnPause:at.submitUserSpeechOnPause}),yt=new st(ot,at,dt);return await yt.setupAudioNode(),yt}constructor(ot,it,at){this.ctx=ot,this.options=it,this.bufferIndex=0,this.pause=()=>{const ut=this.frameProcessor.pause();this.handleFrameProcessorEvent(ut)},this.start=()=>{this.frameProcessor.resume()},this.receive=ut=>{ut.connect(this.audioNode)},this.processFrame=async ut=>{const lt=await this.frameProcessor.process(ut);this.handleFrameProcessorEvent(lt)},this.handleFrameProcessorEvent=ut=>{switch(ut.probs!==void 0&&this.options.onFrameProcessed(ut.probs,ut.frame),ut.msg){case nt.Message.SpeechStart:this.options.onSpeechStart();break;case nt.Message.VADMisfire:this.options.onVADMisfire();break;case nt.Message.SpeechEnd:this.options.onSpeechEnd(ut.audio);break}},this.destroy=()=>{var ut;this.audioNode instanceof AudioWorkletNode&&this.audioNode.port.postMessage({message:nt.Message.SpeechStop}),this.audioNode.disconnect(),(ut=this.gainNode)==null||ut.disconnect()},this.frameProcessor=at}async setupAudioNode(){if("audioWorklet"in this.ctx&&typeof AudioWorkletNode=="function")try{const ut=this.options.baseAssetPath+a;await this.ctx.audioWorklet.addModule(ut);const lt=this.options.workletOptions??{};lt.processorOptions={...lt.processorOptions??{},frameSamples:this.options.frameSamples},this.audioNode=new AudioWorkletNode(this.ctx,"vad-helper-worklet",lt),this.audioNode.port.onmessage=async ct=>{var ft;switch((ft=ct.data)==null?void 0:ft.message){case nt.Message.AudioFrame:let dt=ct.data.data;dt instanceof ArrayBuffer||(dt=new ArrayBuffer(ct.data.data.byteLength),new Uint8Array(dt).set(new Uint8Array(ct.data.data)));const yt=new Float32Array(dt);await this.processFrame(yt);break}};return}catch(ut){console.log("AudioWorklet setup failed, falling back to ScriptProcessor",ut)}this.resampler=new b.Resampler({nativeSampleRate:this.ctx.sampleRate,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples??480});const it=4096;this.audioNode=this.ctx.createScriptProcessor(it,1,1),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=0;let at=!1;this.audioNode.onaudioprocess=async ut=>{if(!at){at=!0;try{const lt=ut.inputBuffer.getChannelData(0);if(ut.outputBuffer.getChannelData(0).fill(0),this.resampler){const ft=this.resampler.process(lt);for(const dt of ft)await this.processFrame(dt)}}catch(lt){console.error("Error processing audio:",lt)}finally{at=!1}}},this.audioNode.connect(this.gainNode),this.gainNode.connect(this.ctx.destination)}}i.AudioNodeVAD=st})(realTimeVad),function(i){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(d,g,rt,st){st===void 0&&(st=rt);var tt=Object.getOwnPropertyDescriptor(g,rt);(!tt||("get"in tt?!g.__esModule:tt.writable||tt.configurable))&&(tt={enumerable:!0,get:function(){return g[rt]}}),Object.defineProperty(d,st,tt)}:function(d,g,rt,st){st===void 0&&(st=rt),d[st]=g[rt]}),s=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(d,g){Object.defineProperty(d,"default",{enumerable:!0,value:g})}:function(d,g){d.default=g}),c=commonjsGlobal&&commonjsGlobal.__importStar||function(d){if(d&&d.__esModule)return d;var g={};if(d!=null)for(var rt in d)rt!=="default"&&Object.prototype.hasOwnProperty.call(d,rt)&&e(g,d,rt);return s(g,d),g};Object.defineProperty(i,"__esModule",{value:!0}),i.NonRealTimeVAD=i.Message=i.FrameProcessor=i.getDefaultRealTimeVADOptions=i.MicVAD=i.DEFAULT_MODEL=i.AudioNodeVAD=i.utils=i.defaultNonRealTimeVADOptions=void 0;const h=c(ortWeb_minExports),$=assetPath,_=defaultModelFetcher$1,j=frameProcessor;Object.defineProperty(i,"FrameProcessor",{enumerable:!0,get:function(){return j.FrameProcessor}});const nt=messages;Object.defineProperty(i,"Message",{enumerable:!0,get:function(){return nt.Message}});const et=nonRealTimeVad,b=utils;i.defaultNonRealTimeVADOptions={modelURL:$.baseAssetPath+"silero_vad_legacy.onnx",modelFetcher:_.defaultModelFetcher};class a extends et.PlatformAgnosticNonRealTimeVAD{static async new(g={}){const{modelURL:rt,modelFetcher:st}={...i.defaultNonRealTimeVADOptions,...g};return await this._new(()=>st(rt),h,g)}}i.NonRealTimeVAD=a,i.utils={audioFileToArray:b.audioFileToArray,minFramesForTargetMS:b.minFramesForTargetMS,arrayBufferToBase64:b.arrayBufferToBase64,encodeWAV:b.encodeWAV};var o=realTimeVad;Object.defineProperty(i,"AudioNodeVAD",{enumerable:!0,get:function(){return o.AudioNodeVAD}}),Object.defineProperty(i,"DEFAULT_MODEL",{enumerable:!0,get:function(){return o.DEFAULT_MODEL}}),Object.defineProperty(i,"MicVAD",{enumerable:!0,get:function(){return o.MicVAD}}),Object.defineProperty(i,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return o.getDefaultRealTimeVADOptions}})}(dist);class VadWebClient{constructor(e,s,c,h,$,_){this.micStream=null,this.is_vad_loading=!0,this.noSpeechStartTime=null,this.recording_started=!1,this.lastWarningTime=null,this.warningCooldownPeriod=2e3,this.vad_past=[],this.last_clip_index=0,this.clip_points=[0],this.sil_duration_acc=0,this.pref_length_samples=e*h,this.desp_length_samples=s*h,this.max_length_samples=c*h,this.shor_thsld=SHORT_SILENCE_THRESHOLD*h,this.long_thsld=LONG_SILENCE_THRESHOLD*h,this.frame_size=FRAME_SIZE,this.speech_pad_frames=PRE_SPEECH_PAD_FRAMES,this.micVad={},this.audioFileManager=$,this.audioBufferManager=_}setDependencies(e,s){this.audioFileManager=e,this.audioBufferManager=s}setCallbacks(e,s,c){this.onVadFramesCallback=e,this.onVadFrameProcessedCallback=s,this.onUserSpeechCallback=c}stopMicStream(){var e,s;try{(s=(e=this.micStream)==null?void 0:e.getTracks)==null||s.call(e).forEach(c=>c.stop())}catch{}finally{this.micStream=null}}checkNoSpeech(e){if(!this.recording_started)return;const s=Date.now();e===0?this.noSpeechStartTime===null?this.noSpeechStartTime=s:s-this.noSpeechStartTime>=1e4&&(this.lastWarningTime===null||s-this.lastWarningTime>=this.warningCooldownPeriod)&&(this.onVadFramesCallback&&this.onVadFramesCallback({message:"No audio detected for a while. Please talk or stop the recording if done.",error_code:ErrorCode.AUDIO_QUALITY_POOR,status_code:HttpStatus.BAD_REQUEST}),this.lastWarningTime=s,this.noSpeechStartTime=s):(this.noSpeechStartTime=null,this.lastWarningTime=null,this.onVadFramesCallback&&this.onVadFramesCallback({message:"Audio captured. Recording continues.",status_code:HttpStatus.OK}))}getMicVad(){return this.micVad}isVadLoading(){return this.is_vad_loading}processVadFrame(e){let s=!1;this.vad_past.length>0&&(e===0&&(this.sil_duration_acc+=1),e===1&&(this.sil_duration_acc=0));const c=(this.vad_past.length-this.last_clip_index)*this.frame_size,h=this.sil_duration_acc*this.frame_size;return c>this.pref_length_samples&&h>this.long_thsld&&(this.last_clip_index=this.vad_past.length-Math.min(Math.floor(this.sil_duration_acc/2),5),this.clip_points.push(this.last_clip_index),this.sil_duration_acc=0,s=!0),c>this.desp_length_samples&&h>this.shor_thsld&&(this.last_clip_index=this.vad_past.length-Math.min(Math.floor(this.sil_duration_acc/2),5),this.clip_points.push(this.last_clip_index),this.sil_duration_acc=0,s=!0),c>=this.max_length_samples&&(this.last_clip_index=this.vad_past.length,this.clip_points.push(this.last_clip_index),this.sil_duration_acc=0,s=!0),this.vad_past.push(e),s?[!0,this.clip_points[this.clip_points.length-1]]:[!1,this.clip_points[this.clip_points.length-1]]}async initVad(e){this.is_vad_loading=!0,this.stopMicStream();let s;try{s=await navigator.mediaDevices.getUserMedia({audio:e?{deviceId:{exact:e}}:!0})}catch(c){if((c==null?void 0:c.name)==="OverconstrainedError"||(c==null?void 0:c.name)==="NotFoundError")s=await navigator.mediaDevices.getUserMedia({audio:!0});else throw c}this.micStream=s;try{const c=await dist.MicVAD.new({stream:s,frameSamples:this.frame_size,preSpeechPadFrames:this.speech_pad_frames,onFrameProcessed:(h,$)=>{var b,a,o;if(this.onVadFrameProcessedCallback&&this.onVadFrameProcessedCallback({probabilities:h,frame:$}),!this.recording_started)return;(b=this.audioFileManager)==null||b.incrementTotalRawSamples($),(a=this.audioBufferManager)==null||a.append($);const{isSpeech:_}=h;let j=0;_>=.5&&(j=1),this.checkNoSpeech(j);const nt=this.processVadFrame(j),et=nt[0];if(console.log("is clip point:",et," at index:",nt[1]),et){const d=(o=this.audioBufferManager)==null?void 0:o.getAudioData();console.log("Processing audio chunk at clip point:",d),d&&this.processAudioChunk({audioFrames:d})}},onSpeechStart:()=>{var h;(h=this.onUserSpeechCallback)==null||h.call(this,!0)},onSpeechEnd:()=>{var h;(h=this.onUserSpeechCallback)==null||h.call(this,!1)}});return this.is_vad_loading=!1,this.micVad=c,!this.is_vad_loading}catch(c){throw console.error("Error initializing VAD:",c),this.stopMicStream(),this.is_vad_loading=!1,c}}async reinitializeVad(e){return await this.initVad(e)}async processAudioChunk({audioFrames:e}){if(!e||!this.audioFileManager||!this.audioBufferManager)return;const c=`audio_${this.audioFileManager.audioChunks.length||0}.${OUTPUT_FORMAT}`,h=this.audioFileManager.getRawSampleDetails(),$=this.audioBufferManager.calculateChunkTimestamps(h.totalRawSamples);try{const _={fileName:c,timestamp:{st:$.start,et:$.end},status:"pending",audioFrames:e},j=this.audioFileManager.updateAudioInfo(_);this.audioFileManager.incrementInsertedSamples(this.audioBufferManager.getCurrentSampleLength(),this.audioBufferManager.getCurrentFrameLength()),this.audioBufferManager.resetBufferState(),console.log("Uploading audio chunk:",c," at index:",j-1),await this.audioFileManager.uploadAudio({audioFrames:e,fileName:c,chunkIndex:j-1})}catch(_){console.error("Error uploading audio chunk:",_)}}startVad(){this.micVad&&typeof this.micVad.start=="function"&&this.micVad.start(),this.recording_started=!0}pauseVad(){this.micVad&&typeof this.micVad.pause=="function"&&this.micVad.pause(),this.recording_started=!1}destroyVad(){this.micVad&&typeof this.micVad.destroy=="function"&&this.micVad.destroy(),this.stopMicStream(),this.recording_started=!1}resetVadWebInstance(){this.micVad&&typeof this.micVad.destroy=="function"&&this.micVad.destroy(),this.stopMicStream(),this.vad_past=[],this.last_clip_index=0,this.clip_points=[0],this.sil_duration_acc=0,this.noSpeechStartTime=null,this.lastWarningTime=null,this.recording_started=!1,this.is_vad_loading=!0}configureVadConstants({pref_length:e,desp_length:s,max_length:c,sr:h,frame_size:$,pre_speech_pad_frames:_,short_thsld:j,long_thsld:nt}){this.pref_length_samples=e*h,this.desp_length_samples=s*h,this.max_length_samples=c*h,this.shor_thsld=j*h,this.long_thsld=nt*h,this.frame_size=$,this.speech_pad_frames=_}}class ChunkedRecorder{constructor(e){this._isPaused=!1,this.eventEmitter=e,this.bufferManager=new AudioBufferManager(SAMPLING_RATE,AUDIO_BUFFER_SIZE_IN_S),this.fileManager=new AudioFileManager,this.vadClient=new VadWebClient(PREF_CHUNK_LENGTH,DESP_CHUNK_LENGTH,MAX_CHUNK_LENGTH,SAMPLING_RATE,this.fileManager,this.bufferManager),this.eventEmitter&&(this.fileManager.setUploadProgressCallback((s,c)=>{}),this.vadClient.setCallbacks(s=>{},s=>{},s=>{}))}initialize(e,s){if(!e.upload_url)throw new Error("Upload URL is required for chunked recording");const c={};s!=null&&s.accessToken&&(c.Authorization=`Bearer ${s.accessToken}`),this.fileManager.setSessionInfo({sessionId:e.session_id,uploadUrl:e.upload_url,uploadHeaders:c}),console.log("ChunkedRecorder initialized with session:",e.session_id)}async start(e){console.log("Starting ChunkedRecorder with deviceId:",e),await this.vadClient.initVad(e);const s=this.vadClient.getMicVad();if((this.vadClient.isVadLoading()||!s||Object.keys(s).length===0)&&await this.vadClient.reinitializeVad(e))throw new Error("VAD instance is not initialized.");this.vadClient.startVad()}pause(){this._isPaused||(this.vadClient.pauseVad(),this._isPaused=!0)}resume(){this._isPaused&&(this.vadClient.startVad(),this._isPaused=!1)}isPaused(){return this._isPaused}async stop(){this._isPaused=!1,this.vadClient.resetVadWebInstance(),await this.fileManager.waitForAllUploads();const e=await this.fileManager.retryFailedUploads(),s=this.fileManager.getTotalAudioChunks().length;return{failedUploads:e,totalFiles:s}}reset(){this._isPaused=!1,this.vadClient.resetVadWebInstance(),this.fileManager.resetFileManagerInstance(),this.bufferManager.resetBufferState()}}class SingleRecorder{constructor(e){this.mediaRecorder=null,this.audioChunks=[],this.uploadUrl="",this.uploadHeaders={},this.stream=null,this._isPaused=!1,this.eventEmitter=e}initialize(e,s){if(!e.upload_url)throw new Error("Upload URL is required for single recording");this.uploadUrl=e.upload_url,s!=null&&s.accessToken&&(this.uploadHeaders.Authorization=`Bearer ${s.accessToken}`)}async start(e){this.audioChunks=[];let s;try{s=await navigator.mediaDevices.getUserMedia({audio:e?{deviceId:{exact:e}}:!0})}catch(c){if((c==null?void 0:c.name)==="OverconstrainedError"||(c==null?void 0:c.name)==="NotFoundError")s=await navigator.mediaDevices.getUserMedia({audio:!0});else throw c}this.stream=s,this.mediaRecorder=new MediaRecorder(s),this.mediaRecorder.ondataavailable=c=>{c.data.size>0&&this.audioChunks.push(c.data)},this.mediaRecorder.start()}pause(){this.mediaRecorder&&this.mediaRecorder.state==="recording"&&(this.mediaRecorder.pause(),this._isPaused=!0)}resume(){this.mediaRecorder&&this.mediaRecorder.state==="paused"&&(this.mediaRecorder.resume(),this._isPaused=!1)}isPaused(){return this._isPaused}async stop(){return this._isPaused=!1,new Promise(e=>{if(!this.mediaRecorder){e({failedUploads:[],totalFiles:0});return}this.mediaRecorder.onstop=async()=>{var $;const s=new Blob(this.audioChunks,{type:"audio/webm"}),c=`recording_${Date.now()}.webm`;(await uploadFileWithFormData(this.uploadUrl,c,s,this.uploadHeaders)).success?e({failedUploads:[],totalFiles:1}):e({failedUploads:[c],totalFiles:1}),($=this.stream)==null||$.getTracks().forEach(_=>_.stop()),this.stream=null,this.mediaRecorder=null},this.mediaRecorder.stop()})}reset(){var e;this._isPaused=!1,this.mediaRecorder&&this.mediaRecorder.state!=="inactive"&&this.mediaRecorder.stop(),(e=this.stream)==null||e.getTracks().forEach(s=>s.stop()),this.stream=null,this.mediaRecorder=null,this.audioChunks=[]}}class EventEmitter{constructor(){this.listeners=new Map}on(e,s){var c;this.listeners.has(e)||this.listeners.set(e,new Set),(c=this.listeners.get(e))==null||c.add(s)}off(e,s){var c;(c=this.listeners.get(e))==null||c.delete(s)}emit(e){var s;(s=this.listeners.get(e.type))==null||s.forEach(c=>{try{c(e)}catch(h){console.error("Error in event listener:",h)}})}}class ScribeClient{static getInstance(e){return ScribeClient.instance||(ScribeClient.instance=new ScribeClient(e)),ScribeClient.instance}static resetInstance(){ScribeClient.instance&&(ScribeClient.instance.reset().catch(()=>{}),ScribeClient.instance=null)}constructor(e){this.discoveryDocument=null,this.currentSession=null,this.isInitialized=!1,this.recorder=null,this.validateConfig(e),this.config={debug:!1,autoDiscovery:!0,...e},this.httpClient=new HttpClient(this.config.apiKey,this.config.accessToken,this.config.debug),this.discoveryAPI=new DiscoveryAPI(this.httpClient),this.sessionAPI=new SessionAPI(this.httpClient,this.config.baseUrl||""),this.eventEmitter=new EventEmitter}async init(){if(this.isInitialized){this.config.debug&&console.log("[ScribeSDK] Already initialized");return}if(!this.config.baseUrl)throw new ValidationError("baseUrl is required for initialization");if(this.config.autoDiscovery)try{this.discoveryDocument=await this.discoveryAPI.getDiscovery(this.config.baseUrl),this.discoveryDocument.endpoints.base_url&&this.sessionAPI.setBaseUrl(this.discoveryDocument.endpoints.base_url),this.emitEvent({type:"discovery:complete",data:this.discoveryDocument}),this.config.debug&&console.log("[ScribeSDK] Discovery complete:",this.discoveryDocument)}catch(e){throw this.emitEvent({type:"error",error:e instanceof Error?e:new Error("Discovery failed")}),e}else this.sessionAPI.setBaseUrl(this.config.baseUrl);this.isInitialized=!0}async startRecording(e){if(this.isInitialized||await this.init(),(await navigator.permissions.query({name:"microphone"})).state!=="granted")throw new ValidationError("Microphone access is required to start recording.");try{const c={templates:e.templates,model:e.model,language_hint:e.languageHint,transcript_language:e.transcriptLanguage,upload_type:e.uploadType||UploadType.CHUNKED,communication_protocol:e.communicationProtocol||"http",additional_data:e.additionalData};return this.currentSession=await this.sessionAPI.createSession(c),this.emitEvent({type:"session:created",data:this.currentSession}),this.config.debug&&console.log("[ScribeSDK] Session created:",this.currentSession),e.uploadType===UploadType.SINGLE?this.recorder=new SingleRecorder(this.eventEmitter):this.recorder=new ChunkedRecorder(this.eventEmitter),this.recorder.initialize(this.currentSession,{accessToken:this.config.accessToken}),await this.recorder.start(e.deviceId),this.currentSession}catch(c){throw this.emitEvent({type:"error",error:c instanceof Error?c:new Error("Failed to start recording")}),c}}pauseRecording(){if(!this.recorder)throw new ValidationError("No active recording to pause");this.recorder.pause(),this.emitEvent({type:"recording:paused"}),this.config.debug&&console.log("[ScribeSDK] Recording paused")}resumeRecording(){if(!this.recorder)throw new ValidationError("No active recording to resume");this.recorder.resume(),this.emitEvent({type:"recording:resumed"}),this.config.debug&&console.log("[ScribeSDK] Recording resumed")}isRecordingPaused(){var e;return((e=this.recorder)==null?void 0:e.isPaused())??!1}async endRecording(){if(!this.currentSession)throw new ValidationError("No active session to end");try{let e=0;if(this.recorder){const{failedUploads:c,totalFiles:h}=await this.recorder.stop();if(c.length>0)throw console.warn("Some audio files failed to upload:",c),new ScribeError(`Failed to upload audio recordings: ${c.join(", ")}`,"upload_failed");e=h||0,this.recorder=null}const s=await this.sessionAPI.endSession(this.currentSession.session_id,e);return this.emitEvent({type:"session:ended",data:s}),this.config.debug&&console.log("[ScribeSDK] Session ended:",s),s}catch(e){throw this.emitEvent({type:"error",error:e instanceof Error?e:new Error("Failed to end recording")}),e}}async reset(){this.recorder&&(await this.recorder.stop().catch(()=>{}),this.recorder=null),this.currentSession=null,this.discoveryAPI.clearCache(),this.discoveryDocument=null,this.isInitialized=!1}emitEvent(e){this.eventEmitter.emit(e)}async getOutputStatus(e){var c;const s=e||((c=this.currentSession)==null?void 0:c.session_id);if(!s)throw new ValidationError("No session ID provided and no active session");try{const h=await this.sessionAPI.getSessionStatus(s);return this.emitEvent({type:"session:status_update",data:h}),this.config.debug&&console.log("[ScribeSDK] Session status:",h),h}catch(h){throw this.emitEvent({type:"error",error:h instanceof Error?h:new Error("Failed to get output status")}),h}}async pollForCompletion(e,s={}){var h;const c=e||((h=this.currentSession)==null?void 0:h.session_id);if(!c)throw new ValidationError("No session ID provided and no active session");return this.sessionAPI.pollSessionStatus(c,{...s,onProgress:$=>{this.emitEvent({type:"session:status_update",data:$}),s.onProgress&&s.onProgress($)}})}getCurrentSession(){return this.currentSession}getDiscoveryDocument(){return this.discoveryDocument}on(e,s){this.eventEmitter.on(e,s)}off(e,s){this.eventEmitter.off(e,s)}clearSession(){this.currentSession=null}validateConfig(e){if(!e.baseUrl)throw new ValidationError("baseUrl is required for initialization")}}ScribeClient.instance=null;function useScribeSession(i){const[e,s]=reactExports.useState("idle"),[c,h]=reactExports.useState(0),[$,_]=reactExports.useState(null),[j,nt]=reactExports.useState(""),et=reactExports.useRef(null),b=reactExports.useRef(null),a=reactExports.useRef(0),o=reactExports.useRef(0),d=reactExports.useCallback((...ft)=>{i.debug&&console.log("[EkaScribe]",...ft)},[i.debug]);reactExports.useEffect(()=>{if(!i.baseUrl){d("Skipping SDK init - no baseUrl provided");return}return(async()=>{try{et.current=ScribeClient.getInstance({accessToken:i.accessToken,baseUrl:i.baseUrl,debug:i.debug}),await et.current.init(),d("SDK initialized")}catch(dt){d("Failed to initialize SDK",dt)}})(),()=>{b.current&&clearInterval(b.current)}},[i.accessToken,i.baseUrl,i.debug,d]);const g=reactExports.useCallback(()=>{b.current=window.setInterval(()=>{const ft=Math.floor((Date.now()-a.current)/1e3);h(ft)},1e3)},[]),rt=reactExports.useCallback(()=>{b.current&&(clearInterval(b.current),b.current=null)},[]),st=async()=>{try{return(await navigator.permissions.query({name:"microphone"})).state}catch{return"prompt"}},tt=async()=>{try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(dt=>dt.stop()),!0}catch(ft){return d("Microphone permission denied",ft),!1}},ot=reactExports.useCallback(ft=>{nt(ft),s("error")},[]),it=reactExports.useCallback(async()=>{const ft=await st();if(ft==="denied"){ot("Microphone access is blocked. Please enable it in your browser settings.");return}if(ft==="prompt"&&(s("permission"),!await tt())){ot("Microphone access is required to record.");return}if(!et.current){ot("SDK not initialized. Please try again.");return}try{s("recording"),await et.current.startRecording({templates:i.templates||["eka_emr_template"],languageHint:i.languageHint}),a.current=Date.now(),o.current=0,h(0),g(),d("Recording started")}catch(dt){d("Failed to start recording",dt),ot("Failed to start recording. Please try again.")}},[i.templates,i.languageHint,d,ot,g]),at=reactExports.useCallback(()=>{et.current&&(et.current.pauseRecording(),s("paused"),o.current=Date.now(),rt(),d("Recording paused"))},[d,rt]),ut=reactExports.useCallback(()=>{et.current&&(et.current.resumeRecording(),s("recording"),o.current&&(a.current+=Date.now()-o.current,o.current=0),g(),d("Recording resumed"))},[d,g]),lt=reactExports.useCallback(async()=>{if(et.current)try{rt(),s("processing"),d("Stopping recording...");const ft=await et.current.endRecording();d("Recording ended",ft),d("Polling for completion...");const dt=await et.current.pollForCompletion(void 0,{maxAttempts:60,intervalMs:2e3,onProgress:yt=>{d("Status update:",yt.status)}});_(dt),d("Final result:",dt),s("results"),i.onResult&&i.onResult(dt)}catch(ft){d("Failed to stop recording",ft),ot("Failed to process recording. Please try again."),i.onError&&ft instanceof Error&&i.onError(ft)}},[i,d,ot,rt]),ct=reactExports.useCallback(()=>{_(null),nt(""),h(0),s("idle")},[]);return{state:e,elapsedTime:c,result:$,errorMessage:j,startRecording:it,pauseRecording:at,resumeRecording:ut,stopRecording:lt,reset:ct}}function App({config:i,onClose:e}){const[s,c]=reactExports.useState(!1),[h,$]=reactExports.useState(i.baseUrl?{accessToken:i.accessToken,baseUrl:i.baseUrl}:null),_=reactExports.useMemo(()=>h?{...i,accessToken:h.accessToken,baseUrl:h.baseUrl}:i,[i,h]),j=!h,{state:nt,elapsedTime:et,result:b,errorMessage:a,startRecording:o,pauseRecording:d,resumeRecording:g,stopRecording:rt,reset:st}=useScribeSession(_);if(s)return null;const tt=(it,at)=>{$({accessToken:it,baseUrl:at})},ot=()=>{if(j)return jsxRuntimeExports.jsx(ConfigState,{onSubmit:tt,initialAccessToken:i.accessToken||"",initialBaseUrl:i.baseUrl||""});switch(nt){case"idle":return jsxRuntimeExports.jsx(IdleState,{onStartRecording:o});case"permission":return jsxRuntimeExports.jsx(PermissionState,{onRequestPermission:o});case"recording":case"paused":return jsxRuntimeExports.jsx(RecordingState,{elapsedTime:et,isPaused:nt==="paused",onPause:d,onResume:g,onStop:rt});case"processing":return jsxRuntimeExports.jsx(ProcessingState,{});case"results":return b?jsxRuntimeExports.jsx(ResultsState,{result:b,onNewRecording:st}):null;case"error":return jsxRuntimeExports.jsx(ErrorState,{message:a,onRetry:st});default:return jsxRuntimeExports.jsx(IdleState,{onStartRecording:o})}};return jsxRuntimeExports.jsx(FloatingPanel,{position:_.position,onClose:e,onMinimize:()=>c(!0),children:ot()})}const widgetStyles=":host{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif}*{box-sizing:border-box;margin:0;padding:0}.scribe-panel{position:fixed;bottom:20px;right:20px;background:#fff;border-radius:16px;box-shadow:0 4px 24px #0000001f,0 0 0 1px #0000000d;z-index:2147483647;overflow:hidden;min-width:320px}.panel-header{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:#fafafa;border-bottom:1px solid #eee;cursor:grab}.panel-header:active{cursor:grabbing}.drag-handle{display:flex;gap:2px;flex-wrap:wrap;width:16px;opacity:.4}.drag-handle span{width:4px;height:4px;background:#666;border-radius:50%}.header-actions{display:flex;gap:8px}.header-btn{background:none;border:none;cursor:pointer;padding:4px;color:#666;display:flex;align-items:center;justify-content:center;width:24px;height:24px}.header-btn:hover{color:#333}.header-btn svg{width:16px;height:16px}.panel-content{padding:20px 24px}.idle-state{display:flex;align-items:center;gap:24px}.logo{display:flex;align-items:center;gap:8px}.logo-icon{width:32px;height:32px}.logo-icon svg{width:100%;height:100%}.logo-text{font-size:20px;font-weight:600;color:#2563eb}.start-btn{display:flex;align-items:center;gap:8px;background:#2563eb;color:#fff;border:none;padding:12px 24px;border-radius:24px;font-size:16px;font-weight:500;cursor:pointer;transition:background .2s}.start-btn:hover{background:#1d4ed8}.start-btn:disabled{background:#93c5fd;cursor:not-allowed}.mic-icon{width:20px;height:20px}.mic-icon svg{width:100%;height:100%}.recording-state{display:flex;align-items:center;gap:16px}.recording-indicator{display:flex;align-items:center;gap:12px;color:#666}.recording-icon{width:24px;height:24px;color:#666}.recording-icon svg{width:100%;height:100%}.recording-icon.active{color:#ef4444;animation:pulse 1.5s infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.timer{font-size:20px;font-weight:500;font-variant-numeric:tabular-nums;color:#374151}.recording-actions{display:flex;gap:8px;margin-left:auto}.resume-btn{background:#fff;color:#2563eb;border:2px solid #2563eb;padding:10px 20px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:all .2s}.resume-btn:hover{background:#eff6ff}.pause-btn{background:#fff;color:#f59e0b;border:2px solid #f59e0b;padding:10px 20px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:all .2s}.pause-btn:hover{background:#fffbeb}.stop-btn{background:#ef4444;color:#fff;border:none;padding:10px 16px;border-radius:8px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .2s}.stop-btn:hover{background:#dc2626}.stop-icon{width:16px;height:16px;background:#fff;border-radius:2px}.processing-state{display:flex;flex-direction:column;align-items:center;gap:16px;padding:20px}.spinner{width:40px;height:40px;border:3px solid #e5e7eb;border-top-color:#2563eb;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.processing-text{color:#6b7280;font-size:14px}.results-state{display:flex;flex-direction:column;gap:16px;max-height:400px}.results-header{display:flex;align-items:center;justify-content:space-between}.results-title{font-size:16px;font-weight:600;color:#111827}.new-recording-btn{background:#2563eb;color:#fff;border:none;padding:8px 16px;border-radius:6px;font-size:13px;cursor:pointer;transition:background .2s}.new-recording-btn:hover{background:#1d4ed8}.results-content{overflow-y:auto;max-height:300px}.transcript-section{margin-bottom:16px}.section-title{font-size:13px;font-weight:600;color:#6b7280;text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px}.transcript-text{font-size:14px;line-height:1.6;color:#374151;background:#f9fafb;padding:12px;border-radius:8px;white-space:pre-wrap}.error-state{display:flex;flex-direction:column;align-items:center;gap:12px;padding:20px;text-align:center}.error-icon{width:48px;height:48px;color:#ef4444}.error-icon svg{width:100%;height:100%}.error-message{color:#ef4444;font-size:14px}.retry-btn{background:#ef4444;color:#fff;border:none;padding:10px 20px;border-radius:8px;font-size:14px;cursor:pointer;transition:background .2s}.retry-btn:hover{background:#dc2626}.permission-state{display:flex;flex-direction:column;align-items:center;gap:16px;padding:20px;text-align:center}.permission-icon{width:48px;height:48px;color:#2563eb}.permission-icon svg{width:100%;height:100%}.permission-text{color:#374151;font-size:14px;line-height:1.5}.permission-btn{background:#2563eb;color:#fff;border:none;padding:12px 24px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:background .2s}.permission-btn:hover{background:#1d4ed8}.config-state{display:flex;flex-direction:column;gap:20px}.config-state .logo{justify-content:center}.config-form{display:flex;flex-direction:column;gap:12px}.config-form .form-group{display:flex;flex-direction:column;gap:4px}.config-form label{font-size:13px;font-weight:500;color:#374151}.config-form input{padding:10px 12px;border:1px solid #d1d5db;border-radius:8px;font-size:14px;color:#111827;background:#fff;transition:border-color .2s,box-shadow .2s}.config-form input:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px #2563eb1a}.config-form input::placeholder{color:#9ca3af}.config-error{color:#ef4444;font-size:13px;margin:0}.config-submit-btn{background:#2563eb;color:#fff;border:none;padding:12px 24px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:background .2s;margin-top:4px}.config-submit-btn:hover{background:#1d4ed8}";class ScribeWidget{constructor(e){Qr(this,"container");Qr(this,"shadowRoot");Qr(this,"root",null);Qr(this,"config");Qr(this,"visible",!0);this.config={templates:["soap"],languageHint:["en"],position:{bottom:20,right:20},...e},this.container=document.createElement("div"),this.container.id="eka-scribe-widget",this.shadowRoot=this.container.attachShadow({mode:"closed"});const s=document.createElement("style");s.textContent=widgetStyles,this.shadowRoot.appendChild(s);const c=document.createElement("div");c.id="eka-scribe-root",this.shadowRoot.appendChild(c),this.root=createRoot(c)}render(){!this.root||!this.visible||this.root.render(jsxRuntimeExports.jsx(App,{config:this.config,onClose:()=>this.hide()}))}mount(e){const s=typeof e=="string"?document.querySelector(e):e||document.body;s&&(s.appendChild(this.container),this.render())}unmount(){this.root&&(this.root.unmount(),this.root=null),this.container.remove()}show(){this.visible=!0,this.container.style.display="block",this.render()}hide(){this.visible=!1,this.container.style.display="none"}isVisible(){return this.visible}}let widgetInstance=null;function init(i={}){return widgetInstance&&widgetInstance.unmount(),console.log(i,"config - WIDGET"),widgetInstance=new ScribeWidget(i),widgetInstance.mount(),widgetInstance}function getInstance(){return widgetInstance}const EkaScribe={init,getInstance,Widget:ScribeWidget};if(typeof window<"u"&&typeof document<"u"){const i=()=>{const e=document.currentScript||document.querySelector('script[src*="scribe-widget"]');e!=null&&e.hasAttribute("data-no-auto-init")||(console.log(widgetInstance,"widget instance"),widgetInstance||init({baseUrl:""}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded - WIDGET",i):(console.log("load document - WIDGET"),i())}exports.ScribeWidget=ScribeWidget,exports.default=EkaScribe,exports.getInstance=getInstance,exports.init=init,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1851
|
+
`},1670:i=>{i.exports=__WEBPACK_EXTERNAL_MODULE__1670__},7067:()=>{},1296:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(i,e,s)=>{s.r(e),s.d(e,{flatbuffers:()=>c});var c={};c.Offset,c.Table,c.SIZEOF_SHORT=2,c.SIZEOF_INT=4,c.FILE_IDENTIFIER_LENGTH=4,c.SIZE_PREFIX_LENGTH=4,c.Encoding={UTF8_BYTES:1,UTF16_STRING:2},c.int32=new Int32Array(2),c.float32=new Float32Array(c.int32.buffer),c.float64=new Float64Array(c.int32.buffer),c.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,c.Long=function(h,$){this.low=0|h,this.high=0|$},c.Long.create=function(h,$){return h==0&&$==0?c.Long.ZERO:new c.Long(h,$)},c.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},c.Long.prototype.equals=function(h){return this.low==h.low&&this.high==h.high},c.Long.ZERO=new c.Long(0,0),c.Builder=function(h){if(h)$=h;else var $=1024;this.bb=c.ByteBuffer.allocate($),this.space=$,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},c.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},c.Builder.prototype.forceDefaults=function(h){this.force_defaults=h},c.Builder.prototype.dataBuffer=function(){return this.bb},c.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},c.Builder.prototype.prep=function(h,$){h>this.minalign&&(this.minalign=h);for(var _=1+~(this.bb.capacity()-this.space+$)&h-1;this.space<_+h+$;){var j=this.bb.capacity();this.bb=c.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-j}this.pad(_)},c.Builder.prototype.pad=function(h){for(var $=0;$<h;$++)this.bb.writeInt8(--this.space,0)},c.Builder.prototype.writeInt8=function(h){this.bb.writeInt8(this.space-=1,h)},c.Builder.prototype.writeInt16=function(h){this.bb.writeInt16(this.space-=2,h)},c.Builder.prototype.writeInt32=function(h){this.bb.writeInt32(this.space-=4,h)},c.Builder.prototype.writeInt64=function(h){this.bb.writeInt64(this.space-=8,h)},c.Builder.prototype.writeFloat32=function(h){this.bb.writeFloat32(this.space-=4,h)},c.Builder.prototype.writeFloat64=function(h){this.bb.writeFloat64(this.space-=8,h)},c.Builder.prototype.addInt8=function(h){this.prep(1,0),this.writeInt8(h)},c.Builder.prototype.addInt16=function(h){this.prep(2,0),this.writeInt16(h)},c.Builder.prototype.addInt32=function(h){this.prep(4,0),this.writeInt32(h)},c.Builder.prototype.addInt64=function(h){this.prep(8,0),this.writeInt64(h)},c.Builder.prototype.addFloat32=function(h){this.prep(4,0),this.writeFloat32(h)},c.Builder.prototype.addFloat64=function(h){this.prep(8,0),this.writeFloat64(h)},c.Builder.prototype.addFieldInt8=function(h,$,_){(this.force_defaults||$!=_)&&(this.addInt8($),this.slot(h))},c.Builder.prototype.addFieldInt16=function(h,$,_){(this.force_defaults||$!=_)&&(this.addInt16($),this.slot(h))},c.Builder.prototype.addFieldInt32=function(h,$,_){(this.force_defaults||$!=_)&&(this.addInt32($),this.slot(h))},c.Builder.prototype.addFieldInt64=function(h,$,_){!this.force_defaults&&$.equals(_)||(this.addInt64($),this.slot(h))},c.Builder.prototype.addFieldFloat32=function(h,$,_){(this.force_defaults||$!=_)&&(this.addFloat32($),this.slot(h))},c.Builder.prototype.addFieldFloat64=function(h,$,_){(this.force_defaults||$!=_)&&(this.addFloat64($),this.slot(h))},c.Builder.prototype.addFieldOffset=function(h,$,_){(this.force_defaults||$!=_)&&(this.addOffset($),this.slot(h))},c.Builder.prototype.addFieldStruct=function(h,$,_){$!=_&&(this.nested($),this.slot(h))},c.Builder.prototype.nested=function(h){if(h!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},c.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},c.Builder.prototype.slot=function(h){this.vtable[h]=this.offset()},c.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},c.Builder.growByteBuffer=function(h){var $=h.capacity();if(3221225472&$)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var _=$<<1,j=c.ByteBuffer.allocate(_);return j.setPosition(_-$),j.bytes().set(h.bytes(),_-$),j},c.Builder.prototype.addOffset=function(h){this.prep(c.SIZEOF_INT,0),this.writeInt32(this.offset()-h+c.SIZEOF_INT)},c.Builder.prototype.startObject=function(h){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=h;for(var $=0;$<h;$++)this.vtable[$]=0;this.isNested=!0,this.object_start=this.offset()},c.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var h=this.offset(),$=this.vtable_in_use-1;$>=0&&this.vtable[$]==0;$--);for(var _=$+1;$>=0;$--)this.addInt16(this.vtable[$]!=0?h-this.vtable[$]:0);this.addInt16(h-this.object_start);var j=(_+2)*c.SIZEOF_SHORT;this.addInt16(j);var nt=0,et=this.space;e:for($=0;$<this.vtables.length;$++){var b=this.bb.capacity()-this.vtables[$];if(j==this.bb.readInt16(b)){for(var a=c.SIZEOF_SHORT;a<j;a+=c.SIZEOF_SHORT)if(this.bb.readInt16(et+a)!=this.bb.readInt16(b+a))continue e;nt=this.vtables[$];break}}return nt?(this.space=this.bb.capacity()-h,this.bb.writeInt32(this.space,nt-h)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-h,this.offset()-h)),this.isNested=!1,h},c.Builder.prototype.finish=function(h,$,_){var j=_?c.SIZE_PREFIX_LENGTH:0;if($){var nt=$;if(this.prep(this.minalign,c.SIZEOF_INT+c.FILE_IDENTIFIER_LENGTH+j),nt.length!=c.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+c.FILE_IDENTIFIER_LENGTH);for(var et=c.FILE_IDENTIFIER_LENGTH-1;et>=0;et--)this.writeInt8(nt.charCodeAt(et))}this.prep(this.minalign,c.SIZEOF_INT+j),this.addOffset(h),j&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},c.Builder.prototype.finishSizePrefixed=function(h,$){this.finish(h,$,!0)},c.Builder.prototype.requiredField=function(h,$){var _=this.bb.capacity()-h,j=_-this.bb.readInt32(_);if(this.bb.readInt16(j+$)==0)throw new Error("FlatBuffers: field "+$+" must be set")},c.Builder.prototype.startVector=function(h,$,_){this.notNested(),this.vector_num_elems=$,this.prep(c.SIZEOF_INT,h*$),this.prep(_,h*$)},c.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},c.Builder.prototype.createString=function(h){if(h instanceof Uint8Array)var $=h;else{$=[];for(var _=0;_<h.length;){var j,nt=h.charCodeAt(_++);(j=nt<55296||nt>=56320?nt:(nt<<10)+h.charCodeAt(_++)+-56613888)<128?$.push(j):(j<2048?$.push(j>>6&31|192):(j<65536?$.push(j>>12&15|224):$.push(j>>18&7|240,j>>12&63|128),$.push(j>>6&63|128)),$.push(63&j|128))}}this.addInt8(0),this.startVector(1,$.length,1),this.bb.setPosition(this.space-=$.length),_=0;for(var et=this.space,b=this.bb.bytes();_<$.length;_++)b[et++]=$[_];return this.endVector()},c.Builder.prototype.createLong=function(h,$){return c.Long.create(h,$)},c.ByteBuffer=function(h){this.bytes_=h,this.position_=0},c.ByteBuffer.allocate=function(h){return new c.ByteBuffer(new Uint8Array(h))},c.ByteBuffer.prototype.clear=function(){this.position_=0},c.ByteBuffer.prototype.bytes=function(){return this.bytes_},c.ByteBuffer.prototype.position=function(){return this.position_},c.ByteBuffer.prototype.setPosition=function(h){this.position_=h},c.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},c.ByteBuffer.prototype.readInt8=function(h){return this.readUint8(h)<<24>>24},c.ByteBuffer.prototype.readUint8=function(h){return this.bytes_[h]},c.ByteBuffer.prototype.readInt16=function(h){return this.readUint16(h)<<16>>16},c.ByteBuffer.prototype.readUint16=function(h){return this.bytes_[h]|this.bytes_[h+1]<<8},c.ByteBuffer.prototype.readInt32=function(h){return this.bytes_[h]|this.bytes_[h+1]<<8|this.bytes_[h+2]<<16|this.bytes_[h+3]<<24},c.ByteBuffer.prototype.readUint32=function(h){return this.readInt32(h)>>>0},c.ByteBuffer.prototype.readInt64=function(h){return new c.Long(this.readInt32(h),this.readInt32(h+4))},c.ByteBuffer.prototype.readUint64=function(h){return new c.Long(this.readUint32(h),this.readUint32(h+4))},c.ByteBuffer.prototype.readFloat32=function(h){return c.int32[0]=this.readInt32(h),c.float32[0]},c.ByteBuffer.prototype.readFloat64=function(h){return c.int32[c.isLittleEndian?0:1]=this.readInt32(h),c.int32[c.isLittleEndian?1:0]=this.readInt32(h+4),c.float64[0]},c.ByteBuffer.prototype.writeInt8=function(h,$){this.bytes_[h]=$},c.ByteBuffer.prototype.writeUint8=function(h,$){this.bytes_[h]=$},c.ByteBuffer.prototype.writeInt16=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8},c.ByteBuffer.prototype.writeUint16=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8},c.ByteBuffer.prototype.writeInt32=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8,this.bytes_[h+2]=$>>16,this.bytes_[h+3]=$>>24},c.ByteBuffer.prototype.writeUint32=function(h,$){this.bytes_[h]=$,this.bytes_[h+1]=$>>8,this.bytes_[h+2]=$>>16,this.bytes_[h+3]=$>>24},c.ByteBuffer.prototype.writeInt64=function(h,$){this.writeInt32(h,$.low),this.writeInt32(h+4,$.high)},c.ByteBuffer.prototype.writeUint64=function(h,$){this.writeUint32(h,$.low),this.writeUint32(h+4,$.high)},c.ByteBuffer.prototype.writeFloat32=function(h,$){c.float32[0]=$,this.writeInt32(h,c.int32[0])},c.ByteBuffer.prototype.writeFloat64=function(h,$){c.float64[0]=$,this.writeInt32(h,c.int32[c.isLittleEndian?0:1]),this.writeInt32(h+4,c.int32[c.isLittleEndian?1:0])},c.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+c.SIZEOF_INT+c.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var h="",$=0;$<c.FILE_IDENTIFIER_LENGTH;$++)h+=String.fromCharCode(this.readInt8(this.position_+c.SIZEOF_INT+$));return h},c.ByteBuffer.prototype.__offset=function(h,$){var _=h-this.readInt32(h);return $<this.readInt16(_)?this.readInt16(_+$):0},c.ByteBuffer.prototype.__union=function(h,$){return h.bb_pos=$+this.readInt32($),h.bb=this,h},c.ByteBuffer.prototype.__string=function(h,$){h+=this.readInt32(h);var _=this.readInt32(h),j="",nt=0;if(h+=c.SIZEOF_INT,$===c.Encoding.UTF8_BYTES)return this.bytes_.subarray(h,h+_);for(;nt<_;){var et,b=this.readUint8(h+nt++);if(b<192)et=b;else{var a=this.readUint8(h+nt++);if(b<224)et=(31&b)<<6|63&a;else{var o=this.readUint8(h+nt++);et=b<240?(15&b)<<12|(63&a)<<6|63&o:(7&b)<<18|(63&a)<<12|(63&o)<<6|63&this.readUint8(h+nt++)}}et<65536?j+=String.fromCharCode(et):(et-=65536,j+=String.fromCharCode(55296+(et>>10),56320+(1023&et)))}return j},c.ByteBuffer.prototype.__indirect=function(h){return h+this.readInt32(h)},c.ByteBuffer.prototype.__vector=function(h){return h+this.readInt32(h)+c.SIZEOF_INT},c.ByteBuffer.prototype.__vector_len=function(h){return this.readInt32(h+this.readInt32(h))},c.ByteBuffer.prototype.__has_identifier=function(h){if(h.length!=c.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+c.FILE_IDENTIFIER_LENGTH);for(var $=0;$<c.FILE_IDENTIFIER_LENGTH;$++)if(h.charCodeAt($)!=this.readInt8(this.position_+c.SIZEOF_INT+$))return!1;return!0},c.ByteBuffer.prototype.createLong=function(h,$){return c.Long.create(h,$)}}},__webpack_module_cache__={};function __webpack_require__(i){var e=__webpack_module_cache__[i];if(e!==void 0)return e.exports;var s=__webpack_module_cache__[i]={exports:{}};return __webpack_modules__[i].call(s.exports,s,s.exports,__webpack_require__),s.exports}__webpack_require__.n=i=>{var e=i&&i.__esModule?()=>i.default:()=>i;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(i,e)=>{for(var s in e)__webpack_require__.o(e,s)&&!__webpack_require__.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:e[s]})},__webpack_require__.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),__webpack_require__.o=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),__webpack_require__.r=i=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6018);return __webpack_exports__})())})(ortWeb_min);var ortWeb_minExports=ortWeb_min.exports,assetPath={};Object.defineProperty(assetPath,"__esModule",{value:!0}),assetPath.baseAssetPath=void 0;const isWeb=typeof window<"u"&&typeof window.document<"u",currentScript=isWeb?window.document.currentScript:null;let basePath="/";currentScript&&(basePath=currentScript.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),assetPath.baseAssetPath=basePath;var defaultModelFetcher$1={};Object.defineProperty(defaultModelFetcher$1,"__esModule",{value:!0}),defaultModelFetcher$1.defaultModelFetcher=void 0;const defaultModelFetcher=i=>fetch(i).then(e=>e.arrayBuffer());defaultModelFetcher$1.defaultModelFetcher=defaultModelFetcher;var frameProcessor={},logging={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.log=i.LOG_PREFIX=void 0,i.LOG_PREFIX="[VAD]";const e=["error","debug","warn"];function s(h){return(...$)=>{console[h](i.LOG_PREFIX,...$)}}const c=e.reduce((h,$)=>(h[$]=s($),h),{});i.log=c})(logging);var messages={};Object.defineProperty(messages,"__esModule",{value:!0}),messages.Message=void 0;var Message;(function(i){i.AudioFrame="AUDIO_FRAME",i.SpeechStart="SPEECH_START",i.VADMisfire="VAD_MISFIRE",i.SpeechEnd="SPEECH_END",i.SpeechStop="SPEECH_STOP"})(Message||(messages.Message=Message={})),Object.defineProperty(frameProcessor,"__esModule",{value:!0}),frameProcessor.FrameProcessor=frameProcessor.validateOptions=frameProcessor.defaultV5FrameProcessorOptions=frameProcessor.defaultLegacyFrameProcessorOptions=void 0;const logging_1$3=logging,messages_1=messages,RECOMMENDED_FRAME_SAMPLES=[512,1024,1536];frameProcessor.defaultLegacyFrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:1,redemptionFrames:8,frameSamples:1536,minSpeechFrames:3,submitUserSpeechOnPause:!1},frameProcessor.defaultV5FrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:3,redemptionFrames:24,frameSamples:512,minSpeechFrames:9,submitUserSpeechOnPause:!1};function validateOptions(i){RECOMMENDED_FRAME_SAMPLES.includes(i.frameSamples)||logging_1$3.log.warn("You are using an unusual frame size"),(i.positiveSpeechThreshold<0||i.positiveSpeechThreshold>1)&&logging_1$3.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(i.negativeSpeechThreshold<0||i.negativeSpeechThreshold>i.positiveSpeechThreshold)&&logging_1$3.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),i.preSpeechPadFrames<0&&logging_1$3.log.error("preSpeechPadFrames should be positive"),i.redemptionFrames<0&&logging_1$3.log.error("redemptionFrames should be positive")}frameProcessor.validateOptions=validateOptions;const concatArrays=i=>{const e=i.reduce((c,h)=>(c.push(c.at(-1)+h.length),c),[0]),s=new Float32Array(e.at(-1));return i.forEach((c,h)=>{const $=e[h];s.set(c,$)}),s};class FrameProcessor{constructor(e,s,c){this.modelProcessFunc=e,this.modelResetFunc=s,this.options=c,this.speaking=!1,this.redemptionCounter=0,this.active=!1,this.reset=()=>{this.speaking=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0},this.pause=()=>(this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment():(this.reset(),{})),this.resume=()=>{this.active=!0},this.endSegment=()=>{const h=this.audioBuffer;this.audioBuffer=[];const $=this.speaking;this.reset();const _=h.reduce((j,nt)=>j+ +nt.isSpeech,0);if($)if(_>=this.options.minSpeechFrames){const j=concatArrays(h.map(nt=>nt.frame));return{msg:messages_1.Message.SpeechEnd,audio:j}}else return{msg:messages_1.Message.VADMisfire};return{}},this.process=async h=>{if(!this.active)return{};const $=await this.modelProcessFunc(h);if(this.audioBuffer.push({frame:h,isSpeech:$.isSpeech>=this.options.positiveSpeechThreshold}),$.isSpeech>=this.options.positiveSpeechThreshold&&this.redemptionCounter&&(this.redemptionCounter=0),$.isSpeech>=this.options.positiveSpeechThreshold&&!this.speaking)return this.speaking=!0,{probs:$,msg:messages_1.Message.SpeechStart,frame:h};if($.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.options.redemptionFrames){this.redemptionCounter=0,this.speaking=!1;const _=this.audioBuffer;if(this.audioBuffer=[],_.reduce((nt,et)=>nt+ +et.isSpeech,0)>=this.options.minSpeechFrames){const nt=concatArrays(_.map(et=>et.frame));return{probs:$,msg:messages_1.Message.SpeechEnd,audio:nt,frame:h}}else return{probs:$,msg:messages_1.Message.VADMisfire,frame:h}}if(!this.speaking)for(;this.audioBuffer.length>this.options.preSpeechPadFrames;)this.audioBuffer.shift();return{probs:$,frame:h}},this.audioBuffer=[],this.reset()}}frameProcessor.FrameProcessor=FrameProcessor;var nonRealTimeVad={},models={},common={};Object.defineProperty(common,"__esModule",{value:!0});var legacy={},_a$1;Object.defineProperty(legacy,"__esModule",{value:!0}),legacy.SileroLegacy=void 0;const logging_1$2=logging;class SileroLegacy{constructor(e,s,c,h,$){this.ortInstance=e,this._session=s,this._h=c,this._c=h,this._sr=$,this.reset_state=()=>{const _=Array(128).fill(0);this._h=new this.ortInstance.Tensor("float32",_,[2,1,64]),this._c=new this.ortInstance.Tensor("float32",_,[2,1,64])},this.process=async _=>{var o;const nt={input:new this.ortInstance.Tensor("float32",_,[1,_.length]),h:this._h,c:this._c,sr:this._sr},et=await this._session.run(nt);this._h=et.hn,this._c=et.cn;const[b]=(o=et.output)==null?void 0:o.data;return{notSpeech:1-b,isSpeech:b}}}}legacy.SileroLegacy=SileroLegacy,_a$1=SileroLegacy,SileroLegacy.new=async(i,e)=>{logging_1$2.log.debug("initializing vad");const s=await e(),c=await i.InferenceSession.create(s),h=new i.Tensor("int64",[16000n]),$=Array(2*64).fill(0),_=new i.Tensor("float32",$,[2,1,64]),j=new i.Tensor("float32",$,[2,1,64]);return logging_1$2.log.debug("vad is initialized"),new _a$1(i,c,_,j,h)};var v5={},_a;Object.defineProperty(v5,"__esModule",{value:!0}),v5.SileroV5=void 0;const logging_1$1=logging;function getNewState(i){const e=Array(256).fill(0);return new i.Tensor("float32",e,[2,1,128])}class SileroV5{constructor(e,s,c,h){this._session=e,this._state=s,this._sr=c,this.ortInstance=h,this.reset_state=()=>{this._state=getNewState(this.ortInstance)},this.process=async $=>{var a;const j={input:new this.ortInstance.Tensor("float32",$,[1,$.length]),state:this._state,sr:this._sr},nt=await this._session.run(j);this._state=nt.stateN;const[et]=(a=nt.output)==null?void 0:a.data;return{notSpeech:1-et,isSpeech:et}}}}v5.SileroV5=SileroV5,_a=SileroV5,SileroV5.new=async(i,e)=>{logging_1$1.log.debug("Loading VAD...");const s=await e(),c=await i.InferenceSession.create(s),h=new i.Tensor("int64",[16000n]),$=getNewState(i);return logging_1$1.log.debug("...finished loading VAD"),new _a(c,$,h,i)},function(i){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function($,_,j,nt){nt===void 0&&(nt=j);var et=Object.getOwnPropertyDescriptor(_,j);(!et||("get"in et?!_.__esModule:et.writable||et.configurable))&&(et={enumerable:!0,get:function(){return _[j]}}),Object.defineProperty($,nt,et)}:function($,_,j,nt){nt===void 0&&(nt=j),$[nt]=_[j]}),s=commonjsGlobal&&commonjsGlobal.__exportStar||function($,_){for(var j in $)j!=="default"&&!Object.prototype.hasOwnProperty.call(_,j)&&e(_,$,j)};Object.defineProperty(i,"__esModule",{value:!0}),i.SileroV5=i.SileroLegacy=void 0,s(common,i);var c=legacy;Object.defineProperty(i,"SileroLegacy",{enumerable:!0,get:function(){return c.SileroLegacy}});var h=v5;Object.defineProperty(i,"SileroV5",{enumerable:!0,get:function(){return h.SileroV5}})}(models);var resampler={};Object.defineProperty(resampler,"__esModule",{value:!0}),resampler.Resampler=void 0;const logging_1=logging;class Resampler{constructor(e){this.options=e,this.process=s=>{const c=[];for(const h of s)for(this.inputBuffer.push(h);this.hasEnoughDataForFrame();){const $=this.generateOutputFrame();c.push($)}return c},this.stream=async function*(s){for(const c of s)for(this.inputBuffer.push(c);this.hasEnoughDataForFrame();)yield this.generateOutputFrame()},e.nativeSampleRate<16e3&&logging_1.log.error("nativeSampleRate is too low. Should have 16000 = targetSampleRate <= nativeSampleRate"),this.inputBuffer=[]}hasEnoughDataForFrame(){return this.inputBuffer.length*this.options.targetSampleRate/this.options.nativeSampleRate>=this.options.targetFrameSize}generateOutputFrame(){const e=new Float32Array(this.options.targetFrameSize);let s=0,c=0;for(;s<this.options.targetFrameSize;){let h=0,$=0;for(;c<Math.min(this.inputBuffer.length,(s+1)*this.options.nativeSampleRate/this.options.targetSampleRate);){const _=this.inputBuffer[c];_!==void 0&&(h+=_,$++),c++}e[s]=h/$,s++}return this.inputBuffer=this.inputBuffer.slice(c),e}}resampler.Resampler=Resampler,function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.PlatformAgnosticNonRealTimeVAD=i.defaultNonRealTimeVADOptions=void 0;const e=frameProcessor,s=messages,c=models,h=resampler;i.defaultNonRealTimeVADOptions={...e.defaultLegacyFrameProcessorOptions,ortConfig:void 0};class ${static async _new(j,nt,et={}){const b={...i.defaultNonRealTimeVADOptions,...et};b.ortConfig!==void 0&&b.ortConfig(nt);const a=new this(j,nt,b);return await a.init(),a}constructor(j,nt,et){this.modelFetcher=j,this.ort=nt,this.options=et,this.init=async()=>{const b=await c.SileroLegacy.new(this.ort,this.modelFetcher);this.frameProcessor=new e.FrameProcessor(b.process,b.reset_state,{frameSamples:this.options.frameSamples,positiveSpeechThreshold:this.options.positiveSpeechThreshold,negativeSpeechThreshold:this.options.negativeSpeechThreshold,redemptionFrames:this.options.redemptionFrames,preSpeechPadFrames:this.options.preSpeechPadFrames,minSpeechFrames:this.options.minSpeechFrames,submitUserSpeechOnPause:this.options.submitUserSpeechOnPause}),this.frameProcessor.resume()},this.run=async function*(b,a){const o={nativeSampleRate:a,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples},d=new h.Resampler(o);let g=0,rt=0,st=0;for await(const it of d.stream(b)){const{msg:at,audio:ut}=await this.frameProcessor.process(it);switch(at){case s.Message.SpeechStart:g=st*this.options.frameSamples/16;break;case s.Message.SpeechEnd:rt=(st+1)*this.options.frameSamples/16,yield{audio:ut,start:g,end:rt};break}st++}const{msg:tt,audio:ot}=this.frameProcessor.endSegment();tt==s.Message.SpeechEnd&&(yield{audio:ot,start:g,end:st*this.options.frameSamples/16})},(0,e.validateOptions)(et)}}i.PlatformAgnosticNonRealTimeVAD=$}(nonRealTimeVad);var utils={};Object.defineProperty(utils,"__esModule",{value:!0}),utils.audioFileToArray=utils.encodeWAV=utils.arrayBufferToBase64=utils.minFramesForTargetMS=void 0;function minFramesForTargetMS(i,e,s=16e3){return Math.ceil(i*s/1e3/e)}utils.minFramesForTargetMS=minFramesForTargetMS;function arrayBufferToBase64(i){const e=new Uint8Array(i),s=e.byteLength,c=new Array(s);for(var h=0;h<s;h++){const $=e[h];if($===void 0)break;c[h]=String.fromCharCode($)}return btoa(c.join(""))}utils.arrayBufferToBase64=arrayBufferToBase64;function encodeWAV(i,e=3,s=16e3,c=1,h=32){var $=h/8,_=c*$,j=new ArrayBuffer(44+i.length*$),nt=new DataView(j);return writeString(nt,0,"RIFF"),nt.setUint32(4,36+i.length*$,!0),writeString(nt,8,"WAVE"),writeString(nt,12,"fmt "),nt.setUint32(16,16,!0),nt.setUint16(20,e,!0),nt.setUint16(22,c,!0),nt.setUint32(24,s,!0),nt.setUint32(28,s*_,!0),nt.setUint16(32,_,!0),nt.setUint16(34,h,!0),writeString(nt,36,"data"),nt.setUint32(40,i.length*$,!0),e===1?floatTo16BitPCM(nt,44,i):writeFloat32(nt,44,i),j}utils.encodeWAV=encodeWAV;function writeFloat32(i,e,s){for(var c=0;c<s.length;c++,e+=4)i.setFloat32(e,s[c],!0)}function floatTo16BitPCM(i,e,s){for(var c=0;c<s.length;c++,e+=2){var h=Math.max(-1,Math.min(1,s[c]));i.setInt16(e,h<0?h*32768:h*32767,!0)}}function writeString(i,e,s){for(var c=0;c<s.length;c++)i.setUint8(e+c,s.charCodeAt(c))}async function audioFileToArray(i){const e=new OfflineAudioContext(1,1,44100),s=new FileReader;let c=null;if(await new Promise(_=>{s.addEventListener("loadend",j=>{const nt=s.result;e.decodeAudioData(nt,et=>{c=et,e.startRendering().then(b=>{console.log("Rendering completed successfully"),_()}).catch(b=>{console.error(`Rendering failed: ${b}`)})},et=>{console.log(`Error with decoding audio data: ${et}`)})}),s.readAsArrayBuffer(i)}),c===null)throw Error("some shit");let h=c,$=new Float32Array(h.length);for(let _=0;_<h.length;_++)for(let j=0;j<h.numberOfChannels;j++)$[_]+=h.getChannelData(j)[_];return{audio:$,sampleRate:h.sampleRate}}utils.audioFileToArray=audioFileToArray;var realTimeVad={};(function(i){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(tt,ot,it,at){at===void 0&&(at=it);var ut=Object.getOwnPropertyDescriptor(ot,it);(!ut||("get"in ut?!ot.__esModule:ut.writable||ut.configurable))&&(ut={enumerable:!0,get:function(){return ot[it]}}),Object.defineProperty(tt,at,ut)}:function(tt,ot,it,at){at===void 0&&(at=it),tt[at]=ot[it]}),s=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(tt,ot){Object.defineProperty(tt,"default",{enumerable:!0,value:ot})}:function(tt,ot){tt.default=ot}),c=commonjsGlobal&&commonjsGlobal.__importStar||function(tt){if(tt&&tt.__esModule)return tt;var ot={};if(tt!=null)for(var it in tt)it!=="default"&&Object.prototype.hasOwnProperty.call(tt,it)&&e(ot,tt,it);return s(ot,tt),ot};Object.defineProperty(i,"__esModule",{value:!0}),i.AudioNodeVAD=i.MicVAD=i.getDefaultRealTimeVADOptions=i.ort=i.DEFAULT_MODEL=void 0;const h=c(ortWeb_minExports),$=defaultModelFetcher$1,_=frameProcessor,j=logging,nt=messages,et=models,b=resampler;i.DEFAULT_MODEL="legacy",i.ort=h;const a="vad.worklet.bundle.min.js",o="silero_vad_v5.onnx",d="silero_vad_legacy.onnx",g=tt=>({...tt==="v5"?_.defaultV5FrameProcessorOptions:_.defaultLegacyFrameProcessorOptions,onFrameProcessed:it=>{},onVADMisfire:()=>{j.log.debug("VAD misfire")},onSpeechStart:()=>{j.log.debug("Detected speech start")},onSpeechEnd:()=>{j.log.debug("Detected speech end")},baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.22/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/",stream:void 0,ortConfig:void 0,model:i.DEFAULT_MODEL,workletOptions:{}});i.getDefaultRealTimeVADOptions=g;class rt{static async new(ot={}){const it={...(0,i.getDefaultRealTimeVADOptions)(ot.model??i.DEFAULT_MODEL),...ot};(0,_.validateOptions)(it);let at;it.stream===void 0?at=await navigator.mediaDevices.getUserMedia({audio:{...it.additionalAudioConstraints,channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}):at=it.stream;const ut=new AudioContext,lt=new MediaStreamAudioSourceNode(ut,{mediaStream:at}),ct=await st.new(ut,it);return ct.receive(lt),new rt(it,ut,at,ct,lt)}constructor(ot,it,at,ut,lt,ct=!1){this.options=ot,this.audioContext=it,this.stream=at,this.audioNodeVAD=ut,this.sourceNode=lt,this.listening=ct,this.pause=()=>{this.audioNodeVAD.pause(),this.listening=!1},this.start=()=>{this.audioNodeVAD.start(),this.listening=!0},this.destroy=()=>{this.listening&&this.pause(),this.options.stream===void 0&&this.stream.getTracks().forEach(ft=>ft.stop()),this.sourceNode.disconnect(),this.audioNodeVAD.destroy(),this.audioContext.close()}}}i.MicVAD=rt;class st{static async new(ot,it={}){const at={...(0,i.getDefaultRealTimeVADOptions)(it.model??i.DEFAULT_MODEL),...it};(0,_.validateOptions)(at),i.ort.env.wasm.wasmPaths=at.onnxWASMBasePath,at.ortConfig!==void 0&&at.ortConfig(i.ort);const ut=at.model==="v5"?o:d,lt=at.baseAssetPath+ut,ct=at.model==="v5"?et.SileroV5.new:et.SileroLegacy.new;let ft;try{ft=await ct(i.ort,()=>(0,$.defaultModelFetcher)(lt))}catch(St){throw console.error(`Encountered an error while loading model file ${lt}`),St}const dt=new _.FrameProcessor(ft.process,ft.reset_state,{frameSamples:at.frameSamples,positiveSpeechThreshold:at.positiveSpeechThreshold,negativeSpeechThreshold:at.negativeSpeechThreshold,redemptionFrames:at.redemptionFrames,preSpeechPadFrames:at.preSpeechPadFrames,minSpeechFrames:at.minSpeechFrames,submitUserSpeechOnPause:at.submitUserSpeechOnPause}),yt=new st(ot,at,dt);return await yt.setupAudioNode(),yt}constructor(ot,it,at){this.ctx=ot,this.options=it,this.bufferIndex=0,this.pause=()=>{const ut=this.frameProcessor.pause();this.handleFrameProcessorEvent(ut)},this.start=()=>{this.frameProcessor.resume()},this.receive=ut=>{ut.connect(this.audioNode)},this.processFrame=async ut=>{const lt=await this.frameProcessor.process(ut);this.handleFrameProcessorEvent(lt)},this.handleFrameProcessorEvent=ut=>{switch(ut.probs!==void 0&&this.options.onFrameProcessed(ut.probs,ut.frame),ut.msg){case nt.Message.SpeechStart:this.options.onSpeechStart();break;case nt.Message.VADMisfire:this.options.onVADMisfire();break;case nt.Message.SpeechEnd:this.options.onSpeechEnd(ut.audio);break}},this.destroy=()=>{var ut;this.audioNode instanceof AudioWorkletNode&&this.audioNode.port.postMessage({message:nt.Message.SpeechStop}),this.audioNode.disconnect(),(ut=this.gainNode)==null||ut.disconnect()},this.frameProcessor=at}async setupAudioNode(){if("audioWorklet"in this.ctx&&typeof AudioWorkletNode=="function")try{const ut=this.options.baseAssetPath+a;await this.ctx.audioWorklet.addModule(ut);const lt=this.options.workletOptions??{};lt.processorOptions={...lt.processorOptions??{},frameSamples:this.options.frameSamples},this.audioNode=new AudioWorkletNode(this.ctx,"vad-helper-worklet",lt),this.audioNode.port.onmessage=async ct=>{var ft;switch((ft=ct.data)==null?void 0:ft.message){case nt.Message.AudioFrame:let dt=ct.data.data;dt instanceof ArrayBuffer||(dt=new ArrayBuffer(ct.data.data.byteLength),new Uint8Array(dt).set(new Uint8Array(ct.data.data)));const yt=new Float32Array(dt);await this.processFrame(yt);break}};return}catch(ut){console.log("AudioWorklet setup failed, falling back to ScriptProcessor",ut)}this.resampler=new b.Resampler({nativeSampleRate:this.ctx.sampleRate,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples??480});const it=4096;this.audioNode=this.ctx.createScriptProcessor(it,1,1),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=0;let at=!1;this.audioNode.onaudioprocess=async ut=>{if(!at){at=!0;try{const lt=ut.inputBuffer.getChannelData(0);if(ut.outputBuffer.getChannelData(0).fill(0),this.resampler){const ft=this.resampler.process(lt);for(const dt of ft)await this.processFrame(dt)}}catch(lt){console.error("Error processing audio:",lt)}finally{at=!1}}},this.audioNode.connect(this.gainNode),this.gainNode.connect(this.ctx.destination)}}i.AudioNodeVAD=st})(realTimeVad),function(i){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(d,g,rt,st){st===void 0&&(st=rt);var tt=Object.getOwnPropertyDescriptor(g,rt);(!tt||("get"in tt?!g.__esModule:tt.writable||tt.configurable))&&(tt={enumerable:!0,get:function(){return g[rt]}}),Object.defineProperty(d,st,tt)}:function(d,g,rt,st){st===void 0&&(st=rt),d[st]=g[rt]}),s=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(d,g){Object.defineProperty(d,"default",{enumerable:!0,value:g})}:function(d,g){d.default=g}),c=commonjsGlobal&&commonjsGlobal.__importStar||function(d){if(d&&d.__esModule)return d;var g={};if(d!=null)for(var rt in d)rt!=="default"&&Object.prototype.hasOwnProperty.call(d,rt)&&e(g,d,rt);return s(g,d),g};Object.defineProperty(i,"__esModule",{value:!0}),i.NonRealTimeVAD=i.Message=i.FrameProcessor=i.getDefaultRealTimeVADOptions=i.MicVAD=i.DEFAULT_MODEL=i.AudioNodeVAD=i.utils=i.defaultNonRealTimeVADOptions=void 0;const h=c(ortWeb_minExports),$=assetPath,_=defaultModelFetcher$1,j=frameProcessor;Object.defineProperty(i,"FrameProcessor",{enumerable:!0,get:function(){return j.FrameProcessor}});const nt=messages;Object.defineProperty(i,"Message",{enumerable:!0,get:function(){return nt.Message}});const et=nonRealTimeVad,b=utils;i.defaultNonRealTimeVADOptions={modelURL:$.baseAssetPath+"silero_vad_legacy.onnx",modelFetcher:_.defaultModelFetcher};class a extends et.PlatformAgnosticNonRealTimeVAD{static async new(g={}){const{modelURL:rt,modelFetcher:st}={...i.defaultNonRealTimeVADOptions,...g};return await this._new(()=>st(rt),h,g)}}i.NonRealTimeVAD=a,i.utils={audioFileToArray:b.audioFileToArray,minFramesForTargetMS:b.minFramesForTargetMS,arrayBufferToBase64:b.arrayBufferToBase64,encodeWAV:b.encodeWAV};var o=realTimeVad;Object.defineProperty(i,"AudioNodeVAD",{enumerable:!0,get:function(){return o.AudioNodeVAD}}),Object.defineProperty(i,"DEFAULT_MODEL",{enumerable:!0,get:function(){return o.DEFAULT_MODEL}}),Object.defineProperty(i,"MicVAD",{enumerable:!0,get:function(){return o.MicVAD}}),Object.defineProperty(i,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return o.getDefaultRealTimeVADOptions}})}(dist);class VadWebClient{constructor(e,s,c,h,$,_){this.micStream=null,this.is_vad_loading=!0,this.noSpeechStartTime=null,this.recording_started=!1,this.lastWarningTime=null,this.warningCooldownPeriod=2e3,this.vad_past=[],this.last_clip_index=0,this.clip_points=[0],this.sil_duration_acc=0,this.pref_length_samples=e*h,this.desp_length_samples=s*h,this.max_length_samples=c*h,this.shor_thsld=SHORT_SILENCE_THRESHOLD*h,this.long_thsld=LONG_SILENCE_THRESHOLD*h,this.frame_size=FRAME_SIZE,this.speech_pad_frames=PRE_SPEECH_PAD_FRAMES,this.micVad={},this.audioFileManager=$,this.audioBufferManager=_}setDependencies(e,s){this.audioFileManager=e,this.audioBufferManager=s}setCallbacks(e,s,c){this.onVadFramesCallback=e,this.onVadFrameProcessedCallback=s,this.onUserSpeechCallback=c}stopMicStream(){var e,s;try{(s=(e=this.micStream)==null?void 0:e.getTracks)==null||s.call(e).forEach(c=>c.stop())}catch{}finally{this.micStream=null}}checkNoSpeech(e){if(!this.recording_started)return;const s=Date.now();e===0?this.noSpeechStartTime===null?this.noSpeechStartTime=s:s-this.noSpeechStartTime>=1e4&&(this.lastWarningTime===null||s-this.lastWarningTime>=this.warningCooldownPeriod)&&(this.onVadFramesCallback&&this.onVadFramesCallback({message:"No audio detected for a while. Please talk or stop the recording if done.",error_code:ErrorCode.AUDIO_QUALITY_POOR,status_code:HttpStatus.BAD_REQUEST}),this.lastWarningTime=s,this.noSpeechStartTime=s):(this.noSpeechStartTime=null,this.lastWarningTime=null,this.onVadFramesCallback&&this.onVadFramesCallback({message:"Audio captured. Recording continues.",status_code:HttpStatus.OK}))}getMicVad(){return this.micVad}isVadLoading(){return this.is_vad_loading}processVadFrame(e){let s=!1;this.vad_past.length>0&&(e===0&&(this.sil_duration_acc+=1),e===1&&(this.sil_duration_acc=0));const c=(this.vad_past.length-this.last_clip_index)*this.frame_size,h=this.sil_duration_acc*this.frame_size;return c>this.pref_length_samples&&h>this.long_thsld&&(this.last_clip_index=this.vad_past.length-Math.min(Math.floor(this.sil_duration_acc/2),5),this.clip_points.push(this.last_clip_index),this.sil_duration_acc=0,s=!0),c>this.desp_length_samples&&h>this.shor_thsld&&(this.last_clip_index=this.vad_past.length-Math.min(Math.floor(this.sil_duration_acc/2),5),this.clip_points.push(this.last_clip_index),this.sil_duration_acc=0,s=!0),c>=this.max_length_samples&&(this.last_clip_index=this.vad_past.length,this.clip_points.push(this.last_clip_index),this.sil_duration_acc=0,s=!0),this.vad_past.push(e),s?[!0,this.clip_points[this.clip_points.length-1]]:[!1,this.clip_points[this.clip_points.length-1]]}async initVad(e){this.is_vad_loading=!0,this.stopMicStream();let s;try{s=await navigator.mediaDevices.getUserMedia({audio:e?{deviceId:{exact:e}}:!0})}catch(c){if((c==null?void 0:c.name)==="OverconstrainedError"||(c==null?void 0:c.name)==="NotFoundError")s=await navigator.mediaDevices.getUserMedia({audio:!0});else throw c}this.micStream=s;try{const c=await dist.MicVAD.new({stream:s,frameSamples:this.frame_size,preSpeechPadFrames:this.speech_pad_frames,onFrameProcessed:(h,$)=>{var b,a,o;if(this.onVadFrameProcessedCallback&&this.onVadFrameProcessedCallback({probabilities:h,frame:$}),!this.recording_started)return;(b=this.audioFileManager)==null||b.incrementTotalRawSamples($),(a=this.audioBufferManager)==null||a.append($);const{isSpeech:_}=h;let j=0;_>=.5&&(j=1),this.checkNoSpeech(j);const nt=this.processVadFrame(j),et=nt[0];if(console.log("is clip point:",et," at index:",nt[1]),et){const d=(o=this.audioBufferManager)==null?void 0:o.getAudioData();console.log("Processing audio chunk at clip point:",d),d&&this.processAudioChunk({audioFrames:d})}},onSpeechStart:()=>{var h;(h=this.onUserSpeechCallback)==null||h.call(this,!0)},onSpeechEnd:()=>{var h;(h=this.onUserSpeechCallback)==null||h.call(this,!1)}});return this.is_vad_loading=!1,this.micVad=c,!this.is_vad_loading}catch(c){throw console.error("Error initializing VAD:",c),this.stopMicStream(),this.is_vad_loading=!1,c}}async reinitializeVad(e){return await this.initVad(e)}async processAudioChunk({audioFrames:e}){if(!e||!this.audioFileManager||!this.audioBufferManager)return;const c=`audio_${this.audioFileManager.audioChunks.length||0}.${OUTPUT_FORMAT}`,h=this.audioFileManager.getRawSampleDetails(),$=this.audioBufferManager.calculateChunkTimestamps(h.totalRawSamples);try{const _={fileName:c,timestamp:{st:$.start,et:$.end},status:"pending",audioFrames:e},j=this.audioFileManager.updateAudioInfo(_);this.audioFileManager.incrementInsertedSamples(this.audioBufferManager.getCurrentSampleLength(),this.audioBufferManager.getCurrentFrameLength()),this.audioBufferManager.resetBufferState(),console.log("Uploading audio chunk:",c," at index:",j-1),await this.audioFileManager.uploadAudio({audioFrames:e,fileName:c,chunkIndex:j-1})}catch(_){console.error("Error uploading audio chunk:",_)}}startVad(){this.micVad&&typeof this.micVad.start=="function"&&this.micVad.start(),this.recording_started=!0}pauseVad(){this.micVad&&typeof this.micVad.pause=="function"&&this.micVad.pause(),this.recording_started=!1}destroyVad(){this.micVad&&typeof this.micVad.destroy=="function"&&this.micVad.destroy(),this.stopMicStream(),this.recording_started=!1}resetVadWebInstance(){this.micVad&&typeof this.micVad.destroy=="function"&&this.micVad.destroy(),this.stopMicStream(),this.vad_past=[],this.last_clip_index=0,this.clip_points=[0],this.sil_duration_acc=0,this.noSpeechStartTime=null,this.lastWarningTime=null,this.recording_started=!1,this.is_vad_loading=!0}configureVadConstants({pref_length:e,desp_length:s,max_length:c,sr:h,frame_size:$,pre_speech_pad_frames:_,short_thsld:j,long_thsld:nt}){this.pref_length_samples=e*h,this.desp_length_samples=s*h,this.max_length_samples=c*h,this.shor_thsld=j*h,this.long_thsld=nt*h,this.frame_size=$,this.speech_pad_frames=_}}class ChunkedRecorder{constructor(e){this._isPaused=!1,this.eventEmitter=e,this.bufferManager=new AudioBufferManager(SAMPLING_RATE,AUDIO_BUFFER_SIZE_IN_S),this.fileManager=new AudioFileManager,this.vadClient=new VadWebClient(PREF_CHUNK_LENGTH,DESP_CHUNK_LENGTH,MAX_CHUNK_LENGTH,SAMPLING_RATE,this.fileManager,this.bufferManager),this.eventEmitter&&(this.fileManager.setUploadProgressCallback((s,c)=>{}),this.vadClient.setCallbacks(s=>{},s=>{},s=>{}))}initialize(e,s){if(!e.upload_url)throw new Error("Upload URL is required for chunked recording");const c={};console.log(s,"initialize - WIDGET"),s!=null&&s.accessToken&&(c.Authorization=`Bearer ${s.accessToken}`),this.fileManager.setSessionInfo({sessionId:e.session_id,uploadUrl:e.upload_url,uploadHeaders:c}),console.log("ChunkedRecorder initialized with session:",e.session_id)}async start(e){console.log("Starting ChunkedRecorder with deviceId:",e),await this.vadClient.initVad(e);const s=this.vadClient.getMicVad();if((this.vadClient.isVadLoading()||!s||Object.keys(s).length===0)&&await this.vadClient.reinitializeVad(e))throw new Error("VAD instance is not initialized.");this.vadClient.startVad()}pause(){this._isPaused||(this.vadClient.pauseVad(),this._isPaused=!0)}resume(){this._isPaused&&(this.vadClient.startVad(),this._isPaused=!1)}isPaused(){return this._isPaused}async stop(){this._isPaused=!1,this.vadClient.resetVadWebInstance(),await this.fileManager.waitForAllUploads();const e=await this.fileManager.retryFailedUploads(),s=this.fileManager.getTotalAudioChunks().length;return{failedUploads:e,totalFiles:s}}reset(){this._isPaused=!1,this.vadClient.resetVadWebInstance(),this.fileManager.resetFileManagerInstance(),this.bufferManager.resetBufferState()}}class SingleRecorder{constructor(e){this.mediaRecorder=null,this.audioChunks=[],this.uploadUrl="",this.uploadHeaders={},this.stream=null,this._isPaused=!1,this.eventEmitter=e}initialize(e,s){if(!e.upload_url)throw new Error("Upload URL is required for single recording");this.uploadUrl=e.upload_url,s!=null&&s.accessToken&&(this.uploadHeaders.Authorization=`Bearer ${s.accessToken}`)}async start(e){this.audioChunks=[];let s;try{s=await navigator.mediaDevices.getUserMedia({audio:e?{deviceId:{exact:e}}:!0})}catch(c){if((c==null?void 0:c.name)==="OverconstrainedError"||(c==null?void 0:c.name)==="NotFoundError")s=await navigator.mediaDevices.getUserMedia({audio:!0});else throw c}this.stream=s,this.mediaRecorder=new MediaRecorder(s),this.mediaRecorder.ondataavailable=c=>{c.data.size>0&&this.audioChunks.push(c.data)},this.mediaRecorder.start()}pause(){this.mediaRecorder&&this.mediaRecorder.state==="recording"&&(this.mediaRecorder.pause(),this._isPaused=!0)}resume(){this.mediaRecorder&&this.mediaRecorder.state==="paused"&&(this.mediaRecorder.resume(),this._isPaused=!1)}isPaused(){return this._isPaused}async stop(){return this._isPaused=!1,new Promise(e=>{if(!this.mediaRecorder){e({failedUploads:[],totalFiles:0});return}this.mediaRecorder.onstop=async()=>{var $;const s=new Blob(this.audioChunks,{type:"audio/webm"}),c=`recording_${Date.now()}.webm`;(await uploadFileWithFormData(this.uploadUrl,c,s,this.uploadHeaders)).success?e({failedUploads:[],totalFiles:1}):e({failedUploads:[c],totalFiles:1}),($=this.stream)==null||$.getTracks().forEach(_=>_.stop()),this.stream=null,this.mediaRecorder=null},this.mediaRecorder.stop()})}reset(){var e;this._isPaused=!1,this.mediaRecorder&&this.mediaRecorder.state!=="inactive"&&this.mediaRecorder.stop(),(e=this.stream)==null||e.getTracks().forEach(s=>s.stop()),this.stream=null,this.mediaRecorder=null,this.audioChunks=[]}}class EventEmitter{constructor(){this.listeners=new Map}on(e,s){var c;this.listeners.has(e)||this.listeners.set(e,new Set),(c=this.listeners.get(e))==null||c.add(s)}off(e,s){var c;(c=this.listeners.get(e))==null||c.delete(s)}emit(e){var s;(s=this.listeners.get(e.type))==null||s.forEach(c=>{try{c(e)}catch(h){console.error("Error in event listener:",h)}})}}class ScribeClient{static getInstance(e){return ScribeClient.instance||(ScribeClient.instance=new ScribeClient(e)),ScribeClient.instance}static resetInstance(){ScribeClient.instance&&(ScribeClient.instance.reset().catch(()=>{}),ScribeClient.instance=null)}constructor(e){this.discoveryDocument=null,this.currentSession=null,this.isInitialized=!1,this.recorder=null,this.validateConfig(e),this.config={debug:!1,autoDiscovery:!0,...e},this.httpClient=new HttpClient(this.config.apiKey,this.config.accessToken,this.config.debug),this.discoveryAPI=new DiscoveryAPI(this.httpClient),this.sessionAPI=new SessionAPI(this.httpClient,this.config.baseUrl||""),this.eventEmitter=new EventEmitter}async init(){if(this.isInitialized){this.config.debug&&console.log("[ScribeSDK] Already initialized");return}if(!this.config.baseUrl)throw new ValidationError("baseUrl is required for initialization");if(this.config.autoDiscovery)try{this.discoveryDocument=await this.discoveryAPI.getDiscovery(this.config.baseUrl),this.discoveryDocument.endpoints.base_url&&this.sessionAPI.setBaseUrl(this.discoveryDocument.endpoints.base_url),this.emitEvent({type:"discovery:complete",data:this.discoveryDocument}),this.config.debug&&console.log("[ScribeSDK] Discovery complete:",this.discoveryDocument)}catch(e){throw this.emitEvent({type:"error",error:e instanceof Error?e:new Error("Discovery failed")}),e}else this.sessionAPI.setBaseUrl(this.config.baseUrl);this.isInitialized=!0}async startRecording(e){if(this.isInitialized||await this.init(),(await navigator.permissions.query({name:"microphone"})).state!=="granted")throw new ValidationError("Microphone access is required to start recording.");try{const c={templates:e.templates,model:e.model,language_hint:e.languageHint,transcript_language:e.transcriptLanguage,upload_type:e.uploadType||UploadType.CHUNKED,communication_protocol:e.communicationProtocol||"http",additional_data:e.additionalData};return this.currentSession=await this.sessionAPI.createSession(c),this.emitEvent({type:"session:created",data:this.currentSession}),this.config.debug&&console.log("[ScribeSDK] Session created:",this.currentSession),e.uploadType===UploadType.SINGLE?this.recorder=new SingleRecorder(this.eventEmitter):this.recorder=new ChunkedRecorder(this.eventEmitter),this.recorder.initialize(this.currentSession,{accessToken:this.config.accessToken}),await this.recorder.start(e.deviceId),this.currentSession}catch(c){throw this.emitEvent({type:"error",error:c instanceof Error?c:new Error("Failed to start recording")}),c}}pauseRecording(){if(!this.recorder)throw new ValidationError("No active recording to pause");this.recorder.pause(),this.emitEvent({type:"recording:paused"}),this.config.debug&&console.log("[ScribeSDK] Recording paused")}resumeRecording(){if(!this.recorder)throw new ValidationError("No active recording to resume");this.recorder.resume(),this.emitEvent({type:"recording:resumed"}),this.config.debug&&console.log("[ScribeSDK] Recording resumed")}isRecordingPaused(){var e;return((e=this.recorder)==null?void 0:e.isPaused())??!1}async endRecording(){if(!this.currentSession)throw new ValidationError("No active session to end");try{let e=0;if(this.recorder){const{failedUploads:c,totalFiles:h}=await this.recorder.stop();if(c.length>0)throw console.warn("Some audio files failed to upload:",c),new ScribeError(`Failed to upload audio recordings: ${c.join(", ")}`,"upload_failed");e=h||0,this.recorder=null}const s=await this.sessionAPI.endSession(this.currentSession.session_id,e);return this.emitEvent({type:"session:ended",data:s}),this.config.debug&&console.log("[ScribeSDK] Session ended:",s),s}catch(e){throw this.emitEvent({type:"error",error:e instanceof Error?e:new Error("Failed to end recording")}),e}}async reset(){this.recorder&&(await this.recorder.stop().catch(()=>{}),this.recorder=null),this.currentSession=null,this.discoveryAPI.clearCache(),this.discoveryDocument=null,this.isInitialized=!1}emitEvent(e){this.eventEmitter.emit(e)}async getOutputStatus(e){var c;const s=e||((c=this.currentSession)==null?void 0:c.session_id);if(!s)throw new ValidationError("No session ID provided and no active session");try{const h=await this.sessionAPI.getSessionStatus(s);return this.emitEvent({type:"session:status_update",data:h}),this.config.debug&&console.log("[ScribeSDK] Session status:",h),h}catch(h){throw this.emitEvent({type:"error",error:h instanceof Error?h:new Error("Failed to get output status")}),h}}async pollForCompletion(e,s={}){var h;const c=e||((h=this.currentSession)==null?void 0:h.session_id);if(!c)throw new ValidationError("No session ID provided and no active session");return this.sessionAPI.pollSessionStatus(c,{...s,onProgress:$=>{this.emitEvent({type:"session:status_update",data:$}),s.onProgress&&s.onProgress($)}})}getCurrentSession(){return this.currentSession}getDiscoveryDocument(){return this.discoveryDocument}on(e,s){this.eventEmitter.on(e,s)}off(e,s){this.eventEmitter.off(e,s)}clearSession(){this.currentSession=null}validateConfig(e){if(!e.baseUrl)throw new ValidationError("baseUrl is required for initialization")}}ScribeClient.instance=null;function useScribeSession(i){const[e,s]=reactExports.useState("idle"),[c,h]=reactExports.useState(0),[$,_]=reactExports.useState(null),[j,nt]=reactExports.useState(""),et=reactExports.useRef(null),b=reactExports.useRef(null),a=reactExports.useRef(0),o=reactExports.useRef(0),d=reactExports.useCallback((...ft)=>{i.debug&&console.log("[EkaScribe]",...ft)},[i.debug]);reactExports.useEffect(()=>{if(!i.baseUrl){d("Skipping SDK init - no baseUrl provided");return}return(async()=>{try{et.current=ScribeClient.getInstance({accessToken:i.accessToken,baseUrl:i.baseUrl,debug:i.debug}),await et.current.init(),d("SDK initialized")}catch(dt){d("Failed to initialize SDK",dt)}})(),()=>{b.current&&clearInterval(b.current)}},[i.accessToken,i.baseUrl,i.debug,d]);const g=reactExports.useCallback(()=>{b.current=window.setInterval(()=>{const ft=Math.floor((Date.now()-a.current)/1e3);h(ft)},1e3)},[]),rt=reactExports.useCallback(()=>{b.current&&(clearInterval(b.current),b.current=null)},[]),st=async()=>{try{return(await navigator.permissions.query({name:"microphone"})).state}catch{return"prompt"}},tt=async()=>{try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(dt=>dt.stop()),!0}catch(ft){return d("Microphone permission denied",ft),!1}},ot=reactExports.useCallback(ft=>{nt(ft),s("error")},[]),it=reactExports.useCallback(async()=>{const ft=await st();if(ft==="denied"){ot("Microphone access is blocked. Please enable it in your browser settings.");return}if(ft==="prompt"&&(s("permission"),!await tt())){ot("Microphone access is required to record.");return}if(!et.current){ot("SDK not initialized. Please try again.");return}try{s("recording"),await et.current.startRecording({templates:["eka_emr_template"],languageHint:i.languageHint}),a.current=Date.now(),o.current=0,h(0),g(),d("Recording started")}catch(dt){d("Failed to start recording",dt),ot("Failed to start recording. Please try again.")}},[i.templates,i.languageHint,d,ot,g]),at=reactExports.useCallback(()=>{et.current&&(et.current.pauseRecording(),s("paused"),o.current=Date.now(),rt(),d("Recording paused"))},[d,rt]),ut=reactExports.useCallback(()=>{et.current&&(et.current.resumeRecording(),s("recording"),o.current&&(a.current+=Date.now()-o.current,o.current=0),g(),d("Recording resumed"))},[d,g]),lt=reactExports.useCallback(async()=>{if(et.current)try{rt(),s("processing"),d("Stopping recording...");const ft=await et.current.endRecording();d("Recording ended",ft),d("Polling for completion...");const dt=await et.current.pollForCompletion(void 0,{maxAttempts:60,intervalMs:2e3,onProgress:yt=>{d("Status update:",yt.status)}});_(dt),d("Final result:",dt),s("results"),i.onResult&&i.onResult(dt)}catch(ft){d("Failed to stop recording",ft),ot("Failed to process recording. Please try again."),i.onError&&ft instanceof Error&&i.onError(ft)}},[i,d,ot,rt]),ct=reactExports.useCallback(()=>{_(null),nt(""),h(0),s("idle")},[]);return{state:e,elapsedTime:c,result:$,errorMessage:j,startRecording:it,pauseRecording:at,resumeRecording:ut,stopRecording:lt,reset:ct}}function App({config:i,onClose:e}){const[s,c]=reactExports.useState(!1),[h,$]=reactExports.useState(i.baseUrl?{accessToken:i.accessToken,baseUrl:i.baseUrl}:null),_=reactExports.useMemo(()=>h?{...i,accessToken:h.accessToken,baseUrl:h.baseUrl}:i,[i,h]),j=!h,{state:nt,elapsedTime:et,result:b,errorMessage:a,startRecording:o,pauseRecording:d,resumeRecording:g,stopRecording:rt,reset:st}=useScribeSession(_);if(s)return null;const tt=(it,at)=>{$({accessToken:it,baseUrl:at})},ot=()=>{if(j)return jsxRuntimeExports.jsx(ConfigState,{onSubmit:tt,initialAccessToken:i.accessToken||"",initialBaseUrl:i.baseUrl||""});switch(nt){case"idle":return jsxRuntimeExports.jsx(IdleState,{onStartRecording:o});case"permission":return jsxRuntimeExports.jsx(PermissionState,{onRequestPermission:o});case"recording":case"paused":return jsxRuntimeExports.jsx(RecordingState,{elapsedTime:et,isPaused:nt==="paused",onPause:d,onResume:g,onStop:rt});case"processing":return jsxRuntimeExports.jsx(ProcessingState,{});case"results":return b?jsxRuntimeExports.jsx(ResultsState,{result:b,onNewRecording:st}):null;case"error":return jsxRuntimeExports.jsx(ErrorState,{message:a,onRetry:st});default:return jsxRuntimeExports.jsx(IdleState,{onStartRecording:o})}};return jsxRuntimeExports.jsx(FloatingPanel,{position:_.position,onClose:e,onMinimize:()=>c(!0),children:ot()})}const widgetStyles=":host{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif}*{box-sizing:border-box;margin:0;padding:0}.scribe-panel{position:fixed;bottom:20px;right:20px;background:#fff;border-radius:16px;box-shadow:0 4px 24px #0000001f,0 0 0 1px #0000000d;z-index:2147483647;overflow:hidden;min-width:320px}.panel-header{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:#fafafa;border-bottom:1px solid #eee;cursor:grab}.panel-header:active{cursor:grabbing}.drag-handle{display:flex;gap:2px;flex-wrap:wrap;width:16px;opacity:.4}.drag-handle span{width:4px;height:4px;background:#666;border-radius:50%}.header-actions{display:flex;gap:8px}.header-btn{background:none;border:none;cursor:pointer;padding:4px;color:#666;display:flex;align-items:center;justify-content:center;width:24px;height:24px}.header-btn:hover{color:#333}.header-btn svg{width:16px;height:16px}.panel-content{padding:20px 24px}.idle-state{display:flex;align-items:center;gap:24px}.logo{display:flex;align-items:center;gap:8px}.logo-icon{width:32px;height:32px}.logo-icon svg{width:100%;height:100%}.logo-text{font-size:20px;font-weight:600;color:#2563eb}.start-btn{display:flex;align-items:center;gap:8px;background:#2563eb;color:#fff;border:none;padding:12px 24px;border-radius:24px;font-size:16px;font-weight:500;cursor:pointer;transition:background .2s}.start-btn:hover{background:#1d4ed8}.start-btn:disabled{background:#93c5fd;cursor:not-allowed}.mic-icon{width:20px;height:20px}.mic-icon svg{width:100%;height:100%}.recording-state{display:flex;align-items:center;gap:16px}.recording-indicator{display:flex;align-items:center;gap:12px;color:#666}.recording-icon{width:24px;height:24px;color:#666}.recording-icon svg{width:100%;height:100%}.recording-icon.active{color:#ef4444;animation:pulse 1.5s infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.timer{font-size:20px;font-weight:500;font-variant-numeric:tabular-nums;color:#374151}.recording-actions{display:flex;gap:8px;margin-left:auto}.resume-btn{background:#fff;color:#2563eb;border:2px solid #2563eb;padding:10px 20px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:all .2s}.resume-btn:hover{background:#eff6ff}.pause-btn{background:#fff;color:#f59e0b;border:2px solid #f59e0b;padding:10px 20px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:all .2s}.pause-btn:hover{background:#fffbeb}.stop-btn{background:#ef4444;color:#fff;border:none;padding:10px 16px;border-radius:8px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .2s}.stop-btn:hover{background:#dc2626}.stop-icon{width:16px;height:16px;background:#fff;border-radius:2px}.processing-state{display:flex;flex-direction:column;align-items:center;gap:16px;padding:20px}.spinner{width:40px;height:40px;border:3px solid #e5e7eb;border-top-color:#2563eb;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.processing-text{color:#6b7280;font-size:14px}.results-state{display:flex;flex-direction:column;gap:16px;max-height:400px}.results-header{display:flex;align-items:center;justify-content:space-between}.results-title{font-size:16px;font-weight:600;color:#111827}.new-recording-btn{background:#2563eb;color:#fff;border:none;padding:8px 16px;border-radius:6px;font-size:13px;cursor:pointer;transition:background .2s}.new-recording-btn:hover{background:#1d4ed8}.results-content{overflow-y:auto;max-height:300px}.transcript-section{margin-bottom:16px}.section-title{font-size:13px;font-weight:600;color:#6b7280;text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px}.transcript-text{font-size:14px;line-height:1.6;color:#374151;background:#f9fafb;padding:12px;border-radius:8px;white-space:pre-wrap}.error-state{display:flex;flex-direction:column;align-items:center;gap:12px;padding:20px;text-align:center}.error-icon{width:48px;height:48px;color:#ef4444}.error-icon svg{width:100%;height:100%}.error-message{color:#ef4444;font-size:14px}.retry-btn{background:#ef4444;color:#fff;border:none;padding:10px 20px;border-radius:8px;font-size:14px;cursor:pointer;transition:background .2s}.retry-btn:hover{background:#dc2626}.permission-state{display:flex;flex-direction:column;align-items:center;gap:16px;padding:20px;text-align:center}.permission-icon{width:48px;height:48px;color:#2563eb}.permission-icon svg{width:100%;height:100%}.permission-text{color:#374151;font-size:14px;line-height:1.5}.permission-btn{background:#2563eb;color:#fff;border:none;padding:12px 24px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:background .2s}.permission-btn:hover{background:#1d4ed8}.config-state{display:flex;flex-direction:column;gap:20px}.config-state .logo{justify-content:center}.config-form{display:flex;flex-direction:column;gap:12px}.config-form .form-group{display:flex;flex-direction:column;gap:4px}.config-form label{font-size:13px;font-weight:500;color:#374151}.config-form input{padding:10px 12px;border:1px solid #d1d5db;border-radius:8px;font-size:14px;color:#111827;background:#fff;transition:border-color .2s,box-shadow .2s}.config-form input:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px #2563eb1a}.config-form input::placeholder{color:#9ca3af}.config-error{color:#ef4444;font-size:13px;margin:0}.config-submit-btn{background:#2563eb;color:#fff;border:none;padding:12px 24px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;transition:background .2s;margin-top:4px}.config-submit-btn:hover{background:#1d4ed8}";class ScribeWidget{constructor(e){Qr(this,"container");Qr(this,"shadowRoot");Qr(this,"root",null);Qr(this,"config");Qr(this,"visible",!0);this.config={templates:["soap"],languageHint:["en"],position:{bottom:20,right:20},...e},this.container=document.createElement("div"),this.container.id="eka-scribe-widget",this.shadowRoot=this.container.attachShadow({mode:"closed"});const s=document.createElement("style");s.textContent=widgetStyles,this.shadowRoot.appendChild(s);const c=document.createElement("div");c.id="eka-scribe-root",this.shadowRoot.appendChild(c),this.root=createRoot(c)}render(){!this.root||!this.visible||this.root.render(jsxRuntimeExports.jsx(App,{config:this.config,onClose:()=>this.hide()}))}mount(e){const s=typeof e=="string"?document.querySelector(e):e||document.body;s&&(s.appendChild(this.container),this.render())}unmount(){this.root&&(this.root.unmount(),this.root=null),this.container.remove()}show(){this.visible=!0,this.container.style.display="block",this.render()}hide(){this.visible=!1,this.container.style.display="none"}isVisible(){return this.visible}}let widgetInstance=null;function init(i={}){return widgetInstance&&widgetInstance.unmount(),console.log(i,"config - WIDGET"),widgetInstance=new ScribeWidget(i),widgetInstance.mount(),widgetInstance}function getInstance(){return widgetInstance}const EkaScribe={init,getInstance,Widget:ScribeWidget};if(typeof window<"u"&&typeof document<"u"){const i=()=>{const e=document.currentScript||document.querySelector('script[src*="scribe-widget"]');e!=null&&e.hasAttribute("data-no-auto-init")||(console.log(widgetInstance,"widget instance"),widgetInstance||init({baseUrl:""}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded - WIDGET",i):(console.log("load document - WIDGET"),i())}exports.ScribeWidget=ScribeWidget,exports.default=EkaScribe,exports.getInstance=getInstance,exports.init=init,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scribe-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Floating panel widget for medical transcription using eka.scribe",
|
|
5
5
|
"main": "dist/scribe-widget.umd.js",
|
|
6
6
|
"module": "dist/scribe-widget.es.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"prepublishOnly": "npm run clean && npm run build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"med-scribe-alliance-ts-sdk": "1.0.
|
|
17
|
+
"med-scribe-alliance-ts-sdk": "1.0.4",
|
|
18
18
|
"react": "^18.2.0",
|
|
19
19
|
"react-dom": "^18.2.0"
|
|
20
20
|
},
|
|
@@ -130,7 +130,7 @@ export function useScribeSession(config: ScribeWidgetConfig): UseScribeSessionRe
|
|
|
130
130
|
setState('recording');
|
|
131
131
|
|
|
132
132
|
await clientRef.current.startRecording({
|
|
133
|
-
templates:
|
|
133
|
+
templates: ['eka_emr_template'],
|
|
134
134
|
languageHint: config.languageHint,
|
|
135
135
|
});
|
|
136
136
|
|