diff --git "a/assets/index-DXRKN6Zo.js" "b/assets/index-DXRKN6Zo.js" new file mode 100644--- /dev/null +++ "b/assets/index-DXRKN6Zo.js" @@ -0,0 +1,2775 @@ +import{G as Color,a4 as Vector2,V as Vector3,J as Euler,b4 as Object3D,bi as AnimationClip,bo as QuaternionKeyframeTrack,bn as NumberKeyframeTrack,al as Quaternion,M as MathUtils,Q as Matrix4,c3 as Matrix3,bh as Skeleton,E as BufferGeometry,ay as BufferAttribute,bg as Group,aa as MeshBasicMaterial,a1 as DoubleSide,a9 as Mesh,b9 as LineBasicMaterial,bc as LineSegments,c4 as ImageLoader,b8 as Material,H as BackSide,c5 as AxesHelper,S as ShaderMaterial,c6 as TangentSpaceNormalMap,U as UniformsUtils,a3 as UniformsLib,c7 as DynamicDrawUsage,bd as Line,bb as SkinnedMesh,c8 as GLBufferAttribute,ag as REVISION,f as getAugmentedNamespace}from"./index-0KofmgRN.js";/*! + * @pixiv/three-vrm-animation v3.3.2 + * The implementation of VRM Animation + * + * Copyright (c) 2019-2024 pixiv Inc. + * @pixiv/three-vrm-animation is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + */var __async$1=(f,r,c)=>new Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())}),VRMExpressionPresetName$1={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};new Color;new Vector2;new Vector3;new Vector3;var VRMHumanBoneParentMap$1={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function quatInvertCompat$1(f){return f.invert?f.invert():f.inverse(),f}new Vector3;new Vector3;new Vector3;new Vector3;new Vector3;new Vector3(0,1,0);var _position$1=new Vector3,_scale$1=new Vector3;function getWorldQuaternionLite$1(f,r){return f.matrixWorld.decompose(_position$1,r,_scale$1),r}function calcAzimuthAltitude$1(f){return[Math.atan2(-f.z,f.x),Math.atan2(f.y,Math.sqrt(f.x*f.x+f.z*f.z))]}function sanitizeAngle$1(f){const r=Math.round(f/2/Math.PI);return f-2*Math.PI*r}var VEC3_POSITIVE_Z$1=new Vector3(0,0,1),_v3A5$1=new Vector3,_v3B3$1=new Vector3,_v3C$1=new Vector3,_quatA5$1=new Quaternion,_quatB2$1=new Quaternion,_quatC$1=new Quaternion,_quatD$1=new Quaternion,_eulerA$1=new Euler,_VRMLookAt$1=class fn{constructor(r,c){this.offsetFromHeadBone=new Vector3,this.autoUpdate=!0,this.faceFront=new Vector3(0,0,1),this.humanoid=r,this.applier=c,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new Quaternion)}get yaw(){return this._yaw}set yaw(r){this._yaw=r,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(r){this._pitch=r,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Euler)}getEuler(r){return r.set(MathUtils.DEG2RAD*this._pitch,MathUtils.DEG2RAD*this._yaw,0,"YXZ")}copy(r){if(this.humanoid!==r.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(r.offsetFromHeadBone),this.applier=r.applier,this.autoUpdate=r.autoUpdate,this.target=r.target,this.faceFront.copy(r.faceFront),this}clone(){return new fn(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(r){const c=this.humanoid.getRawBoneNode("head");return r.copy(this.offsetFromHeadBone).applyMatrix4(c.matrixWorld)}getLookAtWorldQuaternion(r){const c=this.humanoid.getRawBoneNode("head");return getWorldQuaternionLite$1(c,r)}getFaceFrontQuaternion(r){if(this.faceFront.distanceToSquared(VEC3_POSITIVE_Z$1)<.01)return r.copy(this._restHeadWorldQuaternion).invert();const[c,d]=calcAzimuthAltitude$1(this.faceFront);return _eulerA$1.set(0,.5*Math.PI+c,d,"YZX"),r.setFromEuler(_eulerA$1).premultiply(_quatD$1.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(r){return this.getLookAtWorldQuaternion(_quatB2$1),this.getFaceFrontQuaternion(_quatC$1),r.copy(VEC3_POSITIVE_Z$1).applyQuaternion(_quatB2$1).applyQuaternion(_quatC$1).applyEuler(this.getEuler(_eulerA$1))}lookAt(r){const c=_quatA5$1.copy(this._restHeadWorldQuaternion).multiply(quatInvertCompat$1(this.getLookAtWorldQuaternion(_quatB2$1))),d=this.getLookAtWorldPosition(_v3B3$1),l=_v3C$1.copy(r).sub(d).applyQuaternion(c).normalize(),[m,s]=calcAzimuthAltitude$1(this.faceFront),[h,p]=calcAzimuthAltitude$1(l),a=sanitizeAngle$1(h-m),o=sanitizeAngle$1(s-p);this._yaw=MathUtils.RAD2DEG*a,this._pitch=MathUtils.RAD2DEG*o,this._needsUpdate=!0}update(r){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(_v3A5$1)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};_VRMLookAt$1.EULER_ORDER="YXZ";var VRMLookAt$1=_VRMLookAt$1;new Vector3(0,0,1);new Euler(0,0,0,"YXZ");var RAD2DEG=180/Math.PI,_eulerA3=new Euler,VRMLookAtQuaternionProxy=class extends Object3D{constructor(f){super(),this.vrmLookAt=f,this.type="VRMLookAtQuaternionProxy";const r=this.rotation._onChangeCallback;this.rotation._onChange(()=>{r(),this._applyToLookAt()});const c=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{c(),this._applyToLookAt()})}_applyToLookAt(){_eulerA3.setFromQuaternion(this.quaternion,VRMLookAt$1.EULER_ORDER),this.vrmLookAt.yaw=RAD2DEG*_eulerA3.y,this.vrmLookAt.pitch=RAD2DEG*_eulerA3.x}};function createVRMAnimationHumanoidTracks(f,r,c){var d,l;const m=new Map,s=new Map;for(const[h,p]of f.humanoidTracks.rotation.entries()){const a=(d=r.getNormalizedBoneNode(h))==null?void 0:d.name;if(a!=null){const o=new QuaternionKeyframeTrack(`${a}.quaternion`,p.times,p.values.map((t,e)=>c==="0"&&e%2===0?-t:t));s.set(h,o)}}for(const[h,p]of f.humanoidTracks.translation.entries()){const a=(l=r.getNormalizedBoneNode(h))==null?void 0:l.name;if(a!=null){const o=f.restHipsPosition.y,e=r.normalizedRestPose.hips.position[1]/o,n=p.clone();n.values=n.values.map((i,u)=>(c==="0"&&u%3!==1?-i:i)*e),n.name=`${a}.position`,m.set(h,n)}}return{translation:m,rotation:s}}function createVRMAnimationExpressionTracks(f,r){const c=new Map,d=new Map;for(const[l,m]of f.expressionTracks.preset.entries()){const s=r.getExpressionTrackName(l);if(s!=null){const h=m.clone();h.name=s,c.set(l,h)}}for(const[l,m]of f.expressionTracks.custom.entries()){const s=r.getExpressionTrackName(l);if(s!=null){const h=m.clone();h.name=s,d.set(l,h)}}return{preset:c,custom:d}}function createVRMAnimationLookAtTrack(f,r){if(f.lookAtTrack==null)return null;const c=f.lookAtTrack.clone();return c.name=r,c}function createVRMAnimationClip(f,r){const c=[],d=createVRMAnimationHumanoidTracks(f,r.humanoid,r.meta.metaVersion);if(c.push(...d.translation.values()),c.push(...d.rotation.values()),r.expressionManager!=null){const l=createVRMAnimationExpressionTracks(f,r.expressionManager);c.push(...l.preset.values()),c.push(...l.custom.values())}if(r.lookAt!=null){let l=r.scene.children.find(s=>s instanceof VRMLookAtQuaternionProxy);l==null?(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually"),l=new VRMLookAtQuaternionProxy(r.lookAt),l.name="VRMLookAtQuaternionProxy",r.scene.add(l)):l.name==null&&(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually"),l.name="VRMLookAtQuaternionProxy");const m=createVRMAnimationLookAtTrack(f,`${l.name}.quaternion`);m!=null&&c.push(m)}return new AnimationClip("Clip",f.duration,c)}var VRMAnimation=class{constructor(){this.duration=0,this.restHipsPosition=new Vector3,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function arrayChunk(f,r){const c=f.length,d=[];let l=[],m=0;for(let s=0;s{const b=l.animations[g],y=this._parseAnimation(u,b,p,a);return y.restHipsPosition=e,y});f.userData.vrmAnimations=i})}_createNodeMap(f){var r,c,d,l,m;const s=new Map,h=new Map,p=(r=f.humanoid)==null?void 0:r.humanBones;p&&Object.entries(p).forEach(([e,n])=>{const i=n==null?void 0:n.node;i!=null&&s.set(i,e)});const a=(c=f.expressions)==null?void 0:c.preset;a&&Object.entries(a).forEach(([e,n])=>{const i=n==null?void 0:n.node;i!=null&&h.set(i,e)});const o=(d=f.expressions)==null?void 0:d.custom;o&&Object.entries(o).forEach(([e,n])=>{const{node:i}=n;h.set(i,e)});const t=(m=(l=f.lookAt)==null?void 0:l.node)!=null?m:null;return{humanoidIndexToName:s,expressionsIndexToName:h,lookAtIndex:t}}_createBoneWorldMatrixMap(f,r){return __async$1(this,null,function*(){var c,d;f.scene.updateWorldMatrix(!1,!0);const l=yield f.parser.getDependencies("node"),m=new Map;if(r.humanoid==null)return m;for(const[s,h]of Object.entries(r.humanoid.humanBones)){const p=h==null?void 0:h.node;if(p!=null){const a=l[p];m.set(s,a.matrixWorld),s==="hips"&&m.set("hipsParent",(d=(c=a.parent)==null?void 0:c.matrixWorld)!=null?d:MAT4_IDENTITY)}}return m})}_parseAnimation(f,r,c,d){const l=f.tracks,m=r.channels,s=new VRMAnimation;return s.duration=f.duration,m.forEach((h,p)=>{const{node:a,path:o}=h.target,t=l[p];if(a==null)return;const e=c.humanoidIndexToName.get(a);if(e!=null){let i=VRMHumanBoneParentMap$1[e];for(;i!=null&&d.get(i)==null;)i=VRMHumanBoneParentMap$1[i];if(i??(i="hipsParent"),o==="translation")if(e!=="hips")console.warn(`The loading animation contains a translation track for ${e}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{const u=d.get("hipsParent"),g=arrayChunk(t.values,3).flatMap(y=>_v3A6$1.fromArray(y).applyMatrix4(u).toArray()),b=t.clone();b.values=new Float32Array(g),s.humanoidTracks.translation.set(e,b)}else if(o==="rotation"){const u=d.get(e),g=d.get(i);u.decompose(_v3A6$1,_quatA7$1,_v3A6$1),_quatA7$1.invert(),g.decompose(_v3A6$1,_quatB4$1,_v3A6$1);const b=arrayChunk(t.values,4).flatMap(_=>_quatC2$1.fromArray(_).premultiply(_quatB4$1).multiply(_quatA7$1).toArray()),y=t.clone();y.values=new Float32Array(b),s.humanoidTracks.rotation.set(e,y)}else throw new Error(`Invalid path "${o}"`);return}const n=c.expressionsIndexToName.get(a);if(n!=null){if(o==="translation"){const i=t.times,u=new Float32Array(t.values.length/3);for(let b=0;bnew Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())}),__async2=(f,r,c)=>new Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())}),VRMExpression=class extends Object3D{constructor(f){super(),this.weight=0,this.isBinary=!1,this.overrideBlink="none",this.overrideLookAt="none",this.overrideMouth="none",this._binds=[],this.name=`VRMExpression_${f}`,this.expressionName=f,this.type="VRMExpression",this.visible=!1}get binds(){return this._binds}get overrideBlinkAmount(){return this.overrideBlink==="block"?0.5?1:0:this.weight}addBind(f){this._binds.push(f)}deleteBind(f){const r=this._binds.indexOf(f);r>=0&&this._binds.splice(r,1)}applyWeight(f){var r;let c=this.outputWeight;c*=(r=f==null?void 0:f.multiplier)!=null?r:1,this.isBinary&&c<1&&(c=0),this._binds.forEach(d=>d.applyWeight(c))}clearAppliedWeight(){this._binds.forEach(f=>f.clearAppliedWeight())}};function extractPrimitivesInternal(f,r,c){var d,l;const m=f.parser.json,s=(d=m.nodes)==null?void 0:d[r];if(s==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${r}] of glTF but the node doesn't exist`),null;const h=s.mesh;if(h==null)return null;const p=(l=m.meshes)==null?void 0:l[h];if(p==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${h}] of glTF but the mesh doesn't exist`),null;const a=p.primitives.length,o=[];return c.traverse(t=>{o.length{const m=extractPrimitivesInternal(f,l,d);m!=null&&c.set(l,m)}),c})}var VRMExpressionPresetName={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};function saturate(f){return Math.max(Math.min(f,1),0)}var VRMExpressionManager=class mn{constructor(){this.blinkExpressionNames=["blink","blinkLeft","blinkRight"],this.lookAtExpressionNames=["lookLeft","lookRight","lookUp","lookDown"],this.mouthExpressionNames=["aa","ee","ih","oh","ou"],this._expressions=[],this._expressionMap={}}get expressions(){return this._expressions.concat()}get expressionMap(){return Object.assign({},this._expressionMap)}get presetExpressionMap(){const r={},c=new Set(Object.values(VRMExpressionPresetName));return Object.entries(this._expressionMap).forEach(([d,l])=>{c.has(d)&&(r[d]=l)}),r}get customExpressionMap(){const r={},c=new Set(Object.values(VRMExpressionPresetName));return Object.entries(this._expressionMap).forEach(([d,l])=>{c.has(d)||(r[d]=l)}),r}copy(r){return this._expressions.concat().forEach(d=>{this.unregisterExpression(d)}),r._expressions.forEach(d=>{this.registerExpression(d)}),this.blinkExpressionNames=r.blinkExpressionNames.concat(),this.lookAtExpressionNames=r.lookAtExpressionNames.concat(),this.mouthExpressionNames=r.mouthExpressionNames.concat(),this}clone(){return new mn().copy(this)}getExpression(r){var c;return(c=this._expressionMap[r])!=null?c:null}registerExpression(r){this._expressions.push(r),this._expressionMap[r.expressionName]=r}unregisterExpression(r){const c=this._expressions.indexOf(r);c===-1&&console.warn("VRMExpressionManager: The specified expressions is not registered"),this._expressions.splice(c,1),delete this._expressionMap[r.expressionName]}getValue(r){var c;const d=this.getExpression(r);return(c=d==null?void 0:d.weight)!=null?c:null}setValue(r,c){const d=this.getExpression(r);d&&(d.weight=saturate(c))}resetValues(){this._expressions.forEach(r=>{r.weight=0})}getExpressionTrackName(r){const c=this.getExpression(r);return c?`${c.name}.weight`:null}update(){const r=this._calculateWeightMultipliers();this._expressions.forEach(c=>{c.clearAppliedWeight()}),this._expressions.forEach(c=>{let d=1;const l=c.expressionName;this.blinkExpressionNames.indexOf(l)!==-1&&(d*=r.blink),this.lookAtExpressionNames.indexOf(l)!==-1&&(d*=r.lookAt),this.mouthExpressionNames.indexOf(l)!==-1&&(d*=r.mouth),c.applyWeight({multiplier:d})})}_calculateWeightMultipliers(){let r=1,c=1,d=1;return this._expressions.forEach(l=>{r-=l.overrideBlinkAmount,c-=l.overrideLookAtAmount,d-=l.overrideMouthAmount}),r=Math.max(0,r),c=Math.max(0,c),d=Math.max(0,d),{blink:r,lookAt:c,mouth:d}}},VRMExpressionMaterialColorType={Color:"color",EmissionColor:"emissionColor",ShadeColor:"shadeColor",MatcapColor:"matcapColor",RimColor:"rimColor",OutlineColor:"outlineColor"},v0ExpressionMaterialColorMap={_Color:VRMExpressionMaterialColorType.Color,_EmissionColor:VRMExpressionMaterialColorType.EmissionColor,_ShadeColor:VRMExpressionMaterialColorType.ShadeColor,_RimColor:VRMExpressionMaterialColorType.RimColor,_OutlineColor:VRMExpressionMaterialColorType.OutlineColor},_color=new Color,_VRMExpressionMaterialColorBind=class gn{constructor({material:r,type:c,targetValue:d,targetAlpha:l}){this.material=r,this.type=c,this.targetValue=d,this.targetAlpha=l??1;const m=this._initColorBindState(),s=this._initAlphaBindState();this._state={color:m,alpha:s}}applyWeight(r){const{color:c,alpha:d}=this._state;if(c!=null){const{propertyName:l,deltaValue:m}=c,s=this.material[l];s!=null&&s.add(_color.copy(m).multiplyScalar(r))}if(d!=null){const{propertyName:l,deltaValue:m}=d;this.material[l]!=null&&(this.material[l]+=m*r)}}clearAppliedWeight(){const{color:r,alpha:c}=this._state;if(r!=null){const{propertyName:d,initialValue:l}=r,m=this.material[d];m!=null&&m.copy(l)}if(c!=null){const{propertyName:d,initialValue:l}=c;this.material[d]!=null&&(this.material[d]=l)}}_initColorBindState(){var r,c,d;const{material:l,type:m,targetValue:s}=this,h=this._getPropertyNameMap(),p=(c=(r=h==null?void 0:h[m])==null?void 0:r[0])!=null?c:null;if(p==null)return console.warn(`Tried to add a material color bind to the material ${(d=l.name)!=null?d:"(no name)"}, the type ${m} but the material or the type is not supported.`),null;const o=l[p].clone(),t=new Color(s.r-o.r,s.g-o.g,s.b-o.b);return{propertyName:p,initialValue:o,deltaValue:t}}_initAlphaBindState(){var r,c,d;const{material:l,type:m,targetAlpha:s}=this,h=this._getPropertyNameMap(),p=(c=(r=h==null?void 0:h[m])==null?void 0:r[1])!=null?c:null;if(p==null&&s!==1)return console.warn(`Tried to add a material alpha bind to the material ${(d=l.name)!=null?d:"(no name)"}, the type ${m} but the material or the type does not support alpha.`),null;if(p==null)return null;const a=l[p],o=s-a;return{propertyName:p,initialValue:a,deltaValue:o}}_getPropertyNameMap(){var r,c;return(c=(r=Object.entries(gn._propertyNameMapMap).find(([d])=>this.material[d]===!0))==null?void 0:r[1])!=null?c:null}};_VRMExpressionMaterialColorBind._propertyNameMapMap={isMeshStandardMaterial:{color:["color","opacity"],emissionColor:["emissive",null]},isMeshBasicMaterial:{color:["color","opacity"]},isMToonMaterial:{color:["color","opacity"],emissionColor:["emissive",null],outlineColor:["outlineColorFactor",null],matcapColor:["matcapFactor",null],rimColor:["parametricRimColorFactor",null],shadeColor:["shadeColorFactor",null]}};var VRMExpressionMaterialColorBind=_VRMExpressionMaterialColorBind,VRMExpressionMorphTargetBind=class{constructor({primitives:f,index:r,weight:c}){this.primitives=f,this.index=r,this.weight=c}applyWeight(f){this.primitives.forEach(r=>{var c;((c=r.morphTargetInfluences)==null?void 0:c[this.index])!=null&&(r.morphTargetInfluences[this.index]+=this.weight*f)})}clearAppliedWeight(){this.primitives.forEach(f=>{var r;((r=f.morphTargetInfluences)==null?void 0:r[this.index])!=null&&(f.morphTargetInfluences[this.index]=0)})}},_v2=new Vector2,_VRMExpressionTextureTransformBind=class bn{constructor({material:r,scale:c,offset:d}){var l,m;this.material=r,this.scale=c,this.offset=d;const s=(l=Object.entries(bn._propertyNamesMap).find(([h])=>r[h]===!0))==null?void 0:l[1];s==null?(console.warn(`Tried to add a texture transform bind to the material ${(m=r.name)!=null?m:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],s.forEach(h=>{var p;const a=(p=r[h])==null?void 0:p.clone();if(!a)return null;r[h]=a;const o=a.offset.clone(),t=a.repeat.clone(),e=d.clone().sub(o),n=c.clone().sub(t);this._properties.push({name:h,initialOffset:o,deltaOffset:e,initialScale:t,deltaScale:n})}))}applyWeight(r){this._properties.forEach(c=>{const d=this.material[c.name];d!==void 0&&(d.offset.add(_v2.copy(c.deltaOffset).multiplyScalar(r)),d.repeat.add(_v2.copy(c.deltaScale).multiplyScalar(r)))})}clearAppliedWeight(){this._properties.forEach(r=>{const c=this.material[r.name];c!==void 0&&(c.offset.copy(r.initialOffset),c.repeat.copy(r.initialScale))})}};_VRMExpressionTextureTransformBind._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var VRMExpressionTextureTransformBind=_VRMExpressionTextureTransformBind,POSSIBLE_SPEC_VERSIONS=new Set(["1.0","1.0-beta"]),_VRMExpressionLoaderPlugin=class yn{get name(){return"VRMExpressionLoaderPlugin"}constructor(r){this.parser=r}afterRoot(r){return __async2(this,null,function*(){r.userData.vrmExpressionManager=yield this._import(r)})}_import(r){return __async2(this,null,function*(){const c=yield this._v1Import(r);if(c)return c;const d=yield this._v0Import(r);return d||null})}_v1Import(r){return __async2(this,null,function*(){var c,d;const l=this.parser.json;if(!(((c=l.extensionsUsed)==null?void 0:c.indexOf("VRMC_vrm"))!==-1))return null;const s=(d=l.extensions)==null?void 0:d.VRMC_vrm;if(!s)return null;const h=s.specVersion;if(!POSSIBLE_SPEC_VERSIONS.has(h))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${h}"`),null;const p=s.expressions;if(!p)return null;const a=new Set(Object.values(VRMExpressionPresetName)),o=new Map;p.preset!=null&&Object.entries(p.preset).forEach(([e,n])=>{if(n!=null){if(!a.has(e)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${e}" detected. Ignoring the expression`);return}o.set(e,n)}}),p.custom!=null&&Object.entries(p.custom).forEach(([e,n])=>{if(a.has(e)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${e}". Ignoring the expression`);return}o.set(e,n)});const t=new VRMExpressionManager;return yield Promise.all(Array.from(o.entries()).map(e=>__async2(this,[e],function*([n,i]){var u,g,b,y,_,v,w;const T=new VRMExpression(n);if(r.scene.add(T),T.isBinary=(u=i.isBinary)!=null?u:!1,T.overrideBlink=(g=i.overrideBlink)!=null?g:"none",T.overrideLookAt=(b=i.overrideLookAt)!=null?b:"none",T.overrideMouth=(y=i.overrideMouth)!=null?y:"none",(_=i.morphTargetBinds)==null||_.forEach(A=>__async2(this,null,function*(){var E;if(A.node===void 0||A.index===void 0)return;const x=yield gltfExtractPrimitivesFromNode(r,A.node),P=A.index;if(!x.every(L=>Array.isArray(L.morphTargetInfluences)&&P{const x=E.material;x&&(Array.isArray(x)?A.push(...x):A.push(x))}),(v=i.materialColorBinds)==null||v.forEach(E=>__async2(this,null,function*(){A.filter(P=>{var L;const F=(L=this.parser.associations.get(P))==null?void 0:L.materials;return E.material===F}).forEach(P=>{T.addBind(new VRMExpressionMaterialColorBind({material:P,type:E.type,targetValue:new Color().fromArray(E.targetValue),targetAlpha:E.targetValue[3]}))})})),(w=i.textureTransformBinds)==null||w.forEach(E=>__async2(this,null,function*(){A.filter(P=>{var L;const F=(L=this.parser.associations.get(P))==null?void 0:L.materials;return E.material===F}).forEach(P=>{var L,F;T.addBind(new VRMExpressionTextureTransformBind({material:P,offset:new Vector2().fromArray((L=E.offset)!=null?L:[0,0]),scale:new Vector2().fromArray((F=E.scale)!=null?F:[1,1])}))})}))}t.registerExpression(T)}))),t})}_v0Import(r){return __async2(this,null,function*(){var c;const d=this.parser.json,l=(c=d.extensions)==null?void 0:c.VRM;if(!l)return null;const m=l.blendShapeMaster;if(!m)return null;const s=new VRMExpressionManager,h=m.blendShapeGroups;if(!h)return s;const p=new Set;return yield Promise.all(h.map(a=>__async2(this,null,function*(){var o;const t=a.presetName,e=t!=null&&yn.v0v1PresetNameMap[t]||null,n=e??a.name;if(n==null){console.warn("VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression");return}if(p.has(n)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${t} has duplicated entries. Ignoring the expression`);return}p.add(n);const i=new VRMExpression(n);r.scene.add(i),i.isBinary=(o=a.isBinary)!=null?o:!1,a.binds&&a.binds.forEach(g=>__async2(this,null,function*(){var b;if(g.mesh===void 0||g.index===void 0)return;const y=[];(b=d.nodes)==null||b.forEach((v,w)=>{v.mesh===g.mesh&&y.push(w)});const _=g.index;yield Promise.all(y.map(v=>__async2(this,null,function*(){var w;const T=yield gltfExtractPrimitivesFromNode(r,v);if(!T.every(A=>Array.isArray(A.morphTargetInfluences)&&_{if(g.materialName===void 0||g.propertyName===void 0||g.targetValue===void 0)return;const b=[];r.scene.traverse(_=>{if(_.material){const v=_.material;Array.isArray(v)?b.push(...v.filter(w=>(w.name===g.materialName||w.name===g.materialName+" (Outline)")&&b.indexOf(w)===-1)):v.name===g.materialName&&b.indexOf(v)===-1&&b.push(v)}});const y=g.propertyName;b.forEach(_=>{if(y==="_MainTex_ST"){const w=new Vector2(g.targetValue[0],g.targetValue[1]),T=new Vector2(g.targetValue[2],g.targetValue[3]);T.y=1-T.y-w.y,i.addBind(new VRMExpressionTextureTransformBind({material:_,scale:w,offset:T}));return}const v=v0ExpressionMaterialColorMap[y];if(v){i.addBind(new VRMExpressionMaterialColorBind({material:_,type:v,targetValue:new Color().fromArray(g.targetValue),targetAlpha:g.targetValue[3]}));return}console.warn(y+" is not supported")})}),s.registerExpression(i)}))),s})}};_VRMExpressionLoaderPlugin.v0v1PresetNameMap={a:"aa",e:"ee",i:"ih",o:"oh",u:"ou",blink:"blink",joy:"happy",angry:"angry",sorrow:"sad",fun:"relaxed",lookup:"lookUp",lookdown:"lookDown",lookleft:"lookLeft",lookright:"lookRight",blink_l:"blinkLeft",blink_r:"blinkRight",neutral:"neutral"};var VRMExpressionLoaderPlugin=_VRMExpressionLoaderPlugin,_VRMFirstPerson=class Mt{constructor(r,c){this._firstPersonOnlyLayer=Mt.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=Mt.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=r,this.meshAnnotations=c}copy(r){if(this.humanoid!==r.humanoid)throw new Error("VRMFirstPerson: humanoid must be same in order to copy");return this.meshAnnotations=r.meshAnnotations.map(c=>({meshes:c.meshes.concat(),type:c.type})),this}clone(){return new Mt(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:r=Mt.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:c=Mt.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||(this._firstPersonOnlyLayer=r,this._thirdPersonOnlyLayer=c,this.meshAnnotations.forEach(d=>{d.meshes.forEach(l=>{d.type==="firstPersonOnly"?(l.layers.set(this._firstPersonOnlyLayer),l.traverse(m=>m.layers.set(this._firstPersonOnlyLayer))):d.type==="thirdPersonOnly"?(l.layers.set(this._thirdPersonOnlyLayer),l.traverse(m=>m.layers.set(this._thirdPersonOnlyLayer))):d.type==="auto"&&this._createHeadlessModel(l)})}),this._initializedLayers=!0)}_excludeTriangles(r,c,d,l){let m=0;if(c!=null&&c.length>0)for(let s=0;s0&&l.includes(t[0])||o[1]>0&&l.includes(t[1])||o[2]>0&&l.includes(t[2])||o[3]>0&&l.includes(t[3]))continue;const e=c[p],n=d[p];if(e[0]>0&&l.includes(n[0])||e[1]>0&&l.includes(n[1])||e[2]>0&&l.includes(n[2])||e[3]>0&&l.includes(n[3]))continue;const i=c[a],u=d[a];i[0]>0&&l.includes(u[0])||i[1]>0&&l.includes(u[1])||i[2]>0&&l.includes(u[2])||i[3]>0&&l.includes(u[3])||(r[m++]=h,r[m++]=p,r[m++]=a)}return m}_createErasedMesh(r,c){const d=new SkinnedMesh(r.geometry.clone(),r.material);d.name=`${r.name}(erase)`,d.frustumCulled=r.frustumCulled,d.layers.set(this._firstPersonOnlyLayer);const l=d.geometry,m=l.getAttribute("skinIndex"),s=m instanceof GLBufferAttribute?[]:m.array,h=[];for(let u=0;u{this._isEraseTarget(m)&&d.push(s)}),!d.length){c.layers.enable(this._thirdPersonOnlyLayer),c.layers.enable(this._firstPersonOnlyLayer);return}c.layers.set(this._thirdPersonOnlyLayer);const l=this._createErasedMesh(c,d);r.add(l)}_createHeadlessModel(r){if(r.type==="Group")if(r.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(r))r.traverse(c=>c.layers.set(this._thirdPersonOnlyLayer));else{const c=new Group;c.name=`_headless_${r.name}`,c.layers.set(this._firstPersonOnlyLayer),r.parent.add(c),r.children.filter(d=>d.type==="SkinnedMesh").forEach(d=>{const l=d;this._createHeadlessModelForSkinnedMesh(c,l)})}else if(r.type==="SkinnedMesh"){const c=r;this._createHeadlessModelForSkinnedMesh(r.parent,c)}else this._isEraseTarget(r)&&(r.layers.set(this._thirdPersonOnlyLayer),r.traverse(c=>c.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(r){return r===this.humanoid.getRawBoneNode("head")?!0:r.parent?this._isEraseTarget(r.parent):!1}};_VRMFirstPerson.DEFAULT_FIRSTPERSON_ONLY_LAYER=9;_VRMFirstPerson.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var VRMFirstPerson=_VRMFirstPerson,POSSIBLE_SPEC_VERSIONS2=new Set(["1.0","1.0-beta"]),VRMFirstPersonLoaderPlugin=class{get name(){return"VRMFirstPersonLoaderPlugin"}constructor(f){this.parser=f}afterRoot(f){return __async2(this,null,function*(){const r=f.userData.vrmHumanoid;if(r!==null){if(r===void 0)throw new Error("VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");f.userData.vrmFirstPerson=yield this._import(f,r)}})}_import(f,r){return __async2(this,null,function*(){if(r==null)return null;const c=yield this._v1Import(f,r);if(c)return c;const d=yield this._v0Import(f,r);return d||null})}_v1Import(f,r){return __async2(this,null,function*(){var c,d;const l=this.parser.json;if(!(((c=l.extensionsUsed)==null?void 0:c.indexOf("VRMC_vrm"))!==-1))return null;const s=(d=l.extensions)==null?void 0:d.VRMC_vrm;if(!s)return null;const h=s.specVersion;if(!POSSIBLE_SPEC_VERSIONS2.has(h))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${h}"`),null;const p=s.firstPerson,a=[],o=yield gltfExtractPrimitivesFromNodes(f);return Array.from(o.entries()).forEach(([t,e])=>{var n,i;const u=(n=p==null?void 0:p.meshAnnotations)==null?void 0:n.find(g=>g.node===t);a.push({meshes:e,type:(i=u==null?void 0:u.type)!=null?i:"auto"})}),new VRMFirstPerson(r,a)})}_v0Import(f,r){return __async2(this,null,function*(){var c;const d=this.parser.json,l=(c=d.extensions)==null?void 0:c.VRM;if(!l)return null;const m=l.firstPerson;if(!m)return null;const s=[],h=yield gltfExtractPrimitivesFromNodes(f);return Array.from(h.entries()).forEach(([p,a])=>{const o=d.nodes[p],t=m.meshAnnotations?m.meshAnnotations.find(e=>e.mesh===o.mesh):void 0;s.push({meshes:a,type:this._convertV0FlagToV1Type(t==null?void 0:t.firstPersonFlag)})}),new VRMFirstPerson(r,s)})}_convertV0FlagToV1Type(f){return f==="FirstPersonOnly"?"firstPersonOnly":f==="ThirdPersonOnly"?"thirdPersonOnly":f==="Both"?"both":"auto"}},_v3A=new Vector3,_v3B=new Vector3,_quatA=new Quaternion,VRMHumanoidHelper=class extends Group{constructor(f){super(),this.vrmHumanoid=f,this._boneAxesMap=new Map,Object.values(f.humanBones).forEach(r=>{const c=new AxesHelper(1);c.matrixAutoUpdate=!1,c.material.depthTest=!1,c.material.depthWrite=!1,this.add(c),this._boneAxesMap.set(r,c)})}dispose(){Array.from(this._boneAxesMap.values()).forEach(f=>{f.geometry.dispose(),f.material.dispose()})}updateMatrixWorld(f){Array.from(this._boneAxesMap.entries()).forEach(([r,c])=>{r.node.updateWorldMatrix(!0,!1),r.node.matrixWorld.decompose(_v3A,_quatA,_v3B);const d=_v3A.set(.1,.1,.1).divide(_v3B);c.matrix.copy(r.node.matrixWorld).scale(d)}),super.updateMatrixWorld(f)}},VRMHumanBoneList=["hips","spine","chest","upperChest","neck","head","leftEye","rightEye","jaw","leftUpperLeg","leftLowerLeg","leftFoot","leftToes","rightUpperLeg","rightLowerLeg","rightFoot","rightToes","leftShoulder","leftUpperArm","leftLowerArm","leftHand","rightShoulder","rightUpperArm","rightLowerArm","rightHand","leftThumbMetacarpal","leftThumbProximal","leftThumbDistal","leftIndexProximal","leftIndexIntermediate","leftIndexDistal","leftMiddleProximal","leftMiddleIntermediate","leftMiddleDistal","leftRingProximal","leftRingIntermediate","leftRingDistal","leftLittleProximal","leftLittleIntermediate","leftLittleDistal","rightThumbMetacarpal","rightThumbProximal","rightThumbDistal","rightIndexProximal","rightIndexIntermediate","rightIndexDistal","rightMiddleProximal","rightMiddleIntermediate","rightMiddleDistal","rightRingProximal","rightRingIntermediate","rightRingDistal","rightLittleProximal","rightLittleIntermediate","rightLittleDistal"],VRMHumanBoneParentMap={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function quatInvertCompat(f){return f.invert?f.invert():f.inverse(),f}var _v3A2=new Vector3,_quatA2=new Quaternion,VRMRig=class{constructor(f){this.humanBones=f,this.restPose=this.getAbsolutePose()}getAbsolutePose(){const f={};return Object.keys(this.humanBones).forEach(r=>{const c=r,d=this.getBoneNode(c);d&&(_v3A2.copy(d.position),_quatA2.copy(d.quaternion),f[c]={position:_v3A2.toArray(),rotation:_quatA2.toArray()})}),f}getPose(){const f={};return Object.keys(this.humanBones).forEach(r=>{const c=r,d=this.getBoneNode(c);if(!d)return;_v3A2.set(0,0,0),_quatA2.identity();const l=this.restPose[c];l!=null&&l.position&&_v3A2.fromArray(l.position).negate(),l!=null&&l.rotation&&quatInvertCompat(_quatA2.fromArray(l.rotation)),_v3A2.add(d.position),_quatA2.premultiply(d.quaternion),f[c]={position:_v3A2.toArray(),rotation:_quatA2.toArray()}}),f}setPose(f){Object.entries(f).forEach(([r,c])=>{const d=r,l=this.getBoneNode(d);if(!l)return;const m=this.restPose[d];m&&(c!=null&&c.position&&(l.position.fromArray(c.position),m.position&&l.position.add(_v3A2.fromArray(m.position))),c!=null&&c.rotation&&(l.quaternion.fromArray(c.rotation),m.rotation&&l.quaternion.multiply(_quatA2.fromArray(m.rotation))))})}resetPose(){Object.entries(this.restPose).forEach(([f,r])=>{const c=this.getBoneNode(f);c&&(r!=null&&r.position&&c.position.fromArray(r.position),r!=null&&r.rotation&&c.quaternion.fromArray(r.rotation))})}getBone(f){var r;return(r=this.humanBones[f])!=null?r:void 0}getBoneNode(f){var r,c;return(c=(r=this.humanBones[f])==null?void 0:r.node)!=null?c:null}},_v3A3=new Vector3,_quatA3=new Quaternion,_boneWorldPos=new Vector3,VRMHumanoidRig=class _n extends VRMRig{static _setupTransforms(r){const c=new Object3D;c.name="VRMHumanoidRig";const d={},l={},m={};VRMHumanBoneList.forEach(h=>{var p;const a=r.getBoneNode(h);if(a){const o=new Vector3,t=new Quaternion;a.updateWorldMatrix(!0,!1),a.matrixWorld.decompose(o,t,_v3A3),d[h]=o,l[h]=a.quaternion.clone();const e=new Quaternion;(p=a.parent)==null||p.matrixWorld.decompose(_v3A3,e,_v3A3),m[h]=e}});const s={};return VRMHumanBoneList.forEach(h=>{var p;const a=r.getBoneNode(h);if(a){const o=d[h];let t=h,e;for(;e==null&&(t=VRMHumanBoneParentMap[t],t!=null);)e=d[t];const n=new Object3D;n.name="Normalized_"+a.name,(t?(p=s[t])==null?void 0:p.node:c).add(n),n.position.copy(o),e&&n.position.sub(e),s[h]={node:n}}}),{rigBones:s,root:c,parentWorldRotations:m,boneRotations:l}}constructor(r){const{rigBones:c,root:d,parentWorldRotations:l,boneRotations:m}=_n._setupTransforms(r);super(c),this.original=r,this.root=d,this._parentWorldRotations=l,this._boneRotations=m}update(){VRMHumanBoneList.forEach(r=>{const c=this.original.getBoneNode(r);if(c!=null){const d=this.getBoneNode(r),l=this._parentWorldRotations[r],m=_quatA3.copy(l).invert(),s=this._boneRotations[r];if(c.quaternion.copy(d.quaternion).multiply(l).premultiply(m).multiply(s),r==="hips"){const h=d.getWorldPosition(_boneWorldPos);c.parent.updateWorldMatrix(!0,!1);const p=c.parent.matrixWorld,a=h.applyMatrix4(p.invert());c.position.copy(a)}}})}},VRMHumanoid=class vn{get restPose(){return console.warn("VRMHumanoid: restPose is deprecated. Use either rawRestPose or normalizedRestPose instead."),this.rawRestPose}get rawRestPose(){return this._rawHumanBones.restPose}get normalizedRestPose(){return this._normalizedHumanBones.restPose}get humanBones(){return this._rawHumanBones.humanBones}get rawHumanBones(){return this._rawHumanBones.humanBones}get normalizedHumanBones(){return this._normalizedHumanBones.humanBones}get normalizedHumanBonesRoot(){return this._normalizedHumanBones.root}constructor(r,c){var d;this.autoUpdateHumanBones=(d=c==null?void 0:c.autoUpdateHumanBones)!=null?d:!0,this._rawHumanBones=new VRMRig(r),this._normalizedHumanBones=new VRMHumanoidRig(this._rawHumanBones)}copy(r){return this.autoUpdateHumanBones=r.autoUpdateHumanBones,this._rawHumanBones=new VRMRig(r.humanBones),this._normalizedHumanBones=new VRMHumanoidRig(this._rawHumanBones),this}clone(){return new vn(this.humanBones,{autoUpdateHumanBones:this.autoUpdateHumanBones}).copy(this)}getAbsolutePose(){return console.warn("VRMHumanoid: getAbsolutePose() is deprecated. Use either getRawAbsolutePose() or getNormalizedAbsolutePose() instead."),this.getRawAbsolutePose()}getRawAbsolutePose(){return this._rawHumanBones.getAbsolutePose()}getNormalizedAbsolutePose(){return this._normalizedHumanBones.getAbsolutePose()}getPose(){return console.warn("VRMHumanoid: getPose() is deprecated. Use either getRawPose() or getNormalizedPose() instead."),this.getRawPose()}getRawPose(){return this._rawHumanBones.getPose()}getNormalizedPose(){return this._normalizedHumanBones.getPose()}setPose(r){return console.warn("VRMHumanoid: setPose() is deprecated. Use either setRawPose() or setNormalizedPose() instead."),this.setRawPose(r)}setRawPose(r){return this._rawHumanBones.setPose(r)}setNormalizedPose(r){return this._normalizedHumanBones.setPose(r)}resetPose(){return console.warn("VRMHumanoid: resetPose() is deprecated. Use either resetRawPose() or resetNormalizedPose() instead."),this.resetRawPose()}resetRawPose(){return this._rawHumanBones.resetPose()}resetNormalizedPose(){return this._normalizedHumanBones.resetPose()}getBone(r){return console.warn("VRMHumanoid: getBone() is deprecated. Use either getRawBone() or getNormalizedBone() instead."),this.getRawBone(r)}getRawBone(r){return this._rawHumanBones.getBone(r)}getNormalizedBone(r){return this._normalizedHumanBones.getBone(r)}getBoneNode(r){return console.warn("VRMHumanoid: getBoneNode() is deprecated. Use either getRawBoneNode() or getNormalizedBoneNode() instead."),this.getRawBoneNode(r)}getRawBoneNode(r){return this._rawHumanBones.getBoneNode(r)}getNormalizedBoneNode(r){return this._normalizedHumanBones.getBoneNode(r)}update(){this.autoUpdateHumanBones&&this._normalizedHumanBones.update()}},VRMRequiredHumanBoneName={Hips:"hips",Spine:"spine",Head:"head",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand"},POSSIBLE_SPEC_VERSIONS3=new Set(["1.0","1.0-beta"]),thumbBoneNameMap={leftThumbProximal:"leftThumbMetacarpal",leftThumbIntermediate:"leftThumbProximal",rightThumbProximal:"rightThumbMetacarpal",rightThumbIntermediate:"rightThumbProximal"},VRMHumanoidLoaderPlugin=class{get name(){return"VRMHumanoidLoaderPlugin"}constructor(f,r){this.parser=f,this.helperRoot=r==null?void 0:r.helperRoot,this.autoUpdateHumanBones=r==null?void 0:r.autoUpdateHumanBones}afterRoot(f){return __async2(this,null,function*(){f.userData.vrmHumanoid=yield this._import(f)})}_import(f){return __async2(this,null,function*(){const r=yield this._v1Import(f);if(r)return r;const c=yield this._v0Import(f);return c||null})}_v1Import(f){return __async2(this,null,function*(){var r,c;const d=this.parser.json;if(!(((r=d.extensionsUsed)==null?void 0:r.indexOf("VRMC_vrm"))!==-1))return null;const m=(c=d.extensions)==null?void 0:c.VRMC_vrm;if(!m)return null;const s=m.specVersion;if(!POSSIBLE_SPEC_VERSIONS3.has(s))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${s}"`),null;const h=m.humanoid;if(!h)return null;const p=h.humanBones.leftThumbIntermediate!=null||h.humanBones.rightThumbIntermediate!=null,a={};h.humanBones!=null&&(yield Promise.all(Object.entries(h.humanBones).map(t=>__async2(this,[t],function*([e,n]){let i=e;const u=n.node;if(p){const b=thumbBoneNameMap[i];b!=null&&(i=b)}const g=yield this.parser.getDependency("node",u);if(g==null){console.warn(`A glTF node bound to the humanoid bone ${i} (index = ${u}) does not exist`);return}a[i]={node:g}}))));const o=new VRMHumanoid(this._ensureRequiredBonesExist(a),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(f.scene.add(o.normalizedHumanBonesRoot),this.helperRoot){const t=new VRMHumanoidHelper(o);this.helperRoot.add(t),t.renderOrder=this.helperRoot.renderOrder}return o})}_v0Import(f){return __async2(this,null,function*(){var r;const d=(r=this.parser.json.extensions)==null?void 0:r.VRM;if(!d)return null;const l=d.humanoid;if(!l)return null;const m={};l.humanBones!=null&&(yield Promise.all(l.humanBones.map(h=>__async2(this,null,function*(){const p=h.bone,a=h.node;if(p==null||a==null)return;const o=yield this.parser.getDependency("node",a);if(o==null){console.warn(`A glTF node bound to the humanoid bone ${p} (index = ${a}) does not exist`);return}const t=thumbBoneNameMap[p],e=t??p;if(m[e]!=null){console.warn(`Multiple bone entries for ${e} detected (index = ${a}), ignoring duplicated entries.`);return}m[e]={node:o}}))));const s=new VRMHumanoid(this._ensureRequiredBonesExist(m),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(f.scene.add(s.normalizedHumanBonesRoot),this.helperRoot){const h=new VRMHumanoidHelper(s);this.helperRoot.add(h),h.renderOrder=this.helperRoot.renderOrder}return s})}_ensureRequiredBonesExist(f){const r=Object.values(VRMRequiredHumanBoneName).filter(c=>f[c]==null);if(r.length>0)throw new Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${r.join(", ")}`);return f}},FanBufferGeometry=class extends BufferGeometry{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new BufferAttribute(new Float32Array(65*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new BufferAttribute(new Uint16Array(3*63),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let f=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,f=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,f=!0),f&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let f=0;f<64;f++){const r=f/63*this._currentTheta;this._attrPos.setXYZ(f+1,this._currentRadius*Math.sin(r),0,this._currentRadius*Math.cos(r))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let f=0;f<63;f++)this._attrIndex.setXYZ(f*3,0,f+1,f+2);this._attrIndex.needsUpdate=!0}},LineAndSphereBufferGeometry=class extends BufferGeometry{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new Vector3,this._currentTail=new Vector3,this._attrPos=new BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let f=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,f=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),f=!0),f&&this._buildPosition()}_buildPosition(){for(let f=0;f<32;f++){const r=f/16*Math.PI;this._attrPos.setXYZ(f,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+f,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+f,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let f=0;f<32;f++){const r=(f+1)%32;this._attrIndex.setXY(f*2,f,r),this._attrIndex.setXY(64+f*2,32+f,32+r),this._attrIndex.setXY(128+f*2,64+f,64+r)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},_quatA4=new Quaternion,_quatB=new Quaternion,_v3A4=new Vector3,_v3B2=new Vector3,SQRT_2_OVER_2=Math.sqrt(2)/2,QUAT_XY_CW90=new Quaternion(0,0,-SQRT_2_OVER_2,SQRT_2_OVER_2),VEC3_POSITIVE_Y=new Vector3(0,1,0),VRMLookAtHelper=class extends Group{constructor(f){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=f;{const r=new FanBufferGeometry;r.radius=.5;const c=new MeshBasicMaterial({color:65280,transparent:!0,opacity:.5,side:DoubleSide,depthTest:!1,depthWrite:!1});this._meshPitch=new Mesh(r,c),this.add(this._meshPitch)}{const r=new FanBufferGeometry;r.radius=.5;const c=new MeshBasicMaterial({color:16711680,transparent:!0,opacity:.5,side:DoubleSide,depthTest:!1,depthWrite:!1});this._meshYaw=new Mesh(r,c),this.add(this._meshYaw)}{const r=new LineAndSphereBufferGeometry;r.radius=.1;const c=new LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1});this._lineTarget=new LineSegments(r,c),this._lineTarget.frustumCulled=!1,this.add(this._lineTarget)}}dispose(){this._meshYaw.geometry.dispose(),this._meshYaw.material.dispose(),this._meshPitch.geometry.dispose(),this._meshPitch.material.dispose(),this._lineTarget.geometry.dispose(),this._lineTarget.material.dispose()}updateMatrixWorld(f){const r=MathUtils.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=r,this._meshYaw.geometry.update();const c=MathUtils.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=c,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition(_v3A4),this.vrmLookAt.getLookAtWorldQuaternion(_quatA4),_quatA4.multiply(this.vrmLookAt.getFaceFrontQuaternion(_quatB)),this._meshYaw.position.copy(_v3A4),this._meshYaw.quaternion.copy(_quatA4),this._meshPitch.position.copy(_v3A4),this._meshPitch.quaternion.copy(_quatA4),this._meshPitch.quaternion.multiply(_quatB.setFromAxisAngle(VEC3_POSITIVE_Y,r)),this._meshPitch.quaternion.multiply(QUAT_XY_CW90);const{target:d,autoUpdate:l}=this.vrmLookAt;d!=null&&l&&(d.getWorldPosition(_v3B2).sub(_v3A4),this._lineTarget.geometry.tail.copy(_v3B2),this._lineTarget.geometry.update(),this._lineTarget.position.copy(_v3A4)),super.updateMatrixWorld(f)}},_position=new Vector3,_scale=new Vector3;function getWorldQuaternionLite(f,r){return f.matrixWorld.decompose(_position,r,_scale),r}function calcAzimuthAltitude(f){return[Math.atan2(-f.z,f.x),Math.atan2(f.y,Math.sqrt(f.x*f.x+f.z*f.z))]}function sanitizeAngle(f){const r=Math.round(f/2/Math.PI);return f-2*Math.PI*r}var VEC3_POSITIVE_Z=new Vector3(0,0,1),_v3A5=new Vector3,_v3B3=new Vector3,_v3C=new Vector3,_quatA5=new Quaternion,_quatB2=new Quaternion,_quatC=new Quaternion,_quatD=new Quaternion,_eulerA=new Euler,_VRMLookAt=class wn{constructor(r,c){this.offsetFromHeadBone=new Vector3,this.autoUpdate=!0,this.faceFront=new Vector3(0,0,1),this.humanoid=r,this.applier=c,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new Quaternion)}get yaw(){return this._yaw}set yaw(r){this._yaw=r,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(r){this._pitch=r,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Euler)}getEuler(r){return r.set(MathUtils.DEG2RAD*this._pitch,MathUtils.DEG2RAD*this._yaw,0,"YXZ")}copy(r){if(this.humanoid!==r.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(r.offsetFromHeadBone),this.applier=r.applier,this.autoUpdate=r.autoUpdate,this.target=r.target,this.faceFront.copy(r.faceFront),this}clone(){return new wn(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(r){const c=this.humanoid.getRawBoneNode("head");return r.copy(this.offsetFromHeadBone).applyMatrix4(c.matrixWorld)}getLookAtWorldQuaternion(r){const c=this.humanoid.getRawBoneNode("head");return getWorldQuaternionLite(c,r)}getFaceFrontQuaternion(r){if(this.faceFront.distanceToSquared(VEC3_POSITIVE_Z)<.01)return r.copy(this._restHeadWorldQuaternion).invert();const[c,d]=calcAzimuthAltitude(this.faceFront);return _eulerA.set(0,.5*Math.PI+c,d,"YZX"),r.setFromEuler(_eulerA).premultiply(_quatD.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(r){return this.getLookAtWorldQuaternion(_quatB2),this.getFaceFrontQuaternion(_quatC),r.copy(VEC3_POSITIVE_Z).applyQuaternion(_quatB2).applyQuaternion(_quatC).applyEuler(this.getEuler(_eulerA))}lookAt(r){const c=_quatA5.copy(this._restHeadWorldQuaternion).multiply(quatInvertCompat(this.getLookAtWorldQuaternion(_quatB2))),d=this.getLookAtWorldPosition(_v3B3),l=_v3C.copy(r).sub(d).applyQuaternion(c).normalize(),[m,s]=calcAzimuthAltitude(this.faceFront),[h,p]=calcAzimuthAltitude(l),a=sanitizeAngle(h-m),o=sanitizeAngle(s-p);this._yaw=MathUtils.RAD2DEG*a,this._pitch=MathUtils.RAD2DEG*o,this._needsUpdate=!0}update(r){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(_v3A5)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};_VRMLookAt.EULER_ORDER="YXZ";var VRMLookAt=_VRMLookAt,VEC3_POSITIVE_Z2=new Vector3(0,0,1),_quatA6=new Quaternion,_quatB3=new Quaternion,_eulerA2=new Euler(0,0,0,"YXZ"),VRMLookAtBoneApplier=class{constructor(f,r,c,d,l){this.humanoid=f,this.rangeMapHorizontalInner=r,this.rangeMapHorizontalOuter=c,this.rangeMapVerticalDown=d,this.rangeMapVerticalUp=l,this.faceFront=new Vector3(0,0,1),this._restQuatLeftEye=new Quaternion,this._restQuatRightEye=new Quaternion,this._restLeftEyeParentWorldQuat=new Quaternion,this._restRightEyeParentWorldQuat=new Quaternion;const m=this.humanoid.getRawBoneNode("leftEye"),s=this.humanoid.getRawBoneNode("rightEye");m&&(this._restQuatLeftEye.copy(m.quaternion),getWorldQuaternionLite(m.parent,this._restLeftEyeParentWorldQuat)),s&&(this._restQuatRightEye.copy(s.quaternion),getWorldQuaternionLite(s.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(f,r){const c=this.humanoid.getRawBoneNode("leftEye"),d=this.humanoid.getRawBoneNode("rightEye"),l=this.humanoid.getNormalizedBoneNode("leftEye"),m=this.humanoid.getNormalizedBoneNode("rightEye");c&&(r<0?_eulerA2.x=-MathUtils.DEG2RAD*this.rangeMapVerticalDown.map(-r):_eulerA2.x=MathUtils.DEG2RAD*this.rangeMapVerticalUp.map(r),f<0?_eulerA2.y=-MathUtils.DEG2RAD*this.rangeMapHorizontalInner.map(-f):_eulerA2.y=MathUtils.DEG2RAD*this.rangeMapHorizontalOuter.map(f),_quatA6.setFromEuler(_eulerA2),this._getWorldFaceFrontQuat(_quatB3),l.quaternion.copy(_quatB3).multiply(_quatA6).multiply(_quatB3.invert()),_quatA6.copy(this._restLeftEyeParentWorldQuat),c.quaternion.copy(l.quaternion).multiply(_quatA6).premultiply(_quatA6.invert()).multiply(this._restQuatLeftEye)),d&&(r<0?_eulerA2.x=-MathUtils.DEG2RAD*this.rangeMapVerticalDown.map(-r):_eulerA2.x=MathUtils.DEG2RAD*this.rangeMapVerticalUp.map(r),f<0?_eulerA2.y=-MathUtils.DEG2RAD*this.rangeMapHorizontalOuter.map(-f):_eulerA2.y=MathUtils.DEG2RAD*this.rangeMapHorizontalInner.map(f),_quatA6.setFromEuler(_eulerA2),this._getWorldFaceFrontQuat(_quatB3),m.quaternion.copy(_quatB3).multiply(_quatA6).multiply(_quatB3.invert()),_quatA6.copy(this._restRightEyeParentWorldQuat),d.quaternion.copy(m.quaternion).multiply(_quatA6).premultiply(_quatA6.invert()).multiply(this._restQuatRightEye))}lookAt(f){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const r=MathUtils.RAD2DEG*f.y,c=MathUtils.RAD2DEG*f.x;this.applyYawPitch(r,c)}_getWorldFaceFrontQuat(f){if(this.faceFront.distanceToSquared(VEC3_POSITIVE_Z2)<.01)return f.identity();const[r,c]=calcAzimuthAltitude(this.faceFront);return _eulerA2.set(0,.5*Math.PI+r,c,"YZX"),f.setFromEuler(_eulerA2)}};VRMLookAtBoneApplier.type="bone";var VRMLookAtExpressionApplier=class{constructor(f,r,c,d,l){this.expressions=f,this.rangeMapHorizontalInner=r,this.rangeMapHorizontalOuter=c,this.rangeMapVerticalDown=d,this.rangeMapVerticalUp=l}applyYawPitch(f,r){r<0?(this.expressions.setValue("lookDown",0),this.expressions.setValue("lookUp",this.rangeMapVerticalUp.map(-r))):(this.expressions.setValue("lookUp",0),this.expressions.setValue("lookDown",this.rangeMapVerticalDown.map(r))),f<0?(this.expressions.setValue("lookLeft",0),this.expressions.setValue("lookRight",this.rangeMapHorizontalOuter.map(-f))):(this.expressions.setValue("lookRight",0),this.expressions.setValue("lookLeft",this.rangeMapHorizontalOuter.map(f)))}lookAt(f){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const r=MathUtils.RAD2DEG*f.y,c=MathUtils.RAD2DEG*f.x;this.applyYawPitch(r,c)}};VRMLookAtExpressionApplier.type="expression";var VRMLookAtRangeMap=class{constructor(f,r){this.inputMaxValue=f,this.outputScale=r}map(f){return this.outputScale*saturate(f/this.inputMaxValue)}},POSSIBLE_SPEC_VERSIONS4=new Set(["1.0","1.0-beta"]),INPUT_MAX_VALUE_MINIMUM=.01,VRMLookAtLoaderPlugin=class{get name(){return"VRMLookAtLoaderPlugin"}constructor(f,r){this.parser=f,this.helperRoot=r==null?void 0:r.helperRoot}afterRoot(f){return __async2(this,null,function*(){const r=f.userData.vrmHumanoid;if(r===null)return;if(r===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");const c=f.userData.vrmExpressionManager;if(c!==null){if(c===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first");f.userData.vrmLookAt=yield this._import(f,r,c)}})}_import(f,r,c){return __async2(this,null,function*(){if(r==null||c==null)return null;const d=yield this._v1Import(f,r,c);if(d)return d;const l=yield this._v0Import(f,r,c);return l||null})}_v1Import(f,r,c){return __async2(this,null,function*(){var d,l,m;const s=this.parser.json;if(!(((d=s.extensionsUsed)==null?void 0:d.indexOf("VRMC_vrm"))!==-1))return null;const p=(l=s.extensions)==null?void 0:l.VRMC_vrm;if(!p)return null;const a=p.specVersion;if(!POSSIBLE_SPEC_VERSIONS4.has(a))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;const o=p.lookAt;if(!o)return null;const t=o.type==="expression"?1:10,e=this._v1ImportRangeMap(o.rangeMapHorizontalInner,t),n=this._v1ImportRangeMap(o.rangeMapHorizontalOuter,t),i=this._v1ImportRangeMap(o.rangeMapVerticalDown,t),u=this._v1ImportRangeMap(o.rangeMapVerticalUp,t);let g;o.type==="expression"?g=new VRMLookAtExpressionApplier(c,e,n,i,u):g=new VRMLookAtBoneApplier(r,e,n,i,u);const b=this._importLookAt(r,g);return b.offsetFromHeadBone.fromArray((m=o.offsetFromHeadBone)!=null?m:[0,.06,0]),b})}_v1ImportRangeMap(f,r){var c,d;let l=(c=f==null?void 0:f.inputMaxValue)!=null?c:90;const m=(d=f==null?void 0:f.outputScale)!=null?d:r;return l(console.error(s),console.warn("VRMMetaLoaderPlugin: Failed to load a thumbnail image"),null))})}},VRMCore=class{constructor(f){this.scene=f.scene,this.meta=f.meta,this.humanoid=f.humanoid,this.expressionManager=f.expressionManager,this.firstPerson=f.firstPerson,this.lookAt=f.lookAt}update(f){this.humanoid.update(),this.lookAt&&this.lookAt.update(f),this.expressionManager&&this.expressionManager.update()}},VRM=class extends VRMCore{constructor(f){super(f),this.materials=f.materials,this.springBoneManager=f.springBoneManager,this.nodeConstraintManager=f.nodeConstraintManager}update(f){super.update(f),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(f),this.materials&&this.materials.forEach(r=>{r.update&&r.update(f)})}},__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(f,r,c)=>r in f?__defProp(f,r,{enumerable:!0,configurable:!0,writable:!0,value:c}):f[r]=c,__spreadValues=(f,r)=>{for(var c in r||(r={}))__hasOwnProp.call(r,c)&&__defNormalProp(f,c,r[c]);if(__getOwnPropSymbols)for(var c of __getOwnPropSymbols(r))__propIsEnum.call(r,c)&&__defNormalProp(f,c,r[c]);return f},__async3=(f,r,c)=>new Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())}),colorSpaceEncodingMap={"":3e3,srgb:3001};function setTextureColorSpace(f,r){parseInt(REVISION,10)>=152?f.colorSpace=r:f.encoding=colorSpaceEncodingMap[r]}var GLTFMToonMaterialParamsAssignHelper=class{get pending(){return Promise.all(this._pendings)}constructor(f,r){this._parser=f,this._materialParams=r,this._pendings=[]}assignPrimitive(f,r){r!=null&&(this._materialParams[f]=r)}assignColor(f,r,c){r!=null&&(this._materialParams[f]=new Color().fromArray(r),c&&this._materialParams[f].convertSRGBToLinear())}assignTexture(f,r,c){return __async3(this,null,function*(){const d=__async3(this,null,function*(){r!=null&&(yield this._parser.assignTexture(this._materialParams,f,r),c&&setTextureColorSpace(this._materialParams[f],"srgb"))});return this._pendings.push(d),d})}assignTextureByIndex(f,r,c){return __async3(this,null,function*(){return this.assignTexture(f,r!=null?{index:r}:void 0,c)})}},mtoon_default=`// #define PHONG + +varying vec3 vViewPosition; + +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif + +#include + +// #include +#ifdef MTOON_USE_UV + varying vec2 vUv; + + // COMPAT: pre-r151 uses a common uvTransform + #if THREE_VRM_THREE_REVISION < 151 + uniform mat3 uvTransform; + #endif +#endif + +// #include +// COMAPT: pre-r151 uses uv2 for lightMap and aoMap +#if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + attribute vec2 uv2; + varying vec2 vUv2; + uniform mat3 uv2Transform; + #endif +#endif + +// #include +// #include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE + uniform sampler2D outlineWidthMultiplyTexture; + uniform mat3 outlineWidthMultiplyTextureUvTransform; +#endif + +uniform float outlineWidthFactor; + +void main() { + + // #include + #ifdef MTOON_USE_UV + // COMPAT: pre-r151 uses a common uvTransform + #if THREE_VRM_THREE_REVISION >= 151 + vUv = uv; + #else + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #endif + + // #include + // COMAPT: pre-r151 uses uv2 for lightMap and aoMap + #if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; + #endif + #endif + + #include + + #include + #include + #include + #include + + // we need this to compute the outline properly + objectNormal = normalize( objectNormal ); + + #include + + #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED + vNormal = normalize( transformedNormal ); + #endif + + #include + + #include + #include + // #include + #include + #include + #include + + vViewPosition = - mvPosition.xyz; + + #ifdef OUTLINE + float worldNormalLength = length( transformedNormal ); + vec3 outlineOffset = outlineWidthFactor * worldNormalLength * objectNormal; + + #ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE + vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy; + float outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g; + outlineOffset *= outlineTex; + #endif + + #ifdef OUTLINE_WIDTH_SCREEN + outlineOffset *= vViewPosition.z / projectionMatrix[ 1 ].y; + #endif + + gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 ); + + gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic + #endif + + #include + // #include + #include + #include + +}`,mtoon_default2=`// #define PHONG + +uniform vec3 litFactor; + +uniform float opacity; + +uniform vec3 shadeColorFactor; +#ifdef USE_SHADEMULTIPLYTEXTURE + uniform sampler2D shadeMultiplyTexture; + uniform mat3 shadeMultiplyTextureUvTransform; +#endif + +uniform float shadingShiftFactor; +uniform float shadingToonyFactor; + +#ifdef USE_SHADINGSHIFTTEXTURE + uniform sampler2D shadingShiftTexture; + uniform mat3 shadingShiftTextureUvTransform; + uniform float shadingShiftTextureScale; +#endif + +uniform float giEqualizationFactor; + +uniform vec3 parametricRimColorFactor; +#ifdef USE_RIMMULTIPLYTEXTURE + uniform sampler2D rimMultiplyTexture; + uniform mat3 rimMultiplyTextureUvTransform; +#endif +uniform float rimLightingMixFactor; +uniform float parametricRimFresnelPowerFactor; +uniform float parametricRimLiftFactor; + +#ifdef USE_MATCAPTEXTURE + uniform vec3 matcapFactor; + uniform sampler2D matcapTexture; + uniform mat3 matcapTextureUvTransform; +#endif + +uniform vec3 emissive; +uniform float emissiveIntensity; + +uniform vec3 outlineColorFactor; +uniform float outlineLightingMixFactor; + +#ifdef USE_UVANIMATIONMASKTEXTURE + uniform sampler2D uvAnimationMaskTexture; + uniform mat3 uvAnimationMaskTextureUvTransform; +#endif + +uniform float uvAnimationScrollXOffset; +uniform float uvAnimationScrollYOffset; +uniform float uvAnimationRotationPhase; + +#include +#include +#include +#include + +// #include +#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + varying vec2 vUv; +#endif + +// #include +// COMAPT: pre-r151 uses uv2 for lightMap and aoMap +#if THREE_VRM_THREE_REVISION < 151 + #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + varying vec2 vUv2; + #endif +#endif + +#include + +#ifdef USE_MAP + uniform mat3 mapUvTransform; +#endif + +// #include + +#include + +#include +// #include +#include + +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapUvTransform; +#endif + +// #include +// #include +// #include +#include + +// #include +// COMPAT: pre-r151 doesn't have BRDF_Lambert in +#if THREE_VRM_THREE_REVISION < 151 + vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; + } +#endif + +#include + +#include + +// #include +varying vec3 vViewPosition; + +struct MToonMaterial { + vec3 diffuseColor; + vec3 shadeColor; + float shadingShift; +}; + +float linearstep( float a, float b, float t ) { + return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 ); +} + +/** + * Convert NdotL into toon shading factor using shadingShift and shadingToony + */ +float getShading( + const in float dotNL, + const in float shadow, + const in float shadingShift +) { + float shading = dotNL; + shading = shading + shadingShift; + shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading ); + shading *= shadow; + return shading; +} + +/** + * Mix diffuseColor and shadeColor using shading factor and light color + */ +vec3 getDiffuse( + const in MToonMaterial material, + const in float shading, + in vec3 lightColor +) { + #ifdef DEBUG_LITSHADERATE + return vec3( BRDF_Lambert( shading * lightColor ) ); + #endif + + vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) ); + + // The "comment out if you want to PBR absolutely" line + #ifdef V0_COMPAT_SHADE + col = min( col, material.diffuseColor ); + #endif + + return col; +} + +// COMPAT: pre-r156 uses a struct GeometricContext +#if THREE_VRM_THREE_REVISION >= 157 + void RE_Direct_MToon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) { + float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 ); + vec3 irradiance = directLight.color; + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + + irradiance *= dotNL; + + float shading = getShading( dotNL, shadow, material.shadingShift ); + + // toon shaded diffuse + reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color ); + } + + void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, inout ReflectedLight reflectedLight ) { + // indirect diffuse will use diffuseColor, no shadeColor involved + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + } +#else + void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) { + float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 ); + vec3 irradiance = directLight.color; + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + + irradiance *= dotNL; + + float shading = getShading( dotNL, shadow, material.shadingShift ); + + // toon shaded diffuse + reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color ); + } + + void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) { + // indirect diffuse will use diffuseColor, no shadeColor involved + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + + // directSpecular will be used for rim lighting, not an actual specular + reflectedLight.directSpecular += irradiance; + } +#endif + +#define RE_Direct RE_Direct_MToon +#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon +#define Material_LightProbeLOD( material ) (0) + +#include +// #include + +// #include +#ifdef USE_NORMALMAP + + uniform sampler2D normalMap; + uniform mat3 normalMapUvTransform; + uniform vec2 normalScale; + +#endif + +// COMPAT: pre-r151 +// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151 +#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP ) + + uniform mat3 normalMatrix; + +#endif + +// COMPAT: pre-r151 +// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151 +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) ) + + // Per-Pixel Tangent Space Normal Mapping + // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html + + // three-vrm specific change: it requires \`uv\` as an input in order to support uv scrolls + + // Temporary compat against shader change @ Three.js r126, r151 + #if THREE_VRM_THREE_REVISION >= 151 + + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + + vec3 N = surf_norm; + + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + + return mat3( T * scale, B * scale, N ); + + } + + #else + + vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { + + vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); + vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + + vec3 N = normalize( surf_norm ); + + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + + // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0 + // TODO: Is this still required? Or shall I make a PR about it? + if ( length( T ) == 0.0 || length( B ) == 0.0 ) { + return surf_norm; + } + + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); + + return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); + + } + + #endif + +#endif + +// #include +#include +#include + +// == post correction ========================================================== +void postCorrection() { + #include + #include + #include + #include + #include +} + +// == main procedure =========================================================== +void main() { + #include + + vec2 uv = vec2(0.5, 0.5); + + #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + uv = vUv; + + float uvAnimMask = 1.0; + #ifdef USE_UVANIMATIONMASKTEXTURE + vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy; + uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b; + #endif + + float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask ); + float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask ); + uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5; + uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask; + #endif + + #ifdef DEBUG_UV + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) ) + gl_FragColor = vec4( uv, 0.0, 1.0 ); + #endif + return; + #endif + + vec4 diffuseColor = vec4( litFactor, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive * emissiveIntensity; + + #include + + // #include + #ifdef USE_MAP + vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy; + vec4 sampledDiffuseColor = texture2D( map, mapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + #endif + diffuseColor *= sampledDiffuseColor; + #endif + + // #include + #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) ) + diffuseColor.rgb *= vColor; + #endif + + // #include + + #include + + // #include + + // #include + float faceDirection = gl_FrontFacing ? 1.0 : -1.0; + + #ifdef FLAT_SHADED + + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); + + #else + + vec3 normal = normalize( vNormal ); + + #ifdef DOUBLE_SIDED + + normal *= faceDirection; + + #endif + + #endif + + #ifdef USE_NORMALMAP + + vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy; + + #endif + + #ifdef USE_NORMALMAP_TANGENTSPACE + + #ifdef USE_TANGENT + + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + + #else + + mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv ); + + #endif + + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + + #endif + + #endif + + #ifdef USE_CLEARCOAT_NORMALMAP + + #ifdef USE_TANGENT + + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + + #else + + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + + #endif + + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + + #endif + + #endif + + // non perturbed normal for clearcoat among others + + vec3 nonPerturbedNormal = normal; + + #ifdef OUTLINE + normal *= -1.0; + #endif + + // #include + + // COMPAT: pre-r151 + // USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151 + #if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP ) + + normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals + + #ifdef FLIP_SIDED + + normal = - normal; + + #endif + + #ifdef DOUBLE_SIDED + + normal = normal * faceDirection; + + #endif + + normal = normalize( normalMatrix * normal ); + + // COMPAT: pre-r151 + // USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151 + #elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP ) + + vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + + // COMPAT: pre-r151 + #if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT ) + + normal = normalize( tbn * mapN ); + + #else + + normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection ); + + #endif + + #endif + + // #include + #ifdef USE_EMISSIVEMAP + vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy; + totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb; + #endif + + #ifdef DEBUG_NORMAL + gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 ); + return; + #endif + + // -- MToon: lighting -------------------------------------------------------- + // accumulation + // #include + MToonMaterial material; + + material.diffuseColor = diffuseColor.rgb; + + material.shadeColor = shadeColorFactor; + #ifdef USE_SHADEMULTIPLYTEXTURE + vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy; + material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb; + #endif + + #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) ) + material.shadeColor.rgb *= vColor; + #endif + + material.shadingShift = shadingShiftFactor; + #ifdef USE_SHADINGSHIFTTEXTURE + vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy; + material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale; + #endif + + // #include + + // MToon Specific changes: + // Since we want to take shadows into account of shading instead of irradiance, + // we had to modify the codes that multiplies the results of shadowmap into color of direct lights. + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + vec3 geometryPosition = - vViewPosition; + vec3 geometryNormal = normal; + vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); + + vec3 geometryClearcoatNormal; + + #ifdef USE_CLEARCOAT + + geometryClearcoatNormal = clearcoatNormal; + + #endif + #else + GeometricContext geometry; + + geometry.position = - vViewPosition; + geometry.normal = normal; + geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); + + #ifdef USE_CLEARCOAT + + geometry.clearcoatNormal = clearcoatNormal; + + #endif + #endif + + IncidentLight directLight; + + // since these variables will be used in unrolled loop, we have to define in prior + float shadow; + + #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + + pointLight = pointLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getPointLightInfo( pointLight, geometryPosition, directLight ); + #else + getPointLightInfo( pointLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + + SpotLight spotLight; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + + spotLight = spotLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #else + getSpotLightInfo( spotLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + + directionalLight = directionalLights[ i ]; + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + getDirectionalLightInfo( directionalLight, directLight ); + #else + getDirectionalLightInfo( directionalLight, geometry, directLight ); + #endif + + shadow = 1.0; + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + // COMPAT: pre-r166 + // r166 introduced shadowIntensity + #if THREE_VRM_THREE_REVISION >= 166 + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #else + shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + #endif + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight ); + #else + RE_Direct( directLight, geometry, material, shadow, reflectedLight ); + #endif + + } + #pragma unroll_loop_end + + #endif + + // #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + + // RectAreaLight rectAreaLight; + + // #pragma unroll_loop_start + // for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + + // rectAreaLight = rectAreaLights[ i ]; + // RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); + + // } + // #pragma unroll_loop_end + + // #endif + + #if defined( RE_IndirectDiffuse ) + + vec3 iblIrradiance = vec3( 0.0 ); + + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + + // COMPAT: pre-r156 uses a struct GeometricContext + // COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES + #if THREE_VRM_THREE_REVISION >= 157 + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #else + irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); + #endif + + #if ( NUM_HEMI_LIGHTS > 0 ) + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + + // COMPAT: pre-r156 uses a struct GeometricContext + #if THREE_VRM_THREE_REVISION >= 157 + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + #else + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + #endif + + } + #pragma unroll_loop_end + + #endif + + #endif + + // #if defined( RE_IndirectSpecular ) + + // vec3 radiance = vec3( 0.0 ); + // vec3 clearcoatRadiance = vec3( 0.0 ); + + // #endif + + #include + #include + + // modulation + #include + + vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + + #ifdef DEBUG_LITSHADERATE + gl_FragColor = vec4( col, diffuseColor.a ); + postCorrection(); + return; + #endif + + // -- MToon: rim lighting ----------------------------------------- + vec3 viewDir = normalize( vViewPosition ); + + #ifndef PHYSICALLY_CORRECT_LIGHTS + reflectedLight.directSpecular /= PI; + #endif + vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, 1.0 ); + + vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor ); + + #ifdef USE_MATCAPTEXTURE + { + vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) ); + vec3 y = cross( viewDir, x ); // guaranteed to be normalized + vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) ); + sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy; + vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb; + rim += matcapFactor * matcap; + } + #endif + + #ifdef USE_RIMMULTIPLYTEXTURE + vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy; + rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb; + #endif + + col += rimMix * rim; + + // -- MToon: Emission -------------------------------------------------------- + col += totalEmissiveRadiance; + + // #include + + // -- Almost done! ----------------------------------------------------------- + #if defined( OUTLINE ) + col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor ); + #endif + + #ifdef OPAQUE + diffuseColor.a = 1.0; + #endif + + gl_FragColor = vec4( col, diffuseColor.a ); + postCorrection(); +} +`,MToonMaterialDebugMode={None:"none",Normal:"normal",LitShadeRate:"litShadeRate",UV:"uv"},MToonMaterialOutlineWidthMode={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"},encodingColorSpaceMap={3e3:"",3001:"srgb"};function getTextureColorSpace(f){return parseInt(REVISION,10)>=152?f.colorSpace:encodingColorSpaceMap[f.encoding]}var MToonMaterial=class extends ShaderMaterial{constructor(f={}){var r;super({vertexShader:mtoon_default,fragmentShader:mtoon_default2}),this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.fog=!0,this.normalMapType=TangentSpaceNormalMap,this._ignoreVertexColor=!0,this._v0CompatShade=!1,this._debugMode=MToonMaterialDebugMode.None,this._outlineWidthMode=MToonMaterialOutlineWidthMode.None,this._isOutline=!1,f.transparentWithZWrite&&(f.depthWrite=!0),delete f.transparentWithZWrite,f.fog=!0,f.lights=!0,f.clipping=!0,this.uniforms=UniformsUtils.merge([UniformsLib.common,UniformsLib.normalmap,UniformsLib.emissivemap,UniformsLib.fog,UniformsLib.lights,{litFactor:{value:new Color(1,1,1)},mapUvTransform:{value:new Matrix3},colorAlpha:{value:1},normalMapUvTransform:{value:new Matrix3},shadeColorFactor:{value:new Color(0,0,0)},shadeMultiplyTexture:{value:null},shadeMultiplyTextureUvTransform:{value:new Matrix3},shadingShiftFactor:{value:0},shadingShiftTexture:{value:null},shadingShiftTextureUvTransform:{value:new Matrix3},shadingShiftTextureScale:{value:1},shadingToonyFactor:{value:.9},giEqualizationFactor:{value:.9},matcapFactor:{value:new Color(1,1,1)},matcapTexture:{value:null},matcapTextureUvTransform:{value:new Matrix3},parametricRimColorFactor:{value:new Color(0,0,0)},rimMultiplyTexture:{value:null},rimMultiplyTextureUvTransform:{value:new Matrix3},rimLightingMixFactor:{value:1},parametricRimFresnelPowerFactor:{value:5},parametricRimLiftFactor:{value:0},emissive:{value:new Color(0,0,0)},emissiveIntensity:{value:1},emissiveMapUvTransform:{value:new Matrix3},outlineWidthMultiplyTexture:{value:null},outlineWidthMultiplyTextureUvTransform:{value:new Matrix3},outlineWidthFactor:{value:0},outlineColorFactor:{value:new Color(0,0,0)},outlineLightingMixFactor:{value:1},uvAnimationMaskTexture:{value:null},uvAnimationMaskTextureUvTransform:{value:new Matrix3},uvAnimationScrollXOffset:{value:0},uvAnimationScrollYOffset:{value:0},uvAnimationRotationPhase:{value:0}},(r=f.uniforms)!=null?r:{}]),this.setValues(f),this._uploadUniformsWorkaround(),this.customProgramCacheKey=()=>[...Object.entries(this._generateDefines()).map(([c,d])=>`${c}:${d}`),this.matcapTexture?`matcapTextureColorSpace:${getTextureColorSpace(this.matcapTexture)}`:"",this.shadeMultiplyTexture?`shadeMultiplyTextureColorSpace:${getTextureColorSpace(this.shadeMultiplyTexture)}`:"",this.rimMultiplyTexture?`rimMultiplyTextureColorSpace:${getTextureColorSpace(this.rimMultiplyTexture)}`:""].join(","),this.onBeforeCompile=c=>{const d=parseInt(REVISION,10),l=Object.entries(__spreadValues(__spreadValues({},this._generateDefines()),this.defines)).filter(([m,s])=>!!s).map(([m,s])=>`#define ${m} ${s}`).join(` +`)+` +`;c.vertexShader=l+c.vertexShader,c.fragmentShader=l+c.fragmentShader,d<154&&(c.fragmentShader=c.fragmentShader.replace("#include ","#include "))}}get color(){return this.uniforms.litFactor.value}set color(f){this.uniforms.litFactor.value=f}get map(){return this.uniforms.map.value}set map(f){this.uniforms.map.value=f}get normalMap(){return this.uniforms.normalMap.value}set normalMap(f){this.uniforms.normalMap.value=f}get normalScale(){return this.uniforms.normalScale.value}set normalScale(f){this.uniforms.normalScale.value=f}get emissive(){return this.uniforms.emissive.value}set emissive(f){this.uniforms.emissive.value=f}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(f){this.uniforms.emissiveIntensity.value=f}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(f){this.uniforms.emissiveMap.value=f}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(f){this.uniforms.shadeColorFactor.value=f}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(f){this.uniforms.shadeMultiplyTexture.value=f}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(f){this.uniforms.shadingShiftFactor.value=f}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(f){this.uniforms.shadingShiftTexture.value=f}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(f){this.uniforms.shadingShiftTextureScale.value=f}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(f){this.uniforms.shadingToonyFactor.value=f}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(f){this.uniforms.giEqualizationFactor.value=f}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(f){this.uniforms.matcapFactor.value=f}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(f){this.uniforms.matcapTexture.value=f}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(f){this.uniforms.parametricRimColorFactor.value=f}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(f){this.uniforms.rimMultiplyTexture.value=f}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(f){this.uniforms.rimLightingMixFactor.value=f}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(f){this.uniforms.parametricRimFresnelPowerFactor.value=f}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(f){this.uniforms.parametricRimLiftFactor.value=f}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(f){this.uniforms.outlineWidthMultiplyTexture.value=f}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(f){this.uniforms.outlineWidthFactor.value=f}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(f){this.uniforms.outlineColorFactor.value=f}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(f){this.uniforms.outlineLightingMixFactor.value=f}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(f){this.uniforms.uvAnimationMaskTexture.value=f}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(f){this.uniforms.uvAnimationScrollXOffset.value=f}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(f){this.uniforms.uvAnimationScrollYOffset.value=f}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(f){this.uniforms.uvAnimationRotationPhase.value=f}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(f){this._ignoreVertexColor=f,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(f){this._v0CompatShade=f,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(f){this._debugMode=f,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(f){this._outlineWidthMode=f,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(f){this._isOutline=f,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(f){this._uploadUniformsWorkaround(),this._updateUVAnimation(f)}copy(f){return super.copy(f),this.map=f.map,this.normalMap=f.normalMap,this.emissiveMap=f.emissiveMap,this.shadeMultiplyTexture=f.shadeMultiplyTexture,this.shadingShiftTexture=f.shadingShiftTexture,this.matcapTexture=f.matcapTexture,this.rimMultiplyTexture=f.rimMultiplyTexture,this.outlineWidthMultiplyTexture=f.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=f.uvAnimationMaskTexture,this.normalMapType=f.normalMapType,this.uvAnimationScrollXSpeedFactor=f.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=f.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=f.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=f.ignoreVertexColor,this.v0CompatShade=f.v0CompatShade,this.debugMode=f.debugMode,this.outlineWidthMode=f.outlineWidthMode,this.isOutline=f.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(f){this.uniforms.uvAnimationScrollXOffset.value+=f*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=f*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=f*this.uvAnimationRotationSpeedFactor,this.uniforms.alphaTest.value=this.alphaTest,this.uniformsNeedUpdate=!0}_uploadUniformsWorkaround(){this.uniforms.opacity.value=this.opacity,this._updateTextureMatrix(this.uniforms.map,this.uniforms.mapUvTransform),this._updateTextureMatrix(this.uniforms.normalMap,this.uniforms.normalMapUvTransform),this._updateTextureMatrix(this.uniforms.emissiveMap,this.uniforms.emissiveMapUvTransform),this._updateTextureMatrix(this.uniforms.shadeMultiplyTexture,this.uniforms.shadeMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.shadingShiftTexture,this.uniforms.shadingShiftTextureUvTransform),this._updateTextureMatrix(this.uniforms.matcapTexture,this.uniforms.matcapTextureUvTransform),this._updateTextureMatrix(this.uniforms.rimMultiplyTexture,this.uniforms.rimMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.outlineWidthMultiplyTexture,this.uniforms.outlineWidthMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.uvAnimationMaskTexture,this.uniforms.uvAnimationMaskTextureUvTransform),this.uniformsNeedUpdate=!0}_generateDefines(){const f=parseInt(REVISION,10),r=this.outlineWidthMultiplyTexture!==null,c=this.map!==null||this.normalMap!==null||this.emissiveMap!==null||this.shadeMultiplyTexture!==null||this.shadingShiftTexture!==null||this.rimMultiplyTexture!==null||this.uvAnimationMaskTexture!==null;return{THREE_VRM_THREE_REVISION:f,OUTLINE:this._isOutline,MTOON_USE_UV:r||c,MTOON_UVS_VERTEX_ONLY:r&&!c,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:this.shadeMultiplyTexture!==null,USE_SHADINGSHIFTTEXTURE:this.shadingShiftTexture!==null,USE_MATCAPTEXTURE:this.matcapTexture!==null,USE_RIMMULTIPLYTEXTURE:this.rimMultiplyTexture!==null,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&this.outlineWidthMultiplyTexture!==null,USE_UVANIMATIONMASKTEXTURE:this.uvAnimationMaskTexture!==null,IGNORE_VERTEX_COLOR:this._ignoreVertexColor===!0,DEBUG_NORMAL:this._debugMode==="normal",DEBUG_LITSHADERATE:this._debugMode==="litShadeRate",DEBUG_UV:this._debugMode==="uv",OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===MToonMaterialOutlineWidthMode.ScreenCoordinates}}_updateTextureMatrix(f,r){f.value&&(f.value.matrixAutoUpdate&&f.value.updateMatrix(),r.value.copy(f.value.matrix))}},POSSIBLE_SPEC_VERSIONS6=new Set(["1.0","1.0-beta"]),_MToonMaterialLoaderPlugin=class kt{get name(){return kt.EXTENSION_NAME}constructor(r,c={}){var d,l,m,s;this.parser=r,this.materialType=(d=c.materialType)!=null?d:MToonMaterial,this.renderOrderOffset=(l=c.renderOrderOffset)!=null?l:0,this.v0CompatShade=(m=c.v0CompatShade)!=null?m:!1,this.debugMode=(s=c.debugMode)!=null?s:"none",this._mToonMaterialSet=new Set}beforeRoot(){return __async3(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(r){return __async3(this,null,function*(){r.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)})}getMaterialType(r){return this._getMToonExtension(r)?this.materialType:null}extendMaterialParams(r,c){const d=this._getMToonExtension(r);return d?this._extendMaterialParams(d,c):null}loadMesh(r){return __async3(this,null,function*(){var c;const d=this.parser,m=(c=d.json.meshes)==null?void 0:c[r];if(m==null)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${r}] of glTF but the mesh doesn't exist`);const s=m.primitives,h=yield d.loadMesh(r);if(s.length===1){const p=h,a=s[0].material;a!=null&&this._setupPrimitive(p,a)}else{const p=h;for(let a=0;a{var s;this._getMToonExtension(m)&&((s=l.extensions)!=null&&s.KHR_materials_unlit)&&delete l.extensions.KHR_materials_unlit})}_getMToonExtension(r){var c,d;const s=(c=this.parser.json.materials)==null?void 0:c[r];if(s==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${r}] of glTF but the material doesn't exist`);return}const h=(d=s.extensions)==null?void 0:d[kt.EXTENSION_NAME];if(h==null)return;const p=h.specVersion;if(!POSSIBLE_SPEC_VERSIONS6.has(p)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${kt.EXTENSION_NAME} specVersion "${p}"`);return}return h}_extendMaterialParams(r,c){return __async3(this,null,function*(){var d;delete c.metalness,delete c.roughness;const l=new GLTFMToonMaterialParamsAssignHelper(this.parser,c);l.assignPrimitive("transparentWithZWrite",r.transparentWithZWrite),l.assignColor("shadeColorFactor",r.shadeColorFactor),l.assignTexture("shadeMultiplyTexture",r.shadeMultiplyTexture,!0),l.assignPrimitive("shadingShiftFactor",r.shadingShiftFactor),l.assignTexture("shadingShiftTexture",r.shadingShiftTexture,!0),l.assignPrimitive("shadingShiftTextureScale",(d=r.shadingShiftTexture)==null?void 0:d.scale),l.assignPrimitive("shadingToonyFactor",r.shadingToonyFactor),l.assignPrimitive("giEqualizationFactor",r.giEqualizationFactor),l.assignColor("matcapFactor",r.matcapFactor),l.assignTexture("matcapTexture",r.matcapTexture,!0),l.assignColor("parametricRimColorFactor",r.parametricRimColorFactor),l.assignTexture("rimMultiplyTexture",r.rimMultiplyTexture,!0),l.assignPrimitive("rimLightingMixFactor",r.rimLightingMixFactor),l.assignPrimitive("parametricRimFresnelPowerFactor",r.parametricRimFresnelPowerFactor),l.assignPrimitive("parametricRimLiftFactor",r.parametricRimLiftFactor),l.assignPrimitive("outlineWidthMode",r.outlineWidthMode),l.assignPrimitive("outlineWidthFactor",r.outlineWidthFactor),l.assignTexture("outlineWidthMultiplyTexture",r.outlineWidthMultiplyTexture,!1),l.assignColor("outlineColorFactor",r.outlineColorFactor),l.assignPrimitive("outlineLightingMixFactor",r.outlineLightingMixFactor),l.assignTexture("uvAnimationMaskTexture",r.uvAnimationMaskTexture,!1),l.assignPrimitive("uvAnimationScrollXSpeedFactor",r.uvAnimationScrollXSpeedFactor),l.assignPrimitive("uvAnimationScrollYSpeedFactor",r.uvAnimationScrollYSpeedFactor),l.assignPrimitive("uvAnimationRotationSpeedFactor",r.uvAnimationRotationSpeedFactor),l.assignPrimitive("v0CompatShade",this.v0CompatShade),l.assignPrimitive("debugMode",this.debugMode),yield l.pending})}_setupPrimitive(r,c){const d=this._getMToonExtension(c);if(d){const l=this._parseRenderOrder(d);r.renderOrder=l+this.renderOrderOffset,this._generateOutline(r),this._addToMaterialSet(r);return}}_shouldGenerateOutline(r){return typeof r.outlineWidthMode=="string"&&r.outlineWidthMode!=="none"&&typeof r.outlineWidthFactor=="number"&&r.outlineWidthFactor>0}_generateOutline(r){const c=r.material;if(!(c instanceof Material)||!this._shouldGenerateOutline(c))return;r.material=[c];const d=c.clone();d.name+=" (Outline)",d.isOutline=!0,d.side=BackSide,r.material.push(d);const l=r.geometry,m=l.index?l.index.count:l.attributes.position.count/3;l.addGroup(0,m,0),l.addGroup(0,m,1)}_addToMaterialSet(r){const c=r.material,d=new Set;Array.isArray(c)?c.forEach(l=>d.add(l)):d.add(c);for(const l of d)this._mToonMaterialSet.add(l)}_parseRenderOrder(r){var c;return(r.transparentWithZWrite?0:19)+((c=r.renderQueueOffsetNumber)!=null?c:0)}};_MToonMaterialLoaderPlugin.EXTENSION_NAME="VRMC_materials_mtoon";var MToonMaterialLoaderPlugin=_MToonMaterialLoaderPlugin,__async4=(f,r,c)=>new Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())}),_VRMMaterialsHDREmissiveMultiplierLoaderPlugin=class jt{get name(){return jt.EXTENSION_NAME}constructor(r){this.parser=r}extendMaterialParams(r,c){return __async4(this,null,function*(){const d=this._getHDREmissiveMultiplierExtension(r);if(d==null)return;console.warn("VRMMaterialsHDREmissiveMultiplierLoaderPlugin: `VRMC_materials_hdr_emissiveMultiplier` is archived. Use `KHR_materials_emissive_strength` instead.");const l=d.emissiveMultiplier;c.emissiveIntensity=l})}_getHDREmissiveMultiplierExtension(r){var c,d;const s=(c=this.parser.json.materials)==null?void 0:c[r];if(s==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${r}] of glTF but the material doesn't exist`);return}const h=(d=s.extensions)==null?void 0:d[jt.EXTENSION_NAME];if(h!=null)return h}};_VRMMaterialsHDREmissiveMultiplierLoaderPlugin.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var VRMMaterialsHDREmissiveMultiplierLoaderPlugin=_VRMMaterialsHDREmissiveMultiplierLoaderPlugin,__defProp2=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols2=Object.getOwnPropertySymbols,__hasOwnProp2=Object.prototype.hasOwnProperty,__propIsEnum2=Object.prototype.propertyIsEnumerable,__defNormalProp2=(f,r,c)=>r in f?__defProp2(f,r,{enumerable:!0,configurable:!0,writable:!0,value:c}):f[r]=c,__spreadValues2=(f,r)=>{for(var c in r||(r={}))__hasOwnProp2.call(r,c)&&__defNormalProp2(f,c,r[c]);if(__getOwnPropSymbols2)for(var c of __getOwnPropSymbols2(r))__propIsEnum2.call(r,c)&&__defNormalProp2(f,c,r[c]);return f},__spreadProps=(f,r)=>__defProps(f,__getOwnPropDescs(r)),__async5=(f,r,c)=>new Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())});function gammaEOTF(f){return Math.pow(f,2.2)}var VRMMaterialsV0CompatPlugin=class{get name(){return"VRMMaterialsV0CompatPlugin"}constructor(f){var r;this.parser=f,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;const c=this.parser.json;c.extensionsUsed=(r=c.extensionsUsed)!=null?r:[],c.extensionsUsed.indexOf("KHR_texture_transform")===-1&&c.extensionsUsed.push("KHR_texture_transform")}beforeRoot(){return __async5(this,null,function*(){var f;const r=this.parser.json,c=(f=r.extensions)==null?void 0:f.VRM,d=c==null?void 0:c.materialProperties;d&&(this._populateRenderQueueMap(d),d.forEach((l,m)=>{var s,h;const p=(s=r.materials)==null?void 0:s[m];if(p==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${m}] of glTF but the material doesn't exist`);return}if(l.shader==="VRM/MToon"){const a=this._parseV0MToonProperties(l,p);r.materials[m]=a}else if((h=l.shader)!=null&&h.startsWith("VRM/Unlit")){const a=this._parseV0UnlitProperties(l,p);r.materials[m]=a}else l.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${l.shader}`)}))})}_parseV0MToonProperties(f,r){var c,d,l,m,s,h,p,a,o,t,e,n,i,u,g,b,y,_,v,w,T,A,E,x,P,L,F,$,k,q,D,U,J,Y,Z,te,he,Me,Te,ue,xe,_e,Ce,ze,Se,De,Re,Ae,we,Fe,Ue,Be,We,qe,je;const Ve=(d=(c=f.keywordMap)==null?void 0:c._ALPHABLEND_ON)!=null?d:!1,$e=((l=f.floatProperties)==null?void 0:l._ZWrite)===1&&Ve,Ye=this._v0ParseRenderQueue(f),le=(s=(m=f.keywordMap)==null?void 0:m._ALPHATEST_ON)!=null?s:!1,pt=Ve?"BLEND":le?"MASK":"OPAQUE",ut=le?(p=(h=f.floatProperties)==null?void 0:h._Cutoff)!=null?p:.5:void 0,Ke=((o=(a=f.floatProperties)==null?void 0:a._CullMode)!=null?o:2)===0,He=this._portTextureTransform(f),lt=((e=(t=f.vectorProperties)==null?void 0:t._Color)!=null?e:[1,1,1,1]).map((ae,ve)=>ve===3?ae:gammaEOTF(ae)),Le=(n=f.textureProperties)==null?void 0:n._MainTex,nt=Le!=null?{index:Le,extensions:__spreadValues2({},He)}:void 0,ie=(u=(i=f.floatProperties)==null?void 0:i._BumpScale)!=null?u:1,Je=(g=f.textureProperties)==null?void 0:g._BumpMap,At=Je!=null?{index:Je,scale:ie,extensions:__spreadValues2({},He)}:void 0,Et=((y=(b=f.vectorProperties)==null?void 0:b._EmissionColor)!=null?y:[0,0,0,1]).map(gammaEOTF),Xe=(_=f.textureProperties)==null?void 0:_._EmissionMap,ye=Xe!=null?{index:Xe,extensions:__spreadValues2({},He)}:void 0,rt=((w=(v=f.vectorProperties)==null?void 0:v._ShadeColor)!=null?w:[.97,.81,.86,1]).map(gammaEOTF),ct=(T=f.textureProperties)==null?void 0:T._ShadeTexture,it=ct!=null?{index:ct,extensions:__spreadValues2({},He)}:void 0;let oe=(E=(A=f.floatProperties)==null?void 0:A._ShadeShift)!=null?E:0,re=(P=(x=f.floatProperties)==null?void 0:x._ShadeToony)!=null?P:.9;re=MathUtils.lerp(re,1,.5+.5*oe),oe=-oe-(1-re);const se=(F=(L=f.floatProperties)==null?void 0:L._IndirectLightIntensity)!=null?F:.1,ft=se?1-se:void 0,et=($=f.textureProperties)==null?void 0:$._SphereAdd,mt=et!=null?[1,1,1]:void 0,gt=et!=null?{index:et}:void 0,bt=(q=(k=f.floatProperties)==null?void 0:k._RimLightingMix)!=null?q:0,dt=(D=f.textureProperties)==null?void 0:D._RimTexture,yt=dt!=null?{index:dt,extensions:__spreadValues2({},He)}:void 0,_t=((J=(U=f.vectorProperties)==null?void 0:U._RimColor)!=null?J:[0,0,0,1]).map(gammaEOTF),vt=(Z=(Y=f.floatProperties)==null?void 0:Y._RimFresnelPower)!=null?Z:1,wt=(he=(te=f.floatProperties)==null?void 0:te._RimLift)!=null?he:0,xt=["none","worldCoordinates","screenCoordinates"][(Te=(Me=f.floatProperties)==null?void 0:Me._OutlineWidthMode)!=null?Te:0];let ot=(xe=(ue=f.floatProperties)==null?void 0:ue._OutlineWidth)!=null?xe:0;ot=.01*ot;const ht=(_e=f.textureProperties)==null?void 0:_e._OutlineWidthTexture,Tt=ht!=null?{index:ht,extensions:__spreadValues2({},He)}:void 0,M=((ze=(Ce=f.vectorProperties)==null?void 0:Ce._OutlineColor)!=null?ze:[0,0,0]).map(gammaEOTF),N=((De=(Se=f.floatProperties)==null?void 0:Se._OutlineColorMode)!=null?De:0)===1?(Ae=(Re=f.floatProperties)==null?void 0:Re._OutlineLightingMix)!=null?Ae:1:0,V=(we=f.textureProperties)==null?void 0:we._UvAnimMaskTexture,j=V!=null?{index:V,extensions:__spreadValues2({},He)}:void 0,H=(Ue=(Fe=f.floatProperties)==null?void 0:Fe._UvAnimScrollX)!=null?Ue:0;let X=(We=(Be=f.floatProperties)==null?void 0:Be._UvAnimScrollY)!=null?We:0;X!=null&&(X=-X);const ee=(je=(qe=f.floatProperties)==null?void 0:qe._UvAnimRotation)!=null?je:0,K={specVersion:"1.0",transparentWithZWrite:$e,renderQueueOffsetNumber:Ye,shadeColorFactor:rt,shadeMultiplyTexture:it,shadingShiftFactor:oe,shadingToonyFactor:re,giEqualizationFactor:ft,matcapFactor:mt,matcapTexture:gt,rimLightingMixFactor:bt,rimMultiplyTexture:yt,parametricRimColorFactor:_t,parametricRimFresnelPowerFactor:vt,parametricRimLiftFactor:wt,outlineWidthMode:xt,outlineWidthFactor:ot,outlineWidthMultiplyTexture:Tt,outlineColorFactor:M,outlineLightingMixFactor:N,uvAnimationMaskTexture:j,uvAnimationScrollXSpeedFactor:H,uvAnimationScrollYSpeedFactor:X,uvAnimationRotationSpeedFactor:ee};return __spreadProps(__spreadValues2({},r),{pbrMetallicRoughness:{baseColorFactor:lt,baseColorTexture:nt},normalTexture:At,emissiveTexture:ye,emissiveFactor:Et,alphaMode:pt,alphaCutoff:ut,doubleSided:Ke,extensions:{VRMC_materials_mtoon:K}})}_parseV0UnlitProperties(f,r){var c,d,l,m,s;const h=f.shader==="VRM/UnlitTransparentZWrite",p=f.shader==="VRM/UnlitTransparent"||h,a=this._v0ParseRenderQueue(f),o=f.shader==="VRM/UnlitCutout",t=p?"BLEND":o?"MASK":"OPAQUE",e=o?(d=(c=f.floatProperties)==null?void 0:c._Cutoff)!=null?d:.5:void 0,n=this._portTextureTransform(f),i=((m=(l=f.vectorProperties)==null?void 0:l._Color)!=null?m:[1,1,1,1]).map(gammaEOTF),u=(s=f.textureProperties)==null?void 0:s._MainTex,g=u!=null?{index:u,extensions:__spreadValues2({},n)}:void 0,b={specVersion:"1.0",transparentWithZWrite:h,renderQueueOffsetNumber:a,shadeColorFactor:i,shadeMultiplyTexture:g};return __spreadProps(__spreadValues2({},r),{pbrMetallicRoughness:{baseColorFactor:i,baseColorTexture:g},alphaMode:t,alphaCutoff:e,extensions:{VRMC_materials_mtoon:b}})}_portTextureTransform(f){var r,c,d,l,m;const s=(r=f.vectorProperties)==null?void 0:r._MainTex;if(s==null)return{};const h=[(c=s==null?void 0:s[0])!=null?c:0,(d=s==null?void 0:s[1])!=null?d:0],p=[(l=s==null?void 0:s[2])!=null?l:1,(m=s==null?void 0:s[3])!=null?m:1];return h[1]=1-p[1]-h[1],{KHR_texture_transform:{offset:h,scale:p}}}_v0ParseRenderQueue(f){var r,c;const d=f.shader==="VRM/UnlitTransparentZWrite",l=((r=f.keywordMap)==null?void 0:r._ALPHABLEND_ON)!=null||f.shader==="VRM/UnlitTransparent"||d,m=((c=f.floatProperties)==null?void 0:c._ZWrite)===1||d;let s=0;if(l){const h=f.renderQueue;h!=null&&(m?s=this._renderQueueMapTransparentZWrite.get(h):s=this._renderQueueMapTransparent.get(h))}return s}_populateRenderQueueMap(f){const r=new Set,c=new Set;f.forEach(d=>{var l,m;const s=d.shader==="VRM/UnlitTransparentZWrite",h=((l=d.keywordMap)==null?void 0:l._ALPHABLEND_ON)!=null||d.shader==="VRM/UnlitTransparent"||s,p=((m=d.floatProperties)==null?void 0:m._ZWrite)===1||s;if(h){const a=d.renderQueue;a!=null&&(p?c.add(a):r.add(a))}}),r.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${r.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),c.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${c.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(r).sort().forEach((d,l)=>{const m=Math.min(Math.max(l-r.size+1,-9),0);this._renderQueueMapTransparent.set(d,m)}),Array.from(c).sort().forEach((d,l)=>{const m=Math.min(Math.max(l,0),9);this._renderQueueMapTransparentZWrite.set(d,m)})}},__async6=(f,r,c)=>new Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())}),_v3A6=new Vector3,VRMNodeConstraintHelper=class extends Group{constructor(f){super(),this._attrPosition=new BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(DynamicDrawUsage);const r=new BufferGeometry;r.setAttribute("position",this._attrPosition);const c=new LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new Line(r,c),this.add(this._line),this.constraint=f}updateMatrixWorld(f){_v3A6.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,_v3A6.x,_v3A6.y,_v3A6.z),this.constraint.source&&_v3A6.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,_v3A6.x,_v3A6.y,_v3A6.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(f)}};function decomposePosition(f,r){return r.set(f.elements[12],f.elements[13],f.elements[14])}var _v3A22=new Vector3,_v3B4=new Vector3;function decomposeRotation(f,r){return f.decompose(_v3A22,r,_v3B4),r}function quatInvertCompat2(f){return f.invert?f.invert():f.inverse(),f}var VRMNodeConstraint=class{constructor(f,r){this.destination=f,this.source=r,this.weight=1}},_v3A32=new Vector3,_v3B22=new Vector3,_v3C2=new Vector3,_quatA7=new Quaternion,_quatB4=new Quaternion,_quatC2=new Quaternion,VRMAimConstraint=class extends VRMNodeConstraint{get aimAxis(){return this._aimAxis}set aimAxis(f){this._aimAxis=f,this._v3AimAxis.set(f==="PositiveX"?1:f==="NegativeX"?-1:0,f==="PositiveY"?1:f==="NegativeY"?-1:0,f==="PositiveZ"?1:f==="NegativeZ"?-1:0)}get dependencies(){const f=new Set([this.source]);return this.destination.parent&&f.add(this.destination.parent),f}constructor(f,r){super(f,r),this._aimAxis="PositiveX",this._v3AimAxis=new Vector3(1,0,0),this._dstRestQuat=new Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);const f=_quatA7.identity(),r=_quatB4.identity();this.destination.parent&&(decomposeRotation(this.destination.parent.matrixWorld,f),quatInvertCompat2(r.copy(f)));const c=_v3A32.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(f),d=decomposePosition(this.source.matrixWorld,_v3B22).sub(decomposePosition(this.destination.matrixWorld,_v3C2)).normalize(),l=_quatC2.setFromUnitVectors(c,d).premultiply(r).multiply(f).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(l,this.weight)}};function traverseAncestorsFromRoot(f,r){const c=[f];let d=f.parent;for(;d!==null;)c.unshift(d),d=d.parent;c.forEach(l=>{r(l)})}var VRMNodeConstraintManager=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(f){this._constraints.add(f);let r=this._objectConstraintsMap.get(f.destination);r==null&&(r=new Set,this._objectConstraintsMap.set(f.destination,r)),r.add(f)}deleteConstraint(f){this._constraints.delete(f),this._objectConstraintsMap.get(f.destination).delete(f)}setInitState(){const f=new Set,r=new Set;for(const c of this._constraints)this._processConstraint(c,f,r,d=>d.setInitState())}update(){const f=new Set,r=new Set;for(const c of this._constraints)this._processConstraint(c,f,r,d=>d.update())}_processConstraint(f,r,c,d){if(c.has(f))return;if(r.has(f))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");r.add(f);const l=f.dependencies;for(const m of l)traverseAncestorsFromRoot(m,s=>{const h=this._objectConstraintsMap.get(s);if(h)for(const p of h)this._processConstraint(p,r,c,d)});d(f),c.add(f)}},_quatA22=new Quaternion,_quatB22=new Quaternion,VRMRotationConstraint=class extends VRMNodeConstraint{get dependencies(){return new Set([this.source])}constructor(f,r){super(f,r),this._dstRestQuat=new Quaternion,this._invSrcRestQuat=new Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),quatInvertCompat2(this._invSrcRestQuat.copy(this.source.quaternion))}update(){const f=_quatA22.copy(this._invSrcRestQuat).multiply(this.source.quaternion),r=_quatB22.copy(this._dstRestQuat).multiply(f);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}},_v3A42=new Vector3,_quatA32=new Quaternion,_quatB32=new Quaternion,VRMRollConstraint=class extends VRMNodeConstraint{get rollAxis(){return this._rollAxis}set rollAxis(f){this._rollAxis=f,this._v3RollAxis.set(f==="X"?1:0,f==="Y"?1:0,f==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(f,r){super(f,r),this._rollAxis="X",this._v3RollAxis=new Vector3(1,0,0),this._dstRestQuat=new Quaternion,this._invDstRestQuat=new Quaternion,this._invSrcRestQuatMulDstRestQuat=new Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),quatInvertCompat2(this._invDstRestQuat.copy(this._dstRestQuat)),quatInvertCompat2(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){const f=_quatA32.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),r=_v3A42.copy(this._v3RollAxis).applyQuaternion(f),d=_quatB32.setFromUnitVectors(r,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(f);this.destination.quaternion.copy(this._dstRestQuat).slerp(d,this.weight)}},POSSIBLE_SPEC_VERSIONS7=new Set(["1.0","1.0-beta"]),_VRMNodeConstraintLoaderPlugin=class Rt{get name(){return Rt.EXTENSION_NAME}constructor(r,c){this.parser=r,this.helperRoot=c==null?void 0:c.helperRoot}afterRoot(r){return __async6(this,null,function*(){r.userData.vrmNodeConstraintManager=yield this._import(r)})}_import(r){return __async6(this,null,function*(){var c;const d=this.parser.json;if(!(((c=d.extensionsUsed)==null?void 0:c.indexOf(Rt.EXTENSION_NAME))!==-1))return null;const m=new VRMNodeConstraintManager,s=yield this.parser.getDependencies("node");return s.forEach((h,p)=>{var a;const o=d.nodes[p],t=(a=o==null?void 0:o.extensions)==null?void 0:a[Rt.EXTENSION_NAME];if(t==null)return;const e=t.specVersion;if(!POSSIBLE_SPEC_VERSIONS7.has(e)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${Rt.EXTENSION_NAME} specVersion "${e}"`);return}const n=t.constraint;if(n.roll!=null){const i=this._importRollConstraint(h,s,n.roll);m.addConstraint(i)}else if(n.aim!=null){const i=this._importAimConstraint(h,s,n.aim);m.addConstraint(i)}else if(n.rotation!=null){const i=this._importRotationConstraint(h,s,n.rotation);m.addConstraint(i)}}),r.scene.updateMatrixWorld(),m.setInitState(),m})}_importRollConstraint(r,c,d){const{source:l,rollAxis:m,weight:s}=d,h=c[l],p=new VRMRollConstraint(r,h);if(m!=null&&(p.rollAxis=m),s!=null&&(p.weight=s),this.helperRoot){const a=new VRMNodeConstraintHelper(p);this.helperRoot.add(a)}return p}_importAimConstraint(r,c,d){const{source:l,aimAxis:m,weight:s}=d,h=c[l],p=new VRMAimConstraint(r,h);if(m!=null&&(p.aimAxis=m),s!=null&&(p.weight=s),this.helperRoot){const a=new VRMNodeConstraintHelper(p);this.helperRoot.add(a)}return p}_importRotationConstraint(r,c,d){const{source:l,weight:m}=d,s=c[l],h=new VRMRotationConstraint(r,s);if(m!=null&&(h.weight=m),this.helperRoot){const p=new VRMNodeConstraintHelper(h);this.helperRoot.add(p)}return h}};_VRMNodeConstraintLoaderPlugin.EXTENSION_NAME="VRMC_node_constraint";var VRMNodeConstraintLoaderPlugin=_VRMNodeConstraintLoaderPlugin,__async7=(f,r,c)=>new Promise((d,l)=>{var m=p=>{try{h(c.next(p))}catch(a){l(a)}},s=p=>{try{h(c.throw(p))}catch(a){l(a)}},h=p=>p.done?d(p.value):Promise.resolve(p.value).then(m,s);h((c=c.apply(f,r)).next())}),VRMSpringBoneColliderShape=class{},_v3A7=new Vector3,_v3B5=new Vector3,VRMSpringBoneColliderShapeCapsule=class extends VRMSpringBoneColliderShape{get type(){return"capsule"}constructor(f){var r,c,d,l;super(),this.offset=(r=f==null?void 0:f.offset)!=null?r:new Vector3(0,0,0),this.tail=(c=f==null?void 0:f.tail)!=null?c:new Vector3(0,0,0),this.radius=(d=f==null?void 0:f.radius)!=null?d:0,this.inside=(l=f==null?void 0:f.inside)!=null?l:!1}calculateCollision(f,r,c,d){_v3A7.setFromMatrixPosition(f),_v3B5.subVectors(this.tail,this.offset).applyMatrix4(f),_v3B5.sub(_v3A7);const l=_v3B5.lengthSq();d.copy(r).sub(_v3A7);const m=_v3B5.dot(d);m<=0||(l<=m||_v3B5.multiplyScalar(m/l),d.sub(_v3B5));const s=d.length(),h=this.inside?this.radius-c-s:s-c-this.radius;return h<0&&(d.multiplyScalar(1/s),this.inside&&d.negate()),h}},_v3A23=new Vector3,_mat3A=new Matrix3,VRMSpringBoneColliderShapePlane=class extends VRMSpringBoneColliderShape{get type(){return"plane"}constructor(f){var r,c;super(),this.offset=(r=f==null?void 0:f.offset)!=null?r:new Vector3(0,0,0),this.normal=(c=f==null?void 0:f.normal)!=null?c:new Vector3(0,0,1)}calculateCollision(f,r,c,d){d.setFromMatrixPosition(f),d.negate().add(r),_mat3A.getNormalMatrix(f),_v3A23.copy(this.normal).applyNormalMatrix(_mat3A).normalize();const l=d.dot(_v3A23)-c;return d.copy(_v3A23),l}},_v3A33=new Vector3,VRMSpringBoneColliderShapeSphere=class extends VRMSpringBoneColliderShape{get type(){return"sphere"}constructor(f){var r,c,d;super(),this.offset=(r=f==null?void 0:f.offset)!=null?r:new Vector3(0,0,0),this.radius=(c=f==null?void 0:f.radius)!=null?c:0,this.inside=(d=f==null?void 0:f.inside)!=null?d:!1}calculateCollision(f,r,c,d){d.subVectors(r,_v3A33.setFromMatrixPosition(f));const l=d.length(),m=this.inside?this.radius-c-l:l-c-this.radius;return m<0&&(d.multiplyScalar(1/l),this.inside&&d.negate()),m}},_v3A43=new Vector3,ColliderShapeCapsuleBufferGeometry=class extends BufferGeometry{constructor(f){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new Vector3,this._currentTail=new Vector3,this._shape=f,this._attrPos=new BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new BufferAttribute(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let f=!1;const r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,f=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),f=!0);const c=_v3A43.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(c)>1e-10&&(this._currentTail.copy(c),f=!0),f&&this._buildPosition()}_buildPosition(){_v3A43.copy(this._currentTail).sub(this._currentOffset);const f=_v3A43.length()/this._currentRadius;for(let d=0;d<=16;d++){const l=d/16*Math.PI;this._attrPos.setXYZ(d,-Math.sin(l),-Math.cos(l),0),this._attrPos.setXYZ(17+d,f+Math.sin(l),Math.cos(l),0),this._attrPos.setXYZ(34+d,-Math.sin(l),0,-Math.cos(l)),this._attrPos.setXYZ(51+d,f+Math.sin(l),0,Math.cos(l))}for(let d=0;d<32;d++){const l=d/16*Math.PI;this._attrPos.setXYZ(68+d,0,Math.sin(l),Math.cos(l)),this._attrPos.setXYZ(100+d,f,Math.sin(l),Math.cos(l))}const r=Math.atan2(_v3A43.y,Math.sqrt(_v3A43.x*_v3A43.x+_v3A43.z*_v3A43.z)),c=-Math.atan2(_v3A43.z,_v3A43.x);this.rotateZ(r),this.rotateY(c),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let f=0;f<34;f++){const r=(f+1)%34;this._attrIndex.setXY(f*2,f,r),this._attrIndex.setXY(68+f*2,34+f,34+r)}for(let f=0;f<32;f++){const r=(f+1)%32;this._attrIndex.setXY(136+f*2,68+f,68+r),this._attrIndex.setXY(200+f*2,100+f,100+r)}this._attrIndex.needsUpdate=!0}},ColliderShapePlaneBufferGeometry=class extends BufferGeometry{constructor(f){super(),this.worldScale=1,this._currentOffset=new Vector3,this._currentNormal=new Vector3,this._shape=f,this._attrPos=new BufferAttribute(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new BufferAttribute(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let f=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),f=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),f=!0),f&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}},ColliderShapeSphereBufferGeometry=class extends BufferGeometry{constructor(f){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new Vector3,this._shape=f,this._attrPos=new BufferAttribute(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new BufferAttribute(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let f=!1;const r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,f=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),f=!0),f&&this._buildPosition()}_buildPosition(){for(let f=0;f<32;f++){const r=f/16*Math.PI;this._attrPos.setXYZ(f,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+f,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+f,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let f=0;f<32;f++){const r=(f+1)%32;this._attrIndex.setXY(f*2,f,r),this._attrIndex.setXY(64+f*2,32+f,32+r),this._attrIndex.setXY(128+f*2,64+f,64+r)}this._attrIndex.needsUpdate=!0}},_v3A52=new Vector3,VRMSpringBoneColliderHelper=class extends Group{constructor(f){if(super(),this.matrixAutoUpdate=!1,this.collider=f,this.collider.shape instanceof VRMSpringBoneColliderShapeSphere)this._geometry=new ColliderShapeSphereBufferGeometry(this.collider.shape);else if(this.collider.shape instanceof VRMSpringBoneColliderShapeCapsule)this._geometry=new ColliderShapeCapsuleBufferGeometry(this.collider.shape);else if(this.collider.shape instanceof VRMSpringBoneColliderShapePlane)this._geometry=new ColliderShapePlaneBufferGeometry(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");const r=new LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new LineSegments(this._geometry,r),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(f){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);const r=this.matrix.elements;this._geometry.worldScale=_v3A52.set(r[0],r[1],r[2]).length(),this._geometry.update(),super.updateMatrixWorld(f)}},SpringBoneBufferGeometry=class extends BufferGeometry{constructor(f){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new Vector3,this._springBone=f,this._attrPos=new BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let f=!1;const r=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,f=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),f=!0),f&&this._buildPosition()}_buildPosition(){for(let f=0;f<32;f++){const r=f/16*Math.PI;this._attrPos.setXYZ(f,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+f,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+f,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let f=0;f<32;f++){const r=(f+1)%32;this._attrIndex.setXY(f*2,f,r),this._attrIndex.setXY(64+f*2,32+f,32+r),this._attrIndex.setXY(128+f*2,64+f,64+r)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},_v3A62=new Vector3,VRMSpringBoneJointHelper=class extends Group{constructor(f){super(),this.matrixAutoUpdate=!1,this.springBone=f,this._geometry=new SpringBoneBufferGeometry(this.springBone);const r=new LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new LineSegments(this._geometry,r),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(f){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);const r=this.matrix.elements;this._geometry.worldScale=_v3A62.set(r[0],r[1],r[2]).length(),this._geometry.update(),super.updateMatrixWorld(f)}},VRMSpringBoneCollider=class extends Object3D{constructor(f){super(),this.colliderMatrix=new Matrix4,this.shape=f}updateWorldMatrix(f,r){super.updateWorldMatrix(f,r),updateColliderMatrix(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function updateColliderMatrix(f,r,c){const d=r.elements;f.copy(r),c&&(f.elements[12]=d[0]*c.x+d[4]*c.y+d[8]*c.z+d[12],f.elements[13]=d[1]*c.x+d[5]*c.y+d[9]*c.z+d[13],f.elements[14]=d[2]*c.x+d[6]*c.y+d[10]*c.z+d[14])}var _matA=new Matrix4;function mat4InvertCompat(f){return f.invert?f.invert():f.getInverse(_matA.copy(f)),f}var Matrix4InverseCache=class{constructor(f){this._inverseCache=new Matrix4,this._shouldUpdateInverse=!0,this.matrix=f;const r={set:(c,d,l)=>(this._shouldUpdateInverse=!0,c[d]=l,!0)};this._originalElements=f.elements,f.elements=new Proxy(f.elements,r)}get inverse(){return this._shouldUpdateInverse&&(mat4InvertCompat(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},IDENTITY_MATRIX4=new Matrix4,_v3A72=new Vector3,_v3B23=new Vector3,_worldSpacePosition=new Vector3,_nextTail=new Vector3,_matA2=new Matrix4,VRMSpringBoneJoint=class{constructor(f,r,c={},d=[]){this._currentTail=new Vector3,this._prevTail=new Vector3,this._boneAxis=new Vector3,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new Matrix4,this._initialLocalRotation=new Quaternion,this._initialLocalChildPosition=new Vector3;var l,m,s,h,p,a;this.bone=f,this.bone.matrixAutoUpdate=!1,this.child=r,this.settings={hitRadius:(l=c.hitRadius)!=null?l:0,stiffness:(m=c.stiffness)!=null?m:1,gravityPower:(s=c.gravityPower)!=null?s:0,gravityDir:(p=(h=c.gravityDir)==null?void 0:h.clone())!=null?p:new Vector3(0,-1,0),dragForce:(a=c.dragForce)!=null?a:.4},this.colliderGroups=d}get dependencies(){const f=new Set,r=this.bone.parent;r&&f.add(r);for(let c=0;c{r(l)})}function traverseChildrenUntilConditionMet(f,r){f.children.forEach(c=>{r(c)||traverseChildrenUntilConditionMet(c,r)})}function lowestCommonAncestor(f){var r;const c=new Map;for(const d of f){let l=d;do{const m=((r=c.get(l))!=null?r:0)+1;if(m===f.size)return l;c.set(l,m),l=l.parent}while(l!==null)}return null}var VRMSpringBoneManager=class{constructor(){this._joints=new Set,this._sortedJoints=[],this._hasWarnedCircularDependency=!1,this._ancestors=[],this._objectSpringBonesMap=new Map,this._isSortedJointsDirty=!1,this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){const f=new Set;return this._joints.forEach(r=>{r.colliderGroups.forEach(c=>{f.add(c)})}),Array.from(f)}get colliders(){const f=new Set;return this.colliderGroups.forEach(r=>{r.colliders.forEach(c=>{f.add(c)})}),Array.from(f)}addJoint(f){this._joints.add(f);let r=this._objectSpringBonesMap.get(f.bone);r==null&&(r=new Set,this._objectSpringBonesMap.set(f.bone,r)),r.add(f),this._isSortedJointsDirty=!0}addSpringBone(f){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(f)}deleteJoint(f){this._joints.delete(f),this._objectSpringBonesMap.get(f.bone).delete(f),this._isSortedJointsDirty=!0}deleteSpringBone(f){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(f)}setInitState(){this._sortJoints();for(let f=0;f{var s,h;return((h=(s=this._objectSpringBonesMap.get(m))==null?void 0:s.size)!=null?h:0)>0?!0:(this._ancestors.push(m),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(f,r,c,d,l){if(c.has(f))return;if(r.has(f)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}r.add(f);const m=f.dependencies;for(const s of m){let h=!1,p=null;traverseAncestorsFromRoot2(s,a=>{const o=this._objectSpringBonesMap.get(a);if(o)for(const t of o)h=!0,this._insertJointSort(t,r,c,d,l);else h||(p=a)}),p&&l.add(p)}d.push(f),c.add(f)}_relevantChildrenUpdated(f){var r,c;return((c=(r=this._objectSpringBonesMap.get(f))==null?void 0:r.size)!=null?c:0)>0?!0:(f.updateWorldMatrix(!1,!1),!1)}},EXTENSION_NAME_EXTENDED_COLLIDER="VRMC_springBone_extended_collider",POSSIBLE_SPEC_VERSIONS8=new Set(["1.0","1.0-beta"]),POSSIBLE_SPEC_VERSIONS_EXTENDED_COLLIDERS=new Set(["1.0"]),_VRMSpringBoneLoaderPlugin=class Pt{get name(){return Pt.EXTENSION_NAME}constructor(r,c){var d;this.parser=r,this.jointHelperRoot=c==null?void 0:c.jointHelperRoot,this.colliderHelperRoot=c==null?void 0:c.colliderHelperRoot,this.useExtendedColliders=(d=c==null?void 0:c.useExtendedColliders)!=null?d:!0}afterRoot(r){return __async7(this,null,function*(){r.userData.vrmSpringBoneManager=yield this._import(r)})}_import(r){return __async7(this,null,function*(){const c=yield this._v1Import(r);if(c!=null)return c;const d=yield this._v0Import(r);return d??null})}_v1Import(r){return __async7(this,null,function*(){var c,d,l,m,s;const h=r.parser.json;if(!(((c=h.extensionsUsed)==null?void 0:c.indexOf(Pt.EXTENSION_NAME))!==-1))return null;const a=new VRMSpringBoneManager,o=yield r.parser.getDependencies("node"),t=(d=h.extensions)==null?void 0:d[Pt.EXTENSION_NAME];if(!t)return null;const e=t.specVersion;if(!POSSIBLE_SPEC_VERSIONS8.has(e))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Pt.EXTENSION_NAME} specVersion "${e}"`),null;const n=(l=t.colliders)==null?void 0:l.map((u,g)=>{var b,y,_,v,w,T,A,E,x,P,L,F,$,k,q;const D=o[u.node];if(D==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${g} attempted to use the node #${u.node} but not found`),null;const U=u.shape,J=(b=u.extensions)==null?void 0:b[EXTENSION_NAME_EXTENDED_COLLIDER];if(this.useExtendedColliders&&J!=null){const Y=J.specVersion;if(!POSSIBLE_SPEC_VERSIONS_EXTENDED_COLLIDERS.has(Y))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${EXTENSION_NAME_EXTENDED_COLLIDER} specVersion "${Y}". Fallbacking to the ${Pt.EXTENSION_NAME} definition`);else{const Z=J.shape;if(Z.sphere)return this._importSphereCollider(D,{offset:new Vector3().fromArray((y=Z.sphere.offset)!=null?y:[0,0,0]),radius:(_=Z.sphere.radius)!=null?_:0,inside:(v=Z.sphere.inside)!=null?v:!1});if(Z.capsule)return this._importCapsuleCollider(D,{offset:new Vector3().fromArray((w=Z.capsule.offset)!=null?w:[0,0,0]),radius:(T=Z.capsule.radius)!=null?T:0,tail:new Vector3().fromArray((A=Z.capsule.tail)!=null?A:[0,0,0]),inside:(E=Z.capsule.inside)!=null?E:!1});if(Z.plane)return this._importPlaneCollider(D,{offset:new Vector3().fromArray((x=Z.plane.offset)!=null?x:[0,0,0]),normal:new Vector3().fromArray((P=Z.plane.normal)!=null?P:[0,0,1])})}}if(U.sphere)return this._importSphereCollider(D,{offset:new Vector3().fromArray((L=U.sphere.offset)!=null?L:[0,0,0]),radius:(F=U.sphere.radius)!=null?F:0,inside:!1});if(U.capsule)return this._importCapsuleCollider(D,{offset:new Vector3().fromArray(($=U.capsule.offset)!=null?$:[0,0,0]),radius:(k=U.capsule.radius)!=null?k:0,tail:new Vector3().fromArray((q=U.capsule.tail)!=null?q:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${g} has no valid shape`)}),i=(m=t.colliderGroups)==null?void 0:m.map((u,g)=>{var b;return{colliders:((b=u.colliders)!=null?b:[]).flatMap(_=>{const v=n==null?void 0:n[_];return v??(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${g} attempted to use a collider #${_} but not found`),[])}),name:u.name}});return(s=t.springs)==null||s.forEach((u,g)=>{var b;const y=u.joints,_=(b=u.colliderGroups)==null?void 0:b.map(T=>{const A=i==null?void 0:i[T];if(A==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${g} attempted to use a colliderGroup ${T} but not found`);return A}),v=u.center!=null?o[u.center]:void 0;let w;y.forEach(T=>{if(w){const A=w.node,E=o[A],x=T.node,P=o[x],L={hitRadius:w.hitRadius,dragForce:w.dragForce,gravityPower:w.gravityPower,stiffness:w.stiffness,gravityDir:w.gravityDir!=null?new Vector3().fromArray(w.gravityDir):void 0},F=this._importJoint(E,P,L,_);v&&(F.center=v),a.addJoint(F)}w=T})}),a.setInitState(),a})}_v0Import(r){return __async7(this,null,function*(){var c,d,l;const m=r.parser.json;if(!(((c=m.extensionsUsed)==null?void 0:c.indexOf("VRM"))!==-1))return null;const h=(d=m.extensions)==null?void 0:d.VRM,p=h==null?void 0:h.secondaryAnimation;if(!p)return null;const a=p==null?void 0:p.boneGroups;if(!a)return null;const o=new VRMSpringBoneManager,t=yield r.parser.getDependencies("node"),e=(l=p.colliderGroups)==null?void 0:l.map(n=>{var i;const u=t[n.node];return{colliders:((i=n.colliders)!=null?i:[]).map((b,y)=>{var _,v,w;const T=new Vector3(0,0,0);return b.offset&&T.set((_=b.offset.x)!=null?_:0,(v=b.offset.y)!=null?v:0,b.offset.z?-b.offset.z:0),this._importSphereCollider(u,{offset:T,radius:(w=b.radius)!=null?w:0,inside:!1})})}});return a==null||a.forEach((n,i)=>{const u=n.bones;u&&u.forEach(g=>{var b,y,_,v;const w=t[g],T=new Vector3;n.gravityDir?T.set((b=n.gravityDir.x)!=null?b:0,(y=n.gravityDir.y)!=null?y:0,(_=n.gravityDir.z)!=null?_:0):T.set(0,-1,0);const A=n.center!=null?t[n.center]:void 0,E={hitRadius:n.hitRadius,dragForce:n.dragForce,gravityPower:n.gravityPower,stiffness:n.stiffiness,gravityDir:T},x=(v=n.colliderGroups)==null?void 0:v.map(P=>{const L=e==null?void 0:e[P];if(L==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${i} attempted to use a colliderGroup ${P} but not found`);return L});w.traverse(P=>{var L;const F=(L=P.children[0])!=null?L:null,$=this._importJoint(P,F,E,x);A&&($.center=A),o.addJoint($)})})}),r.scene.updateMatrixWorld(),o.setInitState(),o})}_importJoint(r,c,d,l){const m=new VRMSpringBoneJoint(r,c,d,l);if(this.jointHelperRoot){const s=new VRMSpringBoneJointHelper(m);this.jointHelperRoot.add(s),s.renderOrder=this.jointHelperRoot.renderOrder}return m}_importSphereCollider(r,c){const d=new VRMSpringBoneColliderShapeSphere(c),l=new VRMSpringBoneCollider(d);if(r.add(l),this.colliderHelperRoot){const m=new VRMSpringBoneColliderHelper(l);this.colliderHelperRoot.add(m),m.renderOrder=this.colliderHelperRoot.renderOrder}return l}_importCapsuleCollider(r,c){const d=new VRMSpringBoneColliderShapeCapsule(c),l=new VRMSpringBoneCollider(d);if(r.add(l),this.colliderHelperRoot){const m=new VRMSpringBoneColliderHelper(l);this.colliderHelperRoot.add(m),m.renderOrder=this.colliderHelperRoot.renderOrder}return l}_importPlaneCollider(r,c){const d=new VRMSpringBoneColliderShapePlane(c),l=new VRMSpringBoneCollider(d);if(r.add(l),this.colliderHelperRoot){const m=new VRMSpringBoneColliderHelper(l);this.colliderHelperRoot.add(m),m.renderOrder=this.colliderHelperRoot.renderOrder}return l}};_VRMSpringBoneLoaderPlugin.EXTENSION_NAME="VRMC_springBone";var VRMSpringBoneLoaderPlugin=_VRMSpringBoneLoaderPlugin,VRMLoaderPlugin=class{get name(){return"VRMLoaderPlugin"}constructor(f,r){var c,d,l,m,s,h,p,a,o,t;this.parser=f;const e=r==null?void 0:r.helperRoot,n=r==null?void 0:r.autoUpdateHumanBones;this.expressionPlugin=(c=r==null?void 0:r.expressionPlugin)!=null?c:new VRMExpressionLoaderPlugin(f),this.firstPersonPlugin=(d=r==null?void 0:r.firstPersonPlugin)!=null?d:new VRMFirstPersonLoaderPlugin(f),this.humanoidPlugin=(l=r==null?void 0:r.humanoidPlugin)!=null?l:new VRMHumanoidLoaderPlugin(f,{helperRoot:e,autoUpdateHumanBones:n}),this.lookAtPlugin=(m=r==null?void 0:r.lookAtPlugin)!=null?m:new VRMLookAtLoaderPlugin(f,{helperRoot:e}),this.metaPlugin=(s=r==null?void 0:r.metaPlugin)!=null?s:new VRMMetaLoaderPlugin(f),this.mtoonMaterialPlugin=(h=r==null?void 0:r.mtoonMaterialPlugin)!=null?h:new MToonMaterialLoaderPlugin(f),this.materialsHDREmissiveMultiplierPlugin=(p=r==null?void 0:r.materialsHDREmissiveMultiplierPlugin)!=null?p:new VRMMaterialsHDREmissiveMultiplierLoaderPlugin(f),this.materialsV0CompatPlugin=(a=r==null?void 0:r.materialsV0CompatPlugin)!=null?a:new VRMMaterialsV0CompatPlugin(f),this.springBonePlugin=(o=r==null?void 0:r.springBonePlugin)!=null?o:new VRMSpringBoneLoaderPlugin(f,{colliderHelperRoot:e,jointHelperRoot:e}),this.nodeConstraintPlugin=(t=r==null?void 0:r.nodeConstraintPlugin)!=null?t:new VRMNodeConstraintLoaderPlugin(f,{helperRoot:e})}beforeRoot(){return __async(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(f){return __async(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(f)})}getMaterialType(f){const r=this.mtoonMaterialPlugin.getMaterialType(f);return r??null}extendMaterialParams(f,r){return __async(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(f,r),yield this.mtoonMaterialPlugin.extendMaterialParams(f,r)})}afterRoot(f){return __async(this,null,function*(){yield this.metaPlugin.afterRoot(f),yield this.humanoidPlugin.afterRoot(f),yield this.expressionPlugin.afterRoot(f),yield this.lookAtPlugin.afterRoot(f),yield this.firstPersonPlugin.afterRoot(f),yield this.springBonePlugin.afterRoot(f),yield this.nodeConstraintPlugin.afterRoot(f),yield this.mtoonMaterialPlugin.afterRoot(f);const r=f.userData.vrmMeta,c=f.userData.vrmHumanoid;if(r&&c){const d=new VRM({scene:f.scene,expressionManager:f.userData.vrmExpressionManager,firstPerson:f.userData.vrmFirstPerson,humanoid:c,lookAt:f.userData.vrmLookAt,meta:r,materials:f.userData.vrmMToonMaterials,springBoneManager:f.userData.vrmSpringBoneManager,nodeConstraintManager:f.userData.vrmNodeConstraintManager});f.userData.vrm=d}})}};function collectMeshes(f){const r=new Set;return f.traverse(c=>{if(!c.isMesh)return;const d=c;r.add(d)}),r}function combineMorph(f,r,c){if(r.size===1){const s=r.values().next().value;if(s.weight===1)return f[s.index]}const d=new Float32Array(f[0].count*3);let l=0;if(c)l=1;else for(const s of r)l+=s.weight;for(const s of r){const h=f[s.index],p=s.weight/l;for(let a=0;a{if(!c.isSkinnedMesh)return;const d=c;r.add(d)}),r}function listUsedIndices(f,r){const c=new Set;for(let d=0;dc)return!1;return!0}function disposeMaterial(f){if(Object.values(f).forEach(r=>{r!=null&&r.isTexture&&r.dispose()}),f.isShaderMaterial){const r=f.uniforms;r&&Object.values(r).forEach(c=>{const d=c.value;d!=null&&d.isTexture&&d.dispose()})}f.dispose()}function dispose(f){const r=f.geometry;r&&r.dispose();const c=f.skeleton;c&&c.dispose();const d=f.material;d&&(Array.isArray(d)?d.forEach(l=>disposeMaterial(l)):d&&disposeMaterial(d))}function deepDispose(f){f.traverse(dispose)}function removeUnnecessaryJoints(f,r){var c,d;console.warn("VRMUtils.removeUnnecessaryJoints: removeUnnecessaryJoints is deprecated. Use combineSkeletons instead. combineSkeletons contributes more to the performance improvement. This function will be removed in the next major version.");const l=(c=r==null?void 0:r.experimentalSameBoneCounts)!=null?c:!1,m=[];f.traverse(p=>{p.type==="SkinnedMesh"&&m.push(p)});const s=new Map;let h=0;for(const p of m){const o=p.geometry.getAttribute("skinIndex");if(s.has(o))continue;const t=new Map,e=new Map;for(let n=0;n{var d,l,m,s;if(!c.isMesh)return;const h=c,p=h.geometry,a=p.index;if(a==null)return;const o=r.get(p);if(o!=null){h.geometry=o;return}const t=Object.values(p.attributes)[0].count,e=new Array(t);let n=0;const i=a.array;for(let v=0;v{y.addGroup(v.start,v.count,v.materialIndex)}),y.boundingBox=(l=(d=p.boundingBox)==null?void 0:d.clone())!=null?l:null,y.boundingSphere=(s=(m=p.boundingSphere)==null?void 0:m.clone())!=null?s:null,y.setDrawRange(p.drawRange.start,p.drawRange.count),y.userData=p.userData,r.set(p,y);{const v=a.array,w=new v.constructor(v.length);for(let T=0;T{const w=p.attributes[v];if(w.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const T=w.array,{itemSize:A,normalized:E}=w,x=new T.constructor(g.length*A);g.forEach((P,L)=>{for(let F=0;F{y.morphAttributes[v]=[];const w=p.morphAttributes[v];for(let T=0;T{for(let k=0;kF===0),y.morphAttributes[v][T]=new BufferAttribute(L,x,P)}}),_&&(y.morphAttributes={}),h.geometry=y}),Array.from(r.keys()).forEach(c=>{c.dispose()})}function rotateVRM0(f){var r;((r=f.meta)==null?void 0:r.metaVersion)==="0"&&(f.scene.rotation.y=Math.PI)}var VRMUtils=class{constructor(){}};VRMUtils.combineMorphs=combineMorphs;VRMUtils.combineSkeletons=combineSkeletons;VRMUtils.deepDispose=deepDispose;VRMUtils.removeUnnecessaryJoints=removeUnnecessaryJoints;VRMUtils.removeUnnecessaryVertices=removeUnnecessaryVertices;VRMUtils.rotateVRM0=rotateVRM0;/*! + * @pixiv/three-vrm-core v3.3.2 + * The implementation of core features of VRM, for @pixiv/three-vrm + * + * Copyright (c) 2019-2024 pixiv Inc. + * @pixiv/three-vrm-core is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-materials-mtoon v3.3.2 + * MToon (toon material) module for @pixiv/three-vrm + * + * Copyright (c) 2019-2024 pixiv Inc. + * @pixiv/three-vrm-materials-mtoon is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.2 + * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm + * + * Copyright (c) 2019-2024 pixiv Inc. + * @pixiv/three-vrm-materials-hdr-emissive-multiplier is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-materials-v0compat v3.3.2 + * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm + * + * Copyright (c) 2019-2024 pixiv Inc. + * @pixiv/three-vrm-materials-v0compat is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-node-constraint v3.3.2 + * Node constraint module for @pixiv/three-vrm + * + * Copyright (c) 2019-2024 pixiv Inc. + * @pixiv/three-vrm-node-constraint is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + *//*! + * @pixiv/three-vrm-springbone v3.3.2 + * Spring bone module for @pixiv/three-vrm + * + * Copyright (c) 2019-2024 pixiv Inc. + * @pixiv/three-vrm-springbone is distributed under MIT License + * https://github.com/pixiv/three-vrm/blob/release/LICENSE + */var dist={},ortWeb_min={exports:{}};const backends={},backendsSortedByPriority=[],registerBackend=(f,r,c)=>{if(r&&typeof r.init=="function"&&typeof r.createSessionHandler=="function"){const d=backends[f];if(d===void 0)backends[f]={backend:r,priority:c};else{if(d.priority>c)return;if(d.priority===c&&d.backend!==r)throw new Error(`cannot register backend "${f}" using priority ${c}`)}if(c>=0){const l=backendsSortedByPriority.indexOf(f);l!==-1&&backendsSortedByPriority.splice(l,1);for(let m=0;m{const r=f.length===0?backendsSortedByPriority:f,c=[];for(const d of r){const l=backends[d];if(l){if(l.initialized)return l.backend;if(l.aborted)continue;const m=!!l.initPromise;try{return m||(l.initPromise=l.backend.init()),await l.initPromise,l.initialized=!0,l.backend}catch(s){m||c.push({name:d,err:s}),l.aborted=!0}finally{delete l.initPromise}}}throw new Error(`no available backend found. ERR: ${c.map(d=>`[${d.name}] ${d.err}`).join(", ")}`)};class EnvImpl{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(r){if(r!==void 0){if(typeof r!="string"||["verbose","info","warning","error","fatal"].indexOf(r)===-1)throw new Error(`Unsupported logging level: ${r}`);this.logLevelInternal=r}}get logLevel(){return this.logLevelInternal}}const env=new EnvImpl,isBigInt64ArrayAvailable=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",isBigUint64ArrayAvailable=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function",NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);isBigInt64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64",BigInt64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array,"int64"));isBigUint64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64",BigUint64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array,"uint64"));const calculateSize=f=>{let r=1;for(let c=0;c{const t=document.createElement("canvas"),e=t.getContext("2d");if(!r||!e)return o();const n=new Image;n.crossOrigin="Anonymous",n.src=r,n.onload=()=>{t.width=n.width,t.height=n.height,e.drawImage(n,0,0,t.width,t.height);const i=e.getImageData(0,0,t.width,t.height);if(c!==void 0){if(c.height!==void 0&&c.height!==t.height)throw new Error("Image input config height doesn't match ImageBitmap height");if(p.height=t.height,c.width!==void 0&&c.width!==t.width)throw new Error("Image input config width doesn't match ImageBitmap width");p.width=t.width}else p.height=t.height,p.width=t.width;a(St.bufferToTensor(i.data,p))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(h!==void 0)return St.bufferToTensor(h,p);throw new Error("Input data provided is not supported - aborted tensor creation")}toImageData(r){var c,d;const l=document.createElement("canvas").getContext("2d");let m;if(l!=null){const s=this.dims[3],h=this.dims[2],p=this.dims[1],a=r!==void 0&&r.format!==void 0?r.format:"RGB",o=r!==void 0&&((c=r.norm)===null||c===void 0?void 0:c.mean)!==void 0?r.norm.mean:255,t=r!==void 0&&((d=r.norm)===null||d===void 0?void 0:d.bias)!==void 0?r.norm.bias:0,e=h*s;if(r!==void 0){if(r.height!==void 0&&r.height!==h)throw new Error("Image output config height doesn't match tensor height");if(r.width!==void 0&&r.width!==s)throw new Error("Image output config width doesn't match tensor width");if(r.format!==void 0&&p===4&&r.format!=="RGBA"||p===3&&r.format!=="RGB"&&r.format!=="BGR")throw new Error("Tensor format doesn't match input tensor dims")}const n=4;let i=0,u=1,g=2,b=3,y=0,_=e,v=e*2,w=-1;a==="RGBA"?(y=0,_=e,v=e*2,w=e*3):a==="RGB"?(y=0,_=e,v=e*2):a==="RBG"&&(y=0,v=e,_=e*2),m=l.createImageData(s,h);for(let T=0;T"u")throw new Error(`input '${a}' is missing in 'feeds'.`);if(s)for(const a of this.outputNames)l[a]=null;const h=await this.handler.run(r,l,m),p={};for(const a in h)Object.hasOwnProperty.call(h,a)&&(p[a]=new Tensor(h[a].type,h[a].data,h[a].dims));return p}static async create(r,c,d,l){let m,s={};if(typeof r=="string"){if(m=r,typeof c=="object"&&c!==null)s=c;else if(typeof c<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof Uint8Array){if(m=r,typeof c=="object"&&c!==null)s=c;else if(typeof c<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer){const t=r;let e=0,n=r.byteLength;if(typeof c=="object"&&c!==null)s=c;else if(typeof c=="number"){if(e=c,!Number.isSafeInteger(e))throw new RangeError("'byteOffset' must be an integer.");if(e<0||e>=t.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${t.byteLength}).`);if(n=r.byteLength-e,typeof d=="number"){if(n=d,!Number.isSafeInteger(n))throw new RangeError("'byteLength' must be an integer.");if(n<=0||e+n>t.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${t.byteLength-e}].`);if(typeof l=="object"&&l!==null)s=l;else if(typeof l<"u")throw new TypeError("'options' must be an object.")}else if(typeof d<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof c<"u")throw new TypeError("'options' must be an object.");m=new Uint8Array(t,e,n)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const p=(s.executionProviders||[]).map(t=>typeof t=="string"?t:t.name),o=await(await resolveBackend(p)).createSessionHandler(m,s);return new xn(o)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}};const InferenceSession=InferenceSession$1,lib=Object.freeze(Object.defineProperty({__proto__:null,InferenceSession,Tensor,env,registerBackend},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(lib);/*! +* ONNX Runtime Web v1.14.0 +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. +*/var hasRequiredOrtWeb_min;function requireOrtWeb_min(){return hasRequiredOrtWeb_min||(hasRequiredOrtWeb_min=1,function(module,exports){(function(f,r){module.exports=r(require$$0)})(self,__WEBPACK_EXTERNAL_MODULE__1670__=>(()=>{var __webpack_modules__={3474:(f,r,c)=>{var d,l=(d=(d=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(m){function s(){return Y.buffer!=te&&Ae(Y.buffer),he}function h(){return Y.buffer!=te&&Ae(Y.buffer),Me}function p(){return Y.buffer!=te&&Ae(Y.buffer),Te}function a(){return Y.buffer!=te&&Ae(Y.buffer),ue}function o(){return Y.buffer!=te&&Ae(Y.buffer),xe}var t,e,n;m=m||{},t||(t=m!==void 0?m:{}),t.ready=new Promise(function(S,O){e=S,n=O});var i,u,g,b,y,_,v=Object.assign({},t),w="./this.program",T=(S,O)=>{throw O},A=typeof window=="object",E=typeof importScripts=="function",x=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",P=t.ENVIRONMENT_IS_PTHREAD||!1,L="";function F(S){return t.locateFile?t.locateFile(S,L):L+S}if(x){let S;L=E?c(908).dirname(L)+"/":"//",_=()=>{y||(b=c(1384),y=c(908))},i=function(O,I){return _(),O=y.normalize(O),b.readFileSync(O,I?void 0:"utf8")},g=O=>((O=i(O,!0)).buffer||(O=new Uint8Array(O)),O),u=(O,I,C)=>{_(),O=y.normalize(O),b.readFile(O,function(B,z){B?C(B):I(z.buffer)})},1{if(je())throw process.exitCode=O,I;I instanceof Ke||U("exiting due to exception: "+I),process.exit(O)},t.inspect=function(){return"[Emscripten Module object]"};try{S=c(9925)}catch(O){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),O}c.g.Worker=S.Worker}else(A||E)&&(E?L=self.location.href:typeof document<"u"&&document.currentScript&&(L=document.currentScript.src),d&&(L=d),L=L.indexOf("blob:")!==0?L.substr(0,L.replace(/[?#].*/,"").lastIndexOf("/")+1):"",x||(i=S=>{var O=new XMLHttpRequest;return O.open("GET",S,!1),O.send(null),O.responseText},E&&(g=S=>{var O=new XMLHttpRequest;return O.open("GET",S,!1),O.responseType="arraybuffer",O.send(null),new Uint8Array(O.response)}),u=(S,O,I)=>{var C=new XMLHttpRequest;C.open("GET",S,!0),C.responseType="arraybuffer",C.onload=()=>{C.status==200||C.status==0&&C.response?O(C.response):I()},C.onerror=I,C.send(null)}));x&&typeof performance>"u"&&(c.g.performance=c(6953).performance);var $=console.log.bind(console),k=console.warn.bind(console);x&&(_(),$=S=>b.writeSync(1,S+` +`),k=S=>b.writeSync(2,S+` +`));var q,D=t.print||$,U=t.printErr||k;Object.assign(t,v),v=null,t.thisProgram&&(w=t.thisProgram),t.quit&&(T=t.quit),t.wasmBinary&&(q=t.wasmBinary);var J=t.noExitRuntime||!1;typeof WebAssembly!="object"&&le("no native wasm support detected");var Y,Z,te,he,Me,Te,ue,xe,_e=!1,Ce=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ze(S,O,I){var C=(O>>>=0)+I;for(I=O;S[I]&&!(I>=C);)++I;if(16(B=(240&B)==224?(15&B)<<12|z<<6|Q:(7&B)<<18|z<<12|Q<<6|63&S[O++])?C+=String.fromCharCode(B):(B-=65536,C+=String.fromCharCode(55296|B>>10,56320|1023&B))}}else C+=String.fromCharCode(B)}return C}function Se(S,O){return(S>>>=0)?ze(h(),S,O):""}function De(S,O,I,C){if(!(0>>=0;C=I+C-1;for(var z=0;z=Q&&(Q=65536+((1023&Q)<<10)|1023&S.charCodeAt(++z)),127>=Q){if(I>=C)break;O[I++>>>0]=Q}else{if(2047>=Q){if(I+1>=C)break;O[I++>>>0]=192|Q>>6}else{if(65535>=Q){if(I+2>=C)break;O[I++>>>0]=224|Q>>12}else{if(I+3>=C)break;O[I++>>>0]=240|Q>>18,O[I++>>>0]=128|Q>>12&63}O[I++>>>0]=128|Q>>6&63}O[I++>>>0]=128|63&Q}}return O[I>>>0]=0,I-B}function Re(S){for(var O=0,I=0;I=C?O++:2047>=C?O+=2:55296<=C&&57343>=C?(O+=4,++I):O+=3}return O}function Ae(S){te=S,t.HEAP8=he=new Int8Array(S),t.HEAP16=new Int16Array(S),t.HEAP32=Te=new Int32Array(S),t.HEAPU8=Me=new Uint8Array(S),t.HEAPU16=new Uint16Array(S),t.HEAPU32=ue=new Uint32Array(S),t.HEAPF32=new Float32Array(S),t.HEAPF64=xe=new Float64Array(S)}P&&(te=t.buffer);var we=t.INITIAL_MEMORY||16777216;if(P)Y=t.wasmMemory,te=t.buffer;else if(t.wasmMemory)Y=t.wasmMemory;else if(!((Y=new WebAssembly.Memory({initial:we/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw U("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"),x&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Y&&(te=Y.buffer),we=te.byteLength,Ae(te);var Fe,Ue=[],Be=[],We=[],qe=[];function je(){return J||!1}function Ve(){var S=t.preRun.shift();Ue.unshift(S)}var Ee,$e=0,Ye=null;function le(S){throw P?postMessage({cmd:"onAbort",arg:S}):t.onAbort&&t.onAbort(S),U(S="Aborted("+S+")"),_e=!0,S=new WebAssembly.RuntimeError(S+". Build with -sASSERTIONS for more info."),n(S),S}function pt(){return Ee.startsWith("data:application/octet-stream;base64,")}function ut(){var S=Ee;try{if(S==Ee&&q)return new Uint8Array(q);if(g)return g(S);throw"both async and sync fetching of the wasm failed"}catch(O){le(O)}}Ee="ort-wasm-threaded.wasm",pt()||(Ee=F(Ee));var It={};function Ke(S){this.name="ExitStatus",this.message="Program terminated with exit("+S+")",this.status=S}function He(S){(S=ie.Vb[S])||le(),ie.mc(S)}function lt(S){var O=ie.Cc();if(!O)return 6;ie.ac.push(O),ie.Vb[S.Ub]=O,O.Ub=S.Ub;var I={cmd:"run",start_routine:S.Ic,arg:S.zc,pthread_ptr:S.Ub};return O.$b=()=>{I.time=performance.now(),O.postMessage(I,S.Nc)},O.loaded&&(O.$b(),delete O.$b),0}function Le(S){if(P)return K(1,1,S);je()||(ie.oc(),t.onExit&&t.onExit(S),_e=!0),T(S,new Ke(S))}function nt(S,O){if(!O&&P)throw Et(S),"unwind";je()||P||(Xt(),Je(We),Yt(0),Ft[1].length&&Vt(1,10),Ft[2].length&&Vt(2,10),ie.oc()),Le(S)}var ie={Yb:[],ac:[],qc:[],Vb:{},fc:function(){P&&ie.Ec()},Pc:function(){},Ec:function(){ie.receiveObjectTransfer=ie.Gc,ie.threadInitTLS=ie.pc,ie.setExitStatus=ie.nc,J=!1},nc:function(){},oc:function(){for(var S of Object.values(ie.Vb))ie.mc(S);for(S of ie.Yb)S.terminate();ie.Yb=[]},mc:function(S){var O=S.Ub;delete ie.Vb[O],ie.Yb.push(S),ie.ac.splice(ie.ac.indexOf(S),1),S.Ub=0,Ut(O)},Gc:function(){},pc:function(){ie.qc.forEach(S=>S())},Fc:function(S,O){S.onmessage=I=>{var C=(I=I.data).cmd;if(S.Ub&&(ie.Bc=S.Ub),I.targetThread&&I.targetThread!=Lt()){var B=ie.Vb[I.Qc];B?B.postMessage(I,I.transferList):U('Internal error! Worker sent a message "'+C+'" to target pthread '+I.targetThread+", but that thread no longer exists!")}else C==="processProxyingQueue"?N(I.queue):C==="spawnThread"?lt(I):C==="cleanupThread"?He(I.thread):C==="killThread"?(I=I.thread,C=ie.Vb[I],delete ie.Vb[I],C.terminate(),Ut(I),ie.ac.splice(ie.ac.indexOf(C),1),C.Ub=0):C==="cancelThread"?ie.Vb[I.thread].postMessage({cmd:"cancel"}):C==="loaded"?(S.loaded=!0,O&&O(S),S.$b&&(S.$b(),delete S.$b)):C==="print"?D("Thread "+I.threadId+": "+I.text):C==="printErr"?U("Thread "+I.threadId+": "+I.text):C==="alert"?alert("Thread "+I.threadId+": "+I.text):I.target==="setimmediate"?S.postMessage(I):C==="onAbort"?t.onAbort&&t.onAbort(I.arg):C&&U("worker sent an unknown command "+C);ie.Bc=void 0},S.onerror=I=>{throw U("worker sent an error! "+I.filename+":"+I.lineno+": "+I.message),I},x&&(S.on("message",function(I){S.onmessage({data:I})}),S.on("error",function(I){S.onerror(I)}),S.on("detachedExit",function(){})),S.postMessage({cmd:"load",urlOrBlob:t.mainScriptUrlOrBlob||d,wasmMemory:Y,wasmModule:Z})},yc:function(){var S=F("ort-wasm-threaded.worker.js");ie.Yb.push(new Worker(S))},Cc:function(){return ie.Yb.length==0&&(ie.yc(),ie.Fc(ie.Yb[0])),ie.Yb.pop()}};function Je(S){for(;0>2>>>0];S=p()[S+48>>2>>>0],en(O,O-S),ce(O)};var Xe=[];function ye(S){var O=Xe[S];return O||(S>=Xe.length&&(Xe.length=S+1),Xe[S]=O=Fe.get(S)),O}t.invokeEntryPoint=function(S,O){S=ye(S)(O),je()?ie.nc(S):Jt(S)};var rt,ct,it=[],oe=0,re=0;function se(S){this.Zb=S,this.Sb=S-24,this.xc=function(O){a()[this.Sb+4>>2>>>0]=O},this.bc=function(){return a()[this.Sb+4>>2>>>0]},this.wc=function(O){a()[this.Sb+8>>2>>>0]=O},this.Dc=function(){return a()[this.Sb+8>>2>>>0]},this.rc=function(){p()[this.Sb>>2>>>0]=0},this.hc=function(O){O=O?1:0,s()[this.Sb+12>>0>>>0]=O},this.uc=function(){return s()[this.Sb+12>>0>>>0]!=0},this.ic=function(O){O=O?1:0,s()[this.Sb+13>>0>>>0]=O},this.kc=function(){return s()[this.Sb+13>>0>>>0]!=0},this.fc=function(O,I){this.cc(0),this.xc(O),this.wc(I),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(p(),this.Sb>>2,1)},this.Hc=function(){return Atomics.sub(p(),this.Sb>>2,1)===1},this.cc=function(O){a()[this.Sb+16>>2>>>0]=O},this.tc=function(){return a()[this.Sb+16>>2>>>0]},this.vc=function(){if(tn(this.bc()))return a()[this.Zb>>2>>>0];var O=this.tc();return O!==0?O:this.Zb}}function ft(S){return qt(new se(S).Sb)}function et(S,O,I,C){return P?K(3,1,S,O,I,C):mt(S,O,I,C)}function mt(S,O,I,C){if(typeof SharedArrayBuffer>"u")return U("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var B=[];return P&&B.length===0?et(S,O,I,C):(S={Ic:I,Ub:S,zc:C,Nc:B},P?(S.Oc="spawnThread",postMessage(S,B),0):lt(S))}function gt(S,O,I){return P?K(4,1,S,O,I):0}function bt(S,O){if(P)return K(5,1,S,O)}function dt(S,O){if(P)return K(6,1,S,O)}function yt(S,O,I){if(P)return K(7,1,S,O,I)}function _t(S,O,I){return P?K(8,1,S,O,I):0}function vt(S,O){if(P)return K(9,1,S,O)}function wt(S,O,I){if(P)return K(10,1,S,O,I)}function xt(S,O,I,C){if(P)return K(11,1,S,O,I,C)}function ot(S,O,I,C){if(P)return K(12,1,S,O,I,C)}function ht(S,O,I,C){if(P)return K(13,1,S,O,I,C)}function Tt(S){if(P)return K(14,1,S)}function M(S,O){if(P)return K(15,1,S,O)}function R(S,O,I){if(P)return K(16,1,S,O,I)}function N(S){Atomics.store(p(),S>>2,1),Lt()&&Kt(S),Atomics.compareExchange(p(),S>>2,1,0)}function V(S){return a()[S>>>2]+4294967296*p()[S+4>>>2]}function j(S,O,I,C,B,z){return P?K(17,1,S,O,I,C,B,z):-52}function H(S,O,I,C,B,z){if(P)return K(18,1,S,O,I,C,B,z)}function X(S){var O=Re(S)+1,I=$t(O);return I&&De(S,s(),I,O),I}function ee(S,O,I){function C(me){return(me=me.toTimeString().match(/\(([A-Za-z ]+)\)$/))?me[1]:"GMT"}if(P)return K(19,1,S,O,I);var B=new Date().getFullYear(),z=new Date(B,0,1),Q=new Date(B,6,1);B=z.getTimezoneOffset();var ne=Q.getTimezoneOffset(),fe=Math.max(B,ne);p()[S>>2>>>0]=60*fe,p()[O>>2>>>0]=+(B!=ne),S=C(z),O=C(Q),S=X(S),O=X(O),ne>2>>>0]=S,a()[I+4>>2>>>0]=O):(a()[I>>2>>>0]=O,a()[I+4>>2>>>0]=S)}function K(S,O){var I=arguments.length-2,C=arguments;return At(()=>{for(var B=Bt(8*I),z=B>>3,Q=0;Q>>0]=ne}return Zt(S,I,B,O)})}t.executeNotifiedProxyingQueue=N,ct=x?()=>{var S=process.hrtime();return 1e3*S[0]+S[1]/1e6}:P?()=>performance.now()-t.__performance_now_clock_drift:()=>performance.now();var ae,ve=[],ke={};function Ne(){if(!ae){var S,O={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:w||"./this.program"};for(S in ke)ke[S]===void 0?delete O[S]:O[S]=ke[S];var I=[];for(S in O)I.push(S+"="+O[S]);ae=I}return ae}function G(S,O){if(P)return K(20,1,S,O);var I=0;return Ne().forEach(function(C,B){var z=O+I;for(B=a()[S+4*B>>2>>>0]=z,z=0;z>0>>>0]=C.charCodeAt(z);s()[B>>0>>>0]=0,I+=C.length+1}),0}function ge(S,O){if(P)return K(21,1,S,O);var I=Ne();a()[S>>2>>>0]=I.length;var C=0;return I.forEach(function(B){C+=B.length+1}),a()[O>>2>>>0]=C,0}function Oe(S){return P?K(22,1,S):52}function Qe(S,O,I,C){return P?K(23,1,S,O,I,C):52}function st(S,O,I,C,B){return P?K(24,1,S,O,I,C,B):70}var Ft=[null,[],[]];function Vt(S,O){var I=Ft[S];O===0||O===10?((S===1?D:U)(ze(I,0)),I.length=0):I.push(O)}function zt(S,O,I,C){if(P)return K(25,1,S,O,I,C);for(var B=0,z=0;z>2>>>0],ne=a()[O+4>>2>>>0];O+=8;for(var fe=0;fe>>0]);B+=ne}return a()[C>>2>>>0]=B,0}var Ge=0;function Dt(S){return S%4==0&&(S%100!=0||S%400==0)}var Ht=[31,29,31,30,31,30,31,31,30,31,30,31],Gt=[31,28,31,30,31,30,31,31,30,31,30,31];function Wt(S,O,I,C){function B(W,be,Pe){for(W=typeof W=="number"?W.toString():W||"";W.lengthOt?-1:0at-W.getDate())){W.setDate(W.getDate()+be);break}be-=at-W.getDate()+1,W.setDate(1),11>Pe?W.setMonth(Pe+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return Pe=new Date(W.getFullYear()+1,0,4),be=ne(new Date(W.getFullYear(),0,4)),Pe=ne(Pe),0>=Q(be,W)?0>=Q(Pe,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}var me=p()[C+40>>2>>>0];for(var Ie in C={Lc:p()[C>>2>>>0],Kc:p()[C+4>>2>>>0],dc:p()[C+8>>2>>>0],jc:p()[C+12>>2>>>0],ec:p()[C+16>>2>>>0],Xb:p()[C+20>>2>>>0],Tb:p()[C+24>>2>>>0],Wb:p()[C+28>>2>>>0],Rc:p()[C+32>>2>>>0],Jc:p()[C+36>>2>>>0],Mc:me?Se(me):""},I=Se(I),me={"%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"})I=I.replace(new RegExp(Ie,"g"),me[Ie]);var tt="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ze="January February March April May June July August September October November December".split(" ");for(Ie in me={"%a":function(W){return tt[W.Tb].substring(0,3)},"%A":function(W){return tt[W.Tb]},"%b":function(W){return Ze[W.ec].substring(0,3)},"%B":function(W){return Ze[W.ec]},"%C":function(W){return z((W.Xb+1900)/100|0,2)},"%d":function(W){return z(W.jc,2)},"%e":function(W){return B(W.jc,2," ")},"%g":function(W){return fe(W).toString().substring(2)},"%G":function(W){return fe(W)},"%H":function(W){return z(W.dc,2)},"%I":function(W){return(W=W.dc)==0?W=12:12W.dc?"AM":"PM"},"%S":function(W){return z(W.Lc,2)},"%t":function(){return" "},"%u":function(W){return W.Tb||7},"%U":function(W){return z(Math.floor((W.Wb+7-W.Tb)/7),2)},"%V":function(W){var be=Math.floor((W.Wb+7-(W.Tb+6)%7)/7);if(2>=(W.Tb+371-W.Wb-2)%7&&be++,be)be==53&&((Pe=(W.Tb+371-W.Wb)%7)==4||Pe==3&&Dt(W.Xb)||(be=1));else{be=52;var Pe=(W.Tb+7-W.Wb-1)%7;(Pe==4||Pe==5&&Dt(W.Xb%400-1))&&be++}return z(be,2)},"%w":function(W){return W.Tb},"%W":function(W){return z(Math.floor((W.Wb+7-(W.Tb+6)%7)/7),2)},"%y":function(W){return(W.Xb+1900).toString().substring(2)},"%Y":function(W){return W.Xb+1900},"%z":function(W){var be=0<=(W=W.Jc);return W=Math.abs(W)/60,(be?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":function(W){return W.Mc},"%%":function(){return"%"}},I=I.replace(/%%/g,"\0\0"),me)I.includes(Ie)&&(I=I.replace(new RegExp(Ie,"g"),me[Ie](C)));return Ie=function(W){var be=Array(Re(W)+1);return De(W,be,0,be.length),be}(I=I.replace(/\0\0/g,"%")),Ie.length>O?0:(function(W,be){s().set(W,be>>>0)}(Ie,S),Ie.length-1)}ie.fc();var Tn=[null,Le,Et,et,gt,bt,dt,yt,_t,vt,wt,xt,ot,ht,Tt,M,R,j,H,ee,G,ge,Oe,Qe,st,zt],Sn={b:function(S){return $t(S+24)+24},n:function(S){return(S=new se(S)).uc()||(S.hc(!0),oe--),S.ic(!1),it.push(S),S.sc(),S.vc()},ma:function(S){throw U("Unexpected exception thrown, this is not properly supported - aborting"),_e=!0,S},x:function(){pe(0);var S=it.pop();if(S.Hc()&&!S.kc()){var O=S.Dc();O&&ye(O)(S.Zb),ft(S.Zb)}re=0},e:function(){var S=re;if(!S)return Ge=0;var O=new se(S);O.cc(S);var I=O.bc();if(!I)return Ge=0,S;for(var C=Array.prototype.slice.call(arguments),B=0;BN(C));else if(P)postMessage({targetThread:S,cmd:"processProxyingQueue",queue:C});else{if(!(S=ie.Vb[S]))return;S.postMessage({cmd:"processProxyingQueue",queue:C})}return 1},Ea:function(){return-1},Pa:function(S,O){S=new Date(1e3*V(S)),p()[O>>2>>>0]=S.getUTCSeconds(),p()[O+4>>2>>>0]=S.getUTCMinutes(),p()[O+8>>2>>>0]=S.getUTCHours(),p()[O+12>>2>>>0]=S.getUTCDate(),p()[O+16>>2>>>0]=S.getUTCMonth(),p()[O+20>>2>>>0]=S.getUTCFullYear()-1900,p()[O+24>>2>>>0]=S.getUTCDay(),S=(S.getTime()-Date.UTC(S.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,p()[O+28>>2>>>0]=S},Qa:function(S,O){S=new Date(1e3*V(S)),p()[O>>2>>>0]=S.getSeconds(),p()[O+4>>2>>>0]=S.getMinutes(),p()[O+8>>2>>>0]=S.getHours(),p()[O+12>>2>>>0]=S.getDate(),p()[O+16>>2>>>0]=S.getMonth(),p()[O+20>>2>>>0]=S.getFullYear()-1900,p()[O+24>>2>>>0]=S.getDay();var I=new Date(S.getFullYear(),0,1),C=(S.getTime()-I.getTime())/864e5|0;p()[O+28>>2>>>0]=C,p()[O+36>>2>>>0]=-60*S.getTimezoneOffset(),C=new Date(S.getFullYear(),6,1).getTimezoneOffset(),S=0|(C!=(I=I.getTimezoneOffset())&&S.getTimezoneOffset()==Math.min(I,C)),p()[O+32>>2>>>0]=S},Ra:function(S){var O=new Date(p()[S+20>>2>>>0]+1900,p()[S+16>>2>>>0],p()[S+12>>2>>>0],p()[S+8>>2>>>0],p()[S+4>>2>>>0],p()[S>>2>>>0],0),I=p()[S+32>>2>>>0],C=O.getTimezoneOffset(),B=new Date(O.getFullYear(),0,1),z=new Date(O.getFullYear(),6,1).getTimezoneOffset(),Q=B.getTimezoneOffset(),ne=Math.min(Q,z);return 0>I?p()[S+32>>2>>>0]=+(z!=Q&&ne==C):0>2>>>0]=O.getDay(),I=(O.getTime()-B.getTime())/864e5|0,p()[S+28>>2>>>0]=I,p()[S>>2>>>0]=O.getSeconds(),p()[S+4>>2>>>0]=O.getMinutes(),p()[S+8>>2>>>0]=O.getHours(),p()[S+12>>2>>>0]=O.getDate(),p()[S+16>>2>>>0]=O.getMonth(),O.getTime()/1e3|0},Aa:j,Ba:H,Sa:function S(O,I,C){S.Ac||(S.Ac=!0,ee(O,I,C))},y:function(){le("")},U:function(){if(!x&&!E){var S="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";rt||(rt={}),rt[S]||(rt[S]=1,x&&(S="warning: "+S),U(S))}},ra:function(){return 4294901760},B:ct,Ia:function(S,O,I){h().copyWithin(S>>>0,O>>>0,O+I>>>0)},F:function(){return x?c(3993).cpus().length:navigator.hardwareConcurrency},Da:function(S,O,I){ve.length=O,I>>=3;for(var C=0;C>>0];return(0>S?It[-S-1]:Tn[S]).apply(null,ve)},qa:function(S){var O=h().length;if((S>>>=0)<=O||4294901760=I;I*=2){var C=O*(1+.2/I);C=Math.min(C,S+100663296);var B=Math;C=Math.max(S,C),B=B.min.call(B,4294901760,C+(65536-C%65536)%65536);e:{try{Y.grow(B-te.byteLength+65535>>>16),Ae(Y.buffer);var z=1;break e}catch{}z=void 0}if(z)return!0}return!1},Na:function(){throw"unwind"},Ga:G,Ha:ge,J:nt,I:Oe,S:Qe,ga:st,R:zt,d:function(){return Ge},na:function S(O,I){S.lc||(S.lc=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var B=new Uint8Array(1);return()=>(crypto.getRandomValues(B),B[0])}if(x)try{var z=c(Object(function(){var Q=new Error("Cannot find module 'crypto'");throw Q.code="MODULE_NOT_FOUND",Q}()));return()=>z.randomBytes(1)[0]}catch{}return()=>le("randomDevice")}());for(var C=0;C>0>>>0]=S.lc();return 0},ia:function(S,O,I){var C=de();try{return ye(S)(O,I)}catch(B){if(ce(C),B!==B+0)throw B;pe(1,0)}},ja:function(S,O,I){var C=de();try{return ye(S)(O,I)}catch(B){if(ce(C),B!==B+0)throw B;pe(1,0)}},K:function(S){var O=de();try{return ye(S)()}catch(I){if(ce(O),I!==I+0)throw I;pe(1,0)}},f:function(S,O){var I=de();try{return ye(S)(O)}catch(C){if(ce(I),C!==C+0)throw C;pe(1,0)}},P:function(S,O,I){var C=de();try{return ye(S)(O,I)}catch(B){if(ce(C),B!==B+0)throw B;pe(1,0)}},Q:function(S,O,I){var C=de();try{return ye(S)(O,I)}catch(B){if(ce(C),B!==B+0)throw B;pe(1,0)}},k:function(S,O,I){var C=de();try{return ye(S)(O,I)}catch(B){if(ce(C),B!==B+0)throw B;pe(1,0)}},p:function(S,O,I,C){var B=de();try{return ye(S)(O,I,C)}catch(z){if(ce(B),z!==z+0)throw z;pe(1,0)}},q:function(S,O,I,C,B){var z=de();try{return ye(S)(O,I,C,B)}catch(Q){if(ce(z),Q!==Q+0)throw Q;pe(1,0)}},N:function(S,O,I,C,B,z){var Q=de();try{return ye(S)(O,I,C,B,z)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},s:function(S,O,I,C,B,z){var Q=de();try{return ye(S)(O,I,C,B,z)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},w:function(S,O,I,C,B,z,Q){var ne=de();try{return ye(S)(O,I,C,B,z,Q)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;pe(1,0)}},L:function(S,O,I,C,B,z,Q,ne){var fe=de();try{return ye(S)(O,I,C,B,z,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},E:function(S,O,I,C,B,z,Q,ne,fe,me,Ie,tt){var Ze=de();try{return ye(S)(O,I,C,B,z,Q,ne,fe,me,Ie,tt)}catch(W){if(ce(Ze),W!==W+0)throw W;pe(1,0)}},aa:function(S,O,I,C,B,z,Q,ne){var fe=de();try{return dn(S,O,I,C,B,z,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},_:function(S,O,I,C,B,z,Q){var ne=de();try{return rn(S,O,I,C,B,z,Q)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;pe(1,0)}},Z:function(S,O,I,C,B){var z=de();try{return hn(S,O,I,C,B)}catch(Q){if(ce(z),Q!==Q+0)throw Q;pe(1,0)}},ca:function(S,O,I,C){var B=de();try{return ln(S,O,I,C)}catch(z){if(ce(B),z!==z+0)throw z;pe(1,0)}},$:function(S){var O=de();try{return nn(S)}catch(I){if(ce(O),I!==I+0)throw I;pe(1,0)}},ba:function(S,O){var I=de();try{return cn(S,O)}catch(C){if(ce(I),C!==C+0)throw C;pe(1,0)}},Y:function(S,O,I){var C=de();try{return on(S,O,I)}catch(B){if(ce(C),B!==B+0)throw B;pe(1,0)}},g:function(S){var O=de();try{ye(S)()}catch(I){if(ce(O),I!==I+0)throw I;pe(1,0)}},r:function(S,O){var I=de();try{ye(S)(O)}catch(C){if(ce(I),C!==C+0)throw C;pe(1,0)}},i:function(S,O,I){var C=de();try{ye(S)(O,I)}catch(B){if(ce(C),B!==B+0)throw B;pe(1,0)}},ha:function(S,O,I,C){var B=de();try{ye(S)(O,I,C)}catch(z){if(ce(B),z!==z+0)throw z;pe(1,0)}},m:function(S,O,I,C){var B=de();try{ye(S)(O,I,C)}catch(z){if(ce(B),z!==z+0)throw z;pe(1,0)}},v:function(S,O,I,C,B){var z=de();try{ye(S)(O,I,C,B)}catch(Q){if(ce(z),Q!==Q+0)throw Q;pe(1,0)}},u:function(S,O,I,C,B,z){var Q=de();try{ye(S)(O,I,C,B,z)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},O:function(S,O,I,C,B,z,Q){var ne=de();try{ye(S)(O,I,C,B,z,Q)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;pe(1,0)}},A:function(S,O,I,C,B,z,Q,ne){var fe=de();try{ye(S)(O,I,C,B,z,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},ka:function(S,O,I,C,B,z,Q,ne,fe){var me=de();try{ye(S)(O,I,C,B,z,Q,ne,fe)}catch(Ie){if(ce(me),Ie!==Ie+0)throw Ie;pe(1,0)}},C:function(S,O,I,C,B,z,Q,ne,fe,me,Ie){var tt=de();try{ye(S)(O,I,C,B,z,Q,ne,fe,me,Ie)}catch(Ze){if(ce(tt),Ze!==Ze+0)throw Ze;pe(1,0)}},D:function(S,O,I,C,B,z,Q,ne,fe,me,Ie,tt,Ze,W,be,Pe){var at=de();try{ye(S)(O,I,C,B,z,Q,ne,fe,me,Ie,tt,Ze,W,be,Pe)}catch(Ot){if(ce(at),Ot!==Ot+0)throw Ot;pe(1,0)}},fa:function(S,O,I,C,B,z,Q,ne){var fe=de();try{sn(S,O,I,C,B,z,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},da:function(S,O,I,C,B,z,Q,ne,fe,me,Ie,tt){var Ze=de();try{un(S,O,I,C,B,z,Q,ne,fe,me,Ie,tt)}catch(W){if(ce(Ze),W!==W+0)throw W;pe(1,0)}},ea:function(S,O,I,C,B,z){var Q=de();try{an(S,O,I,C,B,z)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},o:function(S){return S},a:Y||t.wasmMemory,G:function(S){Ge=S},la:Wt,z:function(S,O,I,C){return Wt(S,O,I,C)}};(function(){function S(B,z){t.asm=B.exports,ie.qc.push(t.asm.sb),Fe=t.asm.ub,Be.unshift(t.asm.Va),Z=z,P||($e--,t.monitorRunDependencies&&t.monitorRunDependencies($e),$e==0&&Ye&&(B=Ye,Ye=null,B()))}function O(B){S(B.instance,B.module)}function I(B){return function(){if(!q&&(A||E)){if(typeof fetch=="function"&&!Ee.startsWith("file://"))return fetch(Ee,{credentials:"same-origin"}).then(function(z){if(!z.ok)throw"failed to load wasm binary file at '"+Ee+"'";return z.arrayBuffer()}).catch(function(){return ut()});if(u)return new Promise(function(z,Q){u(Ee,function(ne){z(new Uint8Array(ne))},Q)})}return Promise.resolve().then(function(){return ut()})}().then(function(z){return WebAssembly.instantiate(z,C)}).then(function(z){return z}).then(B,function(z){U("failed to asynchronously prepare wasm: "+z),le(z)})}var C={a:Sn};if(P||($e++,t.monitorRunDependencies&&t.monitorRunDependencies($e)),t.instantiateWasm)try{return t.instantiateWasm(C,S)}catch(B){return U("Module.instantiateWasm callback failed with error: "+B),!1}(q||typeof WebAssembly.instantiateStreaming!="function"||pt()||Ee.startsWith("file://")||x||typeof fetch!="function"?I(O):fetch(Ee,{credentials:"same-origin"}).then(function(B){return WebAssembly.instantiateStreaming(B,C).then(O,function(z){return U("wasm streaming compile failed: "+z),U("falling back to ArrayBuffer instantiation"),I(O)})})).catch(n)})(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.Va).apply(null,arguments)},t._OrtInit=function(){return(t._OrtInit=t.asm.Wa).apply(null,arguments)},t._OrtCreateSessionOptions=function(){return(t._OrtCreateSessionOptions=t.asm.Xa).apply(null,arguments)},t._OrtAppendExecutionProvider=function(){return(t._OrtAppendExecutionProvider=t.asm.Ya).apply(null,arguments)},t._OrtAddSessionConfigEntry=function(){return(t._OrtAddSessionConfigEntry=t.asm.Za).apply(null,arguments)},t._OrtReleaseSessionOptions=function(){return(t._OrtReleaseSessionOptions=t.asm._a).apply(null,arguments)},t._OrtCreateSession=function(){return(t._OrtCreateSession=t.asm.$a).apply(null,arguments)},t._OrtReleaseSession=function(){return(t._OrtReleaseSession=t.asm.ab).apply(null,arguments)},t._OrtGetInputCount=function(){return(t._OrtGetInputCount=t.asm.bb).apply(null,arguments)},t._OrtGetOutputCount=function(){return(t._OrtGetOutputCount=t.asm.cb).apply(null,arguments)},t._OrtGetInputName=function(){return(t._OrtGetInputName=t.asm.db).apply(null,arguments)},t._OrtGetOutputName=function(){return(t._OrtGetOutputName=t.asm.eb).apply(null,arguments)},t._OrtFree=function(){return(t._OrtFree=t.asm.fb).apply(null,arguments)},t._OrtCreateTensor=function(){return(t._OrtCreateTensor=t.asm.gb).apply(null,arguments)},t._OrtGetTensorData=function(){return(t._OrtGetTensorData=t.asm.hb).apply(null,arguments)},t._OrtReleaseTensor=function(){return(t._OrtReleaseTensor=t.asm.ib).apply(null,arguments)},t._OrtCreateRunOptions=function(){return(t._OrtCreateRunOptions=t.asm.jb).apply(null,arguments)},t._OrtAddRunConfigEntry=function(){return(t._OrtAddRunConfigEntry=t.asm.kb).apply(null,arguments)},t._OrtReleaseRunOptions=function(){return(t._OrtReleaseRunOptions=t.asm.lb).apply(null,arguments)},t._OrtRun=function(){return(t._OrtRun=t.asm.mb).apply(null,arguments)},t._OrtEndProfiling=function(){return(t._OrtEndProfiling=t.asm.nb).apply(null,arguments)};var Lt=t._pthread_self=function(){return(Lt=t._pthread_self=t.asm.ob).apply(null,arguments)},$t=t._malloc=function(){return($t=t._malloc=t.asm.pb).apply(null,arguments)},qt=t._free=function(){return(qt=t._free=t.asm.qb).apply(null,arguments)},Yt=t._fflush=function(){return(Yt=t._fflush=t.asm.rb).apply(null,arguments)};t.__emscripten_tls_init=function(){return(t.__emscripten_tls_init=t.asm.sb).apply(null,arguments)};var Xt=t.___funcs_on_exit=function(){return(Xt=t.___funcs_on_exit=t.asm.tb).apply(null,arguments)},Qt=t.__emscripten_thread_init=function(){return(Qt=t.__emscripten_thread_init=t.asm.vb).apply(null,arguments)};t.__emscripten_thread_crashed=function(){return(t.__emscripten_thread_crashed=t.asm.wb).apply(null,arguments)};var Ct,Zt=t._emscripten_run_in_main_runtime_thread_js=function(){return(Zt=t._emscripten_run_in_main_runtime_thread_js=t.asm.xb).apply(null,arguments)},Kt=t.__emscripten_proxy_execute_task_queue=function(){return(Kt=t.__emscripten_proxy_execute_task_queue=t.asm.yb).apply(null,arguments)},Ut=t.__emscripten_thread_free_data=function(){return(Ut=t.__emscripten_thread_free_data=t.asm.zb).apply(null,arguments)},Jt=t.__emscripten_thread_exit=function(){return(Jt=t.__emscripten_thread_exit=t.asm.Ab).apply(null,arguments)},pe=t._setThrew=function(){return(pe=t._setThrew=t.asm.Bb).apply(null,arguments)},en=t._emscripten_stack_set_limits=function(){return(en=t._emscripten_stack_set_limits=t.asm.Cb).apply(null,arguments)},de=t.stackSave=function(){return(de=t.stackSave=t.asm.Db).apply(null,arguments)},ce=t.stackRestore=function(){return(ce=t.stackRestore=t.asm.Eb).apply(null,arguments)},Bt=t.stackAlloc=function(){return(Bt=t.stackAlloc=t.asm.Fb).apply(null,arguments)},Nt=t.___cxa_can_catch=function(){return(Nt=t.___cxa_can_catch=t.asm.Gb).apply(null,arguments)},tn=t.___cxa_is_pointer_type=function(){return(tn=t.___cxa_is_pointer_type=t.asm.Hb).apply(null,arguments)},nn=t.dynCall_j=function(){return(nn=t.dynCall_j=t.asm.Ib).apply(null,arguments)},rn=t.dynCall_iiiiij=function(){return(rn=t.dynCall_iiiiij=t.asm.Jb).apply(null,arguments)},on=t.dynCall_jii=function(){return(on=t.dynCall_jii=t.asm.Kb).apply(null,arguments)},sn=t.dynCall_viiiiij=function(){return(sn=t.dynCall_viiiiij=t.asm.Lb).apply(null,arguments)},an=t.dynCall_vjji=function(){return(an=t.dynCall_vjji=t.asm.Mb).apply(null,arguments)},un=t.dynCall_viiijjjii=function(){return(un=t.dynCall_viiijjjii=t.asm.Nb).apply(null,arguments)},ln=t.dynCall_iij=function(){return(ln=t.dynCall_iij=t.asm.Ob).apply(null,arguments)},cn=t.dynCall_ji=function(){return(cn=t.dynCall_ji=t.asm.Pb).apply(null,arguments)},dn=t.dynCall_iiiiiij=function(){return(dn=t.dynCall_iiiiiij=t.asm.Qb).apply(null,arguments)},hn=t.dynCall_iiij=function(){return(hn=t.dynCall_iiij=t.asm.Rb).apply(null,arguments)};function pn(){function S(){if(!Ct&&(Ct=!0,t.calledRun=!0,!_e)&&(P||Je(Be),e(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),!P)){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;){var O=t.postRun.shift();qe.unshift(O)}Je(qe)}}if(!(0<$e))if(P)e(t),P||Je(Be),postMessage({cmd:"loaded"});else{if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Ve();Je(Ue),0<$e||(t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),S()},1)):S())}}if(t.UTF8ToString=Se,t.stringToUTF8=function(S,O,I){return De(S,h(),O,I)},t.lengthBytesUTF8=Re,t.keepRuntimeAlive=je,t.wasmMemory=Y,t.stackSave=de,t.stackRestore=ce,t.stackAlloc=Bt,t.ExitStatus=Ke,t.PThread=ie,Ye=function S(){Ct||pn(),Ct||(Ye=S)},t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);0{var d,l=(d=(d=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(m){var s,h,p;m=m||{},s||(s=m!==void 0?m:{}),s.ready=new Promise(function(M,R){h=M,p=R});var a,o,t,e,n,i,u=Object.assign({},s),g="./this.program",b=(M,R)=>{throw R},y=typeof window=="object",_=typeof importScripts=="function",v=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",w="";v?(w=_?c(908).dirname(w)+"/":"//",i=()=>{n||(e=c(1384),n=c(908))},a=function(M,R){return i(),M=n.normalize(M),e.readFileSync(M,R?void 0:"utf8")},t=M=>((M=a(M,!0)).buffer||(M=new Uint8Array(M)),M),o=(M,R,N)=>{i(),M=n.normalize(M),e.readFile(M,function(V,j){V?N(V):R(j.buffer)})},1{if(x||0{var R=new XMLHttpRequest;return R.open("GET",M,!1),R.send(null),R.responseText},_&&(t=M=>{var R=new XMLHttpRequest;return R.open("GET",M,!1),R.responseType="arraybuffer",R.send(null),new Uint8Array(R.response)}),o=(M,R,N)=>{var V=new XMLHttpRequest;V.open("GET",M,!0),V.responseType="arraybuffer",V.onload=()=>{V.status==200||V.status==0&&V.response?R(V.response):N()},V.onerror=N,V.send(null)});var T,A=s.print||console.log.bind(console),E=s.printErr||console.warn.bind(console);Object.assign(s,u),u=null,s.thisProgram&&(g=s.thisProgram),s.quit&&(b=s.quit),s.wasmBinary&&(T=s.wasmBinary);var x=s.noExitRuntime||!1;typeof WebAssembly!="object"&&Ae("no native wasm support detected");var P,L,F,$,k,q,D=!1,U=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function J(M,R,N){var V=(R>>>=0)+N;for(N=R;M[N]&&!(N>=V);)++N;if(16(j=(240&j)==224?(15&j)<<12|H<<6|X:(7&j)<<18|H<<12|X<<6|63&M[R++])?V+=String.fromCharCode(j):(j-=65536,V+=String.fromCharCode(55296|j>>10,56320|1023&j))}}else V+=String.fromCharCode(j)}return V}function Y(M,R){return(M>>>=0)?J($,M,R):""}function Z(M,R,N,V){if(!(0>>=0;V=N+V-1;for(var H=0;H=X&&(X=65536+((1023&X)<<10)|1023&M.charCodeAt(++H)),127>=X){if(N>=V)break;R[N++>>>0]=X}else{if(2047>=X){if(N+1>=V)break;R[N++>>>0]=192|X>>6}else{if(65535>=X){if(N+2>=V)break;R[N++>>>0]=224|X>>12}else{if(N+3>=V)break;R[N++>>>0]=240|X>>18,R[N++>>>0]=128|X>>12&63}R[N++>>>0]=128|X>>6&63}R[N++>>>0]=128|63&X}}return R[N>>>0]=0,N-j}function te(M){for(var R=0,N=0;N=V?R++:2047>=V?R+=2:55296<=V&&57343>=V?(R+=4,++N):R+=3}return R}function he(){var M=P.buffer;L=M,s.HEAP8=F=new Int8Array(M),s.HEAP16=new Int16Array(M),s.HEAP32=k=new Int32Array(M),s.HEAPU8=$=new Uint8Array(M),s.HEAPU16=new Uint16Array(M),s.HEAPU32=q=new Uint32Array(M),s.HEAPF32=new Float32Array(M),s.HEAPF64=new Float64Array(M)}var Me,Te=[],ue=[],xe=[],_e=[],Ce=0;function ze(){var M=s.preRun.shift();Te.unshift(M)}var Se,De=0,Re=null;function Ae(M){throw s.onAbort&&s.onAbort(M),E(M="Aborted("+M+")"),D=!0,M=new WebAssembly.RuntimeError(M+". Build with -sASSERTIONS for more info."),p(M),M}function we(){return Se.startsWith("data:application/octet-stream;base64,")}if(Se="ort-wasm.wasm",!we()){var Fe=Se;Se=s.locateFile?s.locateFile(Fe,w):w+Fe}function Ue(){var M=Se;try{if(M==Se&&T)return new Uint8Array(T);if(t)return t(M);throw"both async and sync fetching of the wasm failed"}catch(R){Ae(R)}}function Be(M){this.name="ExitStatus",this.message="Program terminated with exit("+M+")",this.status=M}function We(M){for(;0>2>>>0]=R},this.Eb=function(){return q[this.zb+4>>2>>>0]},this.Sb=function(R){q[this.zb+8>>2>>>0]=R},this.Wb=function(){return q[this.zb+8>>2>>>0]},this.Tb=function(){k[this.zb>>2>>>0]=0},this.Ib=function(R){F[this.zb+12>>0>>>0]=R?1:0},this.Pb=function(){return F[this.zb+12>>0>>>0]!=0},this.Jb=function(R){F[this.zb+13>>0>>>0]=R?1:0},this.Lb=function(){return F[this.zb+13>>0>>>0]!=0},this.Rb=function(R,N){this.Fb(0),this.Ub(R),this.Sb(N),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){k[this.zb>>2>>>0]+=1},this.Xb=function(){var R=k[this.zb>>2>>>0];return k[this.zb>>2>>>0]=R-1,R===1},this.Fb=function(R){q[this.zb+16>>2>>>0]=R},this.Ob=function(){return q[this.zb+16>>2>>>0]},this.Qb=function(){if(mt(this.Eb()))return q[this.Db>>2>>>0];var R=this.Ob();return R!==0?R:this.Db}}function $e(M){return rt(new Ee(M).zb)}var Ye=[];function le(M){var R=Ye[M];return R||(M>=Ye.length&&(Ye.length=M+1),Ye[M]=R=Me.get(M)),R}function pt(M){var R=te(M)+1,N=ye(R);return N&&Z(M,F,N,R),N}var ut={};function It(){if(!Ke){var M,R={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:g||"./this.program"};for(M in ut)ut[M]===void 0?delete R[M]:R[M]=ut[M];var N=[];for(M in R)N.push(M+"="+R[M]);Ke=N}return Ke}var Ke,He=[null,[],[]];function lt(M,R){var N=He[M];R===0||R===10?((M===1?A:E)(J(N,0)),N.length=0):N.push(R)}var Le=0;function nt(M){return M%4==0&&(M%100!=0||M%400==0)}var ie=[31,29,31,30,31,30,31,31,30,31,30,31],Je=[31,28,31,30,31,30,31,31,30,31,30,31];function At(M,R,N,V){function j(G,ge,Oe){for(G=typeof G=="number"?G.toString():G||"";G.lengthst?-1:0Qe-G.getDate())){G.setDate(G.getDate()+ge);break}ge-=Qe-G.getDate()+1,G.setDate(1),11>Oe?G.setMonth(Oe+1):(G.setMonth(0),G.setFullYear(G.getFullYear()+1))}return Oe=new Date(G.getFullYear()+1,0,4),ge=ee(new Date(G.getFullYear(),0,4)),Oe=ee(Oe),0>=X(ge,G)?0>=X(Oe,G)?G.getFullYear()+1:G.getFullYear():G.getFullYear()-1}var ae=k[V+40>>2>>>0];for(var ve in V={$b:k[V>>2>>>0],Zb:k[V+4>>2>>>0],Gb:k[V+8>>2>>>0],Kb:k[V+12>>2>>>0],Hb:k[V+16>>2>>>0],Cb:k[V+20>>2>>>0],Ab:k[V+24>>2>>>0],Bb:k[V+28>>2>>>0],bc:k[V+32>>2>>>0],Yb:k[V+36>>2>>>0],ac:ae?Y(ae):""},N=Y(N),ae={"%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(ve,"g"),ae[ve]);var ke="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ne="January February March April May June July August September October November December".split(" ");for(ve in ae={"%a":function(G){return ke[G.Ab].substring(0,3)},"%A":function(G){return ke[G.Ab]},"%b":function(G){return Ne[G.Hb].substring(0,3)},"%B":function(G){return Ne[G.Hb]},"%C":function(G){return H((G.Cb+1900)/100|0,2)},"%d":function(G){return H(G.Kb,2)},"%e":function(G){return j(G.Kb,2," ")},"%g":function(G){return K(G).toString().substring(2)},"%G":function(G){return K(G)},"%H":function(G){return H(G.Gb,2)},"%I":function(G){return(G=G.Gb)==0?G=12:12G.Gb?"AM":"PM"},"%S":function(G){return H(G.$b,2)},"%t":function(){return" "},"%u":function(G){return G.Ab||7},"%U":function(G){return H(Math.floor((G.Bb+7-G.Ab)/7),2)},"%V":function(G){var ge=Math.floor((G.Bb+7-(G.Ab+6)%7)/7);if(2>=(G.Ab+371-G.Bb-2)%7&&ge++,ge)ge==53&&((Oe=(G.Ab+371-G.Bb)%7)==4||Oe==3&&nt(G.Cb)||(ge=1));else{ge=52;var Oe=(G.Ab+7-G.Bb-1)%7;(Oe==4||Oe==5&&nt(G.Cb%400-1))&&ge++}return H(ge,2)},"%w":function(G){return G.Ab},"%W":function(G){return H(Math.floor((G.Bb+7-(G.Ab+6)%7)/7),2)},"%y":function(G){return(G.Cb+1900).toString().substring(2)},"%Y":function(G){return G.Cb+1900},"%z":function(G){var ge=0<=(G=G.Yb);return G=Math.abs(G)/60,(ge?"+":"-")+("0000"+(G/60*100+G%60)).slice(-4)},"%Z":function(G){return G.ac},"%%":function(){return"%"}},N=N.replace(/%%/g,"\0\0"),ae)N.includes(ve)&&(N=N.replace(new RegExp(ve,"g"),ae[ve](V)));return ve=function(G){var ge=Array(te(G)+1);return Z(G,ge,0,ge.length),ge}(N=N.replace(/\0\0/g,"%")),ve.length>R?0:(F.set(ve,M>>>0),ve.length-1)}var Et={a:function(M){return ye(M+24)+24},m:function(M){return(M=new Ee(M)).Pb()||(M.Ib(!0),je--),M.Jb(!1),qe.push(M),M.Nb(),M.Qb()},ia:function(M){throw E("Unexpected exception thrown, this is not properly supported - aborting"),D=!0,M},w:function(){oe(0);var M=qe.pop();if(M.Xb()&&!M.Lb()){var R=M.Wb();R&&le(R)(M.Db),$e(M.Db)}Ve=0},d:function(){var M=Ve;if(!M)return Le=0;var R=new Ee(M);R.Fb(M);var N=R.Eb();if(!N)return Le=0,M;for(var V=Array.prototype.slice.call(arguments),j=0;j>>2]+4294967296*k[M+4>>>2])),k[R>>2>>>0]=M.getUTCSeconds(),k[R+4>>2>>>0]=M.getUTCMinutes(),k[R+8>>2>>>0]=M.getUTCHours(),k[R+12>>2>>>0]=M.getUTCDate(),k[R+16>>2>>>0]=M.getUTCMonth(),k[R+20>>2>>>0]=M.getUTCFullYear()-1900,k[R+24>>2>>>0]=M.getUTCDay(),k[R+28>>2>>>0]=(M.getTime()-Date.UTC(M.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(M,R){M=new Date(1e3*(q[M>>>2]+4294967296*k[M+4>>>2])),k[R>>2>>>0]=M.getSeconds(),k[R+4>>2>>>0]=M.getMinutes(),k[R+8>>2>>>0]=M.getHours(),k[R+12>>2>>>0]=M.getDate(),k[R+16>>2>>>0]=M.getMonth(),k[R+20>>2>>>0]=M.getFullYear()-1900,k[R+24>>2>>>0]=M.getDay();var N=new Date(M.getFullYear(),0,1);k[R+28>>2>>>0]=(M.getTime()-N.getTime())/864e5|0,k[R+36>>2>>>0]=-60*M.getTimezoneOffset();var V=new Date(M.getFullYear(),6,1).getTimezoneOffset();N=N.getTimezoneOffset(),k[R+32>>2>>>0]=0|(V!=N&&M.getTimezoneOffset()==Math.min(N,V))},Fa:function(M){var R=new Date(k[M+20>>2>>>0]+1900,k[M+16>>2>>>0],k[M+12>>2>>>0],k[M+8>>2>>>0],k[M+4>>2>>>0],k[M>>2>>>0],0),N=k[M+32>>2>>>0],V=R.getTimezoneOffset(),j=new Date(R.getFullYear(),0,1),H=new Date(R.getFullYear(),6,1).getTimezoneOffset(),X=j.getTimezoneOffset(),ee=Math.min(X,H);return 0>N?k[M+32>>2>>>0]=+(H!=X&&ee==V):0>2>>>0]=R.getDay(),k[M+28>>2>>>0]=(R.getTime()-j.getTime())/864e5|0,k[M>>2>>>0]=R.getSeconds(),k[M+4>>2>>>0]=R.getMinutes(),k[M+8>>2>>>0]=R.getHours(),k[M+12>>2>>>0]=R.getDate(),k[M+16>>2>>>0]=R.getMonth(),R.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function M(R,N,V){M.Vb||(M.Vb=!0,function(j,H,X){function ee(Ne){return(Ne=Ne.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Ne[1]:"GMT"}var K=new Date().getFullYear(),ae=new Date(K,0,1),ve=new Date(K,6,1);K=ae.getTimezoneOffset();var ke=ve.getTimezoneOffset();k[j>>2>>>0]=60*Math.max(K,ke),k[H>>2>>>0]=+(K!=ke),j=ee(ae),H=ee(ve),j=pt(j),H=pt(H),ke>2>>>0]=j,q[X+4>>2>>>0]=H):(q[X>>2>>>0]=H,q[X+4>>2>>>0]=j)}(R,N,V))},B:function(){Ae("")},ma:function(){return 4294901760},I:v?()=>{var M=process.hrtime();return 1e3*M[0]+M[1]/1e6}:()=>performance.now(),xa:function(M,R,N){$.copyWithin(M>>>0,R>>>0,R+N>>>0)},G:function(M){var R=$.length;if(4294901760<(M>>>=0))return!1;for(var N=1;4>=N;N*=2){var V=R*(1+.2/N);V=Math.min(V,M+100663296);var j=Math;V=Math.max(M,V),j=j.min.call(j,4294901760,V+(65536-V%65536)%65536);e:{try{P.grow(j-L.byteLength+65535>>>16),he();var H=1;break e}catch{}H=void 0}if(H)return!0}return!1},va:function(M,R){var N=0;return It().forEach(function(V,j){var H=R+N;for(j=q[M+4*j>>2>>>0]=H,H=0;H>0>>>0]=V.charCodeAt(H);F[j>>0>>>0]=0,N+=V.length+1}),0},wa:function(M,R){var N=It();q[M>>2>>>0]=N.length;var V=0;return N.forEach(function(j){V+=j.length+1}),q[R>>2>>>0]=V,0},ba:function(M){x||0>2>>>0],ee=q[R+4>>2>>>0];R+=8;for(var K=0;K>>0]);j+=ee}return q[V>>2>>>0]=j,0},c:function(){return Le},ja:function M(R,N){M.Mb||(M.Mb=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var j=new Uint8Array(1);return()=>(crypto.getRandomValues(j),j[0])}if(v)try{var H=c(Object(function(){var X=new Error("Cannot find module 'crypto'");throw X.code="MODULE_NOT_FOUND",X}()));return()=>H.randomBytes(1)[0]}catch{}return()=>Ae("randomDevice")}());for(var V=0;V>0>>>0]=M.Mb();return 0},ea:function(M,R,N){var V=re();try{return le(M)(R,N)}catch(j){if(se(V),j!==j+0)throw j;oe(1,0)}},fa:function(M,R,N){var V=re();try{return le(M)(R,N)}catch(j){if(se(V),j!==j+0)throw j;oe(1,0)}},J:function(M){var R=re();try{return le(M)()}catch(N){if(se(R),N!==N+0)throw N;oe(1,0)}},e:function(M,R){var N=re();try{return le(M)(R)}catch(V){if(se(N),V!==V+0)throw V;oe(1,0)}},N:function(M,R,N){var V=re();try{return le(M)(R,N)}catch(j){if(se(V),j!==j+0)throw j;oe(1,0)}},O:function(M,R,N){var V=re();try{return le(M)(R,N)}catch(j){if(se(V),j!==j+0)throw j;oe(1,0)}},j:function(M,R,N){var V=re();try{return le(M)(R,N)}catch(j){if(se(V),j!==j+0)throw j;oe(1,0)}},o:function(M,R,N,V){var j=re();try{return le(M)(R,N,V)}catch(H){if(se(j),H!==H+0)throw H;oe(1,0)}},p:function(M,R,N,V,j){var H=re();try{return le(M)(R,N,V,j)}catch(X){if(se(H),X!==X+0)throw X;oe(1,0)}},M:function(M,R,N,V,j,H){var X=re();try{return le(M)(R,N,V,j,H)}catch(ee){if(se(X),ee!==ee+0)throw ee;oe(1,0)}},r:function(M,R,N,V,j,H){var X=re();try{return le(M)(R,N,V,j,H)}catch(ee){if(se(X),ee!==ee+0)throw ee;oe(1,0)}},v:function(M,R,N,V,j,H,X){var ee=re();try{return le(M)(R,N,V,j,H,X)}catch(K){if(se(ee),K!==K+0)throw K;oe(1,0)}},K:function(M,R,N,V,j,H,X,ee){var K=re();try{return le(M)(R,N,V,j,H,X,ee)}catch(ae){if(se(K),ae!==ae+0)throw ae;oe(1,0)}},D:function(M,R,N,V,j,H,X,ee,K,ae,ve,ke){var Ne=re();try{return le(M)(R,N,V,j,H,X,ee,K,ae,ve,ke)}catch(G){if(se(Ne),G!==G+0)throw G;oe(1,0)}},X:function(M,R,N,V,j,H,X,ee){var K=re();try{return ot(M,R,N,V,j,H,X,ee)}catch(ae){if(se(K),ae!==ae+0)throw ae;oe(1,0)}},V:function(M,R,N,V,j,H,X){var ee=re();try{return bt(M,R,N,V,j,H,X)}catch(K){if(se(ee),K!==K+0)throw K;oe(1,0)}},U:function(M,R,N,V,j){var H=re();try{return ht(M,R,N,V,j)}catch(X){if(se(H),X!==X+0)throw X;oe(1,0)}},Z:function(M,R,N,V){var j=re();try{return wt(M,R,N,V)}catch(H){if(se(j),H!==H+0)throw H;oe(1,0)}},W:function(M){var R=re();try{return gt(M)}catch(N){if(se(R),N!==N+0)throw N;oe(1,0)}},Y:function(M,R){var N=re();try{return xt(M,R)}catch(V){if(se(N),V!==V+0)throw V;oe(1,0)}},T:function(M,R,N){var V=re();try{return dt(M,R,N)}catch(j){if(se(V),j!==j+0)throw j;oe(1,0)}},f:function(M){var R=re();try{le(M)()}catch(N){if(se(R),N!==N+0)throw N;oe(1,0)}},q:function(M,R){var N=re();try{le(M)(R)}catch(V){if(se(N),V!==V+0)throw V;oe(1,0)}},h:function(M,R,N){var V=re();try{le(M)(R,N)}catch(j){if(se(V),j!==j+0)throw j;oe(1,0)}},da:function(M,R,N,V){var j=re();try{le(M)(R,N,V)}catch(H){if(se(j),H!==H+0)throw H;oe(1,0)}},l:function(M,R,N,V){var j=re();try{le(M)(R,N,V)}catch(H){if(se(j),H!==H+0)throw H;oe(1,0)}},t:function(M,R,N,V,j){var H=re();try{le(M)(R,N,V,j)}catch(X){if(se(H),X!==X+0)throw X;oe(1,0)}},u:function(M,R,N,V,j,H){var X=re();try{le(M)(R,N,V,j,H)}catch(ee){if(se(X),ee!==ee+0)throw ee;oe(1,0)}},x:function(M,R,N,V,j,H,X){var ee=re();try{le(M)(R,N,V,j,H,X)}catch(K){if(se(ee),K!==K+0)throw K;oe(1,0)}},z:function(M,R,N,V,j,H,X,ee){var K=re();try{le(M)(R,N,V,j,H,X,ee)}catch(ae){if(se(K),ae!==ae+0)throw ae;oe(1,0)}},ga:function(M,R,N,V,j,H,X,ee,K){var ae=re();try{le(M)(R,N,V,j,H,X,ee,K)}catch(ve){if(se(ae),ve!==ve+0)throw ve;oe(1,0)}},A:function(M,R,N,V,j,H,X,ee,K,ae,ve){var ke=re();try{le(M)(R,N,V,j,H,X,ee,K,ae,ve)}catch(Ne){if(se(ke),Ne!==Ne+0)throw Ne;oe(1,0)}},C:function(M,R,N,V,j,H,X,ee,K,ae,ve,ke,Ne,G,ge,Oe){var Qe=re();try{le(M)(R,N,V,j,H,X,ee,K,ae,ve,ke,Ne,G,ge,Oe)}catch(st){if(se(Qe),st!==st+0)throw st;oe(1,0)}},aa:function(M,R,N,V,j,H,X,ee){var K=re();try{yt(M,R,N,V,j,H,X,ee)}catch(ae){if(se(K),ae!==ae+0)throw ae;oe(1,0)}},_:function(M,R,N,V,j,H,X,ee,K,ae,ve,ke){var Ne=re();try{vt(M,R,N,V,j,H,X,ee,K,ae,ve,ke)}catch(G){if(se(Ne),G!==G+0)throw G;oe(1,0)}},$:function(M,R,N,V,j,H){var X=re();try{_t(M,R,N,V,j,H)}catch(ee){if(se(X),ee!==ee+0)throw ee;oe(1,0)}},n:function(M){return M},F:function(M){Le=M},ha:At,y:function(M,R,N,V){return At(M,R,N,V)}};(function(){function M(j){s.asm=j.exports,P=s.asm.Ka,he(),Me=s.asm.ib,ue.unshift(s.asm.La),De--,s.monitorRunDependencies&&s.monitorRunDependencies(De),De==0&&Re&&(j=Re,Re=null,j())}function R(j){M(j.instance)}function N(j){return function(){if(!T&&(y||_)){if(typeof fetch=="function"&&!Se.startsWith("file://"))return fetch(Se,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+Se+"'";return H.arrayBuffer()}).catch(function(){return Ue()});if(o)return new Promise(function(H,X){o(Se,function(ee){H(new Uint8Array(ee))},X)})}return Promise.resolve().then(function(){return Ue()})}().then(function(H){return WebAssembly.instantiate(H,V)}).then(function(H){return H}).then(j,function(H){E("failed to asynchronously prepare wasm: "+H),Ae(H)})}var V={a:Et};if(De++,s.monitorRunDependencies&&s.monitorRunDependencies(De),s.instantiateWasm)try{return s.instantiateWasm(V,M)}catch(j){return E("Module.instantiateWasm callback failed with error: "+j),!1}(T||typeof WebAssembly.instantiateStreaming!="function"||we()||Se.startsWith("file://")||v||typeof fetch!="function"?N(R):fetch(Se,{credentials:"same-origin"}).then(function(j){return WebAssembly.instantiateStreaming(j,V).then(R,function(H){return E("wasm streaming compile failed: "+H),E("falling back to ArrayBuffer instantiation"),N(R)})})).catch(p)})(),s.___wasm_call_ctors=function(){return(s.___wasm_call_ctors=s.asm.La).apply(null,arguments)},s._OrtInit=function(){return(s._OrtInit=s.asm.Ma).apply(null,arguments)},s._OrtCreateSessionOptions=function(){return(s._OrtCreateSessionOptions=s.asm.Na).apply(null,arguments)},s._OrtAppendExecutionProvider=function(){return(s._OrtAppendExecutionProvider=s.asm.Oa).apply(null,arguments)},s._OrtAddSessionConfigEntry=function(){return(s._OrtAddSessionConfigEntry=s.asm.Pa).apply(null,arguments)},s._OrtReleaseSessionOptions=function(){return(s._OrtReleaseSessionOptions=s.asm.Qa).apply(null,arguments)},s._OrtCreateSession=function(){return(s._OrtCreateSession=s.asm.Ra).apply(null,arguments)},s._OrtReleaseSession=function(){return(s._OrtReleaseSession=s.asm.Sa).apply(null,arguments)},s._OrtGetInputCount=function(){return(s._OrtGetInputCount=s.asm.Ta).apply(null,arguments)},s._OrtGetOutputCount=function(){return(s._OrtGetOutputCount=s.asm.Ua).apply(null,arguments)},s._OrtGetInputName=function(){return(s._OrtGetInputName=s.asm.Va).apply(null,arguments)},s._OrtGetOutputName=function(){return(s._OrtGetOutputName=s.asm.Wa).apply(null,arguments)},s._OrtFree=function(){return(s._OrtFree=s.asm.Xa).apply(null,arguments)},s._OrtCreateTensor=function(){return(s._OrtCreateTensor=s.asm.Ya).apply(null,arguments)},s._OrtGetTensorData=function(){return(s._OrtGetTensorData=s.asm.Za).apply(null,arguments)},s._OrtReleaseTensor=function(){return(s._OrtReleaseTensor=s.asm._a).apply(null,arguments)},s._OrtCreateRunOptions=function(){return(s._OrtCreateRunOptions=s.asm.$a).apply(null,arguments)},s._OrtAddRunConfigEntry=function(){return(s._OrtAddRunConfigEntry=s.asm.ab).apply(null,arguments)},s._OrtReleaseRunOptions=function(){return(s._OrtReleaseRunOptions=s.asm.bb).apply(null,arguments)},s._OrtRun=function(){return(s._OrtRun=s.asm.cb).apply(null,arguments)},s._OrtEndProfiling=function(){return(s._OrtEndProfiling=s.asm.db).apply(null,arguments)};var Xe,ye=s._malloc=function(){return(ye=s._malloc=s.asm.eb).apply(null,arguments)},rt=s._free=function(){return(rt=s._free=s.asm.fb).apply(null,arguments)},ct=s._fflush=function(){return(ct=s._fflush=s.asm.gb).apply(null,arguments)},it=s.___funcs_on_exit=function(){return(it=s.___funcs_on_exit=s.asm.hb).apply(null,arguments)},oe=s._setThrew=function(){return(oe=s._setThrew=s.asm.jb).apply(null,arguments)},re=s.stackSave=function(){return(re=s.stackSave=s.asm.kb).apply(null,arguments)},se=s.stackRestore=function(){return(se=s.stackRestore=s.asm.lb).apply(null,arguments)},ft=s.stackAlloc=function(){return(ft=s.stackAlloc=s.asm.mb).apply(null,arguments)},et=s.___cxa_can_catch=function(){return(et=s.___cxa_can_catch=s.asm.nb).apply(null,arguments)},mt=s.___cxa_is_pointer_type=function(){return(mt=s.___cxa_is_pointer_type=s.asm.ob).apply(null,arguments)},gt=s.dynCall_j=function(){return(gt=s.dynCall_j=s.asm.pb).apply(null,arguments)},bt=s.dynCall_iiiiij=function(){return(bt=s.dynCall_iiiiij=s.asm.qb).apply(null,arguments)},dt=s.dynCall_jii=function(){return(dt=s.dynCall_jii=s.asm.rb).apply(null,arguments)},yt=s.dynCall_viiiiij=function(){return(yt=s.dynCall_viiiiij=s.asm.sb).apply(null,arguments)},_t=s.dynCall_vjji=function(){return(_t=s.dynCall_vjji=s.asm.tb).apply(null,arguments)},vt=s.dynCall_viiijjjii=function(){return(vt=s.dynCall_viiijjjii=s.asm.ub).apply(null,arguments)},wt=s.dynCall_iij=function(){return(wt=s.dynCall_iij=s.asm.vb).apply(null,arguments)},xt=s.dynCall_ji=function(){return(xt=s.dynCall_ji=s.asm.wb).apply(null,arguments)},ot=s.dynCall_iiiiiij=function(){return(ot=s.dynCall_iiiiiij=s.asm.xb).apply(null,arguments)},ht=s.dynCall_iiij=function(){return(ht=s.dynCall_iiij=s.asm.yb).apply(null,arguments)};function Tt(){function M(){if(!Xe&&(Xe=!0,s.calledRun=!0,!D)){if(We(ue),h(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;){var R=s.postRun.shift();_e.unshift(R)}We(_e)}}if(!(0{f.exports=function(r,c){for(var d=new Array(arguments.length-1),l=0,m=2,s=!0;m{var c=r;c.length=function(h){var p=h.length;if(!p)return 0;for(var a=0;--p%4>1&&h.charAt(p)==="=";)++a;return Math.ceil(3*h.length)/4-a};for(var d=new Array(64),l=new Array(123),m=0;m<64;)l[d[m]=m<26?m+65:m<52?m+71:m<62?m-4:m-59|43]=m++;c.encode=function(h,p,a){for(var o,t=null,e=[],n=0,i=0;p>2],o=(3&u)<<4,i=1;break;case 1:e[n++]=d[o|u>>4],o=(15&u)<<2,i=2;break;case 2:e[n++]=d[o|u>>6],e[n++]=d[63&u],i=0}n>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,e)),n=0)}return i&&(e[n++]=d[o],e[n++]=61,i===1&&(e[n++]=61)),t?(n&&t.push(String.fromCharCode.apply(String,e.slice(0,n))),t.join("")):String.fromCharCode.apply(String,e.slice(0,n))};var s="invalid encoding";c.decode=function(h,p,a){for(var o,t=a,e=0,n=0;n1)break;if((i=l[i])===void 0)throw Error(s);switch(e){case 0:o=i,e=1;break;case 1:p[a++]=o<<2|(48&i)>>4,o=i,e=2;break;case 2:p[a++]=(15&o)<<4|(60&i)>>2,o=i,e=3;break;case 3:p[a++]=(3&o)<<6|i,e=0}}if(e===1)throw Error(s);return a-t},c.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9211:f=>{function r(){this._listeners={}}f.exports=r,r.prototype.on=function(c,d,l){return(this._listeners[c]||(this._listeners[c]=[])).push({fn:d,ctx:l||this}),this},r.prototype.off=function(c,d){if(c===void 0)this._listeners={};else if(d===void 0)this._listeners[c]=[];else for(var l=this._listeners[c],m=0;m{function r(s){return typeof Float32Array<"u"?function(){var h=new Float32Array([-0]),p=new Uint8Array(h.buffer),a=p[3]===128;function o(i,u,g){h[0]=i,u[g]=p[0],u[g+1]=p[1],u[g+2]=p[2],u[g+3]=p[3]}function t(i,u,g){h[0]=i,u[g]=p[3],u[g+1]=p[2],u[g+2]=p[1],u[g+3]=p[0]}function e(i,u){return p[0]=i[u],p[1]=i[u+1],p[2]=i[u+2],p[3]=i[u+3],h[0]}function n(i,u){return p[3]=i[u],p[2]=i[u+1],p[1]=i[u+2],p[0]=i[u+3],h[0]}s.writeFloatLE=a?o:t,s.writeFloatBE=a?t:o,s.readFloatLE=a?e:n,s.readFloatBE=a?n:e}():function(){function h(a,o,t,e){var n=o<0?1:0;if(n&&(o=-o),o===0)a(1/o>0?0:2147483648,t,e);else if(isNaN(o))a(2143289344,t,e);else if(o>34028234663852886e22)a((n<<31|2139095040)>>>0,t,e);else if(o<11754943508222875e-54)a((n<<31|Math.round(o/1401298464324817e-60))>>>0,t,e);else{var i=Math.floor(Math.log(o)/Math.LN2);a((n<<31|i+127<<23|8388607&Math.round(o*Math.pow(2,-i)*8388608))>>>0,t,e)}}function p(a,o,t){var e=a(o,t),n=2*(e>>31)+1,i=e>>>23&255,u=8388607&e;return i===255?u?NaN:n*(1/0):i===0?1401298464324817e-60*n*u:n*Math.pow(2,i-150)*(u+8388608)}s.writeFloatLE=h.bind(null,c),s.writeFloatBE=h.bind(null,d),s.readFloatLE=p.bind(null,l),s.readFloatBE=p.bind(null,m)}(),typeof Float64Array<"u"?function(){var h=new Float64Array([-0]),p=new Uint8Array(h.buffer),a=p[7]===128;function o(i,u,g){h[0]=i,u[g]=p[0],u[g+1]=p[1],u[g+2]=p[2],u[g+3]=p[3],u[g+4]=p[4],u[g+5]=p[5],u[g+6]=p[6],u[g+7]=p[7]}function t(i,u,g){h[0]=i,u[g]=p[7],u[g+1]=p[6],u[g+2]=p[5],u[g+3]=p[4],u[g+4]=p[3],u[g+5]=p[2],u[g+6]=p[1],u[g+7]=p[0]}function e(i,u){return p[0]=i[u],p[1]=i[u+1],p[2]=i[u+2],p[3]=i[u+3],p[4]=i[u+4],p[5]=i[u+5],p[6]=i[u+6],p[7]=i[u+7],h[0]}function n(i,u){return p[7]=i[u],p[6]=i[u+1],p[5]=i[u+2],p[4]=i[u+3],p[3]=i[u+4],p[2]=i[u+5],p[1]=i[u+6],p[0]=i[u+7],h[0]}s.writeDoubleLE=a?o:t,s.writeDoubleBE=a?t:o,s.readDoubleLE=a?e:n,s.readDoubleBE=a?n:e}():function(){function h(a,o,t,e,n,i){var u=e<0?1:0;if(u&&(e=-e),e===0)a(0,n,i+o),a(1/e>0?0:2147483648,n,i+t);else if(isNaN(e))a(0,n,i+o),a(2146959360,n,i+t);else if(e>17976931348623157e292)a(0,n,i+o),a((u<<31|2146435072)>>>0,n,i+t);else{var g;if(e<22250738585072014e-324)a((g=e/5e-324)>>>0,n,i+o),a((u<<31|g/4294967296)>>>0,n,i+t);else{var b=Math.floor(Math.log(e)/Math.LN2);b===1024&&(b=1023),a(4503599627370496*(g=e*Math.pow(2,-b))>>>0,n,i+o),a((u<<31|b+1023<<20|1048576*g&1048575)>>>0,n,i+t)}}}function p(a,o,t,e,n){var i=a(e,n+o),u=a(e,n+t),g=2*(u>>31)+1,b=u>>>20&2047,y=4294967296*(1048575&u)+i;return b===2047?y?NaN:g*(1/0):b===0?5e-324*g*y:g*Math.pow(2,b-1075)*(y+4503599627370496)}s.writeDoubleLE=h.bind(null,c,0,4),s.writeDoubleBE=h.bind(null,d,4,0),s.readDoubleLE=p.bind(null,l,0,4),s.readDoubleBE=p.bind(null,m,4,0)}(),s}function c(s,h,p){h[p]=255&s,h[p+1]=s>>>8&255,h[p+2]=s>>>16&255,h[p+3]=s>>>24}function d(s,h,p){h[p]=s>>>24,h[p+1]=s>>>16&255,h[p+2]=s>>>8&255,h[p+3]=255&s}function l(s,h){return(s[h]|s[h+1]<<8|s[h+2]<<16|s[h+3]<<24)>>>0}function m(s,h){return(s[h]<<24|s[h+1]<<16|s[h+2]<<8|s[h+3])>>>0}f.exports=r(r)},7199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(f){}return null}module.exports=inquire},6662:f=>{f.exports=function(r,c,d){var l=d||8192,m=l>>>1,s=null,h=l;return function(p){if(p<1||p>m)return r(p);h+p>l&&(s=r(l),h=0);var a=c.call(s,h,h+=p);return 7&h&&(h=1+(7|h)),a}}},4997:(f,r)=>{var c=r;c.length=function(d){for(var l=0,m=0,s=0;s191&&s<224?p[a++]=(31&s)<<6|63&d[l++]:s>239&&s<365?(s=((7&s)<<18|(63&d[l++])<<12|(63&d[l++])<<6|63&d[l++])-65536,p[a++]=55296+(s>>10),p[a++]=56320+(1023&s)):p[a++]=(15&s)<<12|(63&d[l++])<<6|63&d[l++],a>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,p)),a=0);return h?(a&&h.push(String.fromCharCode.apply(String,p.slice(0,a))),h.join("")):String.fromCharCode.apply(String,p.slice(0,a))},c.write=function(d,l,m){for(var s,h,p=m,a=0;a>6|192,l[m++]=63&s|128):(64512&s)==55296&&(64512&(h=d.charCodeAt(a+1)))==56320?(s=65536+((1023&s)<<10)+(1023&h),++a,l[m++]=s>>18|240,l[m++]=s>>12&63|128,l[m++]=s>>6&63|128,l[m++]=63&s|128):(l[m++]=s>>12|224,l[m++]=s>>6&63|128,l[m++]=63&s|128);return m-p}},3442:(f,r)=>{r.__esModule=!0;var c=function(){function d(l){if(!l)throw new TypeError("Invalid argument; `value` has no value.");this.value=d.EMPTY,l&&d.isGuid(l)&&(this.value=l)}return d.isGuid=function(l){var m=l.toString();return l&&(l instanceof d||d.validator.test(m))},d.create=function(){return new d([d.gen(2),d.gen(1),d.gen(1),d.gen(1),d.gen(3)].join("-"))},d.createEmpty=function(){return new d("emptyguid")},d.parse=function(l){return new d(l)},d.raw=function(){return[d.gen(2),d.gen(1),d.gen(1),d.gen(1),d.gen(3)].join("-")},d.gen=function(l){for(var m="",s=0;s{f.exports=c;var r=null;try{r=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function c(x,P,L){this.low=0|x,this.high=0|P,this.unsigned=!!L}function d(x){return(x&&x.__isLong__)===!0}c.prototype.__isLong__,Object.defineProperty(c.prototype,"__isLong__",{value:!0}),c.isLong=d;var l={},m={};function s(x,P){var L,F,$;return P?($=0<=(x>>>=0)&&x<256)&&(F=m[x])?F:(L=p(x,(0|x)<0?-1:0,!0),$&&(m[x]=L),L):($=-128<=(x|=0)&&x<128)&&(F=l[x])?F:(L=p(x,x<0?-1:0,!1),$&&(l[x]=L),L)}function h(x,P){if(isNaN(x))return P?b:g;if(P){if(x<0)return b;if(x>=n)return T}else{if(x<=-i)return A;if(x+1>=i)return w}return x<0?h(-x,P).neg():p(x%e|0,x/e|0,P)}function p(x,P,L){return new c(x,P,L)}c.fromInt=s,c.fromNumber=h,c.fromBits=p;var a=Math.pow;function o(x,P,L){if(x.length===0)throw Error("empty string");if(x==="NaN"||x==="Infinity"||x==="+Infinity"||x==="-Infinity")return g;if(typeof P=="number"?(L=P,P=!1):P=!!P,(L=L||10)<2||360)throw Error("interior hyphen");if(F===0)return o(x.substring(1),P,L).neg();for(var $=h(a(L,8)),k=g,q=0;q>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*e+(this.low>>>0):this.high*e+(this.low>>>0)},E.toString=function(x){if((x=x||10)<2||36>>0).toString(x);if((k=D).isZero())return U+q;for(;U.length<6;)U="0"+U;q=""+U+q}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(A)?64:this.neg().getNumBitsAbs();for(var x=this.high!=0?this.high:this.low,P=31;P>0&&!(x&1<=0},E.isOdd=function(){return(1&this.low)==1},E.isEven=function(){return(1&this.low)==0},E.equals=function(x){return d(x)||(x=t(x)),(this.unsigned===x.unsigned||this.high>>>31!=1||x.high>>>31!=1)&&this.high===x.high&&this.low===x.low},E.eq=E.equals,E.notEquals=function(x){return!this.eq(x)},E.neq=E.notEquals,E.ne=E.notEquals,E.lessThan=function(x){return this.comp(x)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(x){return this.comp(x)<=0},E.lte=E.lessThanOrEqual,E.le=E.lessThanOrEqual,E.greaterThan=function(x){return this.comp(x)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(x){return this.comp(x)>=0},E.gte=E.greaterThanOrEqual,E.ge=E.greaterThanOrEqual,E.compare=function(x){if(d(x)||(x=t(x)),this.eq(x))return 0;var P=this.isNegative(),L=x.isNegative();return P&&!L?-1:!P&&L?1:this.unsigned?x.high>>>0>this.high>>>0||x.high===this.high&&x.low>>>0>this.low>>>0?-1:1:this.sub(x).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(A)?A:this.not().add(y)},E.neg=E.negate,E.add=function(x){d(x)||(x=t(x));var P=this.high>>>16,L=65535&this.high,F=this.low>>>16,$=65535&this.low,k=x.high>>>16,q=65535&x.high,D=x.low>>>16,U=0,J=0,Y=0,Z=0;return Y+=(Z+=$+(65535&x.low))>>>16,J+=(Y+=F+D)>>>16,U+=(J+=L+q)>>>16,U+=P+k,p((Y&=65535)<<16|(Z&=65535),(U&=65535)<<16|(J&=65535),this.unsigned)},E.subtract=function(x){return d(x)||(x=t(x)),this.add(x.neg())},E.sub=E.subtract,E.multiply=function(x){if(this.isZero())return g;if(d(x)||(x=t(x)),r)return p(r.mul(this.low,this.high,x.low,x.high),r.get_high(),this.unsigned);if(x.isZero())return g;if(this.eq(A))return x.isOdd()?A:g;if(x.eq(A))return this.isOdd()?A:g;if(this.isNegative())return x.isNegative()?this.neg().mul(x.neg()):this.neg().mul(x).neg();if(x.isNegative())return this.mul(x.neg()).neg();if(this.lt(u)&&x.lt(u))return h(this.toNumber()*x.toNumber(),this.unsigned);var P=this.high>>>16,L=65535&this.high,F=this.low>>>16,$=65535&this.low,k=x.high>>>16,q=65535&x.high,D=x.low>>>16,U=65535&x.low,J=0,Y=0,Z=0,te=0;return Z+=(te+=$*U)>>>16,Y+=(Z+=F*U)>>>16,Z&=65535,Y+=(Z+=$*D)>>>16,J+=(Y+=L*U)>>>16,Y&=65535,J+=(Y+=F*D)>>>16,Y&=65535,J+=(Y+=$*q)>>>16,J+=P*U+L*D+F*q+$*k,p((Z&=65535)<<16|(te&=65535),(J&=65535)<<16|(Y&=65535),this.unsigned)},E.mul=E.multiply,E.divide=function(x){if(d(x)||(x=t(x)),x.isZero())throw Error("division by zero");var P,L,F;if(r)return this.unsigned||this.high!==-2147483648||x.low!==-1||x.high!==-1?p((this.unsigned?r.div_u:r.div_s)(this.low,this.high,x.low,x.high),r.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?b:g;if(this.unsigned){if(x.unsigned||(x=x.toUnsigned()),x.gt(this))return b;if(x.gt(this.shru(1)))return _;F=b}else{if(this.eq(A))return x.eq(y)||x.eq(v)?A:x.eq(A)?y:(P=this.shr(1).div(x).shl(1)).eq(g)?x.isNegative()?y:v:(L=this.sub(x.mul(P)),F=P.add(L.div(x)));if(x.eq(A))return this.unsigned?b:g;if(this.isNegative())return x.isNegative()?this.neg().div(x.neg()):this.neg().div(x).neg();if(x.isNegative())return this.div(x.neg()).neg();F=g}for(L=this;L.gte(x);){P=Math.max(1,Math.floor(L.toNumber()/x.toNumber()));for(var $=Math.ceil(Math.log(P)/Math.LN2),k=$<=48?1:a(2,$-48),q=h(P),D=q.mul(x);D.isNegative()||D.gt(L);)D=(q=h(P-=k,this.unsigned)).mul(x);q.isZero()&&(q=y),F=F.add(q),L=L.sub(D)}return F},E.div=E.divide,E.modulo=function(x){return d(x)||(x=t(x)),r?p((this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,x.low,x.high),r.get_high(),this.unsigned):this.sub(this.div(x).mul(x))},E.mod=E.modulo,E.rem=E.modulo,E.not=function(){return p(~this.low,~this.high,this.unsigned)},E.and=function(x){return d(x)||(x=t(x)),p(this.low&x.low,this.high&x.high,this.unsigned)},E.or=function(x){return d(x)||(x=t(x)),p(this.low|x.low,this.high|x.high,this.unsigned)},E.xor=function(x){return d(x)||(x=t(x)),p(this.low^x.low,this.high^x.high,this.unsigned)},E.shiftLeft=function(x){return d(x)&&(x=x.toInt()),(x&=63)==0?this:x<32?p(this.low<>>32-x,this.unsigned):p(0,this.low<>>x|this.high<<32-x,this.high>>x,this.unsigned):p(this.high>>x-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(x){if(d(x)&&(x=x.toInt()),(x&=63)==0)return this;var P=this.high;return x<32?p(this.low>>>x|P<<32-x,P>>>x,this.unsigned):p(x===32?P:P>>>x-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.shr_u=E.shiftRightUnsigned,E.toSigned=function(){return this.unsigned?p(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:p(this.low,this.high,!0)},E.toBytes=function(x){return x?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var x=this.high,P=this.low;return[255&P,P>>>8&255,P>>>16&255,P>>>24,255&x,x>>>8&255,x>>>16&255,x>>>24]},E.toBytesBE=function(){var x=this.high,P=this.low;return[x>>>24,x>>>16&255,x>>>8&255,255&x,P>>>24,P>>>16&255,P>>>8&255,255&P]},c.fromBytes=function(x,P,L){return L?c.fromBytesLE(x,P):c.fromBytesBE(x,P)},c.fromBytesLE=function(x,P){return new c(x[0]|x[1]<<8|x[2]<<16|x[3]<<24,x[4]|x[5]<<8|x[6]<<16|x[7]<<24,P)},c.fromBytesBE=function(x,P){return new c(x[4]<<24|x[5]<<16|x[6]<<8|x[7],x[0]<<24|x[1]<<16|x[2]<<8|x[3],P)}},1446:(f,r,c)=>{var d,l,m,s=c(2100),h=s.Reader,p=s.Writer,a=s.util,o=s.roots.default||(s.roots.default={});o.onnx=((m={}).Version=(d={},(l=Object.create(d))[d[0]="_START_VERSION"]=0,l[d[1]="IR_VERSION_2017_10_10"]=1,l[d[2]="IR_VERSION_2017_10_30"]=2,l[d[3]="IR_VERSION_2017_11_3"]=3,l[d[4]="IR_VERSION_2019_1_22"]=4,l[d[5]="IR_VERSION"]=5,l),m.AttributeProto=function(){function t(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],e)for(var n=Object.keys(e),i=0;i>>3){case 1:u.name=e.string();break;case 21:u.refAttrName=e.string();break;case 13:u.docString=e.string();break;case 20:u.type=e.int32();break;case 2:u.f=e.float();break;case 3:u.i=e.int64();break;case 4:u.s=e.bytes();break;case 5:u.t=o.onnx.TensorProto.decode(e,e.uint32());break;case 6:u.g=o.onnx.GraphProto.decode(e,e.uint32());break;case 7:if(u.floats&&u.floats.length||(u.floats=[]),(7&g)==2)for(var b=e.uint32()+e.pos;e.pos>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?a.base64.decode(e.s,n.s=a.newBuffer(a.base64.length(e.s)),0):e.s.length&&(n.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");n.t=o.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");n.g=o.onnx.GraphProto.fromObject(e.g)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");n.floats=[];for(var i=0;i>>0,e.ints[i].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(n.strings=[],i=0;i>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(i.s=n.bytes===String?a.base64.encode(e.s,0,e.s.length):n.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(i.t=o.onnx.TensorProto.toObject(e.t,n)),e.g!=null&&e.hasOwnProperty("g")&&(i.g=o.onnx.GraphProto.toObject(e.g,n)),e.floats&&e.floats.length){i.floats=[];for(var g=0;g>>0,e.ints[g].high>>>0).toNumber():e.ints[g];if(e.strings&&e.strings.length)for(i.strings=[],g=0;g>>3){case 1:u.name=e.string();break;case 2:u.type=o.onnx.TypeProto.decode(e,e.uint32());break;case 3:u.docString=e.string();break;default:e.skipType(7&g)}}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!a.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var n=o.onnx.TypeProto.verify(e.type);if(n)return"type."+n}return e.docString!=null&&e.hasOwnProperty("docString")&&!a.isString(e.docString)?"docString: string expected":null},t.fromObject=function(e){if(e instanceof o.onnx.ValueInfoProto)return e;var n=new o.onnx.ValueInfoProto;if(e.name!=null&&(n.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");n.type=o.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(n.docString=String(e.docString)),n},t.toObject=function(e,n){n||(n={});var i={};return n.defaults&&(i.name="",i.type=null,i.docString=""),e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.type!=null&&e.hasOwnProperty("type")&&(i.type=o.onnx.TypeProto.toObject(e.type,n)),e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),m.NodeProto=function(){function t(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var n=Object.keys(e),i=0;i>>3){case 1:u.input&&u.input.length||(u.input=[]),u.input.push(e.string());break;case 2:u.output&&u.output.length||(u.output=[]),u.output.push(e.string());break;case 3:u.name=e.string();break;case 4:u.opType=e.string();break;case 7:u.domain=e.string();break;case 5:u.attribute&&u.attribute.length||(u.attribute=[]),u.attribute.push(o.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:u.docString=e.string();break;default:e.skipType(7&g)}}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var n=0;n>>3){case 1:u.irVersion=e.int64();break;case 8:u.opsetImport&&u.opsetImport.length||(u.opsetImport=[]),u.opsetImport.push(o.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:u.producerName=e.string();break;case 3:u.producerVersion=e.string();break;case 4:u.domain=e.string();break;case 5:u.modelVersion=e.int64();break;case 6:u.docString=e.string();break;case 7:u.graph=o.onnx.GraphProto.decode(e,e.uint32());break;case 14:u.metadataProps&&u.metadataProps.length||(u.metadataProps=[]),u.metadataProps.push(o.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&!(a.isInteger(e.irVersion)||e.irVersion&&a.isInteger(e.irVersion.low)&&a.isInteger(e.irVersion.high)))return"irVersion: integer|Long expected";if(e.opsetImport!=null&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var n=0;n>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");n.opsetImport=[];for(var i=0;i>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(n.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");n.graph=o.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(n.metadataProps=[],i=0;i>>0,e.irVersion.high>>>0).toNumber():e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&(i.producerName=e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&(i.producerVersion=e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&(typeof e.modelVersion=="number"?i.modelVersion=n.longs===String?String(e.modelVersion):e.modelVersion:i.modelVersion=n.longs===String?a.Long.prototype.toString.call(e.modelVersion):n.longs===Number?new a.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&(i.graph=o.onnx.GraphProto.toObject(e.graph,n)),e.opsetImport&&e.opsetImport.length){i.opsetImport=[];for(var g=0;g>>3){case 1:u.key=e.string();break;case 2:u.value=e.string();break;default:e.skipType(7&g)}}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!a.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!a.isString(e.value)?"value: string expected":null},t.fromObject=function(e){if(e instanceof o.onnx.StringStringEntryProto)return e;var n=new o.onnx.StringStringEntryProto;return e.key!=null&&(n.key=String(e.key)),e.value!=null&&(n.value=String(e.value)),n},t.toObject=function(e,n){n||(n={});var i={};return n.defaults&&(i.key="",i.value=""),e.key!=null&&e.hasOwnProperty("key")&&(i.key=e.key),e.value!=null&&e.hasOwnProperty("value")&&(i.value=e.value),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),m.TensorAnnotation=function(){function t(e){if(this.quantParameterTensorNames=[],e)for(var n=Object.keys(e),i=0;i>>3){case 1:u.tensorName=e.string();break;case 2:u.quantParameterTensorNames&&u.quantParameterTensorNames.length||(u.quantParameterTensorNames=[]),u.quantParameterTensorNames.push(o.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.tensorName!=null&&e.hasOwnProperty("tensorName")&&!a.isString(e.tensorName))return"tensorName: string expected";if(e.quantParameterTensorNames!=null&&e.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(e.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var n=0;n>>3){case 1:u.node&&u.node.length||(u.node=[]),u.node.push(o.onnx.NodeProto.decode(e,e.uint32()));break;case 2:u.name=e.string();break;case 5:u.initializer&&u.initializer.length||(u.initializer=[]),u.initializer.push(o.onnx.TensorProto.decode(e,e.uint32()));break;case 10:u.docString=e.string();break;case 11:u.input&&u.input.length||(u.input=[]),u.input.push(o.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:u.output&&u.output.length||(u.output=[]),u.output.push(o.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:u.valueInfo&&u.valueInfo.length||(u.valueInfo=[]),u.valueInfo.push(o.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:u.quantizationAnnotation&&u.quantizationAnnotation.length||(u.quantizationAnnotation=[]),u.quantizationAnnotation.push(o.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.node!=null&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var n=0;n>>3){case 1:if(u.dims&&u.dims.length||(u.dims=[]),(7&g)==2)for(var b=e.uint32()+e.pos;e.pos>>0,e.dims[i].high>>>0).toNumber())}if(e.dataType!=null&&(n.dataType=0|e.dataType),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");n.segment=o.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(n.floatData=[],i=0;i>>0,e.int64Data[i].high>>>0).toNumber())}if(e.name!=null&&(n.name=String(e.name)),e.docString!=null&&(n.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?a.base64.decode(e.rawData,n.rawData=a.newBuffer(a.base64.length(e.rawData)),0):e.rawData.length&&(n.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(n.externalData=[],i=0;i>>0,e.uint64Data[i].high>>>0).toNumber(!0))}return n},t.toObject=function(e,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.dims=[],i.floatData=[],i.int32Data=[],i.stringData=[],i.int64Data=[],i.doubleData=[],i.uint64Data=[],i.externalData=[]),n.defaults&&(i.dataType=0,i.segment=null,i.name="",n.bytes===String?i.rawData="":(i.rawData=[],n.bytes!==Array&&(i.rawData=a.newBuffer(i.rawData))),i.docString="",i.dataLocation=n.enums===String?"DEFAULT":0),e.dims&&e.dims.length){i.dims=[];for(var u=0;u>>0,e.dims[u].high>>>0).toNumber():e.dims[u]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(i.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(i.segment=o.onnx.TensorProto.Segment.toObject(e.segment,n)),e.floatData&&e.floatData.length)for(i.floatData=[],u=0;u>>0,e.int64Data[u].high>>>0).toNumber():e.int64Data[u];if(e.name!=null&&e.hasOwnProperty("name")&&(i.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(i.rawData=n.bytes===String?a.base64.encode(e.rawData,0,e.rawData.length):n.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length)for(i.doubleData=[],u=0;u>>0,e.uint64Data[u].high>>>0).toNumber(!0):e.uint64Data[u];if(e.docString!=null&&e.hasOwnProperty("docString")&&(i.docString=e.docString),e.externalData&&e.externalData.length)for(i.externalData=[],u=0;u>>3){case 1:g.begin=n.int64();break;case 2:g.end=n.int64();break;default:n.skipType(7&b)}}return g},e.decodeDelimited=function(n){return n instanceof h||(n=new h(n)),this.decode(n,n.uint32())},e.verify=function(n){return typeof n!="object"||n===null?"object expected":n.begin!=null&&n.hasOwnProperty("begin")&&!(a.isInteger(n.begin)||n.begin&&a.isInteger(n.begin.low)&&a.isInteger(n.begin.high))?"begin: integer|Long expected":n.end!=null&&n.hasOwnProperty("end")&&!(a.isInteger(n.end)||n.end&&a.isInteger(n.end.low)&&a.isInteger(n.end.high))?"end: integer|Long expected":null},e.fromObject=function(n){if(n instanceof o.onnx.TensorProto.Segment)return n;var i=new o.onnx.TensorProto.Segment;return n.begin!=null&&(a.Long?(i.begin=a.Long.fromValue(n.begin)).unsigned=!1:typeof n.begin=="string"?i.begin=parseInt(n.begin,10):typeof n.begin=="number"?i.begin=n.begin:typeof n.begin=="object"&&(i.begin=new a.LongBits(n.begin.low>>>0,n.begin.high>>>0).toNumber())),n.end!=null&&(a.Long?(i.end=a.Long.fromValue(n.end)).unsigned=!1:typeof n.end=="string"?i.end=parseInt(n.end,10):typeof n.end=="number"?i.end=n.end:typeof n.end=="object"&&(i.end=new a.LongBits(n.end.low>>>0,n.end.high>>>0).toNumber())),i},e.toObject=function(n,i){i||(i={});var u={};if(i.defaults){if(a.Long){var g=new a.Long(0,0,!1);u.begin=i.longs===String?g.toString():i.longs===Number?g.toNumber():g}else u.begin=i.longs===String?"0":0;a.Long?(g=new a.Long(0,0,!1),u.end=i.longs===String?g.toString():i.longs===Number?g.toNumber():g):u.end=i.longs===String?"0":0}return n.begin!=null&&n.hasOwnProperty("begin")&&(typeof n.begin=="number"?u.begin=i.longs===String?String(n.begin):n.begin:u.begin=i.longs===String?a.Long.prototype.toString.call(n.begin):i.longs===Number?new a.LongBits(n.begin.low>>>0,n.begin.high>>>0).toNumber():n.begin),n.end!=null&&n.hasOwnProperty("end")&&(typeof n.end=="number"?u.end=i.longs===String?String(n.end):n.end:u.end=i.longs===String?a.Long.prototype.toString.call(n.end):i.longs===Number?new a.LongBits(n.end.low>>>0,n.end.high>>>0).toNumber():n.end),u},e.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},e}(),t.DataLocation=function(){var e={},n=Object.create(e);return n[e[0]="DEFAULT"]=0,n[e[1]="EXTERNAL"]=1,n}(),t}(),m.TensorShapeProto=function(){function t(e){if(this.dim=[],e)for(var n=Object.keys(e),i=0;i>>3==1?(u.dim&&u.dim.length||(u.dim=[]),u.dim.push(o.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&g)}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dim!=null&&e.hasOwnProperty("dim")){if(!Array.isArray(e.dim))return"dim: array expected";for(var n=0;n>>3){case 1:b.dimValue=i.int64();break;case 2:b.dimParam=i.string();break;case 3:b.denotation=i.string();break;default:i.skipType(7&y)}}return b},e.decodeDelimited=function(i){return i instanceof h||(i=new h(i)),this.decode(i,i.uint32())},e.verify=function(i){if(typeof i!="object"||i===null)return"object expected";var u={};if(i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(u.value=1,!(a.isInteger(i.dimValue)||i.dimValue&&a.isInteger(i.dimValue.low)&&a.isInteger(i.dimValue.high))))return"dimValue: integer|Long expected";if(i.dimParam!=null&&i.hasOwnProperty("dimParam")){if(u.value===1)return"value: multiple values";if(u.value=1,!a.isString(i.dimParam))return"dimParam: string expected"}return i.denotation!=null&&i.hasOwnProperty("denotation")&&!a.isString(i.denotation)?"denotation: string expected":null},e.fromObject=function(i){if(i instanceof o.onnx.TensorShapeProto.Dimension)return i;var u=new o.onnx.TensorShapeProto.Dimension;return i.dimValue!=null&&(a.Long?(u.dimValue=a.Long.fromValue(i.dimValue)).unsigned=!1:typeof i.dimValue=="string"?u.dimValue=parseInt(i.dimValue,10):typeof i.dimValue=="number"?u.dimValue=i.dimValue:typeof i.dimValue=="object"&&(u.dimValue=new a.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber())),i.dimParam!=null&&(u.dimParam=String(i.dimParam)),i.denotation!=null&&(u.denotation=String(i.denotation)),u},e.toObject=function(i,u){u||(u={});var g={};return u.defaults&&(g.denotation=""),i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(typeof i.dimValue=="number"?g.dimValue=u.longs===String?String(i.dimValue):i.dimValue:g.dimValue=u.longs===String?a.Long.prototype.toString.call(i.dimValue):u.longs===Number?new a.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber():i.dimValue,u.oneofs&&(g.value="dimValue")),i.dimParam!=null&&i.hasOwnProperty("dimParam")&&(g.dimParam=i.dimParam,u.oneofs&&(g.value="dimParam")),i.denotation!=null&&i.hasOwnProperty("denotation")&&(g.denotation=i.denotation),g},e.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},e}(),t}(),m.TypeProto=function(){function t(n){if(n)for(var i=Object.keys(n),u=0;u>>3){case 1:g.tensorType=o.onnx.TypeProto.Tensor.decode(n,n.uint32());break;case 6:g.denotation=n.string();break;default:n.skipType(7&b)}}return g},t.decodeDelimited=function(n){return n instanceof h||(n=new h(n)),this.decode(n,n.uint32())},t.verify=function(n){if(typeof n!="object"||n===null)return"object expected";if(n.tensorType!=null&&n.hasOwnProperty("tensorType")){var i=o.onnx.TypeProto.Tensor.verify(n.tensorType);if(i)return"tensorType."+i}return n.denotation!=null&&n.hasOwnProperty("denotation")&&!a.isString(n.denotation)?"denotation: string expected":null},t.fromObject=function(n){if(n instanceof o.onnx.TypeProto)return n;var i=new o.onnx.TypeProto;if(n.tensorType!=null){if(typeof n.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");i.tensorType=o.onnx.TypeProto.Tensor.fromObject(n.tensorType)}return n.denotation!=null&&(i.denotation=String(n.denotation)),i},t.toObject=function(n,i){i||(i={});var u={};return i.defaults&&(u.denotation=""),n.tensorType!=null&&n.hasOwnProperty("tensorType")&&(u.tensorType=o.onnx.TypeProto.Tensor.toObject(n.tensorType,i),i.oneofs&&(u.value="tensorType")),n.denotation!=null&&n.hasOwnProperty("denotation")&&(u.denotation=n.denotation),u},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t.Tensor=function(){function n(i){if(i)for(var u=Object.keys(i),g=0;g>>3){case 1:b.elemType=i.int32();break;case 2:b.shape=o.onnx.TensorShapeProto.decode(i,i.uint32());break;default:i.skipType(7&y)}}return b},n.decodeDelimited=function(i){return i instanceof h||(i=new h(i)),this.decode(i,i.uint32())},n.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")&&!a.isInteger(i.elemType))return"elemType: integer expected";if(i.shape!=null&&i.hasOwnProperty("shape")){var u=o.onnx.TensorShapeProto.verify(i.shape);if(u)return"shape."+u}return null},n.fromObject=function(i){if(i instanceof o.onnx.TypeProto.Tensor)return i;var u=new o.onnx.TypeProto.Tensor;if(i.elemType!=null&&(u.elemType=0|i.elemType),i.shape!=null){if(typeof i.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");u.shape=o.onnx.TensorShapeProto.fromObject(i.shape)}return u},n.toObject=function(i,u){u||(u={});var g={};return u.defaults&&(g.elemType=0,g.shape=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(g.elemType=i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&(g.shape=o.onnx.TensorShapeProto.toObject(i.shape,u)),g},n.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},n}(),t}(),m.OperatorSetIdProto=function(){function t(e){if(e)for(var n=Object.keys(e),i=0;i>>3){case 1:u.domain=e.string();break;case 2:u.version=e.int64();break;default:e.skipType(7&g)}}return u},t.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},t.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!a.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!(a.isInteger(e.version)||e.version&&a.isInteger(e.version.low)&&a.isInteger(e.version.high))?"version: integer|Long expected":null},t.fromObject=function(e){if(e instanceof o.onnx.OperatorSetIdProto)return e;var n=new o.onnx.OperatorSetIdProto;return e.domain!=null&&(n.domain=String(e.domain)),e.version!=null&&(a.Long?(n.version=a.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?n.version=parseInt(e.version,10):typeof e.version=="number"?n.version=e.version:typeof e.version=="object"&&(n.version=new a.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),n},t.toObject=function(e,n){n||(n={});var i={};if(n.defaults)if(i.domain="",a.Long){var u=new a.Long(0,0,!1);i.version=n.longs===String?u.toString():n.longs===Number?u.toNumber():u}else i.version=n.longs===String?"0":0;return e.domain!=null&&e.hasOwnProperty("domain")&&(i.domain=e.domain),e.version!=null&&e.hasOwnProperty("version")&&(typeof e.version=="number"?i.version=n.longs===String?String(e.version):e.version:i.version=n.longs===String?a.Long.prototype.toString.call(e.version):n.longs===Number?new a.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},t}(),m),f.exports=o},2100:(f,r,c)=>{f.exports=c(9482)},9482:(f,r,c)=>{var d=r;function l(){d.util._configure(),d.Writer._configure(d.BufferWriter),d.Reader._configure(d.BufferReader)}d.build="minimal",d.Writer=c(1173),d.BufferWriter=c(3155),d.Reader=c(1408),d.BufferReader=c(593),d.util=c(9693),d.rpc=c(5994),d.roots=c(5054),d.configure=l,l()},1408:(f,r,c)=>{f.exports=p;var d,l=c(9693),m=l.LongBits,s=l.utf8;function h(u,g){return RangeError("index out of range: "+u.pos+" + "+(g||1)+" > "+u.len)}function p(u){this.buf=u,this.pos=0,this.len=u.length}var a,o=typeof Uint8Array<"u"?function(u){if(u instanceof Uint8Array||Array.isArray(u))return new p(u);throw Error("illegal buffer")}:function(u){if(Array.isArray(u))return new p(u);throw Error("illegal buffer")},t=function(){return l.Buffer?function(u){return(p.create=function(g){return l.Buffer.isBuffer(g)?new d(g):o(g)})(u)}:o};function e(){var u=new m(0,0),g=0;if(!(this.len-this.pos>4)){for(;g<3;++g){if(this.pos>=this.len)throw h(this);if(u.lo=(u.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return u}return u.lo=(u.lo|(127&this.buf[this.pos++])<<7*g)>>>0,u}for(;g<4;++g)if(u.lo=(u.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return u;if(u.lo=(u.lo|(127&this.buf[this.pos])<<28)>>>0,u.hi=(u.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return u;if(g=0,this.len-this.pos>4){for(;g<5;++g)if(u.hi=(u.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return u}else for(;g<5;++g){if(this.pos>=this.len)throw h(this);if(u.hi=(u.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return u}throw Error("invalid varint encoding")}function n(u,g){return(u[g-4]|u[g-3]<<8|u[g-2]<<16|u[g-1]<<24)>>>0}function i(){if(this.pos+8>this.len)throw h(this,8);return new m(n(this.buf,this.pos+=4),n(this.buf,this.pos+=4))}p.create=t(),p.prototype._slice=l.Array.prototype.subarray||l.Array.prototype.slice,p.prototype.uint32=(a=4294967295,function(){if(a=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(a=(a|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(a=(a|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(a=(a|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(a=(a|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return a;if((this.pos+=5)>this.len)throw this.pos=this.len,h(this,10);return a}),p.prototype.int32=function(){return 0|this.uint32()},p.prototype.sint32=function(){var u=this.uint32();return u>>>1^-(1&u)|0},p.prototype.bool=function(){return this.uint32()!==0},p.prototype.fixed32=function(){if(this.pos+4>this.len)throw h(this,4);return n(this.buf,this.pos+=4)},p.prototype.sfixed32=function(){if(this.pos+4>this.len)throw h(this,4);return 0|n(this.buf,this.pos+=4)},p.prototype.float=function(){if(this.pos+4>this.len)throw h(this,4);var u=l.float.readFloatLE(this.buf,this.pos);return this.pos+=4,u},p.prototype.double=function(){if(this.pos+8>this.len)throw h(this,4);var u=l.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,u},p.prototype.bytes=function(){var u=this.uint32(),g=this.pos,b=this.pos+u;if(b>this.len)throw h(this,u);return this.pos+=u,Array.isArray(this.buf)?this.buf.slice(g,b):g===b?new this.buf.constructor(0):this._slice.call(this.buf,g,b)},p.prototype.string=function(){var u=this.bytes();return s.read(u,0,u.length)},p.prototype.skip=function(u){if(typeof u=="number"){if(this.pos+u>this.len)throw h(this,u);this.pos+=u}else do if(this.pos>=this.len)throw h(this);while(128&this.buf[this.pos++]);return this},p.prototype.skipType=function(u){switch(u){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(u=7&this.uint32())!=4;)this.skipType(u);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+u+" at offset "+this.pos)}return this},p._configure=function(u){d=u,p.create=t(),d._configure();var g=l.Long?"toLong":"toNumber";l.merge(p.prototype,{int64:function(){return e.call(this)[g](!1)},uint64:function(){return e.call(this)[g](!0)},sint64:function(){return e.call(this).zzDecode()[g](!1)},fixed64:function(){return i.call(this)[g](!0)},sfixed64:function(){return i.call(this)[g](!1)}})}},593:(f,r,c)=>{f.exports=m;var d=c(1408);(m.prototype=Object.create(d.prototype)).constructor=m;var l=c(9693);function m(s){d.call(this,s)}m._configure=function(){l.Buffer&&(m.prototype._slice=l.Buffer.prototype.slice)},m.prototype.string=function(){var s=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+s,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+s,this.len))},m._configure()},5054:f=>{f.exports={}},5994:(f,r,c)=>{r.Service=c(7948)},7948:(f,r,c)=>{f.exports=l;var d=c(9693);function l(m,s,h){if(typeof m!="function")throw TypeError("rpcImpl must be a function");d.EventEmitter.call(this),this.rpcImpl=m,this.requestDelimited=!!s,this.responseDelimited=!!h}(l.prototype=Object.create(d.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function m(s,h,p,a,o){if(!a)throw TypeError("request must be specified");var t=this;if(!o)return d.asPromise(m,t,s,h,p,a);if(t.rpcImpl)try{return t.rpcImpl(s,h[t.requestDelimited?"encodeDelimited":"encode"](a).finish(),function(e,n){if(e)return t.emit("error",e,s),o(e);if(n!==null){if(!(n instanceof p))try{n=p[t.responseDelimited?"decodeDelimited":"decode"](n)}catch(i){return t.emit("error",i,s),o(i)}return t.emit("data",n,s),o(null,n)}t.end(!0)})}catch(e){return t.emit("error",e,s),void setTimeout(function(){o(e)},0)}else setTimeout(function(){o(Error("already ended"))},0)},l.prototype.end=function(m){return this.rpcImpl&&(m||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(f,r,c)=>{f.exports=l;var d=c(9693);function l(p,a){this.lo=p>>>0,this.hi=a>>>0}var m=l.zero=new l(0,0);m.toNumber=function(){return 0},m.zzEncode=m.zzDecode=function(){return this},m.length=function(){return 1};var s=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(p){if(p===0)return m;var a=p<0;a&&(p=-p);var o=p>>>0,t=(p-o)/4294967296>>>0;return a&&(t=~t>>>0,o=~o>>>0,++o>4294967295&&(o=0,++t>4294967295&&(t=0))),new l(o,t)},l.from=function(p){if(typeof p=="number")return l.fromNumber(p);if(d.isString(p)){if(!d.Long)return l.fromNumber(parseInt(p,10));p=d.Long.fromString(p)}return p.low||p.high?new l(p.low>>>0,p.high>>>0):m},l.prototype.toNumber=function(p){if(!p&&this.hi>>>31){var a=1+~this.lo>>>0,o=~this.hi>>>0;return a||(o=o+1>>>0),-(a+4294967296*o)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(p){return d.Long?new d.Long(0|this.lo,0|this.hi,!!p):{low:0|this.lo,high:0|this.hi,unsigned:!!p}};var h=String.prototype.charCodeAt;l.fromHash=function(p){return p===s?m:new l((h.call(p,0)|h.call(p,1)<<8|h.call(p,2)<<16|h.call(p,3)<<24)>>>0,(h.call(p,4)|h.call(p,5)<<8|h.call(p,6)<<16|h.call(p,7)<<24)>>>0)},l.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},l.prototype.zzEncode=function(){var p=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^p)>>>0,this.lo=(this.lo<<1^p)>>>0,this},l.prototype.zzDecode=function(){var p=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^p)>>>0,this.hi=(this.hi>>>1^p)>>>0,this},l.prototype.length=function(){var p=this.lo,a=(this.lo>>>28|this.hi<<4)>>>0,o=this.hi>>>24;return o===0?a===0?p<16384?p<128?1:2:p<2097152?3:4:a<16384?a<128?5:6:a<2097152?7:8:o<128?9:10}},9693:function(f,r,c){var d=r;function l(s,h,p){for(var a=Object.keys(h),o=0;o0)},d.Buffer=function(){try{var s=d.inquire("buffer").Buffer;return s.prototype.utf8Write?s:null}catch{return null}}(),d._Buffer_from=null,d._Buffer_allocUnsafe=null,d.newBuffer=function(s){return typeof s=="number"?d.Buffer?d._Buffer_allocUnsafe(s):new d.Array(s):d.Buffer?d._Buffer_from(s):typeof Uint8Array>"u"?s:new Uint8Array(s)},d.Array=typeof Uint8Array<"u"?Uint8Array:Array,d.Long=d.global.dcodeIO&&d.global.dcodeIO.Long||d.global.Long||d.inquire("long"),d.key2Re=/^true|false|0|1$/,d.key32Re=/^-?(?:0|[1-9][0-9]*)$/,d.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,d.longToHash=function(s){return s?d.LongBits.from(s).toHash():d.LongBits.zeroHash},d.longFromHash=function(s,h){var p=d.LongBits.fromHash(s);return d.Long?d.Long.fromBits(p.lo,p.hi,h):p.toNumber(!!h)},d.merge=l,d.lcFirst=function(s){return s.charAt(0).toLowerCase()+s.substring(1)},d.newError=m,d.ProtocolError=m("ProtocolError"),d.oneOfGetter=function(s){for(var h={},p=0;p-1;--o)if(h[a[o]]===1&&this[a[o]]!==void 0&&this[a[o]]!==null)return a[o]}},d.oneOfSetter=function(s){return function(h){for(var p=0;p{f.exports=t;var d,l=c(9693),m=l.LongBits,s=l.base64,h=l.utf8;function p(y,_,v){this.fn=y,this.len=_,this.next=void 0,this.val=v}function a(){}function o(y){this.head=y.head,this.tail=y.tail,this.len=y.len,this.next=y.states}function t(){this.len=0,this.head=new p(a,0,0),this.tail=this.head,this.states=null}var e=function(){return l.Buffer?function(){return(t.create=function(){return new d})()}:function(){return new t}};function n(y,_,v){_[v]=255&y}function i(y,_){this.len=y,this.next=void 0,this.val=_}function u(y,_,v){for(;y.hi;)_[v++]=127&y.lo|128,y.lo=(y.lo>>>7|y.hi<<25)>>>0,y.hi>>>=7;for(;y.lo>127;)_[v++]=127&y.lo|128,y.lo=y.lo>>>7;_[v++]=y.lo}function g(y,_,v){_[v]=255&y,_[v+1]=y>>>8&255,_[v+2]=y>>>16&255,_[v+3]=y>>>24}t.create=e(),t.alloc=function(y){return new l.Array(y)},l.Array!==Array&&(t.alloc=l.pool(t.alloc,l.Array.prototype.subarray)),t.prototype._push=function(y,_,v){return this.tail=this.tail.next=new p(y,_,v),this.len+=_,this},i.prototype=Object.create(p.prototype),i.prototype.fn=function(y,_,v){for(;y>127;)_[v++]=127&y|128,y>>>=7;_[v]=y},t.prototype.uint32=function(y){return this.len+=(this.tail=this.tail.next=new i((y>>>=0)<128?1:y<16384?2:y<2097152?3:y<268435456?4:5,y)).len,this},t.prototype.int32=function(y){return y<0?this._push(u,10,m.fromNumber(y)):this.uint32(y)},t.prototype.sint32=function(y){return this.uint32((y<<1^y>>31)>>>0)},t.prototype.uint64=function(y){var _=m.from(y);return this._push(u,_.length(),_)},t.prototype.int64=t.prototype.uint64,t.prototype.sint64=function(y){var _=m.from(y).zzEncode();return this._push(u,_.length(),_)},t.prototype.bool=function(y){return this._push(n,1,y?1:0)},t.prototype.fixed32=function(y){return this._push(g,4,y>>>0)},t.prototype.sfixed32=t.prototype.fixed32,t.prototype.fixed64=function(y){var _=m.from(y);return this._push(g,4,_.lo)._push(g,4,_.hi)},t.prototype.sfixed64=t.prototype.fixed64,t.prototype.float=function(y){return this._push(l.float.writeFloatLE,4,y)},t.prototype.double=function(y){return this._push(l.float.writeDoubleLE,8,y)};var b=l.Array.prototype.set?function(y,_,v){_.set(y,v)}:function(y,_,v){for(var w=0;w>>0;if(!_)return this._push(n,1,0);if(l.isString(y)){var v=t.alloc(_=s.length(y));s.decode(y,v,0),y=v}return this.uint32(_)._push(b,_,y)},t.prototype.string=function(y){var _=h.length(y);return _?this.uint32(_)._push(h.write,_,y):this._push(n,1,0)},t.prototype.fork=function(){return this.states=new o(this),this.head=this.tail=new p(a,0,0),this.len=0,this},t.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new p(a,0,0),this.len=0),this},t.prototype.ldelim=function(){var y=this.head,_=this.tail,v=this.len;return this.reset().uint32(v),v&&(this.tail.next=y.next,this.tail=_,this.len+=v),this},t.prototype.finish=function(){for(var y=this.head.next,_=this.constructor.alloc(this.len),v=0;y;)y.fn(y.val,_,v),v+=y.len,y=y.next;return _},t._configure=function(y){d=y,t.create=e(),d._configure()}},3155:(f,r,c)=>{f.exports=m;var d=c(1173);(m.prototype=Object.create(d.prototype)).constructor=m;var l=c(9693);function m(){d.call(this)}function s(h,p,a){h.length<40?l.utf8.write(h,p,a):p.utf8Write?p.utf8Write(h,a):p.write(h,a)}m._configure=function(){m.alloc=l._Buffer_allocUnsafe,m.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&l.Buffer.prototype.set.name==="set"?function(h,p,a){p.set(h,a)}:function(h,p,a){if(h.copy)h.copy(p,a,0,h.length);else for(var o=0;o>>0;return this.uint32(p),p&&this._push(m.writeBytesBuffer,p,h),this},m.prototype.string=function(h){var p=l.Buffer.byteLength(h);return this.uint32(p),p&&this._push(s,p,h),this},m._configure()},7714:(f,r,c)=>{r.R=void 0;const d=c(6919),l=c(7448);r.R=new class{async init(){}async createSessionHandler(m,s){const h=new d.Session(s);return await h.loadModel(m),new l.OnnxjsSessionHandler(h)}}},4200:(f,r,c)=>{r.c8=r.rX=void 0;const d=c(1670),l=c(5381),m=c(2157),s=c(2306);r.rX=()=>{if((typeof d.env.wasm.initTimeout!="number"||d.env.wasm.initTimeout<0)&&(d.env.wasm.initTimeout=0),typeof d.env.wasm.simd!="boolean"&&(d.env.wasm.simd=!0),typeof d.env.wasm.proxy!="boolean"&&(d.env.wasm.proxy=!1),typeof d.env.wasm.numThreads!="number"||!Number.isInteger(d.env.wasm.numThreads)||d.env.wasm.numThreads<=0){const h=typeof navigator>"u"?(0,l.cpus)().length:navigator.hardwareConcurrency;d.env.wasm.numThreads=Math.min(4,Math.ceil((h||1)/2))}},r.c8=new class{async init(){(0,r.rX)(),await(0,m.initWasm)()}async createSessionHandler(h,p){const a=new s.OnnxruntimeWebAssemblySessionHandler;return await a.loadModel(h,p),Promise.resolve(a)}}},6018:function(f,r,c){var d=this&&this.__createBinding||(Object.create?function(s,h,p,a){a===void 0&&(a=p);var o=Object.getOwnPropertyDescriptor(h,p);o&&!("get"in o?!h.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return h[p]}}),Object.defineProperty(s,a,o)}:function(s,h,p,a){a===void 0&&(a=p),s[a]=h[p]}),l=this&&this.__exportStar||function(s,h){for(var p in s)p==="default"||Object.prototype.hasOwnProperty.call(h,p)||d(h,s,p)};Object.defineProperty(r,"__esModule",{value:!0}),l(c(1670),r);const m=c(1670);{const s=c(7714).R;(0,m.registerBackend)("webgl",s,-10)}{const s=c(4200).c8;(0,m.registerBackend)("cpu",s,10),(0,m.registerBackend)("wasm",s,10),(0,m.registerBackend)("xnnpack",s,9)}},246:(f,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createAttributeWithCacheKey=void 0;class c{constructor(l){Object.assign(this,l)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(l=>`${this[l]}`).join(";")),this._cacheKey}}r.createAttributeWithCacheKey=d=>new c(d)},7778:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Attribute=void 0;const d=c(1446),l=c(9395),m=c(9162),s=c(2517);var h=l.onnxruntime.experimental.fbs;class p{constructor(o){if(this._attributes=new Map,o!=null){for(const t of o)t instanceof d.onnx.AttributeProto?this._attributes.set(t.name,[p.getValue(t),p.getType(t)]):t instanceof h.Attribute&&this._attributes.set(t.name(),[p.getValue(t),p.getType(t)]);if(this._attributes.sizem.Tensor.fromProto(n));if(o instanceof h.Attribute)return e.map(n=>m.Tensor.fromOrtTensor(n))}if(t===d.onnx.AttributeProto.AttributeType.STRING&&o instanceof d.onnx.AttributeProto){const n=e;return(0,s.decodeUtf8String)(n)}return t===d.onnx.AttributeProto.AttributeType.STRINGS&&o instanceof d.onnx.AttributeProto?e.map(s.decodeUtf8String):e}static getValueNoCheck(o){return o instanceof d.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(o):this.getValueNoCheckFromOrtFormat(o)}static getValueNoCheckFromOnnxFormat(o){switch(o.type){case d.onnx.AttributeProto.AttributeType.FLOAT:return o.f;case d.onnx.AttributeProto.AttributeType.INT:return o.i;case d.onnx.AttributeProto.AttributeType.STRING:return o.s;case d.onnx.AttributeProto.AttributeType.TENSOR:return o.t;case d.onnx.AttributeProto.AttributeType.GRAPH:return o.g;case d.onnx.AttributeProto.AttributeType.FLOATS:return o.floats;case d.onnx.AttributeProto.AttributeType.INTS:return o.ints;case d.onnx.AttributeProto.AttributeType.STRINGS:return o.strings;case d.onnx.AttributeProto.AttributeType.TENSORS:return o.tensors;case d.onnx.AttributeProto.AttributeType.GRAPHS:return o.graphs;default:throw new Error(`unsupported attribute type: ${d.onnx.AttributeProto.AttributeType[o.type]}`)}}static getValueNoCheckFromOrtFormat(o){switch(o.type()){case h.AttributeType.FLOAT:return o.f();case h.AttributeType.INT:return o.i();case h.AttributeType.STRING:return o.s();case h.AttributeType.TENSOR:return o.t();case h.AttributeType.GRAPH:return o.g();case h.AttributeType.FLOATS:return o.floatsArray();case h.AttributeType.INTS:{const t=[];for(let e=0;e{Object.defineProperty(r,"__esModule",{value:!0}),r.resolveBackend=r.backend=void 0;const d=c(5038),l=new Map;async function m(s){const h=r.backend;if(h[s]!==void 0&&function(p){const a=p;return"initialize"in a&&typeof a.initialize=="function"&&"createSessionHandler"in a&&typeof a.createSessionHandler=="function"&&"dispose"in a&&typeof a.dispose=="function"}(h[s])){const p=h[s];let a=p.initialize();if(typeof a=="object"&&"then"in a&&(a=await a),a)return l.set(s,p),p}}r.backend={webgl:new d.WebGLBackend},r.resolveBackend=async function s(h){if(!h)return s(["webgl"]);{const p=typeof h=="string"?[h]:h;for(const a of p){const o=l.get(a);if(o)return o;const t=await m(a);if(t)return t}}throw new Error("no available backend to use")}},5038:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WebGLBackend=void 0;const d=c(1670),l=c(6231),m=c(6416),s=c(7305);r.WebGLBackend=class{get contextId(){return d.env.webgl.contextId}set contextId(h){d.env.webgl.contextId=h}get matmulMaxBatchSize(){return d.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(h){d.env.webgl.matmulMaxBatchSize=h}get textureCacheMode(){return d.env.webgl.textureCacheMode}set textureCacheMode(h){d.env.webgl.textureCacheMode=h}get pack(){return d.env.webgl.pack}set pack(h){d.env.webgl.pack=h}get async(){return d.env.webgl.async}set async(h){d.env.webgl.async=h}initialize(){try{return this.glContext=(0,s.createWebGLContext)(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),l.Logger.setWithEnv(d.env),l.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(h){return l.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${h}`),!1}}createSessionHandler(h){return new m.WebGLSessionHandler(this,h)}dispose(){this.glContext.dispose()}}},5107:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoordsGlslLib=void 0;const d=c(2517),l=c(8520),m=c(5060),s=c(7859),h=c(9390);class p extends l.GlslLib{constructor(o){super(o)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.offsetToCoords()),this.coordsToOffset()),this.toVec()),this.valueFrom()),this.getCommonUtilFuncs()),this.getInputsSamplingSnippets()),this.getOutputSamplingSnippet())}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new l.GlslLibRoutine(` + vec2 offsetToCoords(int offset, int width, int height) { + int t = offset / width; + int s = offset - t*width; + vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height); + return coords; + } + `)}}coordsToOffset(){return{coordsToOffset:new l.GlslLibRoutine(` + int coordsToOffset(vec2 coords, int width, int height) { + float s = coords.s * float(width); + float t = coords.t * float(height); + int offset = int(t) * width + int(s); + return offset; + } + `)}}getOutputSamplingSnippet(){const o=this.context.outputTextureLayout;return o.isPacked?this.getPackedOutputSamplingSnippet(o):this.getUnpackedOutputSamplingSnippet(o)}getPackedOutputSamplingSnippet(o){const t=o.unpackedShape,e=[o.width,o.height],n={},i="getOutputCoords";switch(t.length){case 0:n[i]=this.getOutputScalarCoords();break;case 1:n[i]=this.getOutputPacked1DCoords(t,e);break;case 2:n[i]=this.getOutputPacked2DCoords(t,e);break;case 3:n[i]=this.getOutputPacked3DCoords(t,e);break;default:n[i]=this.getOutputPackedNDCoords(t,e)}const u=` + void setOutput(vec4 val) { + ${(0,m.getGlsl)(this.context.glContext.version).output} = val; + } + `;return n.floatTextureSetRGBA=new l.GlslLibRoutine(u),n}getUnpackedOutputSamplingSnippet(o){const t=o.unpackedShape,e=[o.width,o.height],n={},i="getOutputCoords";switch(t.length){case 0:n[i]=this.getOutputScalarCoords();break;case 1:n[i]=this.getOutputUnpacked1DCoords(t,e);break;case 2:n[i]=this.getOutputUnpacked2DCoords(t,e);break;case 3:n[i]=this.getOutputUnpacked3DCoords(t,e);break;case 4:n[i]=this.getOutputUnpacked4DCoords(t,e);break;case 5:n[i]=this.getOutputUnpacked5DCoords(t,e);break;case 6:n[i]=this.getOutputUnpacked6DCoords(t,e);break;default:throw new Error(`Unsupported output dimensionality: ${t.length}`)}const u=` + void setOutput(float val) { + ${(0,m.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0); + } + `;return n.floatTextureSetR=new l.GlslLibRoutine(u),n}getOutputScalarCoords(){return new l.GlslLibRoutine(` + int getOutputCoords() { + return 0; + } + `)}getOutputPacked1DCoords(o,t){const e=t;let n="";return e[0]===1?(n=` + int getOutputCoords() { + return 2 * int(TexCoords.y * ${e[1]}.0); + } + `,new l.GlslLibRoutine(n)):e[1]===1?(n=` + int getOutputCoords() { + return 2 * int(TexCoords.x * ${e[0]}.0); + } + `,new l.GlslLibRoutine(n)):(n=` + int getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + return 2 * (resTexRC.y * ${e[0]} + resTexRC.x); + } + `,new l.GlslLibRoutine(n))}getOutputPacked2DCoords(o,t){let e="";if(d.ArrayUtil.arraysEqual(o,t))return e=` + ivec2 getOutputCoords() { + return 2 * ivec2(TexCoords.xy * vec2(${t[0]}, ${t[1]})); + } + `,new l.GlslLibRoutine(e);const n=t,i=Math.ceil(o[1]/2);return e=` + ivec2 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${n[0]}, ${n[1]})); + + int index = resTexRC.y * ${n[0]} + resTexRC.x; + + // reverse r and c order for packed texture + int r = imod(index, ${i}) * 2; + int c = 2 * (index / ${i}); + + return ivec2(r, c); + } + `,new l.GlslLibRoutine(e)}getOutputPacked3DCoords(o,t){const e=[t[0],t[1]],n=Math.ceil(o[2]/2),i=n*Math.ceil(o[1]/2),u=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${e[0]}, ${e[1]})); + int index = resTexRC.y * ${e[0]} + resTexRC.x; + + int b = index / ${i}; + index -= b * ${i}; + + // reverse r and c order for packed texture + int r = imod(index, ${n}) * 2; + int c = 2 * (index / ${n}); + + return ivec3(b, r, c); + } + `;return new l.GlslLibRoutine(u)}getOutputPackedNDCoords(o,t){const e=[t[0],t[1]],n=Math.ceil(o[o.length-1]/2),i=n*Math.ceil(o[o.length-2]/2);let u=i,g="",b="b, r, c";for(let _=2;_=0;--b)i[b]=i[b+1]*o[b+1];const u=["r","c","d"],g=i.map((b,y)=>`int ${u[y]} = index / ${b}; ${y===i.length-1?`int ${u[y+1]} = index - ${u[y]} * ${b}`:`index -= ${u[y]} * ${b}`};`).join("");return e=` + ivec3 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${g} + return ivec3(r, c, d); + } + `,new l.GlslLibRoutine(e)}getOutputUnpacked4DCoords(o,t){let e="";const n=o.length;let i=null;n<2&&(i=[]),i=new Array(n-1),i[n-2]=o[n-1];for(let b=n-3;b>=0;--b)i[b]=i[b+1]*o[b+1];const u=["r","c","d","d2"],g=i.map((b,y)=>`int ${u[y]} = index / ${b}; ${y===i.length-1?`int ${u[y+1]} = index - ${u[y]} * ${b}`:`index -= ${u[y]} * ${b}`};`).join("");return e=` + ivec4 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${g} + return ivec4(r, c, d, d2); + } + `,new l.GlslLibRoutine(e)}getOutputUnpacked5DCoords(o,t){let e="";const n=o.length;let i=null;n<2&&(i=[]),i=new Array(n-1),i[n-2]=o[n-1];for(let b=n-3;b>=0;--b)i[b]=i[b+1]*o[b+1];const u=["r","c","d","d2","d3"],g=i.map((b,y)=>`int ${u[y]} = index / ${b}; ${y===i.length-1?`int ${u[y+1]} = index - ${u[y]} * ${b}`:`index -= ${u[y]} * ${b}`};`).join("");return e=` + ivec5 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${g} + return ivec5(r, c, d, d2, d3); + } + `,new l.GlslLibRoutine(e)}getOutputUnpacked6DCoords(o,t){let e="";const n=o.length;let i=null;n<2&&(i=[]),i=new Array(n-1),i[n-2]=o[n-1];for(let b=n-3;b>=0;--b)i[b]=i[b+1]*o[b+1];const u=["r","c","d","d2","d3","d4"],g=i.map((b,y)=>`int ${u[y]} = index / ${b}; ${y===i.length-1?`int ${u[y+1]} = index - ${u[y]} * ${b}`:`index -= ${u[y]} * ${b}`};`).join("");return e=` + ivec6 getOutputCoords() { + ivec2 resTexRC = ivec2(TexCoords.xy * + vec2(${t[0]}, ${t[1]})); + int index = resTexRC.y * ${t[0]} + resTexRC.x; + ${g} + return ivec6(r, c, d, d2, d3, d4); + } + `,new l.GlslLibRoutine(e)}getCommonUtilFuncs(){const o={};let t="uvFromFlat";o[t]=new l.GlslLibRoutine(` + vec2 uvFromFlat(int texNumR, int texNumC, int index) { + int texC = index / texNumR; + int texR = index - texC * texNumR; + // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to + // v. + return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC); + } + `),t="packedUVfrom1D",o[t]=new l.GlslLibRoutine(` + vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { + int texelIndex = index / 2; + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),t="packedUVfrom2D",o[t]=new l.GlslLibRoutine(` + vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) { + int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); + int texR = texelIndex / texNumC; + int texC = texelIndex - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),t="packedUVfrom3D",o[t]=new l.GlslLibRoutine(` + vec2 packedUVfrom3D(int texNumR, int texNumC, + int texelsInBatch, int texelsInLogicalRow, int b, + int row, int col) { + int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); + int texR = index / texNumC; + int texC = index - texR * texNumC; + return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); + } + `),t="sampleTexture";const e=(0,m.getGlsl)(this.context.glContext.version);return o[t]=new l.GlslLibRoutine(` + float sampleTexture(sampler2D textureSampler, vec2 uv) { + return ${e.texture2D}(textureSampler, uv).r; + }`),o}getInputsSamplingSnippets(){const o={},t=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((e,n)=>{const i=this.context.inputTextureLayouts[n],u=(0,h.generateShaderFuncNameFromInputSamplerName)(e);i.isPacked?o[u]=this.getPackedSamplerFromInput(u,e,i):o[u]=this.getUnpackedSamplerFromInput(u,e,i);const g=(0,h.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(e);i.unpackedShape.length<=t.unpackedShape.length&&(i.isPacked?o[g]=this.getPackedSamplerAtOutputCoords(g,i,t,e):o[g]=this.getUnpackedSamplerAtOutputCoords(g,i,t,e))}),o}getPackedSamplerAtOutputCoords(o,t,e,n){const i=t.unpackedShape,u=e.unpackedShape,g=n,b=(0,h.generateShaderFuncNameFromInputSamplerName)(g),y=i.length,_=u.length,v=d.BroadcastUtil.getBroadcastDims(i,u),w=(0,h.getCoordsDataType)(_),T=_-y;let A;const E=(0,h.getGlChannels)();A=y===0?"":_<2&&v.length>=1?"coords = 0;":v.map(k=>`coords.${E[k+T]} = 0;`).join(` +`);let x="";x=_<2&&y>0?"coords":i.map((k,q)=>`coords.${E[q+T]}`).join(", ");let P="return outputValue;";const L=d.ShapeUtil.size(i)===1,F=d.ShapeUtil.size(u)===1;if(y!==1||L||F){if(L&&!F)P=_===1?` + return vec4(outputValue.x, outputValue.x, 0., 0.); + `:` + return vec4(outputValue.x); + `;else if(v.length){const k=y-2,q=y-1;v.indexOf(k)>-1&&v.indexOf(q)>-1?P="return vec4(outputValue.x);":v.indexOf(k)>-1?P="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":v.indexOf(q)>-1&&(P="return vec4(outputValue.xx, outputValue.zz);")}}else P=` + return vec4(outputValue.xy, outputValue.xy); + `;const $=` + vec4 ${o}() { + ${w} coords = getOutputCoords(); + + int lastDim = coords.${E[_-1]}; + coords.${E[_-1]} = coords.${E[_-2]}; + coords.${E[_-2]} = lastDim; + + ${A} + vec4 outputValue = ${b}(${x}); + ${P} + } + `;return new l.GlslLibRoutine($,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(o,t,e,n){const i=[e.width,e.height],u=[t.width,t.height],g=t.unpackedShape.length,b=e.unpackedShape.length,y=t.unpackedShape,_=e.unpackedShape,v=(0,h.generateShaderFuncNameFromInputSamplerName)(n);if(g===b&&d.ArrayUtil.arraysEqual(u,i)){const F=` + float ${o}() { + return sampleTexture(${n}, TexCoords); + } + `;return new l.GlslLibRoutine(F,["coordinates.sampleTexture"])}const w=(0,h.getCoordsDataType)(b),T=d.BroadcastUtil.getBroadcastDims(y,_),A=b-g;let E;const x=(0,h.getGlChannels)();E=g===0?"":b<2&&T.length>=1?"coords = 0;":T.map(F=>`coords.${x[F+A]} = 0;`).join(` +`);let P="";P=b<2&&g>0?"coords":t.unpackedShape.map((F,$)=>`coords.${x[$+A]}`).join(", ");const L=` + float ${o}() { + ${w} coords = getOutputCoords(); + ${E} + return ${v}(${P}); + } + `;return new l.GlslLibRoutine(L,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(o,t,e){switch(e.unpackedShape.length){case 0:return this.getPackedSamplerScalar(o,t);case 1:return this.getPackedSampler1D(o,t,e);case 2:return this.getPackedSampler2D(o,t,e);case 3:return this.getPackedSampler3D(o,t,e);default:return this.getPackedSamplerND(o,t,e)}}getUnpackedSamplerFromInput(o,t,e){const n=e.unpackedShape;switch(n.length){case 0:return this.getUnpackedSamplerScalar(o,t,e);case 1:return this.getUnpackedSampler1D(o,t,e);case 2:return this.getUnpackedSampler2D(o,t,e);case 3:return this.getUnpackedSampler3D(o,t,e);case 4:return this.getUnpackedSampler4D(o,t,e);case 5:return this.getUnpackedSampler5D(o,t,e);case 6:return this.getUnpackedSampler6D(o,t,e);default:throw new Error(`Unsupported dimension ${n.length}-D`)}}getPackedSamplerScalar(o,t){const e=` + vec4 ${o}() { + return ${(0,m.getGlsl)(this.context.glContext.version).texture2D}(${t}, halfCR); + } + `;return new l.GlslLibRoutine(e)}getPackedSampler1D(o,t,e){const n=[e.width,e.height],i=[n[1],n[0]],u=(0,m.getGlsl)(this.context.glContext.version),g=`vec4 ${o}(int index) { + vec2 uv = packedUVfrom1D( + ${i[0]}, ${i[1]}, index); + return ${u.texture2D}(${t}, uv); + }`;return new l.GlslLibRoutine(g,["coordinates.packedUVfrom1D"])}getPackedSampler2D(o,t,e){const n=e.unpackedShape,i=[e.width,e.height],u=(0,m.getGlsl)(this.context.glContext.version),g=i[0],b=i[1];if(i!=null&&d.ArrayUtil.arraysEqual(n,i)){const w=`vec4 ${o}(int row, int col) { + vec2 uv = (vec2(col, row) + halfCR) / vec2(${b}.0, ${g}.0); + return ${u.texture2D}(${t}, uv); + }`;return new l.GlslLibRoutine(w)}const y=i,_=Math.ceil(n[1]/2),v=`vec4 ${o}(int row, int col) { + vec2 uv = packedUVfrom2D(${y[1]}, ${y[0]}, ${_}, row, col); + return ${u.texture2D}(${t}, uv); + }`;return new l.GlslLibRoutine(v,["coordinates.packedUVfrom2D"])}getPackedSampler3D(o,t,e){const n=e.unpackedShape,i=[e.width,e.height],u=[i[0],i[1]],g=(0,m.getGlsl)(this.context.glContext.version);if(n[0]===1){const w=n.slice(1),T=[1,2],A=(0,h.squeezeInputShape)(n,w),E=["b","row","col"],x=JSON.parse(JSON.stringify(e));x.unpackedShape=A;const P=this.getPackedSamplerFromInput(o,t,x),L=`${P.routineBody} + vec4 ${o}(int b, int row, int col) { + return ${o}(${(0,h.getSqueezedParams)(E,T)}); + } `;return new l.GlslLibRoutine(L,P.dependencies)}const b=u[0],y=u[1],_=Math.ceil(n[2]/2),v=`vec4 ${o}(int b, int row, int col) { + vec2 uv = packedUVfrom3D( + ${y}, ${b}, ${_*Math.ceil(n[1]/2)}, ${_}, b, row, col); + return ${g.texture2D}(${t}, uv);}`;return new l.GlslLibRoutine(v,["coordinates.packedUVfrom3D"])}getPackedSamplerND(o,t,e){const n=e.unpackedShape,i=n.length,u=[e.width,e.height],g=(0,m.getGlsl)(this.context.glContext.version),b=[u[0],u[1]],y=b[1],_=b[0],v=Math.ceil(n[i-1]/2);let w=v*Math.ceil(n[i-2]/2),T="int b, int row, int col",A=`b * ${w} + (row / 2) * ${v} + (col / 2)`;for(let x=2;x{const n=this.context.inputTextureLayouts[e],i=(n.unpackedShape.length>0?n.unpackedShape:n.shape).length;let u=`_${t}`;o[u]=new l.GlslLibRoutine(this.getValueFromSingle(t,i,n.width,n.height,!1),[`shapeUtils.indicesToOffset${u}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),u+="_T",o[u]=new l.GlslLibRoutine(this.getValueFromSingle(t,i,n.width,n.height,!0),[`shapeUtils.indicesToOffset${u}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),o}getValueFromSingle(o,t,e,n,i){let u=`_${o}`;return i&&(u+="_T"),` + float ${u}(int m[${t}]) { + int offset = indicesToOffset${u}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${n}); + float value = getColorAsFloat(${(0,m.getGlsl)(this.context.glContext.version).texture2D}(${o}, coords)); + return value; + } + `}getPackedValueFrom(o,t,e,n,i){let u=`_${o}_Pack`;return i&&(u+="_T"),` + vec4 ${u}(int m[${t}]) { + int offset = indicesToOffset_${o}(m); + vec2 coords = offsetToCoords(offset, ${e}, ${n}); + return ${(0,m.getGlsl)(this.context.glContext.version).texture2D}(${o}, coords); + } + `}}r.CoordsGlslLib=p},8520:(f,r)=>{var c;Object.defineProperty(r,"__esModule",{value:!0}),r.TopologicalSortGlslRoutines=r.GlslLibRoutineNode=r.GlslLibRoutine=r.GlslLib=r.GlslContext=r.FunctionType=void 0,(c=r.FunctionType||(r.FunctionType={}))[c.ValueBased=0]="ValueBased",c[c.Positional=1]="Positional",r.GlslContext=class{constructor(d,l,m,s){this.glContext=d,this.programInfo=l,this.inputTextureLayouts=m,this.outputTextureLayout=s}},r.GlslLib=class{constructor(d){this.context=d}},r.GlslLibRoutine=class{constructor(d,l){this.routineBody=d,this.dependencies=l}},r.GlslLibRoutineNode=class{constructor(d,l,m){this.name=d,this.dependencies=m||[],l&&(this.routineBody=l)}addDependency(d){d&&this.dependencies.push(d)}},r.TopologicalSortGlslRoutines=class{static returnOrderedNodes(d){if(!d||d.length===0)return[];if(d.length===1)return d;const l=new Set,m=new Set,s=new Array;return this.createOrderedNodes(d,l,m,s),s}static createOrderedNodes(d,l,m,s){for(let h=0;h0)for(let p=0;p{Object.defineProperty(r,"__esModule",{value:!0}),r.EncodingGlslLib=void 0;const d=c(8520);class l extends d.GlslLib{constructor(s){super(s)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new d.GlslLibRoutine(`highp vec4 encode(highp float f) { + return vec4(f, 0.0, 0.0, 0.0); + } + `)}}decodeFloat32(){return{decode:new d.GlslLibRoutine(`highp float decode(highp vec4 rgba) { + return rgba.r; + } + `)}}encodeUint8(){const s=l.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new d.GlslLibRoutine(` + highp vec4 encode(highp float f) { + highp float F = abs(f); + highp float Sign = step(0.0,-f); + highp float Exponent = floor(log2(F)); + highp float Mantissa = (exp2(- Exponent) * F); + Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa)); + highp vec4 rgba; + rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0)); + rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0); + rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0))); + rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0))); + ${s} + rgba = rgba / 255.0; // values need to be normalized to [0,1] + return rgba; + } + `)}}decodeUint8(){const s=l.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new d.GlslLibRoutine(` + highp float decode(highp vec4 rgba) { + rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255] + ${s} + highp float Sign = 1.0 - step(128.0,rgba[0])*2.0; + highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0; + highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000); + highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 )); + return Result; + } + `)}}static isLittleEndian(){const s=new ArrayBuffer(4),h=new Uint32Array(s),p=new Uint8Array(s);if(h[0]=3735928559,p[0]===239)return!0;if(p[0]===222)return!1;throw new Error("unknown endianness")}}r.EncodingGlslLib=l},9894:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FragColorGlslLib=void 0;const d=c(8520),l=c(5060);class m extends d.GlslLib{constructor(h){super(h)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const h=(0,l.getGlsl)(this.context.glContext.version);return{setFragColor:new d.GlslLibRoutine(` + void setFragColor(float value) { + ${h.output} = encode(value); + } + `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new d.GlslLibRoutine(` + float getColorAsFloat(vec4 color) { + return decode(color); + } + `,["encoding.decode"])}}}r.FragColorGlslLib=m},2848:(f,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.replaceInlines=void 0;const c=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;r.replaceInlines=function(d){const l={};let m;for(;(m=c.exec(d))!==null;){const s=m[3].split(",").map(h=>{const p=h.trim().split(" ");return p&&p.length===2?{type:p[0],name:p[1]}:null}).filter(h=>h!==null);l[m[2]]={params:s,body:m[4]}}for(const s in l){const h="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",s),p=new RegExp(h,"gm");for(;(m=p.exec(d))!==null;){const a=m[1],o=m[2],t=m[3].split(","),e=a?`${a} ${o};`:"";let n=l[s].body,i="";l[s].params.forEach((g,b)=>{g&&(i+=`${g.type} ${g.name} = ${t[b]}; +`)}),n=`${i} + ${n}`,n=n.replace("return",`${o} = `);const u=` + ${e} + { + ${n} + } + `;d=d.replace(m[0],u)}}return d.replace(c,"")}},8879:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.GlslPreprocessor=void 0;const d=c(8520),l=c(2848),m=c(5483),s=c(5060);r.GlslPreprocessor=class{constructor(h,p,a,o){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new d.GlslContext(h,p,a,o),Object.keys(m.glslRegistry).forEach(e=>{const n=new m.glslRegistry[e](this.context);this.libs[e]=n});const t=this.glslLibRoutineDependencyGraph;for(const e in this.libs){const n=this.libs[e].getFunctions();for(const i in n){const u=e+"."+i;let g;t[u]?(g=t[u],g.routineBody=n[i].routineBody):(g=new d.GlslLibRoutineNode(u,n[i].routineBody),t[u]=g);const b=n[i].dependencies;if(b)for(let y=0;y{const o=a.split(".")[1];h.indexOf(o)!==-1&&p.push(this.glslLibRoutineDependencyGraph[a])}),d.TopologicalSortGlslRoutines.returnOrderedNodes(p)}getUniforms(h,p){const a=[];if(h)for(const o of h)a.push(`uniform sampler2D ${o};`);if(p)for(const o of p)a.push(`uniform ${o.type} ${o.name}${o.arrayLength?`[${o.arrayLength}]`:""};`);return a.join(` +`)}}},5483:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.glslRegistry=void 0;const d=c(5107),l=c(7341),m=c(9894),s=c(2655),h=c(3891);r.glslRegistry={encoding:l.EncodingGlslLib,fragcolor:m.FragColorGlslLib,vec:h.VecGlslLib,shapeUtils:s.ShapeUtilsGlslLib,coordinates:d.CoordsGlslLib}},2655:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ShapeUtilsGlslLib=void 0;const d=c(8520);class l extends d.GlslLib{constructor(s){super(s)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.bcastIndex()),this.bcastMatmulIndex()),this.offsetToIndices()),this.indicesToOffset()),this.incrementIndices())}getCustomTypes(){return{}}bcastIndex(){const s=this.context.outputTextureLayout.shape.length,h={};return this.context.programInfo.inputNames.forEach((p,a)=>{const o=this.context.inputTextureLayouts[a].unpackedShape;if(o.length<=s){const t=o.length,e=s-t,n=`bcastIndices_${p}`;let i="";for(let g=0;g{const o=this.context.inputTextureLayouts[a].shape;if(!(o.length<2||o.length>s)){const t=o.length,e=s-t,n=`bcastMatmulIndices_${p}`;let i="";for(let g=0;g{const a=this.context.inputTextureLayouts[p].shape,o=this.context.inputTextureLayouts[p].strides,t=a.length;let e=`indicesToOffset_${h}`;s[e]=new d.GlslLibRoutine(l.indexToOffsetSingle(e,t,o)),e=`indicesToOffset_${h}_T`,s[e]=new d.GlslLibRoutine(l.indexToOffsetSingle(e,t,o.slice().reverse()))}),s}static indexToOffsetSingle(s,h,p){let a="";for(let o=h-1;o>=0;--o)a+=` + offset += indices[${o}] * ${p[o]}; + `;return` + int ${s}(int indices[${h}]) { + int offset = 0; + ${a} + return offset; + } + `}offsetToIndices(){const s={};return this.context.programInfo.inputNames.forEach((h,p)=>{const a=this.context.inputTextureLayouts[p].shape,o=this.context.inputTextureLayouts[p].strides,t=a.length;let e=`offsetToIndices_${h}`;s[e]=new d.GlslLibRoutine(l.offsetToIndicesSingle(e,t,o)),e=`offsetToIndices_${h}_T`,s[e]=new d.GlslLibRoutine(l.offsetToIndicesSingle(e,t,o.slice().reverse()))}),s}static offsetToIndicesSingle(s,h,p){const a=[];for(let o=0;o{const a=this.context.inputTextureLayouts[p].shape,o=a.length,t=`incrementIndices_${h}`;let e="";for(let i=0;i= 0; --i) { + if(i > axis) continue; + indices[i] += 1; + if(indices[i] < shape[i]) { + break; + } + indices[i] = 0; + } + } + `;s[t]=new d.GlslLibRoutine(n)}),s}}r.ShapeUtilsGlslLib=l},5060:(f,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getDefaultFragShaderMain=r.getFragShaderPreamble=r.getVertexShaderSource=r.getGlsl=void 0;const c={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},d={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function l(m){return m===1?c:d}r.getGlsl=l,r.getVertexShaderSource=function(m){const s=l(m);return`${s.version} + precision highp float; + ${s.attribute} vec3 position; + ${s.attribute} vec2 textureCoord; + + ${s.varyingVertex} vec2 TexCoords; + + void main() + { + gl_Position = vec4(position, 1.0); + TexCoords = textureCoord; + }`},r.getFragShaderPreamble=function(m){const s=l(m);return`${s.version} + precision highp float; + precision highp int; + precision highp sampler2D; + ${s.varyingFrag} vec2 TexCoords; + ${s.outputDeclaration} + const vec2 halfCR = vec2(0.5, 0.5); + + // Custom vector types to handle higher dimenalities. + struct ivec5 + { + int x; + int y; + int z; + int w; + int u; + }; + + struct ivec6 + { + int x; + int y; + int z; + int w; + int u; + int v; + }; + + int imod(int x, int y) { + return x - y * (x / y); + } + + `},r.getDefaultFragShaderMain=function(m,s){return` + void main() { + int indices[${s}]; + toVec(TexCoords, indices); + vec4 result = vec4(process(indices)); + ${l(m).output} = result; + } + `}},3891:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.VecGlslLib=void 0;const d=c(8520);class l extends d.GlslLib{constructor(s){super(s)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const s=this.context.outputTextureLayout.shape.length,h={add:"+=",sub:"-=",mul:"*=",div:"/="},p={};for(const a in h){const o=`${a}Vec`;let t="";for(let n=0;n{Object.defineProperty(r,"__esModule",{value:!0}),r.WebGLInferenceHandler=void 0;const d=c(6231),l=c(9162),m=c(2517),s=c(2403),h=c(7019),p=c(8710),a=c(5611),o=c(4057),t=c(2039);r.WebGLInferenceHandler=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,n){return(0,o.calculateTextureWidthAndHeight)(this.session.layoutStrategy,e,n)}executeProgram(e,n){if(n.length{const T=w.map(E=>`${E.unpackedShape.join(",")};${E.width}x${E.height}`).join("_");let A=v.name;return v.cacheHint&&(A+="["+v.cacheHint+"]"),A+=":"+T,A})(e,i);let g=this.session.programManager.getArtifact(u);const b=g?g.programInfo:typeof e.get=="function"?e.get():e,y=(0,o.createTextureLayoutFromTextureType)(this.session.layoutStrategy,b.output.dims,b.output.textureType),_=this.createTextureData(y,b.output.type);return g||(g=this.session.programManager.build(b,i,_),this.session.programManager.setArtifact(u,g)),this.runProgram(g,i,_),_}run(e,n){return this.executeProgram(e,n).tensor}runProgram(e,n,i){for(let u=0;uthis.readTexture(b),async y=>this.readTextureAsync(b),void 0,g),texture:i});return this.setTextureData(b.tensor.dataId,b,e.isPacked),b}getTextureData(e,n=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,n):n?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,n,i=!1){this.session.isInitializer(e)?this.session.setTextureData(e,n,i):(i?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,n)}isTextureLayoutCached(e,n=!1){return!!this.getTextureData(e.dataId,n)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.unpackedTextureDataCache=new Map}readTexture(e){return e.isPacked?this.readTexture(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,p.encodeAsUint8)(this,e))}async readTextureAsync(e){return e.isPacked?this.readTextureAsync(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,p.encodeAsUint8)(this,e))}pack(e){return this.executeProgram((0,s.createPackProgramInfoLoader)(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram((0,a.createUnpackProgramInfoLoader)(this,e.tensor),[e.tensor])}}},1640:function(f,r,c){var d=this&&this.__createBinding||(Object.create?function(Y,Z,te,he){he===void 0&&(he=te);var Me=Object.getOwnPropertyDescriptor(Z,te);Me&&!("get"in Me?!Z.__esModule:Me.writable||Me.configurable)||(Me={enumerable:!0,get:function(){return Z[te]}}),Object.defineProperty(Y,he,Me)}:function(Y,Z,te,he){he===void 0&&(he=te),Y[he]=Z[te]}),l=this&&this.__setModuleDefault||(Object.create?function(Y,Z){Object.defineProperty(Y,"default",{enumerable:!0,value:Z})}:function(Y,Z){Y.default=Z}),m=this&&this.__importStar||function(Y){if(Y&&Y.__esModule)return Y;var Z={};if(Y!=null)for(var te in Y)te!=="default"&&Object.prototype.hasOwnProperty.call(Y,te)&&d(Z,Y,te);return l(Z,Y),Z};Object.defineProperty(r,"__esModule",{value:!0}),r.WEBGL_OP_RESOLVE_RULES=void 0;const s=c(2898),h=m(c(7839)),p=c(4196),a=c(2069),o=c(8138),t=c(9663),e=c(5193),n=c(7992),i=c(1253),u=c(4776),g=c(6572),b=c(3346),y=c(5623),_=c(2870),v=c(2143),w=c(4939),T=c(718),A=c(2268),E=c(8117),x=c(2278),P=c(5524),L=c(5975),F=c(3933),$=c(6558),k=c(5723),q=c(3738),D=m(c(4909)),U=c(8428),J=c(9793);r.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",D.abs],["Acos","","7+",D.acos],["Add","","7+",h.add],["And","","7+",h.and],["Asin","","7+",D.asin],["Atan","","7+",D.atan],["AveragePool","","7+",v.averagePool,v.parseAveragePoolAttributes],["BatchNormalization","","7+",s.batchNormalization,s.parseBatchNormalizationAttributes],["Cast","","6+",p.cast,p.parseCastAttributes],["Ceil","","6+",D.ceil],["Clip","","6-10",D.clip,D.parseClipAttributes],["Clip","","11+",D.clipV11],["Concat","","4+",a.concat,a.parseConcatAttributes],["Conv","","1+",o.conv,o.parseConvAttributes],["ConvTranspose","","1+",t.convTranspose,t.parseConvTransposeAttributes],["Cos","","7+",D.cos],["Div","","7+",h.div],["Dropout","","7+",D.identity],["DepthToSpace","","1+",e.depthToSpace,e.parseDepthToSpaceAttributes],["Equal","","7+",h.equal],["Elu","","6+",D.elu,D.parseEluAttributes],["Exp","","6+",D.exp],["Flatten","","1+",n.flatten,n.parseFlattenAttributes],["Floor","","6+",D.floor],["FusedConv","com.microsoft","1+",o.conv,o.parseConvAttributes],["Gather","","1+",i.gather,i.parseGatherAttributes],["Gemm","","7-10",u.gemm,u.parseGemmAttributesV7],["Gemm","","11+",u.gemm,u.parseGemmAttributesV11],["GlobalAveragePool","","1+",v.globalAveragePool,v.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",v.globalMaxPool],["Greater","","7+",h.greater],["Identity","","1+",D.identity],["ImageScaler","","1+",g.imageScaler,g.parseImageScalerAttributes],["InstanceNormalization","","6+",b.instanceNormalization,b.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",D.leakyRelu,D.parseLeakyReluAttributes],["Less","","7+",h.less],["Log","","6+",D.log],["MatMul","","1+",y.matMul,y.parseMatMulAttributes],["MaxPool","","1+",v.maxPool,v.parseMaxPoolAttributes],["Mul","","7+",h.mul],["Neg","","6+",D.neg],["Not","","1+",D.not],["Or","","7+",h.or],["Pad","","2-10",_.padV2,_.parsePadAttributesV2],["Pad","","11+",_.padV11,_.parsePadAttributesV11],["Pow","","7+",h.pow],["PRelu","","7+",h.pRelu],["ReduceLogSum","","1+",w.reduceLogSum,w.parseReduceAttributes],["ReduceMax","","1+",w.reduceMax,w.parseReduceAttributes],["ReduceMean","","1+",w.reduceMean,w.parseReduceAttributes],["ReduceMin","","1+",w.reduceMin,w.parseReduceAttributes],["ReduceProd","","1+",w.reduceProd,w.parseReduceAttributes],["ReduceSum","","1-12",w.reduceSum,w.parseReduceAttributes],["ReduceSumSquare","","1+",w.reduceLogSumSquare,w.parseReduceAttributes],["Relu","","6+",D.relu],["Reshape","","5+",T.reshape],["Resize","","10",A.resize,A.parseResizeAttributesV10],["Resize","","11+",A.resize,A.parseResizeAttributesV11],["Shape","","1+",E.shape],["Sigmoid","","6+",D.sigmoid],["Sin","","7+",D.sin],["Slice","","10+",x.sliceV10],["Slice","","1-9",x.slice,x.parseSliceAttributes],["Softmax","","1-12",P.softmax,P.parseSoftmaxAttributes],["Softmax","","13+",P.softmaxV13,P.parseSoftmaxAttributesV13],["Split","","2-12",L.split,L.parseSplitAttributes],["Sqrt","","6+",D.sqrt],["Squeeze","","1-12",F.squeeze,F.parseSqueezeAttributes],["Squeeze","","13+",F.squeezeV13],["Sub","","7+",h.sub],["Sum","","6+",$.sum],["Tan","","7+",D.tan],["Tanh","","6+",D.tanh],["Tile","","6+",k.tile],["Transpose","","1+",q.transpose,q.parseTransposeAttributes],["Upsample","","7-8",J.upsample,J.parseUpsampleAttributesV7],["Upsample","","9",J.upsample,J.parseUpsampleAttributesV9],["Unsqueeze","","1-12",U.unsqueeze,U.parseUnsqueezeAttributes],["Unsqueeze","","13+",U.unsqueezeV13],["Xor","","7+",h.xor]]},2898:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseBatchNormalizationAttributes=r.batchNormalization=void 0;const d=c(246),l=c(5060),m=c(2039),s={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[m.TextureType.unpacked,m.TextureType.unpacked,m.TextureType.unpacked,m.TextureType.unpacked,m.TextureType.unpacked]};r.batchNormalization=(a,o,t)=>(p(o),[a.run(Object.assign(Object.assign({},s),{cacheHint:t.cacheKey,get:()=>h(a,o,t)}),o)]),r.parseBatchNormalizationAttributes=a=>{const o=a.attributes.getFloat("epsilon",1e-5),t=a.attributes.getFloat("momentum",.9),e=a.attributes.getInt("spatial",1);return(0,d.createAttributeWithCacheKey)({epsilon:o,momentum:t,spatial:e})};const h=(a,o,t)=>{const e=(0,l.getGlsl)(a.session.backend.glContext.version),n=o[0].dims.length,[i,u]=a.calculateTextureWidthAndHeight(o[1].dims,m.TextureType.unpacked),g=` + float process(int[${n}] indices) { + vec2 position = offsetToCoords(indices[1], ${i}, ${u}); + float scale = getColorAsFloat(${e.texture2D}(Scale, position)); + float mean = getColorAsFloat(${e.texture2D}(Mean, position)); + float variance = getColorAsFloat(${e.texture2D}(Variance, position)); + float b = getColorAsFloat(${e.texture2D}(B, position)); + + return scale * ( (_A(indices) - mean) / sqrt(variance + float(${t.epsilon})) ) + b; + }`;return Object.assign(Object.assign({},s),{output:{dims:o[0].dims,type:o[0].type,textureType:m.TextureType.unpacked},shaderSource:g})},p=a=>{if(!a||a.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const o=a[0],t=a[1],e=a[2],n=a[3],i=a[4];if(o.dims.length<3||t.dims.length!==1||e.dims.length!==1||n.dims.length!==1||i.dims.length!==1)throw new Error("invalid input shape.");if(t.dims[0]!==o.dims[1]||e.dims[0]!==o.dims[1]||n.dims[0]!==o.dims[1]||i.dims[0]!==o.dims[1])throw new Error("invalid input shape.");if(o.type!=="float32"&&o.type!=="float64"||t.type!=="float32"&&t.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||i.type!=="float32"&&i.type!=="float64")throw new Error("invalid input tensor types.")}},7839:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.xor=r.sub=r.pRelu=r.pow=r.or=r.mul=r.less=r.greater=r.equal=r.div=r.and=r.add=r.glslPRelu=r.glslPow=r.glslXor=r.glslOr=r.glslAnd=r.glslLess=r.glslGreater=r.glslEqual=r.glslSub=r.glslMul=r.glslDiv=r.glslAdd=void 0;const d=c(2517),l=c(8520),m=c(5060),s=c(2039);function h(){const w="add_";return{body:` + float ${w}(float a, float b) { + return a + b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 + v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function p(){const w="div_";return{body:` + float ${w}(float a, float b) { + return a / b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 / v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function a(){const w="mul_";return{body:` + float ${w}(float a, float b) { + return a * b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 * v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function o(){const w="sub_";return{body:` + float ${w}(float a, float b) { + return a - b; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return v1 - v2; + } + `,name:w,type:l.FunctionType.ValueBased}}function t(){const w="equal_";return{body:` + float ${w}(float a, float b) { + return float(a == b); + } + vec4 ${w}(vec4 v1, vec4 v2) { + return vec4(equal(v1, v2)); + } + `,name:w,type:l.FunctionType.ValueBased}}function e(){const w="greater_";return{body:` + float ${w}(float a, float b) { + return float(a > b); + } + vec4 ${w}(vec4 v1, vec4 v2) { + return vec4( v1.r > v2.r , + v1.g > v2.g, + v1.b > v2.b, + v1.a > v2.a ); + } + `,name:w,type:l.FunctionType.ValueBased}}function n(){const w="less_";return{body:` + float ${w}(float a, float b) { + return float(a < b); + } + vec4 ${w}(vec4 v1, vec4 v2) { + return vec4( v1.r < v2.r , + v1.g < v2.g, + v1.b < v2.b, + v1.a < v2.a ); + } + `,name:w,type:l.FunctionType.ValueBased}}function i(){const w="and_";return{body:` + float ${w}(float a, float b) { + return float( bool(a) && bool(b) ); + } + vec4 ${w}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r && b2.r , + b1.g && b2.g, + b1.b && b2.b, + b1.a && b2.a ); + } + `,name:w,type:l.FunctionType.ValueBased}}function u(){const w="or_";return{body:` + float ${w}(float a, float b) { + return float( bool(a) || bool(b) ); + } + vec4 ${w}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r || b2.r , + b1.g || b2.g, + b1.b || b2.b, + b1.a || b2.a ); + } + `,name:w,type:l.FunctionType.ValueBased}}function g(){const w="xor_";return{body:` + float ${w}(float a, float b) { + return float( bool(a) ^^ bool(b) ); + } + vec4 ${w}(vec4 v1, vec4 v2) { + bvec4 b1 = bvec4(v1); + bvec4 b2 = bvec4(v2); + return vec4( b1.r ^^ b2.r , + b1.g ^^ b2.g, + b1.b ^^ b2.b, + b1.a ^^ b2.a ); + } + `,name:w,type:l.FunctionType.ValueBased}}function b(){return function(w){const T=`${w}_`;return{body:` + float ${T}(float a, float b) { + return ${w}(a, b); + } + vec4 ${T}(vec4 v1, vec4 v2) { + return ${w}(v1, v2); + } + `,name:T,type:l.FunctionType.ValueBased}}("pow")}function y(){const w="prelu_";return{body:` + float ${w}(float a, float b) { + return a < 0.0 ? a * b: a; + } + vec4 ${w}(vec4 v1, vec4 v2) { + return vec4( + v1.r < 0.0 ? v1.r * v2.r: v1.r, + v1.g < 0.0 ? v1.g * v2.g: v1.g, + v1.b < 0.0 ? v1.b * v2.b: v1.b, + v1.a < 0.0 ? v1.a * v2.a: v1.a + ); + } + `,name:w,type:l.FunctionType.ValueBased}}r.glslAdd=h,r.glslDiv=p,r.glslMul=a,r.glslSub=o,r.glslEqual=t,r.glslGreater=e,r.glslLess=n,r.glslAnd=i,r.glslOr=u,r.glslXor=g,r.glslPow=b,r.glslPRelu=y;const _=(w,T,A,E=T[0].type,x)=>{const P=w.session.pack?s.TextureType.packed:s.TextureType.unpacked;return{name:A.name,inputNames:["A","B"],inputTypes:[P,P],cacheHint:x,get:()=>v(w,T,A,E)}},v=(w,T,A,E=T[0].type)=>{const x=w.session.pack?s.TextureType.packed:s.TextureType.unpacked,P=!d.ShapeUtil.areEqual(T[0].dims,T[1].dims);let L=T[0].dims;const F=w.session.pack;if(P){const q=d.BroadcastUtil.calcShape(T[0].dims,T[1].dims,!1);if(!q)throw new Error("Can't perform binary op on the given tensors");L=q;const D=L.length,U=T[0].dims.length!==0?T[0].dims.length:1,J=T[1].dims.length!==0?T[1].dims.length:1,Y=T[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",Z=T[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",te=(0,m.getGlsl)(w.session.backend.glContext.version),he=F?` + ${A.body} + void main() { + vec4 a = getAAtOutCoords(); + vec4 b = getBAtOutCoords(); + vec4 result = ${A.name}(a, b); + ${te.output} = result; + }`:` + ${A.body} + float process(int indices[${D}]) { + int aindices[${U}]; + int bindices[${J}]; + ${Y} + ${Z} + return ${A.name}(_A(aindices), _B(bindices)); + }`;return{name:A.name,inputNames:["A","B"],inputTypes:[x,x],output:{dims:L,type:E,textureType:x},shaderSource:he,hasMain:F}}const $=(0,m.getGlsl)(w.session.backend.glContext.version),k=` + ${A.body} + void main() { + vec4 v1 = ${$.texture2D}(A, TexCoords); + vec4 v2 = ${$.texture2D}(B, TexCoords); + vec4 result = ${A.name}(v1, v2); + ${$.output} = result; + } + `;return{name:A.name,inputNames:["A","B"],inputTypes:[x,x],output:{dims:T[0].dims,type:E,textureType:x},shaderSource:k,hasMain:!0}};r.add=(w,T)=>[w.run(_(w,T,h()),T)],r.and=(w,T)=>[w.run(_(w,T,i(),"bool"),T)],r.div=(w,T)=>[w.run(_(w,T,p()),T)],r.equal=(w,T)=>[w.run(_(w,T,t(),"bool"),T)],r.greater=(w,T)=>[w.run(_(w,T,e(),"bool"),T)],r.less=(w,T)=>[w.run(_(w,T,n(),"bool"),T)],r.mul=(w,T)=>[w.run(_(w,T,a()),T)],r.or=(w,T)=>[w.run(_(w,T,u(),"bool"),T)],r.pow=(w,T)=>[w.run(_(w,T,b()),T)],r.pRelu=(w,T)=>[w.run(_(w,T,y()),T)],r.sub=(w,T)=>[w.run(_(w,T,o()),T)],r.xor=(w,T)=>[w.run(_(w,T,g(),"bool"),T)]},4196:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseCastAttributes=r.cast=void 0;const d=c(2517);r.cast=(m,s,h)=>(l(s),[m.cast(s[0],h)]),r.parseCastAttributes=m=>d.ProtoUtil.tensorDataTypeFromProto(m.attributes.getInt("to"));const l=m=>{if(!m||m.length!==1)throw new Error("Cast requires 1 input.");if(m[0].type==="string")throw new Error("Invalid input type.")}},1163:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createPackedConcatProgramInfoLoader=void 0;const d=c(5060),l=c(2039),m=c(9390),s=c(2827);r.createPackedConcatProgramInfoLoader=(p,a,o)=>{const t=(e=a.length,n=o.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:e},(i,u)=>`X${u}`),inputTypes:Array(e).fill(l.TextureType.packed),cacheHint:n});var e,n;return Object.assign(Object.assign({},t),{get:()=>((i,u,g,b)=>{const y=g[0].dims.slice();if(b>=y.length||b<-1*y.length)throw new Error("axis specified for concat doesn't match input dimensionality");b<0&&(b=y.length+b);const _=y.slice(0);for(let Y=1;YY.dims),x=(0,m.getGlChannels)(v),P=new Array(E.length-1);P[0]=E[0][b];for(let Y=1;Y= ${P[Y-1]}) { + return getChannel( + getX${Y}(${h(x,L,Z)}), + vec2(${h(F,L,Z)})); + }`}const q=P.length,D=P[P.length-1];k+=` + return getChannel( + getX${q}(${h(x,L,D)}), + vec2(${h(F,L,D)}));`;const U=(0,d.getGlsl)(i.session.backend.glContext.version),J=` + ${A} + float getValue(${x.map(Y=>"int "+Y)}) { + ${k} + } + + void main() { + ${T} coords = getOutputCoords(); + int lastDim = coords.${x[v-1]}; + coords.${x[v-1]} = coords.${x[v-2]}; + coords.${x[v-2]} = lastDim; + + vec4 result = vec4(getValue(${w}), 0., 0., 0.); + + ${w[v-1]} = ${w[v-1]} + 1; + if (${w[v-1]} < ${_[v-1]}) { + result.g = getValue(${w}); + } + + ${w[v-2]} = ${w[v-2]} + 1; + if (${w[v-2]} < ${_[v-2]}) { + result.a = getValue(${w}); + } + + ${w[v-1]} = ${w[v-1]} - 1; + if (${w[v-2]} < ${_[v-2]} && + ${w[v-1]} < ${_[v-1]}) { + result.b = getValue(${w}); + } + ${U.output} = result; + } + `;return Object.assign(Object.assign({},u),{output:{dims:_,type:g[0].type,textureType:l.TextureType.packed},shaderSource:J,hasMain:!0})})(p,t,a,o.axis)})};const h=(p,a,o)=>{const t=p.indexOf(a);return p.map((e,n)=>n===t?`${e} - ${o}`:e).join()}},2069:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseConcatAttributes=r.concat=void 0;const d=c(246),l=c(2039),m=c(1163);r.concat=(e,n,i)=>(t(n),e.session.pack&&n[0].dims.length>1?[e.run((0,m.createPackedConcatProgramInfoLoader)(e,n,i),n)]:[e.run(s(e,n,i),n)]);const s=(e,n,i)=>{const u=(g=n.length,b=i.cacheKey,{name:"Concat",inputNames:Array.from({length:g},(y,_)=>`X${_}`),inputTypes:Array(g).fill(l.TextureType.unpacked),cacheHint:b});var g,b;return Object.assign(Object.assign({},u),{get:()=>((y,_,v,w)=>{const T=v[0].dims.slice();if(w>=T.length||w<-1*T.length)throw new Error("axis specified for concat doesn't match input dimensionality");w<0&&(w=T.length+w);const A=T.slice(0);for(let $=1;$`int getTextureWhereDataResides(int index) { + ${e.map((n,i)=>`if(index<${n}) {return ${i};} +`).join("")} + }`,p=e=>h(e),a=(e,n)=>{const i=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${n}]) {`];for(let u=0;u{const n=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let i=0;i(0,d.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis")});const t=e=>{if(!e||e.length<1)throw new Error("too few inputs");const n=e[0].type,i=e[0].dims.length;if(n==="string")throw new Error("string tensor is not supported yet");for(const u of e){if(u.type!==n)throw new Error("input tensors should be one type");if(u.dims.length!==i)throw new Error("input tensors should have the same shape")}}},4770:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createUnpackedGroupedConvProgramInfoLoader=void 0;const d=c(6231),l=c(5060),m=c(2039),s=c(8138),h=c(2823);r.createUnpackedGroupedConvProgramInfoLoader=(p,a,o)=>{const t=(e=a.length>2,n=o.cacheKey,{name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[m.TextureType.unpacked,m.TextureType.unpacked,m.TextureType.unpacked]:[m.TextureType.unpacked,m.TextureType.unpacked],cacheHint:n});var e,n;return Object.assign(Object.assign({},t),{get:()=>((i,u,g,b)=>{const y=u.length>2?"value += getBias(output_channel);":"",_=u[0].dims.slice(),v=u[1].dims.slice(),w=v[0]/b.group;d.Logger.verbose("GroupedConv",`autpPad:${b.autoPad}, dilations:${b.dilations}, group:${b.group}, kernelShape:${b.kernelShape}, pads:${b.pads}, strides:${b.strides}`);const T=(0,s.calculateOutputShape)(_,v,b.dilations,b.pads,b.strides),A=(0,l.getGlsl)(i.session.backend.glContext.version),{activationFunction:E,applyActivation:x}=(0,h.getActivationSnippet)(b),P=` + const ivec2 strides = ivec2(${b.strides[0]}, ${b.strides[1]}); + const ivec2 pads = ivec2(${b.pads[0]}, ${b.pads[1]}); + ${E} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + ivec2 xRCCorner = coords.zw * strides - pads; + int group_id = output_channel / ${w}; + + float value = 0.0; + for (int wInChannel = 0; wInChannel < ${v[1]}; wInChannel++) { + int input_channel = group_id * ${v[1]} + wInChannel; + for (int wHeight = 0; wHeight < ${v[2]}; wHeight++) { + int xHeight = xRCCorner.x + wHeight * ${b.dilations[0]}; + + if (xHeight < 0 || xHeight >= ${_[2]}) { + continue; + } + + for (int wWidth = 0; wWidth < ${v[3]}; wWidth++) { + int xWidth = xRCCorner.y + wWidth * ${b.dilations[1]}; + if (xWidth < 0 || xWidth >= ${_[3]}) { + continue; + } + + float xVal = getX(batch, input_channel, xWidth, xHeight); + float wVal = getW(output_channel, wInChannel, wWidth, wHeight); + value += xVal*wVal; + } + } + } + ${y} + ${x} + ${A.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},g),{output:{dims:T,type:u[0].type,textureType:m.TextureType.unpacked},shaderSource:P,hasMain:!0})})(p,a,t,o)})}},1386:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.conv2DPacked=r.conv2DPackedPointwise=void 0;const d=c(8138),l=c(8555),m=c(708);r.conv2DPackedPointwise=(s,h,p)=>{const a=h[0].dims,o=h[1].dims,t=(0,d.calculateOutputShape)(a,o,p.dilations,p.pads,p.strides),e=s.reshapePacked(h[0],[a[1],a[2]*a[3]]),n=s.reshapePacked(h[1],[o[0],o[1]]),i=h.length>2?[n,e,h[2]]:[n,e],u=s.run((0,m.createPackedMatmulProgramInfoLoader)(s,i,p),i);return s.reshapePacked(u,t)},r.conv2DPacked=(s,h,p)=>{const a=h[0].dims,o=h[1].dims,t=(0,d.calculateOutputShape)(a,o,p.dilations,p.pads,p.strides),e=s.run((0,l.createPackedIm2ColProgramInfoLoader)(s,h[0],h[1],t,p),[h[0]]),n=s.reshapePacked(h[1],[o[0],o[1]*o[2]*o[3]]),i=h.length===3?[n,e,h[2]]:[n,e],u=s.run((0,m.createPackedMatmulProgramInfoLoader)(s,i,p),i);return s.reshapePacked(u,t)}},9663:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseConvTransposeAttributes=r.convTranspose=void 0;const d=c(246),l=c(5060),m=c(2039),s=c(2823),h=(n,i,u,g,b,y)=>(n-1)*i+u+(g-1)*b+1-y,p=(n,i,u,g,b)=>{const y=Math.floor(n/2);i==="SAME_UPPER"?(u[g]=y,u[b]=n-y):i==="SAME_LOWER"&&(u[g]=n-y,u[b]=y)};r.convTranspose=(n,i,u)=>(e(i,u),a(n,i,u));const a=(n,i,u)=>{const g=t(u,i);return[o(n,i,g)]},o=(n,i,u)=>n.run(((g,b,y)=>{const _=(v=b.length>2,w=y.cacheKey,{name:"ConvTranspose",inputNames:v?["X","W","B"]:["X","W"],inputTypes:v?[m.TextureType.unpacked,m.TextureType.unpacked,m.TextureType.unpacked]:[m.TextureType.unpacked,m.TextureType.unpacked],cacheHint:w});var v,w;return Object.assign(Object.assign({},_),{get:()=>((T,A,E,x)=>{const P=A.length>2?"getB(output_channel)":"0.0",L=A[0].dims,F=A[1].dims,$=F[1],k=F[0]/x.group,q=[A[0].dims[0],A[1].dims[1]*x.group,...x.outputShape],D=(0,l.getGlsl)(T.session.backend.glContext.version),{activationFunction:U,applyActivation:J}=(0,s.getActivationSnippet)(x),Y=` + const ivec2 strides = ivec2(${x.strides[0]}, ${x.strides[1]}); + const ivec2 pads = ivec2(${x.pads[0]}, ${x.pads[1]}); + ${U} + void main() { + ivec4 coords = getOutputCoords(); + int batch = coords.x; + int output_channel = coords.y; + + ivec2 loc = coords.zw + pads; + + int group_id = output_channel / ${$}; + int wOutChannel = output_channel - group_id * ${$}; + + float value = ${P}; + for (int inChannelOffset = 0; inChannelOffset < ${k}; inChannelOffset++) { + int input_channel = group_id * ${k} + inChannelOffset; + for (int wWOff = 0; wWOff < ${F[2]}; wWOff++) { + for (int wHOff = 0; wHOff < ${F[3]}; wHOff++) { + ivec2 wOff = ivec2(wWOff * ${x.dilations[0]}, wHOff * ${x.dilations[1]}); + ivec2 wLoc = loc - wOff; + ivec2 wLocIn = wLoc / strides; + if ( + wLocIn * strides == wLoc && + wLocIn.x >= 0 && wLocIn.x < ${L[2]} && + wLocIn.y >= 0 && wLocIn.y < ${L[3]} + ) { + float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); + float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); + value += xVal * wVal; + } + } + } + } + ${J} + ${D.output} = vec4(value, .0, .0, .0); + } +`;return Object.assign(Object.assign({},E),{output:{dims:q,type:A[0].type,textureType:m.TextureType.unpacked},shaderSource:Y,hasMain:!0})})(g,b,_,y)})})(n,i,u),i),t=(n,i)=>{const u=n.kernelShape.slice();if(n.kernelShape.length===0)for(let _=2;_{const L=_.length-2,F=P.length===0;for(let $=0;${const i=n.attributes,u=(0,s.parseInternalActivationAttributes)(i),g=i.getString("auto_pad","NOTSET"),b=i.getInts("dilations",[1,1]),y=i.getInt("group",1),_=i.getInts("kernel_shape",[]),v=i.getInts("output_padding",[0,0]),w=i.getInts("output_shape",[]),T=i.getInts("pads",[0,0,0,0]),A=i.getInts("strides",[1,1]);return(0,d.createAttributeWithCacheKey)(Object.assign({autoPad:g,dilations:b,group:y,kernelShape:_,outputPadding:v,outputShape:w,pads:T,strides:A},u))};const e=(n,i)=>{if(!n||n.length!==2&&n.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(n[0].dims.length!==4||n[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(n[0].dims[1]!==n[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const u=n[1].dims[1]*i.group;if(n.length===3&&(n[2].dims.length!==1||n[2].dims[0]!==u))throw new Error("invalid bias");const g=n[0].dims.length-2;if(i.dilations.length!==g)throw new Error(`dilations should be ${g}D`);if(i.strides.length!==g)throw new Error(`strides should be ${g}D`);if(i.pads.length!==2*g)throw new Error(`pads should be ${2*g}D`);if(i.outputPadding.length!==g)throw new Error(`output_padding should be ${g}D`);if(i.kernelShape.length!==0&&i.kernelShape.length!==n[1].dims.length-2)throw new Error("invalid kernel shape");if(i.outputShape.length!==0&&i.outputShape.length!==n[0].dims.length-2)throw new Error("invalid output shape");if(n[0].type!=="float32"||n[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(n.length===3&&n[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}},8138:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseConvAttributes=r.conv=r.calculateOutputShape=void 0;const d=c(246),l=c(2517),m=c(4770),s=c(1386),h=c(9828),p=c(2823),a=c(3248),o=c(5623);r.calculateOutputShape=(g,b,y,_,v)=>{const w=g[0],T=g.slice(2),A=T.length,E=b[0],x=b.slice(2).map((L,F)=>L+(L-1)*(y[F]-1)),P=T.map((L,F)=>L+_[F]+_[F+A]).map((L,F)=>Math.floor((L-x[F]+v[F])/v[F]));return[w,E].concat(...P)},r.conv=(g,b,y)=>(u(b,y),t(g,b,y));const t=(g,b,y)=>{const _=i(y,b),v=g.session.pack,w=_.kernelShape[0]===1&&_.kernelShape[1]===1;return _.group>1?[g.run((0,m.createUnpackedGroupedConvProgramInfoLoader)(g,b,_),b)]:w&&v?[e(g,b,_)]:v&&b[0].dims.length===4&&b[0].dims[0]===1&&!w?[(0,s.conv2DPacked)(g,b,_)]:[n(g,b,_)]},e=(g,b,y)=>{const _=b[0].dims,v=b[1].dims,w=(0,r.calculateOutputShape)(_,v,y.dilations,y.pads,y.strides),T=g.reshapeUnpacked(b[0],[_[1],_[2]*_[3]]),A=g.reshapeUnpacked(b[1],[v[0],v[1]]),E=b.length>2?[A,T,b[2]]:[A,T],x=g.run((0,o.createMatmulProgramInfoLoader)(E,y),E);return g.reshapeUnpacked(x,w)},n=(g,b,y)=>{const _=b[0].dims,v=b[1].dims,w=(0,r.calculateOutputShape)(_,v,y.dilations,y.pads,y.strides),T=g.run((0,a.createIm2ColProgramInfoLoader)(g,b[0],b[1],w,y),[b[0]]),A=b.length===3?[T,b[1],b[2]]:[T,b[1]];return g.run((0,h.createDotProductProgramInfoLoader)(g,b,w,y),A)},i=(g,b)=>{const y=g.kernelShape.slice();if(g.kernelShape.length===0)for(let w=2;w{const b=g.attributes,y=(0,p.parseInternalActivationAttributes)(b),_=b.getString("auto_pad","NOTSET"),v=b.getInts("dilations",[1,1]),w=b.getInt("group",1),T=b.getInts("kernel_shape",[]),A=b.getInts("pads",[0,0,0,0]),E=b.getInts("strides",[1,1]);return(0,d.createAttributeWithCacheKey)(Object.assign({autoPad:_,dilations:v,group:w,kernelShape:T,pads:A,strides:E},y))};const u=(g,b)=>{if(!g||g.length!==2&&g.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(g[0].dims.length!==4||g[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(g[0].dims[1]!==g[1].dims[1]*b.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(g.length===3&&(g[2].dims.length!==1||g[1].dims[0]!==g[2].dims[0]))throw new Error("invalid bias");const y=g[0].dims.length-2;if(b.dilations.length!==y)throw new Error(`dilations should be ${y}D`);if(b.strides.length!==y)throw new Error(`strides should be ${y}D`);if(b.pads.length!==2*y)throw new Error(`pads should be ${2*y}D`);if(b.kernelShape.length!==0&&b.kernelShape.length!==g[1].dims.length-2)throw new Error("invalid kernel shape");if(g[0].type!=="float32"||g[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(g.length===3&&g[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}},5193:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseDepthToSpaceAttributes=r.depthToSpace=void 0;const d=c(3738);r.depthToSpace=(m,s,h)=>{l(s);const p=h.blocksize,a=p*p,o=h.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],t=h.mode==="DCR"?[s[0].dims[0],p,p,s[0].dims[1]/a,s[0].dims[2],s[0].dims[3]]:[s[0].dims[0],s[0].dims[1]/a,p,p,s[0].dims[2],s[0].dims[3]],e=m.reshapeUnpacked(s[0],t),n={perm:o,cacheKey:`${o}`},[i]=(0,d.transpose)(m,[e],n),u=[s[0].dims[0],s[0].dims[1]/a,s[0].dims[2]*p,s[0].dims[3]*p];return[m.reshapeUnpacked(i,u)]},r.parseDepthToSpaceAttributes=m=>{const s=m.attributes.getInt("blocksize");if(s<1)throw new Error(`blocksize must be >= 1, but got : ${s} for DepthToSpace`);const h=m.attributes.getString("mode","DCR");if(h!=="DCR"&&h!=="CRD")throw new Error(`unrecognized mode: ${h} for DepthToSpace`);return{mode:h,blocksize:s}};const l=m=>{if(m.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${m.length}`);if(m[0].type==="string"||m[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},9828:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDotProductProgramInfoLoader=void 0;const d=c(2517),l=c(5060),m=c(2039),s=c(2823),h=c(3248);r.createDotProductProgramInfoLoader=(p,a,o,t)=>{const e=((n,i)=>({name:"ConvDotProduct",inputNames:n?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:n?[m.TextureType.unpacked,m.TextureType.packedLastDimension,m.TextureType.unpacked]:[m.TextureType.unpacked,m.TextureType.packedLastDimension],cacheKey:i.activationCacheKey}))(a.length>2,t);return Object.assign(Object.assign({},e),{get:()=>((n,i,u,g,b)=>{const y=u[0].dims,_=u[1].dims,v=[_[0],Math.ceil(y[1]*_[2]*_[3]/4)],w=(0,h.calculateIm2ColDims)(y,_,g),[T,A]=n.calculateTextureWidthAndHeight(v,m.TextureType.packedLastDimension),E=d.ShapeUtil.computeStrides(w),[x,P]=n.calculateTextureWidthAndHeight(w,m.TextureType.packedLastDimension),L=g.length,F=u.length<3?"0.0":"_B(b)",$=Math.ceil(y[1]*_[2]*_[3]/4),{activationFunction:k,applyActivation:q}=(0,s.getActivationSnippet)(b),D=(0,l.getGlsl)(n.session.backend.glContext.version),U=` +${k} +float process(int indices[${L}]) { + int b[1]; + b[0] = indices[1]; + int im2col[4]; + im2col[0] = indices[0]; + im2col[1] = indices[2]; + im2col[2] = indices[3]; + int im2colOffset = im2col[0] * ${E[0]} + im2col[1] * ${E[1]} + im2col[2] * ${E[2]}; + int kernelOffset = indices[1] * ${v[1]}; + float value = ${F}; + for (int i = 0; i < ${$}; ++i) { + vec2 im2colCoords = offsetToCoords(im2colOffset, ${x}, ${P}); + vec2 kernelCoords = offsetToCoords(kernelOffset, ${T}, ${A}); + value += dot(${D.texture2D}(Im2Col, im2colCoords), ${D.texture2D}(K, kernelCoords)); + ++im2colOffset; + ++kernelOffset; + } + ${q} + return value; +}`;return Object.assign(Object.assign({},i),{output:{dims:g,type:u[0].type,textureType:m.TextureType.unpacked},shaderSource:U})})(p,e,a,o,t)})}},7992:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseFlattenAttributes=r.flatten=void 0;const d=c(2517);r.flatten=(m,s,h)=>{l(s,h);const p=d.ShapeUtil.flattenShape(s[0].dims,h);return[m.reshapeUnpacked(s[0],p)]},r.parseFlattenAttributes=m=>m.attributes.getInt("axis",1);const l=(m,s)=>{if(!m||m.length!==1)throw new Error("Flatten requires 1 input.");const h=m[0].dims.length;if(h===0)throw new Error("scalar tensor is not supported.");if(s<-h||s>h)throw new Error("Invalid axis");if(m[0].type==="string")throw new Error("string tensor is not supported.")}},2823:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseInternalActivationAttributes=r.getActivationSnippet=void 0;const d=c(2517),l=c(4909);r.getActivationSnippet=function(m){let s;switch(m.activation){case"Relu":s=(0,l.glslRelu)();break;case"Sigmoid":s=(0,l.glslSigmoid)();break;case"Clip":s=(0,l.glslClip)(m.clipMin,m.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const h=s.name;return{activationFunction:s.body,applyActivation:`value = ${h}_(value);`}},r.parseInternalActivationAttributes=m=>{const s=m.getString("activation","");if(s==="Clip"){const[h,p]=m.getFloats("activation_params",[d.MIN_CLIP,d.MAX_CLIP]);return{activation:s,clipMax:p,clipMin:h,activationCacheKey:`${s}:${h},${p}`}}return{activation:s,activationCacheKey:s}}},1253:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseGatherAttributes=r.gather=void 0;const d=c(246),l=c(782),m=c(2517),s=c(2039);r.gather=(o,t,e)=>(a(t,e.axis),[o.run(p(o,t,e),t)]),r.parseGatherAttributes=o=>(0,d.createAttributeWithCacheKey)({axis:o.attributes.getInt("axis",0)});const h={name:"Gather",inputNames:["A","B"],inputTypes:[s.TextureType.unpacked,s.TextureType.unpacked]},p=(o,t,e)=>{const n=Object.assign(Object.assign({},h),{cacheHint:e.cacheKey});return Object.assign(Object.assign({},n),{get:()=>((i,u,g,b)=>{const y=g[0].dims.slice(),_=g[1].dims.slice(),v=new Array(y.length+_.length-1);b=m.ShapeUtil.normalizeAxis(b,y.length);const w=[];for(let A=0;A{if(!o||o.length!==2)throw new Error("Gather requires 2 inputs.");const e=o[0].dims.length;if(e<1)throw new Error("Invalid input shape.");if(t<-e||t>e-1)throw new Error("Invalid axis.");if(l.NUMBER_TYPES.indexOf(o[0].type)===-1)throw new Error("Invaid input type.");if(o[1].type!=="int32"&&o[1].type!=="int16")throw new Error("Invaid input type.")}},4776:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseGemmAttributesV11=r.parseGemmAttributesV7=r.gemm=void 0;const d=c(246),l=c(2517),m=c(2039);r.gemm=(o,t,e)=>(a(t,e),[o.run(h(t,e),t)]);const s=(o,t)=>{const e=o.attributes.getInt("transA",0)!==0,n=o.attributes.getInt("transB",0)!==0,i=o.attributes.getFloat("alpha",1),u=o.attributes.getFloat("beta",1);return(0,d.createAttributeWithCacheKey)({transA:e,transB:n,alpha:i,beta:u,isOptionalC:t})};r.parseGemmAttributesV7=o=>s(o,!1),r.parseGemmAttributesV11=o=>s(o,!0);const h=(o,t)=>{const e={name:"Gemm",inputNames:o.length===3?["A","B","C"]:["A","B"],inputTypes:o.length===3?[m.TextureType.unpacked,m.TextureType.unpacked,m.TextureType.unpacked]:[m.TextureType.unpacked,m.TextureType.unpacked],key:t.cacheKey};return Object.assign(Object.assign({},e),{get:()=>p(e,o,t)})},p=(o,t,e)=>{const n=t[0].dims.slice(),i=t[1].dims.slice(),[u,g]=l.GemmUtil.getShapeOfGemmResult(n,e.transA,i,e.transB,t.length===3?t[2].dims:void 0),b=[u,g];if(!b)throw new Error("Can't use gemm on the given tensors");let y=n[n.length-1],_="";e.transA&&(y=n[0]),e.transA&&e.transB?_="value += _A_T(a) * _B_T(b);":e.transA&&!e.transB?_="value += _A_T(a) * _B(b);":!e.transA&&e.transB?_="value += _A(a) * _B_T(b);":e.transA||e.transB||(_="value += _A(a) * _B(b);");const v=b.length,w=` + float process(int indices[${v}]) { + int a[${v}]; + int b[${v}]; + ${t.length===3?`int c[${t[2].dims.length}];`:""} + + copyVec(indices, a); + copyVec(indices, b); + ${t.length===3?"bcastIndices_C(indices, c);":""} + + float value = 0.0; + for (int k=0; k<${y}; ++k) { + a[${v-1}] = k; + b[${v-2}] = k; + ${_} + } + + value = value * alpha; + ${t.length===3?"value += beta * _C(c);":""} + return value; + }`;return Object.assign(Object.assign({},o),{output:{dims:b,type:t[0].type,textureType:m.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:e.alpha},{name:"beta",type:"float",data:e.beta}],shaderSource:w})},a=(o,t)=>{if(!o)throw new Error("Input is missing");if(t.isOptionalC&&(o.length<2||o.length>3))throw new Error("Invaid input shape.");if(!t.isOptionalC&&o.length!==3)throw new Error("Gemm requires 3 inputs");if(o.length===3&&o[2].dims.length!==1&&o[2].dims.length!==2)throw new Error("Invalid input shape of C");if(o[0].type!=="float32"&&o[0].type!=="float64"||o[1].type!=="float32"&&o[1].type!=="float64"||o.length===3&&o[2].type!=="float32"&&o[2].type!=="float64")throw new Error("Invalid input type.");if(o[0].type!==o[1].type||o.length===3&&o[0].type!==o[2].type)throw new Error("Input types are mismatched")}},8555:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createPackedIm2ColProgramInfoLoader=void 0;const d=c(5060),l=c(2039),m=c(2827);r.createPackedIm2ColProgramInfoLoader=(s,h,p,a,o)=>{const t=(e=o.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[l.TextureType.packed],cacheHint:e});var e;return Object.assign(Object.assign({},t),{get:()=>((n,i,u,g,b,y)=>{const _=u.dims,v=g.dims,w=b.length,T=[v[1]*v[2]*v[3],b[2]*b[3]],A=v[2]*v[3],E=(0,m.unpackFromChannel)(),x=(0,d.getGlsl)(n.session.backend.glContext.version);let P="";for(let F=0;F<=1;F++)for(let $=0;$<=1;$++)P+=` + blockIndex = rc.x + ${$}; + pos = rc.y + ${F}; + + if(blockIndex < ${T[1]} && pos < ${T[0]}) { + offsetY = int(blockIndex / (${b[w-1]})) * ${y.strides[0]} - + ${y.pads[0]}; + d0 = offsetY + ${y.dilations[0]} * (imod(pos, ${A}) / ${v[2]}); + + if(d0 < ${_[2]} && d0 >= 0) { + offsetX = imod(blockIndex, ${b[w-1]}) * ${y.strides[1]} - + ${y.pads[1]}; + d1 = offsetX + ${y.dilations[1]} * imod(imod(pos, ${A}), ${v[2]}); + + if(d1 < ${_[3]} && d1 >= 0) { + + ch = int(float(pos)/ ${A}.); + innerDims = vec2(d0, d1); + result[${2*F+$}] = getChannel( + getA(0, ch, int(innerDims.x), + int(innerDims.y)), innerDims); + } + } + } + + `;const L=` + ${E} + + void main() { + ivec2 rc = getOutputCoords(); + vec4 result = vec4(0.0); + int blockIndex, pos, offsetY, d0, offsetX, d1, ch; + vec2 innerDims; + ${P} + ${x.output} = result; + } + `;return Object.assign(Object.assign({},i),{output:{dims:T,type:u.type,textureType:l.TextureType.packed},shaderSource:L,hasMain:!0})})(s,t,h,p,a,o)})}},3248:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.calculateIm2ColDims=r.createIm2ColProgramInfoLoader=void 0;const d=c(2039);r.createIm2ColProgramInfoLoader=(l,m,s,h,p)=>{const a=(o=p.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:o});var o;return Object.assign(Object.assign({},a),{get:()=>((t,e,n,i,u,g)=>{const b=n.dims,y=i.dims,_=u.length,v=(0,r.calculateIm2ColDims)(b,y,u,4),w=` + const int XC = ${b[1]}; + const int XH = ${b[2]}; + const int XW = ${b[3]}; + const int KH = ${g.kernelShape[0]}; + const int KW = ${g.kernelShape[1]}; + const int dilationH = ${g.dilations[0]}; + const int dilationW = ${g.dilations[1]}; + const int strideH = ${g.strides[0]}; + const int strideW = ${g.strides[1]}; + const int padH = ${g.pads[0]}; + const int padW = ${g.pads[1]}; + const int KHKW = KH*KW; + const int XCKHKW = XC * KHKW; + const int outputChannels = 4; + vec4 process(int indices[${_}]) { + int b = indices[0]; // batch size + int oh = indices[1] * strideH - padH; //output height + int ow = indices[2] * strideW - padW; //output width + int p = indices[3] * outputChannels; //patch + vec4 value = vec4(0.0); + for(int i=0; i < outputChannels; ++i) { + if(p < XCKHKW) { + int patchC = p / KHKW; + int patchH = (p - patchC*KHKW) / KW; + int patchW = (p - patchC*KHKW) - patchH * KW; + int xh2 = oh + patchH * dilationH; + int xw2 = ow + patchW * dilationW; + int x[${b.length}]; + x[0] = b; + x[1] = patchC; + x[2] = xh2; + x[3] = xw2; + if(xh2 >= 0 && + xh2 < XH && + xw2 >= 0 && + xw2 < XW) { + value[i] = _X(x); + } + } + ++p; + } + return value; + } + `;return Object.assign(Object.assign({},e),{output:{dims:v,type:n.type,textureType:d.TextureType.packedLastDimension},shaderSource:w})})(0,a,m,s,h,p)})},r.calculateIm2ColDims=(l,m,s,h=4)=>[s[0],s[2],s[3],Math.ceil(l[1]*m[2]*m[3]/h)]},6572:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseImageScalerAttributes=r.imageScaler=void 0;const d=c(246),l=c(2039);r.imageScaler=(a,o,t)=>(p(o),[a.run(s(a,o,t),o)]),r.parseImageScalerAttributes=a=>{const o=a.attributes.getFloat("scale"),t=a.attributes.getFloats("bias");return(0,d.createAttributeWithCacheKey)({scale:o,bias:t})};const m={name:"ImageScaler",inputNames:["X"],inputTypes:[l.TextureType.unpacked]},s=(a,o,t)=>{const e=Object.assign(Object.assign({},m),{cacheHint:t.cacheKey});return Object.assign(Object.assign({},e),{get:()=>((n,i,u,g)=>{const b=u[0].dims.slice(),y=b.length,_=` + ${h(g.bias.length)} + float process(int indices[${y}]) { + return _X(indices) * scale + getBias(bias, indices[1]); + }`;return Object.assign(Object.assign({},i),{output:{dims:b,type:u[0].type,textureType:l.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:g.bias.length,data:g.bias},{name:"scale",type:"float",data:g.scale}],shaderSource:_})})(0,e,o,t)})},h=a=>{const o=[`float getBias(float bias[${a}], int channel) {`];for(let t=0;t{if(!a||a.length!==1)throw new Error("ImageScaler requires 1 input.");if(a[0].dims.length!==4)throw new Error("Invalid input shape.");if(a[0].type!=="float32"&&a[0].type!=="float64")throw new Error("Invalid input type.")}},3346:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseInstanceNormalizationAttributes=r.instanceNormalization=void 0;const d=c(5060),l=c(2039);r.instanceNormalization=(o,t,e)=>{a(t);const n=o.run(s(t[0]),t);return[o.run(p(o,t[0],e,n.dims),[t[0],n,t[1],t[2]])]},r.parseInstanceNormalizationAttributes=o=>o.attributes.getFloat("epsilon",1e-5);const m={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[l.TextureType.unpacked]},s=o=>Object.assign(Object.assign({},m),{get:()=>((t,e)=>{const n=e.dims.slice(),i=n[1],u=n[2]*n[3],g=[n[0],i],b=` + vec4 process(int[2] indices) { + vec4 v = vec4(0.0); + int a[4]; + a[0] = indices[0]; + a[1] = indices[1]; + float temp = 0.0; + for(int a2=0; a2<${n[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${n[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += x; + } + } + float mean = temp / float(${u}); + temp = 0.0; + for(int a2=0; a2<${n[2]}; a2++) { + a[2] = a2; + for(int a3=0; a3<${n[3]}; a3++) { + a[3] = a3; + float x = _X(a); + temp += (x - mean) * (x - mean); + } + } + v.r = mean; + v.g = temp / float(${u}); + + return v; + }`;return Object.assign(Object.assign({},t),{output:{dims:g,type:e.type,textureType:l.TextureType.packedLastDimension},shaderSource:b})})(m,o)}),h={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[l.TextureType.unpacked,l.TextureType.packedLastDimension,l.TextureType.unpacked,l.TextureType.unpacked]},p=(o,t,e,n)=>{const i=Object.assign(Object.assign({},h),{cacheHint:`${e}`});return Object.assign(Object.assign({},i),{get:()=>((u,g,b,y,_)=>{const v=(0,d.getGlsl)(u.session.backend.glContext.version),[w,T]=u.calculateTextureWidthAndHeight(_,l.TextureType.packedLastDimension),[A,E]=[w/4,T],x=` + vec4 get_MeanAndVariance(int[2] mv) { + int offset = indicesToOffset_MeanAndVariance(mv); + vec2 coords = offsetToCoords(offset, ${A}, ${E}); + return ${v.texture2D}(MeanAndVariance, coords); + } + + float process(int[4] indices) { + int mv[2]; + mv[0] = indices[0]; + mv[1] = indices[1]; + vec4 mean_and_variance = get_MeanAndVariance(mv); + float mean = mean_and_variance.r; + float variance = mean_and_variance.g; + + int sb[1]; + sb[0] = indices[1]; + float scale = _Scale(sb); + float b = _B(sb); + + return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b; + }`;return Object.assign(Object.assign({},g),{output:{dims:b.dims,type:b.type,textureType:l.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:y}],shaderSource:x})})(o,i,t,e,n)})},a=o=>{if(!o||o.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const t=o[0],e=o[1],n=o[2];if(t.dims.length<3||e.dims.length!==1||n.dims.length!==1)throw new Error("Invalid input shape.");if(e.dims[0]!==t.dims[1]||n.dims[0]!==t.dims[1])throw new Error("Input shapes are mismatched.");if(t.type!=="float32"&&t.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||n.type!=="float32"&&n.type!=="float64")throw new Error("Invalid input type.");if(o[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},708:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createPackedMatmulProgramInfoLoader=void 0;const d=c(2517),l=c(5060),m=c(2039),s=c(9390),h=c(2823),p=c(5623);r.createPackedMatmulProgramInfoLoader=(a,o,t)=>{const e=(n=o.length>2,i=t.activationCacheKey,{name:"MatMul (packed)",inputNames:n?["A","B","Bias"]:["A","B"],inputTypes:n?[m.TextureType.packed,m.TextureType.packed,m.TextureType.packed]:[m.TextureType.packed,m.TextureType.packed],cacheHint:i});var n,i;return Object.assign(Object.assign({},e),{get:()=>((u,g,b,y)=>{const _=b.length>2,v=_?"value += getBiasForMatmul();":"",w=b[0].dims,T=b[1].dims,A=d.BroadcastUtil.calcShape(w,T,!0),E=!d.ShapeUtil.areEqual(b[0].dims,b[1].dims);if(!A)throw new Error("Can't use matmul on the given tensors");const x=w[w.length-1],P=Math.ceil(x/2),L=w.length,F=T.length,$=(0,l.getGlsl)(u.session.backend.glContext.version),k=(0,s.getCoordsDataType)(A.length),q=A.length,D=(0,s.getGlChannels)(),{activationFunction:U,applyActivation:J}=(0,h.getActivationSnippet)(y),Y=_?`${(0,p.getBiasForMatmul)(k,D,b[2].dims,A,!0)}`:"",Z=E?`${function(Te,ue,xe,_e){let Ce=[],ze=[];const Se=xe[0].dims,De=xe[1].dims,Re=Se.length,Ae=De.length,we=_e.length,Fe=we-Re,Ue=we-Ae;Ce=Se.map((Ee,$e)=>`coords.${ue[$e+Fe]}`),Ce[Re-1]="i*2",Ce.join(", "),ze=De.map((Ee,$e)=>`coords.${ue[$e+Ue]}`),ze[Ae-2]="i*2",ze.join(", ");const Be=d.BroadcastUtil.getBroadcastDims(Se,_e),We=d.BroadcastUtil.getBroadcastDims(De,_e),qe=Be.map(Ee=>`coords.${ue[Ee+Fe]} = 0;`).join(` +`),je=We.map(Ee=>`coords.${ue[Ee+Ue]} = 0;`).join(` +`),Ve=`int lastDim = coords.${ue[we-1]}; + coords.${ue[we-1]} = coords.${ue[we-2]}; + coords.${ue[we-2]} = lastDim;`;return` +vec4 getAAtOutCoordsMatmul(int i) { + ${Te} coords = getOutputCoords(); + ${Ve} + ${qe} + vec4 outputValue = getA(${Ce}); + return outputValue; +} + +vec4 getBAtOutCoordsMatmul(int i) { + ${Te} coords = getOutputCoords(); + ${Ve} + ${je} + vec4 outputValue = getB(${ze}); + return outputValue; +}`}(k,D,b,A)}`:"",te=E?"getAAtOutCoordsMatmul(i)":`getA(${function(Te,ue){let xe="";for(let _e=0;_e{Object.defineProperty(r,"__esModule",{value:!0}),r.getBiasForMatmul=r.createMatmulProgramInfoLoader=r.parseMatMulAttributes=r.matMul=void 0;const d=c(2517),l=c(2039),m=c(9390),s=c(2823),h=c(708);function p(t,e){const n=(i=t.length>2,u=e.activationCacheKey,{name:"MatMul",inputNames:i?["A","B","Bias"]:["A","B"],inputTypes:i?[l.TextureType.unpacked,l.TextureType.unpacked,l.TextureType.unpacked]:[l.TextureType.unpacked,l.TextureType.unpacked],cacheHint:u});var i,u;return Object.assign(Object.assign({},n),{get:()=>function(g,b,y){const _=b[0].dims,v=b[1].dims,w=d.BroadcastUtil.calcShape(_,v,!0);if(!w)throw new Error("Can't use matmul on the given tensors");const T=(0,m.getCoordsDataType)(w.length),A=(0,m.getGlChannels)(),{activationFunction:E,applyActivation:x}=(0,s.getActivationSnippet)(y),P=b.length>2,L=P?"value += getBiasForMatmul();":"",F=P?`${o(T,A,b[2].dims,w,!1)}`:"",$=w.length,k=_.length,q=v.length,D=` + ${E} + ${F} + float process(int indices[${$}]) { + int a[${k}]; + int b[${q}]; + bcastMatmulIndices_A(indices, a); + bcastMatmulIndices_B(indices, b); + + float value; + for (int k=0; k<${_[_.length-1]}; ++k) { + a[${k-1}] = k; + b[${q-2}] = k; + value += _A(a) * _B(b); + } + ${L} + ${x} + return value; + }`;return Object.assign(Object.assign({},g),{output:{dims:w,type:b[0].type,textureType:l.TextureType.unpacked},shaderSource:D})}(n,t,e)})}r.matMul=(t,e,n)=>(a(e),t.session.pack?[t.run((0,h.createPackedMatmulProgramInfoLoader)(t,e,n),e)]:[t.run(p(e,n),e)]),r.parseMatMulAttributes=t=>(0,s.parseInternalActivationAttributes)(t.attributes),r.createMatmulProgramInfoLoader=p;const a=t=>{if(!t||t.length!==2)throw new Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw new Error("shared dimension does not match.");if(t[0].type!=="float32"&&t[0].type!=="float64"||t[1].type!=="float32"&&t[1].type!=="float64")throw new Error("inputs should be float type");if(t[0].type!==t[1].type)throw new Error("inputs types should match")};function o(t,e,n,i,u){let g="";const b=n.length,y=i.length,_=y-b;g=y<2&&b>0?"coords":n.map((T,A)=>`coords.${e[A+_]}`).join(", ");const v=d.BroadcastUtil.getBroadcastDims(n,i).map(T=>`coords.${e[T+_]} = 0;`).join(` +`);let w="vec4(outputValue.xx, outputValue.yy)";return d.ShapeUtil.size(n)===1&&(w="vec4(outputValue.x)"),u?` +vec4 getBiasForMatmul() { + ${t} coords = getOutputCoords(); + ${v} + vec4 outputValue = getBias(${g}); + return ${w}; +}`:` +float getBiasForMatmul() { + ${t} coords = getOutputCoords(); + ${v} + return getBias(coords.x); +}`}r.getBiasForMatmul=o},2403:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createPackProgramInfoLoader=void 0;const d=c(5060),l=c(2039),m=c(9390),s=c(2827),h={name:"pack",inputNames:["A"],inputTypes:[l.TextureType.unpackedReversed]};r.createPackProgramInfoLoader=(p,a)=>Object.assign(Object.assign({},h),{get:()=>((o,t)=>{const e=(0,d.getGlsl)(o.session.backend.glContext.version),n=t.dims,i=n.length,u=t.dims.length,g=(0,m.getCoordsDataType)(u),b=(0,s.getChannels)("rc",u),y=(_=u,v=b,w=n[n.length-2],T=n[n.length-1],_===0||_===1?"":` + int r = ${v[_-2]}; + int c = ${v[_-1]}; + int rp1 = ${v[_-2]} + 1; + int cp1 = ${v[_-1]} + 1; + bool rEdge = rp1 >= ${T}; + bool cEdge = cp1 >= ${w}; + `);var _,v,w,T;let A;A=i===0?[1,1]:i===1?[n[0],1]:[n[u-1],n[u-2]];const E=function(L,F,$){if(L===0)return"false";if(L===1)return`rc > ${F[0]}`;let k="";for(let q=L-2;q= ${F[q-L+2]}`,q= ${L[0]} ? 0. : getA(rc + 1), + 0, 0`;let k="";if($>2)for(let q=0;q<$-2;++q)k+=`${F[q]},`;return`getA(${k}r, c), + rEdge ? 0. : getA(${k}rp1, c), + cEdge ? 0. : getA(${k}r, cp1), + rEdge || cEdge ? 0. : getA(${k}rp1, cp1)`}(n,b),P=` + void main() { + ${g} rc = getOutputCoords(); + + if(${E}) { + ${e.output} = vec4(0); + } else { + ${y} + + ${e.output} = vec4(${x}); + } + } + `;return Object.assign(Object.assign({},h),{hasMain:!0,output:{dims:t.dims,type:t.type,textureType:l.TextureType.packed},shaderSource:P})})(p,a)})},2827:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.unpackFromChannel=r.getChannels=r.getVecChannels=void 0;const d=c(9390);function l(m,s){return(0,d.getGlChannels)(s).map(h=>`${m}.${h}`)}r.getVecChannels=l,r.getChannels=function(m,s){return s===1?[m]:l(m,s)},r.unpackFromChannel=function(){return` + float getChannel(vec4 frag, int dim) { + int modCoord = imod(dim, 2); + return modCoord == 0 ? frag.r : frag.g; + } + + float getChannel(vec4 frag, vec2 innerDims) { + vec2 modCoord = mod(innerDims, 2.); + return modCoord.x == 0. ? + (modCoord.y == 0. ? frag.r : frag.g) : + (modCoord.y == 0. ? frag.b : frag.a); + } + `}},2870:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parsePadAttributesV11=r.padV11=r.parsePadAttributesV2=r.padV2=void 0;const d=c(246),l=c(2517),m=c(5060),s=c(2039),h={name:"Pad",inputNames:["A"],inputTypes:[s.TextureType.unpacked]};r.padV2=(g,b,y)=>(o(b),[g.run(Object.assign(Object.assign({},h),{cacheHint:y.cacheKey,get:()=>a(g,b[0],y)}),b)]),r.parsePadAttributesV2=g=>{const b=g.attributes.getString("mode","constant"),y=g.attributes.getFloat("value",0),_=g.attributes.getInts("pads");return(0,d.createAttributeWithCacheKey)({mode:b,value:y,pads:_})},r.padV11=(g,b,y)=>{t(b);const _=p(g,b,y);return(0,r.padV2)(g,[b[0]],_)},r.parsePadAttributesV11=g=>g.attributes.getString("mode","constant");const p=(g,b,y)=>{if(!g.session.isInitializer(b[1].dataId)||b.length>=3&&!g.session.isInitializer(b[2].dataId))throw new Error("dynamic pad attributes are not allowed");const _=Array.from(b[1].integerData),v=b.length>=3?b[2].floatData[0]:0;return(0,d.createAttributeWithCacheKey)({mode:y,pads:_,value:v})},a=(g,b,y)=>{const _=l.ShapeUtil.padShape(b.dims.slice(),y.pads),v=_.length,w=` + ${e(g,b,y)} + float process(int[${v}] indices) { + return padA(indices); + }`;return{name:"Pad",inputNames:["A"],inputTypes:[s.TextureType.unpacked],output:{dims:_,type:b.type,textureType:s.TextureType.unpacked},shaderSource:w}},o=g=>{if(!g||g.length!==1)throw new Error("Pad requires 1 input");if(g[0].type!=="float32"&&g[0].type!=="float64")throw new Error("Invalid input type.")},t=g=>{if(!g||g.length!==2&&g.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(g[1].type!=="int32")throw new Error("Invalid input type.");if(g.length>=3&&g[2].type==="string")throw new Error("Invalid input type.")},e=(g,b,y)=>{const _=(0,m.getGlsl)(g.session.backend.glContext.version),[v,w]=g.calculateTextureWidthAndHeight(b.dims,s.TextureType.unpacked),T=l.ShapeUtil.computeStrides(b.dims);switch(y.mode){case"constant":return n(_,b.dims,T,v,w,y.pads,y.value);case"reflect":return i(_,b.dims,T,v,w,y.pads);case"edge":return u(_,b.dims,T,v,w,y.pads);default:throw new Error("Invalid mode")}},n=(g,b,y,_,v,w,T)=>{const A=b.length;let E="";for(let x=A-1;x>=0;--x)E+=` + k = m[${x}] - ${w[x]}; + if (k < 0) return constant; + if (k >= ${b[x]}) return constant; + offset += k * ${y[x]}; + `;return` + float padA(int m[${A}]) { + const float constant = float(${T}); + int offset = 0; + int k = 0; + ${E} + vec2 coords = offsetToCoords(offset, ${_}, ${v}); + float value = getColorAsFloat(${g.texture2D}(A, coords)); + return value; + } + `},i=(g,b,y,_,v,w)=>{const T=b.length;let A="";for(let E=T-1;E>=0;--E)A+=` + k = m[${E}] - ${w[E]}; + if (k < 0) { k = -k; } + { + const int _2n_1 = ${2*(b[E]-1)}; + k = int( mod( float(k), float(_2n_1) ) ) ; + if(k >= ${b[E]}) { k = _2n_1 - k; } + } + offset += k * ${y[E]}; + `;return` + float padA(int m[${T}]) { + int offset = 0; + int k = 0; + ${A} + vec2 coords = offsetToCoords(offset, ${_}, ${v}); + float value = getColorAsFloat(${g.texture2D}(A, coords)); + return value; + } + `},u=(g,b,y,_,v,w)=>{const T=b.length;let A="";for(let E=T-1;E>=0;--E)A+=` + k = m[${E}] - ${w[E]}; + if (k < 0) k = 0; + if (k >= ${b[E]}) k = ${b[E]-1}; + offset += k * ${y[E]}; + `;return` + float padA(int m[${T}]) { + int offset = 0; + int k = 0; + ${A} + vec2 coords = offsetToCoords(offset, ${_}, ${v}); + float value = getColorAsFloat(${g.texture2D}(A, coords)); + return value; + } + `}},2143:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.globalMaxPool=r.parseMaxPoolAttributes=r.maxPool=r.parseGlobalAveragePoolAttributes=r.globalAveragePool=r.parseAveragePoolAttributes=r.averagePool=void 0;const d=c(246),l=c(2517),m=c(2039);r.averagePool=(u,g,b)=>{t(g);const y={name:"AveragePool",inputNames:["X"],inputTypes:[m.TextureType.unpacked],cacheHint:b.cacheKey};return[u.run(Object.assign(Object.assign({},y),{get:()=>s(g,y,!1,b)}),g)]},r.parseAveragePoolAttributes=u=>{const g=u.attributes.getString("auto_pad","NOTSET"),b=u.attributes.getInt("ceil_mode",0),y=u.attributes.getInt("count_include_pad",0)!==0,_=u.attributes.getInts("kernel_shape"),v=u.attributes.getInts("strides",[]),w=u.attributes.getInts("pads",[]);if(b!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,d.createAttributeWithCacheKey)({autoPad:g,ceilMode:b,countIncludePad:y,kernelShape:_,strides:v,pads:w})};const s=(u,g,b,y)=>{const[_,v]=p(u,y,b),w=l.ShapeUtil.size(_.kernelShape);let T="";_.countIncludePad?T+=`value /= float(${w});`:T+=`value /= float(${w} - pad);`;const A=` + ${e(u[0].dims,_,"value += _X(x);",T,"0.0")} + `;return Object.assign(Object.assign({},g),{output:{dims:v,type:u[0].type,textureType:m.TextureType.unpacked},shaderSource:A})};r.globalAveragePool=(u,g,b)=>{t(g);const y={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[m.TextureType.unpacked],cacheHint:`${b.countIncludePad}`};return[u.run(Object.assign(Object.assign({},y),{get:()=>s(g,y,!0,b)}),g)]},r.parseGlobalAveragePoolAttributes=u=>{const g=u.attributes.getInt("count_include_pad",0)!==0;return(0,d.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:g,kernelShape:[],strides:[],pads:[]})},r.maxPool=(u,g,b)=>{t(g);const y={name:"MaxPool",inputNames:["X"],inputTypes:[m.TextureType.unpacked],cacheHint:b.cacheKey};return[u.run(Object.assign(Object.assign({},y),{get:()=>h(g,y,!1,b)}),g)]},r.parseMaxPoolAttributes=u=>{const g=u.attributes.getString("auto_pad","NOTSET"),b=u.attributes.getInt("ceil_mode",0),y=u.attributes.getInts("kernel_shape"),_=u.attributes.getInts("strides",[]),v=u.attributes.getInts("pads",[]),w=u.attributes.getInt("storage_order",0),T=u.attributes.getInts("dilations",[]);if(w!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(b!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,d.createAttributeWithCacheKey)({autoPad:g,ceilMode:b,countIncludePad:!1,kernelShape:y,strides:_,pads:v,storageOrder:w,dilations:T})};const h=(u,g,b,y)=>{const[_,v]=p(u,y,b),w=` + ${e(u[0].dims,_,` + value = max(_X(x), value); + `,"","-1e5")} + `;return Object.assign(Object.assign({},g),{output:{dims:v,type:u[0].type,textureType:m.TextureType.unpacked},shaderSource:w})},p=(u,g,b)=>{const y=u[0].dims.slice(),_=Object.hasOwnProperty.call(g,"dilations"),v=g.kernelShape.slice(),w=g.strides.slice(),T=_?g.dilations.slice():[],A=g.pads.slice();l.PoolConvUtil.adjustPoolAttributes(b,y,v,w,T,A);const E=l.PoolConvUtil.computePoolOutputShape(b,y,w,T,v,A,g.autoPad),x=Object.assign({},g);return _?Object.assign(x,{kernelShape:v,strides:w,pads:A,dilations:T,cacheKey:g.cacheKey}):Object.assign(x,{kernelShape:v,strides:w,pads:A,cacheKey:g.cacheKey}),[x,E]},a={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},o={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[m.TextureType.unpacked]};r.globalMaxPool=(u,g)=>(t(g),[u.run(Object.assign(Object.assign({},o),{get:()=>h(g,o,!0,a)}),g)]);const t=u=>{if(!u||u.length!==1)throw new Error("Pool ops requires 1 input.");if(u[0].type!=="float32"&&u[0].type!=="float64")throw new Error("Invalid input type.")},e=(u,g,b,y,_)=>{const v=u.length;if(g.kernelShape.length<=2){const w=g.kernelShape[g.kernelShape.length-1],T=g.strides[g.strides.length-1],A=g.pads[g.pads.length/2-1],E=g.pads[g.pads.length-1],x=u[v-1];let P="",L="",F="";if(P=A+E!==0?` + for (int i = 0; i < ${w}; i++) { + x[${v} - 1] = indices[${v} - 1] * ${T} - ${A} + i; + if (x[${v} - 1] < 0 || x[${v} - 1] >= ${x}) { + pad++; + continue; + } + ${b} + }`:` + for (int i = 0; i < ${w}; i++) { + x[${v} - 1] = indices[${v} - 1] * ${T} - ${A} + i; + ${b} + }`,g.kernelShape.length===2){const $=g.kernelShape[g.kernelShape.length-2],k=g.strides[g.strides.length-2],q=g.pads[g.pads.length/2-2],D=g.pads[g.pads.length-2],U=u[v-2];L=q+D!==0?` + for (int j = 0; j < ${$}; j++) { + x[${v} - 2] = indices[${v} - 2] * ${k} - ${q} + j; + if (x[${v} - 2] < 0 || x[${v} - 2] >= ${U}) { + pad+= ${w}; + continue; + } + `:` + for (int j = 0; j < ${$}; j++) { + x[${v} - 2] = indices[${v} - 2] * ${k} - ${q} + j; + `,F=` + } + `}return` + float process(int indices[${v}]) { + int x[${v}]; + copyVec(indices, x); + + float value = ${_}; + int pad = 0; + ${L} + ${P} + ${F} + ${y} + return value; + } + `}{const w=l.ShapeUtil.size(g.kernelShape),T=l.ShapeUtil.computeStrides(g.kernelShape),A=T.length,E=g.pads.length,x=i(A),P=n(u,"inputDims"),L=n(g.pads,"pads"),F=n(T,"kernelStrides"),$=n(g.strides,"strides");let k="";return k=g.pads.reduce((q,D)=>q+D)?` + if (x[j] >= inputDims[j] || x[j] < 0) { + pad++; + isPad = true; + break; + } + } + if (!isPad) { + ${b} + }`:` + } + ${b} + `,` + ${x} + float process(int indices[${v}]) { + int x[${v}]; + copyVec(indices, x); + int offset[${A}]; + int pads[${E}]; + int inputDims[${v}]; + int kernelStrides[${A}]; + int strides[${A}]; + ${L} + ${P} + ${$} + ${F} + + float value = ${_}; + int pad = 0; + bool isPad = false; + for (int i = 0; i < ${w}; i++) { + offsetToIndices(i, kernelStrides, offset); + isPad = false; + for (int j = ${v} - ${A}; j < ${v}; j++) { + x[j] = indices[j] * strides[j - ${v} + ${A}] + + offset[j - ${v} + ${A}] - pads[j - 2]; + ${k} + } + ${y} + + return value; + } + `}},n=(u,g)=>{let b="";for(let y=0;y` + void offsetToIndices(int offset, int[${u}] strides, out int[${u}] indices) { + if (${u} == 0) { + return; + } + for (int i = 0; i < ${u} - 1; ++i) { + indices[i] = offset / strides[i]; + offset -= indices[i] * strides[i]; + } + indices[${u} - 1] = offset; + }`},4939:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.reduceLogSumSquare=r.reduceLogSum=r.reduceProd=r.reduceMin=r.reduceMax=r.reduceMean=r.reduceSum=r.parseReduceAttributes=void 0;const d=c(246),l=c(782),m=c(2517),s=c(2039),h=(o,t,e,n,i)=>{a(t);const u={name:n,inputNames:["A"],inputTypes:[s.TextureType.unpacked]};return[o.run(Object.assign(Object.assign({},u),{cacheHint:e.cacheKey,get:()=>p(o,t,e,n,i,u)}),t)]};r.parseReduceAttributes=o=>{const t=o.attributes.getInts("axes",[]),e=o.attributes.getInt("keepdims",1)===1;return(0,d.createAttributeWithCacheKey)({axes:t,keepDims:e})};const p=(o,t,e,n,i,u)=>{const g=[],b=t[0].dims.length||1,y=[],_=m.ShapeUtil.normalizeAxes(e.axes,t[0].dims.length),v=i(t,_);let w=v[1];for(let A=0;A=0||_.length===0?(e.keepDims&&g.push(1),w=` + for(int j${A} = 0; j${A} < ${t[0].dims[A]}; j${A}++) { + inputIdx[${A}] = j${A}; + ${w} + }`):(y.push(`inputIdx[${A}] = outputIdx[${g.length}];`),g.push(t[0].dims[A]));const T=` + float process(int outputIdx[${g.length||1}]) { + float value; // final result + int inputIdx[${b}]; // addressing input data + ${y.join(` +`)} + ${v[0]} // init ops for reduce max/min + ${w} + ${v[2]} // final computation for reduce mean + return value; + }`;return Object.assign(Object.assign({},u),{output:{dims:g,type:t[0].type,textureType:s.TextureType.unpacked},shaderSource:T})},a=o=>{if(!o||o.length!==1)throw new Error("Reduce op requires 1 input.");if(l.NUMBER_TYPES.indexOf(o[0].type)===-1)throw new Error("Invalid input type.")};r.reduceSum=(o,t,e)=>h(o,t,e,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),r.reduceMean=(o,t,e)=>h(o,t,e,"ReduceMean",(n,i)=>{let u=1;for(let g=0;g=0||i.length===0)&&(u*=n[0].dims[g]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${u}.;`]}),r.reduceMax=(o,t,e)=>h(o,t,e,"ReduceMax",(n,i)=>{const u=[];for(let g=0;g=0||i.length===0)&&u.push(`inputIdx[${g}] = 0;`);return[`${u.join(` +`)} +value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),r.reduceMin=(o,t,e)=>h(o,t,e,"ReduceMin",(n,i)=>{const u=[];for(let g=0;g=0||i.length===0)&&u.push(`inputIdx[${g}] = 0;`);return[`${u.join(` +`)} +value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),r.reduceProd=(o,t,e)=>h(o,t,e,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),r.reduceLogSum=(o,t,e)=>h(o,t,e,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),r.reduceLogSumSquare=(o,t,e)=>h(o,t,e,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])},7019:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isReshapeCheap=r.processDims3D=r.createPackedReshape3DProgramInfoLoader=void 0;const d=c(2517),l=c(5060),m=c(2039),s=c(2827);r.createPackedReshape3DProgramInfoLoader=(h,p,a)=>{const o=(t=>({name:"Reshape (packed)",inputTypes:[m.TextureType.packed],inputNames:["A"],cacheHint:`${t}`}))(a);return Object.assign(Object.assign({},o),{get:()=>((t,e,n,i)=>{const u=e.dims,g=i;let b="";for(let v=0;v<4;v++){let w="";switch(v){case 0:w="outputCoords = rc;";break;case 1:w="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:w="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:w="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}b+=` + ${w} + ${v>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""} + int flattenedIndex = getFlattenedIndex(outputCoords); + + ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex); + vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z)); + + result[${v}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims); + + ${v>0?"}":""} + `}const y=(0,l.getGlsl)(t.session.backend.glContext.version),_=` + ${function(v){const w=d.ShapeUtil.computeStrides(v),T=["b","r","c"],A="index";return` + ivec3 inputCoordsFromReshapedOutCoords(int index) { + ${w.map((E,x)=>`int ${T[x]} = ${A} / ${E}; ${x===w.length-1?`int ${T[x+1]} = ${A} - ${T[x]} * ${E}`:`index -= ${T[x]} * ${E}`};`).join("")} + return ivec3(b, r, c); + } + `}(u)} + ${function(v){const w=d.ShapeUtil.computeStrides(v);return` + int getFlattenedIndex(ivec3 coords) { + // reverse y, z order + return coords.x * ${w[0]} + coords.z * ${w[1]} + coords.y; + } +`}(g)} + ${(0,s.unpackFromChannel)()} + + void main() { + ivec3 rc = getOutputCoords(); + + vec4 result = vec4(0.0); + + ivec3 outputCoords; + int rows = ${g[2]}; + int cols = ${g[1]}; + + ${b} + ${y.output} = result; + } + `;return Object.assign(Object.assign({},n),{output:{dims:g,type:e.type,textureType:m.TextureType.packed},shaderSource:_,hasMain:!0})})(h,p,o,a)})},r.processDims3D=function(h){if(h.length===0)return[1,1,1];let p=1;for(let a=0;a1?h[h.length-2]:1,h[h.length-1]]},r.isReshapeCheap=function(h,p){let a=!1;return a=h.length===0||p.length===0||(h.length<2||p.length<2?h[h.length-1]===p[p.length-1]:h[h.length-1]===p[p.length-1]&&h[h.length-2]===p[p.length-2]),a}},718:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.reshape=void 0;const d=c(2517);r.reshape=(l,m)=>{const s=d.ShapeUtil.calculateReshapedDims(m[0].dims,m[1].integerData);return l.session.pack?[l.reshapePacked(m[0],s)]:[l.reshapeUnpacked(m[0],s)]}},2268:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseResizeAttributesV11=r.parseResizeAttributesV10=r.resize=void 0;const d=c(5060),l=c(2039),m=c(9390),s=c(2827),h=c(9793),p={name:"Resize",inputNames:["A"],inputTypes:[l.TextureType.packed]};r.resize=(n,i,u)=>((0,h.validateInputs)(i,u),[n.run(Object.assign(Object.assign({},p),{cacheHint:u.cacheKey,get:()=>a(n,i,u)}),i)]),r.parseResizeAttributesV10=n=>(0,h.parseUpsampleAttributes)(n,10),r.parseResizeAttributesV11=n=>(0,h.parseUpsampleAttributes)(n,11);const a=(n,i,u)=>{const g=(0,d.getGlsl)(n.session.backend.glContext.version),[b,y]=o(i,u);if(b.every(k=>k===1)&&u.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},p),{output:{dims:y,type:i[0].type,textureType:l.TextureType.packed},hasMain:!0,shaderSource:`void main() { + vec4 v = ${g.texture2D}(X, TexCoords); + ${g.output} = v; + }`});const _=y.length;if(_<2)throw new Error(`output dimension should be at least 2, but got ${_}`);const v=y[_-2],w=y[_-1],T=i[0].dims;if(_!==T.length)throw new Error(`output dimension should match input ${T.length}, but got ${_}`);const A=T[_-2],E=T[_-1],x=b[_-2],P=b[_-1];let L="";if(u.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${u.mode}'`);switch(u.coordinateTransformMode){case"asymmetric":L=` + vec4 getSourceFracIndex(ivec4 coords) { + return vec4(coords) / scaleWHWH; + } + `;break;case"half_pixel":L=` + vec4 getSourceFracIndex(ivec4 coords) { + return (vec4(coords) + 0.5) / scaleWHWH - 0.5; + } + `;break;case"pytorch_half_pixel":L=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 fcoords = vec4(coords); + return vec4( + ${w}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, + ${v}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, + ${w}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, + ${v}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 + ); + } + `;break;case"align_corners":L=` + vec4 getSourceFracIndex(ivec4 coords) { + vec4 resized = vec4(${w}.0 - 1.0, ${v}.0 - 1.0, ${w}.0 - 1.0, + ${v}.0 - 1.0); + vec4 original = vec4(${E}.0 - 1.0, ${A}.0 - 1.0, ${E}.0 - 1.0, + ${A}.0 - 1.0); + vec4 new_scale = original / resized; + return vec4(coords) * new_scale; + } + `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${u.coordinateTransformMode}'`)}const F=(0,m.getCoordsDataType)(_),$=` + const vec2 inputWH = vec2(${A}.0, ${E}.0); + const vec4 scaleWHWH = vec4(float(${x}), float(${P}), float(${x}), float(${P})); + ${(0,s.unpackFromChannel)()} + ${L} + float getAValue(int x10, int r, int c, int d) { + return getChannel(getA(x10, r, c, d), vec2(c, d)); + } + void main() { + ${F} rc = getOutputCoords(); + + int batch = rc[0]; + int depth = rc[1]; + + // retrieve the 4 coordinates that is used in the 4 packed output values. + ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1); + + // calculate the source index in fraction + vec4 sourceFrac = getSourceFracIndex(coords); + + // get the lower and upper bound of the 4 values that will be packed into one texel. + ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy))); + ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw))); + ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy))); + ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw))); + + bool hasNextRow = rc.w < ${v-1}; + bool hasNextCol = rc.z < ${w-1}; + + // pack x00, x01, x10, x11's top-left corner into one vec4 structure + vec4 topLeft = vec4( + getAValue(batch, depth, x00.x, x00.y), + hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0); + + // pack x00, x01, x10, x11's top-right corner into one vec4 structure + vec4 topRight = vec4( + getAValue(batch, depth, x00.x, x00.w), + hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0); + + // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure + vec4 bottomLeft = vec4( + getAValue(batch, depth, x00.z, x00.y), + hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0); + + // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure + vec4 bottomRight = vec4( + getAValue(batch, depth, x00.z, x00.w), + hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0, + hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0, + (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0); + + // calculate the interpolation fraction on u and v direction + vec4 frac = vec4(sourceFrac) - floor(sourceFrac); + vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0)); + + vec4 top = mix(topLeft, topRight, clampFrac.ywyw); + vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw); + vec4 newValue = mix(top, bottom, clampFrac.xxzz); + + ${g.output} = vec4(newValue); + } + `;return Object.assign(Object.assign({},p),{output:{dims:y,type:i[0].type,textureType:l.TextureType.packed},hasMain:!0,shaderSource:$})},o=(n,i)=>{const u=n[0].dims;let g,b=i.scales;if(b.length===0){const _=n[i.scalesInputIdx];if(_&&_.size!==0){if(n[i.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");b=t(_,i.mode,i.isResize)}else{const v=n[i.sizesInputIdx];if(!v||v.size===0)throw new Error("Either scales or sizes MUST be provided as input.");g=Array.from(v.integerData),b=e(g,u,i.mode,i.isResize)}}else if(n[i.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const y=g||u.map((_,v)=>Math.floor(_*b[v]));return[b,y]},t=(n,i,u)=>{const g=Array.from(n.floatData);return(0,h.scalesValidation)(g,i,u),g},e=(n,i,u,g)=>{const b=i.length,y=new Array(b);for(let _=0,v=b;_{Object.defineProperty(r,"__esModule",{value:!0}),r.shape=void 0;const d=c(9162);r.shape=(m,s)=>(l(s),[new d.Tensor([s[0].dims.length],"int32",void 0,void 0,new Int32Array(s[0].dims))]);const l=m=>{if(!m||m.length!==1)throw new Error("Shape requires 1 input.")}},2278:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.sliceV10=r.parseSliceAttributes=r.slice=void 0;const d=c(246),l=c(782),m=c(2517),s=c(2039),h={name:"Slice",inputNames:["A"],inputTypes:[s.TextureType.unpacked]};r.slice=(e,n,i)=>(a(n),[e.run(Object.assign(Object.assign({},h),{cacheHint:i.cacheKey,get:()=>p(e,n[0],i)}),n)]),r.parseSliceAttributes=e=>{const n=e.attributes.getInts("starts"),i=e.attributes.getInts("ends"),u=e.attributes.getInts("axes",[]);return(0,d.createAttributeWithCacheKey)({starts:n,ends:i,axes:u})};const p=(e,n,i)=>{const u=i.axes.length===0?n.dims.slice(0).map((T,A)=>A):i.axes,g=m.ShapeUtil.normalizeAxes(u,n.dims.length),b=i.starts.map((T,A)=>T>n.dims[g[A]]-1?n.dims[g[A]]:m.ShapeUtil.normalizeAxis(T,n.dims[g[A]])),y=i.ends.map((T,A)=>T>n.dims[g[A]]-1?n.dims[g[A]]:m.ShapeUtil.normalizeAxis(T,n.dims[g[A]])),_=n.dims.slice(),v=[];for(let T=0;T0&&v.push(`outputIdx[${g[T]}] += ${b[T]};`);const w=` + float process(int outputIdx[${_.length}]) { + ${v.join(` + `)} + return _A(outputIdx); + }`;return Object.assign(Object.assign({},h),{output:{dims:_,type:n.type,textureType:s.TextureType.unpacked},shaderSource:w})},a=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(l.NUMBER_TYPES.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")};r.sliceV10=(e,n)=>{t(n);const i=o(e,n);return[e.run(Object.assign(Object.assign({},h),{cacheHint:i.cacheKey,get:()=>p(e,n[0],i)}),[n[0]])]};const o=(e,n)=>{if(!e.session.isInitializer(n[1].dataId)||!e.session.isInitializer(n[2].dataId)||n.length>=4&&!e.session.isInitializer(n[3].dataId)||n.length>=5&&!e.session.isInitializer(n[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(n.length>=5&&n[4].integerData.some(b=>b!==1))throw new Error("currently non-1 steps is not supported for Slice");const i=Array.from(n[1].integerData),u=Array.from(n[2].integerData),g=n.length>=4?Array.from(n[3].integerData):[];return{starts:i,ends:u,axes:g,cacheKey:`${g};${i};${u}`}},t=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if(e[1].type!=="int32"||e[1].dims.length!==1)throw new Error("Invalid input type.");if(e[2].type!=="int32"||e[2].dims.length!==1)throw new Error("Invalid input type.");if(e.length>=4&&(e[3].type!=="int32"||e[3].dims.length!==1))throw new Error("Invalid input type.");if(e.length>=5&&(e[4].type!=="int32"||e[4].dims.length!==1))throw new Error("Invalid input type.")}},5524:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.softmaxV13=r.parseSoftmaxAttributesV13=r.parseSoftmaxAttributes=r.softmax=void 0;const d=c(246),l=c(2517),m=c(5060),s=c(2039),h=c(3738),p={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[s.TextureType.unpacked]},a={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[s.TextureType.unpacked,s.TextureType.unpacked]},o={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[s.TextureType.unpacked,s.TextureType.unpacked,s.TextureType.unpacked]};r.softmax=(g,b,y)=>{u(b);const _=b[0].dims.slice(),v=l.ShapeUtil.normalizeAxis(y.axis,_.length),w=l.ShapeUtil.sizeToDimension(_,v),T=l.ShapeUtil.sizeFromDimension(_,v);return t(g,b,y,w,T)},r.parseSoftmaxAttributes=g=>(0,d.createAttributeWithCacheKey)({axis:g.attributes.getInt("axis",1)}),r.parseSoftmaxAttributesV13=g=>(0,d.createAttributeWithCacheKey)({axis:g.attributes.getInt("axis",-1)}),r.softmaxV13=(g,b,y)=>{u(b);const _=b[0].dims.slice(),v=l.ShapeUtil.normalizeAxis(y.axis,_.length),w=_.length,T=v!==w-1,A=[];let E,x=[],P=[];T&&(x=Array.from({length:w}).map((k,q)=>q),x[v]=w-1,x[w-1]=v,x.map(k=>A.push(_[k])),E=(0,d.createAttributeWithCacheKey)({perm:x}),P=(0,h.transpose)(g,b,E));const L=T?l.ShapeUtil.sizeToDimension(A,w-1):l.ShapeUtil.sizeToDimension(_,w-1),F=T?l.ShapeUtil.sizeFromDimension(A,w-1):l.ShapeUtil.sizeFromDimension(_,w-1),$=t(g,T?P:b,y,L,F);return T?(0,h.transpose)(g,$,E):$};const t=(g,b,y,_,v)=>{const w=e(g,b[0],_,v,[_]),T=g.run(Object.assign(Object.assign({},p),{cacheHint:y.cacheKey,get:()=>w}),b),A=n(g,b[0],_,v,w.output.dims,[_]),E=g.run(Object.assign(Object.assign({},a),{cacheHint:y.cacheKey,get:()=>A}),[b[0],T]),x=i(g,b[0],_,v,w.output.dims,A.output.dims);return[g.run(Object.assign(Object.assign({},o),{cacheHint:y.cacheKey,get:()=>x}),[b[0],T,E])]},e=(g,b,y,_,v)=>{const[w,T]=g.calculateTextureWidthAndHeight(b.dims,s.TextureType.unpacked),A=v.length;if(y<1||_<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(v.length!==1)throw new Error("Dimensionality of the output should be 1");if(v[0]!==y)throw new Error("Shape of the output should be equal to logical row count");const E=(0,m.getGlsl)(g.session.backend.glContext.version),x=` + float process(int[${A}] indices) { + int logical_row_start_offset = indices[0] * ${_}; + + float max = getColorAsFloat(${E.texture2D}(A, offsetToCoords(logical_row_start_offset, ${w}, + ${T} ))); + for(int i=1; i<${_}; ++i) + { + float current = getColorAsFloat(${E.texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${w}, ${T}))); + if(current > max) + max = current; + } + + return max; + }`;return Object.assign(Object.assign({},p),{output:{dims:v,type:b.type,textureType:s.TextureType.unpacked},shaderSource:x})},n=(g,b,y,_,v,w)=>{const[T,A]=g.calculateTextureWidthAndHeight(b.dims,s.TextureType.unpacked),E=w.length;if(y<1||_<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(w.length!==1)throw new Error("Dimensionality of the output should be 1");if(w[0]!==y)throw new Error("Shape of the output should be equal to logical row count");if(v.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(v[0]!==y)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` + float process(int[${E}] indices) { + int logical_row_start_offset = indices[0] * ${_}; + + float norm_factor = 0.0; + float max = _Max(indices); + for(int i=0; i<${_}; ++i) + { + norm_factor += exp(getColorAsFloat(${(0,m.getGlsl)(g.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i, + ${T}, ${A}))) - max); + } + + return norm_factor; + }`;return Object.assign(Object.assign({},a),{output:{dims:w,type:b.type,textureType:s.TextureType.unpacked},shaderSource:x})},i=(g,b,y,_,v,w)=>{const[T,A]=g.calculateTextureWidthAndHeight(b.dims,s.TextureType.unpacked),E=b.dims.length;if(y<1||_<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(v.length!==1||w.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(v[0]!==y||w[0]!==y)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` + float process(int[${E}] indices) { + + // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords) + int offset = coordsToOffset(TexCoords, ${T}, ${A}); + + //determine the logical row for this index + int logical_row_index[1]; + logical_row_index[0] = offset / ${_}; + + float norm_factor = _Norm(logical_row_index); + + // avoid possible division by 0 + // if norm_facor is 0, all elements are zero + // if so, return 0 + if(norm_factor == 0.0) + return 0.0; + + return exp(_A(indices) - _Max(logical_row_index)) / norm_factor; + }`;return Object.assign(Object.assign({},o),{output:{dims:b.dims,type:b.type,textureType:s.TextureType.unpacked},shaderSource:x})},u=g=>{if(!g||g.length!==1)throw new Error("Softmax requires 1 input.");if(g[0].type!=="float32"&&g[0].type!=="float64")throw new Error("Invalid input type")}},5975:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseSplitAttributes=r.split=void 0;const d=c(246),l=c(2517),m=c(2039),s={name:"Split",inputNames:["A"],inputTypes:[m.TextureType.unpacked]};r.split=(o,t,e)=>{a(t);const n=l.ShapeUtil.normalizeAxis(e.axis,t[0].dims.length),i=h(o,t,n,e),u=[];for(let g=0;gp(o,t[0],e,n,g)}),t));return u},r.parseSplitAttributes=o=>{const t=o.attributes.getInt("axis",0),e=o.attributes.getInts("split",[]),n=o.outputs.length;return(0,d.createAttributeWithCacheKey)({axis:t,split:e,numOutputs:n})};const h=(o,t,e,n)=>{const[,i]=l.SplitUtil.splitShape(t[0].dims,e,n.split,n.numOutputs);return i.length},p=(o,t,e,n,i)=>{const[u,g]=l.SplitUtil.splitShape(t.dims,n,e.split,e.numOutputs),b=g[i],y=u[i],_=` + float process(int indices[${y.length}]) { + indices[${n}] += ${b}; + return _A(indices); + } + `;return Object.assign(Object.assign({},s),{cacheHint:`${e.cacheKey}:${i}`,output:{dims:y,type:t.type,textureType:m.TextureType.unpacked},shaderSource:_})},a=o=>{if(!o||o.length!==1)throw new Error("Split requires one input.");if(o[0].type!=="int8"&&o[0].type!=="uint8"&&o[0].type!=="int16"&&o[0].type!=="uint16"&&o[0].type!=="int32"&&o[0].type!=="uint32"&&o[0].type!=="float32"&&o[0].type!=="float64"&&o[0].type!=="bool")throw new Error("Invalid input type.")}},3933:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseSqueezeAttributes=r.squeezeV13=r.squeeze=void 0;const d=c(2517);r.squeeze=(s,h,p)=>{l(h);const a=d.ShapeUtil.squeezeShape(h[0].dims,p);return[s.reshapeUnpacked(h[0],a)]},r.squeezeV13=(s,h)=>(m(h),(0,r.squeeze)(s,[h[0]],Array.from(h[1].integerData))),r.parseSqueezeAttributes=s=>s.attributes.getInts("axes");const l=s=>{if(!s||s.length!==1)throw new Error("Squeeze requires 1 input.");if(s[0].type==="string")throw new Error("invalid input tensor types.")},m=s=>{if(!s||s.length!==2)throw new Error("Squeeze requires 2 inputs.");if(s[1].type!=="int32")throw new Error("Invalid input type.")}},6558:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.sum=void 0;const d=c(5060),l=c(2039);r.sum=(h,p)=>{s(p);const a={name:"Sum",inputNames:p.map((o,t)=>`X${t}`),inputTypes:new Array(p.length).fill(l.TextureType.unpacked)};return[h.run(Object.assign(Object.assign({},a),{get:()=>m(h,p,a)}),p)]};const m=(h,p,a)=>{const o=(0,d.getGlsl)(h.session.backend.glContext.version),t=p[0].dims.slice(),e=` + void main() { + vec4 result = ${p.map((n,i)=>`${o.texture2D}(X${i},TexCoords)`).join(" + ")}; + ${o.output} = result; + } + `;return Object.assign(Object.assign({},a),{output:{dims:t,type:p[0].type,textureType:l.TextureType.unpacked},hasMain:!0,shaderSource:e})},s=h=>{if(!h||h.length===0)throw new Error("Sum requires inputs.");const p=h[0].dims.length;for(let a=1;a{Object.defineProperty(r,"__esModule",{value:!0}),r.tile=void 0;const d=c(782),l=c(2039);r.tile=(h,p)=>{s(p);const a={name:"Tile",inputNames:["A"],inputTypes:[l.TextureType.unpacked]};return[h.run(Object.assign(Object.assign({},a),{get:()=>m(h,p,a)}),p)]};const m=(h,p,a)=>{const o=p[0].dims.slice(),t=new Array(o.length),e=[];for(let u=0;u{if(!h||h.length!==2)throw new Error("Tile requires 2 input.");if(h[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(h[1].dims[0]!==h[0].dims.length)throw new Error("Invalid input shape.");if(d.NUMBER_TYPES.indexOf(h[0].type)===-1)throw new Error("Invalid input type.");if(h[1].type!=="int32"&&h[1].type!=="int16")throw new Error("Invalid repeat type.")}},3738:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseTransposeAttributes=r.transpose=void 0;const d=c(246),l=c(2517),m=c(2039),s={name:"Transpose",inputNames:["A"],inputTypes:[m.TextureType.unpacked]};r.transpose=(e,n,i)=>(t(n),[e.run(Object.assign(Object.assign({},s),{cacheHint:i.cacheKey,get:()=>h(e,n[0],i.perm)}),n)]),r.parseTransposeAttributes=e=>(0,d.createAttributeWithCacheKey)({perm:e.attributes.getInts("perm",[])});const h=(e,n,i)=>{const u=n.dims;i=p(u,i);const g=a(u,i),b=u.length,y=` + ${o("perm",i,b)} + float process(int indices[${b}]) { + int a[${b}]; + perm(a, indices); + return _A(a); + }`;return Object.assign(Object.assign({},s),{output:{dims:g,type:n.type,textureType:m.TextureType.unpacked},shaderSource:y})},p=(e,n)=>(n&&n.length!==e.length&&(n=[...e.keys()].reverse()),n),a=(e,n)=>(n=p(e,n),l.ShapeUtil.sortBasedOnPerm(e,n)),o=(e,n,i)=>{const u=[];u.push(`void ${e}(out int a[${i}], int src[${i}]) {`);for(let g=0;g{if(!e||e.length!==1)throw new Error("Transpose requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("input should be float tensor")}},8710:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.encodeAsUint8=void 0;const d=c(5060),l=c(2039);r.encodeAsUint8=(m,s)=>{const h=s.shape,p=(0,d.getGlsl)(m.session.backend.glContext.version),a=` + const float FLOAT_MAX = 1.70141184e38; + const float FLOAT_MIN = 1.17549435e-38; + + bool isNaN(float val) { + return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true; + } + + highp vec4 encodeAsUint8(highp float v) { + if (isNaN(v)) { + return vec4(255, 255, 255, 255); + } + + highp float av = abs(v); + + if(av < FLOAT_MIN) { + return vec4(0.0, 0.0, 0.0, 0.0); + } else if(v > FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; + } else if(v < -FLOAT_MAX) { + return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; + } + + highp vec4 c = vec4(0,0,0,0); + + highp float e = floor(log2(av)); + highp float m = exp2(fract(log2(av))) - 1.0; + + c[2] = floor(128.0 * m); + m -= c[2] / 128.0; + c[1] = floor(32768.0 * m); + m -= c[1] / 32768.0; + c[0] = floor(8388608.0 * m); + + highp float ebias = e + 127.0; + c[3] = floor(ebias / 2.0); + ebias -= c[3] * 2.0; + c[2] += floor(ebias) * 128.0; + + c[3] += 128.0 * step(0.0, -v); + + return c / 255.0; + } + + void main() { + float value = ${p.texture2D}(X,TexCoords).r; + ${p.output} = encodeAsUint8(value); + }`,o={name:"Uint8Encode",inputTypes:[l.TextureType.unpacked],inputNames:["X"],output:{dims:h,type:s.tensor.type,textureType:l.TextureType.downloadUint8AsFloat},shaderSource:a,hasMain:!0};return m.executeProgram(o,[s.tensor])}},4909:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tanh=r.tan=r.sqrt=r.sin=r.sigmoid=r.relu=r.not=r.neg=r.log=r.parseLeakyReluAttributes=r.leakyRelu=r.identity=r.floor=r.exp=r.parseEluAttributes=r.elu=r.cos=r.ceil=r.clipV11=r.parseClipAttributes=r.clip=r.atan=r.asin=r.acos=r.abs=r.glslTanh=r.glslTan=r.glslSqrt=r.glslSigmoid=r.glslRelu=r.glslSin=r.glslNot=r.glslNeg=r.glslLog=r.glslLeakyRelu=r.glslIdentity=r.glslClip=r.glslFloor=r.glslExp=r.glslElu=r.glslCos=r.glslCeil=r.glslAtan=r.glslAsin=r.glslAcos=r.glslAbs=void 0;const d=c(246),l=c(2517),m=c(8520),s=c(5060),h=c(2039);function p(){return $("abs")}function a(){return $("acos")}function o(){return $("asin")}function t(){return $("atan")}function e(){return $("ceil")}function n(){return $("cos")}function i(D){const U="elu";return{body:` + const float alpha = float(${D}); + + float ${U}_(float a) { + return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; + } + vec4 ${U}_(vec4 v) { + return vec4(${U}_(v.x), ${U}_(v.y), ${U}_(v.z), ${U}_(v.w)); + } + `,name:U,type:m.FunctionType.ValueBased}}function u(){return $("exp")}function g(){return $("floor")}function b(D,U){const J="clip";return{body:` + const float min = float(${D}); + const float max = float(${U}); + + float ${J}_(float a) { + return clamp(a, min, max); + } + vec4 ${J}_(vec4 v) { + return clamp(v, min, max); + } + `,name:J,type:m.FunctionType.ValueBased}}function y(){const D="indentity";return{body:` + float ${D}_(float a) { + return a; + } + vec4 ${D}_(vec4 v) { + return v; + } + `,name:D,type:m.FunctionType.ValueBased}}function _(D){const U="leakyRelu";return{body:` + const float alpha = float(${D}); + + float ${U}_(float a) { + return a < 0.0 ? a * alpha : a; + } + vec4 ${U}_(vec4 v) { + return vec4(${U}_(v.x), ${U}_(v.y), ${U}_(v.z), ${U}_(v.w)); + } + `,name:U,type:m.FunctionType.ValueBased}}function v(){return $("log")}function w(){const D="neg";return{body:` + float ${D}_(float a) { + return -a; + } + vec4 ${D}_(vec4 v) { + return -v; + } + `,name:D,type:m.FunctionType.ValueBased}}function T(){const D="not";return{body:` + float ${D}_(float a) { + return float( ! bool(a) ); + } + bool ${D}_(bool a) { + return !a; + } + vec4 ${D}_(vec4 v) { + return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w)); + } + bvec4 ${D}_(bvec4 v) { + return bvec4(!v.x, !v.y, !v.z, !v.w); + } + `,name:D,type:m.FunctionType.ValueBased}}function A(){return $("sin")}function E(){const D="relu";return{body:` + float ${D}_(float a) { + return max( a, 0.0 ); + } + vec4 ${D}_(vec4 v) { + return max( v, 0.0 ); + } + `,name:D,type:m.FunctionType.ValueBased}}function x(){const D="sigmoid";return{body:` + float ${D}_(float a) { + return 1.0 / (1.0 + exp(-a)); + } + vec4 ${D}_(vec4 v) { + return 1.0 / (1.0 + exp(-v)); + } + `,name:D,type:m.FunctionType.ValueBased}}function P(){return $("sqrt")}function L(){return $("tan")}function F(){const D="tanh";return{body:` + float ${D}_(float a) { + a = clamp(a, -10., 10.); + a = exp(2.*a); + return (a - 1.) / (a + 1.); + } + vec4 ${D}_(vec4 v) { + v = clamp(v, -10., 10.); + v = exp(2.*v); + return (v - 1.) / (v + 1.); + } + `,name:D,type:m.FunctionType.ValueBased}}function $(D){return{body:` + float ${D}_(float a) { + return ${D}(a); + } + vec4 ${D}_(vec4 v) { + return ${D}(v); + } + `,name:D,type:m.FunctionType.ValueBased}}r.glslAbs=p,r.glslAcos=a,r.glslAsin=o,r.glslAtan=t,r.glslCeil=e,r.glslCos=n,r.glslElu=i,r.glslExp=u,r.glslFloor=g,r.glslClip=b,r.glslIdentity=y,r.glslLeakyRelu=_,r.glslLog=v,r.glslNeg=w,r.glslNot=T,r.glslSin=A,r.glslRelu=E,r.glslSigmoid=x,r.glslSqrt=P,r.glslTan=L,r.glslTanh=F;const k=(D,U,J,Y)=>{const Z=D.session.pack?h.TextureType.packed:h.TextureType.unpacked,te={name:J.name,inputTypes:[Z],inputNames:["A"],cacheHint:Y};return Object.assign(Object.assign({},te),{get:()=>((he,Me,Te,ue)=>{const xe=he.session.pack?h.TextureType.packed:h.TextureType.unpacked,_e=(0,s.getGlsl)(he.session.backend.glContext.version);return Object.assign(Object.assign({},Me),{output:{dims:Te.dims,type:Te.type,textureType:xe},shaderSource:` + ${ue.body} + void main() { + vec4 v = ${_e.texture2D}(A, TexCoords); + v = ${ue.name}_(v); + ${_e.output} = v; + } + `,hasMain:!0})})(D,te,U,J)})};r.abs=(D,U)=>[D.run(k(D,U[0],p()),U)],r.acos=(D,U)=>[D.run(k(D,U[0],a()),U)],r.asin=(D,U)=>[D.run(k(D,U[0],o()),U)],r.atan=(D,U)=>[D.run(k(D,U[0],t()),U)],r.clip=(D,U,J)=>[D.run(k(D,U[0],b(J.min,J.max),J.cacheKey),U)],r.parseClipAttributes=D=>(0,d.createAttributeWithCacheKey)({min:D.attributes.getFloat("min",l.MIN_CLIP),max:D.attributes.getFloat("max",l.MAX_CLIP)}),r.clipV11=(D,U)=>{const J=q(D,U);return(0,r.clip)(D,[U[0]],J)};const q=(D,U)=>{if(U.length>=3&&(!D.session.isInitializer(U[1].dataId)||!D.session.isInitializer(U[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const J=U.length>=3?U[1].numberData[0]:l.MIN_CLIP,Y=U.length>=3?U[2].numberData[0]:l.MAX_CLIP;return(0,d.createAttributeWithCacheKey)({min:J,max:Y})};r.ceil=(D,U)=>[D.run(k(D,U[0],e()),U)],r.cos=(D,U)=>[D.run(k(D,U[0],n()),U)],r.elu=(D,U,J)=>[D.run(k(D,U[0],i(J.alpha),J.cacheKey),U)],r.parseEluAttributes=D=>(0,d.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",1)}),r.exp=(D,U)=>[D.run(k(D,U[0],u()),U)],r.floor=(D,U)=>[D.run(k(D,U[0],g()),U)],r.identity=(D,U)=>[D.run(k(D,U[0],y()),U)],r.leakyRelu=(D,U,J)=>[D.run(k(D,U[0],_(J.alpha),J.cacheKey),U)],r.parseLeakyReluAttributes=D=>(0,d.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",.01)}),r.log=(D,U)=>[D.run(k(D,U[0],v()),U)],r.neg=(D,U)=>[D.run(k(D,U[0],w()),U)],r.not=(D,U)=>[D.run(k(D,U[0],T()),U)],r.relu=(D,U)=>[D.run(k(D,U[0],E()),U)],r.sigmoid=(D,U)=>[D.run(k(D,U[0],x()),U)],r.sin=(D,U)=>[D.run(k(D,U[0],A()),U)],r.sqrt=(D,U)=>[D.run(k(D,U[0],P()),U)],r.tan=(D,U)=>[D.run(k(D,U[0],L()),U)],r.tanh=(D,U)=>[D.run(k(D,U[0],F()),U)]},5611:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createUnpackProgramInfoLoader=r.createUnpackProgramInfo=void 0;const d=c(5060),l=c(2039),m=c(9390),s=c(2827),h={name:"unpack",inputNames:["A"],inputTypes:[l.TextureType.packed]};r.createUnpackProgramInfo=(p,a)=>{const o=a.dims.length,t=(0,s.getChannels)("rc",o),e=t.slice(-2),n=(0,m.getCoordsDataType)(o),i=(0,s.unpackFromChannel)(),u=a.dims.length===0?"":function(y,_){if(y===1)return"rc";let v="";for(let w=0;wObject.assign(Object.assign({},h),{get:()=>(0,r.createUnpackProgramInfo)(p,a)})},8428:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseUnsqueezeAttributes=r.unsqueezeV13=r.unsqueeze=void 0;const d=c(2517);r.unsqueeze=(s,h,p)=>{l(h);const a=d.ShapeUtil.unsqueezeShape(h[0].dims,p);return[s.reshapeUnpacked(h[0],a)]},r.unsqueezeV13=(s,h)=>(m(h),(0,r.unsqueeze)(s,[h[0]],Array.from(h[1].integerData))),r.parseUnsqueezeAttributes=s=>s.attributes.getInts("axes");const l=s=>{if(!s||s.length!==1)throw new Error("Unsqueeze requires 1 input.");if(s[0].type==="string")throw new Error("invalid input tensor types.")},m=s=>{if(!s||s.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(s[1].type!=="int32")throw new Error("Invalid input type.")}},9793:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.scalesValidation=r.validateInputs=r.parseUpsampleAttributes=r.parseUpsampleAttributesV9=r.parseUpsampleAttributesV7=r.upsample=void 0;const d=c(246),l=c(5060),m=c(2039),s={name:"Upsample",inputNames:["X"],inputTypes:[m.TextureType.unpacked]};r.upsample=(p,a,o)=>((0,r.validateInputs)(a,o),[p.run(Object.assign(Object.assign({},s),{cacheHint:o.cacheKey,get:()=>h(p,a,o)}),a)]),r.parseUpsampleAttributesV7=p=>(0,r.parseUpsampleAttributes)(p,7),r.parseUpsampleAttributesV9=p=>(0,r.parseUpsampleAttributes)(p,9),r.parseUpsampleAttributes=(p,a)=>{const o=a>=10,t=p.attributes.getString("mode","nearest");if(t!=="nearest"&&t!=="linear"&&(a<11||t!=="cubic"))throw new Error(`unrecognized mode: ${t}`);let e=[];a<9&&(e=p.attributes.getFloats("scales"),(0,r.scalesValidation)(e,t,o));const n=p.attributes.getFloat("extrapolation_value",0),i=a>10?p.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(i)===-1)throw new Error(`coordinate_transform_mode '${i}' is not supported`);const u=i==="tf_crop_and_resize",g=u,b=t==="nearest"&&a>=11?p.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(b)===-1)throw new Error(`nearest_mode '${b}' is not supported`);const y=p.attributes.getFloat("cubic_coeff_a",-.75),_=p.attributes.getInt("exclude_outside",0)!==0;if(_&&t!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const v=a<11||t==="nearest"&&i==="asymmetric"&&b==="floor";let w=0,T=0,A=0;return a>10?p.inputs.length>2?(w=1,T=2,A=3):(T=1,A=2):a===9&&(T=1),(0,d.createAttributeWithCacheKey)({opset:a,isResize:o,mode:t,scales:e,extrapolationValue:n,coordinateTransformMode:i,useExtrapolation:g,needRoiInput:u,nearestMode:b,cubicCoefficientA:y,excludeOutside:_,useNearest2xOptimization:v,roiInputIdx:w,scalesInputIdx:T,sizesInputIdx:A})};const h=(p,a,o)=>{const t=(0,l.getGlsl)(p.session.backend.glContext.version),[e,n]=p.calculateTextureWidthAndHeight(a[0].dims,m.TextureType.unpacked),i=a[0].dims.map((A,E)=>Math.floor(A*o.scales[E])),[u,g]=p.calculateTextureWidthAndHeight(i,m.TextureType.unpacked),b=i.length,y=new Array(b),_=new Array(b);let v=` + int output_pitches[${b}]; + int input_pitches[${b}]; + `;for(let A=b-1;A>=0;A--)y[A]=A===b-1?1:y[A+1]*i[A+1],_[A]=A===b-1?1:_[A+1]*a[0].dims[A+1],v+=` + output_pitches[${A}] = ${y[A]}; + input_pitches[${A}] = ${_[A]}; + `;const w=` + float getInputFloat(int index) { + vec2 coords = offsetToCoords(index, ${e}, ${n}); + float value = getColorAsFloat(${t.texture2D}(X, coords)); + return value; + } + `,T=o.mode==="nearest"?` + ${w} + float process(int indices[${b}]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${u}, ${g}); + + ${v} + + int d, m; + for (int dim = 0; dim < ${b}; ++dim) { + d = output_index / output_pitches[dim]; + m = output_index - d * output_pitches[dim]; + output_index = m; + + if (scales[dim] != 1 && d > 0) { + int d2 = d / scales[dim]; + m = d - d2 * scales[dim]; + d = d2; + } + input_index += input_pitches[dim] * d; + } + + return getInputFloat(input_index); + }`:b===4?` + ${w} + float process(int indices[4]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${u}, ${g}); + + ${v} + + int m; + int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m / output_pitches[1]; + m = m - index_of_dim1 * output_pitches[1]; + index_of_dim2 = m / output_pitches[2]; + m = m - index_of_dim2 * output_pitches[2]; + index_of_dim3 = m; + + int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset; + index_of_input_dim2 = index_of_dim2 / scales[2]; + y_offset = index_of_dim2 - index_of_input_dim2 * scales[2]; + index_of_input_dim3 = index_of_dim3 / scales[3]; + x_offset = index_of_dim3 - index_of_input_dim3 * scales[3]; + + input_index = index_of_dim0 * input_pitches[0] + + index_of_dim1 * input_pitches[1] + + index_of_input_dim2 * input_pitches[2] + + index_of_input_dim3; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim2 = false; + if (index_of_input_dim2 == (${a[0].dims[2]} - 1)) { + // It's the end in dimension 2 + x01 = x00; + end_of_dim2 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[2]); + } + + if (index_of_input_dim3 == (input_pitches[2] - 1)) { + // It's the end in dimension 3 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[3]); + }`:` + ${w} + float process(int indices[2]) { + int input_index = 0; + int output_index = coordsToOffset(TexCoords, ${u}, ${g}); + + ${v} + + int m; + int index_of_dim0, index_of_dim1; + index_of_dim0 = output_index / output_pitches[0]; + m = output_index - index_of_dim0 * output_pitches[0]; + index_of_dim1 = m; + + int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset; + index_of_input_dim0 = index_of_dim0 / scales[0]; + y_offset = index_of_dim0 - index_of_input_dim0 * scales[0]; + index_of_input_dim1 = index_of_dim1 / scales[1]; + x_offset = index_of_dim1 - index_of_input_dim1 * scales[1]; + + input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1; + + float x00 = getInputFloat(input_index); + float x10, x01, x11; + + bool end_of_dim0 = false; + if (index_of_input_dim0 == (${a[0].dims[0]} - 1)) { + // It's the end in dimension 0 + x01 = x00; + end_of_dim0 = true; + } else { + x01 = getInputFloat(input_index + input_pitches[0]); + } + + if (index_of_input_dim1 == (input_pitches[0] - 1)) { + // It's the end in dimension 1 + x10 = x00; + x11 = x01; + } + else { + x10 = getInputFloat(input_index + 1); + x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1); + } + + float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]); + float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]); + return y0 + float(x_offset) * (y1 - y0) / float(scales[1]); + }`;return Object.assign(Object.assign({},s),{output:{dims:i,type:a[0].type,textureType:m.TextureType.unpacked},shaderSource:T,variables:[{name:"scales",type:"int",arrayLength:o.scales.length,data:o.scales.map(A=>Math.ceil(A))}]})};r.validateInputs=(p,a)=>{if(!p||a.opset<9&&p.length!==1||a.opset>=9&&a.opset<11&&p.length!==2||a.opset>=11&&p.length<2)throw new Error("invalid inputs.");if(a.scales.length>0&&p[0].dims.length!==a.scales.length)throw new Error("Invalid input shape.");if(p[0].type==="string")throw new Error("Invalid input tensor types.")},r.scalesValidation=(p,a,o)=>{if(o){for(const t of p)if(t<=0)throw new Error("Scale value should be greater than 0.")}else for(const t of p)if(t<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(a!=="linear"&&a!=="cubic"||p.length===2||p.length===4&&p[0]===1&&p[1]===1))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic') or 4-D inputs with the corresponding outermost 2 scale values being 1 in the ${o?"Resize":"Upsample"} opeartor.`)}},1958:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ProgramManager=void 0;const d=c(1670),l=c(6231),m=c(8879),s=c(5060);r.ProgramManager=class{constructor(h,p,a){this.profiler=h,this.glContext=p,this.textureLayoutStrategy=a,this.repo=new Map,this.attributesBound=!1}getArtifact(h){return this.repo.get(h)}setArtifact(h,p){this.repo.set(h,p)}run(h,p,a){var o;this.profiler.event("op",`ProgramManager.run ${(o=h.programInfo.name)!==null&&o!==void 0?o:"unknown kernel"}`,()=>{var t;const e=this.glContext.gl,n=h.program;e.useProgram(n);try{this.bindOutput(a),this.attributesBound||this.bindAttributes(h.attribLocations),this.bindUniforms(h.uniformLocations,(t=h.programInfo.variables)!==null&&t!==void 0?t:[],p)}catch(i){throw l.Logger.error("ProgramManager",h.programInfo.shaderSource),i}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(h=>this.glContext.deleteProgram(h.program))}build(h,p,a){return this.profiler.event("backend","ProgramManager.build",()=>{const o=new m.GlslPreprocessor(this.glContext,h,p,a),t=o.preprocess(),e=this.compile(t);return{programInfo:h,program:e,uniformLocations:this.getUniformLocations(e,o.context.programInfo.inputNames,o.context.programInfo.variables),attribLocations:this.getAttribLocations(e)}})}compile(h){if(!this.vertexShader){l.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const o=(0,s.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(o,this.glContext.gl.VERTEX_SHADER)}d.env.debug&&l.Logger.verbose("ProrgramManager",`FragShader: +${h} +`);const p=this.glContext.compileShader(h,this.glContext.gl.FRAGMENT_SHADER),a=this.glContext.createProgram(this.vertexShader,p);return this.glContext.deleteShader(p),a}bindOutput(h){const p=h.width,a=h.height;l.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${p}/${a}, shape=${h.shape}, type=${h.tensor.type}`),this.glContext.attachFramebuffer(h.texture,p,a)}bindAttributes(h){const p=h.position,a=h.textureCoord;this.glContext.setVertexAttributes(p,a),this.attributesBound=!0}bindUniforms(h,p,a){var o;const t=this.glContext.gl;let e=0;for(const{name:n,type:i,location:u,arrayLength:g}of h){const b=(o=p.find(y=>y.name===n))===null||o===void 0?void 0:o.data;if(i!=="sampler2D"&&!b)throw new Error(`variable '${n}' does not have data defined in program info`);switch(i){case"sampler2D":this.bindTexture(a[e],u,e),e++;break;case"float":g?t.uniform1fv(u,b):t.uniform1f(u,b);break;case"int":g?t.uniform1iv(u,b):t.uniform1i(u,b);break;default:throw new Error(`Uniform not implemented: ${i}`)}}}bindTexture(h,p,a){this.glContext.bindTextureToUniform(h.texture,a,p)}getAttribLocations(h){return{position:this.getAttribLocation(h,"position"),textureCoord:this.getAttribLocation(h,"textureCoord")}}getUniformLocations(h,p,a){const o=[];if(p)for(const t of p)o.push({name:t,type:"sampler2D",location:this.getUniformLocation(h,t)});if(a)for(const t of a)o.push(Object.assign(Object.assign({},t),{location:this.getUniformLocation(h,t.name)}));return o}getUniformLocation(h,p){const a=this.glContext.gl.getUniformLocation(h,p);if(a===null)throw new Error(`Uniform ${p} not found.`);return a}getAttribLocation(h,p){return this.glContext.gl.getAttribLocation(h,p)}}},6416:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WebGLSessionHandler=void 0;const d=c(6231),l=c(1047),m=c(8316),s=c(1640),h=c(1958),p=c(7859),a=c(5702);r.WebGLSessionHandler=class{constructor(o,t){this.backend=o,this.context=t,this.layoutStrategy=new p.PreferLogicalStrategy(o.glContext.maxTextureSize),this.programManager=new h.ProgramManager(this.context.profiler,o.glContext,this.layoutStrategy),this.textureManager=new a.TextureManager(o.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:o.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=o.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new m.WebGLInferenceHandler(this)}onGraphInitialized(o){const t=o.getValues().filter(e=>e.from===-1&&e.tensor).map(e=>e.tensor.dataId);this.initializers=new Set(t)}isInitializer(o){return!!this.initializers&&this.initializers.has(o)}addInitializer(o){this.initializers.add(o)}getTextureData(o,t){return t?this.packedTextureDataCache.get(o):this.unpackedTextureDataCache.get(o)}setTextureData(o,t,e=!1){d.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),e?this.packedTextureDataCache.set(o,t):this.unpackedTextureDataCache.set(o,t)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(o=>this.textureManager.releaseTexture(o,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(o=>this.textureManager.releaseTexture(o,!0)),this.unpackedTextureDataCache=new Map}resolve(o,t,e){const n=(0,l.resolveOperator)(o,t,s.WEBGL_OP_RESOLVE_RULES);return{impl:n.opImpl,context:n.opInit?n.opInit(o,e):o}}}},7769:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Uint8DataEncoder=r.RGBAFloatDataEncoder=r.RedFloat32DataEncoder=void 0;const d=c(6231);r.RedFloat32DataEncoder=class{constructor(l,m=1){if(m===1)this.internalFormat=l.R32F,this.format=l.RED,this.textureType=l.FLOAT,this.channelSize=m;else{if(m!==4)throw new Error(`Invalid number of channels: ${m}`);this.internalFormat=l.RGBA32F,this.format=l.RGBA,this.textureType=l.FLOAT,this.channelSize=m}}encode(l,m){let s,h;return l.constructor!==Float32Array&&(d.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),h=new Float32Array(l)),m*this.channelSize>l.length?(d.Logger.warning("Encoder","Source data too small. Allocating larger array"),h=l,s=this.allocate(m*this.channelSize),h.forEach((p,a)=>s[a]=p)):(h=l,s=h),s}allocate(l){return new Float32Array(4*l)}decode(l,m){return this.channelSize===1?l.filter((s,h)=>h%4==0).subarray(0,m):l.subarray(0,m)}},r.RGBAFloatDataEncoder=class{constructor(l,m=1,s){if(m!==1&&m!==4)throw new Error(`Invalid number of channels: ${m}`);this.internalFormat=l.RGBA,this.format=l.RGBA,this.channelSize=m,this.textureType=s||l.FLOAT}encode(l,m){let s=l;return this.channelSize===1&&(d.Logger.verbose("Encoder","Exploding into a larger array"),s=this.allocate(m),l.forEach((h,p)=>s[4*p]=h)),s}allocate(l){return new Float32Array(4*l)}decode(l,m){return this.channelSize===1?l.filter((s,h)=>h%4==0).subarray(0,m):l.subarray(0,m)}},r.Uint8DataEncoder=class{constructor(l,m=1){if(this.channelSize=4,m===1)this.internalFormat=l.ALPHA,this.format=l.ALPHA,this.textureType=l.UNSIGNED_BYTE,this.channelSize=m;else{if(m!==4)throw new Error(`Invalid number of channels: ${m}`);this.internalFormat=l.RGBA,this.format=l.RGBA,this.textureType=l.UNSIGNED_BYTE,this.channelSize=m}}encode(l,m){return new Uint8Array(l.buffer,l.byteOffset,l.byteLength)}allocate(l){return new Uint8Array(l*this.channelSize)}decode(l,m){if(l instanceof Uint8Array)return l.subarray(0,m);throw new Error(`Invalid array type: ${l.constructor}`)}}},7859:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getBatchDim=r.sizeToSquarishShape=r.getRowsCols=r.sizeFromShape=r.isInt=r.parseAxisParam=r.squeezeShape=r.PreferLogicalStrategy=r.AlwaysKeepOriginalSizeStrategy=void 0;const d=c(6231),l=c(2517);function m(o,t){const e=[],n=[],i=t!=null&&Array.isArray(t)&&t.length===0,u=t==null||i?null:s(t,o).sort();let g=0;for(let b=0;bb)&&o[b]===1&&(e.push(o[b]),n.push(b)),u[g]<=b&&g++}o[b]!==1&&(e.push(o[b]),n.push(b))}return{newShape:e,keptDims:n}}function s(o,t){const e=t.length;return o=o==null?t.map((n,i)=>i):[].concat(o),(0,l.assert)(o.every(n=>n>=-e&&n`All values in axis param must be in range [-${e}, ${e}) but got axis ${o}`),(0,l.assert)(o.every(h),()=>`All values in axis param must be integers but got axis ${o}`),o.map(n=>n<0?e+n:n)}function h(o){return o%1==0}function p(o){if(o.length===0)return 1;let t=o[0];for(let e=1;e=o.length?1:o.slice(t.breakAxis).reduce((b,y)=>b*y),g=t.breakAxis<=0?1:o.slice(0,t.breakAxis).reduce((b,y)=>b*y);if(!(u>e||g>e))return[u,g];d.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${o}, breakAxis:${t.breakAxis}`)}const n=o.reduce((u,g)=>u*g);let i=Math.floor(Math.sqrt(n));for(;i=e||n%i!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${o}`);return[i,n/i]}},r.PreferLogicalStrategy=class{constructor(o){this.maxTextureSize=o}computeTextureWH(o,t){const e=this.computeTexture(o,t);return t&&t.isPacked&&(e[0]/=2,e[1]/=2),t&&t.reverseWH?[e[1],e[0]]:e}computeTexture(o,t){const e=t&&t.isPacked;if(o.length===0)return e?[2,2]:[1,1];let n=this.maxTextureSize;if(t&&t.breakAxis!==void 0){const g=t.breakAxis>=o.length?1:o.slice(t.breakAxis).reduce((y,_)=>y*_),b=t.breakAxis<=0?1:o.slice(0,t.breakAxis).reduce((y,_)=>y*_);if(!(g>n||b>n))return[g,b];d.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${o}, breakAxis:${t.breakAxis}`)}let i=o.slice(0);e&&(n*=2,i=i.map((g,b)=>b>=i.length-2?i[b]%2==0?i[b]:i[b]+1:i[b]),i.length===1&&(i=[2,i[0]])),i.length!==2&&(i=m(i).newShape);const u=p(i);return i.length<=1&&u<=n?[1,u]:i.length===2&&i[0]<=n&&i[1]<=n?i:i.length===3&&i[0]*i[1]<=n&&i[2]<=n?[i[0]*i[1],i[2]]:i.length===3&&i[0]<=n&&i[1]*i[2]<=n?[i[0],i[1]*i[2]]:i.length===4&&i[0]*i[1]*i[2]<=n&&i[3]<=n?[i[0]*i[1]*i[2],i[3]]:i.length===4&&i[0]<=n&&i[1]*i[2]*i[3]<=n?[i[0],i[1]*i[2]*i[3]]:e?a(u/4).map(g=>2*g):a(u)}},r.squeezeShape=m,r.parseAxisParam=s,r.isInt=h,r.sizeFromShape=p,r.getRowsCols=function(o){if(o.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[o.length>1?o[o.length-2]:1,o[o.length-1]]},r.sizeToSquarishShape=a,r.getBatchDim=function(o,t=2){return p(o.slice(0,o.length-t))}},4057:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createTextureLayoutFromShape=r.calculateTextureWidthAndHeight=r.createTextureLayoutFromTextureType=void 0;const d=c(2517),l=c(2039);r.createTextureLayoutFromTextureType=(m,s,h)=>{const p=h===l.TextureType.unpacked||h===l.TextureType.unpackedReversed?1:4,a=h===l.TextureType.packed,o=h===l.TextureType.unpackedReversed||h===l.TextureType.packed,t=h===l.TextureType.packedLastDimension?s.length-1:void 0,e=h===l.TextureType.packedLastDimension?s.map((n,i)=>i===s.length-1?4*n:n):void 0;return(0,r.createTextureLayoutFromShape)(m,s,p,e,{isPacked:a,reverseWH:o,breakAxis:t})},r.calculateTextureWidthAndHeight=(m,s,h)=>{const p=(0,r.createTextureLayoutFromTextureType)(m,s,h);return[p.width,p.height]},r.createTextureLayoutFromShape=(m,s,h=1,p,a)=>{const o=!(!a||!a.isPacked),[t,e]=m.computeTextureWH(o&&p||s,a),n=s.length;let i=s.slice(0);if(n===0&&(i=[1]),h===1)p=s;else if(o){if(h!==4)throw new Error("a packed texture must be 4-channel");p=s,n>0&&(i[n-1]=Math.ceil(i[n-1]/2)),n>1&&(i[n-2]=Math.ceil(i[n-2]/2))}else if(!p)throw new Error("Unpacked shape is needed when using channels > 1");return{width:t,height:e,channels:h,isPacked:o,shape:i,strides:d.ShapeUtil.computeStrides(i),unpackedShape:p,reversedWH:a&&a.reverseWH}}},5702:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TextureManager=void 0;const d=c(6231);r.TextureManager=class{constructor(l,m,s,h){this.glContext=l,this.layoutStrategy=m,this.profiler=s,this.config=h,this.pendingRead=new Map,h.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(l,m,s,h){const p=this.toEncoderType(l),a=this.glContext.getEncoder(p,m.channels||1,h);if(m.isPacked&&h===1)throw new Error("not implemented");const o=m.width,t=m.height;let e,n;if(this.config.reuseTextures){e=`${o}x${t}_${a.format}_${a.internalFormat}_${a.textureType}`,n=this.inUseTextures.get(e),n||(n=[],this.inUseTextures.set(e,n));const u=this.idleTextures.get(e);if(u&&u.length>0){const g=u.pop();return n.push(g),h===1&&this.glContext.updateTexture(g,o,t,a,this.toTextureData(l,s)),g}}d.Logger.verbose("TextureManager",`Creating new texture of size ${m.width}x${m.height}`);const i=this.glContext.allocateTexture(o,t,a,this.toTextureData(l,s));return this.config.reuseTextures&&(n.push(i),this.textureLookup.set(i,e)),i}readTexture(l,m,s){return s||(s=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const h=l.shape.reduce((a,o)=>a*o)*s,p=this.glContext.readTexture(l.texture,l.width,l.height,h,this.toEncoderType(m),s);return this.toTensorData(m,p)})}async readTextureAsync(l,m,s){const h=l.tensor.dataId;if(s||(s=1),this.pendingRead.has(h)){const p=this.pendingRead.get(h);return new Promise(a=>p==null?void 0:p.push(a))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(h,[]);const p=l.shape.reduce((e,n)=>e*n)*s;await this.glContext.createAndWaitForFence();const a=this.glContext.readTexture(l.texture,l.width,l.height,p,this.toEncoderType(m),s),o=this.toTensorData(m,a),t=this.pendingRead.get(h);return this.pendingRead.delete(h),t==null||t.forEach(e=>e(o)),o})}readUint8TextureAsFloat(l){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const m=l.shape.reduce((h,p)=>h*p),s=this.glContext.readTexture(l.texture,l.width,l.height,4*m,"byte",4);return new Float32Array(s.buffer,s.byteOffset,m)})}releaseTexture(l,m){let s;if(this.config.reuseTextures&&(s=this.textureLookup.get(l.texture),s)){m&&this.textureLookup.delete(s);const h=this.inUseTextures.get(s);if(h){const p=h.indexOf(l.texture);if(p!==-1){h.splice(p,1);let a=this.idleTextures.get(s);a||(a=[],this.idleTextures.set(s,a)),a.push(l.texture)}}}s&&!m||(d.Logger.verbose("TextureManager",`Deleting texture of size ${l.width}x${l.height}`),this.glContext.deleteTexture(l.texture))}toTensorData(l,m){switch(l){case"int16":return m instanceof Int16Array?m:Int16Array.from(m);case"int32":return m instanceof Int32Array?m:Int32Array.from(m);case"int8":return m instanceof Int8Array?m:Int8Array.from(m);case"uint16":return m instanceof Uint16Array?m:Uint16Array.from(m);case"uint32":return m instanceof Uint32Array?m:Uint32Array.from(m);case"uint8":case"bool":return m instanceof Uint8Array?m:Uint8Array.from(m);case"float32":return m instanceof Float32Array?m:Float32Array.from(m);case"float64":return m instanceof Float64Array?m:Float64Array.from(m);default:throw new Error(`TensorData type ${l} is not supported`)}}toTextureData(l,m){if(m)return m instanceof Float32Array?m:new Float32Array(m)}toEncoderType(l){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},2039:(f,r)=>{var c;Object.defineProperty(r,"__esModule",{value:!0}),r.TextureType=void 0,(c=r.TextureType||(r.TextureType={}))[c.unpacked=0]="unpacked",c[c.unpackedReversed=1]="unpackedReversed",c[c.packed=2]="packed",c[c.downloadUint8AsFloat=3]="downloadUint8AsFloat",c[c.packedLastDimension=4]="packedLastDimension"},9390:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getGlChannels=r.getCoordsDataType=r.getSqueezedParams=r.squeezeInputShape=r.generateShaderFuncNameFromInputSamplerNameAtOutCoords=r.generateShaderFuncNameFromInputSamplerName=r.repeatedTry=r.getPackedShape=void 0;const d=c(2517);r.getPackedShape=function(l){const m=l.length;return l.slice(0,m-1).concat(l[m-1]/4)},r.repeatedTry=async function(l,m=h=>0,s){return new Promise((h,p)=>{let a=0;const o=()=>{if(l())return void h();a++;const t=m(a);s!=null&&a>=s?p():setTimeout(o,t)};o()})},r.generateShaderFuncNameFromInputSamplerName=function(l){return(0,d.assert)(l!==void 0&&l.length!==0,()=>"empty string found for sampler name"),"get"+l.charAt(0).toUpperCase()+l.slice(1)},r.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(l){return(0,d.assert)(l!==void 0&&l.length!==0,()=>"empty string found for sampler name"),"get"+l.charAt(0).toUpperCase()+l.slice(1)+"AtOutCoords"},r.squeezeInputShape=function(l,m){let s=JSON.parse(JSON.stringify(l));return s=m,s},r.getSqueezedParams=function(l,m){return m.map(s=>l[s]).join(", ")},r.getCoordsDataType=function(l){if(l<=1)return"int";if(l===2)return"ivec2";if(l===3)return"ivec3";if(l===4)return"ivec4";if(l===5)return"ivec5";if(l===6)return"ivec6";throw Error(`GPU for rank ${l} is not yet supported`)},r.getGlChannels=function(l=6){return["x","y","z","w","u","v"].slice(0,l)}},7305:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createNewWebGLContext=r.createWebGLContext=void 0;const d=c(6231),l=c(1713),m={};function s(h){const p=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 t=document.createElement("canvas");return t.width=1,t.height=1,t}();let a;const o={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!h||h==="webgl2")&&(a=p.getContext("webgl2",o),a))try{return new l.WebGLContext(a,2)}catch(t){d.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${t}`)}if((!h||h==="webgl")&&(a=p.getContext("webgl",o)||p.getContext("experimental-webgl",o),a))try{return new l.WebGLContext(a,1)}catch(t){d.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${t}`)}throw new Error("WebGL is not supported")}r.createWebGLContext=function h(p){let a;p&&p!=="webgl2"||!("webgl2"in m)?p&&p!=="webgl"||!("webgl"in m)||(a=m.webgl):a=m.webgl2,a=a||s(p),p=p||a.version===1?"webgl":"webgl2";const o=a.gl;return m[p]=a,o.isContextLost()?(delete m[p],h(p)):(o.disable(o.DEPTH_TEST),o.disable(o.STENCIL_TEST),o.disable(o.BLEND),o.disable(o.DITHER),o.disable(o.POLYGON_OFFSET_FILL),o.disable(o.SAMPLE_COVERAGE),o.enable(o.SCISSOR_TEST),o.enable(o.CULL_FACE),o.cullFace(o.BACK),a)},r.createNewWebGLContext=s},1713:function(f,r,c){var d=this&&this.__createBinding||(Object.create?function(o,t,e,n){n===void 0&&(n=e);var i=Object.getOwnPropertyDescriptor(t,e);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(o,n,i)}:function(o,t,e,n){n===void 0&&(n=e),o[n]=t[e]}),l=this&&this.__setModuleDefault||(Object.create?function(o,t){Object.defineProperty(o,"default",{enumerable:!0,value:t})}:function(o,t){o.default=t}),m=this&&this.__importStar||function(o){if(o&&o.__esModule)return o;var t={};if(o!=null)for(var e in o)e!=="default"&&Object.prototype.hasOwnProperty.call(o,e)&&d(t,o,e);return l(t,o),t};Object.defineProperty(r,"__esModule",{value:!0}),r.WebGLContext=r.linearSearchLastTrue=void 0;const s=c(1670),h=m(c(7769)),p=c(9390);function a(o){let t=0;for(;tthis.isTimerResultAvailable(o)),this.getTimerResult(o)}async createAndWaitForFence(){const o=this.createFence(this.gl);return this.pollFence(o)}createFence(o){let t;const e=o,n=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return o.flush(),t=n===null?()=>!0:()=>{const i=e.clientWaitSync(n,0,0);return i===e.ALREADY_SIGNALED||i===e.CONDITION_SATISFIED},{query:n,isFencePassed:t}}async pollFence(o){return new Promise(t=>{this.addItemToPoll(()=>o.isFencePassed(),()=>t())})}pollItems(){const o=a(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=o;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(o+1)}async addItemToPoll(o,t){this.itemsToPoll.push({isDoneFn:o,resolveFn:t}),this.itemsToPoll.length>1||await(0,p.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},1036:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExecutionPlan=void 0;const d=c(6231);class l{constructor(s,h){this.op=s,this.node=h}}r.ExecutionPlan=class{constructor(m,s,h){this.graph=m,this.profiler=h,this.initialize(s)}initialize(m){this.profiler.event("session","ExecutionPlan.initialize",()=>{const s=this.graph.getNodes();if(s.length!==m.length)throw new Error("The size of nodes and OPs do not match.");this._ops=m.map((h,p)=>new l(h,s[p])),this.reset(),this._starter=[],this._ops.forEach((h,p)=>{let a=!0;for(const o of h.node.inputs)if(!this._values[o]&&this.graph.getInputIndices().indexOf(o)===-1){a=!1;break}a&&this._starter.push(p)})})}reset(){this._values=this.graph.getValues().map(m=>m.tensor)}async execute(m,s){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const h=m.createInferenceHandler(),p=this.graph.getInputIndices();if(s.length!==p.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${s.length} expected: ${p.length}`);s.forEach((i,u)=>{const g=p[u];this._values[g]=i});const a=this._starter.slice(0),o=this.graph.getValues(),t=this.graph.getNodes();let e=0;for(;ethis._values[v]);if(g.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${u.node}`);const b=g;d.Logger.verbose("ExecPlan",`Runing op:${u.node.name} (${b.map((v,w)=>`'${u.node.inputs[w]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);const y=await this.profiler.event("node",u.node.name,async()=>u.op.impl(h,b,u.op.context));if(y.length!==u.node.outputs.length)throw new Error("the size of output does not match model definition.");y.forEach((v,w)=>{const T=u.node.outputs[w];if(this._values[T])throw new Error(`output [${T}] already has value: op:${u.node.name}`);this._values[T]=v});const _=new Set;y.forEach((v,w)=>{const T=u.node.outputs[w];for(const A of o[T].to){const E=t[A];let x=!0;for(const P of E.inputs)if(!this._values[P]){x=!1;break}x&&_.add(A)}}),a.push(..._)}const n=[];for(let i=0;i{Object.defineProperty(r,"__esModule",{value:!0}),r.Graph=void 0;const d=c(1446),l=c(7778),m=c(9395),s=c(9162),h=c(2517);var p=m.onnxruntime.experimental.fbs;r.Graph={from:(e,n)=>new t(e,n)};class a{constructor(n){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,n&&(this.type=h.ProtoUtil.tensorValueTypeFromProto(n.type.tensorType))}get from(){return this._from}get to(){return this._to}}class o{constructor(n,i){n instanceof d.onnx.NodeProto?(this.name=n.name,this.opType=n.opType,this.attributes=new l.Attribute(n.attribute)):n instanceof p.Node&&(this.name=i??n.name(),this.opType=n.opType(),this.attributes=new l.Attribute(h.ProtoUtil.tensorAttributesFromORTFormat(n))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class t{constructor(n,i){if(!n)throw new TypeError("graph is empty");this.buildGraph(n),this.transformGraph(i),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(n){if(n instanceof d.onnx.GraphProto)this.buildGraphFromOnnxFormat(n);else{if(!(n instanceof p.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(n)}}buildGraphFromOnnxFormat(n){const i=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const u=new Map;if(!n.input)throw new Error("missing information in graph: input");const g=[];for(const b of n.input){if(i.has(b.name))throw new Error(`duplicated input name: ${b.name}`);const y=this._allData.push(new a(b))-1;i.set(b.name,y),g.push(b.name)}if(!n.initializer)throw new Error("missing information in graph: initializer");for(const b of n.initializer){let y=i.get(b.name);if(y===void 0){const _=new a;_.type={shape:{dims:h.ProtoUtil.tensorDimsFromProto(b.dims)},tensorType:h.ProtoUtil.tensorDataTypeFromProto(b.dataType)},y=this._allData.push(_)-1,i.set(b.name,y)}this._allData[y]._from=-1,this._allData[y].tensor=s.Tensor.fromProto(b)}for(let b=0;b{this._allData[g]._to.forEach(b=>{n.add(b)})});const i=Array.from(n),u=new Array(this._nodes.length).fill("white");for(;i.length>0;){const g=i.pop();u[g]==="gray"?u[g]="black":(i.push(g),u[g]="gray",this._nodes[g].outputs.forEach(b=>{const y=this._allData[b];if(y.tensor!==void 0)throw new Error("node outputs should not be initialized");if(y._from!==g)throw new Error("from property of the Value object doesn't match index of Node being processed");y._to.forEach(_=>{if(u[_]==="gray")throw new Error("model graph is cyclic");u[_]==="white"&&i.push(_)})}))}}transformGraph(n){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),n&&n.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let n=0;for(let i=0;i0&&(this._nodes[i].inputs.forEach(u=>{const g=this._allData[u]._to.indexOf(i+n);g!==-1&&(this._allData[u]._to[g]=i)}),this._nodes[i].outputs.forEach(u=>{this._allData[u]._from&&this._allData[u]._from===i+n&&(this._allData[u]._from=i)})):(n++,this._nodes[i].outputs.forEach(u=>{this._allData[u]._from=-2}),this._nodes.splice(i,1),i--);n=0;for(let i=0;i0){let u=-1;this._allData[i].from!==void 0&&this._allData[i].from!==-1?(u=this._nodes[this._allData[i].from].outputs.indexOf(i+n),u!==-1&&(this._nodes[this._allData[i].from].outputs[u]=i)):(u=this._allInputIndices.indexOf(i+n),u!==-1&&(this._allInputIndices[u]=i)),this._allData[i].to.forEach(g=>{u=this._nodes[g].inputs.indexOf(i+n),u!==-1&&(this._nodes[g].inputs[u]=i)}),this._allData[i].to.length===0&&(u=this._allOutputIndices.indexOf(i+n),u!==-1&&(this._allOutputIndices[u]=i))}}else n++,this._allData.splice(i,1),i--}deleteNode(n){const i=this._nodes[n];if(i.outputs.length>1){for(let v=1;v0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}i.executeNode=!1;const u=i.inputs[0],g=i.outputs[0],b=this._allData[g].to,y=this._allData[u].to.indexOf(n);if(y===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[u].to.splice(y,1),this._allData[g]._to=[];const _=this._allOutputIndices.indexOf(g);if(_!==-1&&(this._allOutputIndices[_]=u),b&&b.length>0)for(const v of b){const w=this._nodes[v].inputs.indexOf(g);if(w===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[v].inputs[w]=u,this._allData[u].to.push(v)}}removeAllDropoutNodes(){let n=0;for(const i of this._nodes){if(i.opType==="Dropout"){if(i.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(i.outputs.length!==1&&i.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(i.outputs.length===2&&this._allData[i.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(n)}n++}}removeAllIdentityNodes(){let n=0;for(const i of this._nodes)i.opType==="Identity"&&this.deleteNode(n),n++}isActivation(n){switch(n.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const n of this._nodes)if(n.opType==="Conv"){const i=this._allData[n.outputs[0]]._to;if(i.length===1&&this.isActivation(this._nodes[i[0]])){const u=this._nodes[i[0]];if(u.opType==="Clip")if(u.inputs.length===1)try{n.attributes.set("activation_params","floats",[u.attributes.getFloat("min"),u.attributes.getFloat("max")])}catch{n.attributes.set("activation_params","floats",[h.MIN_CLIP,h.MAX_CLIP])}else{if(!(u.inputs.length>=3&&this._allData[u.inputs[1]].tensor!==void 0&&this._allData[u.inputs[2]].tensor!==void 0))continue;n.attributes.set("activation_params","floats",[this._allData[u.inputs[1]].tensor.floatData[0],this._allData[u.inputs[2]].tensor.floatData[0]])}n.attributes.set("activation","string",u.opType),this.deleteNode(i[0])}}}}},6231:(f,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.now=r.Profiler=r.Logger=void 0;const c={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},d={none:new class{log(o,t,e){}},console:new class{log(o,t,e){console.log(`${this.color(o)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${t}`)}color(o){switch(o){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: ${o}`)}}}},l={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let m={"":l};function s(o,t,e,n){if(t===void 0)return i=o,{verbose:s.verbose.bind(null,i),info:s.info.bind(null,i),warning:s.warning.bind(null,i),error:s.error.bind(null,i),fatal:s.fatal.bind(null,i)};if(e===void 0)h(o,t);else if(typeof e=="number"&&n===void 0)h(o,t);else if(typeof e=="string"&&n===void 0)h(o,e,0,t);else{if(typeof e!="string"||typeof n!="number")throw new TypeError("input is valid");h(o,e,0,t)}var i}function h(o,t,e,n){const i=m[n||""]||m[""];c[o]{g.then(async _=>{i&&await i.end(),b(_)},async _=>{i&&await i.end(),y(_)})});if(!u&&i){const b=i.end();if(b&&typeof b.then=="function")return new Promise((y,_)=>{b.then(()=>{y(g)},v=>{_(v)})})}return g}begin(o,t,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){const n=(0,r.now)();return this.flush(n),new p(o,t,n,i=>this.endSync(i))}{const n=e.beginTimer();return new p(o,t,0,async i=>this.end(i),n,e)}}async end(o){const t=await o.checkTimer();this._timingEvents.length=this._flushBatchSize||o-this._flushTime>=this._flushIntervalInMilliseconds){for(const t=this._flushPointer;this._flushPointerperformance.now():Date.now},2644:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Model=void 0;const d=c(5686),l=c(1446),m=c(7070),s=c(9395),h=c(2517);var p=s.onnxruntime.experimental.fbs;r.Model=class{constructor(){}load(a,o,t){if(!t)try{return void this.loadFromOnnxFormat(a,o)}catch(e){if(t!==void 0)throw e}this.loadFromOrtFormat(a,o)}loadFromOnnxFormat(a,o){const t=l.onnx.ModelProto.decode(a);if(h.LongUtil.longToNumber(t.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=t.opsetImport.map(e=>({domain:e.domain,version:h.LongUtil.longToNumber(e.version)})),this._graph=m.Graph.from(t.graph,o)}loadFromOrtFormat(a,o){const t=new d.flatbuffers.ByteBuffer(a),e=p.InferenceSession.getRootAsInferenceSession(t).model();if(h.LongUtil.longToNumber(e.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let n=0;n{Object.defineProperty(r,"__esModule",{value:!0}),r.FLOAT_TYPES=r.INT_TYPES=r.NUMBER_TYPES=void 0,r.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],r.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],r.FLOAT_TYPES=["float32","float64"]},1047:(f,r)=>{function c(d,l){if(l.endsWith("+")){const m=Number.parseInt(l.substring(0,l.length-1),10);return!isNaN(m)&&m<=d}if(l.split("-").length===2){const m=l.split("-"),s=Number.parseInt(m[0],10),h=Number.parseInt(m[1],10);return!isNaN(s)&&!isNaN(h)&&s<=d&&d<=h}return Number.parseInt(l,10)===d}Object.defineProperty(r,"__esModule",{value:!0}),r.resolveOperator=void 0,r.resolveOperator=function(d,l,m){for(const s of m){const h=s[0],p=s[1],a=s[2],o=s[3],t=s[4];if(d.opType===h){for(const e of l)if((e.domain===p||e.domain==="ai.onnx"&&p==="")&&c(e.version,a))return{opImpl:o,opInit:t}}}throw new TypeError(`cannot resolve operator '${d.opType}' with opsets: ${l.map(s=>`${s.domain||"ai.onnx"} v${s.version}`).join(", ")}`)}},9395:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.onnxruntime=void 0;const d=c(5686);var l,m;l=r.onnxruntime||(r.onnxruntime={}),function(s){(function(h){h[h.UNDEFINED=0]="UNDEFINED",h[h.FLOAT=1]="FLOAT",h[h.INT=2]="INT",h[h.STRING=3]="STRING",h[h.TENSOR=4]="TENSOR",h[h.GRAPH=5]="GRAPH",h[h.FLOATS=6]="FLOATS",h[h.INTS=7]="INTS",h[h.STRINGS=8]="STRINGS",h[h.TENSORS=9]="TENSORS",h[h.GRAPHS=10]="GRAPHS",h[h.SPARSE_TENSOR=11]="SPARSE_TENSOR",h[h.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(s.AttributeType||(s.AttributeType={}))}((m=l.experimental||(l.experimental={})).fbs||(m.fbs={})),function(s){(function(h){(function(p){(function(a){a[a.UNKNOWN=0]="UNKNOWN",a[a.VALUE=1]="VALUE",a[a.PARAM=2]="PARAM"})(p.DimensionValueType||(p.DimensionValueType={}))})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){(function(a){a[a.UNDEFINED=0]="UNDEFINED",a[a.FLOAT=1]="FLOAT",a[a.UINT8=2]="UINT8",a[a.INT8=3]="INT8",a[a.UINT16=4]="UINT16",a[a.INT16=5]="INT16",a[a.INT32=6]="INT32",a[a.INT64=7]="INT64",a[a.STRING=8]="STRING",a[a.BOOL=9]="BOOL",a[a.FLOAT16=10]="FLOAT16",a[a.DOUBLE=11]="DOUBLE",a[a.UINT32=12]="UINT32",a[a.UINT64=13]="UINT64",a[a.COMPLEX64=14]="COMPLEX64",a[a.COMPLEX128=15]="COMPLEX128",a[a.BFLOAT16=16]="BFLOAT16"})(p.TensorDataType||(p.TensorDataType={}))})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){(function(a){a[a.Primitive=0]="Primitive",a[a.Fused=1]="Fused"})(p.NodeType||(p.NodeType={}))})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){(function(a){a[a.NONE=0]="NONE",a[a.tensor_type=1]="tensor_type",a[a.sequence_type=2]="sequence_type",a[a.map_type=3]="map_type"})(p.TypeInfoValue||(p.TypeInfoValue={}))})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsShape(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsShape(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}dim(t,e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new s.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}dimLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}static startShape(t){t.startObject(1)}static addDim(t,e){t.addFieldOffset(0,e,0)}static createDimVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startDimVector(t,e){t.startVector(4,e,4)}static endShape(t){return t.endObject()}static createShape(t,e){return a.startShape(t),a.addDim(t,e),a.endShape(t)}}p.Shape=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDimension(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimension(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}value(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new s.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}denotation(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startDimension(t){t.startObject(2)}static addValue(t,e){t.addFieldOffset(0,e,0)}static addDenotation(t,e){t.addFieldOffset(1,e,0)}static endDimension(t){return t.endObject()}static createDimension(t,e,n){return a.startDimension(t),a.addValue(t,e),a.addDenotation(t,n),a.endDimension(t)}}p.Dimension=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDimensionValue(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDimensionValue(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}dimType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):s.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}dimParam(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}static startDimensionValue(t){t.startObject(3)}static addDimType(t,e){t.addFieldInt8(0,e,s.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(t,e){t.addFieldInt64(1,e,t.createLong(0,0))}static addDimParam(t,e){t.addFieldOffset(2,e,0)}static endDimensionValue(t){return t.endObject()}static createDimensionValue(t,e,n,i){return a.startDimensionValue(t),a.addDimType(t,e),a.addDimValue(t,n),a.addDimParam(t,i),a.endDimensionValue(t)}}p.DimensionValue=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTensorTypeAndShape(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensorTypeAndShape(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}elemType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):s.experimental.fbs.TensorDataType.UNDEFINED}shape(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new s.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startTensorTypeAndShape(t){t.startObject(2)}static addElemType(t,e){t.addFieldInt32(0,e,s.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(t,e){t.addFieldOffset(1,e,0)}static endTensorTypeAndShape(t){return t.endObject()}static createTensorTypeAndShape(t,e,n){return a.startTensorTypeAndShape(t),a.addElemType(t,e),a.addShape(t,n),a.endTensorTypeAndShape(t)}}p.TensorTypeAndShape=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMapType(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMapType(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}keyType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):s.experimental.fbs.TensorDataType.UNDEFINED}valueType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new s.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startMapType(t){t.startObject(2)}static addKeyType(t,e){t.addFieldInt32(0,e,s.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(t,e){t.addFieldOffset(1,e,0)}static endMapType(t){return t.endObject()}static createMapType(t,e,n){return a.startMapType(t),a.addKeyType(t,e),a.addValueType(t,n),a.endMapType(t)}}p.MapType=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSequenceType(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSequenceType(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}elemType(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new s.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSequenceType(t){t.startObject(1)}static addElemType(t,e){t.addFieldOffset(0,e,0)}static endSequenceType(t){return t.endObject()}static createSequenceType(t,e){return a.startSequenceType(t),a.addElemType(t,e),a.endSequenceType(t)}}p.SequenceType=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(h.fbs||(h.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(p,a){return this.bb_pos=p,this.bb=a,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(p,a,o,t){return p.prep(4,12),p.writeInt32(t),p.writeInt32(o),p.writeInt32(a),p.offset()}}})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNodeEdge(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNodeEdge(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}nodeIndex(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}inputEdges(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new s.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+n)+12*t,this.bb):null}inputEdgesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}outputEdges(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new s.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+n)+12*t,this.bb):null}outputEdgesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNodeEdge(t){t.startObject(3)}static addNodeIndex(t,e){t.addFieldInt32(0,e,0)}static addInputEdges(t,e){t.addFieldOffset(1,e,0)}static startInputEdgesVector(t,e){t.startVector(12,e,4)}static addOutputEdges(t,e){t.addFieldOffset(2,e,0)}static startOutputEdgesVector(t,e){t.startVector(12,e,4)}static endNodeEdge(t){return t.endObject()}static createNodeEdge(t,e,n,i){return a.startNodeEdge(t),a.addNodeIndex(t,e),a.addInputEdges(t,n),a.addOutputEdges(t,i),a.endNodeEdge(t)}}p.NodeEdge=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNode(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNode(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}domain(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}sinceVersion(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0}index(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readUint32(this.bb_pos+t):0}opType(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):s.experimental.fbs.NodeType.Primitive}executionProviderType(t){let e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,t):null}inputs(t,e){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,e){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}attributes(t,e){let n=this.bb.__offset(this.bb_pos,24);return n?(e||new s.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}attributesLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCounts(t){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+4*t):0}inputArgCountsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}inputArgCountsArray(){let t=this.bb.__offset(this.bb_pos,26);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}implicitInputs(t,e){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}implicitInputsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startNode(t){t.startObject(13)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addDomain(t,e){t.addFieldOffset(2,e,0)}static addSinceVersion(t,e){t.addFieldInt32(3,e,0)}static addIndex(t,e){t.addFieldInt32(4,e,0)}static addOpType(t,e){t.addFieldOffset(5,e,0)}static addType(t,e){t.addFieldInt32(6,e,s.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(t,e){t.addFieldOffset(7,e,0)}static addInputs(t,e){t.addFieldOffset(8,e,0)}static createInputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startInputsVector(t,e){t.startVector(4,e,4)}static addOutputs(t,e){t.addFieldOffset(9,e,0)}static createOutputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startOutputsVector(t,e){t.startVector(4,e,4)}static addAttributes(t,e){t.addFieldOffset(10,e,0)}static createAttributesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startAttributesVector(t,e){t.startVector(4,e,4)}static addInputArgCounts(t,e){t.addFieldOffset(11,e,0)}static createInputArgCountsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startInputArgCountsVector(t,e){t.startVector(4,e,4)}static addImplicitInputs(t,e){t.addFieldOffset(12,e,0)}static createImplicitInputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startImplicitInputsVector(t,e){t.startVector(4,e,4)}static endNode(t){return t.endObject()}static createNode(t,e,n,i,u,g,b,y,_,v,w,T,A,E){return a.startNode(t),a.addName(t,e),a.addDocString(t,n),a.addDomain(t,i),a.addSinceVersion(t,u),a.addIndex(t,g),a.addOpType(t,b),a.addType(t,y),a.addExecutionProviderType(t,_),a.addInputs(t,v),a.addOutputs(t,w),a.addAttributes(t,T),a.addInputArgCounts(t,A),a.addImplicitInputs(t,E),a.endNode(t)}}p.Node=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsValueInfo(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsValueInfo(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}type(t){let e=this.bb.__offset(this.bb_pos,8);return e?(t||new s.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startValueInfo(t){t.startObject(3)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addType(t,e){t.addFieldOffset(2,e,0)}static endValueInfo(t){return t.endObject()}static createValueInfo(t,e,n,i){return a.startValueInfo(t),a.addName(t,e),a.addDocString(t,n),a.addType(t,i),a.endValueInfo(t)}}p.ValueInfo=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTypeInfo(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTypeInfo(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}denotation(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}valueType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):s.experimental.fbs.TypeInfoValue.NONE}value(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}static startTypeInfo(t){t.startObject(3)}static addDenotation(t,e){t.addFieldOffset(0,e,0)}static addValueType(t,e){t.addFieldInt8(1,e,s.experimental.fbs.TypeInfoValue.NONE)}static addValue(t,e){t.addFieldOffset(2,e,0)}static endTypeInfo(t){return t.endObject()}static createTypeInfo(t,e,n,i){return a.startTypeInfo(t),a.addDenotation(t,e),a.addValueType(t,n),a.addValue(t,i),a.endTypeInfo(t)}}p.TypeInfo=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsOperatorSetId(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsOperatorSetId(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}domain(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}version(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}static startOperatorSetId(t){t.startObject(2)}static addDomain(t,e){t.addFieldOffset(0,e,0)}static addVersion(t,e){t.addFieldInt64(1,e,t.createLong(0,0))}static endOperatorSetId(t){return t.endObject()}static createOperatorSetId(t,e,n){return a.startOperatorSetId(t),a.addDomain(t,e),a.addVersion(t,n),a.endOperatorSetId(t)}}p.OperatorSetId=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTensor(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTensor(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}dims(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}dataType(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):s.experimental.fbs.TensorDataType.UNDEFINED}rawData(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}rawDataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}rawDataArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}stringData(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}stringDataLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}static startTensor(t){t.startObject(6)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addDims(t,e){t.addFieldOffset(2,e,0)}static createDimsVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static addDataType(t,e){t.addFieldInt32(3,e,s.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(t,e){t.addFieldOffset(4,e,0)}static createRawDataVector(t,e){t.startVector(1,e.length,1);for(let n=e.length-1;n>=0;n--)t.addInt8(e[n]);return t.endVector()}static startRawDataVector(t,e){t.startVector(1,e,1)}static addStringData(t,e){t.addFieldOffset(5,e,0)}static createStringDataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startStringDataVector(t,e){t.startVector(4,e,4)}static endTensor(t){return t.endObject()}static createTensor(t,e,n,i,u,g,b){return a.startTensor(t),a.addName(t,e),a.addDocString(t,n),a.addDims(t,i),a.addDataType(t,u),a.addRawData(t,g),a.addStringData(t,b),a.endTensor(t)}}p.Tensor=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSparseTensor(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSparseTensor(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}values(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}indices(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dims(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dimsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSparseTensor(t){t.startObject(3)}static addValues(t,e){t.addFieldOffset(0,e,0)}static addIndices(t,e){t.addFieldOffset(1,e,0)}static addDims(t,e){t.addFieldOffset(2,e,0)}static createDimsVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startDimsVector(t,e){t.startVector(8,e,8)}static endSparseTensor(t){return t.endObject()}static createSparseTensor(t,e,n,i){return a.startSparseTensor(t),a.addValues(t,e),a.addIndices(t,n),a.addDims(t,i),a.endSparseTensor(t)}}p.SparseTensor=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsAttribute(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsAttribute(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}docString(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):s.experimental.fbs.AttributeType.UNDEFINED}f(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):0}i(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}s(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}t(t){let e=this.bb.__offset(this.bb_pos,16);return e?(t||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}g(t){let e=this.bb.__offset(this.bb_pos,18);return e?(t||new s.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}floats(t){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0}floatsLength(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}floatsArray(){let t=this.bb.__offset(this.bb_pos,20);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}ints(t){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}intsLength(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}strings(t,e){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}stringsLength(){let t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}tensors(t,e){let n=this.bb.__offset(this.bb_pos,26);return n?(e||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}tensorsLength(){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}graphs(t,e){let n=this.bb.__offset(this.bb_pos,28);return n?(e||new s.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}graphsLength(){let t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}static startAttribute(t){t.startObject(13)}static addName(t,e){t.addFieldOffset(0,e,0)}static addDocString(t,e){t.addFieldOffset(1,e,0)}static addType(t,e){t.addFieldInt32(2,e,s.experimental.fbs.AttributeType.UNDEFINED)}static addF(t,e){t.addFieldFloat32(3,e,0)}static addI(t,e){t.addFieldInt64(4,e,t.createLong(0,0))}static addS(t,e){t.addFieldOffset(5,e,0)}static addT(t,e){t.addFieldOffset(6,e,0)}static addG(t,e){t.addFieldOffset(7,e,0)}static addFloats(t,e){t.addFieldOffset(8,e,0)}static createFloatsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addFloat32(e[n]);return t.endVector()}static startFloatsVector(t,e){t.startVector(4,e,4)}static addInts(t,e){t.addFieldOffset(9,e,0)}static createIntsVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startIntsVector(t,e){t.startVector(8,e,8)}static addStrings(t,e){t.addFieldOffset(10,e,0)}static createStringsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startStringsVector(t,e){t.startVector(4,e,4)}static addTensors(t,e){t.addFieldOffset(11,e,0)}static createTensorsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startTensorsVector(t,e){t.startVector(4,e,4)}static addGraphs(t,e){t.addFieldOffset(12,e,0)}static createGraphsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startGraphsVector(t,e){t.startVector(4,e,4)}static endAttribute(t){return t.endObject()}static createAttribute(t,e,n,i,u,g,b,y,_,v,w,T,A,E){return a.startAttribute(t),a.addName(t,e),a.addDocString(t,n),a.addType(t,i),a.addF(t,u),a.addI(t,g),a.addS(t,b),a.addT(t,y),a.addG(t,_),a.addFloats(t,v),a.addInts(t,w),a.addStrings(t,T),a.addTensors(t,A),a.addGraphs(t,E),a.endAttribute(t)}}p.Attribute=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGraph(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGraph(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}initializers(t,e){let n=this.bb.__offset(this.bb_pos,4);return n?(e||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}initializersLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeArgs(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new s.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}nodeArgsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}nodes(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new s.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}maxNodeIndex(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readUint32(this.bb_pos+t):0}nodeEdges(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new s.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}nodeEdgesLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}inputs(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}inputsLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}outputs(t,e){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*t,e):null}outputsLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}sparseInitializers(t,e){let n=this.bb.__offset(this.bb_pos,18);return n?(e||new s.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}sparseInitializersLength(){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGraph(t){t.startObject(8)}static addInitializers(t,e){t.addFieldOffset(0,e,0)}static createInitializersVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startInitializersVector(t,e){t.startVector(4,e,4)}static addNodeArgs(t,e){t.addFieldOffset(1,e,0)}static createNodeArgsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startNodeArgsVector(t,e){t.startVector(4,e,4)}static addNodes(t,e){t.addFieldOffset(2,e,0)}static createNodesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startNodesVector(t,e){t.startVector(4,e,4)}static addMaxNodeIndex(t,e){t.addFieldInt32(3,e,0)}static addNodeEdges(t,e){t.addFieldOffset(4,e,0)}static createNodeEdgesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startNodeEdgesVector(t,e){t.startVector(4,e,4)}static addInputs(t,e){t.addFieldOffset(5,e,0)}static createInputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startInputsVector(t,e){t.startVector(4,e,4)}static addOutputs(t,e){t.addFieldOffset(6,e,0)}static createOutputsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startOutputsVector(t,e){t.startVector(4,e,4)}static addSparseInitializers(t,e){t.addFieldOffset(7,e,0)}static createSparseInitializersVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startSparseInitializersVector(t,e){t.startVector(4,e,4)}static endGraph(t){return t.endObject()}static createGraph(t,e,n,i,u,g,b,y,_){return a.startGraph(t),a.addInitializers(t,e),a.addNodeArgs(t,n),a.addNodes(t,i),a.addMaxNodeIndex(t,u),a.addNodeEdges(t,g),a.addInputs(t,b),a.addOutputs(t,y),a.addSparseInitializers(t,_),a.endGraph(t)}}p.Graph=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsModel(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsModel(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}irVersion(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}opsetImport(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new s.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}opsetImportLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}producerName(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}producerVersion(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}domain(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}modelVersion(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}docString(t){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb_pos+e,t):null}graph(t){let e=this.bb.__offset(this.bb_pos,18);return e?(t||new s.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}graphDocString(t){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb_pos+e,t):null}static startModel(t){t.startObject(9)}static addIrVersion(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addOpsetImport(t,e){t.addFieldOffset(1,e,0)}static createOpsetImportVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startOpsetImportVector(t,e){t.startVector(4,e,4)}static addProducerName(t,e){t.addFieldOffset(2,e,0)}static addProducerVersion(t,e){t.addFieldOffset(3,e,0)}static addDomain(t,e){t.addFieldOffset(4,e,0)}static addModelVersion(t,e){t.addFieldInt64(5,e,t.createLong(0,0))}static addDocString(t,e){t.addFieldOffset(6,e,0)}static addGraph(t,e){t.addFieldOffset(7,e,0)}static addGraphDocString(t,e){t.addFieldOffset(8,e,0)}static endModel(t){return t.endObject()}static createModel(t,e,n,i,u,g,b,y,_,v){return a.startModel(t),a.addIrVersion(t,e),a.addOpsetImport(t,n),a.addProducerName(t,i),a.addProducerVersion(t,u),a.addDomain(t,g),a.addModelVersion(t,b),a.addDocString(t,y),a.addGraph(t,_),a.addGraphDocString(t,v),a.endModel(t)}}p.Model=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKernelCreateInfos(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKernelCreateInfos(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}nodeIndices(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}nodeIndicesLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}nodeIndicesArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}kernelDefHashes(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}kernelDefHashesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startKernelCreateInfos(t){t.startObject(2)}static addNodeIndices(t,e){t.addFieldOffset(0,e,0)}static createNodeIndicesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startNodeIndicesVector(t,e){t.startVector(4,e,4)}static addKernelDefHashes(t,e){t.addFieldOffset(1,e,0)}static createKernelDefHashesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startKernelDefHashesVector(t,e){t.startVector(8,e,8)}static endKernelCreateInfos(t){return t.endObject()}static createKernelCreateInfos(t,e,n){return a.startKernelCreateInfos(t),a.addNodeIndices(t,e),a.addKernelDefHashes(t,n),a.endKernelCreateInfos(t)}}p.KernelCreateInfos=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSubGraphSessionState(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSubGraphSessionState(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}graphId(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}sessionState(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new s.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSubGraphSessionState(t){t.startObject(2)}static addGraphId(t,e){t.addFieldOffset(0,e,0)}static addSessionState(t,e){t.addFieldOffset(1,e,0)}static endSubGraphSessionState(t){let e=t.endObject();return t.requiredField(e,4),e}static createSubGraphSessionState(t,e,n){return a.startSubGraphSessionState(t),a.addGraphId(t,e),a.addSessionState(t,n),a.endSubGraphSessionState(t)}}p.SubGraphSessionState=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSessionState(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSessionState(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}kernels(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new s.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}subGraphSessionStates(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new s.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}subGraphSessionStatesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSessionState(t){t.startObject(2)}static addKernels(t,e){t.addFieldOffset(0,e,0)}static addSubGraphSessionStates(t,e){t.addFieldOffset(1,e,0)}static createSubGraphSessionStatesVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startSubGraphSessionStatesVector(t,e){t.startVector(4,e,4)}static endSessionState(t){return t.endObject()}static createSessionState(t,e,n){return a.startSessionState(t),a.addKernels(t,e),a.addSubGraphSessionStates(t,n),a.endSessionState(t)}}p.SessionState=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={})),function(s){(function(h){(function(p){class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInferenceSession(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInferenceSession(t,e){return t.setPosition(t.position()+d.flatbuffers.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static bufferHasIdentifier(t){return t.__has_identifier("ORTM")}ortVersion(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}model(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new s.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}sessionState(t){let e=this.bb.__offset(this.bb_pos,8);return e?(t||new s.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startInferenceSession(t){t.startObject(3)}static addOrtVersion(t,e){t.addFieldOffset(0,e,0)}static addModel(t,e){t.addFieldOffset(1,e,0)}static addSessionState(t,e){t.addFieldOffset(2,e,0)}static endInferenceSession(t){return t.endObject()}static finishInferenceSessionBuffer(t,e){t.finish(e,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(t,e){t.finish(e,"ORTM",!0)}static createInferenceSession(t,e,n,i){return a.startInferenceSession(t),a.addOrtVersion(t,e),a.addModel(t,n),a.addSessionState(t,i),a.endInferenceSession(t)}}p.InferenceSession=a})(h.fbs||(h.fbs={}))})(s.experimental||(s.experimental={}))}(r.onnxruntime||(r.onnxruntime={}))},7448:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OnnxjsSessionHandler=void 0;const d=c(1670),l=c(9162);r.OnnxjsSessionHandler=class{constructor(m){this.session=m,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(m,s,h){const p=new Map;for(const t in m)if(Object.hasOwnProperty.call(m,t)){const e=m[t];p.set(t,new l.Tensor(e.dims,e.type,void 0,void 0,e.data))}const a=await this.session.run(p),o={};return a.forEach((t,e)=>{o[e]=new d.Tensor(t.type,t.data,t.dims)}),o}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6919:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Session=void 0;const d=c(7067),l=c(1296),m=c(7091),s=c(1036),h=c(6231),p=c(2644);r.Session=class{constructor(a={}){this._initialized=!1,this.backendHint=a.backendHint,this.profiler=h.Profiler.create(a.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(a,o,t){await this.profiler.event("session","Session.loadModel",async()=>{const e=await(0,m.resolveBackend)(this.backendHint);if(this.sessionHandler=e.createSessionHandler(this.context),this._model=new p.Model,typeof a=="string"){const n=a.endsWith(".ort");if(typeof fetch>"u"){const i=await(0,l.promisify)(d.readFile)(a);this.initialize(i,n)}else{const i=await fetch(a),u=await i.arrayBuffer();this.initialize(new Uint8Array(u),n)}}else if(ArrayBuffer.isView(a))this.initialize(a);else{const n=new Uint8Array(a,o||0,t||a.byteLength);this.initialize(n)}})}initialize(a,o){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const t=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(a,t,o),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new s.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(a){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const o=this.normalizeAndValidateInputs(a),t=await this._executionPlan.execute(this.sessionHandler,o);return this.createOutput(t)})}normalizeAndValidateInputs(a){const o=this._model.graph.getInputNames();if(Array.isArray(a)){if(a.length!==o.length)throw new Error(`incorrect input array length: expected ${o.length} but got ${a.length}`)}else{if(a.size!==o.length)throw new Error(`incorrect input map size: expected ${o.length} but got ${a.size}`);const t=new Array(a.size);let e=0;for(let n=0;ntypeof E=="string")))throw new TypeError("cache should be a string array");A&&(this.cache=new Array(T))}else{if(v!==void 0){const E=e(b);if(!(v instanceof E))throw new TypeError(`cache should be type ${E.name}`)}if(A){const E=new ArrayBuffer(T*function(x){switch(x){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 ${x}`)}}(b));this.cache=function(x,P){return new(e(P))(x)}(E,b)}}}static fromProto(g){if(!g)throw new Error("cannot construct Value from an empty tensor");const b=p.ProtoUtil.tensorDataTypeFromProto(g.dataType),y=p.ProtoUtil.tensorDimsFromProto(g.dims),_=new o(y,b);if(b==="string")g.stringData.forEach((v,w)=>{_.data[w]=(0,p.decodeUtf8String)(v)});else if(g.rawData&&typeof g.rawData.byteLength=="number"&&g.rawData.byteLength>0){const v=_.data,w=new DataView(g.rawData.buffer,g.rawData.byteOffset,g.rawData.byteLength),T=t(g.dataType),A=g.rawData.byteLength/T;if(g.rawData.byteLength%T!=0)throw new Error("invalid buffer length");if(v.length!==A)throw new Error("buffer length mismatch");for(let E=0;E0){const v=_.data,w=new DataView(g.rawDataArray().buffer,g.rawDataArray().byteOffset,g.rawDataLength()),T=t(g.dataType()),A=g.rawDataLength()/T;if(g.rawDataLength()%T!=0)throw new Error("invalid buffer length");if(v.length!==A)throw new Error("buffer length mismatch");for(let E=0;E1&&P>1)return;A[T-E]=Math.max(x,P)}return A}static index(b,y){const _=new Array(y.length);return a.fillIndex(b,y,_),_}static fillIndex(b,y,_){const v=b.length-y.length;for(let w=0;w=0;J--)x[J]=F%T[J],F=Math.floor(F/T[J]);q||(a.fillIndex(x,b.dims,P),$=b.get(P)),D||(a.fillIndex(x,y.dims,L),k=y.get(L)),E.set(x,_($,k))}}return E}}static isValidBroadcast(b,y){const _=b.length,v=y.length;if(_>v)return!1;for(let w=1;w<=_;w++)if(b[_-w]!==1&&b[_-w]!==y[v-w])return!1;return!0}static getBroadcastDims(b,y){const _=b.length,v=[];for(let w=0;w<_;w++){const T=_-1-w,A=b[T]||1;(y[y.length-1-w]||1)>1&&A===1&&v.unshift(T)}return v}}r.BroadcastUtil=a,r.arrayCopyHelper=function(g,b,y,_,v){if(_<0||_>=b.length)throw new Error("sourceIndex out of bounds");if(y<0||y>=g.length)throw new Error("targetIndex out of bounds");if(_+v>b.length)throw new Error("source indices to be copied are outside bounds");if(y+v>g.length)throw new Error("target array is too small to hold result");for(let w=0;wm.default.isLong(y)?y.toNumber():y)}static tensorValueTypeFromProto(b){return{tensorType:o.tensorDataTypeFromProto(b.elemType),shape:{dims:o.tensorDimsFromProto(b.shape.dim.map(y=>y.dimValue))}}}static tensorDimsFromORTFormat(b){const y=[];for(let _=0;_b.length)throw new Error(`invalid dimension of ${y} for sizeFromDimension as Tensor has ${b.length} dimensions.`);return e.getSizeFromDimensionRange(b,y,b.length)}static sizeToDimension(b,y){if(y<0||y>b.length)throw new Error(`invalid dimension of ${y} for sizeToDimension as Tensor has ${b.length} dimensions.`);return e.getSizeFromDimensionRange(b,0,y)}static getSizeFromDimensionRange(b,y,_){let v=1;for(let w=y;w<_;w++){if(b[w]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");v*=b[w]}return v}static computeStrides(b){const y=b.length;if(y===0)return[];if(y===1)return[1];const _=new Array(y);_[y-1]=1,_[y-2]=b[y-1];for(let v=y-3;v>=0;--v)_[v]=_[v+1]*b[v+1];return _}static transpose(b){return b.slice().reverse()}static indicesToOffset(b,y,_){_===void 0&&(_=b.length);let v=0;for(let w=0;w<_;++w)v+=y[w]*b[w];return v}static offsetToIndices(b,y){const _=y.length;if(_===0)return[];if(_===1)return[b*y[0]];const v=new Array(y.length);for(let w=0;w=y)throw new Error("unsupported axis for this operation.");return b<0?b+y:b}static normalizeAxes(b,y){return b.map(_=>this.normalizeAxis(_,y))}static incrementIndex(b,y,_){if(y.length===0||b.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(_===void 0)_=y.length;else if(_<=0||_>y.length)throw new Error("Incorrect axis to increment on");for(let v=_-1;v>=0&&(b[v]++,!(b[v]=b.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");v[E]=b[E]}else v[E]=y[E];T*=v[E]}}const A=e.size(b);if(w!==-1){if(A%T!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${b}] Output shape: [${y}]`);v[w]=A/T}else if(T!==A)throw new Error("reshapedDims and originalDims don't have matching sizes");return v}static sortBasedOnPerm(b,y){return y?y.map(_=>b[_]):b.slice().reverse()}static padShape(b,y){const _=b.length;return b.map((v,w)=>v+y[w]+y[w+_])}static areEqual(b,y){return b.length===y.length&&b.every((_,v)=>_===y[v])}static validateDimsAndCalcSize(b){if(b.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let y=1;for(const _ of b){if(!Number.isInteger(_))throw new TypeError(`Invalid shape: ${_} is not an integer`);if(_<0||_>2147483647)throw new TypeError(`Invalid shape: length ${_} is not allowed`);y*=_}return y}static flattenShape(b,y){y<0&&(y+=b.length);const _=b.reduce((w,T)=>w*T,1),v=b.slice(y).reduce((w,T)=>w*T,1);return[_/v,v]}static squeezeShape(b,y){const _=new Array;y=e.normalizeAxes(y,b.length);for(let v=0;v=0;if(w&&b[v]!==1)throw new Error("squeeze an axis of size different than 1");(y.length===0&&b[v]>1||y.length>0&&!w)&&_.push(b[v])}return _}static unsqueezeShape(b,y){const _=new Array(b.length+y.length);_.fill(0);for(let w=0;w=_.length)throw new Error("'axes' has an out of range axis");if(_[T]!==0)throw new Error("'axes' has a duplicate axis");_[T]=1}let v=0;for(let w=0;w<_.length;w++)_[w]===0&&(_[w]=b[v++]);if(v!==b.length)throw new Error("the unsqueezed dimension could not be established");return _}}r.ShapeUtil=e,r.MathUtil=class{static sqr(g,b,y,_,v){if(_<0||_>=b.length)throw new Error("sourceIndex out of bounds");if(y<0||y>=g.length)throw new Error("targetIndex out of bounds");if(_+v>b.length)throw new Error("source indices to be copied are outside bounds");if(y+v>g.length)throw new Error("target array is too small to hold result");for(let w=0;w=b.length)throw new Error("sourceIndex out of bounds");if(y<0||y>=g.length)throw new Error("targetIndex out of bounds");if(_+v>b.length)throw new Error("source indices to be copied are outside bounds");if(y+v>g.length)throw new Error("target array is too small to hold result");for(let T=0;T=b.length)throw new Error("sourceIndex out of bounds");if(y<0||y>=g.length)throw new Error("targetIndex out of bounds");if(_+v>b.length)throw new Error("source indices to be copied are outside bounds");if(y+v>g.length)throw new Error("target array is too small to hold result");for(let T=0;T=b.length)throw new Error("sourceIndex out of bounds");if(y<0||y>=g.length)throw new Error("targetIndex out of bounds");if(_+v>b.length)throw new Error("source indices to be copied are outside bounds");if(y+v>g.length)throw new Error("target array is too small to hold result");for(let w=0;wy.push(k));const A=i.calcReduceShape(T,y,!0),E=e.size(A),x=new h.Tensor(A,b.type),P=e.computeStrides(A),L=e.computeStrides(T),F=new Array(T.length);for(let $=0;$=y.length)return T(b[w]);const x=y[v],P=x>=_.length?1:e.size(_.slice(x+1));for(let L=0;L<_[x];L++)E=L===0?i.calcReduceByAxis(b,y,_,v+1,w,T,A):A(E,i.calcReduceByAxis(b,y,_,v+1,w,T,A)),w+=P;return E}static calcReduceShape(b,y,_){const v=b.slice();for(let w=0;ww!==0)}}r.ReduceUtil=i;class u{static adjustPoolAttributes(b,y,_,v,w,T){if(!b&&_.length!==y.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(b)for(let A=0;A=_.length?_.push(y[A+2]):_[A]=y[A+2];for(let A=0;A<_.length;A++)if(A=_[A]||T[A+_.length]>=_[A])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(b,y,_,v,w,T){if(T){if(w.length!==2*(b.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(y.length!==b.length-2)throw new Error("length of strides should be the length of data dimensions");if(v.length!==b.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let A=0;A{Object.defineProperty(r,"__esModule",{value:!0}),r.iterateExtraOptions=void 0,r.iterateExtraOptions=(c,d,l,m)=>{if(typeof c=="object"&&c!==null){if(l.has(c))throw new Error("Circular reference in options");l.add(c)}Object.entries(c).forEach(([s,h])=>{const p=d?d+s:s;if(typeof h=="object")(0,r.iterateExtraOptions)(h,p+".",l,m);else if(typeof h=="string"||typeof h=="number")m(p,h.toString());else{if(typeof h!="boolean")throw new Error("Can't handle extra config type: "+typeof h);m(p,h?"1":"0")}})}},2157:function(f,r,c){var d,l=this&&this.__createBinding||(Object.create?function(P,L,F,$){$===void 0&&($=F);var k=Object.getOwnPropertyDescriptor(L,F);k&&!("get"in k?!L.__esModule:k.writable||k.configurable)||(k={enumerable:!0,get:function(){return L[F]}}),Object.defineProperty(P,$,k)}:function(P,L,F,$){$===void 0&&($=F),P[$]=L[F]}),m=this&&this.__setModuleDefault||(Object.create?function(P,L){Object.defineProperty(P,"default",{enumerable:!0,value:L})}:function(P,L){P.default=L}),s=this&&this.__importStar||function(P){if(P&&P.__esModule)return P;var L={};if(P!=null)for(var F in P)F!=="default"&&Object.prototype.hasOwnProperty.call(P,F)&&l(L,P,F);return m(L,P),L};Object.defineProperty(r,"__esModule",{value:!0}),r.endProfiling=r.run=r.releaseSession=r.createSession=r.createSessionFinalize=r.createSessionAllocate=r.initOrt=r.initWasm=void 0;const h=c(1670),p=s(c(349)),a=c(6361),o=()=>!!h.env.wasm.proxy&&typeof document<"u";let t,e,n,i=!1,u=!1,g=!1;const b=[],y=[],_=[],v=[],w=[],T=[],A=()=>{if(i||!u||g||!t)throw new Error("worker not ready")},E=P=>{switch(P.data.type){case"init-wasm":i=!1,P.data.err?(g=!0,e[1](P.data.err)):(u=!0,e[0]());break;case"init-ort":P.data.err?n[1](P.data.err):n[0]();break;case"create_allocate":P.data.err?b.shift()[1](P.data.err):b.shift()[0](P.data.out);break;case"create_finalize":P.data.err?y.shift()[1](P.data.err):y.shift()[0](P.data.out);break;case"create":P.data.err?_.shift()[1](P.data.err):_.shift()[0](P.data.out);break;case"release":P.data.err?v.shift()[1](P.data.err):v.shift()[0]();break;case"run":P.data.err?w.shift()[1](P.data.err):w.shift()[0](P.data.out);break;case"end-profiling":P.data.err?T.shift()[1](P.data.err):T.shift()[0]()}},x=typeof document<"u"?(d=document==null?void 0:document.currentScript)===null||d===void 0?void 0:d.src:void 0;r.initWasm=async()=>{if(o()){if(u)return;if(i)throw new Error("multiple calls to 'initWasm()' detected.");if(g)throw new Error("previous call to 'initWasm()' failed.");return i=!0,h.env.wasm.wasmPaths===void 0&&x&&x.indexOf("blob:")!==0&&(h.env.wasm.wasmPaths=x.substr(0,+x.lastIndexOf("/")+1)),new Promise((P,L)=>{t==null||t.terminate(),t=c(9710).Z(),t.onmessage=E,e=[P,L];const F={type:"init-wasm",in:h.env.wasm};t.postMessage(F)})}return(0,a.initializeWebAssembly)(h.env.wasm)},r.initOrt=async(P,L)=>{if(o())return A(),new Promise((F,$)=>{n=[F,$];const k={type:"init-ort",in:{numThreads:P,loggingLevel:L}};t.postMessage(k)});p.initOrt(P,L)},r.createSessionAllocate=async P=>o()?(A(),new Promise((L,F)=>{b.push([L,F]);const $={type:"create_allocate",in:{model:P}};t.postMessage($,[P.buffer])})):p.createSessionAllocate(P),r.createSessionFinalize=async(P,L)=>o()?(A(),new Promise((F,$)=>{y.push([F,$]);const k={type:"create_finalize",in:{modeldata:P,options:L}};t.postMessage(k)})):p.createSessionFinalize(P,L),r.createSession=async(P,L)=>o()?(A(),new Promise((F,$)=>{_.push([F,$]);const k={type:"create",in:{model:P,options:L}};t.postMessage(k,[P.buffer])})):p.createSession(P,L),r.releaseSession=async P=>{if(o())return A(),new Promise((L,F)=>{v.push([L,F]);const $={type:"release",in:P};t.postMessage($)});p.releaseSession(P)},r.run=async(P,L,F,$,k)=>o()?(A(),new Promise((q,D)=>{w.push([q,D]);const U={type:"run",in:{sessionId:P,inputIndices:L,inputs:F,outputIndices:$,options:k}};t.postMessage(U,p.extractTransferableBuffers(F))})):p.run(P,L,F,$,k),r.endProfiling=async P=>{if(o())return A(),new Promise((L,F)=>{T.push([L,F]);const $={type:"end-profiling",in:P};t.postMessage($)});p.endProfiling(P)}},586:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.setRunOptions=void 0;const d=c(7967),l=c(4983),m=c(6361);r.setRunOptions=s=>{const h=(0,m.getInstance)();let p=0;const a=[],o=s||{};try{if((s==null?void 0:s.logSeverityLevel)===void 0)o.logSeverityLevel=2;else if(typeof s.logSeverityLevel!="number"||!Number.isInteger(s.logSeverityLevel)||s.logSeverityLevel<0||s.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${s.logSeverityLevel}`);if((s==null?void 0:s.logVerbosityLevel)===void 0)o.logVerbosityLevel=0;else if(typeof s.logVerbosityLevel!="number"||!Number.isInteger(s.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${s.logVerbosityLevel}`);(s==null?void 0:s.terminate)===void 0&&(o.terminate=!1);let t=0;if((s==null?void 0:s.tag)!==void 0&&(t=(0,l.allocWasmString)(s.tag,a)),p=h._OrtCreateRunOptions(o.logSeverityLevel,o.logVerbosityLevel,!!o.terminate,t),p===0)throw new Error("Can't create run options");return(s==null?void 0:s.extra)!==void 0&&(0,d.iterateExtraOptions)(s.extra,"",new WeakSet,(e,n)=>{const i=(0,l.allocWasmString)(e,a),u=(0,l.allocWasmString)(n,a);if(h._OrtAddRunConfigEntry(p,i,u)!==0)throw new Error(`Can't set a run config entry: ${e} - ${n}`)}),[p,a]}catch(t){throw p!==0&&h._OrtReleaseRunOptions(p),a.forEach(h._free),t}}},2306:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OnnxruntimeWebAssemblySessionHandler=void 0;const d=c(2806),l=c(1670),m=c(2850),s=c(2157);let h;r.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(p){const a=await fetch(p),o=await a.arrayBuffer();return(0,s.createSessionAllocate)(new Uint8Array(o))}async loadModel(p,a){if(h||(await(0,s.initOrt)(l.env.wasm.numThreads,(o=>{switch(o){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: ${o}`)}})(l.env.logLevel)),h=!0),typeof p=="string")if(typeof fetch>"u"){const o=await(0,m.promisify)(d.readFile)(p);[this.sessionId,this.inputNames,this.outputNames]=await(0,s.createSession)(o,a)}else{const o=await this.createSessionAllocate(p);[this.sessionId,this.inputNames,this.outputNames]=await(0,s.createSessionFinalize)(o,a)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,s.createSession)(p,a)}async dispose(){return(0,s.releaseSession)(this.sessionId)}async run(p,a,o){const t=[],e=[];Object.entries(p).forEach(g=>{const b=g[0],y=g[1],_=this.inputNames.indexOf(b);if(_===-1)throw new Error(`invalid input '${b}'`);t.push(y),e.push(_)});const n=[];Object.entries(a).forEach(g=>{const b=g[0],y=this.outputNames.indexOf(b);if(y===-1)throw new Error(`invalid output '${b}'`);n.push(y)});const i=await(0,s.run)(this.sessionId,e,t.map(g=>[g.type,g.dims,g.data]),n,o),u={};for(let g=0;g{Object.defineProperty(r,"__esModule",{value:!0}),r.setSessionOptions=void 0;const d=c(7967),l=c(4983),m=c(6361);r.setSessionOptions=s=>{const h=(0,m.getInstance)();let p=0;const a=[],o=s||{};(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")})(o);try{(s==null?void 0:s.graphOptimizationLevel)===void 0&&(o.graphOptimizationLevel="all");const t=(i=>{switch(i){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${i}`)}})(o.graphOptimizationLevel);(s==null?void 0:s.enableCpuMemArena)===void 0&&(o.enableCpuMemArena=!0),(s==null?void 0:s.enableMemPattern)===void 0&&(o.enableMemPattern=!0),(s==null?void 0:s.executionMode)===void 0&&(o.executionMode="sequential");const e=(i=>{switch(i){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${i}`)}})(o.executionMode);let n=0;if((s==null?void 0:s.logId)!==void 0&&(n=(0,l.allocWasmString)(s.logId,a)),(s==null?void 0:s.logSeverityLevel)===void 0)o.logSeverityLevel=2;else if(typeof s.logSeverityLevel!="number"||!Number.isInteger(s.logSeverityLevel)||s.logSeverityLevel<0||s.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${s.logSeverityLevel}`);if((s==null?void 0:s.logVerbosityLevel)===void 0)o.logVerbosityLevel=0;else if(typeof s.logVerbosityLevel!="number"||!Number.isInteger(s.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${s.logVerbosityLevel}`);if((s==null?void 0:s.enableProfiling)===void 0&&(o.enableProfiling=!1),p=h._OrtCreateSessionOptions(t,!!o.enableCpuMemArena,!!o.enableMemPattern,e,!!o.enableProfiling,0,n,o.logSeverityLevel,o.logVerbosityLevel),p===0)throw new Error("Can't create session options");return s!=null&&s.executionProviders&&((i,u,g)=>{for(const b of u){let y=typeof b=="string"?b:b.name;switch(y){case"xnnpack":y="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${y}`)}const _=(0,l.allocWasmString)(y,g);if((0,m.getInstance)()._OrtAppendExecutionProvider(i,_)!==0)throw new Error(`Can't append execution provider: ${y}`)}})(p,s.executionProviders,a),(s==null?void 0:s.extra)!==void 0&&(0,d.iterateExtraOptions)(s.extra,"",new WeakSet,(i,u)=>{const g=(0,l.allocWasmString)(i,a),b=(0,l.allocWasmString)(u,a);if(h._OrtAddSessionConfigEntry(p,g,b)!==0)throw new Error(`Can't set a session config entry: ${i} - ${u}`)}),[p,a]}catch(t){throw p!==0&&h._OrtReleaseSessionOptions(p),a.forEach(h._free),t}}},4983:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.allocWasmString=void 0;const d=c(6361);r.allocWasmString=(l,m)=>{const s=(0,d.getInstance)(),h=s.lengthBytesUTF8(l)+1,p=s._malloc(h);return s.stringToUTF8(l,p,h),m.push(p),p}},349:(f,r,c)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.extractTransferableBuffers=r.endProfiling=r.run=r.releaseSession=r.createSession=r.createSessionFinalize=r.createSessionAllocate=r.initOrt=void 0;const d=c(586),l=c(4919),m=c(4983),s=c(6361);r.initOrt=(t,e)=>{const n=(0,s.getInstance)()._OrtInit(t,e);if(n!==0)throw new Error(`Can't initialize onnxruntime. error code = ${n}`)};const h=new Map;r.createSessionAllocate=t=>{const e=(0,s.getInstance)(),n=e._malloc(t.byteLength);return e.HEAPU8.set(t,n),[n,t.byteLength]},r.createSessionFinalize=(t,e)=>{const n=(0,s.getInstance)();let i=0,u=0,g=[];try{if([u,g]=(0,l.setSessionOptions)(e),i=n._OrtCreateSession(t[0],t[1],u),i===0)throw new Error("Can't create a session")}finally{n._free(t[0]),n._OrtReleaseSessionOptions(u),g.forEach(n._free)}const b=n._OrtGetInputCount(i),y=n._OrtGetOutputCount(i),_=[],v=[],w=[],T=[];for(let A=0;A{const n=(0,r.createSessionAllocate)(t);return(0,r.createSessionFinalize)(n,e)},r.releaseSession=t=>{const e=(0,s.getInstance)(),n=h.get(t);if(!n)throw new Error("invalid session id");const i=n[0],u=n[1],g=n[2];u.forEach(e._OrtFree),g.forEach(e._OrtFree),e._OrtReleaseSession(i),h.delete(t)};const p=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}`)}},a=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}`)}},o=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}`)}};r.run=(t,e,n,i,u)=>{const g=(0,s.getInstance)(),b=h.get(t);if(!b)throw new Error("invalid session id");const y=b[0],_=b[1],v=b[2],w=e.length,T=i.length;let A=0,E=[];const x=[],P=[];try{[A,E]=(0,d.setRunOptions)(u);for(let D=0;Dg.HEAP32[Te++]=xe);const ue=g._OrtCreateTensor(p(U),Z,te,Me,J.length);if(ue===0)throw new Error("Can't create a tensor");x.push(ue)}finally{g.stackRestore(he)}}const L=g.stackSave(),F=g.stackAlloc(4*w),$=g.stackAlloc(4*w),k=g.stackAlloc(4*T),q=g.stackAlloc(4*T);try{let D=F/4,U=$/4,J=k/4,Y=q/4;for(let he=0;hewe*Fe);if(xe=a(ze),xe==="string"){const we=[];let Fe=_e/4;for(let Ue=0;Ue{const e=(0,s.getInstance)(),n=h.get(t);if(!n)throw new Error("invalid session id");const i=n[0],u=e._OrtEndProfiling(i);if(u===0)throw new Error("Can't get an profile file name");e._OrtFree(u)},r.extractTransferableBuffers=t=>{const e=[];for(const n of t){const i=n[2];!Array.isArray(i)&&i.buffer&&e.push(i.buffer)}return e}},6361:function(f,r,c){var d=this&&this.__createBinding||(Object.create?function(u,g,b,y){y===void 0&&(y=b);var _=Object.getOwnPropertyDescriptor(g,b);_&&!("get"in _?!g.__esModule:_.writable||_.configurable)||(_={enumerable:!0,get:function(){return g[b]}}),Object.defineProperty(u,y,_)}:function(u,g,b,y){y===void 0&&(y=b),u[y]=g[b]}),l=this&&this.__setModuleDefault||(Object.create?function(u,g){Object.defineProperty(u,"default",{enumerable:!0,value:g})}:function(u,g){u.default=g}),m=this&&this.__importStar||function(u){if(u&&u.__esModule)return u;var g={};if(u!=null)for(var b in u)b!=="default"&&Object.prototype.hasOwnProperty.call(u,b)&&d(g,u,b);return l(g,u),g},s=this&&this.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0}),r.dispose=r.getInstance=r.initializeWebAssembly=void 0;const h=m(c(6449)),p=s(c(932)),a=c(3474);let o,t=!1,e=!1,n=!1;const i=(u,g)=>g?u?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":u?"ort-wasm-simd.wasm":"ort-wasm.wasm";r.initializeWebAssembly=async u=>{if(t)return Promise.resolve();if(e)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(n)throw new Error("previous call to 'initializeWebAssembly()' failed.");e=!0;const g=u.initTimeout,b=u.numThreads,y=u.simd,_=b>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}})(),v=y&&(()=>{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}})(),w=typeof u.wasmPaths=="string"?u.wasmPaths:void 0,T=i(!1,_),A=i(v,_),E=typeof u.wasmPaths=="object"?u.wasmPaths[A]:void 0;let x=!1;const P=[];if(g>0&&P.push(new Promise(L=>{setTimeout(()=>{x=!0,L()},g)})),P.push(new Promise((L,F)=>{const $=_?a:p.default,k={locateFile:(q,D)=>_&&q.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([c(4154)],{type:"text/javascript"})):q===T?E??(w??D)+A:D+q};if(_)if(typeof Blob>"u")k.mainScriptUrlOrBlob=h.join("/","ort-wasm-threaded.js");else{const q=`var ortWasmThreaded=(function(){var _scriptDir;return ${$.toString()}})();`;k.mainScriptUrlOrBlob=new Blob([q],{type:"text/javascript"})}$(k).then(q=>{e=!1,t=!0,o=q,L()},q=>{e=!1,n=!0,F(q)})})),await Promise.race(P),x)throw new Error(`WebAssembly backend initializing failed due to timeout: ${g}ms`)},r.getInstance=()=>{if(t&&o)return o;throw new Error("WebAssembly is not initialized yet.")},r.dispose=()=>{var u;!t||e||n||(e=!0,(u=o.PThread)===null||u===void 0||u.terminateAllThreads(),o=void 0,e=!1,t=!1,n=!0)}},9710:(f,r,c)=>{c.d(r,{Z:()=>m});var d=c(477),l=c.n(d);function m(){return l()('/*!\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{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(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>>=0;r=n+r-1;for(var i=0;i=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=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>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>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>>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>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>2>>>0],s=i()[e+4>>2>>>0];e+=8;for(var l=0;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.lengtht?-1:0r-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:12t.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;azt(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>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>>0];return(0>t?ut[-t-1]:fe[t]).apply(null,Xt)},qa:function(t){var e=r().length;if((t>>>=0)<=e||4294901760=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>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{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{if(_||0{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(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>>=0;r=n+r-1;for(var i=0;i=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=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>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.lengtht?-1:0r-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:12t.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>>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>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>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>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>2>>>0],u=M[e+4>>2>>>0];e+=8;for(var c=0;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>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{"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{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;tp.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;tt*e));if(a=s(o),"string"===a){const t=[];let e=i/4;for(let n=0;n{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:f=>{f.exports=function(r,c,d,l){var m=self||window;try{try{var s;try{s=new m.Blob([r])}catch{(s=new(m.BlobBuilder||m.WebKitBlobBuilder||m.MozBlobBuilder||m.MSBlobBuilder)).append(r),s=s.getBlob()}var h=m.URL||m.webkitURL,p=h.createObjectURL(s),a=new m[c](p,d);return h.revokeObjectURL(p),a}catch{return new m[c]("data:application/javascript,".concat(encodeURIComponent(r)),d)}}catch{if(!l)throw Error("Inline worker is not supported");return new m[c](l,d)}}},4154:f=>{f.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}}; +`},1670:f=>{f.exports=__WEBPACK_EXTERNAL_MODULE__1670__},7067:()=>{},1296:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(f,r,c)=>{c.r(r),c.d(r,{flatbuffers:()=>d});var d={};d.Offset,d.Table,d.SIZEOF_SHORT=2,d.SIZEOF_INT=4,d.FILE_IDENTIFIER_LENGTH=4,d.SIZE_PREFIX_LENGTH=4,d.Encoding={UTF8_BYTES:1,UTF16_STRING:2},d.int32=new Int32Array(2),d.float32=new Float32Array(d.int32.buffer),d.float64=new Float64Array(d.int32.buffer),d.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,d.Long=function(l,m){this.low=0|l,this.high=0|m},d.Long.create=function(l,m){return l==0&&m==0?d.Long.ZERO:new d.Long(l,m)},d.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},d.Long.prototype.equals=function(l){return this.low==l.low&&this.high==l.high},d.Long.ZERO=new d.Long(0,0),d.Builder=function(l){if(l)m=l;else var m=1024;this.bb=d.ByteBuffer.allocate(m),this.space=m,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},d.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},d.Builder.prototype.forceDefaults=function(l){this.force_defaults=l},d.Builder.prototype.dataBuffer=function(){return this.bb},d.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},d.Builder.prototype.prep=function(l,m){l>this.minalign&&(this.minalign=l);for(var s=1+~(this.bb.capacity()-this.space+m)&l-1;this.space=0&&this.vtable[m]==0;m--);for(var s=m+1;m>=0;m--)this.addInt16(this.vtable[m]!=0?l-this.vtable[m]:0);this.addInt16(l-this.object_start);var h=(s+2)*d.SIZEOF_SHORT;this.addInt16(h);var p=0,a=this.space;e:for(m=0;m=0;a--)this.writeInt8(p.charCodeAt(a))}this.prep(this.minalign,d.SIZEOF_INT+h),this.addOffset(l),h&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},d.Builder.prototype.finishSizePrefixed=function(l,m){this.finish(l,m,!0)},d.Builder.prototype.requiredField=function(l,m){var s=this.bb.capacity()-l,h=s-this.bb.readInt32(s);if(this.bb.readInt16(h+m)==0)throw new Error("FlatBuffers: field "+m+" must be set")},d.Builder.prototype.startVector=function(l,m,s){this.notNested(),this.vector_num_elems=m,this.prep(d.SIZEOF_INT,l*m),this.prep(s,l*m)},d.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},d.Builder.prototype.createString=function(l){if(l instanceof Uint8Array)var m=l;else{m=[];for(var s=0;s=56320?p:(p<<10)+l.charCodeAt(s++)+-56613888)<128?m.push(h):(h<2048?m.push(h>>6&31|192):(h<65536?m.push(h>>12&15|224):m.push(h>>18&7|240,h>>12&63|128),m.push(h>>6&63|128)),m.push(63&h|128))}}this.addInt8(0),this.startVector(1,m.length,1),this.bb.setPosition(this.space-=m.length),s=0;for(var a=this.space,o=this.bb.bytes();s>24},d.ByteBuffer.prototype.readUint8=function(l){return this.bytes_[l]},d.ByteBuffer.prototype.readInt16=function(l){return this.readUint16(l)<<16>>16},d.ByteBuffer.prototype.readUint16=function(l){return this.bytes_[l]|this.bytes_[l+1]<<8},d.ByteBuffer.prototype.readInt32=function(l){return this.bytes_[l]|this.bytes_[l+1]<<8|this.bytes_[l+2]<<16|this.bytes_[l+3]<<24},d.ByteBuffer.prototype.readUint32=function(l){return this.readInt32(l)>>>0},d.ByteBuffer.prototype.readInt64=function(l){return new d.Long(this.readInt32(l),this.readInt32(l+4))},d.ByteBuffer.prototype.readUint64=function(l){return new d.Long(this.readUint32(l),this.readUint32(l+4))},d.ByteBuffer.prototype.readFloat32=function(l){return d.int32[0]=this.readInt32(l),d.float32[0]},d.ByteBuffer.prototype.readFloat64=function(l){return d.int32[d.isLittleEndian?0:1]=this.readInt32(l),d.int32[d.isLittleEndian?1:0]=this.readInt32(l+4),d.float64[0]},d.ByteBuffer.prototype.writeInt8=function(l,m){this.bytes_[l]=m},d.ByteBuffer.prototype.writeUint8=function(l,m){this.bytes_[l]=m},d.ByteBuffer.prototype.writeInt16=function(l,m){this.bytes_[l]=m,this.bytes_[l+1]=m>>8},d.ByteBuffer.prototype.writeUint16=function(l,m){this.bytes_[l]=m,this.bytes_[l+1]=m>>8},d.ByteBuffer.prototype.writeInt32=function(l,m){this.bytes_[l]=m,this.bytes_[l+1]=m>>8,this.bytes_[l+2]=m>>16,this.bytes_[l+3]=m>>24},d.ByteBuffer.prototype.writeUint32=function(l,m){this.bytes_[l]=m,this.bytes_[l+1]=m>>8,this.bytes_[l+2]=m>>16,this.bytes_[l+3]=m>>24},d.ByteBuffer.prototype.writeInt64=function(l,m){this.writeInt32(l,m.low),this.writeInt32(l+4,m.high)},d.ByteBuffer.prototype.writeUint64=function(l,m){this.writeUint32(l,m.low),this.writeUint32(l+4,m.high)},d.ByteBuffer.prototype.writeFloat32=function(l,m){d.float32[0]=m,this.writeInt32(l,d.int32[0])},d.ByteBuffer.prototype.writeFloat64=function(l,m){d.float64[0]=m,this.writeInt32(l,d.int32[d.isLittleEndian?0:1]),this.writeInt32(l+4,d.int32[d.isLittleEndian?1:0])},d.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&a)))}return h},d.ByteBuffer.prototype.__indirect=function(l){return l+this.readInt32(l)},d.ByteBuffer.prototype.__vector=function(l){return l+this.readInt32(l)+d.SIZEOF_INT},d.ByteBuffer.prototype.__vector_len=function(l){return this.readInt32(l+this.readInt32(l))},d.ByteBuffer.prototype.__has_identifier=function(l){if(l.length!=d.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+d.FILE_IDENTIFIER_LENGTH);for(var m=0;m{var r=f&&f.__esModule?()=>f.default:()=>f;return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=(f,r)=>{for(var c in r)__webpack_require__.o(r,c)&&!__webpack_require__.o(f,c)&&Object.defineProperty(f,c,{enumerable:!0,get:r[c]})},__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=(f,r)=>Object.prototype.hasOwnProperty.call(f,r),__webpack_require__.r=f=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(f,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6018);return __webpack_exports__})())}(ortWeb_min)),ortWeb_min.exports}var assetPath={},hasRequiredAssetPath;function requireAssetPath(){if(hasRequiredAssetPath)return assetPath;hasRequiredAssetPath=1,Object.defineProperty(assetPath,"__esModule",{value:!0}),assetPath.baseAssetPath=void 0;const r=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let c="/";return r&&(c=r.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),assetPath.baseAssetPath=c,assetPath}var defaultModelFetcher={},hasRequiredDefaultModelFetcher;function requireDefaultModelFetcher(){if(hasRequiredDefaultModelFetcher)return defaultModelFetcher;hasRequiredDefaultModelFetcher=1,Object.defineProperty(defaultModelFetcher,"__esModule",{value:!0}),defaultModelFetcher.defaultModelFetcher=void 0;const f=r=>fetch(r).then(c=>c.arrayBuffer());return defaultModelFetcher.defaultModelFetcher=f,defaultModelFetcher}var frameProcessor={},logging={},hasRequiredLogging;function requireLogging(){return hasRequiredLogging||(hasRequiredLogging=1,function(f){Object.defineProperty(f,"__esModule",{value:!0}),f.log=f.LOG_PREFIX=void 0,f.LOG_PREFIX="[VAD]";const r=["error","debug","warn"];function c(l){return(...m)=>{console[l](f.LOG_PREFIX,...m)}}const d=r.reduce((l,m)=>(l[m]=c(m),l),{});f.log=d}(logging)),logging}var messages={},hasRequiredMessages;function requireMessages(){if(hasRequiredMessages)return messages;hasRequiredMessages=1,Object.defineProperty(messages,"__esModule",{value:!0}),messages.Message=void 0;var f;return function(r){r.AudioFrame="AUDIO_FRAME",r.SpeechStart="SPEECH_START",r.VADMisfire="VAD_MISFIRE",r.SpeechEnd="SPEECH_END",r.SpeechStop="SPEECH_STOP"}(f||(messages.Message=f={})),messages}var hasRequiredFrameProcessor;function requireFrameProcessor(){if(hasRequiredFrameProcessor)return frameProcessor;hasRequiredFrameProcessor=1,Object.defineProperty(frameProcessor,"__esModule",{value:!0}),frameProcessor.FrameProcessor=frameProcessor.validateOptions=frameProcessor.defaultV5FrameProcessorOptions=frameProcessor.defaultLegacyFrameProcessorOptions=void 0;const f=requireLogging(),r=requireMessages(),c=[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 d(s){c.includes(s.frameSamples)||f.log.warn("You are using an unusual frame size"),(s.positiveSpeechThreshold<0||s.positiveSpeechThreshold>1)&&f.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(s.negativeSpeechThreshold<0||s.negativeSpeechThreshold>s.positiveSpeechThreshold)&&f.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),s.preSpeechPadFrames<0&&f.log.error("preSpeechPadFrames should be positive"),s.redemptionFrames<0&&f.log.error("redemptionFrames should be positive")}frameProcessor.validateOptions=d;const l=s=>{const h=s.reduce((a,o)=>(a.push(a.at(-1)+o.length),a),[0]),p=new Float32Array(h.at(-1));return s.forEach((a,o)=>{const t=h[o];p.set(a,t)}),p};class m{constructor(h,p,a){this.modelProcessFunc=h,this.modelResetFunc=p,this.options=a,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 o=this.audioBuffer;this.audioBuffer=[];const t=this.speaking;this.reset();const e=o.reduce((n,i)=>n+ +i.isSpeech,0);if(t)if(e>=this.options.minSpeechFrames){const n=l(o.map(i=>i.frame));return{msg:r.Message.SpeechEnd,audio:n}}else return{msg:r.Message.VADMisfire};return{}},this.process=async o=>{if(!this.active)return{};const t=await this.modelProcessFunc(o);if(this.audioBuffer.push({frame:o,isSpeech:t.isSpeech>=this.options.positiveSpeechThreshold}),t.isSpeech>=this.options.positiveSpeechThreshold&&this.redemptionCounter&&(this.redemptionCounter=0),t.isSpeech>=this.options.positiveSpeechThreshold&&!this.speaking)return this.speaking=!0,{probs:t,msg:r.Message.SpeechStart,frame:o};if(t.isSpeech=this.options.redemptionFrames){this.redemptionCounter=0,this.speaking=!1;const e=this.audioBuffer;if(this.audioBuffer=[],e.reduce((i,u)=>i+ +u.isSpeech,0)>=this.options.minSpeechFrames){const i=l(e.map(u=>u.frame));return{probs:t,msg:r.Message.SpeechEnd,audio:i,frame:o}}else return{probs:t,msg:r.Message.VADMisfire,frame:o}}if(!this.speaking)for(;this.audioBuffer.length>this.options.preSpeechPadFrames;)this.audioBuffer.shift();return{probs:t,frame:o}},this.audioBuffer=[],this.reset()}}return frameProcessor.FrameProcessor=m,frameProcessor}var nonRealTimeVad={},models={},common={},hasRequiredCommon;function requireCommon(){return hasRequiredCommon||(hasRequiredCommon=1,Object.defineProperty(common,"__esModule",{value:!0})),common}var legacy={},hasRequiredLegacy;function requireLegacy(){if(hasRequiredLegacy)return legacy;hasRequiredLegacy=1;var f;Object.defineProperty(legacy,"__esModule",{value:!0}),legacy.SileroLegacy=void 0;const r=requireLogging();class c{constructor(l,m,s,h,p){this.ortInstance=l,this._session=m,this._h=s,this._c=h,this._sr=p,this.reset_state=()=>{const a=Array(128).fill(0);this._h=new this.ortInstance.Tensor("float32",a,[2,1,64]),this._c=new this.ortInstance.Tensor("float32",a,[2,1,64])},this.process=async a=>{var u;const t={input:new this.ortInstance.Tensor("float32",a,[1,a.length]),h:this._h,c:this._c,sr:this._sr},e=await this._session.run(t);this._h=e.hn,this._c=e.cn;const[n]=(u=e.output)==null?void 0:u.data;return{notSpeech:1-n,isSpeech:n}}}}return legacy.SileroLegacy=c,f=c,c.new=async(d,l)=>{r.log.debug("initializing vad");const m=await l(),s=await d.InferenceSession.create(m),h=new d.Tensor("int64",[16000n]),p=Array(2*64).fill(0),a=new d.Tensor("float32",p,[2,1,64]),o=new d.Tensor("float32",p,[2,1,64]);return r.log.debug("vad is initialized"),new f(d,s,a,o,h)},legacy}var v5={},hasRequiredV5;function requireV5(){if(hasRequiredV5)return v5;hasRequiredV5=1;var f;Object.defineProperty(v5,"__esModule",{value:!0}),v5.SileroV5=void 0;const r=requireLogging();function c(l){const m=Array(256).fill(0);return new l.Tensor("float32",m,[2,1,128])}class d{constructor(m,s,h,p){this._session=m,this._state=s,this._sr=h,this.ortInstance=p,this.reset_state=()=>{this._state=c(this.ortInstance)},this.process=async a=>{var u;const t={input:new this.ortInstance.Tensor("float32",a,[1,a.length]),state:this._state,sr:this._sr},e=await this._session.run(t);this._state=e.stateN;const[n]=(u=e.output)==null?void 0:u.data;return{notSpeech:1-n,isSpeech:n}}}}return v5.SileroV5=d,f=d,d.new=async(l,m)=>{r.log.debug("Loading VAD...");const s=await m(),h=await l.InferenceSession.create(s),p=new l.Tensor("int64",[16000n]),a=c(l);return r.log.debug("...finished loading VAD"),new f(h,a,p,l)},v5}var hasRequiredModels;function requireModels(){return hasRequiredModels||(hasRequiredModels=1,function(f){var r=models.__createBinding||(Object.create?function(m,s,h,p){p===void 0&&(p=h);var a=Object.getOwnPropertyDescriptor(s,h);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[h]}}),Object.defineProperty(m,p,a)}:function(m,s,h,p){p===void 0&&(p=h),m[p]=s[h]}),c=models.__exportStar||function(m,s){for(var h in m)h!=="default"&&!Object.prototype.hasOwnProperty.call(s,h)&&r(s,m,h)};Object.defineProperty(f,"__esModule",{value:!0}),f.SileroV5=f.SileroLegacy=void 0,c(requireCommon(),f);var d=requireLegacy();Object.defineProperty(f,"SileroLegacy",{enumerable:!0,get:function(){return d.SileroLegacy}});var l=requireV5();Object.defineProperty(f,"SileroV5",{enumerable:!0,get:function(){return l.SileroV5}})}(models)),models}var resampler={},hasRequiredResampler;function requireResampler(){if(hasRequiredResampler)return resampler;hasRequiredResampler=1,Object.defineProperty(resampler,"__esModule",{value:!0}),resampler.Resampler=void 0;const f=requireLogging();class r{constructor(d){this.options=d,this.process=l=>{const m=[];for(const s of l)for(this.inputBuffer.push(s);this.hasEnoughDataForFrame();){const h=this.generateOutputFrame();m.push(h)}return m},this.stream=async function*(l){for(const m of l)for(this.inputBuffer.push(m);this.hasEnoughDataForFrame();)yield this.generateOutputFrame()},d.nativeSampleRate<16e3&&f.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 d=new Float32Array(this.options.targetFrameSize);let l=0,m=0;for(;l{const o=await d.SileroLegacy.new(this.ort,this.modelFetcher);this.frameProcessor=new r.FrameProcessor(o.process,o.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*(o,t){const e={nativeSampleRate:t,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples},n=new l.Resampler(e);let i=0,u=0,g=0;for await(const _ of n.stream(o)){const{msg:v,audio:w}=await this.frameProcessor.process(_);switch(v){case c.Message.SpeechStart:i=g*this.options.frameSamples/16;break;case c.Message.SpeechEnd:u=(g+1)*this.options.frameSamples/16,yield{audio:w,start:i,end:u};break}g++}const{msg:b,audio:y}=this.frameProcessor.endSegment();b==c.Message.SpeechEnd&&(yield{audio:y,start:i,end:g*this.options.frameSamples/16})},(0,r.validateOptions)(a)}}f.PlatformAgnosticNonRealTimeVAD=m}(nonRealTimeVad)),nonRealTimeVad}var utils={},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils;hasRequiredUtils=1,Object.defineProperty(utils,"__esModule",{value:!0}),utils.audioFileToArray=utils.encodeWAV=utils.arrayBufferToBase64=utils.minFramesForTargetMS=void 0;function f(h,p,a=16e3){return Math.ceil(h*a/1e3/p)}utils.minFramesForTargetMS=f;function r(h){const p=new Uint8Array(h),a=p.byteLength,o=new Array(a);for(var t=0;t{a.addEventListener("loadend",i=>{const u=a.result;p.decodeAudioData(u,g=>{o=g,p.startRendering().then(b=>{console.log("Rendering completed successfully"),n()}).catch(b=>{console.error(`Rendering failed: ${b}`)})},g=>{console.log(`Error with decoding audio data: ${g}`)})}),a.readAsArrayBuffer(h)}),o===null)throw Error("some shit");let t=o,e=new Float32Array(t.length);for(let n=0;n({...b==="v5"?s.defaultV5FrameProcessorOptions:s.defaultLegacyFrameProcessorOptions,onFrameProcessed:_=>{},onVADMisfire:()=>{h.log.debug("VAD misfire")},onSpeechStart:()=>{h.log.debug("Detected speech start")},onSpeechEnd:()=>{h.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:f.DEFAULT_MODEL,workletOptions:{}});f.getDefaultRealTimeVADOptions=i;class u{static async new(y={}){const _={...(0,f.getDefaultRealTimeVADOptions)(y.model??f.DEFAULT_MODEL),...y};(0,s.validateOptions)(_);let v;_.stream===void 0?v=await navigator.mediaDevices.getUserMedia({audio:{..._.additionalAudioConstraints,channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}):v=_.stream;const w=new AudioContext,T=new MediaStreamAudioSourceNode(w,{mediaStream:v}),A=await g.new(w,_);return A.receive(T),new u(_,w,v,A,T)}constructor(y,_,v,w,T,A=!1){this.options=y,this.audioContext=_,this.stream=v,this.audioNodeVAD=w,this.sourceNode=T,this.listening=A,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(E=>E.stop()),this.sourceNode.disconnect(),this.audioNodeVAD.destroy(),this.audioContext.close()}}}f.MicVAD=u;class g{static async new(y,_={}){const v={...(0,f.getDefaultRealTimeVADOptions)(_.model??f.DEFAULT_MODEL),..._};(0,s.validateOptions)(v),f.ort.env.wasm.wasmPaths=v.onnxWASMBasePath,v.ortConfig!==void 0&&v.ortConfig(f.ort);const w=v.model==="v5"?e:n,T=v.baseAssetPath+w,A=v.model==="v5"?a.SileroV5.new:a.SileroLegacy.new;let E;try{E=await A(f.ort,()=>(0,m.defaultModelFetcher)(T))}catch(L){throw console.error(`Encountered an error while loading model file ${T}`),L}const x=new s.FrameProcessor(E.process,E.reset_state,{frameSamples:v.frameSamples,positiveSpeechThreshold:v.positiveSpeechThreshold,negativeSpeechThreshold:v.negativeSpeechThreshold,redemptionFrames:v.redemptionFrames,preSpeechPadFrames:v.preSpeechPadFrames,minSpeechFrames:v.minSpeechFrames,submitUserSpeechOnPause:v.submitUserSpeechOnPause}),P=new g(y,v,x);return await P.setupAudioNode(),P}constructor(y,_,v){this.ctx=y,this.options=_,this.bufferIndex=0,this.pause=()=>{const w=this.frameProcessor.pause();this.handleFrameProcessorEvent(w)},this.start=()=>{this.frameProcessor.resume()},this.receive=w=>{w.connect(this.audioNode)},this.processFrame=async w=>{const T=await this.frameProcessor.process(w);this.handleFrameProcessorEvent(T)},this.handleFrameProcessorEvent=w=>{switch(w.probs!==void 0&&this.options.onFrameProcessed(w.probs,w.frame),w.msg){case p.Message.SpeechStart:this.options.onSpeechStart();break;case p.Message.VADMisfire:this.options.onVADMisfire();break;case p.Message.SpeechEnd:this.options.onSpeechEnd(w.audio);break}},this.destroy=()=>{var w;this.audioNode instanceof AudioWorkletNode&&this.audioNode.port.postMessage({message:p.Message.SpeechStop}),this.audioNode.disconnect(),(w=this.gainNode)==null||w.disconnect()},this.frameProcessor=v}async setupAudioNode(){if("audioWorklet"in this.ctx&&typeof AudioWorkletNode=="function")try{const w=this.options.baseAssetPath+t;await this.ctx.audioWorklet.addModule(w);const T=this.options.workletOptions??{};T.processorOptions={...T.processorOptions??{},frameSamples:this.options.frameSamples},this.audioNode=new AudioWorkletNode(this.ctx,"vad-helper-worklet",T),this.audioNode.port.onmessage=async A=>{var E;switch((E=A.data)==null?void 0:E.message){case p.Message.AudioFrame:let x=A.data.data;x instanceof ArrayBuffer||(x=new ArrayBuffer(A.data.data.byteLength),new Uint8Array(x).set(new Uint8Array(A.data.data)));const P=new Float32Array(x);await this.processFrame(P);break}};return}catch(w){console.log("AudioWorklet setup failed, falling back to ScriptProcessor",w)}this.resampler=new o.Resampler({nativeSampleRate:this.ctx.sampleRate,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples??480});const _=4096;this.audioNode=this.ctx.createScriptProcessor(_,1,1),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=0;let v=!1;this.audioNode.onaudioprocess=async w=>{if(!v){v=!0;try{const T=w.inputBuffer.getChannelData(0);if(w.outputBuffer.getChannelData(0).fill(0),this.resampler){const E=this.resampler.process(T);for(const x of E)await this.processFrame(x)}}catch(T){console.error("Error processing audio:",T)}finally{v=!1}}},this.audioNode.connect(this.gainNode),this.gainNode.connect(this.ctx.destination)}}f.AudioNodeVAD=g}(realTimeVad)),realTimeVad}var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,function(f){var r=dist.__createBinding||(Object.create?function(n,i,u,g){g===void 0&&(g=u);var b=Object.getOwnPropertyDescriptor(i,u);(!b||("get"in b?!i.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return i[u]}}),Object.defineProperty(n,g,b)}:function(n,i,u,g){g===void 0&&(g=u),n[g]=i[u]}),c=dist.__setModuleDefault||(Object.create?function(n,i){Object.defineProperty(n,"default",{enumerable:!0,value:i})}:function(n,i){n.default=i}),d=dist.__importStar||function(n){if(n&&n.__esModule)return n;var i={};if(n!=null)for(var u in n)u!=="default"&&Object.prototype.hasOwnProperty.call(n,u)&&r(i,n,u);return c(i,n),i};Object.defineProperty(f,"__esModule",{value:!0}),f.NonRealTimeVAD=f.Message=f.FrameProcessor=f.getDefaultRealTimeVADOptions=f.MicVAD=f.DEFAULT_MODEL=f.AudioNodeVAD=f.utils=f.defaultNonRealTimeVADOptions=void 0;const l=d(requireOrtWeb_min()),m=requireAssetPath(),s=requireDefaultModelFetcher(),h=requireFrameProcessor();Object.defineProperty(f,"FrameProcessor",{enumerable:!0,get:function(){return h.FrameProcessor}});const p=requireMessages();Object.defineProperty(f,"Message",{enumerable:!0,get:function(){return p.Message}});const a=requireNonRealTimeVad(),o=requireUtils();f.defaultNonRealTimeVADOptions={modelURL:m.baseAssetPath+"silero_vad_legacy.onnx",modelFetcher:s.defaultModelFetcher};class t extends a.PlatformAgnosticNonRealTimeVAD{static async new(i={}){const{modelURL:u,modelFetcher:g}={...f.defaultNonRealTimeVADOptions,...i};return await this._new(()=>g(u),l,i)}}f.NonRealTimeVAD=t,f.utils={audioFileToArray:o.audioFileToArray,minFramesForTargetMS:o.minFramesForTargetMS,arrayBufferToBase64:o.arrayBufferToBase64,encodeWAV:o.encodeWAV};var e=requireRealTimeVad();Object.defineProperty(f,"AudioNodeVAD",{enumerable:!0,get:function(){return e.AudioNodeVAD}}),Object.defineProperty(f,"DEFAULT_MODEL",{enumerable:!0,get:function(){return e.DEFAULT_MODEL}}),Object.defineProperty(f,"MicVAD",{enumerable:!0,get:function(){return e.MicVAD}}),Object.defineProperty(f,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return e.getDefaultRealTimeVADOptions}})}(dist)),dist}var distExports=requireDist();export{VRMLoaderPlugin as V,VRMAnimationLoaderPlugin as a,VRMUtils as b,createVRMAnimationClip as c,VRMLookAtQuaternionProxy as d,distExports as e};