@sage-rsc/talking-head-react 1.4.9 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +51 -42
- package/package.json +1 -1
- package/src/lib/talkinghead.mjs +36 -43
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("react/jsx-runtime"),v=require("react"),Ge=require("three"),Xe=require("three/addons/controls/OrbitControls.js"),Ze=require("three/addons/loaders/GLTFLoader.js"),je=require("three/addons/loaders/DRACOLoader.js"),Pe=require("three/addons/loaders/FBXLoader.js"),Ye=require("three/addons/environments/RoomEnvironment.js"),Qe=require("three/addons/libs/stats.module.js");var He=typeof document<"u"?document.currentScript:null;function qe(U){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(U){for(const e in U)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(U,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>U[e]})}}return t.default=U,Object.freeze(t)}const y=qe(Ge);let m,le,ce;const H=[0,0,0,0],F=new y.Vector3,ke=new y.Vector3,se=new y.Vector3,we=new y.Vector3;new y.Plane;new y.Ray;new y.Euler;const ae=new y.Quaternion,Be=new y.Quaternion,pe=new y.Matrix4,ge=new y.Matrix4;new y.Vector3;const Ce=new y.Vector3(0,0,1),_e=new y.Vector3(1,0,0),Ke=new y.Vector3(0,1,0),Je=new y.Vector3(0,0,1);class $e{constructor(t=null){this.opt=Object.assign({warmupMs:2e3,sensitivityFactor:1,movementFactor:1,isExcludes:!0,isPivots:!0,isLimits:!0,helperBoneColor1:16711680,helperBoneColor2:16238028,helperLinkColor1:16711680,helperLinkColor2:255,helperExcludesColor:11184895},t||{}),this.scene=null,this.armature=null,this.config=[],this.data=[],this.dict={},this.objectsUpdate=[],this.helpers={isActive:!1,isShowAll:!1,points:{bones:[],pivots:[],object:null},lines:{bones:[],object:null},excludes:{bones:[],deltaLocals:[],radii:[],objects:[]}},this.running=!1,this.timerMs=0}getOptionValue(t){return this.opt[t]}setOptionValue(t,e){this.opt[t]=e,this.helpers.isActive&&this.showHelpers()}getBoneNames(){return this.data.map(t=>t.name)}getValue(t,e){if(this.scene===null)throw new Error("Dynamic bones has not been setup yet.");if(!this.dict.hasOwnProperty(t))throw new Error("Dynamic bone '"+t+"' not found.");const n=this.dict[t];let i;if(e==="type")i=n.type;else if(e==="stiffness")i=n.k.every(s=>s===n.k[0])?n.k[0]:[...n.k];else if(e==="damping")i=n.c.every(s=>s===n.c[0])?n.c[0]:[...n.c];else if(e==="external")i=n.ext<1?n.ext:null;else if(e==="limits")i=n.limits?.map(s=>s===null?null:[...s]);else if(e==="deltaLocal")i=n.dl?[...n.dl]:null;else if(e==="excludes")i=n.excludes?[...n.excludes.map(s=>{const o={bone:s.bone.name.slice(),radius:s.radius};return s.deltaLocal&&(o.deltaLocal=[...s.deltaLocal]),o})]:null;else if(e==="deltaWorld")i=n.dw?[...n.dw]:null;else if(e==="pivot")i=n.pivot;else if(e==="helper")i=n.helper;else throw new Error("Unsupported property '"+e+"'.");return i}setValue(t,e,n){if(this.scene===null)throw new Error("Dynamic bones has not been setup yet.");if(!this.dict.hasOwnProperty(t))throw new Error("Dynamic bone '"+t+"' not found.");const i=this.dict[t];if(e==="type"){if(!n)throw new Error("Parameter 'type' not set.");if(typeof n!="string")throw new Error("Type must be a string.");switch(n){case"point":i.isPoint=!0,i.isX=!0,i.isY=!0,i.isZ=!0,i.isT=!1;break;case"link":i.isPoint=!1,i.isX=!0,i.isY=!1,i.isZ=!0,i.isT=!1;break;case"mix1":i.isPoint=!1,i.isX=!0,i.isY=!0,i.isZ=!0,i.isT=!1;break;case"mix2":i.isPoint=!1,i.isX=!0,i.isY=!1,i.isZ=!0,i.isT=!0;break;case"full":i.isPoint=!1,i.isX=!0,i.isY=!0,i.isZ=!0,i.isT=!0;break;default:throw new Error("Unknown type'"+n+"'.")}i.type=n.slice()}else if(e==="stiffness"){if(!n)throw new Error("Parameter 'stiffness' not set.");if(!Number.isNaN(n)&&n>=0)i.k=Array(4).fill(n);else if(Array.isArray(n)&&n.length===4&&n.every(s=>s>=0))i.k=[...n];else throw new Error("Stiffness must be a non-negative number or an array of four non-negative numbers.")}else if(e==="damping"){if(!n)throw new Error("Parameter 'damping' not set.");if(!Number.isNaN(n)&&n>=0)i.c=Array(4).fill(n);else if(Array.isArray(n)&&n.length===4&&n.every(s=>s>=0))i.c=[...n];else throw new Error("Damping must be a non-negative number or an array of four non-negative numbers.")}else if(e==="external")if(n==null)i.ext=1;else if(!Number.isNaN(n)&&n>=0&&n<=1)i.ext=n;else throw new Error("External (if set) must be a number between [0,1].");else if(e==="limits")if(n==null)i.limits=null;else{if(!Array.isArray(n)||n.length!==4)throw new Error("Limits (if set) must null, or an array of four arrays.");if(!n.every(s=>s===null||Array.isArray(s)&&s.length===2&&(s[0]===null||!Number.isNaN(s[0]))&&(s[1]===null||!Number.isNaN(s))))throw new Error("Limit values must be null or numbers.");i.limits=[n[0]?[...n[0]]:null,n[1]?[...n[1]]:null,n[2]?[...n[2]]:null,n[3]?[...n[3]]:null]}else if(e==="excludes"){if(n==null)i.excludes=null;else{if(!Array.isArray(n))throw new Error("Excludes (if set) must null, or an array.");i.excludes=[],n.forEach((s,o)=>{if(!s.bone)throw new Error("Bone not specified in #"+o+" exclude.");if(typeof s.bone!="string"||s.bone.length===0)throw new Error("Bone name must be a non-empty string in #"+o+" exclude.");const l=this.armature.getObjectByName(s.bone);if(!l)throw new Error("Bone '"+s.bone+"' not found in #"+o+" exclude.");if(Number.isNaN(s.radius)&&s.radius>=0)throw new Error("Radius must be a non-negative number in #"+o+" exclude.");const c={bone:l,radius:s.radius,radiusSq:s.radius*s.radius,deltaLocal:null};if(s.deltaLocal){if(!Array.isArray(s.deltaLocal)||s.deltaLocal.length!==3||s.deltaLocal.some(r=>Number.isNaN(r)))throw new Error("deltaLocal must be an array of three numbers in #"+o+" exclude.");c.deltaLocal=[...s.deltaLocal]}i.excludes.push(c)})}this.showHelpers()}else if(e==="helper"){if(n==null)i.helper=null;else{if(n!==!1&&n!==!0)throw new Error("Helper, if set, must be false or true.");i.helper=n}this.showHelpers()}else if(e==="pivot")if(n==null)i.pivot=null;else{if(n!==!1&&n!==!0)throw new Error("Pivot, if set, must be false or true.");if(n===!0&&i.type===0)throw new Error("Point type bone can't be a pivot.");i.pivot=n}else if(e==="deltaLocal")if(n==null)i.dl=null;else{if(!Array.isArray(n)||n.length!==3)throw new Error("deltaLocal, is set, must be an array of three numbers.");if(!n.every(s=>!Number.isNaN(s)))throw new Error("deltaLocal values must be numbers.");i.dl=[...n]}else if(e==="deltaWorld")if(n==null)i.dw=null;else{if(!Array.isArray(n)||n.length!==3)throw new Error("deltaWorld, is set, must be an array of three values.");if(!n.every(s=>!Number.isNaN(s)))throw new Error("deltaWorld values must be numbers.");i.dw=[...n]}else throw new Error("Unsupported property "+e)}getConfig(){return this.data.map(t=>{const e={bone:t.name.slice()};return["type","stiffness","damping","external","deltaLocal","deltaWorld","limits","excludes","pivot","helper"].forEach(n=>{m=this.getValue(t.name,n),m&&(e[n]=m)}),e})}sortBones(){if(this.scene===null)throw new Error("Dynamic bones has not been setup yet.");let t=0;const e=new WeakMap;this.armature.traverse(o=>{e.has(o)||(e.set(o,t),t++)}),this.data.sort((o,l)=>e.get(o.bone)-e.get(l.bone)),this.data.forEach(o=>{m=this.dict[o.boneParent.name],m&&(m.children||(m.children=[]),m.children.push(o))}),this.objectsUpdate=[];const n=new WeakSet,i=o=>o.parent?.isBone?[o,...i(o.parent)]:[o],s=o=>{i(o).forEach(c=>{n.has(c)||(this.objectsUpdate.push(c),n.add(c))})};this.data.forEach(o=>{s(o.bone),o.excludes&&o.excludes.forEach(l=>{s(l.bone)})}),this.objectsUpdate.sort((o,l)=>e.get(o)-e.get(l))}setup(t,e,n){this.dispose();const i=(s,o)=>{if(!s)throw this.dispose(),new Error(o)};i(t?.isScene,"First parameter must be Scene."),this.scene=t,i(e?.isObject3D,"Second parameter must be the armature Object3D."),this.armature=e,i(Array.isArray(n),"Third parameter must be an array of bone configs."),this.config=n,this.config.forEach((s,o)=>{const l="Config item #"+o+": ";i(s.bone,l+"Bone not specified.");const c=s.bone;i(typeof c=="string"&&c.length>0,l+"Bone name must be a non-empty string.");const r=this.armature.getObjectByName(c);i(r,l+"Bone '"+c+"' not found."),i(r.parent?.isBone,l+"Bone must have a parent bone."),i(this.data.every(a=>a.bone!==r),l+"Bone '"+c+"' already exists."),r.updateMatrixWorld(!0);const u={name:c,bone:r,boneParent:r.parent,vBasis:r.position.clone(),vWorld:r.parent.getWorldPosition(F).clone(),qBasis:r.parent.quaternion.clone(),l:r.position.length(),p:[0,0,0,0],v:[0,0,0,0],a:[0,0,0,0],ev:[0,0,0,0],ea:[0,0,0,0]};u.boneParent.matrixWorld.decompose(F,ae,se),F.copy(Ce).applyQuaternion(ae).setY(0).normalize(),ae.premultiply(Be.setFromUnitVectors(Ce,F).invert()).normalize(),u.qWorldInverseYaw=ae.clone().normalize(),this.data.push(u),this.dict[c]=u;try{this.setValue(c,"type",s.type),this.setValue(c,"stiffness",s.stiffness),this.setValue(c,"damping",s.damping),this.setValue(c,"external",s.external),this.setValue(c,"limits",s.limits),this.setValue(c,"excludes",s.excludes),this.setValue(c,"deltaLocal",s.deltaLocal),this.setValue(c,"deltaWorld",s.deltaWorld),this.setValue(c,"pivot",s.pivot),this.setValue(c,"helper",s.helper)}catch(a){i(!1,l+a)}}),this.sortBones(),this.start()}update(t){if(!this.running)return;let e,n,i,s,o;for(this.timerMs+=t,t>1e3&&(this.timerMs=0),t/=1e3,e=0,i=this.objectsUpdate.length;e<i;e++)o=this.objectsUpdate[e],o.updateMatrix(),o.parent===null?o.matrixWorld.copy(o.matrix):o.matrixWorld.multiplyMatrices(o.parent.matrixWorld,o.matrix),o.matrixWorldNeedsUpdate=!1;for(e=0,i=this.data.length;e<i;e++){if(o=this.data[e],F.copy(o.vWorld),pe.copy(o.boneParent.matrixWorld),ge.copy(pe).invert(),o.vWorld.setFromMatrixPosition(pe),F.applyMatrix4(ge),F.length()>.5&&(console.info("Info: Unrealistic jump of "+F.length().toFixed(2)+" meters."),F.setLength(.5)),F.applyQuaternion(o.bone.quaternion),H[0]=F.x,H[1]=F.y,H[2]=-F.z,H[3]=F.length()/3,o.children)for(n=0,s=o.children.length;n<s;n++)m=o.children[n],H[0]-=m.v[0]*t/3,H[1]-=m.v[1]*t/3,H[2]+=m.v[2]*t/3,H[3]-=m.v[3]*t/3;if(m=this.opt.sensitivityFactor,H[0]*=o.ext*m,H[1]*=o.ext*m,H[2]*=o.ext*m,H[3]*=o.ext*m,o.isX&&(m=H[0]/t,o.ea[0]=(m-o.ev[0])/t,o.ev[0]=m,o.a[0]=-o.k[0]*o.p[0]-o.c[0]*o.v[0]-o.ea[0],o.p[0]+=o.v[0]*t+o.a[0]*t*t/2+H[0],m=o.v[0]+o.a[0]*t/2,m=-o.k[0]*o.p[0]-o.c[0]*m-o.ea[0],o.v[0]=o.v[0]+(m+o.a[0])*t/2),o.isY&&(m=H[1]/t,o.ea[1]=(m-o.ev[1])/t,o.ev[1]=m,o.a[1]=-o.k[1]*o.p[1]-o.c[1]*o.v[1]-o.ea[1],o.p[1]+=o.v[1]*t+o.a[1]*t*t/2+H[1],m=o.v[1]+o.a[1]*t/2,m=-o.k[1]*o.p[1]-o.c[1]*m-o.ea[1],o.v[1]=o.v[1]+(m+o.a[1])*t/2),o.isZ&&(m=H[2]/t,o.ea[2]=(m-o.ev[2])/t,o.ev[2]=m,o.a[2]=-o.k[2]*o.p[2]-o.c[2]*o.v[2]-o.ea[2],o.p[2]+=o.v[2]*t+o.a[2]*t*t/2+H[2],m=o.v[2]+o.a[2]*t/2,m=-o.k[2]*o.p[2]-o.c[2]*m-o.ea[2],o.v[2]=o.v[2]+(m+o.a[2])*t/2),o.isT&&(m=H[3]/t,o.ea[3]=(m-o.ev[3])/t,o.ev[3]=m,o.a[3]=-o.k[3]*o.p[3]-o.c[3]*o.v[3]-o.ea[3],o.p[3]+=o.v[3]*t+o.a[3]*t*t/2+H[3],m=o.v[3]+o.a[3]*t/2,m=-o.k[3]*o.p[3]-o.c[3]*m-o.ea[3],o.v[3]=o.v[3]+(m+o.a[3])*t/2),this.timerMs<this.opt.warmupMs&&(o.v[0]*=1e-4,o.p[0]*=1e-4,o.v[1]*=1e-4,o.p[1]*=1e-4,o.v[2]*=1e-4,o.p[2]*=1e-4,o.v[3]*=1e-4,o.p[3]*=1e-4),H[0]=o.p[0],H[1]=o.p[1],H[2]=o.p[2],H[3]=o.p[3],m=this.opt.movementFactor,H[0]*=m,H[1]*=m,H[2]*=m,H[3]*=m,o.dl&&(m=o.dl,H[0]+=m[0],H[1]+=m[1],H[2]+=m[2]),o.dw&&(m=o.dw,F.set(o.vBasis.x+H[0],o.vBasis.y+H[1],o.vBasis.z+H[2]),F.applyMatrix4(pe),F.x+=m[0],F.y+=m[1],F.z+=m[2],F.applyMatrix4(ge),H[0]+=F.x-o.vBasis.x,H[1]+=F.y-o.vBasis.y,H[2]+=F.z-o.vBasis.z),o.limits&&this.opt.isLimits&&(m=o.limits,m[0]&&(m[0][0]!==null&&H[0]<m[0][0]&&(H[0]=m[0][0]),m[0][1]!==null&&H[0]>m[0][1]&&(H[0]=m[0][1])),m[1]&&(m[1][0]!==null&&H[1]<m[1][0]&&(H[1]=m[1][0]),m[1][1]!==null&&H[1]>m[1][1]&&(H[1]=m[1][1])),m[2]&&(m[2][0]!==null&&H[2]<m[2][0]&&(H[2]=m[2][0]),m[2][1]!==null&&H[2]>m[2][1]&&(H[2]=m[2][1])),m[3]&&(m[3][0]!==null&&H[3]<m[3][0]&&(H[3]=m[3][0]),m[3][1]!==null&&H[3]>m[3][1]&&(H[3]=m[3][1]))),o.isPoint)o.bone.position.set(o.vBasis.x+H[0],o.vBasis.y+H[1],o.vBasis.z-H[2]);else if(o.boneParent.quaternion.copy(o.qBasis),o.pivot&&this.opt.isPivots&&(o.boneParent.updateWorldMatrix(!1,!1),o.boneParent.matrixWorld.decompose(F,ae,se),F.copy(Ce).applyQuaternion(ae).setY(0).normalize(),ae.premultiply(Be.setFromUnitVectors(Ce,F).invert()).normalize(),o.boneParent.quaternion.multiply(ae.invert()),o.boneParent.quaternion.multiply(o.qWorldInverseYaw)),o.isZ&&(m=Math.atan(H[0]/o.l),ae.setFromAxisAngle(Je,-m),o.boneParent.quaternion.multiply(ae)),o.isY&&(m=o.l/3,m=m*Math.tanh(H[1]/m),o.bone.position.setLength(o.l+m)),o.isX&&(m=Math.atan(H[2]/o.l),ae.setFromAxisAngle(_e,-m),o.boneParent.quaternion.multiply(ae)),o.isT&&(m=1.5*Math.tanh(H[3]*1.5),ae.setFromAxisAngle(Ke,-m),o.boneParent.quaternion.multiply(ae)),o.boneParent.updateWorldMatrix(!1,!0),o.excludes&&this.opt.isExcludes)for(n=0,s=o.excludes.length;n<s;n++)m=o.excludes[n],se.set(0,0,0),m.deltaLocal&&(se.x+=m.deltaLocal[0],se.y+=m.deltaLocal[1],se.z+=m.deltaLocal[2]),se.applyMatrix4(m.bone.matrixWorld),ge.copy(o.boneParent.matrixWorld).invert(),se.applyMatrix4(ge),F.copy(o.bone.position),!(F.distanceToSquared(se)>=m.radiusSq)&&(ce=F.length(),le=se.length(),!(le>m.radius+ce)&&(le<Math.abs(m.radius-ce)||(le=(le*le+ce*ce-m.radiusSq)/(2*le),se.normalize(),we.copy(se).multiplyScalar(le),le=Math.sqrt(ce*ce-le*le),F.subVectors(F,we).projectOnPlane(se).normalize().multiplyScalar(le),ke.subVectors(o.vBasis,we).projectOnPlane(se).normalize(),ce=ke.dot(F),ce<0&&(ce=Math.sqrt(le*le-ce*ce),ke.multiplyScalar(ce),F.add(ke)),F.add(we).normalize(),se.copy(o.bone.position).normalize(),ae.setFromUnitVectors(se,F),o.boneParent.quaternion.premultiply(ae),o.boneParent.updateWorldMatrix(!1,!0))))}this.helpers.isActive&&this.updateHelpers()}showHelpers(t){if(this.hideHelpers(),this.helpers.isShowAll=t===void 0?this.helpers.isShowAll:t===!0,m=this.helpers,this.data.forEach(e=>{(this.helpers.isShowAll||e.helper===!0)&&(m.points.bones.push(e.bone),m.points.pivots.push(e.pivot),e.type!==0&&m.lines.bones.push(e.bone),e.excludes&&e.excludes.forEach(n=>{let i=!1;for(let s=0;s<m.excludes.bones.length;s++)if(m.excludes.bones[s]===n.bone&&m.excludes.radii[s]===n.radius&&!(m.excludes.deltaLocals[s]===null&&n.deltaLocal!==null)&&!(m.excludes.deltaLocals[s]!==null&&n.deltaLocal===null)&&!(m.excludes.deltaLocals[s]!==null&&m.excludes.deltaLocals[s].some((o,l)=>o!==n.deltaLocal[l]))){i=!0;break}i||(m.excludes.bones.push(n.bone),m.excludes.radii.push(n.radius),m.excludes.deltaLocals.push(n.deltaLocal?[...n.deltaLocal]:null),m.excludes.objects.push(null))}))}),m=this.helpers.excludes,this.opt.isExcludes&&m.bones.length&&m.bones.forEach((e,n)=>{const i=new y.SphereGeometry(m.radii[n],6,6),s=new y.MeshBasicMaterial({depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0,wireframe:!0,color:this.opt.helperExcludesColor});m.objects[n]=new y.Mesh(i,s),m.objects[n].renderOrder=997,e.add(m.objects[n]),m.deltaLocals[n]&&m.objects[n].position.set(m.deltaLocals[n][0],m.deltaLocals[n][1],m.deltaLocals[n][2])}),m=this.helpers.points,m.bones.length){this.helpers.isActive=!0;const e=new y.BufferGeometry,n=m.bones.map(c=>[0,0,0]).flat();e.setAttribute("position",new y.Float32BufferAttribute(n,3));const i=new y.Color(this.opt.helperBoneColor1),s=new y.Color(this.opt.helperBoneColor2),o=m.pivots.map(c=>c&&this.opt.isPivots?[s.r,s.g,s.b]:[i.r,i.g,i.b]).flat();e.setAttribute("color",new y.Float32BufferAttribute(o,3));const l=new y.PointsMaterial({depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0,size:.2,vertexColors:!0});m.object=new y.Points(e,l),m.object.renderOrder=998,m.object.matrix=this.armature.matrixWorld,m.object.matrixAutoUpdate=!1,this.scene.add(m.object)}if(m=this.helpers.lines,m.bones.length){const e=new y.BufferGeometry,n=m.bones.map(c=>[0,0,0,0,0,0]).flat();e.setAttribute("position",new y.Float32BufferAttribute(n,3));const i=new y.Color(this.opt.helperLinkColor1),s=new y.Color(this.opt.helperLinkColor2),o=m.bones.map(c=>[i.r,i.g,i.b,s.r,s.g,s.b]).flat();e.setAttribute("color",new y.Float32BufferAttribute(o,3));const l=new y.LineBasicMaterial({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});m.object=new y.LineSegments(e,l),m.object.renderOrder=999,m.object.matrix=this.armature.matrixWorld,m.object.matrixAutoUpdate=!1,this.scene.add(m.object)}}updateHelpers(){if(m=this.helpers.points,m.bones.length){ge.copy(this.armature.matrixWorld).invert();const t=m.object.geometry.getAttribute("position");for(let e=0,n=m.bones.length;e<n;e++)pe.multiplyMatrices(ge,m.bones[e].matrixWorld),F.setFromMatrixPosition(pe),t.setXYZ(e,F.x,F.y,F.z);t.needsUpdate=!0,m.object.updateMatrixWorld()}if(m=this.helpers.lines,m.bones.length){ge.copy(this.armature.matrixWorld).invert();const t=m.object.geometry.getAttribute("position");for(let e=0,n=0,i=m.bones.length;e<i;e++,n+=2)pe.multiplyMatrices(ge,m.bones[e].matrixWorld),F.setFromMatrixPosition(pe),t.setXYZ(n,F.x,F.y,F.z),pe.multiplyMatrices(ge,m.bones[e].parent.matrixWorld),F.setFromMatrixPosition(pe),t.setXYZ(n+1,F.x,F.y,F.z);t.needsUpdate=!0,m.object.updateMatrixWorld()}}hideHelpers(){[this.helpers.points,this.helpers.lines].forEach(t=>{t.bones=[],t.object&&(this.scene.remove(t.object),t.object.geometry.dispose(),t.object.material.dispose(),t.object=null)}),m=this.helpers.excludes,m.objects.forEach((t,e)=>{t&&(m.bones[e].remove(t),t.geometry.dispose(),t.material.dispose())}),m.bones=[],m.deltaLocals=[],m.radii=[],m.objects=[],this.helpers.isActive=!1}start(){this.data.length&&(this.running=!0,this.timerMs=0,this.showHelpers())}stop(){this.running=!1,this.hideHelpers();for(let t=0,e=this.data.length;t<e;t++){const n=this.data[t];n.bone.position.copy(n.vBasis),n.boneParent.quaternion.copy(n.qBasis)}}dispose(){this.stop(),this.scene=null,this.armature=null,this.config=[],this.data=[],this.dict={},this.objectsUpdate=[],this.timerMs=0}}class et{constructor(t){this.audioContext=t,this.analyzer=null,this.dataArray=null,this.bufferLength=0}async analyzeAudio(t,e){const n=t.sampleRate,i=t.duration,s=t.getChannelData(0),o=this.extractAudioFeatures(s,n);return this.generateTimingData(o,e,i)}extractAudioFeatures(t,e){const n={energy:[],spectralCentroid:[],zeroCrossingRate:[],mfcc:[],onsets:[],phonemeBoundaries:[]},i=1024,s=512,o=Math.floor((t.length-i)/s)+1;for(let l=0;l<o;l++){const c=l*s,r=Math.min(c+i,t.length),u=t.slice(c,r),a=this.calculateEnergy(u);n.energy.push(a);const d=this.calculateSpectralCentroid(u);n.spectralCentroid.push(d);const h=this.calculateZeroCrossingRate(u);n.zeroCrossingRate.push(h);const g=this.calculateMFCC(u);n.mfcc.push(g)}return n.onsets=this.detectOnsets(n.energy),n.phonemeBoundaries=this.detectPhonemeBoundaries(n),n}calculateEnergy(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return e/t.length}calculateSpectralCentroid(t){const e=this.fft(t);let n=0,i=0;for(let s=0;s<e.length/2;s++){const o=Math.sqrt(e[s*2]*e[s*2]+e[s*2+1]*e[s*2+1]);n+=s*o,i+=o}return i>0?n/i:0}calculateZeroCrossingRate(t){let e=0;for(let n=1;n<t.length;n++)t[n]>=0!=t[n-1]>=0&&e++;return e/(t.length-1)}calculateMFCC(t){const e=this.fft(t),n=[];for(let i=0;i<13;i++){let s=0;for(let o=0;o<e.length/2;o++){const l=Math.sqrt(e[o*2]*e[o*2]+e[o*2+1]*e[o*2+1]);s+=l*Math.cos(Math.PI*i*(o+.5)/(e.length/2))}n.push(s)}return n}fft(t){const e=t.length,n=new Float32Array(e*2);for(let i=0;i<e;i++)n[i*2]=t[i],n[i*2+1]=0;for(let i=1,s=0;i<e;i++){let o=e>>1;for(;s&o;)s^=o,o>>=1;if(s^=o,i<s){const l=n[i*2],c=n[i*2+1];n[i*2]=n[s*2],n[i*2+1]=n[s*2+1],n[s*2]=l,n[s*2+1]=c}}for(let i=2;i<=e;i<<=1){const s=-2*Math.PI/i,o=Math.cos(s),l=Math.sin(s);for(let c=0;c<e;c+=i){let r=1,u=0;for(let a=0;a<i/2;a++){const d=n[(c+a)*2],h=n[(c+a)*2+1],g=n[(c+a+i/2)*2]*r-n[(c+a+i/2)*2+1]*u,x=n[(c+a+i/2)*2]*u+n[(c+a+i/2)*2+1]*r;n[(c+a)*2]=d+g,n[(c+a)*2+1]=h+x,n[(c+a+i/2)*2]=d-g,n[(c+a+i/2)*2+1]=h-x;const f=r*o-u*l,w=r*l+u*o;r=f,u=w}}}return n}detectOnsets(t){const e=[];let s=-.1;for(let o=1;o<t.length;o++){const l=t[o]-t[o-1],c=o*.023;l>.1&&c-s>.1&&(e.push(c),s=c)}return e}detectPhonemeBoundaries(t){const e=[],{energy:n,spectralCentroid:i,zeroCrossingRate:s}=t;for(let o=1;o<n.length;o++){const l=o*.023,c=Math.abs(n[o]-n[o-1]),r=Math.abs(i[o]-i[o-1]),u=Math.abs(s[o]-s[o-1]);c+r*.1+u*.5>.2&&e.push(l)}return e}generateTimingData(t,e,n){const i=e.toLowerCase().split(/\s+/);t.phonemeBoundaries,t.onsets;const s=[];let o=0;for(let c=0;c<i.length;c++){const r=i[c],u=this.estimateWordDuration(r,n/i.length);s.push({word:r,startTime:o,endTime:o+u,duration:u}),o+=u}const l=this.generateVisemeTimings(t,e,n);return{words:s,visemes:l,duration:n,features:t}}estimateWordDuration(t,e){const n=Math.max(.5,Math.min(2,t.length/5)),i=this.getWordComplexity(t);return e*n*i}getWordComplexity(t){const e=(t.match(/[bcdfghjklmnpqrstvwxyz]{2,}/g)||[]).length,n=(t.match(/[aeiou]{2,}/g)||[]).length;return 1+e*.2+n*.1}generateVisemeTimings(t,e,n){const i=[],s=t.phonemeBoundaries;t.onsets;const o=this.textToVisemes(e);let l=0,c=0;for(let r=0;r<s.length&&l<o.length;r++){const u=s[r],a=o[l],d=t.energy[Math.floor(u/.023)]||0,h=this.calculateVisemeDuration(a,d);i.push({viseme:a,startTime:c,endTime:c+h,duration:h,intensity:Math.min(1,d*2)}),c+=h,l++}for(;l<o.length;){const r=o[l],u=this.calculateVisemeDuration(r,.5);i.push({viseme:r,startTime:c,endTime:c+u,duration:u,intensity:.6}),c+=u,l++}return i}textToVisemes(t){const e={a:"aa",e:"E",i:"I",o:"O",u:"U",ae:"aa",ai:"aa",au:"O",ea:"E",ee:"E",ei:"E",ie:"I",oa:"O",oo:"U",ou:"U",b:"PP",p:"PP",m:"PP",f:"FF",v:"FF",th:"SS",s:"SS",z:"SS",sh:"SS",ch:"SS",d:"DD",t:"DD",n:"nn",l:"nn",k:"kk",g:"kk",ng:"kk",r:"RR",w:"RR",y:"I",h:"kk"},n=[],i=t.toLowerCase().replace(/[^a-z\s]/g,"").split(/\s+/);for(const s of i){let o=0;for(;o<s.length;){let l=!1;for(let c=3;c>=2;c--){const r=s.substr(o,c);if(e[r]){n.push(e[r]),o+=c,l=!0;break}}if(!l){const c=s[o];e[c]&&n.push(e[c]),o++}}}return n}calculateVisemeDuration(t,e){const i={aa:.15,E:.12,I:.1,O:.14,U:.13,PP:.08,FF:.1,SS:.12,DD:.11,kk:.09,nn:.1,RR:.11}[t]||.1,s=.5+e*.5;return i*s}}class tt{constructor(){this.rules={A:["[A] =aa"," [ARE] =aa RR"," [AR]O=aa RR","[AR]#=E RR"," ^[AS]#=E SS","[A]WA=aa","[AW]=aa"," :[ANY]=E nn I","[A]^+#=E","#:[ALLY]=aa nn I"," [AL]#=aa nn","[AGAIN]=aa kk E nn","#:[AG]E=I kk","[A]^+:#=aa",":[A]^+ =E","[A]^%=E"," [ARR]=aa RR","[ARR]=aa RR"," :[AR] =aa RR","[AR] =E","[AR]=aa RR","[AIR]=E RR","[AI]=E","[AY]=E","[AU]=aa","#:[AL] =aa nn","#:[ALS] =aa nn SS","[ALK]=aa kk","[AL]^=aa nn"," :[ABLE]=E PP aa nn","[ABLE]=aa PP aa nn","[ANG]+=E nn kk","[A]=aa"],B:[" [BE]^#=PP I","[BEING]=PP I I nn"," [BOTH] =PP O TH"," [BUS]#=PP I SS","[BUIL]=PP I nn","[B]=PP"],C:[" [CH]^=kk","^E[CH]=kk","[CH]=CH"," S[CI]#=SS aa","[CI]A=SS","[CI]O=SS","[CI]EN=SS","[C]+=SS","[CK]=kk","[COM]%=kk aa PP","[C]=kk"],D:["#:[DED] =DD I DD",".E[D] =DD","#^:E[D] =DD"," [DE]^#=DD I"," [DO] =DD U"," [DOES]=DD aa SS"," [DOING]=DD U I nn"," [DOW]=DD aa","[DU]A=kk U","[D]=DD"],E:["#:[E] =","'^:[E] ="," :[E] =I","#[ED] =DD","#:[E]D =","[EV]ER=E FF","[E]^%=I","[ERI]#=I RR I","[ERI]=E RR I","#:[ER]#=E","[ER]#=E RR","[ER]=E"," [EVEN]=I FF E nn","#:[E]W=","@[EW]=U","[EW]=I U","[E]O=I","#:&[ES] =I SS","#:[E]S =","#:[ELY] =nn I","#:[EMENT]=PP E nn DD","[EFUL]=FF U nn","[EE]=I","[EARN]=E nn"," [EAR]^=E","[EAD]=E DD","#:[EA] =I aa","[EA]SU=E","[EA]=I","[EIGH]=E","[EI]=I"," [EYE]=aa","[EY]=I","[EU]=I U","[E]=E"],F:["[FUL]=FF U nn","[F]=FF"],G:["[GIV]=kk I FF"," [G]I^=kk","[GE]T=kk E","SU[GGES]=kk kk E SS","[GG]=kk"," B#[G]=kk","[G]+=kk","[GREAT]=kk RR E DD","#[GH]=","[G]=kk"],H:[" [HAV]=I aa FF"," [HERE]=I I RR"," [HOUR]=aa EE","[HOW]=I aa","[H]#=I","[H]="],I:[" [IN]=I nn"," [I] =aa","[IN]D=aa nn","[IER]=I E","#:R[IED] =I DD","[IED] =aa DD","[IEN]=I E nn","[IE]T=aa E"," :[I]%=aa","[I]%=I","[IE]=I","[I]^+:#=I","[IR]#=aa RR","[IZ]%=aa SS","[IS]%=aa SS","[I]D%=aa","+^[I]^+=I","[I]T%=aa","#^:[I]^+=I","[I]^+=aa","[IR]=E","[IGH]=aa","[ILD]=aa nn DD","[IGN] =aa nn","[IGN]^=aa nn","[IGN]%=aa nn","[IQUE]=I kk","[I]=I"],J:["[J]=kk"],K:[" [K]N=","[K]=kk"],L:["[LO]C#=nn O","L[L]=","#^:[L]%=aa nn","[LEAD]=nn I DD","[L]=nn"],M:["[MOV]=PP U FF","[M]=PP"],N:["E[NG]+=nn kk","[NG]R=nn kk","[NG]#=nn kk","[NGL]%=nn kk aa nn","[NG]=nn","[NK]=nn kk"," [NOW] =nn aa","[N]=nn"],O:["[OF] =aa FF","[OROUGH]=E O","#:[OR] =E","#:[ORS] =E SS","[OR]=aa RR"," [ONE]=FF aa nn","[OW]=O"," [OVER]=O FF E","[OV]=aa FF","[O]^%=O","[O]^EN=O","[O]^I#=O","[OL]D=O nn","[OUGHT]=aa DD","[OUGH]=aa FF"," [OU]=aa","H[OU]S#=aa","[OUS]=aa SS","[OUR]=aa RR","[OULD]=U DD","^[OU]^L=aa","[OUP]=U OO","[OU]=aa","[OY]=O","[OING]=O I nn","[OI]=O","[OOR]=aa RR","[OOK]=U kk","[OOD]=U DD","[OO]=U","[O]E=O","[O] =O","[OA]=O"," [ONLY]=O nn nn I"," [ONCE]=FF aa nn SS","[ON'T]=O nn DD","C[O]N=aa","[O]NG=aa"," ^:[O]N=aa","I[ON]=aa nn","#:[ON] =aa nn","#^[ON]=aa nn","[O]ST =O","[OF]^=aa FF","[OTHER]=aa TH E","[OSS] =aa SS","#^:[OM]=aa PP","[O]=aa"],P:["[PH]=FF","[PEOP]=PP I PP","[POW]=PP aa","[PUT] =PP U DD","[P]=PP"],Q:["[QUAR]=kk FF aa RR","[QU]=kk FF","[Q]=kk"],R:[" [RE]^#=RR I","[R]=RR"],S:["[SH]=SS","#[SION]=SS aa nn","[SOME]=SS aa PP","#[SUR]#=SS E","[SUR]#=SS E","#[SU]#=SS U","#[SSU]#=SS U","#[SED] =SS DD","#[S]#=SS","[SAID]=SS E DD","^[SION]=SS aa nn","[S]S=",".[S] =SS","#:.E[S] =SS","#^:##[S] =SS","#^:#[S] =SS","U[S] =SS"," :#[S] =SS"," [SCH]=SS kk","[S]C+=","#[SM]=SS PP","#[SN]'=SS aa nn","[S]=SS"],T:[" [THE] =TH aa","[TO] =DD U","[THAT] =TH aa DD"," [THIS] =TH I SS"," [THEY]=TH E"," [THERE]=TH E RR","[THER]=TH E","[THEIR]=TH E RR"," [THAN] =TH aa nn"," [THEM] =TH E PP","[THESE] =TH I SS"," [THEN]=TH E nn","[THROUGH]=TH RR U","[THOSE]=TH O SS","[THOUGH] =TH O"," [THUS]=TH aa SS","[TH]=TH","#:[TED] =DD I DD","S[TI]#N=CH","[TI]O=SS","[TI]A=SS","[TIEN]=SS aa nn","[TUR]#=CH E","[TU]A=CH U"," [TWO]=DD U","[T]=DD"],U:[" [UN]I=I U nn"," [UN]=aa nn"," [UPON]=aa PP aa nn","@[UR]#=U RR","[UR]#=I U RR","[UR]=E","[U]^ =aa","[U]^^=aa","[UY]=aa"," G[U]#=","G[U]%=","G[U]#=FF","#N[U]=I U","@[U]=I","[U]=I U"],V:["[VIEW]=FF I U","[V]=FF"],W:[" [WERE]=FF E","[WA]S=FF aa","[WA]T=FF aa","[WHERE]=FF E RR","[WHAT]=FF aa DD","[WHOL]=I O nn","[WHO]=I U","[WH]=FF","[WAR]=FF aa RR","[WOR]^=FF E","[WR]=RR","[W]=FF"],X:[" [X]=SS","[X]=kk SS"],Y:["[YOUNG]=I aa nn"," [YOU]=I U"," [YES]=I E SS"," [Y]=I","#^:[Y] =I","#^:[Y]I=I"," :[Y] =aa"," :[Y]#=aa"," :[Y]^+:#=I"," :[Y]^#=I","[Y]=I"],Z:["[Z]=SS"]};const t={"#":"[AEIOUY]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ED|ING|ELY)","&":"(?:[SCGZXJ]|CH|SH)","@":"(?:[TSRDLZNJ]|TH|CH|SH)","^":"[BCDFGHJKLMNPQRSTVWXZ]","+":"[EIY]",":":"[BCDFGHJKLMNPQRSTVWXZ]*"," ":"\\b"};Object.keys(this.rules).forEach(e=>{this.rules[e]=this.rules[e].map(n=>{const i=n.indexOf("["),s=n.indexOf("]"),o=n.indexOf("="),l=n.substring(0,i),c=n.substring(i+1,s),r=n.substring(s+1,o),u=n.substring(o+1),a={regex:"",move:0,visemes:[]};let d="";d+=[...l].map(g=>t[g]||g).join("");const h=[...c];return h[0]=h[0].toLowerCase(),d+=h.join(""),a.move=h.length,d+=[...r].map(g=>t[g]||g).join(""),a.regex=new RegExp(d),u.length&&u.split(" ").forEach(g=>{a.visemes.push(g)}),a})}),this.visemeDurations={aa:.95,E:.9,I:.92,O:.96,U:.95,PP:1.08,SS:1.23,TH:1,DD:1.05,FF:1,kk:1.21,nn:.88,RR:.88,DD:1.05,sil:1},this.specialDurations={" ":1,",":3,"-":.5,"'":.5},this.digits=["oh","one","two","three","four","five","six","seven","eight","nine"],this.ones=["","one","two","three","four","five","six","seven","eight","nine"],this.tens=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],this.teens=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],this.decades={20:"twenties",30:"thirties",40:"forties",50:"fifties",60:"sixties",70:"seventies",80:"eighties",90:"nineties"},this.ordinals={1:"first",2:"second",3:"third",4:"fourth",5:"fifth",6:"sixth",7:"seventh",8:"eighth",9:"ninth",10:"tenth",11:"eleventh",12:"twelfth",13:"thirteenth",14:"fourteenth",15:"fifteenth",16:"sixteenth",17:"seventeeth",18:"eighteenth",19:"nineteenth",20:"twentieth",30:"thirtieth",40:"fortieth",50:"fiftieth",60:"sixtieth",70:"seventieth",80:"eightieth",90:"ninetieth"},this.symbols={"%":"percent","€":"euros","&":"and","+":"plus",$:"dollars"},this.symbolsReg=/[%€&\+\$]/g}convert_digit_by_digit(t){t=String(t).split("");let e="";for(let n=0;n<t.length;n++)e+=this.digits[t[n]]+" ";return e=e.substring(0,e.length-1),e}convert_sets_of_two(t){let e=String(t).substring(0,2),n=String(t).substring(2,4),i=this.convert_tens(e);return i+=" "+this.convert_tens(n),i}convert_millions(t){return t>=1e6?this.convert_millions(Math.floor(t/1e6))+" million "+this.convert_thousands(t%1e6):this.convert_thousands(t)}convert_thousands(t){return t>=1e3?this.convert_hundreds(Math.floor(t/1e3))+" thousand "+this.convert_hundreds(t%1e3):this.convert_hundreds(t)}convert_hundreds(t){return t>99?this.ones[Math.floor(t/100)]+" hundred "+this.convert_tens(t%100):this.convert_tens(t)}convert_tens(t){return t<10?(Number(t)!=0&&t.toString().startsWith("0")?"oh ":"")+this.ones[Number(t)]:t>=10&&t<20?this.teens[t-10]:(this.tens[Math.floor(t/10)]+" "+this.ones[t%10]).trim()}convertNumberToWords(t,e=!1){const n=parseFloat(t);if(t=="0")return"zero";if(t<0)return" minus "+this.convertNumberToWords(Math.abs(t).toString(),e).trim();if(n&&!Number.isInteger(n)){const i=n.toString().split(".");return this.convertNumberToWords(i[0],e).trim()+" point "+this.convert_digit_by_digit(i[1]).trim()}else return t.toString().startsWith("0")?this.convert_digit_by_digit(t).trim():!e&&(t<1e3&&t>99&&t%100!==0||t>1e4&&t<1e6)?this.convert_digit_by_digit(t).trim():!e&&(t>1e3&&t<2e3||t>2009&&t<3e3)?t%100!=0?this.convert_sets_of_two(t).trim():this.convert_tens(t.toString().substring(0,2)).trim()+" hundred":this.convert_millions(t).trim()}convertDecade(t){const e=parseInt(t),n=!isNaN(e)&&t.length===2,i=!isNaN(e)&&t.length>2&&e>0&&e<=3e3,s=i&&e%1e3===0?Math.floor(e/1e3):null,o=i&&!s?Math.floor(e/100):null,l=n||i?Math.floor(e%100/10)*10:null;let c=[];return s?c.push(this.convertNumberToWords(s).trim(),"thousands"):(o&&c.push(this.convertNumberToWords(o).trim()),l?c.push(this.decades[l]||this.convertNumberToWords(l).trim()+"s"):o?c.push("hundreds"):c.push(t)),c.join(" ")}convertOrdinal(t){if(this.ordinals.hasOwnProperty(t))return this.ordinals[t];const e=Math.floor(t/100),n=Math.floor(t%100/10)*10,i=t%10;let s=[];return e&&(s.push(this.convertNumberToWords(e).trim()),n||i?s.push("hundred"):s.push("hundredth")),n&&(i?s.push(this.convertNumberToWords(n).trim()):s.push(this.ordinals[n])),i&&s.push(this.ordinals[i]),s.join(" ")}preProcessText(t){let e=t.replace('/[#_*":;]/g',"");return e=e.replace(this.symbolsReg,n=>" "+this.symbols[n]+" "),/\d/.test(e)&&(e=e.replace(/\b(\d{2,4})[''']?\s?[sS](?=\s|[.,!?;:]|$)/g,(n,i)=>{const s=this.convertDecade(i);return s===i?n:s}),e=e.replace(/\b(\d+)\s*(st|nd|rd|th)(?=\s|[.,!?;:]|$)/gi,(n,i)=>this.convertOrdinal(Number(i))),e=e.replace(/\b(\w*?)(\d+)([A-Za-z]+)\b/g,(n,i,s,o)=>{const l=this.convertNumberToWords(s);return`${i}${l} ${o}`}).replace(/\b([A-Za-z]+)(\d+)(\w*?)\b/g,(n,i,s,o)=>{const l=this.convertNumberToWords(s);return`${i} ${l}${o}`}),e=e.replace(/-?(?:\d{1,3}(?:,\d{3})+|\d+)(\.\d+)?/g,(n,i)=>{let s=n,o=!1;return/,/.test(s)&&(s=s.replace(/,/g,""),o=!0),i&&(o=!0),this.convertNumberToWords(s,o)})),e=e.replace(/(\D)\1\1+/g,"$1$1").replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC").trim(),e}wordsToVisemes(t){let e={words:t.toUpperCase(),visemes:[],times:[],durations:[],i:0},n=0;const i=[...e.words];for(;e.i<i.length;){const s=i[e.i],o=this.rules[s];if(o)for(let l=0;l<o.length;l++){const c=o[l];if((e.words.substring(0,e.i)+s.toLowerCase()+e.words.substring(e.i+1)).match(c.regex)){c.visemes.forEach(a=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===a){const d=.7*(this.visemeDurations[a]||1);e.durations[e.durations.length-1]+=d,n+=d}else{const d=this.visemeDurations[a]||1;e.visemes.push(a),e.times.push(n),e.durations.push(d),n+=d}}),e.i+=c.move;break}}else e.i++,n+=this.specialDurations[s]||0}return e}}const nt=Object.freeze(Object.defineProperty({__proto__:null,LipsyncEn:tt},Symbol.toStringTag,{value:"Module"}));class it{constructor(){this.rules={A:["[AH]=aa","[AU]=aa U","[AI]=aa I","[AE]=E","[A]H=aa","[A]U=aa U","[A]I=aa I"," [AN] =aa nn"," [AM] =aa PP","[ARR]=aa RR","[AR]=aa RR"," [ALS]=aa nn SS","[AL]=aa nn","[AUCH]=aa U kk","[ABER]=aa PP E RR","[A]=aa"],Ä:["[Ä]H=E","[ÄU]=O","[Ä]=E"],B:["[B]=PP"],C:["[CH]S=kk SS","[CH]=kk"," [CH]=kk","#[CH]=kk","[CK]=kk","[C]H=kk","[C]=kk"],D:[" [DAS] =DD aa SS"," [DEN] =DD E nn"," [DER] =DD E RR"," [DIE] =DD I"," [DU] =DD U"," [DURCH]=DD U RR kk","[D]=DD"],E:["[EI]=aa I","[EU]=O","[EH]=E"," [ER] =E RR"," [ES] =E SS"," [EIN] =aa I nn"," [EINE]=aa I nn aa","[ER]#=E","[ER]=E RR","[EN]#=aa nn","[E]=E"],F:["[F]=FF"],G:["[G]=kk"],H:[" [HAT] =I aa DD"," [HABEN]=I aa PP aa nn"," [HIER]=I I RR"," [HEUTE]=I O DD aa","[H]="],I:[" [ICH] =I kk"," [IHR] =I RR"," [IN] =I nn"," [IST] =I SS DD"," [IM] =I PP","[IE]=I","[IH]=I","[I]=I"],J:["[J]=I"],K:["[K]=kk"],L:["[L]=nn"],M:[" [MIT] =PP I DD"," [MAN] =PP aa nn"," [MEHR]=PP E RR"," [MICH]=PP I kk","[M]=PP"],N:[" [NICHT]=nn I kk DD"," [NUR] =nn U RR"," [NACH]=nn aa kk"," [NOCH]=nn aa kk","[NG]=nn kk","[N]=nn"],O:["[OO]=U","[OH]=O","[OU]=aa U"," [ODER]=O DD E RR"," [OHNE]=O nn aa","[Ö]=E","[O]=aa"],Ö:["[ÖH]=E","[Ö]=E"],P:["[PF]=FF FF","[PH]=FF","[P]=PP"],Q:["[QU]=kk FF","[Q]=kk"],R:["[R]=RR"],S:["[SCH]=SS","[SP]=SS PP","[ST]=SS DD","[SS]=SS","[S]=SS"],ß:["[ß]=SS"],T:["[TZ]=DD SS","[TH]=DD","[T]=DD"],U:[" [UND] =U nn DD"," [UM] =U PP"," [UNTER]=U nn DD E RR"," [UNS] =U nn SS","[UH]=U","[ÜH]=I U","[Ü]=I U","[U]=U"],Ü:["[ÜH]=I U","[Ü]=I U"],V:[" [VON] =FF aa nn"," [VOR] =FF aa RR"," [VIEL]=FF I nn","[V]=FF"],W:[" [WAS] =FF aa SS"," [WIR] =FF I RR"," [WIE] =FF I"," [WENN]=FF E nn"," [WILL]=FF I nn"," [WO] =FF aa"," [WIEDER]=FF I DD E RR","[W]=FF"],X:["[X]=kk SS"],Y:["[Y]=I"],Z:[" [ZU] =DD SS U"," [ZUM] =DD SS U PP"," [ZUR] =DD SS U RR"," [ZEIT]=DD SS aa I DD","[Z]=DD SS"]};const t={"#":"[AEIOUÄÖÜ]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ED|ING|ELY|EN|TE|ST)","&":"(?:[SCGZXJ]|CH|SCH|TZ)","@":"(?:[TSRDLZNJ]|TH|CH|SCH)","^":"[BCDFGHJKLMNPQRSTVWXYZß]","+":"[EIY]",":":"[BCDFGHJKLMNPQRSTVWXYZß]*"," ":"\\b"};Object.keys(this.rules).forEach(e=>{this.rules[e]=this.rules[e].map(n=>{const i=n.indexOf("["),s=n.indexOf("]"),o=n.indexOf("="),l=n.substring(0,i),c=n.substring(i+1,s),r=n.substring(s+1,o),u=n.substring(o+1),a={regex:"",move:0,visemes:[]};let d="";d+=[...l].map(g=>t[g]||g).join("");const h=[...c];return h[0]=h[0].toLowerCase(),d+=h.join(""),a.move=h.length,d+=[...r].map(g=>t[g]||g).join(""),a.regex=new RegExp(d),u.length&&u.split(" ").forEach(g=>{a.visemes.push(g)}),a})}),this.visemeDurations={aa:1,E:.85,I:.9,O:1.05,U:1,PP:1.15,SS:1.2,TH:1,DD:1.1,FF:1.05,kk:1.25,nn:.85,RR:.9,sil:1},this.specialDurations={" ":1,",":3,"-":.5,"'":.5,".":4,"!":3,"?":3},this.digits=["null","eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun"],this.ones=["","ein","zwei","drei","vier","fünf","sechs","sieben","acht","neun"],this.tens=["","","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"],this.teens=["zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn"],this.symbols={"%":"prozent","€":"euro","&":"und","+":"plus",$:"dollar","=":"gleich","@":"at","#":"hashtag"},this.symbolsReg=/[%€&\+\$=@#]/g}convert_digit_by_digit(t){t=String(t).split("");let e="";for(let n=0;n<t.length;n++)e+=this.digits[t[n]]+" ";return e=e.substring(0,e.length-1),e}convert_millions(t){if(t>=1e6){const e=Math.floor(t/1e6),n=t%1e6;let i=this.convert_thousands(e);return i+=e===1?" million ":" millionen ",n>0&&(i+=this.convert_thousands(n)),i}else return this.convert_thousands(t)}convert_thousands(t){if(t>=1e3){const e=Math.floor(t/1e3),n=t%1e3;let i="";return e===1?i="eintausend":i=this.convert_hundreds(e)+"tausend",n>0&&(i+=this.convert_hundreds(n)),i}else return this.convert_hundreds(t)}convert_hundreds(t){if(t>99){const e=Math.floor(t/100),n=t%100;let i="";return e===1?i="einhundert":i=this.ones[e]+"hundert",n>0&&(i+=this.convert_tens(n)),i}else return this.convert_tens(t)}convert_tens(t){if(t<10)return this.ones[Number(t)]||"";if(t>=10&&t<20)return this.teens[t-10];{const e=Math.floor(t/10),n=t%10;return n===0?this.tens[e]:this.ones[n]+"und"+this.tens[e]}}convertNumberToWords(t){const e=String(t);return t=="0"?"null":e.startsWith("0")?this.convert_digit_by_digit(t):e.length===4&&(t<1e3||t>2100)?this.convert_digit_by_digit(t):this.convert_millions(Number(t))}preProcessText(t){return t.replace(/[#_*\":;]/g,"").replace(this.symbolsReg,e=>" "+this.symbols[e]+" ").replace(/(\d)\.(\d)/g,"$1 komma $2").replace(/(\d),(\d)/g,"$1 komma $2").replace(/\d+/g,this.convertNumberToWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replace(/\s+/g," ").toLowerCase().trim()}wordsToVisemes(t){let e={words:t.toUpperCase(),visemes:[],times:[],durations:[],i:0},n=0;const i=[...e.words];for(;e.i<i.length;){const s=i[e.i],o=this.rules[s];if(o){let l=!1;for(let c=0;c<o.length;c++){const r=o[c];if((e.words.substring(0,e.i)+s.toLowerCase()+e.words.substring(e.i+1)).match(r.regex)){r.visemes.forEach(d=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===d){const h=.7*(this.visemeDurations[d]||1);e.durations[e.durations.length-1]+=h,n+=h}else{const h=this.visemeDurations[d]||1;e.visemes.push(d),e.times.push(n),e.durations.push(h),n+=h}}),e.i+=r.move,l=!0;break}}l||(e.i++,n+=this.specialDurations[s]||0)}else e.i++,n+=this.specialDurations[s]||0}return e}}const ot=Object.freeze(Object.defineProperty({__proto__:null,LipsyncDe:it},Symbol.toStringTag,{value:"Module"}));class st{constructor(){this.rules={A:["[AN]C=aa nn","[AN]G=aa nn","[AN]T=aa nn","[AN]D=aa nn","[AN] =aa nn","[AN]$=aa nn","[AM]P=aa nn","[AM]B=aa nn","[AM] =aa nn","[AM]$=aa nn","[AI]N=E nn","[AIM]=E nn","[AIN]=E nn","[AU]=O","[AUX]=O","[AUT]=O","[AI]=E","[AY]=E","[A]=aa"],À:["[À]=aa"],Â:["[Â]=aa"],B:[" [B] =PP","[BB]=PP","[B]=PP"],C:["[C]E=SS","[C]I=SS","[C]Y=SS","[C]È=SS","[C]É=SS","[C]Ê=SS","[CH]=SS","[C]A=kk","[C]O=kk","[C]U=kk","[C]L=kk","[C]R=kk","[CK]=kk","[C]=kk"],Ç:["[Ç]=SS"],D:["[D]=DD"],E:["[EN]C=aa nn","[EN]T=aa nn","[EN]D=aa nn","[EN] =aa nn","[EN]$=aa nn","[EM]P=aa nn","[EM]B=aa nn","[EM] =aa nn","[EM]$=aa nn","[EAU]=O","[EAU]X=O","[EU]=U","[EUX]=U","[EUR]=U RR","[EI]=E","[EIN]=E nn","[ER] =E","[ER]$=E","[EZ] =E","[EZ]$=E","[ED] =E","[ED]$=E"," [E] =","[E] =","[E]$=","[E]S =","[E]S$=","[E]NT =","[E]NT$=","[È]=E","[É]=E","[Ê]=E","[Ë]=E","[E]=E"],È:["[È]=E"],É:["[É]=E"],Ê:["[Ê]=E"],Ë:["[Ë]=E"],F:["[FF]=FF","[F]=FF","[PH]=FF"],G:["[G]E=SS","[G]I=SS","[G]Y=SS","[G]È=SS","[G]É=SS","[G]Ê=SS","[GN]=nn I","[GN]E=nn","[GN]A=nn aa","[GN]O=nn O","[GU]E=kk","[GU]I=kk","[GU]A=kk FF aa","[GU]O=kk FF O","[G]A=kk","[G]O=kk","[G]U=kk","[G]L=kk","[G]R=kk","[GG]=kk","[G]=kk"],H:["[H]="],I:["[IN]C=E nn","[IN]T=E nn","[IN]D=E nn","[IN] =E nn","[IN]$=E nn","[IM]P=E nn","[IM]B=E nn","[IM] =E nn","[IM]$=E nn","[IEN]=I E nn","[IER]=I E","[IEU]=I U","[IEZ]=I E","[ILL]E=I","[ILLE]=I","[ILL]=I","[Î]=I","[Ï]=I","[I]=I"],Î:["[Î]=I"],Ï:["[Ï]=I"],J:["[J]=SS"],K:["[K]=kk"],L:["[LL]E=","[LLE]=","[LL]A=I aa","[LL]O=I O","[LL]U=I U","[LL]I=I","[LL]=I","[L]=nn"],M:["[MM]=PP","[M]=PP"],N:["[NN]=nn","[N]=nn"],O:["[ON]C=O nn","[ON]T=O nn","[ON]D=O nn","[ON] =O nn","[ON]$=O nn","[OM]P=O nn","[OM]B=O nn","[OM] =O nn","[OM]$=O nn","[OI]N=FF E nn","[OI]G=FF aa","[OI]S=FF aa","[OI]T=FF aa","[OI]X=FF aa","[OI]=FF aa","[OU]=U","[OÙ]=U","[OÛ]=U","[OEU]=U","[OEUR]=U RR","[OUGH]=U FF","[OUGH]T=U","[Ô]=O","[O]=O"],Ô:["[Ô]=O"],Ù:["[Ù]=U"],Û:["[Û]=U"],P:["[PH]=FF","[PP]=PP","[P]=PP"],Q:["[QU]=kk","[Q]=kk"],R:["[RR]=RR","[R]=RR"],S:["#[S]#=SS"," [S]=SS","[SS]=SS","[S] =","[S]$=","[SC]E=SS","[SC]I=SS","[SC]Y=SS","[S]=SS"],T:["[TI]A=SS I aa","[TI]E=SS I E","[TI]O=SS I O","[TI]ON=SS I O nn","[TH]=DD","[TT]=DD","[T] =","[T]$=","[T]=DD"],U:["[UN]C=U nn","[UN]T=U nn","[UN]D=U nn","[UN] =U nn","[UN]$=U nn","[UM]=U nn","[UE]=I","[UEI]=I E","[UEIL]=I I","[UILL]=I","[Ù]=U","[Û]=U","[Ü]=I U","[U]=I U"],Ü:["[Ü]=I U"],V:["[V]=FF"],W:["[W]=FF"],X:["[X] =","[X]$=","#[X]#=kk SS"," [X]=kk SS","[X]=kk SS"],Y:["[Y]=I"," [Y]=I","[YE]=I E","[YA]=I aa","[YO]=I O","[YU]=I U"],Z:["[Z]=SS"]};const t={"#":"[AEIOUYÀÂÈÉÊËÎÏÔÙÛÜ]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ÉS|ÈS|ÊS|ENT|MENT|TION|SION)","&":"(?:[SCGZXJ]|CH|SH|GN)","@":"(?:[TSRDLZNJ]|TH|CH|SH|GN)","^":"[BCDFGHJKLMNPQRSTVWXZÇ]+","+":"[EIYÈÉÊËÎÏ]",":":"[BCDFGHJKLMNPQRSTVWXZÇ]*"," ":"\\b",$:"$"};Object.keys(this.rules).forEach(e=>{this.rules[e]=this.rules[e].map(n=>{const i=n.indexOf("["),s=n.indexOf("]"),o=n.indexOf("="),l=n.substring(0,i),c=n.substring(i+1,s),r=n.substring(s+1,o),u=n.substring(o+1),a={regex:"",move:0,visemes:[]};let d="";d+=[...l].map(g=>t[g]||g).join("");const h=[...c];return h[0]=h[0].toLowerCase(),d+=h.join(""),a.move=h.length,d+=[...r].map(g=>t[g]||g).join(""),a.regex=new RegExp(d,"i"),u.length&&u.split(" ").forEach(g=>{g&&a.visemes.push(g)}),a})}),this.visemeDurations={aa:1,E:.95,I:.9,O:1.05,U:.95,PP:1.1,SS:1.25,TH:1,DD:1.05,FF:1,kk:1.2,nn:.88,RR:1.15,sil:1},this.specialDurations={" ":1,",":2.5,".":3.5,";":2.8,":":2.2,"!":3.2,"?":3.2,"-":.8,"'":.3,'"':.3,"(":1.5,")":1.5},this.digits=["zéro","un","deux","trois","quatre","cinq","six","sept","huit","neuf"],this.ones=["","un","deux","trois","quatre","cinq","six","sept","huit","neuf"],this.teens=["dix","onze","douze","treize","quatorze","quinze","seize","dix-sept","dix-huit","dix-neuf"],this.tens=["","dix","vingt","trente","quarante","cinquante","soixante","soixante-dix","quatre-vingts","quatre-vingt-dix"],this.symbols={"%":"pourcent","€":"euros","&":"et","+":"plus",$:"dollars","=":"égale","@":"arobase","#":"dièse","°":"degrés"},this.symbolsReg=/[%€&\+\$=@#°]/g}convert_digit_by_digit(t){t=String(t).split("");let e="";for(let n=0;n<t.length;n++)e+=this.digits[t[n]]+" ";return e=e.substring(0,e.length-1),e}convert_tens(t){if(t<10)return this.ones[t]||"";if(t>=10&&t<20)return this.teens[t-10];if(t>=70&&t<80){const e=t-60;return e===11?"soixante et onze":"soixante-"+this.teens[e-10]}else if(t>=90){const e=t-80;return e===11?"quatre-vingt-onze":"quatre-vingt-"+this.teens[e-10]}else{const e=Math.floor(t/10),n=t%10;return e===8&&n===0?"quatre-vingts":e===8?"quatre-vingt-"+this.ones[n]:(e===2||e===3||e===4||e===5||e===6)&&n===1?this.tens[e]+" et un":n===0?this.tens[e]:this.tens[e]+"-"+this.ones[n]}}convert_hundreds(t){if(t>=100){const e=Math.floor(t/100),n=t%100;let i="";return e===1?i="cent":(i=this.ones[e]+" cent",n===0&&(i+="s")),n>0&&(i+=" "+this.convert_tens(n)),i}else return this.convert_tens(t)}convert_thousands(t){if(t>=1e3){const e=Math.floor(t/1e3),n=t%1e3;let i="";return e===1?i="mille":i=this.convert_hundreds(e)+" mille",n>0&&(i+=" "+this.convert_hundreds(n)),i}else return this.convert_hundreds(t)}convert_millions(t){if(t>=1e6){const e=Math.floor(t/1e6),n=t%1e6;let i="";return e===1?i="un million":i=this.convert_hundreds(e)+" millions",n>0&&(i+=" "+this.convert_thousands(n)),i}else return this.convert_thousands(t)}convertNumberToWords(t){const e=String(t);return t==="0"||t===0?"zéro":e.startsWith("0")?this.convert_digit_by_digit(t):this.convert_millions(Number(t))}preProcessText(t){return t.replace(/[#_*\":;]/g,"").replace(this.symbolsReg,e=>" "+this.symbols[e]+" ").replace(/(\d)[,.](\d)/g,"$1 virgule $2").replace(/\d+/g,this.convertNumberToWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replace(/\s+/g," ").replace(/'/g,"'").trim()}wordsToVisemes(t){let e={words:t.toUpperCase(),visemes:[],times:[],durations:[],i:0},n=0;const i=[...e.words];for(;e.i<i.length;){const s=i[e.i],o=this.rules[s];if(o){let l=!1;for(let c=0;c<o.length;c++){const r=o[c];if((e.words.substring(0,e.i)+s.toLowerCase()+e.words.substring(e.i+1)).match(r.regex)){r.visemes.forEach(d=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===d){const h=.7*(this.visemeDurations[d]||1);e.durations[e.durations.length-1]+=h,n+=h}else{const h=this.visemeDurations[d]||1;e.visemes.push(d),e.times.push(n),e.durations.push(h),n+=h}}),e.i+=r.move,l=!0;break}}l||(e.i++,n+=this.specialDurations[s]||0)}else e.i++,n+=this.specialDurations[s]||0}return e}}const at=Object.freeze(Object.defineProperty({__proto__:null,LipsyncFr:st},Symbol.toStringTag,{value:"Module"}));class rt{constructor(){this.visemes={a:"aa",e:"E",i:"I",o:"O",u:"U",y:"U",ä:"aa",ö:"O",å:"O",b:"PP",c:"SS",d:"DD",f:"FF",g:"kk",h:"kk",j:"I",k:"kk",l:"nn",m:"PP",n:"nn",p:"PP",q:"kk",r:"RR",s:"SS",t:"DD",v:"FF",w:"FF",x:"SS",z:"SS"},this.visemeDurations={aa:.95,E:.9,I:.92,O:.96,U:.95,PP:1.08,SS:1.23,DD:1.05,FF:1,kk:1.21,nn:.88,RR:.88,DD:1.05,sil:1},this.specialDurations={" ":1,",":3,"-":.5},this.numbers=["nolla","yksi","kaksi","kolme","neljä","viisi","kuusi","seitsemän","kahdeksan","yhdeksän","kymmenen","yksitoista","kaksitoista","kolmetoista","neljätoista","viisitoista","kuusitoista","seitsemäntoista","kahdeksantoista","yhdeksäntoista"],this.symbols={"%":"prosenttia","€":"euroa","&":"ja","+":"plus",$:"dollaria"},this.symbolsReg=/[%€&\+\$]/g}numberToFinnishWords(t){const e=[];let n=parseFloat(t);if(n===void 0)return t;let i=(s,o,l,c,r)=>{if(s<o)return s;const u=Math.floor(s/o);return e.push(l+(u===1?c:this.numberToFinnishWords(u.toString())+r)),s-u*o};if(n<0&&(e.push("miinus "),n=Math.abs(n)),n=i(n,1e9," ","miljardi"," miljardia"),n=i(n,1e6," ","miljoona"," miljoonaa"),n=i(n,1e3,"","tuhat","tuhatta"),n=i(n,100," ","sata","sataa"),n>20&&(n=i(n,10,"","","kymmentä")),n>=1){let s=Math.floor(n);e.push(this.numbers[s]),n-=s}if(n>=0&&Math.abs(parseFloat(t))<1&&e.push("nolla"),n>0){let s=t.split(".");if(s.length>1){e.push(" pilkku");let o=[...s[s.length-1]];for(let l=0;l<o.length;l++)e.push(" "+this.numbers[o[l]])}}return e.join("").trim()}preProcessText(t){return t.replace(/[#_*\'\":;]/g,"").replace(this.symbolsReg,e=>" "+this.symbols[e]+" ").replace(/(\d)\,(\d)/g,"$1 pilkku $2").replace(/\d+/g,this.numberToFinnishWords.bind(this)).replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u0307\u0309\u030b-\u036f]/g,"").normalize("NFC").trim()}wordsToVisemes(t){let e={words:t,visemes:[],times:[],durations:[]},n=0;const i=[...t];for(let s=0;s<i.length;s++){const o=this.visemes[i[s].toLowerCase()];if(o)if(e.visemes.length&&e.visemes[e.visemes.length-1]===o){const l=.7*(this.visemeDurations[o]||1);e.durations[e.durations.length-1]+=l,n+=l}else{const l=this.visemeDurations[o]||1;e.visemes.push(o),e.times.push(n),e.durations.push(l),n+=l}else n+=this.specialDurations[i[s]]||0}return e}}const lt=Object.freeze(Object.defineProperty({__proto__:null,LipsyncFi:rt},Symbol.toStringTag,{value:"Module"}));class ut{constructor(){this.visemes={a:"aa",ą:"O",e:"E",ę:"E",ė:"E",i:"I",į:"I",o:"O",u:"U",ū:"U",ų:"U",y:"I",b:"PP",c:"SS",č:"SS",d:"DD",f:"FF",g:"kk",h:"kk",j:"I",k:"kk",l:"nn",m:"PP",n:"nn",p:"PP",q:"kk",r:"RR",s:"SS",š:"CH",t:"DD",v:"FF",w:"FF",x:"SS",z:"SS",ž:"SS"},this.durations={a:.95,ą:1.5,e:.9,ę:1.5,ė:1.5,i:.92,į:1.5,o:.96,u:.95,ū:1.5,ų:1.5,y:1.5,b:1.08,c:1.23,d:1.05,f:1,g:1.21,h:1.21,j:.92,k:1.21,l:.88,m:1.08,n:.88,p:1.08,q:1.21,r:.88,s:1.23,š:1.23,t:1.05,v:1,w:1,x:1.23,z:1.23,ž:1.23},this.pauses={" ":1,",":3,"-":.5},this.numbers=["nulis","vienas","du","trys","keturi","penki","šeši","septyni","aštuoni","devyni","dešimt","vienuolika","dvylika","trylika","keturiolika","penkiolika","šešiolika","septyniolika","aštuoniolika","devyniolika"],this.tens=[this.numbers[0],this.numbers[10],"dvidešimt","trisdešimt","keturiasdešimt","penkiasdešimt","šešiasdešimt","septyniasdešimt","aštuoniasdešimt","devyniasdešimt"]}numberToLithuanianWords(t){const e=[];let n=parseFloat(t);if(n===void 0)return t;let i=(s,o,l,c,r)=>{if(s<o)return s;const u=Math.floor(s/o);return u===1?e.push(this.numbers[1]):e.push(this.numberToLithuanianWords(u.toString())),u%10===1?e.push(l):u%10===0||u%100>10&&u%100<20?e.push(r):e.push(c),s-u*o};n<0&&(e.push("minus"),n=Math.abs(n)),n=i(n,1e9,"milijardas","milijardai","milijardų"),n=i(n,1e6,"milijonas","milijonai","milijonų"),n=i(n,1e3,"tūkstantis","tūkstančiai","tūkstančių"),n=i(n,100,"šimtas","šimtai","šimtų");for(let s=this.tens.length-1;s>=1;s--)if(n>=10*s){e.push(this.tens[s]),n=n-10*s;break}if(n>=1){let s=Math.floor(n);e.push(this.numbers[s]),n-=s}if(n>=0&&Math.abs(parseFloat(t))<1&&e.push(this.numbers[0]),n>0){let s=t.split(".");if(s.length>1){e.push("kablelis");let o=[...s[s.length-1]];for(let l=0;l<o.length;l++)e.push(this.numbers[o[l]])}}return e.join(" ").trim()}preProcessText(t){return t.replace(`/[#_*'":;]/g`,"").replaceAll("0 %","0 procentų ").replaceAll("1 %","1 procentas ").replaceAll("%"," procentai ").replaceAll("0 €","0 eurų ").replaceAll("1 €","1 euras ").replaceAll("€"," eurai ").replaceAll("0 $","0 dolerių ").replaceAll("1 $","1 doleris ").replaceAll("$"," doleriai ").replaceAll("&"," ir ").replaceAll("+"," pliusas ").replace(/(\d)\,(\d)/g,"$1 kablelis $2").replace(/\d+/g,this.numberToLithuanianWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u0303\u0305\u0306\u0308-\u0327\u0329-\u036f]/g,"").normalize("NFC").trim()}wordsToVisemes(t){let e={words:t,visemes:[],times:[],durations:[]},n=0;const i=[...t];for(let s=0;s<i.length;s++){const o=i[s].toLowerCase(),l=this.visemes[o];if(l)if(e.visemes.length&&e.visemes[e.visemes.length-1]===l){const c=.7*(this.durations[o]||1);e.durations[e.durations.length-1]+=c,n+=c}else{const c=this.durations[o]||1;e.visemes.push(l),e.times.push(n),e.durations.push(c),n+=c}else n+=this.pauses[i[s]]||0}return e}}const ct=Object.freeze(Object.defineProperty({__proto__:null,LipsyncLt:ut},Symbol.toStringTag,{value:"Module"})),ht=new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy5fc2FtcGxlUmF0ZSAqIHNpbGVuY2VEdXJhdGlvblNlY29uZHMpIC8gMTI4KTsKCiAgICAvLyBNZXRyaWNzIGNvbmZpZ3VyYXRpb24gdmlhIG9wdGlvbnMKICAgIGNvbnN0IG1ldHJpY3NDZmcgPSBvcHRpb25zPy5wcm9jZXNzb3JPcHRpb25zPy5tZXRyaWNzIHx8IHt9OwogICAgdGhpcy5fbWV0cmljc0VuYWJsZWQgPSBtZXRyaWNzQ2ZnLmVuYWJsZWQgIT09IGZhbHNlOwogICAgY29uc3QgaW50ZXJ2YWxIeiA9ICh0eXBlb2YgbWV0cmljc0NmZy5pbnRlcnZhbEh6ID09PSAibnVtYmVyIiAmJiBtZXRyaWNzQ2ZnLmludGVydmFsSHogPiAwKQogICAgICA/IG1ldHJpY3NDZmcuaW50ZXJ2YWxIeiA6IDI7CiAgICAvLyBNZXRyaWNzIHN0YXRlIChsb3ctb3ZlcmhlYWQpCiAgICB0aGlzLl9mcmFtZXNQcm9jZXNzZWQgPSAwOwogICAgdGhpcy5fdW5kZXJydW5CbG9ja3MgPSAwOwogICAgdGhpcy5fbWF4UXVldWVTYW1wbGVzID0gMDsKICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSAwOwogICAgLy8gQ29udmVydCB0byBmcmFtZXMgYmV0d2VlbiByZXBvcnRzCiAgICB0aGlzLl9tZXRyaWNzSW50ZXJ2YWxGcmFtZXMgPSBNYXRoLm1heCgxMjgsIE1hdGgucm91bmQodGhpcy5fc2FtcGxlUmF0ZSAvIGludGVydmFsSHopKTsKCiAgICB0aGlzLnJlc2V0KCk7CiAgfQoKICAvKioKICAgKiBSZXNldHMgdGhlIHdvcmtsZXQgdG8gaXRzIGluaXRpYWwgSURMRSBzdGF0ZS4KICAgKi8KICByZXNldCgpIHsKICAgIHRoaXMuX2J1ZmZlclF1ZXVlID0gW107CiAgICB0aGlzLl9jdXJyZW50Q2h1bmsgPSBudWxsOwogICAgdGhpcy5fY3VycmVudENodW5rT2Zmc2V0ID0gMDsKICAgIHRoaXMuX3N0YXRlID0gUGxheWJhY2tXb3JrbGV0LkZTTS5JRExFOwoKICAgIHRoaXMuX25vTW9yZURhdGFSZWNlaXZlZCA9IGZhbHNlOwogICAgdGhpcy5fc2lsZW5jZUZyYW1lc0NvdW50ID0gMDsKICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IGZhbHNlOwogICAgLy8gUmVzZXQgbWF4IHF1ZXVlIHRyYWNrZXIgb25seSB3aGVuIGdvaW5nIGlkbGUKICAgIHRoaXMuX21heFF1ZXVlU2FtcGxlcyA9IDA7CiAgfQoKICBoYW5kbGVNZXNzYWdlKGV2ZW50KSB7CiAgICBjb25zdCB7IHR5cGUsIGRhdGEgfSA9IGV2ZW50LmRhdGE7CgogICAgLy8gSU5URVJSVVBUOiBUaGUgbWFpbiB0aHJlYWQgd2FudHMgdG8gc3RvcCBpbW1lZGlhdGVseS4KICAgIGlmICh0eXBlID09PSAic3RvcCIpIHsKICAgICAgdGhpcy5yZXNldCgpOwogICAgICAvLyBTZW5kIGZpbmFsIG1ldHJpY3Mgc2hvd2luZyBjbGVhcmVkIHN0YXRlCiAgICAgIGlmICh0aGlzLl9tZXRyaWNzRW5hYmxlZCkgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICB0eXBlOiAibWV0cmljcyIsCiAgICAgICAgICAgIGRhdGE6IHsKICAgICAgICAgICAgICBzdGF0ZTogUGxheWJhY2tXb3JrbGV0LkZTTS5JRExFLAogICAgICAgICAgICAgIHF1ZXVlZFNhbXBsZXM6IDAsCiAgICAgICAgICAgICAgcXVldWVkTXM6IDAsCiAgICAgICAgICAgICAgbWF4UXVldWVkTXM6IE1hdGgucm91bmQoKHRoaXMuX21heFF1ZXVlU2FtcGxlcyAvIHRoaXMuX3NhbXBsZVJhdGUpICogMTAwMCksCiAgICAgICAgICAgICAgdW5kZXJydW5CbG9ja3M6IHRoaXMuX3VuZGVycnVuQmxvY2tzLAogICAgICAgICAgICAgIGZyYW1lc1Byb2Nlc3NlZDogdGhpcy5fZnJhbWVzUHJvY2Vzc2VkCiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgIH0gY2F0Y2ggKF8pIHsgfQogICAgICB9CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBNYWluIHRocmVhZCBoYXMgc2lnbmFsZWQgdGhhdCBubyBtb3JlIGF1ZGlvIGNodW5rcyB3aWxsIGJlIHNlbnQgZm9yIHRoaXMgdXR0ZXJhbmNlLgogICAgaWYgKHR5cGUgPT09ICJuby1tb3JlLWRhdGEiKSB7CiAgICAgIHRoaXMuX25vTW9yZURhdGFSZWNlaXZlZCA9IHRydWU7CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBVcGRhdGUgbWV0cmljcyBjb25maWd1cmF0aW9uIGF0IHJ1bnRpbWUKICAgIGlmICh0eXBlID09PSAiY29uZmlnLW1ldHJpY3MiICYmIGRhdGEgJiYgdHlwZW9mIGRhdGEgPT09ICJvYmplY3QiKSB7CiAgICAgIGlmICgiZW5hYmxlZCIgaW4gZGF0YSkgdGhpcy5fbWV0cmljc0VuYWJsZWQgPSAhIWRhdGEuZW5hYmxlZDsKICAgICAgaWYgKHR5cGVvZiBkYXRhLmludGVydmFsSHogPT09ICJudW1iZXIiICYmIGRhdGEuaW50ZXJ2YWxIeiA+IDApIHsKICAgICAgICBjb25zdCBpbnRlcnZhbEh6ID0gZGF0YS5pbnRlcnZhbEh6OwogICAgICAgIHRoaXMuX21ldHJpY3NJbnRlcnZhbEZyYW1lcyA9IE1hdGgubWF4KDEyOCwgTWF0aC5yb3VuZCh0aGlzLl9zYW1wbGVSYXRlIC8gaW50ZXJ2YWxIeikpOwogICAgICB9CiAgICAgIC8vIFJlc2V0IHBhY2luZyBzbyB0aGUgbmV4dCByZXBvcnQgYWxpZ25zIHdpdGggbmV3IGludGVydmFsCiAgICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSB0aGlzLl9mcmFtZXNQcm9jZXNzZWQ7CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBOZXcgYXVkaW8gZGF0YSBoYXMgYXJyaXZlZC4KICAgIGlmICh0eXBlID09PSAiYXVkaW9EYXRhIiAmJiBkYXRhIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIpIHsKICAgICAgdGhpcy5fbm9Nb3JlRGF0YVJlY2VpdmVkID0gZmFsc2U7CiAgICAgIC8vIElmIHdlIHdlcmUgaWRsZSwgdGhpcyBuZXcgZGF0YSBraWNrcyBvZmYgdGhlIHBsYXliYWNrLgogICAgICBpZiAodGhpcy5fc3RhdGUgPT09IFBsYXliYWNrV29ya2xldC5GU00uSURMRSkgewogICAgICAgIHRoaXMuX3N0YXRlID0gUGxheWJhY2tXb3JrbGV0LkZTTS5QTEFZSU5HOwogICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7IHR5cGU6ICJwbGF5YmFjay1zdGFydGVkIiB9KTsKICAgICAgfQoKICAgICAgLy8gV2Ugb25seSBxdWV1ZSBkYXRhIGlmIHdlIGFyZSBpbiB0aGUgUExBWUlORyBzdGF0ZS4gVGhpcyBwcmV2ZW50cwogICAgICAvLyBkYXRhIGZyb20gYSBwcmV2aW91cywgaW50ZXJydXB0ZWQgc3RyZWFtIGZyb20gbGluZ2VyaW5nLgogICAgICBpZiAodGhpcy5fc3RhdGUgPT09IFBsYXliYWNrV29ya2xldC5GU00uUExBWUlORykgewogICAgICAgIC8vIFN0b3JlIGFzIEludDE2QXJyYXkgdmlldyB0byBhdm9pZCBjb25zdHJ1Y3RpbmcgaXQgaW4gcHJvY2VzcygpCiAgICAgICAgdGhpcy5fYnVmZmVyUXVldWUucHVzaChuZXcgSW50MTZBcnJheShkYXRhKSk7CiAgICAgICAgdGhpcy5fc2lsZW5jZUZyYW1lc0NvdW50ID0gMDsgLy8gUmVzZXQgc2lsZW5jZSBjb3VudGVyIG9uIG5ldyBkYXRhCiAgICAgIH0KICAgIH0KICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBvdXRwdXRDaGFubmVsID0gb3V0cHV0c1swXT8uWzBdOwogICAgaWYgKCFvdXRwdXRDaGFubmVsKSB7CiAgICAgIHJldHVybiB0cnVlOyAvLyBLZWVwIGFsaXZlIGV2ZW4gaWYgb3V0cHV0IGlzIHRlbXBvcmFyaWx5IGRpc2Nvbm5lY3RlZAogICAgfQoKICAgIC8vIElmIHdlIGFyZSBub3QgcGxheWluZywganVzdCBvdXRwdXQgc2lsZW5jZSBhbmQgd2FpdC4KICAgIGlmICh0aGlzLl9zdGF0ZSAhPT0gUGxheWJhY2tXb3JrbGV0LkZTTS5QTEFZSU5HKSB7CiAgICAgIG91dHB1dENoYW5uZWwuZmlsbCgwKTsKICAgICAgcmV0dXJuIHRydWU7IC8vIEFsd2F5cyByZXR1cm4gdHJ1ZSB0byBrZWVwIHRoZSBwcm9jZXNzb3IgYWxpdmUKICAgIH0KCiAgICAvLyBDb3JlIFBMQVlJTkcgTG9naWMKICAgIGNvbnN0IGJsb2NrU2l6ZSA9IG91dHB1dENoYW5uZWwubGVuZ3RoOwogICAgbGV0IHNhbXBsZXNDb3BpZWQgPSAwOwoKICAgIHdoaWxlIChzYW1wbGVzQ29waWVkIDwgYmxvY2tTaXplKSB7CiAgICAgIGlmICghdGhpcy5fY3VycmVudENodW5rIHx8IHRoaXMuX2N1cnJlbnRDaHVua09mZnNldCA+PSB0aGlzLl9jdXJyZW50Q2h1bmsubGVuZ3RoKSB7CiAgICAgICAgaWYgKHRoaXMuX2J1ZmZlclF1ZXVlLmxlbmd0aCA+IDApIHsKICAgICAgICAgIHRoaXMuX2N1cnJlbnRDaHVuayA9IHRoaXMuX2J1ZmZlclF1ZXVlLnNoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3ZlKSwgcHJvY2VzcyBpdC4KICAgICAgaWYgKHRoaXMuX2N1cnJlbnRDaHVuaykgewogICAgICAgIGNvbnN0IHNhbXBsZXNUb0NvcHkgPSBNYXRoLm1pbigKICAgICAgICAgIGJsb2NrU2l6ZSAtIHNhbXBsZXNDb3BpZWQsCiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmsubGVuZ3RoIC0gdGhpcy5fY3VycmVudENodW5rT2Zmc2V0CiAgICAgICAgKTsKICAgICAgICAvLyBEaXJlY3RseSB3cml0ZSB0byBvdXRwdXRDaGFubmVsIHRvIGF2b2lkIGV4dHJhIGNvcHkKICAgICAgICBjb25zdCBzcmMgPSB0aGlzLl9jdXJyZW50Q2h1bms7CiAgICAgICAgY29uc3QgYmFzZVNyYyA9IHRoaXMuX2N1cnJlbnRDaHVua09mZnNldDsKICAgICAgICBjb25zdCBiYXNlRHN0ID0gc2FtcGxlc0NvcGllZDsKICAgICAgICBjb25zdCBzY2FsZSA9IHRoaXMuX3NjYWxlOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2FtcGxlc1RvQ29weTsgaSsrKSB7CiAgICAgICAgICBvdXRwdXRDaGFubmVsW2Jhc2VEc3QgKyBpXSA9IHNyY1tiYXNlU3JjICsgaV0gKiBzY2FsZTsKICAgICAgICB9CgogICAgICAgIHRoaXMuX2N1cnJlbnRDaHVua09mZnNldCArPSBzYW1wbGVzVG9Db3B5OwogICAgICAgIHNhbXBsZXNDb3BpZWQgKz0gc2FtcGxlc1RvQ29weTsKICAgICAgfQogICAgfQoKICAgIC8vIFplcm8tZmlsbCB0aGUgcmVtYWluZGVyLCBpZiBhbnksIG9uY2UgcGVyIGJsb2NrCiAgICBpZiAoc2FtcGxlc0NvcGllZCA8IGJsb2NrU2l6ZSkgewogICAgICBvdXRwdXRDaGFubmVsLmZpbGwoMCwgc2FtcGxlc0NvcGllZCk7CiAgICB9CgogICAgLy8gVXBkYXRlIG1ldHJpY3MgKG9wdGlvbmFsKQogICAgaWYgKHRoaXMuX21ldHJpY3NFbmFibGVkKSB7CiAgICAgIHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZCArPSBibG9ja1NpemU7CgogICAgICAvLyBUcmFjayBxdWV1ZSBkZXB0aCBpbiBzYW1wbGVzIChhcHByb3hpbWF0ZSkKICAgICAgbGV0IHF1ZXVlZFNhbXBsZXMgPSAwOwogICAgICBpZiAodGhpcy5fY3VycmVudENodW5rKSBxdWV1ZWRTYW1wbGVzICs9IE1hdGgubWF4KDAsIHRoaXMuX2N1cnJlbnRDaHVuay5sZW5ndGggLSB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQpOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuX2J1ZmZlclF1ZXVlLmxlbmd0aDsgaSsrKSBxdWV1ZWRTYW1wbGVzICs9IHRoaXMuX2J1ZmZlclF1ZXVlW2ldLmxlbmd0aDsKICAgICAgaWYgKHF1ZXVlZFNhbXBsZXMgPiB0aGlzLl9tYXhRdWV1ZVNhbXBsZXMpIHRoaXMuX21heFF1ZXVlU2FtcGxlcyA9IHF1ZXVlZFNhbXBsZXM7CgogICAgICAvLyBQZXJpb2RpY2FsbHkgc2VuZCBtZXRyaWNzIHRvIG1haW4gdGhyZWFkCiAgICAgIGlmICh0aGlzLl9mcmFtZXNQcm9jZXNzZWQgLSB0aGlzLl9sYXN0TWV0cmljc1NlbnRBdEZyYW1lID49IHRoaXMuX21ldHJpY3NJbnRlcnZhbEZyYW1lcykgewogICAgICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSB0aGlzLl9mcmFtZXNQcm9jZXNzZWQ7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHR5cGU6ICJtZXRyaWNzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=",typeof document>"u"?require("url").pathToFileURL(__filename).href:He&&He.tagName.toUpperCase()==="SCRIPT"&&He.src||new URL("index.cjs",document.baseURI).href),Oe={en:nt,de:ot,fr:at,fi:lt,lt:ct},J=new y.Quaternion,G=new y.Euler,fe=new y.Vector3,xe=new y.Vector3,De=new y.Box3;new y.Matrix4;new y.Matrix4;new y.Vector3;new y.Vector3(0,0,1);const dt=new y.Vector3(1,0,0);new y.Vector3(0,1,0);new y.Vector3(0,0,1);class Te{constructor(t,e=null){this.nodeAvatar=t,this.opt={jwtGet:null,ttsEndpoint:"",ttsApikey:null,ttsTrimStart:0,ttsTrimEnd:400,ttsLang:"fi-FI",ttsVoice:"fi-FI-Standard-A",ttsRate:1,ttsPitch:0,ttsVolume:.3,mixerGainSpeech:1.2,mixerGainBackground:null,lipsyncLang:"fi",lipsyncModules:["fi","en","lt"],pcmSampleRate:22050,modelRoot:"Armature",modelPixelRatio:1,modelFPS:30,modelMovementFactor:1,cameraView:"full",dracoEnabled:!1,dracoDecoderPath:"https://www.gstatic.com/draco/v1/decoders/",cameraDistance:0,cameraX:0,cameraY:0,cameraRotateX:0,cameraRotateY:0,cameraRotateEnable:!0,cameraPanEnable:!1,cameraZoomEnable:!1,lightAmbientColor:16777215,lightAmbientIntensity:1.25,lightDirectColor:8947882,lightDirectIntensity:12,lightDirectPhi:1,lightDirectTheta:2,lightSpotIntensity:0,lightSpotColor:3377407,lightSpotPhi:.1,lightSpotTheta:4,lightSpotDispersion:1,avatarMood:"neutral",avatarMute:!1,avatarIdleEyeContact:.6,avatarIdleHeadMove:.5,avatarSpeakingEyeContact:.8,avatarSpeakingHeadMove:.5,avatarIgnoreCamera:!1,listeningSilenceThresholdLevel:40,listeningSilenceThresholdMs:2e3,listeningSilenceDurationMax:1e4,listeningActiveThresholdLevel:75,listeningActiveThresholdMs:300,listeningActiveDurationMax:24e4,update:null,avatarOnly:!1,avatarOnlyScene:null,avatarOnlyCamera:null,statsNode:null,statsStyle:null},Object.assign(this.opt,e||{}),this.opt.statsNode&&(this.stats=new Qe,this.opt.statsStyle&&(this.stats.dom.style.cssText=this.opt.statsStyle),this.opt.statsNode.appendChild(this.stats.dom)),this.poseTemplates={side:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.003,y:-.017,z:.1},"Spine.rotation":{x:-.103,y:-.002,z:-.063},"Spine1.rotation":{x:.042,y:-.02,z:-.069},"Spine2.rotation":{x:.131,y:-.012,z:-.065},"Neck.rotation":{x:.027,y:.006,z:0},"Head.rotation":{x:.077,y:-.065,z:0},"LeftShoulder.rotation":{x:1.599,y:.084,z:-1.77},"LeftArm.rotation":{x:1.364,y:.052,z:-.044},"LeftForeArm.rotation":{x:.002,y:-.007,z:.331},"LeftHand.rotation":{x:.104,y:-.067,z:-.174},"LeftHandThumb1.rotation":{x:.231,y:.258,z:.355},"LeftHandThumb2.rotation":{x:-.106,y:-.339,z:-.454},"LeftHandThumb3.rotation":{x:-.02,y:-.142,z:-.004},"LeftHandIndex1.rotation":{x:.148,y:.032,z:-.069},"LeftHandIndex2.rotation":{x:.326,y:-.049,z:-.029},"LeftHandIndex3.rotation":{x:.247,y:-.053,z:-.073},"LeftHandMiddle1.rotation":{x:.238,y:-.057,z:-.089},"LeftHandMiddle2.rotation":{x:.469,y:-.036,z:-.081},"LeftHandMiddle3.rotation":{x:.206,y:-.015,z:-.017},"LeftHandRing1.rotation":{x:.187,y:-.118,z:-.157},"LeftHandRing2.rotation":{x:.579,y:.02,z:-.097},"LeftHandRing3.rotation":{x:.272,y:.021,z:-.063},"LeftHandPinky1.rotation":{x:.405,y:-.182,z:-.138},"LeftHandPinky2.rotation":{x:.613,y:.128,z:-.144},"LeftHandPinky3.rotation":{x:.268,y:.094,z:-.081},"RightShoulder.rotation":{x:1.541,y:.192,z:1.775},"RightArm.rotation":{x:1.273,y:-.352,z:-.067},"RightForeArm.rotation":{x:-.011,y:-.031,z:-.357},"RightHand.rotation":{x:-.008,y:.312,z:-.028},"RightHandThumb1.rotation":{x:.23,y:-.258,z:-.355},"RightHandThumb2.rotation":{x:-.107,y:.339,z:.454},"RightHandThumb3.rotation":{x:-.02,y:.142,z:.004},"RightHandIndex1.rotation":{x:.148,y:-.031,z:.069},"RightHandIndex2.rotation":{x:.326,y:.049,z:.029},"RightHandIndex3.rotation":{x:.247,y:.053,z:.073},"RightHandMiddle1.rotation":{x:.237,y:.057,z:.089},"RightHandMiddle2.rotation":{x:.469,y:.036,z:.081},"RightHandMiddle3.rotation":{x:.206,y:.015,z:.017},"RightHandRing1.rotation":{x:.204,y:.086,z:.135},"RightHandRing2.rotation":{x:.579,y:-.02,z:.098},"RightHandRing3.rotation":{x:.272,y:-.021,z:.063},"RightHandPinky1.rotation":{x:.404,y:.182,z:.137},"RightHandPinky2.rotation":{x:.613,y:-.128,z:.144},"RightHandPinky3.rotation":{x:.268,y:-.094,z:.081},"LeftUpLeg.rotation":{x:.096,y:.209,z:2.983},"LeftLeg.rotation":{x:-.053,y:.042,z:-.017},"LeftFoot.rotation":{x:1.091,y:.15,z:.026},"LeftToeBase.rotation":{x:.469,y:-.07,z:-.015},"RightUpLeg.rotation":{x:-.307,y:-.219,z:2.912},"RightLeg.rotation":{x:-.359,y:.164,z:.015},"RightFoot.rotation":{x:1.035,y:.11,z:.005},"RightToeBase.rotation":{x:.467,y:.07,z:.015}}},hip:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.036,y:.09,z:.135},"Spine.rotation":{x:.076,y:-.035,z:.01},"Spine1.rotation":{x:-.096,y:.013,z:-.094},"Spine2.rotation":{x:-.014,y:.002,z:-.097},"Neck.rotation":{x:.034,y:-.051,z:-.075},"Head.rotation":{x:.298,y:-.1,z:.154},"LeftShoulder.rotation":{x:1.694,y:.011,z:-1.68},"LeftArm.rotation":{x:1.343,y:.177,z:-.153},"LeftForeArm.rotation":{x:-.049,y:.134,z:.351},"LeftHand.rotation":{x:.057,y:-.189,z:-.026},"LeftHandThumb1.rotation":{x:.368,y:-.066,z:.438},"LeftHandThumb2.rotation":{x:-.156,y:.029,z:-.369},"LeftHandThumb3.rotation":{x:.034,y:-.009,z:.016},"LeftHandIndex1.rotation":{x:.157,y:-.002,z:-.171},"LeftHandIndex2.rotation":{x:.099,y:0,z:0},"LeftHandIndex3.rotation":{x:.1,y:0,z:0},"LeftHandMiddle1.rotation":{x:.222,y:-.019,z:-.16},"LeftHandMiddle2.rotation":{x:.142,y:0,z:0},"LeftHandMiddle3.rotation":{x:.141,y:0,z:0},"LeftHandRing1.rotation":{x:.333,y:-.039,z:-.174},"LeftHandRing2.rotation":{x:.214,y:0,z:0},"LeftHandRing3.rotation":{x:.213,y:0,z:0},"LeftHandPinky1.rotation":{x:.483,y:-.069,z:-.189},"LeftHandPinky2.rotation":{x:.312,y:0,z:0},"LeftHandPinky3.rotation":{x:.309,y:0,z:0},"RightShoulder.rotation":{x:1.597,y:.012,z:1.816},"RightArm.rotation":{x:.618,y:-1.274,z:-.266},"RightForeArm.rotation":{x:-.395,y:-.097,z:-1.342},"RightHand.rotation":{x:-.816,y:-.057,z:-.976},"RightHandThumb1.rotation":{x:.42,y:.23,z:-1.172},"RightHandThumb2.rotation":{x:-.027,y:.361,z:.122},"RightHandThumb3.rotation":{x:.076,y:.125,z:-.371},"RightHandIndex1.rotation":{x:-.158,y:-.045,z:.033},"RightHandIndex2.rotation":{x:.391,y:.051,z:.025},"RightHandIndex3.rotation":{x:.317,y:.058,z:.07},"RightHandMiddle1.rotation":{x:.486,y:.066,z:.014},"RightHandMiddle2.rotation":{x:.718,y:.055,z:.07},"RightHandMiddle3.rotation":{x:.453,y:.019,z:.013},"RightHandRing1.rotation":{x:.591,y:.241,z:.11},"RightHandRing2.rotation":{x:1.014,y:.023,z:.097},"RightHandRing3.rotation":{x:.708,y:.008,z:.066},"RightHandPinky1.rotation":{x:1.02,y:.305,z:.051},"RightHandPinky2.rotation":{x:1.187,y:-.028,z:.191},"RightHandPinky3.rotation":{x:.872,y:-.031,z:.121},"LeftUpLeg.rotation":{x:-.095,y:-.058,z:-3.338},"LeftLeg.rotation":{x:-.366,y:.287,z:-.021},"LeftFoot.rotation":{x:1.131,y:.21,z:.176},"LeftToeBase.rotation":{x:.739,y:-.068,z:-.001},"RightUpLeg.rotation":{x:-.502,y:.362,z:3.153},"RightLeg.rotation":{x:-1.002,y:.109,z:.008},"RightFoot.rotation":{x:.626,y:-.097,z:-.194},"RightToeBase.rotation":{x:1.33,y:.288,z:-.078}}},turn:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.07,y:-.604,z:-.004},"Spine.rotation":{x:-.007,y:.003,z:.071},"Spine1.rotation":{x:-.053,y:.024,z:-.06},"Spine2.rotation":{x:.074,y:.013,z:-.068},"Neck.rotation":{x:.03,y:.186,z:-.077},"Head.rotation":{x:.045,y:.243,z:-.086},"LeftShoulder.rotation":{x:1.717,y:-.085,z:-1.761},"LeftArm.rotation":{x:1.314,y:.07,z:-.057},"LeftForeArm.rotation":{x:-.151,y:.714,z:.302},"LeftHand.rotation":{x:-.069,y:.003,z:-.118},"LeftHandThumb1.rotation":{x:.23,y:.258,z:.354},"LeftHandThumb2.rotation":{x:-.107,y:-.338,z:-.455},"LeftHandThumb3.rotation":{x:-.015,y:-.142,z:.002},"LeftHandIndex1.rotation":{x:.145,y:.032,z:-.069},"LeftHandIndex2.rotation":{x:.323,y:-.049,z:-.028},"LeftHandIndex3.rotation":{x:.249,y:-.053,z:-.074},"LeftHandMiddle1.rotation":{x:.235,y:-.057,z:-.088},"LeftHandMiddle2.rotation":{x:.468,y:-.036,z:-.081},"LeftHandMiddle3.rotation":{x:.203,y:-.015,z:-.017},"LeftHandRing1.rotation":{x:.185,y:-.118,z:-.157},"LeftHandRing2.rotation":{x:.578,y:.02,z:-.097},"LeftHandRing3.rotation":{x:.27,y:.021,z:-.063},"LeftHandPinky1.rotation":{x:.404,y:-.182,z:-.138},"LeftHandPinky2.rotation":{x:.612,y:.128,z:-.144},"LeftHandPinky3.rotation":{x:.267,y:.094,z:-.081},"RightShoulder.rotation":{x:1.605,y:.17,z:1.625},"RightArm.rotation":{x:1.574,y:-.655,z:.388},"RightForeArm.rotation":{x:-.36,y:-.849,z:-.465},"RightHand.rotation":{x:.114,y:.416,z:-.069},"RightHandThumb1.rotation":{x:.486,y:.009,z:-.492},"RightHandThumb2.rotation":{x:-.073,y:-.01,z:.284},"RightHandThumb3.rotation":{x:-.054,y:-.006,z:.209},"RightHandIndex1.rotation":{x:.245,y:-.014,z:.052},"RightHandIndex2.rotation":{x:.155,y:0,z:0},"RightHandIndex3.rotation":{x:.153,y:0,z:0},"RightHandMiddle1.rotation":{x:.238,y:.004,z:.028},"RightHandMiddle2.rotation":{x:.15,y:0,z:0},"RightHandMiddle3.rotation":{x:.149,y:0,z:0},"RightHandRing1.rotation":{x:.267,y:.012,z:.007},"RightHandRing2.rotation":{x:.169,y:0,z:0},"RightHandRing3.rotation":{x:.167,y:0,z:0},"RightHandPinky1.rotation":{x:.304,y:.018,z:-.021},"RightHandPinky2.rotation":{x:.192,y:0,z:0},"RightHandPinky3.rotation":{x:.19,y:0,z:0},"LeftUpLeg.rotation":{x:-.001,y:-.058,z:-3.238},"LeftLeg.rotation":{x:-.29,y:.058,z:-.021},"LeftFoot.rotation":{x:1.288,y:.168,z:.183},"LeftToeBase.rotation":{x:.363,y:-.09,z:-.01},"RightUpLeg.rotation":{x:-.1,y:.36,z:3.062},"RightLeg.rotation":{x:-.67,y:-.304,z:.043},"RightFoot.rotation":{x:1.195,y:-.159,z:-.294},"RightToeBase.rotation":{x:.737,y:.164,z:-.002}}},bend:{bend:!0,standing:!0,props:{"Hips.position":{x:-.007,y:.943,z:-.001},"Hips.rotation":{x:1.488,y:-.633,z:1.435},"Spine.rotation":{x:-.126,y:.007,z:-.057},"Spine1.rotation":{x:-.134,y:.009,z:.01},"Spine2.rotation":{x:-.019,y:0,z:-.002},"Neck.rotation":{x:-.159,y:.572,z:-.108},"Head.rotation":{x:-.064,y:.716,z:-.257},"RightShoulder.rotation":{x:1.625,y:-.043,z:1.382},"RightArm.rotation":{x:.746,y:-.96,z:-1.009},"RightForeArm.rotation":{x:-.199,y:-.528,z:-.38},"RightHand.rotation":{x:-.261,y:-.043,z:-.027},"RightHandThumb1.rotation":{x:.172,y:-.138,z:-.445},"RightHandThumb2.rotation":{x:-.158,y:.327,z:.545},"RightHandThumb3.rotation":{x:-.062,y:.138,z:.152},"RightHandIndex1.rotation":{x:.328,y:-.005,z:.132},"RightHandIndex2.rotation":{x:.303,y:.049,z:.028},"RightHandIndex3.rotation":{x:.241,y:.046,z:.077},"RightHandMiddle1.rotation":{x:.309,y:.074,z:.089},"RightHandMiddle2.rotation":{x:.392,y:.036,z:.081},"RightHandMiddle3.rotation":{x:.199,y:.014,z:.019},"RightHandRing1.rotation":{x:.239,y:.143,z:.091},"RightHandRing2.rotation":{x:.275,y:-.02,z:.097},"RightHandRing3.rotation":{x:.248,y:-.023,z:.061},"RightHandPinky1.rotation":{x:.211,y:.154,z:.029},"RightHandPinky2.rotation":{x:.348,y:-.128,z:.144},"RightHandPinky3.rotation":{x:.21,y:-.091,z:.065},"LeftShoulder.rotation":{x:1.626,y:-.027,z:-1.367},"LeftArm.rotation":{x:1.048,y:.737,z:.712},"LeftForeArm.rotation":{x:-.508,y:.879,z:.625},"LeftHand.rotation":{x:.06,y:-.243,z:-.079},"LeftHandThumb1.rotation":{x:.187,y:-.072,z:.346},"LeftHandThumb2.rotation":{x:-.066,y:.008,z:-.256},"LeftHandThumb3.rotation":{x:-.085,y:.014,z:-.334},"LeftHandIndex1.rotation":{x:-.1,y:.016,z:-.058},"LeftHandIndex2.rotation":{x:.334,y:0,z:0},"LeftHandIndex3.rotation":{x:.281,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.056,y:0,z:0},"LeftHandMiddle2.rotation":{x:.258,y:0,z:0},"LeftHandMiddle3.rotation":{x:.26,y:0,z:0},"LeftHandRing1.rotation":{x:-.067,y:-.002,z:.008},"LeftHandRing2.rotation":{x:.259,y:0,z:0},"LeftHandRing3.rotation":{x:.276,y:0,z:0},"LeftHandPinky1.rotation":{x:-.128,y:-.007,z:.042},"LeftHandPinky2.rotation":{x:.227,y:0,z:0},"LeftHandPinky3.rotation":{x:.145,y:0,z:0},"RightUpLeg.rotation":{x:-1.507,y:.2,z:-3.043},"RightLeg.rotation":{x:-.689,y:-.124,z:.017},"RightFoot.rotation":{x:.909,y:.008,z:-.093},"RightToeBase.rotation":{x:.842,y:.075,z:-.008},"LeftUpLeg.rotation":{x:-1.449,y:-.2,z:3.018},"LeftLeg.rotation":{x:-.74,y:-.115,z:-.008},"LeftFoot.rotation":{x:1.048,y:-.058,z:.117},"LeftToeBase.rotation":{x:.807,y:-.067,z:.003}}},back:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.732,y:-1.463,z:-.637},"Spine.rotation":{x:-.171,y:.106,z:.157},"Spine1.rotation":{x:-.044,y:.138,z:-.059},"Spine2.rotation":{x:.082,y:.133,z:-.074},"Neck.rotation":{x:.39,y:.591,z:-.248},"Head.rotation":{x:-.001,y:.596,z:-.057},"LeftShoulder.rotation":{x:1.676,y:.007,z:-1.892},"LeftArm.rotation":{x:-5.566,y:1.188,z:-.173},"LeftForeArm.rotation":{x:-.673,y:-.105,z:1.702},"LeftHand.rotation":{x:-.469,y:-.739,z:.003},"LeftHandThumb1.rotation":{x:.876,y:.274,z:.793},"LeftHandThumb2.rotation":{x:.161,y:-.23,z:-.172},"LeftHandThumb3.rotation":{x:.078,y:.027,z:.156},"LeftHandIndex1.rotation":{x:-.085,y:-.002,z:.009},"LeftHandIndex2.rotation":{x:.176,y:0,z:-.002},"LeftHandIndex3.rotation":{x:-.036,y:.001,z:-.035},"LeftHandMiddle1.rotation":{x:.015,y:.144,z:-.076},"LeftHandMiddle2.rotation":{x:.378,y:-.007,z:-.077},"LeftHandMiddle3.rotation":{x:-.141,y:-.001,z:.031},"LeftHandRing1.rotation":{x:.039,y:.02,z:-.2},"LeftHandRing2.rotation":{x:.25,y:-.002,z:-.073},"LeftHandRing3.rotation":{x:.236,y:.006,z:-.075},"LeftHandPinky1.rotation":{x:.172,y:-.033,z:-.275},"LeftHandPinky2.rotation":{x:.216,y:.043,z:-.054},"LeftHandPinky3.rotation":{x:.325,y:.078,z:-.13},"RightShoulder.rotation":{x:2.015,y:-.168,z:1.706},"RightArm.rotation":{x:.203,y:-1.258,z:-.782},"RightForeArm.rotation":{x:-.658,y:-.133,z:-1.401},"RightHand.rotation":{x:-1.504,y:.375,z:-.005},"RightHandThumb1.rotation":{x:.413,y:-.158,z:-1.121},"RightHandThumb2.rotation":{x:-.142,y:-.008,z:.209},"RightHandThumb3.rotation":{x:-.091,y:.021,z:.142},"RightHandIndex1.rotation":{x:-.167,y:.014,z:-.072},"RightHandIndex2.rotation":{x:.474,y:.009,z:.051},"RightHandIndex3.rotation":{x:.115,y:.006,z:.047},"RightHandMiddle1.rotation":{x:.385,y:.019,z:.144},"RightHandMiddle2.rotation":{x:.559,y:.035,z:.101},"RightHandMiddle3.rotation":{x:.229,y:0,z:.027},"RightHandRing1.rotation":{x:.48,y:.026,z:.23},"RightHandRing2.rotation":{x:.772,y:.038,z:.109},"RightHandRing3.rotation":{x:.622,y:.039,z:.106},"RightHandPinky1.rotation":{x:.767,y:.288,z:.353},"RightHandPinky2.rotation":{x:.886,y:.049,z:.122},"RightHandPinky3.rotation":{x:.662,y:.044,z:.113},"LeftUpLeg.rotation":{x:-.206,y:-.268,z:-3.343},"LeftLeg.rotation":{x:-.333,y:.757,z:-.043},"LeftFoot.rotation":{x:1.049,y:.167,z:.287},"LeftToeBase.rotation":{x:.672,y:-.069,z:-.004},"RightUpLeg.rotation":{x:.055,y:-.226,z:3.037},"RightLeg.rotation":{x:-.559,y:.39,z:-.001},"RightFoot.rotation":{x:1.2,y:.133,z:.085},"RightToeBase.rotation":{x:.92,y:.093,z:-.013}}},straight:{standing:!0,props:{"Hips.position":{x:0,y:.989,z:.001},"Hips.rotation":{x:.047,y:.007,z:-.007},"Spine.rotation":{x:-.143,y:-.007,z:.005},"Spine1.rotation":{x:-.043,y:-.014,z:.012},"Spine2.rotation":{x:.072,y:-.013,z:.013},"Neck.rotation":{x:.048,y:-.003,z:.012},"Head.rotation":{x:.05,y:-.02,z:-.017},"LeftShoulder.rotation":{x:1.62,y:-.166,z:-1.605},"LeftArm.rotation":{x:1.275,y:.544,z:-.092},"LeftForeArm.rotation":{x:0,y:0,z:.302},"LeftHand.rotation":{x:-.225,y:-.154,z:.11},"LeftHandThumb1.rotation":{x:.435,y:-.044,z:.457},"LeftHandThumb2.rotation":{x:-.028,y:.002,z:-.246},"LeftHandThumb3.rotation":{x:-.236,y:-.025,z:.113},"LeftHandIndex1.rotation":{x:.218,y:.008,z:-.081},"LeftHandIndex2.rotation":{x:.165,y:-.001,z:-.017},"LeftHandIndex3.rotation":{x:.165,y:-.001,z:-.017},"LeftHandMiddle1.rotation":{x:.235,y:-.011,z:-.065},"LeftHandMiddle2.rotation":{x:.182,y:-.002,z:-.019},"LeftHandMiddle3.rotation":{x:.182,y:-.002,z:-.019},"LeftHandRing1.rotation":{x:.316,y:-.017,z:.008},"LeftHandRing2.rotation":{x:.253,y:-.003,z:-.026},"LeftHandRing3.rotation":{x:.255,y:-.003,z:-.026},"LeftHandPinky1.rotation":{x:.336,y:-.062,z:.088},"LeftHandPinky2.rotation":{x:.276,y:-.004,z:-.028},"LeftHandPinky3.rotation":{x:.276,y:-.004,z:-.028},"RightShoulder.rotation":{x:1.615,y:.064,z:1.53},"RightArm.rotation":{x:1.313,y:-.424,z:.131},"RightForeArm.rotation":{x:0,y:0,z:-.317},"RightHand.rotation":{x:-.158,y:-.639,z:-.196},"RightHandThumb1.rotation":{x:.44,y:.048,z:-.549},"RightHandThumb2.rotation":{x:-.056,y:-.008,z:.274},"RightHandThumb3.rotation":{x:-.258,y:.031,z:-.095},"RightHandIndex1.rotation":{x:.169,y:-.011,z:.105},"RightHandIndex2.rotation":{x:.134,y:.001,z:.011},"RightHandIndex3.rotation":{x:.134,y:.001,z:.011},"RightHandMiddle1.rotation":{x:.288,y:.014,z:.092},"RightHandMiddle2.rotation":{x:.248,y:.003,z:.02},"RightHandMiddle3.rotation":{x:.249,y:.003,z:.02},"RightHandRing1.rotation":{x:.369,y:.019,z:.006},"RightHandRing2.rotation":{x:.321,y:.004,z:.026},"RightHandRing3.rotation":{x:.323,y:.004,z:.026},"RightHandPinky1.rotation":{x:.468,y:.085,z:-.03},"RightHandPinky2.rotation":{x:.427,y:.007,z:.034},"RightHandPinky3.rotation":{x:.142,y:.001,z:.012},"LeftUpLeg.rotation":{x:-.077,y:-.058,z:3.126},"LeftLeg.rotation":{x:-.252,y:.001,z:-.018},"LeftFoot.rotation":{x:1.315,y:-.064,z:.315},"LeftToeBase.rotation":{x:.577,y:-.07,z:-.009},"RightUpLeg.rotation":{x:-.083,y:-.032,z:3.124},"RightLeg.rotation":{x:-.272,y:-.003,z:.021},"RightFoot.rotation":{x:1.342,y:.076,z:-.222},"RightToeBase.rotation":{x:.44,y:.069,z:.016}}},wide:{standing:!0,props:{"Hips.position":{x:0,y:1.017,z:.016},"Hips.rotation":{x:.064,y:-.048,z:.059},"Spine.rotation":{x:-.123,y:0,z:-.018},"Spine1.rotation":{x:.014,y:.003,z:-.006},"Spine2.rotation":{x:.04,y:.003,z:-.007},"Neck.rotation":{x:.101,y:.007,z:-.035},"Head.rotation":{x:-.091,y:-.049,z:.105},"RightShoulder.rotation":{x:1.831,y:.017,z:1.731},"RightArm.rotation":{x:-1.673,y:-1.102,z:-3.132},"RightForeArm.rotation":{x:.265,y:.23,z:-.824},"RightHand.rotation":{x:-.52,y:.345,z:-.061},"RightHandThumb1.rotation":{x:.291,y:.056,z:-.428},"RightHandThumb2.rotation":{x:.025,y:.005,z:.166},"RightHandThumb3.rotation":{x:-.089,y:.009,z:.068},"RightHandIndex1.rotation":{x:.392,y:-.015,z:.11},"RightHandIndex2.rotation":{x:.391,y:.001,z:.004},"RightHandIndex3.rotation":{x:.326,y:0,z:.003},"RightHandMiddle1.rotation":{x:.285,y:.068,z:.081},"RightHandMiddle2.rotation":{x:.519,y:.004,z:.011},"RightHandMiddle3.rotation":{x:.252,y:0,z:.001},"RightHandRing1.rotation":{x:.207,y:.133,z:.146},"RightHandRing2.rotation":{x:.597,y:.004,z:.004},"RightHandRing3.rotation":{x:.292,y:.002,z:.012},"RightHandPinky1.rotation":{x:.338,y:.182,z:.136},"RightHandPinky2.rotation":{x:.533,y:.002,z:.004},"RightHandPinky3.rotation":{x:.194,y:0,z:.002},"LeftShoulder.rotation":{x:1.83,y:-.063,z:-1.808},"LeftArm.rotation":{x:-1.907,y:1.228,z:-2.959},"LeftForeArm.rotation":{x:-.159,y:.268,z:.572},"LeftHand.rotation":{x:.069,y:-.498,z:-.025},"LeftHandThumb1.rotation":{x:.738,y:.123,z:.178},"LeftHandThumb2.rotation":{x:-.26,y:.028,z:-.477},"LeftHandThumb3.rotation":{x:-.448,y:.093,z:-.661},"LeftHandIndex1.rotation":{x:1.064,y:.005,z:-.13},"LeftHandIndex2.rotation":{x:1.55,y:-.143,z:-.136},"LeftHandIndex3.rotation":{x:.722,y:-.076,z:-.127},"LeftHandMiddle1.rotation":{x:1.095,y:-.091,z:.006},"LeftHandMiddle2.rotation":{x:1.493,y:-.174,z:-.151},"LeftHandMiddle3.rotation":{x:.651,y:-.031,z:-.087},"LeftHandRing1.rotation":{x:1.083,y:-.224,z:.072},"LeftHandRing2.rotation":{x:1.145,y:-.107,z:-.195},"LeftHandRing3.rotation":{x:1.208,y:-.134,z:-.158},"LeftHandPinky1.rotation":{x:.964,y:-.383,z:.128},"LeftHandPinky2.rotation":{x:1.457,y:-.146,z:-.159},"LeftHandPinky3.rotation":{x:1.019,y:-.102,z:-.141},"RightUpLeg.rotation":{x:-.221,y:-.233,z:2.87},"RightLeg.rotation":{x:-.339,y:-.043,z:-.041},"RightFoot.rotation":{x:1.081,y:.177,z:.114},"RightToeBase.rotation":{x:.775,y:0,z:0},"LeftUpLeg.rotation":{x:-.185,y:.184,z:3.131},"LeftLeg.rotation":{x:-.408,y:.129,z:.02},"LeftFoot.rotation":{x:1.167,y:-.002,z:-.007},"LeftToeBase.rotation":{x:.723,y:0,z:0}}},oneknee:{kneeling:!0,props:{"Hips.position":{x:-.005,y:.415,z:-.017},"Hips.rotation":{x:-.25,y:.04,z:-.238},"Spine.rotation":{x:.037,y:.043,z:.047},"Spine1.rotation":{x:.317,y:.103,z:.066},"Spine2.rotation":{x:.433,y:.109,z:.054},"Neck.rotation":{x:-.156,y:-.092,z:.059},"Head.rotation":{x:-.398,y:-.032,z:.018},"RightShoulder.rotation":{x:1.546,y:.119,z:1.528},"RightArm.rotation":{x:.896,y:-.247,z:-.512},"RightForeArm.rotation":{x:.007,y:0,z:-1.622},"RightHand.rotation":{x:1.139,y:-.853,z:.874},"RightHandThumb1.rotation":{x:.176,y:.107,z:-.311},"RightHandThumb2.rotation":{x:-.047,y:-.003,z:.12},"RightHandThumb3.rotation":{x:0,y:0,z:0},"RightHandIndex1.rotation":{x:.186,y:.005,z:.125},"RightHandIndex2.rotation":{x:.454,y:.005,z:.015},"RightHandIndex3.rotation":{x:0,y:0,z:0},"RightHandMiddle1.rotation":{x:.444,y:.035,z:.127},"RightHandMiddle2.rotation":{x:.403,y:-.006,z:-.04},"RightHandMiddle3.rotation":{x:0,y:0,z:0},"RightHandRing1.rotation":{x:.543,y:.074,z:.121},"RightHandRing2.rotation":{x:.48,y:-.018,z:-.063},"RightHandRing3.rotation":{x:0,y:0,z:0},"RightHandPinky1.rotation":{x:.464,y:.086,z:.113},"RightHandPinky2.rotation":{x:.667,y:-.06,z:-.128},"RightHandPinky3.rotation":{x:0,y:0,z:0},"LeftShoulder.rotation":{x:1.545,y:-.116,z:-1.529},"LeftArm.rotation":{x:.799,y:.631,z:.556},"LeftForeArm.rotation":{x:-.002,y:.007,z:.926},"LeftHand.rotation":{x:-.508,y:.439,z:.502},"LeftHandThumb1.rotation":{x:.651,y:-.035,z:.308},"LeftHandThumb2.rotation":{x:-.053,y:.008,z:-.11},"LeftHandThumb3.rotation":{x:0,y:0,z:0},"LeftHandIndex1.rotation":{x:.662,y:-.053,z:-.116},"LeftHandIndex2.rotation":{x:.309,y:-.004,z:-.02},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:.501,y:-.062,z:-.12},"LeftHandMiddle2.rotation":{x:.144,y:-.002,z:.016},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.397,y:-.029,z:-.143},"LeftHandRing2.rotation":{x:.328,y:.01,z:.059},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.194,y:.008,z:-.164},"LeftHandPinky2.rotation":{x:.38,y:.031,z:.128},"LeftHandPinky3.rotation":{x:0,y:0,z:0},"RightUpLeg.rotation":{x:-1.594,y:-.251,z:2.792},"RightLeg.rotation":{x:-2.301,y:-.073,z:.055},"RightFoot.rotation":{x:1.553,y:-.207,z:-.094},"RightToeBase.rotation":{x:.459,y:.069,z:.016},"LeftUpLeg.rotation":{x:-.788,y:-.236,z:-2.881},"LeftLeg.rotation":{x:-2.703,y:.012,z:-.047},"LeftFoot.rotation":{x:2.191,y:-.102,z:.019},"LeftToeBase.rotation":{x:1.215,y:-.027,z:.01}}},kneel:{kneeling:!0,lying:!0,props:{"Hips.position":{x:0,y:.532,z:-.002},"Hips.rotation":{x:.018,y:-.008,z:-.017},"Spine.rotation":{x:-.139,y:-.01,z:.002},"Spine1.rotation":{x:.002,y:-.002,z:.001},"Spine2.rotation":{x:.028,y:-.002,z:.001},"Neck.rotation":{x:-.007,y:0,z:-.002},"Head.rotation":{x:-.02,y:-.008,z:-.004},"LeftShoulder.rotation":{x:1.77,y:-.428,z:-1.588},"LeftArm.rotation":{x:.911,y:.343,z:.083},"LeftForeArm.rotation":{x:0,y:0,z:.347},"LeftHand.rotation":{x:.033,y:-.052,z:-.105},"LeftHandThumb1.rotation":{x:.508,y:-.22,z:.708},"LeftHandThumb2.rotation":{x:-.323,y:-.139,z:-.56},"LeftHandThumb3.rotation":{x:-.328,y:.16,z:-.301},"LeftHandIndex1.rotation":{x:.178,y:.248,z:.045},"LeftHandIndex2.rotation":{x:.236,y:-.002,z:-.019},"LeftHandIndex3.rotation":{x:-.062,y:0,z:.005},"LeftHandMiddle1.rotation":{x:.123,y:-.005,z:-.019},"LeftHandMiddle2.rotation":{x:.589,y:-.014,z:-.045},"LeftHandMiddle3.rotation":{x:.231,y:-.002,z:-.019},"LeftHandRing1.rotation":{x:.196,y:-.008,z:-.091},"LeftHandRing2.rotation":{x:.483,y:-.009,z:-.038},"LeftHandRing3.rotation":{x:.367,y:-.005,z:-.029},"LeftHandPinky1.rotation":{x:.191,y:-.269,z:-.246},"LeftHandPinky2.rotation":{x:.37,y:-.006,z:-.029},"LeftHandPinky3.rotation":{x:.368,y:-.005,z:-.029},"RightShoulder.rotation":{x:1.73,y:.434,z:1.715},"RightArm.rotation":{x:.841,y:-.508,z:-.155},"RightForeArm.rotation":{x:0,y:0,z:-.355},"RightHand.rotation":{x:.091,y:.137,z:.197},"RightHandThumb1.rotation":{x:.33,y:.051,z:-.753},"RightHandThumb2.rotation":{x:-.113,y:.075,z:.612},"RightHandThumb3.rotation":{x:-.271,y:-.166,z:.164},"RightHandIndex1.rotation":{x:.073,y:.001,z:-.093},"RightHandIndex2.rotation":{x:.338,y:.006,z:.034},"RightHandIndex3.rotation":{x:.131,y:.001,z:.013},"RightHandMiddle1.rotation":{x:.13,y:.005,z:-.017},"RightHandMiddle2.rotation":{x:.602,y:.018,z:.058},"RightHandMiddle3.rotation":{x:-.031,y:0,z:-.003},"RightHandRing1.rotation":{x:.351,y:.019,z:.045},"RightHandRing2.rotation":{x:.19,y:.002,z:.019},"RightHandRing3.rotation":{x:.21,y:.002,z:.021},"RightHandPinky1.rotation":{x:.256,y:.17,z:.118},"RightHandPinky2.rotation":{x:.451,y:.01,z:.045},"RightHandPinky3.rotation":{x:.346,y:.006,z:.035},"LeftUpLeg.rotation":{x:-.06,y:.1,z:-2.918},"LeftLeg.rotation":{x:-1.933,y:-.01,z:.011},"LeftFoot.rotation":{x:.774,y:-.162,z:-.144},"LeftToeBase.rotation":{x:1.188,y:0,z:0},"RightUpLeg.rotation":{x:-.099,y:-.057,z:2.922},"RightLeg.rotation":{x:-1.93,y:.172,z:-.02},"RightFoot.rotation":{x:.644,y:.251,z:.212},"RightToeBase.rotation":{x:.638,y:-.034,z:-.001}}},sitting:{sitting:!0,lying:!0,props:{"Hips.position":{x:0,y:.117,z:.005},"Hips.rotation":{x:-.411,y:-.049,z:.056},"Spine.rotation":{x:.45,y:-.039,z:-.116},"Spine1.rotation":{x:.092,y:-.076,z:.08},"Spine2.rotation":{x:.073,y:.035,z:.066},"Neck.rotation":{x:.051,y:.053,z:-.079},"Head.rotation":{x:-.169,y:.009,z:.034},"LeftShoulder.rotation":{x:1.756,y:-.037,z:-1.301},"LeftArm.rotation":{x:-.098,y:.016,z:1.006},"LeftForeArm.rotation":{x:-.089,y:.08,z:.837},"LeftHand.rotation":{x:.262,y:-.399,z:.3},"LeftHandThumb1.rotation":{x:.149,y:-.043,z:.452},"LeftHandThumb2.rotation":{x:.032,y:.006,z:-.162},"LeftHandThumb3.rotation":{x:-.086,y:-.005,z:-.069},"LeftHandIndex1.rotation":{x:.145,y:.032,z:-.069},"LeftHandIndex2.rotation":{x:.325,y:-.001,z:-.004},"LeftHandIndex3.rotation":{x:.253,y:0,z:-.003},"LeftHandMiddle1.rotation":{x:.186,y:-.051,z:-.091},"LeftHandMiddle2.rotation":{x:.42,y:-.003,z:-.011},"LeftHandMiddle3.rotation":{x:.153,y:.001,z:-.001},"LeftHandRing1.rotation":{x:.087,y:-.19,z:-.078},"LeftHandRing2.rotation":{x:.488,y:-.004,z:-.005},"LeftHandRing3.rotation":{x:.183,y:-.001,z:-.012},"LeftHandPinky1.rotation":{x:.205,y:-.262,z:.051},"LeftHandPinky2.rotation":{x:.407,y:-.002,z:-.004},"LeftHandPinky3.rotation":{x:.068,y:0,z:-.002},"RightShoulder.rotation":{x:1.619,y:-.139,z:1.179},"RightArm.rotation":{x:.17,y:-.037,z:-1.07},"RightForeArm.rotation":{x:-.044,y:-.056,z:-.665},"RightHand.rotation":{x:.278,y:.454,z:-.253},"RightHandThumb1.rotation":{x:.173,y:.089,z:-.584},"RightHandThumb2.rotation":{x:-.003,y:-.004,z:.299},"RightHandThumb3.rotation":{x:-.133,y:-.002,z:.235},"RightHandIndex1.rotation":{x:.393,y:-.023,z:.108},"RightHandIndex2.rotation":{x:.391,y:.001,z:.004},"RightHandIndex3.rotation":{x:.326,y:0,z:.003},"RightHandMiddle1.rotation":{x:.285,y:.062,z:.086},"RightHandMiddle2.rotation":{x:.519,y:.003,z:.011},"RightHandMiddle3.rotation":{x:.252,y:-.001,z:.001},"RightHandRing1.rotation":{x:.207,y:.122,z:.155},"RightHandRing2.rotation":{x:.597,y:.004,z:.005},"RightHandRing3.rotation":{x:.292,y:.001,z:.012},"RightHandPinky1.rotation":{x:.338,y:.171,z:.149},"RightHandPinky2.rotation":{x:.533,y:.002,z:.004},"RightHandPinky3.rotation":{x:.194,y:0,z:.002},"LeftUpLeg.rotation":{x:-1.957,y:.083,z:-2.886},"LeftLeg.rotation":{x:-1.46,y:.123,z:.005},"LeftFoot.rotation":{x:-.013,y:.016,z:.09},"LeftToeBase.rotation":{x:.744,y:0,z:0},"RightUpLeg.rotation":{x:-1.994,y:.125,z:2.905},"RightLeg.rotation":{x:-1.5,y:-.202,z:-.006},"RightFoot.rotation":{x:-.012,y:-.065,z:.081},"RightToeBase.rotation":{x:.758,y:0,z:0}}}},this.gestureTemplates={handup:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.815,y:[-.4,0,1,2],z:1.575},"LeftHand.rotation":{x:-.529,y:-.2,z:.022},"LeftHandThumb1.rotation":{x:.745,y:-.526,z:.604},"LeftHandThumb2.rotation":{x:-.107,y:-.01,z:-.142},"LeftHandThumb3.rotation":{x:0,y:.001,z:0},"LeftHandIndex1.rotation":{x:-.126,y:-.035,z:-.087},"LeftHandIndex2.rotation":{x:.255,y:.007,z:-.085},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.019,y:-.128,z:-.082},"LeftHandMiddle2.rotation":{x:.233,y:.019,z:-.074},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.005,y:-.241,z:-.122},"LeftHandRing2.rotation":{x:.261,y:.021,z:-.076},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.059,y:-.336,z:-.2},"LeftHandPinky2.rotation":{x:.153,y:.019,z:.001},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},index:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.815,y:[-.4,0,1,2],z:1.575},"LeftHand.rotation":{x:-.276,y:-.506,z:-.208},"LeftHandThumb1.rotation":{x:.579,y:.228,z:.363},"LeftHandThumb2.rotation":{x:-.027,y:-.04,z:-.662},"LeftHandThumb3.rotation":{x:0,y:.001,z:0},"LeftHandIndex1.rotation":{x:0,y:-.105,z:.225},"LeftHandIndex2.rotation":{x:.256,y:-.103,z:-.213},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:1.453,y:.07,z:.021},"LeftHandMiddle2.rotation":{x:1.599,y:.062,z:.07},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:1.528,y:-.073,z:.052},"LeftHandRing2.rotation":{x:1.386,y:.044,z:.053},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:1.65,y:-.204,z:.031},"LeftHandPinky2.rotation":{x:1.302,y:.071,z:.085},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},ok:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,1],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.415,y:[-.4,0,1,2],z:1.575},"LeftHand.rotation":{x:-.476,y:-.506,z:-.208},"LeftHandThumb1.rotation":{x:.703,y:.445,z:.899},"LeftHandThumb2.rotation":{x:-.312,y:-.04,z:-.938},"LeftHandThumb3.rotation":{x:-.37,y:.024,z:-.393},"LeftHandIndex1.rotation":{x:.8,y:-.086,z:-.091},"LeftHandIndex2.rotation":{x:1.123,y:-.046,z:-.074},"LeftHandIndex3.rotation":{x:.562,y:-.013,z:-.043},"LeftHandMiddle1.rotation":{x:-.019,y:-.128,z:-.082},"LeftHandMiddle2.rotation":{x:.233,y:.019,z:-.074},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.005,y:-.241,z:-.122},"LeftHandRing2.rotation":{x:.261,y:.021,z:-.076},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.059,y:-.336,z:-.2},"LeftHandPinky2.rotation":{x:.153,y:.019,z:.001},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},thumbup:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.415,y:.206,z:1.575},"LeftHand.rotation":{x:-.276,y:-.506,z:-.208},"LeftHandThumb1.rotation":{x:.208,y:-.189,z:.685},"LeftHandThumb2.rotation":{x:.129,y:-.285,z:-.163},"LeftHandThumb3.rotation":{x:-.047,y:.068,z:.401},"LeftHandIndex1.rotation":{x:1.412,y:-.102,z:-.152},"LeftHandIndex2.rotation":{x:1.903,y:-.16,z:-.114},"LeftHandIndex3.rotation":{x:.535,y:-.017,z:-.062},"LeftHandMiddle1.rotation":{x:1.424,y:-.103,z:-.12},"LeftHandMiddle2.rotation":{x:1.919,y:-.162,z:-.114},"LeftHandMiddle3.rotation":{x:.44,y:-.012,z:-.051},"LeftHandRing1.rotation":{x:1.619,y:-.127,z:-.053},"LeftHandRing2.rotation":{x:1.898,y:-.16,z:-.115},"LeftHandRing3.rotation":{x:.262,y:-.004,z:-.031},"LeftHandPinky1.rotation":{x:1.661,y:-.131,z:-.016},"LeftHandPinky2.rotation":{x:1.715,y:-.067,z:-.13},"LeftHandPinky3.rotation":{x:.627,y:-.023,z:-.071}},thumbdown:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-2.015,y:.406,z:1.575},"LeftHand.rotation":{x:-.176,y:-.206,z:-.208},"LeftHandThumb1.rotation":{x:.208,y:-.189,z:.685},"LeftHandThumb2.rotation":{x:.129,y:-.285,z:-.163},"LeftHandThumb3.rotation":{x:-.047,y:.068,z:.401},"LeftHandIndex1.rotation":{x:1.412,y:-.102,z:-.152},"LeftHandIndex2.rotation":{x:1.903,y:-.16,z:-.114},"LeftHandIndex3.rotation":{x:.535,y:-.017,z:-.062},"LeftHandMiddle1.rotation":{x:1.424,y:-.103,z:-.12},"LeftHandMiddle2.rotation":{x:1.919,y:-.162,z:-.114},"LeftHandMiddle3.rotation":{x:.44,y:-.012,z:-.051},"LeftHandRing1.rotation":{x:1.619,y:-.127,z:-.053},"LeftHandRing2.rotation":{x:1.898,y:-.16,z:-.115},"LeftHandRing3.rotation":{x:.262,y:-.004,z:-.031},"LeftHandPinky1.rotation":{x:1.661,y:-.131,z:-.016},"LeftHandPinky2.rotation":{x:1.715,y:-.067,z:-.13},"LeftHandPinky3.rotation":{x:.627,y:-.023,z:-.071}},side:{"LeftShoulder.rotation":{x:1.755,y:-.035,z:-1.63},"LeftArm.rotation":{x:1.263,y:-.955,z:1.024},"LeftForeArm.rotation":{x:0,y:0,z:.8},"LeftHand.rotation":{x:-.36,y:-1.353,z:-.184},"LeftHandThumb1.rotation":{x:.137,y:-.049,z:.863},"LeftHandThumb2.rotation":{x:-.293,y:.153,z:-.193},"LeftHandThumb3.rotation":{x:-.271,y:-.17,z:.18},"LeftHandIndex1.rotation":{x:-.018,y:.007,z:.28},"LeftHandIndex2.rotation":{x:.247,y:-.003,z:-.025},"LeftHandIndex3.rotation":{x:.13,y:-.001,z:-.013},"LeftHandMiddle1.rotation":{x:.333,y:-.015,z:.182},"LeftHandMiddle2.rotation":{x:.313,y:-.005,z:-.032},"LeftHandMiddle3.rotation":{x:.294,y:-.004,z:-.03},"LeftHandRing1.rotation":{x:.456,y:-.028,z:-.092},"LeftHandRing2.rotation":{x:.53,y:-.014,z:-.052},"LeftHandRing3.rotation":{x:.478,y:-.012,z:-.047},"LeftHandPinky1.rotation":{x:.647,y:-.049,z:-.184},"LeftHandPinky2.rotation":{x:.29,y:-.004,z:-.029},"LeftHandPinky3.rotation":{x:.501,y:-.013,z:-.049}},shrug:{"Neck.rotation":{x:[-.3,.3,1,2],y:[-.3,.3,1,2],z:[-.1,.1]},"Head.rotation":{x:[-.3,.3],y:[-.3,.3],z:[-.1,.1]},"RightShoulder.rotation":{x:1.732,y:-.058,z:1.407},"RightArm.rotation":{x:1.305,y:.46,z:.118},"RightForeArm.rotation":{x:[0,2],y:[-1,.2],z:-1.637},"RightHand.rotation":{x:-.048,y:.165,z:-.39},"RightHandThumb1.rotation":{x:1.467,y:.599,z:-1.315},"RightHandThumb2.rotation":{x:-.255,y:-.123,z:.119},"RightHandThumb3.rotation":{x:0,y:-.002,z:0},"RightHandIndex1.rotation":{x:-.293,y:-.066,z:-.112},"RightHandIndex2.rotation":{x:.181,y:.007,z:.069},"RightHandIndex3.rotation":{x:0,y:0,z:0},"RightHandMiddle1.rotation":{x:-.063,y:-.041,z:.032},"RightHandMiddle2.rotation":{x:.149,y:.005,z:.05},"RightHandMiddle3.rotation":{x:0,y:0,z:0},"RightHandRing1.rotation":{x:.152,y:-.03,z:.132},"RightHandRing2.rotation":{x:.194,y:.007,z:.058},"RightHandRing3.rotation":{x:0,y:0,z:0},"RightHandPinky1.rotation":{x:.306,y:-.015,z:.257},"RightHandPinky2.rotation":{x:.15,y:-.003,z:-.003},"RightHandPinky3.rotation":{x:0,y:0,z:0},"LeftShoulder.rotation":{x:1.713,y:.141,z:-1.433},"LeftArm.rotation":{x:1.136,y:-.422,z:-.416},"LeftForeArm.rotation":{x:1.42,y:.123,z:1.506},"LeftHand.rotation":{x:.073,y:-.138,z:.064},"LeftHandThumb1.rotation":{x:1.467,y:-.599,z:1.314},"LeftHandThumb2.rotation":{x:-.255,y:.123,z:-.119},"LeftHandThumb3.rotation":{x:0,y:.001,z:0},"LeftHandIndex1.rotation":{x:-.293,y:.066,z:.112},"LeftHandIndex2.rotation":{x:.181,y:-.007,z:-.069},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.062,y:.041,z:-.032},"LeftHandMiddle2.rotation":{x:.149,y:-.005,z:-.05},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.152,y:.03,z:-.132},"LeftHandRing2.rotation":{x:.194,y:-.007,z:-.058},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.306,y:.015,z:-.257},"LeftHandPinky2.rotation":{x:.15,y:.003,z:.003},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},namaste:{"RightShoulder.rotation":{x:1.758,y:.099,z:1.604},"RightArm.rotation":{x:.862,y:-.292,z:-.932},"RightForeArm.rotation":{x:.083,y:.066,z:-1.791},"RightHand.rotation":{x:-.52,y:-.001,z:-.176},"RightHandThumb1.rotation":{x:.227,y:.418,z:-.776},"RightHandThumb2.rotation":{x:-.011,y:-.003,z:.171},"RightHandThumb3.rotation":{x:-.041,y:-.001,z:-.013},"RightHandIndex1.rotation":{x:-.236,y:.003,z:-.028},"RightHandIndex2.rotation":{x:.004,y:0,z:.001},"RightHandIndex3.rotation":{x:.002,y:0,z:0},"RightHandMiddle1.rotation":{x:-.236,y:.003,z:-.028},"RightHandMiddle2.rotation":{x:.004,y:0,z:.001},"RightHandMiddle3.rotation":{x:.002,y:0,z:0},"RightHandRing1.rotation":{x:-.236,y:.003,z:-.028},"RightHandRing2.rotation":{x:.004,y:0,z:.001},"RightHandRing3.rotation":{x:.002,y:0,z:0},"RightHandPinky1.rotation":{x:-.236,y:.003,z:-.028},"RightHandPinky2.rotation":{x:.004,y:0,z:.001},"RightHandPinky3.rotation":{x:.002,y:0,z:0},"LeftShoulder.rotation":{x:1.711,y:-.002,z:-1.625},"LeftArm.rotation":{x:.683,y:.334,z:.977},"LeftForeArm.rotation":{x:.086,y:-.066,z:1.843},"LeftHand.rotation":{x:-.595,y:-.229,z:.096},"LeftHandThumb1.rotation":{x:.404,y:-.05,z:.537},"LeftHandThumb2.rotation":{x:-.02,y:.004,z:-.154},"LeftHandThumb3.rotation":{x:-.049,y:.002,z:-.019},"LeftHandIndex1.rotation":{x:-.113,y:-.001,z:.014},"LeftHandIndex2.rotation":{x:.003,y:0,z:0},"LeftHandIndex3.rotation":{x:.002,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.113,y:-.001,z:.014},"LeftHandMiddle2.rotation":{x:.004,y:0,z:0},"LeftHandMiddle3.rotation":{x:.002,y:0,z:0},"LeftHandRing1.rotation":{x:-.113,y:-.001,z:.014},"LeftHandRing2.rotation":{x:.003,y:0,z:0},"LeftHandRing3.rotation":{x:.002,y:0,z:0},"LeftHandPinky1.rotation":{x:-.122,y:-.001,z:-.057},"LeftHandPinky2.rotation":{x:.012,y:.001,z:.07},"LeftHandPinky3.rotation":{x:.002,y:0,z:0}}},this.poseDelta={props:{"Hips.quaternion":{x:0,y:0,z:0},"Spine.quaternion":{x:0,y:0,z:0},"Spine1.quaternion":{x:0,y:0,z:0},"Neck.quaternion":{x:0,y:0,z:0},"Head.quaternion":{x:0,y:0,z:0},"Spine1.scale":{x:0,y:0,z:0},"Neck.scale":{x:0,y:0,z:0},"LeftArm.scale":{x:0,y:0,z:0},"RightArm.scale":{x:0,y:0,z:0}}},["Left","Right"].forEach(l=>{["Leg","UpLeg","Arm","ForeArm","Hand"].forEach(c=>{this.poseDelta.props[l+c+".quaternion"]={x:0,y:0,z:0}}),["HandThumb","HandIndex","HandMiddle","HandRing","HandPinky"].forEach(c=>{this.poseDelta.props[l+c+"1.quaternion"]={x:0,y:0,z:0},this.poseDelta.props[l+c+"2.quaternion"]={x:0,y:0,z:0},this.poseDelta.props[l+c+"3.quaternion"]={x:0,y:0,z:0}})});const n=new Set;Object.values(this.poseTemplates).forEach(l=>{Object.keys(this.propsToThreeObjects(l.props)).forEach(c=>n.add(c))}),Object.keys(this.poseDelta.props).forEach(l=>{n.add(l)}),this.posePropNames=[...n],this.poseName="side",this.poseWeightOnLeft=!0,this.gesture=null,this.poseCurrentTemplate=this.poseTemplates[this.poseName],this.poseStraight=this.propsToThreeObjects(this.poseTemplates.straight.props),this.poseBase=this.poseFactory(this.poseCurrentTemplate),this.poseTarget=this.poseFactory(this.poseCurrentTemplate),this.poseAvatar=null,this.avatarHeight=1.7,this.animTemplateEyes={name:"eyes",idle:{alt:[{p:()=>this.avatar?.hasOwnProperty("avatarIdleEyeContact")?this.avatar.avatarIdleEyeContact:this.opt.avatarIdleEyeContact,delay:[200,5e3],dt:[200,[2e3,5e3],[3e3,1e4,1,2]],vs:{headMove:[this.avatar?.hasOwnProperty("avatarIdleHeadMove")?this.avatar.avatarIdleHeadMove:this.opt.avatarIdleHeadMove],eyesRotateY:[[-.6,.6]],eyesRotateX:[[-.2,.6]],eyeContact:[null,1]}},{delay:[200,5e3],dt:[200,[2e3,5e3,1,2]],vs:{headMove:[this.avatar?.hasOwnProperty("avatarIdleHeadMove")?this.avatar.avatarIdleHeadMove:this.opt.avatarIdleHeadMove],eyesRotateY:[[-.6,.6]],eyesRotateX:[[-.2,.6]]}}]},speaking:{alt:[{p:()=>this.avatar?.hasOwnProperty("avatarSpeakingEyeContact")?this.avatar.avatarSpeakingEyeContact:this.opt.avatarSpeakingEyeContact,delay:[200,5e3],dt:[0,[3e3,1e4,1,2],[2e3,5e3]],vs:{eyeContact:[1,null],headMove:[null,this.avatar?.hasOwnProperty("avatarSpeakingHeadMove")?this.avatar.avatarSpeakingHeadMove:this.opt.avatarSpeakingHeadMove,null],eyesRotateY:[null,[-.6,.6]],eyesRotateX:[null,[-.2,.6]]}},{delay:[200,5e3],dt:[200,[2e3,5e3,1,2]],vs:{headMove:[this.avatar?.hasOwnProperty("avatarSpeakingHeadMove")?this.avatar.avatarSpeakingHeadMove:this.opt.avatarSpeakingHeadMove,null],eyesRotateY:[[-.6,.6]],eyesRotateX:[[-.2,.6]]}}]}},this.animTemplateBlink={name:"blink",alt:[{p:.85,delay:[1e3,8e3,1,2],dt:[50,[100,300],100],vs:{eyeBlinkLeft:[1,1,0],eyeBlinkRight:[1,1,0]}},{delay:[1e3,4e3,1,2],dt:[50,[100,200],100,[10,400,0],50,[100,200],100],vs:{eyeBlinkLeft:[1,1,0,0,1,1,0],eyeBlinkRight:[1,1,0,0,1,1,0]}}]},this.animMoods={neutral:{baseline:{eyesLookDown:0},speech:{deltaRate:0,deltaPitch:0,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1200,500,1e3],vs:{chestInhale:[.5,.5,0]}},{name:"pose",alt:[{p:.5,delay:[5e3,3e4],vs:{pose:["side"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.3,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{delay:[5e3,3e4],vs:{pose:["straight"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}}]},{name:"head",idle:{delay:[0,1e3],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.3,.3]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},happy:{baseline:{mouthSmile:.2,eyesLookDown:0},speech:{deltaRate:0,deltaPitch:.1,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1200,500,1e3],vs:{chestInhale:[.5,.5,0]}},{name:"pose",idle:{alt:[{p:.6,delay:[5e3,3e4],vs:{pose:["side"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.2,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.1,delay:[5e3,3e4],vs:{pose:["straight"]}},{delay:[5e3,1e4],vs:{pose:["wide"]}},{delay:[1e3,3e3],vs:{pose:["turn"]}}]},speaking:{alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.4,delay:[5e3,3e4],vs:{pose:["straight"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{delay:[5e3,2e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}}]}},{name:"head",idle:{dt:[[1e3,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.3,.3]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthLeft:[[0,.3,2]],mouthSmile:[[0,.2,3]],mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},angry:{baseline:{eyesLookDown:.1,browDownLeft:.6,browDownRight:.6,jawForward:.3,mouthFrownLeft:.7,mouthFrownRight:.7,mouthRollLower:.2,mouthShrugLower:.3,handFistLeft:1,handFistRight:1},speech:{deltaRate:-.2,deltaPitch:.2,deltaVolume:0},anims:[{name:"breathing",delay:500,dt:[1e3,500,1e3],vs:{chestInhale:[.7,.7,0]}},{name:"pose",alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]}},{p:.4,delay:[5e3,3e4],vs:{pose:["straight"]}},{p:.2,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}}]},{name:"head",idle:{delay:[100,500],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.2,.2]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},sad:{baseline:{eyesLookDown:.2,browDownRight:.1,browInnerUp:.6,browOuterUpRight:.2,eyeSquintLeft:.7,eyeSquintRight:.7,mouthFrownLeft:.8,mouthFrownRight:.8,mouthLeft:.2,mouthPucker:.5,mouthRollLower:.2,mouthRollUpper:.2,mouthShrugLower:.2,mouthShrugUpper:.2,mouthStretchLeft:.4},speech:{deltaRate:-.2,deltaPitch:-.2,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1e3,500,1e3],vs:{chestInhale:[.3,.3,0]}},{name:"pose",alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]}},{p:.4,delay:[5e3,3e4],vs:{pose:["straight"]}},{delay:[5e3,2e4],vs:{pose:["side"]},full:{delay:[5e3,2e4],vs:{pose:["oneknee"]}}}]},{name:"head",idle:{delay:[100,500],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.2,.2]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},fear:{baseline:{browInnerUp:.7,eyeSquintLeft:.5,eyeSquintRight:.5,eyeWideLeft:.6,eyeWideRight:.6,mouthClose:.1,mouthFunnel:.3,mouthShrugLower:.5,mouthShrugUpper:.5},speech:{deltaRate:-.2,deltaPitch:0,deltaVolume:0},anims:[{name:"breathing",delay:500,dt:[1e3,500,1e3],vs:{chestInhale:[.7,.7,0]}},{name:"pose",alt:[{p:.8,delay:[5e3,3e4],vs:{pose:["side"]}},{delay:[5e3,3e4],vs:{pose:["straight"]}},{delay:[5e3,2e4],vs:{pose:["wide"]}},{delay:[5e3,2e4],vs:{pose:["side"]},full:{delay:[5e3,2e4],vs:{pose:["oneknee"]}}}]},{name:"head",idle:{delay:[100,500],dt:[[200,3e3]],vs:{bodyRotateX:[[-.06,.12]],bodyRotateY:[[-.7,.7]],bodyRotateZ:[[-.1,.1]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},disgust:{baseline:{browDownLeft:.7,browDownRight:.1,browInnerUp:.3,eyeSquintLeft:1,eyeSquintRight:1,eyeWideLeft:.5,eyeWideRight:.5,eyesRotateX:.05,mouthLeft:.4,mouthPressLeft:.3,mouthRollLower:.3,mouthShrugLower:.3,mouthShrugUpper:.8,mouthUpperUpLeft:.3,noseSneerLeft:1,noseSneerRight:.7},speech:{deltaRate:-.2,deltaPitch:0,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1e3,500,1e3],vs:{chestInhale:[.5,.5,0]}},{name:"pose",alt:[{delay:[5e3,2e4],vs:{pose:["side"]}}]},{name:"head",idle:{delay:[100,500],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.2,.2]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},love:{baseline:{browInnerUp:.4,browOuterUpLeft:.2,browOuterUpRight:.2,mouthSmile:.2,eyeBlinkLeft:.6,eyeBlinkRight:.6,eyeWideLeft:.7,eyeWideRight:.7,bodyRotateX:.1,mouthDimpleLeft:.1,mouthDimpleRight:.1,mouthPressLeft:.2,mouthShrugUpper:.2,mouthUpperUpLeft:.1,mouthUpperUpRight:.1},speech:{deltaRate:-.1,deltaPitch:-.7,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1500,500,1500],vs:{chestInhale:[.8,.8,0]}},{name:"pose",alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]}},{p:.2,delay:[5e3,3e4],vs:{pose:["straight"]}},{p:.2,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["side"]}}},{delay:[5e3,1e4],vs:{pose:["side"]},full:{delay:[5e3,1e4],vs:{pose:["kneel"]}}},{delay:[1e3,3e3],vs:{pose:["turn"]},M:{delay:[1e3,3e3],vs:{pose:["wide"]}}},{delay:[1e3,3e3],vs:{pose:["back"]},M:{delay:[1e3,3e3],vs:{pose:["wide"]}}},{delay:[5e3,2e4],vs:{pose:["side"]},M:{delay:[5e3,2e4],vs:{pose:["side"]}},full:{delay:[5e3,2e4],vs:{pose:["bend"]}}},{delay:[1e3,3e3],vs:{pose:["side"]},full:{delay:[5e3,1e4],vs:{pose:["oneknee"]}}}]},{name:"head",idle:{dt:[[1e3,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.3,.3]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.deepCopy(this.animTemplateBlink,l=>{l.alt[0].delay[0]=l.alt[1].delay[0]=2e3}),{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthLeft:[[0,.3,2]],mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[500,1e3],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[.3,.6,2]],browOuterUpLeft:[[.1,.3,2]],browOuterUpRight:[[.1,.3,2]]}}]},sleep:{baseline:{eyeBlinkLeft:1,eyeBlinkRight:1,eyesClosed:.6},speech:{deltaRate:0,deltaPitch:-.2,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1e3,500,1e3],vs:{chestInhale:[.6,.6,0]}},{name:"pose",alt:[{delay:[5e3,2e4],vs:{pose:["side"]}}]},{name:"head",delay:[1e3,5e3],dt:[[2e3,1e4]],vs:{bodyRotateX:[[0,.4]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.04,.04]]}},{name:"eyes",delay:10010,dt:[],vs:{}},{name:"blink",delay:10020,dt:[],vs:{}},{name:"mouth",delay:10030,dt:[],vs:{}},{name:"misc",delay:10040,dt:[],vs:{}}]}},this.moodName=this.opt.avatarMood||"neutral",this.mood=this.animMoods[this.moodName],this.mood||(this.moodName="neutral",this.mood=this.animMoods.neutral),this.animEmojis={"😐":{dt:[300,2e3],rescale:[0,1],vs:{pose:["straight"],browInnerUp:[.4],eyeWideLeft:[.7],eyeWideRight:[.7],mouthPressLeft:[.6],mouthPressRight:[.6],mouthRollLower:[.3],mouthStretchLeft:[1],mouthStretchRight:[1]}},"😶":{link:"😐"},"😏":{dt:[300,2e3],rescale:[0,1],vs:{eyeContact:[0],browDownRight:[.1],browInnerUp:[.7],browOuterUpRight:[.2],eyeLookInRight:[.7],eyeLookOutLeft:[.7],eyeSquintLeft:[1],eyeSquintRight:[.8],eyesRotateY:[.7],mouthLeft:[.4],mouthPucker:[.4],mouthShrugLower:[.3],mouthShrugUpper:[.2],mouthSmile:[.2],mouthSmileLeft:[.4],mouthSmileRight:[.2],mouthStretchLeft:[.5],mouthUpperUpLeft:[.6],noseSneerLeft:[.7]}},"🙂":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5]}},"🙃":{link:"🙂"},"😊":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.6],eyeSquintLeft:[1],eyeSquintRight:[1],mouthSmile:[.7],noseSneerLeft:[.7],noseSneerRight:[.7]}},"😇":{link:"😊"},"😀":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.6],jawOpen:[.1],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😃":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.6],eyeWideLeft:[.7],eyeWideRight:[.7],jawOpen:[.1],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😄":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],jawOpen:[.2],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😁":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],jawOpen:[.3],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthPressLeft:[.5],mouthPressRight:[.5],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😆":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.6],jawOpen:[.3],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthPressLeft:[.5],mouthPressRight:[.5],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😝":{dt:[300,100,1500,500,500],rescale:[0,0,1,0,0],vs:{browInnerUp:[.8],eyesClosed:[1],jawOpen:[.7],mouthFunnel:[.5],mouthSmile:[1],tongueOut:[0,1,1,0]}},"😋":{link:"😝"},"😛":{link:"😝"},"😛":{link:"😝"},"😜":{link:"😝"},"🤪":{link:"😝"},"😂":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.6],jawOpen:[.3],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthPressLeft:[.5],mouthPressRight:[.5],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"🤣":{link:"😂"},"😅":{link:"😂"},"😉":{dt:[500,200,500,500],rescale:[0,0,0,1],vs:{mouthSmile:[.5],mouthOpen:[.2],mouthSmileLeft:[0,.5,0],eyeBlinkLeft:[0,.7,0],eyeBlinkRight:[0,0,0],bodyRotateX:[.05,.05,.05,0],bodyRotateZ:[-.05,-.05,-.05,0],browDownLeft:[0,.7,0],cheekSquintLeft:[0,.7,0],eyeSquintLeft:[0,1,0],eyesClosed:[0]}},"😭":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[1],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.1],jawOpen:[0],mouthFrownLeft:[1],mouthFrownRight:[1],mouthOpen:[.5],mouthPucker:[.5],mouthUpperUpLeft:[.6],mouthUpperUpRight:[.6]}},"🥺":{dt:[1e3,1e3],rescale:[0,1],vs:{browDownLeft:[.2],browDownRight:[.2],browInnerUp:[1],eyeWideLeft:[.9],eyeWideRight:[.9],eyesClosed:[.1],mouthClose:[.2],mouthFrownLeft:[1],mouthFrownRight:[1],mouthPressLeft:[.4],mouthPressRight:[.4],mouthPucker:[1],mouthRollLower:[.6],mouthRollUpper:[.2],mouthUpperUpLeft:[.8],mouthUpperUpRight:[.8]}},"😞":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[.7],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.5],bodyRotateX:[.3],mouthClose:[.2],mouthFrownLeft:[1],mouthFrownRight:[1],mouthPucker:[1],mouthRollLower:[1],mouthShrugLower:[.2],mouthUpperUpLeft:[.8],mouthUpperUpRight:[.8]}},"😔":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[1],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.5],bodyRotateX:[.3],mouthClose:[.2],mouthFrownLeft:[1],mouthFrownRight:[1],mouthPressLeft:[.4],mouthPressRight:[.4],mouthPucker:[1],mouthRollLower:[.6],mouthRollUpper:[.2],mouthUpperUpLeft:[.8],mouthUpperUpRight:[.8]}},"😳":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[1],eyeWideLeft:[.5],eyeWideRight:[.5],eyesRotateY:[.05],eyesRotateX:[.05],mouthClose:[.2],mouthFunnel:[.5],mouthPucker:[.4],mouthRollLower:[.4],mouthRollUpper:[.4]}},"☹️":{dt:[500,1500],rescale:[0,1],vs:{mouthFrownLeft:[1],mouthFrownRight:[1],mouthPucker:[.1],mouthRollLower:[.8]}},"😚":{dt:[500,1e3,1e3],rescale:[0,1,0],vs:{browInnerUp:[.6],eyeBlinkLeft:[1],eyeBlinkRight:[1],eyeSquintLeft:[1],eyeSquintRight:[1],mouthPucker:[0,.5],noseSneerLeft:[0,.7],noseSneerRight:[0,.7],viseme_U:[0,1]}},"😘":{dt:[500,500,200,500],rescale:[0,0,0,1],vs:{browInnerUp:[.6],eyeBlinkLeft:[0,0,1,0],eyeBlinkRight:[0],eyesRotateY:[0],bodyRotateY:[0],bodyRotateX:[0,.05,.05,0],bodyRotateZ:[0,-.05,-.05,0],eyeSquintLeft:[1],eyeSquintRight:[1],mouthPucker:[0,.5,0],noseSneerLeft:[0,.7],noseSneerRight:[.7],viseme_U:[0,1]}},"🥰":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[.6],eyeSquintLeft:[1],eyeSquintRight:[1],mouthSmile:[.7],noseSneerLeft:[.7],noseSneerRight:[.7]}},"😍":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[.6],jawOpen:[.1],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"🤩":{link:"😍"},"😡":{dt:[1e3,1500],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],eyesLookUp:[.2],jawForward:[.3],mouthFrownLeft:[1],mouthFrownRight:[1],bodyRotateX:[.15]}},"😠":{dt:[1e3,1500],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],eyesLookUp:[.2],jawForward:[.3],mouthFrownLeft:[1],mouthFrownRight:[1],bodyRotateX:[.15]}},"🤬":{link:"😠"},"😒":{dt:[1e3,1e3],rescale:[0,1],vs:{eyeContact:[0],browDownRight:[.1],browInnerUp:[.7],browOuterUpRight:[.2],eyeLookInRight:[.7],eyeLookOutLeft:[.7],eyeSquintLeft:[1],eyeSquintRight:[.8],eyesRotateY:[.7],mouthFrownLeft:[1],mouthFrownRight:[1],mouthLeft:[.2],mouthPucker:[.5],mouthRollLower:[.2],mouthRollUpper:[.2],mouthShrugLower:[.2],mouthShrugUpper:[.2],mouthStretchLeft:[.5]}},"😱":{dt:[500,1500],rescale:[0,1],vs:{browInnerUp:[.8],eyeWideLeft:[.5],eyeWideRight:[.5],jawOpen:[.7],mouthFunnel:[.5]}},"😬":{dt:[500,1500],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],browInnerUp:[1],mouthDimpleLeft:[.5],mouthDimpleRight:[.5],mouthLowerDownLeft:[1],mouthLowerDownRight:[1],mouthPressLeft:[.4],mouthPressRight:[.4],mouthPucker:[.5],mouthSmile:[.1],mouthSmileLeft:[.2],mouthSmileRight:[.2],mouthStretchLeft:[1],mouthStretchRight:[1],mouthUpperUpLeft:[1],mouthUpperUpRight:[1]}},"🙄":{dt:[500,1500],rescale:[0,1],vs:{browInnerUp:[.8],eyeWideLeft:[1],eyeWideRight:[1],eyesRotateX:[-.8],bodyRotateX:[.15],mouthPucker:[.5],mouthRollLower:[.6],mouthRollUpper:[.5],mouthShrugLower:[0],mouthSmile:[0]}},"🤔":{dt:[500,1500],rescale:[0,1],vs:{browDownLeft:[1],browOuterUpRight:[1],eyeSquintLeft:[.6],mouthFrownLeft:[.7],mouthFrownRight:[.7],mouthLowerDownLeft:[.3],mouthPressRight:[.4],mouthPucker:[.1],mouthRight:[.5],mouthRollLower:[.5],mouthRollUpper:[.2],handRight:[{x:.1,y:.1,z:.1,d:1e3},{d:1e3}],handFistRight:[.1]}},"👀":{dt:[500,1500],rescale:[0,1],vs:{eyesRotateY:[-.8]}},"😴":{dt:[5e3,5e3],rescale:[0,1],vs:{eyeBlinkLeft:[1],eyeBlinkRight:[1],bodyRotateX:[.2],bodyRotateZ:[.1]}},"✋":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["handup",2,!0],null]}},"🤚":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["handup",2],null]}},"👋":{link:"✋"},"👍":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["thumbup",2],null]}},"👎":{dt:[300,2e3],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],eyesLookUp:[.2],jawForward:[.3],mouthFrownLeft:[1],mouthFrownRight:[1],bodyRotateX:[.15],gesture:[["thumbdown",2],null]}},"👌":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["ok",2],null]}},"🤷♂️":{dt:[1e3,1500],rescale:[0,1],vs:{gesture:[["shrug",2],null]}},"🤷♀️":{link:"🤷♂️"},"🤷":{link:"🤷♂️"},"🙏":{dt:[1500,300,1e3],rescale:[0,1,0],vs:{eyeBlinkLeft:[0,1],eyeBlinkRight:[0,1],bodyRotateX:[0],bodyRotateZ:[.1],gesture:[["namaste",2],null]}},yes:{dt:[[200,500],[200,500],[200,500],[200,500]],vs:{headMove:[0],headRotateX:[[.1,.2],.1,[.1,.2],0],headRotateZ:[[-.2,.2]]}},no:{dt:[[200,500],[200,500],[200,500],[200,500],[200,500]],vs:{headMove:[0],headRotateY:[[-.1,-.05],[.05,.1],[-.1,-.05],[.05,.1],0],headRotateZ:[[-.2,.2]]}}},this.mtAvatar={},this.mtCustoms=["handFistLeft","handFistRight","bodyRotateX","bodyRotateY","bodyRotateZ","headRotateX","headRotateY","headRotateZ","chestInhale"],this.mtEasingDefault=this.sigmoidFactory(5),this.mtAccDefault=.01,this.mtAccExceptions={eyeBlinkLeft:.1,eyeBlinkRight:.1,eyeLookOutLeft:.1,eyeLookInLeft:.1,eyeLookOutRight:.1,eyeLookInRight:.1},this.mtMaxVDefault=5,this.mtMaxVExceptions={bodyRotateX:1,bodyRotateY:1,bodyRotateZ:1},this.mtBaselineDefault=0,this.mtBaselineExceptions={bodyRotateX:null,bodyRotateY:null,bodyRotateZ:null,eyeLookOutLeft:null,eyeLookInLeft:null,eyeLookOutRight:null,eyeLookInRight:null,eyesLookDown:null,eyesLookUp:null},this.mtMinDefault=0,this.mtMinExceptions={bodyRotateX:-1,bodyRotateY:-1,bodyRotateZ:-1,headRotateX:-1,headRotateY:-1,headRotateZ:-1},this.mtMaxDefault=1,this.mtMaxExceptions={},this.mtLimits={eyeBlinkLeft:l=>Math.max(l,(this.mtAvatar.eyesLookDown.value+this.mtAvatar.browDownLeft.value)/2),eyeBlinkRight:l=>Math.max(l,(this.mtAvatar.eyesLookDown.value+this.mtAvatar.browDownRight.value)/2)},this.mtOnchange={eyesLookDown:()=>{this.mtAvatar.eyeBlinkLeft.needsUpdate=!0,this.mtAvatar.eyeBlinkRight.needsUpdate=!0},browDownLeft:()=>{this.mtAvatar.eyeBlinkLeft.needsUpdate=!0},browDownRight:()=>{this.mtAvatar.eyeBlinkRight.needsUpdate=!0}},this.mtRandomized=["mouthDimpleLeft","mouthDimpleRight","mouthLeft","mouthPressLeft","mouthPressRight","mouthStretchLeft","mouthStretchRight","mouthShrugLower","mouthShrugUpper","noseSneerLeft","noseSneerRight","mouthRollLower","mouthRollUpper","browDownLeft","browDownRight","browOuterUpLeft","browOuterUpRight","cheekPuff","cheekSquintLeft","cheekSquintRight"],this.mtExtras=[{key:"mouthOpen",mix:{jawOpen:.5}},{key:"mouthSmile",mix:{mouthSmileLeft:.8,mouthSmileRight:.8}},{key:"eyesClosed",mix:{eyeBlinkLeft:1,eyeBlinkRight:1}},{key:"eyesLookUp",mix:{eyeLookUpLeft:1,eyeLookUpRight:1}},{key:"eyesLookDown",mix:{eyeLookDownLeft:1,eyeLookDownRight:1}}],this.animQueue=[],this.animClips=[],this.animPoses=[],this.animFrameDur=1e3/this.opt.modelFPS,this.animClock=0,this.animSlowdownRate=1,this.animTimeLast=0,this.easing=this.sigmoidFactory(5),this.lipsync={},this.opt.lipsyncModules.forEach(l=>{this.lipsyncGetProcessor(l)}),this.visemeNames=["aa","E","I","O","U","PP","SS","TH","DD","FF","kk","nn","RR","CH","sil"],this.segmenter=new Intl.Segmenter("en",{granularity:"grapheme"}),this.initAudioGraph(),this.audioPlaylist=[],this.volumeFrequencyData=new Uint8Array(16),this.volumeMax=0,this.volumeHeadBase=0,this.volumeHeadTarget=0,this.volumeHeadCurrent=0,this.volumeHeadVelocity=.15,this.volumeHeadEasing=this.sigmoidFactory(3),this.isListening=!1,this.listeningAnalyzer=null,this.listeningActive=!1,this.listeningVolume=0,this.listeningSilenceThresholdLevel=this.opt.listeningSilenceThresholdLevel,this.listeningSilenceThresholdMs=this.opt.listeningSilenceThresholdMs,this.listeningSilenceDurationMax=this.opt.listeningSilenceDurationMax,this.listeningActiveThresholdLevel=this.opt.listeningActiveThresholdLevel,this.listeningActiveThresholdMs=this.opt.listeningActiveThresholdMs,this.listeningActiveDurationMax=this.opt.listeningActiveDurationMax,this.listeningTimer=0,this.listeningTimerTotal=0,this.dracoEnabled=this.opt.dracoEnabled,this.dracoDecoderPath=this.opt.dracoDecoderPath;const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";this.b64Lookup=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let l=0;l<i.length;l++)this.b64Lookup[i.charCodeAt(l)]=l;if(this.stateName="idle",this.speechQueue=[],this.isSpeaking=!1,this.isListening=!1,this.opt.ttsEndpoint){let l=new Audio;if(l.canPlayType("audio/ogg"))this.ttsAudioEncoding="OGG-OPUS";else if(l.canPlayType("audio/mp3"))this.ttsAudioEncoding="MP3";else throw new Error("There was no support for either OGG or MP3 audio.")}if(this.isAvatarOnly=this.opt.avatarOnly,this.isAvatarOnly)this.scene=this.opt.avatarOnlyScene,this.camera=this.opt.avatarOnlyCamera;else{this.renderer=new y.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(this.opt.modelPixelRatio*window.devicePixelRatio),this.renderer.setSize(this.nodeAvatar.clientWidth,this.nodeAvatar.clientHeight),this.renderer.outputColorSpace=y.SRGBColorSpace,this.renderer.toneMapping=y.ACESFilmicToneMapping,this.renderer.shadowMap.enabled=!1,this.nodeAvatar.appendChild(this.renderer.domElement),this.camera=new y.PerspectiveCamera(10,this.nodeAvatar.clientWidth/this.nodeAvatar.clientHeight,.1,2e3),this.scene=new y.Scene,this.lightAmbient=new y.AmbientLight(new y.Color(this.opt.lightAmbientColor),this.opt.lightAmbientIntensity),this.lightDirect=new y.DirectionalLight(new y.Color(this.opt.lightDirectColor),this.opt.lightDirectIntensity),this.lightSpot=new y.SpotLight(new y.Color(this.opt.lightSpotColor),this.opt.lightSpotIntensity,0,this.opt.lightSpotDispersion),this.setLighting(this.opt);const l=new y.PMREMGenerator(this.renderer);l.compileEquirectangularShader(),this.scene.environment=l.fromScene(new Ye.RoomEnvironment).texture,this.resizeobserver=new ResizeObserver(this.onResize.bind(this)),this.resizeobserver.observe(this.nodeAvatar),this.controls=new Xe.OrbitControls(this.camera,this.renderer.domElement),this.controls.enableZoom=this.opt.cameraZoomEnable,this.controls.enableRotate=this.opt.cameraRotateEnable,this.controls.enablePan=this.opt.cameraPanEnable,this.controls.minDistance=2,this.controls.maxDistance=2e3,this.controls.autoRotateSpeed=0,this.controls.autoRotate=!1,this.controls.update(),this.cameraClock=null}this.ikMesh=new y.SkinnedMesh;const s={LeftShoulder:null,LeftArm:"LeftShoulder",LeftForeArm:"LeftArm",LeftHand:"LeftForeArm",LeftHandMiddle1:"LeftHand",RightShoulder:null,RightArm:"RightShoulder",RightForeArm:"RightArm",RightHand:"RightForeArm",RightHandMiddle1:"RightHand"},o=[];Object.entries(s).forEach((l,c)=>{const r=new y.Bone;r.name=l[0],l[1]?this.ikMesh.getObjectByName(l[1]).add(r):this.ikMesh.add(r),o.push(r)}),this.ikMesh.bind(new y.Skeleton(o)),this.dynamicbones=new $e,this.isStreaming=!1,this.streamWorkletNode=null,this.streamAudioStartTime=null,this.streamWaitForAudioChunks=!0,this.streamLipsyncLang=null,this.streamLipsyncType="visemes",this.streamLipsyncQueue=[]}initAudioGraph(t=null){if(this.audioCtx&&this.audioCtx.state!=="closed"&&this.audioCtx.close(),t?this.audioCtx=new AudioContext({sampleRate:t}):this.audioCtx=new AudioContext,this.audioSpeechSource=this.audioCtx.createBufferSource(),this.audioBackgroundSource=this.audioCtx.createBufferSource(),this.audioBackgroundGainNode=this.audioCtx.createGain(),this.audioSpeechGainNode=this.audioCtx.createGain(),this.audioStreamGainNode=this.audioCtx.createGain(),this.audioAnalyzerNode=this.audioCtx.createAnalyser(),this.audioAnalyzerNode.fftSize=256,this.audioAnalyzerNode.smoothingTimeConstant=.1,this.audioAnalyzerNode.minDecibels=-70,this.audioAnalyzerNode.maxDecibels=-10,this.audioAnalyzer=new et(this.audioCtx),this.audioReverbNode=this.audioCtx.createConvolver(),this.audioBackgroundGainNode.connect(this.audioReverbNode),this.audioAnalyzerNode.connect(this.audioSpeechGainNode),this.audioSpeechGainNode.connect(this.audioReverbNode),this.audioStreamGainNode.connect(this.audioReverbNode),this.audioReverbNode.connect(this.audioCtx.destination),this.setReverb(this.currentReverb||null),this.setMixerGain(this.opt.mixerGainSpeech,this.opt.mixerGainBackground),this.workletLoaded=!1,this.streamWorkletNode){try{this.streamWorkletNode.port.postMessage({type:"stop"}),this.streamWorkletNode.disconnect(),this.isStreaming=!1}catch(e){console.error("Error disconnecting streamWorkletNode:",e)}this.streamWorkletNode=null}}valueFn(t){return typeof t=="function"?t():t}deepCopy(t,e=null){const n=JSON.parse(JSON.stringify(t));return e&&typeof e=="function"&&e(n),n}b64ToArrayBuffer(t){let e=3*t.length/4;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const n=new ArrayBuffer(e),i=new Uint8Array(n);let s,o=0,l,c,r,u;for(s=0;s<t.length;s+=4)l=this.b64Lookup[t.charCodeAt(s)],c=this.b64Lookup[t.charCodeAt(s+1)],r=this.b64Lookup[t.charCodeAt(s+2)],u=this.b64Lookup[t.charCodeAt(s+3)],i[o++]=l<<2|c>>4,i[o++]=(c&15)<<4|r>>2,i[o++]=(r&3)<<6|u&63;return n}concatArrayBuffers(t){if(t.length===1)return t[0];let e=0;for(let o=0;o<t.length;o++)e+=t[o].byteLength;let n=new ArrayBuffer(e),i=new Uint8Array(n),s=0;for(let o=0;o<t.length;o++)i.set(new Uint8Array(t[o]),s),s+=t[o].byteLength;return n}pcmToAudioBuffer(t){const e=new Int16Array(t),n=new Float32Array(e.length);for(let s=0;s<e.length;s++)n[s]=e[s]>=32768?-(65536-e[s])/32768:e[s]/32767;const i=this.audioCtx.createBuffer(1,n.length,this.opt.pcmSampleRate);return i.copyToChannel(n,0,0),i}propsToThreeObjects(t){const e={};for(let[n,i]of Object.entries(t)){const s=n.split(".");let o=Array.isArray(i.x)?this.gaussianRandom(...i.x):i.x,l=Array.isArray(i.y)?this.gaussianRandom(...i.y):i.y,c=Array.isArray(i.z)?this.gaussianRandom(...i.z):i.z;s[1]==="position"||s[1]==="scale"?e[n]=new y.Vector3(o,l,c):s[1]==="rotation"?(n=s[0]+".quaternion",e[n]=new y.Quaternion().setFromEuler(new y.Euler(o,l,c,"XYZ")).normalize()):s[1]==="quaternion"&&(e[n]=new y.Quaternion(o,l,c,i.w).normalize())}return e}clearThree(t){for(;t.children.length;)this.clearThree(t.children[0]),t.remove(t.children[0]);t.geometry&&t.geometry.dispose(),t.material&&(Object.keys(t.material).forEach(e=>{t.material[e]&&t.material[e]!==null&&typeof t.material[e].dispose=="function"&&t.material[e].dispose()}),t.material.dispose())}addMixedMorphTarget(t,e,n,i=!1){t.forEach(s=>{if(!i&&s.morphTargetDictionary.hasOwnProperty(e))return;const o=s.geometry;let l=null,c=null;for(const[r,u]of Object.entries(n))if(s.morphTargetDictionary.hasOwnProperty(r)){const a=s.morphTargetDictionary[r],d=o.morphAttributes.position[a],h=o.morphAttributes.normal?.[a];l||(l=new y.Float32BufferAttribute(d.count*3,3),h&&(c=new y.Float32BufferAttribute(d.count*3,3)));for(let g=0;g<d.count;g++){const x=l.getX(g)+d.getX(g)*u,f=l.getY(g)+d.getY(g)*u,w=l.getZ(g)+d.getZ(g)*u;l.setXYZ(g,x,f,w)}if(h)for(let g=0;g<d.count;g++){const x=c.getX(g)+h.getX(g)*u,f=c.getY(g)+h.getY(g)*u,w=c.getZ(g)+h.getZ(g)*u;c.setXYZ(g,x,f,w)}}if(l){o.morphAttributes.position.push(l),c&&o.morphAttributes.normal.push(c);const r=o.morphAttributes.position.length-1;s.morphTargetInfluences[r]=0,s.morphTargetDictionary[e]=r}})}async showAvatar(t,e=null){if(!t||!t.hasOwnProperty("url"))throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");const n=new Ze.GLTFLoader;if(this.dracoEnabled){const r=new je.DRACOLoader;r.setDecoderPath(this.dracoDecoderPath),n.setDRACOLoader(r)}let i=await n.loadAsync(t.url,e);const s=[this.opt.modelRoot];if(this.posePropNames.forEach(r=>s.push(r.split(".")[0])),s.forEach(r=>{if(!i.scene.getObjectByName(r))throw new Error("Avatar object "+r+" not found")}),this.stop(),this.avatar=t,this.bodyMovement=t.bodyMovement||"idle",this.movementIntensity=t.movementIntensity||.5,this.showFullAvatar=t.showFullAvatar||!1,this.fbxAnimationLoader=null,this.dynamicbones.dispose(),this.mixer=null,this.isAvatarOnly?this.armature&&this.clearThree(this.armature):this.armature&&this.clearThree(this.scene),this.armature=i.scene.getObjectByName(this.opt.modelRoot),this.armature.scale.setScalar(1),this.animations=i.animations,this.userData=i.userData,this.morphs=[],this.armature.traverse(r=>{r.morphTargetInfluences&&r.morphTargetInfluences.length&&r.morphTargetDictionary&&this.morphs.push(r),r.frustumCulled=!1}),this.morphs.length===0)throw new Error("Blend shapes not found");const o=new Set(this.mtCustoms);this.morphs.forEach(r=>{Object.keys(r.morphTargetDictionary).forEach(u=>o.add(u))}),this.mtExtras.forEach(r=>{o.has(r.key)||(this.addMixedMorphTarget(this.morphs,r.key,r.mix),o.add(r.key))});const l={};if(o.forEach(r=>{l[r]={fixed:null,realtime:null,system:null,systemd:null,newvalue:null,ref:null,min:this.mtMinExceptions.hasOwnProperty(r)?this.mtMinExceptions[r]:this.mtMinDefault,max:this.mtMaxExceptions.hasOwnProperty(r)?this.mtMaxExceptions[r]:this.mtMaxDefault,easing:this.mtEasingDefault,base:null,v:0,needsUpdate:!0,acc:(this.mtAccExceptions.hasOwnProperty(r)?this.mtAccExceptions[r]:this.mtAccDefault)/1e3,maxv:(this.mtMaxVExceptions.hasOwnProperty(r)?this.mtMaxVExceptions[r]:this.mtMaxVDefault)/1e3,limit:this.mtLimits.hasOwnProperty(r)?this.mtLimits[r]:null,onchange:this.mtOnchange.hasOwnProperty(r)?this.mtOnchange[r]:null,baseline:this.avatar.baseline?.hasOwnProperty(r)?this.avatar.baseline[r]:this.mtBaselineExceptions.hasOwnProperty(r)?this.mtBaselineExceptions[r]:this.mtBaselineDefault,ms:[],is:[]},l[r].value=l[r].baseline,l[r].applied=l[r].baseline;const u=this.mtAvatar[r];u&&["fixed","system","systemd","realtime","base","v","value","applied"].forEach(a=>{l[r][a]=u[a]}),this.morphs.forEach(a=>{const d=a.morphTargetDictionary[r];d!==void 0&&(l[r].ms.push(a.morphTargetInfluences),l[r].is.push(d),a.morphTargetInfluences[d]=l[r].applied)})}),this.mtAvatar=l,this.poseAvatar={props:{}},this.posePropNames.forEach(r=>{const u=r.split("."),a=this.armature.getObjectByName(u[0]);this.poseAvatar.props[r]=a[u[1]],this.poseBase.props.hasOwnProperty(r)?this.poseAvatar.props[r].copy(this.poseBase.props[r]):this.poseBase.props[r]=this.poseAvatar.props[r].clone(),this.poseDelta.props.hasOwnProperty(r)&&!this.poseTarget.props.hasOwnProperty(r)&&(this.poseTarget.props[r]=this.poseAvatar.props[r].clone()),this.poseTarget.props[r].t=this.animClock,this.poseTarget.props[r].d=2e3}),this.ikMesh.traverse(r=>{r.isBone&&r.position.copy(this.armature.getObjectByName(r.name).position)}),this.isAvatarOnly?this.scene&&this.scene.add(this.armature):(this.scene.add(i.scene),this.scene.add(this.lightAmbient),this.scene.add(this.lightDirect),this.scene.add(this.lightSpot),this.lightSpot.target=this.armature.getObjectByName("Head")),t.hasOwnProperty("modelDynamicBones"))try{this.dynamicbones.setup(this.scene,this.armature,t.modelDynamicBones)}catch(r){console.error("Dynamic bones setup failed: "+r)}this.objectLeftToeBase=this.armature.getObjectByName("LeftToeBase"),this.objectRightToeBase=this.armature.getObjectByName("RightToeBase"),this.objectLeftEye=this.armature.getObjectByName("LeftEye"),this.objectRightEye=this.armature.getObjectByName("RightEye"),this.objectLeftArm=this.armature.getObjectByName("LeftArm"),this.objectRightArm=this.armature.getObjectByName("RightArm"),this.objectHips=this.armature.getObjectByName("Hips"),this.objectHead=this.armature.getObjectByName("Head"),this.objectNeck=this.armature.getObjectByName("Neck");const c=new y.Vector3;this.objectLeftEye.getWorldPosition(c),this.avatarHeight=c.y+.2,this.viewName||this.setView(this.opt.cameraView),this.setMood(this.avatar.avatarMood||this.moodName||this.opt.avatarMood),this.avatar.body==="M"&&this.poseTemplates.wide&&(this.poseName="wide",this.setPoseFromTemplate(this.poseTemplates.wide,0),console.log("Set initial male-appropriate pose: wide")),this.initializeFBXAnimationLoader(),this.bodyMovement&&this.bodyMovement!=="idle"&&this.applyBodyMovementAnimation(),this.start()}getViewNames(){return["full","mid","upper","head"]}getView(){return this.viewName}setView(t,e=null){if(t=t||this.viewName,t!=="full"&&t!=="upper"&&t!=="head"&&t!=="mid")return;if(!this.armature){this.opt.cameraView=t;return}if(this.viewName=t||this.viewName,e=e||{},this.isAvatarOnly)return;const n=e.hasOwnProperty("cameraX")?e.cameraX:this.opt.cameraX,i=e.hasOwnProperty("cameraY")?e.cameraY:this.opt.cameraY,s=e.hasOwnProperty("cameraDistance")?e.cameraDistance:this.opt.cameraDistance,o=e.hasOwnProperty("cameraRotateX")?e.cameraRotateX:this.opt.cameraRotateX,l=e.hasOwnProperty("cameraRotateY")?e.cameraRotateY:this.opt.cameraRotateY,c=this.camera.fov*(Math.PI/180);let r=-n*Math.tan(c/2),u=(1-i)*Math.tan(c/2),a=s;switch(this.viewName){case"head":a+=2,u=u*a+4*this.avatarHeight/5;break;case"upper":a+=4.5,u=u*a+2*this.avatarHeight/3;break;case"mid":a+=8,u=u*a+this.avatarHeight/3;break;default:a+=12,u=u*a}r=r*a,this.controlsEnd=new y.Vector3(r,u,0),this.cameraEnd=new y.Vector3(r,u,a).applyEuler(new y.Euler(o,l,0)),this.cameraClock===null&&(this.controls.target.copy(this.controlsEnd),this.camera.position.copy(this.cameraEnd)),this.controlsStart=this.controls.target.clone(),this.cameraStart=this.camera.position.clone(),this.cameraClock=0}setLighting(t){this.isAvatarOnly||(t=t||{},t.hasOwnProperty("lightAmbientColor")&&this.lightAmbient.color.set(new y.Color(t.lightAmbientColor)),t.hasOwnProperty("lightAmbientIntensity")&&(this.lightAmbient.intensity=t.lightAmbientIntensity,this.lightAmbient.visible=t.lightAmbientIntensity!==0),t.hasOwnProperty("lightDirectColor")&&this.lightDirect.color.set(new y.Color(t.lightDirectColor)),t.hasOwnProperty("lightDirectIntensity")&&(this.lightDirect.intensity=t.lightDirectIntensity,this.lightDirect.visible=t.lightDirectIntensity!==0),t.hasOwnProperty("lightDirectPhi")&&t.hasOwnProperty("lightDirectTheta")&&this.lightDirect.position.setFromSphericalCoords(2,t.lightDirectPhi,t.lightDirectTheta),t.hasOwnProperty("lightSpotColor")&&this.lightSpot.color.set(new y.Color(t.lightSpotColor)),t.hasOwnProperty("lightSpotIntensity")&&(this.lightSpot.intensity=t.lightSpotIntensity,this.lightSpot.visible=t.lightSpotIntensity!==0),t.hasOwnProperty("lightSpotPhi")&&t.hasOwnProperty("lightSpotTheta")&&(this.lightSpot.position.setFromSphericalCoords(2,t.lightSpotPhi,t.lightSpotTheta),this.lightSpot.position.add(new y.Vector3(0,1.5,0))),t.hasOwnProperty("lightSpotDispersion")&&(this.lightSpot.angle=t.lightSpotDispersion))}render(){this.isRunning&&!this.isAvatarOnly&&this.renderer&&this.renderer.render(this.scene,this.camera)}onResize(){!this.isAvatarOnly&&this.renderer&&(this.camera.aspect=this.nodeAvatar.clientWidth/this.nodeAvatar.clientHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.nodeAvatar.clientWidth,this.nodeAvatar.clientHeight),this.controls.update(),this.render())}updatePoseBase(t){for(const[e,n]of Object.entries(this.poseTarget.props)){const i=this.poseAvatar.props[e];if(i){let s=(t-n.t)/n.d;s>1||!this.poseBase.props.hasOwnProperty(e)?i.copy(n):i.isQuaternion?i.copy(this.poseBase.props[e].slerp(n,this.easing(s))):i.isVector3&&i.copy(this.poseBase.props[e].lerp(n,this.easing(s)))}}this.applyShoulderAdjustment()}applyShoulderAdjustment(){const t=new y.Euler,e=.6,n=.7;if(this.poseAvatar.props["LeftShoulder.quaternion"]){const i=this.poseAvatar.props["LeftShoulder.quaternion"];t.setFromQuaternion(i,"XYZ"),t.x>n?t.x=e:t.x>e&&(t.x=e+(t.x-e)*.2),i.setFromEuler(t,"XYZ")}if(this.poseAvatar.props["RightShoulder.quaternion"]){const i=this.poseAvatar.props["RightShoulder.quaternion"];t.setFromQuaternion(i,"XYZ"),t.x>n?t.x=e:t.x>e&&(t.x=e+(t.x-e)*.2),i.setFromEuler(t,"XYZ")}}applyShoulderAdjustmentToBones(){if(!this.armature)return;const t=this.armature.getObjectByName("LeftShoulder"),e=this.armature.getObjectByName("RightShoulder");if(!t||!e)return;const n=new y.Euler,i=new y.Quaternion,s=this.mixer&&this.currentFBXAction&&this.currentFBXAction.isRunning(),o=.5,l=.6;t.quaternion&&(n.setFromQuaternion(t.quaternion,"XYZ"),n.x>l?n.x=o:n.x>o&&(s?n.x=o:n.x=o+(n.x-o)*.1),i.setFromEuler(n,"XYZ"),t.quaternion.copy(i),t.updateMatrixWorld(!0)),e.quaternion&&(n.setFromQuaternion(e.quaternion,"XYZ"),n.x>l?n.x=o:n.x>o&&(s?n.x=o:n.x=o+(n.x-o)*.1),i.setFromEuler(n,"XYZ"),e.quaternion.copy(i),e.updateMatrixWorld(!0))}updatePoseDelta(){for(const[t,e]of Object.entries(this.poseDelta.props)){if(e.x===0&&e.y===0&&e.z===0)continue;G.set(e.x,e.y,e.z);const n=this.poseAvatar.props[t];n.isQuaternion?(J.setFromEuler(G),n.multiply(J)):n.isVector3&&n.add(G)}}updateMorphTargets(t){for(let[e,n]of Object.entries(this.mtAvatar)){if(!n.needsUpdate)continue;let i=null,s=null;if(n.fixed!==null){if(i=n.fixed,n.system=null,n.systemd=null,n.newvalue=null,n.ref&&n.ref.hasOwnProperty(e)&&delete n.ref[e],n.ref=null,n.base=null,n.value===i){n.needsUpdate=!1;continue}}else n.realtime!==null?(n.ref=null,n.base=null,s=n.realtime):n.system!==null?(i=n.system,n.newvalue=null,n.ref&&n.ref.hasOwnProperty(e)&&delete n.ref[e],n.ref=null,n.base=null,n.systemd!==null?n.systemd===0?(i=null,n.system=null,n.systemd=null):(n.systemd-=t,n.systemd<0&&(n.systemd=0),n.value===i&&(i=null)):n.value===i&&(i=null,n.system=null)):n.newvalue!==null?(n.ref=null,n.base=null,s=n.newvalue,n.newvalue=null):n.base!==null?(i=n.base,n.ref=null,n.value===i&&(i=null,n.base=null,n.needsUpdate=!1)):(n.ref=null,n.baseline!==null&&n.value!==n.baseline?(i=n.baseline,n.base=n.baseline):n.needsUpdate=!1);if(i!==null){let o=i-n.value;o>=0?o<.005?(s=i,n.v=0):(n.v<n.maxv&&(n.v+=n.acc*t),n.v>=0?s=n.value+o*(1-Math.exp(-n.v*t)):s=n.value+n.v*t*(1-Math.exp(n.v*t))):o>-.005?(s=i,n.v=0):(n.v>-n.maxv&&(n.v-=n.acc*t),n.v>=0?s=n.value+n.v*t*(1-Math.exp(-n.v*t)):s=n.value+o*(1-Math.exp(n.v*t)))}if(n.limit!==null){if(s!==null&&s!==n.value&&(n.value=s,n.onchange!==null&&n.onchange(s)),s=n.limit(n.value),s===n.applied)continue}else{if(s===null||s===n.value)continue;n.value=s,n.onchange!==null&&n.onchange(s)}switch(n.applied=s,n.applied<n.min&&(n.applied=n.min),n.applied>n.max&&(n.applied=n.max),e){case"headRotateX":this.poseDelta.props["Head.quaternion"].x=n.applied+this.mtAvatar.bodyRotateX.applied;break;case"headRotateY":this.poseDelta.props["Head.quaternion"].y=n.applied+this.mtAvatar.bodyRotateY.applied;break;case"headRotateZ":this.poseDelta.props["Head.quaternion"].z=n.applied+this.mtAvatar.bodyRotateZ.applied;break;case"bodyRotateX":this.poseDelta.props["Head.quaternion"].x=n.applied+this.mtAvatar.headRotateX.applied,this.poseDelta.props["Spine1.quaternion"].x=n.applied/2,this.poseDelta.props["Spine.quaternion"].x=n.applied/8,this.poseDelta.props["Hips.quaternion"].x=n.applied/24;break;case"bodyRotateY":this.poseDelta.props["Head.quaternion"].y=n.applied+this.mtAvatar.headRotateY.applied,this.poseDelta.props["Spine1.quaternion"].y=n.applied/2,this.poseDelta.props["Spine.quaternion"].y=n.applied/2,this.poseDelta.props["Hips.quaternion"].y=n.applied/4,this.poseDelta.props["LeftUpLeg.quaternion"].y=n.applied/2,this.poseDelta.props["RightUpLeg.quaternion"].y=n.applied/2,this.poseDelta.props["LeftLeg.quaternion"].y=n.applied/4,this.poseDelta.props["RightLeg.quaternion"].y=n.applied/4;break;case"bodyRotateZ":this.poseDelta.props["Head.quaternion"].z=n.applied+this.mtAvatar.headRotateZ.applied,this.poseDelta.props["Spine1.quaternion"].z=n.applied/12,this.poseDelta.props["Spine.quaternion"].z=n.applied/12,this.poseDelta.props["Hips.quaternion"].z=n.applied/24;break;case"handFistLeft":case"handFistRight":const o=e.substring(8);["HandThumb","HandIndex","HandMiddle","HandRing","HandPinky"].forEach((u,a)=>{a===0?(this.poseDelta.props[o+u+"1.quaternion"].x=0,this.poseDelta.props[o+u+"2.quaternion"].z=(o==="Left"?-1:1)*n.applied,this.poseDelta.props[o+u+"3.quaternion"].z=(o==="Left"?-1:1)*n.applied):(this.poseDelta.props[o+u+"1.quaternion"].x=n.applied,this.poseDelta.props[o+u+"2.quaternion"].x=1.5*n.applied,this.poseDelta.props[o+u+"3.quaternion"].x=1.5*n.applied)});break;case"chestInhale":const l=n.applied/20,c={x:l,y:l/2,z:3*l},r={x:1/(1+l)-1,y:1/(1+l/2)-1,z:1/(1+3*l)-1};this.poseDelta.props["Spine1.scale"]=c,this.poseDelta.props["Neck.scale"]=r,this.poseDelta.props["LeftArm.scale"]=r,this.poseDelta.props["RightArm.scale"]=r;break;default:for(let u=0,a=n.ms.length;u<a;u++)n.ms[u][n.is[u]]=n.applied}}}getPoseString(t,e=1e3){let n="{";return Object.entries(t).forEach((i,s)=>{const o=i[0].split(".");if(o[1]==="position"||o[1]==="rotation"||o[1]==="quaternion"){const l=o[1]==="quaternion"?o[0]+".rotation":i[0],c=i[1].isQuaternion?new y.Euler().setFromQuaternion(i[1]):i[1];n+=(s?", ":"")+"'"+l+"':{",n+="x:"+Math.round(c.x*e)/e,n+=", y:"+Math.round(c.y*e)/e,n+=", z:"+Math.round(c.z*e)/e,n+="}"}}),n+="}",n}getPoseTemplateProp(t){const e=t.split(".");let n=e[0]+"."+(e[1]==="rotation"?"quaternion":e[1]);if(this.gesture&&this.gesture.hasOwnProperty(n))return this.gesture[n].clone();{let i=e[0]+"."+(e[1]==="quaternion"?"rotation":e[1]);this.poseWeightOnLeft||(i.startsWith("Left")?(i="Right"+i.substring(4),n="Right"+n.substring(4)):i.startsWith("Right")&&(i="Left"+i.substring(5),n="Left"+n.substring(5)));let s;if(this.poseTarget.template.props.hasOwnProperty(n)){const o={};o[n]=this.poseTarget.template.props[n],s=this.propsToThreeObjects(o)[n]}else if(this.poseTarget.template.props.hasOwnProperty(i)){const o={};o[i]=this.poseTarget.template.props[i],s=this.propsToThreeObjects(o)[n]}return s&&!this.poseWeightOnLeft&&s.isQuaternion&&(s.x*=-1,s.w*=-1),s}}mirrorPose(t){const e={};for(let[n,i]of Object.entries(t))i.isQuaternion&&(n.startsWith("Left")?n="Right"+n.substring(4):n.startsWith("Right")&&(n="Left"+n.substring(5)),i.x*=-1,i.w*=-1),e[n]=i.clone(),e[n].t=i.t,e[n].d=i.d;return e}poseFactory(t,e=2e3){const n={template:t,props:this.propsToThreeObjects(t.props)};for(const[i,s]of Object.entries(n.props)){if(this.opt.modelMovementFactor<1&&t.standing&&(i==="Hips.quaternion"||i==="Spine.quaternion"||i==="Spine1.quaternion"||i==="Spine2.quaternion"||i==="Neck.quaternion"||i==="LeftUpLeg.quaternion"||i==="LeftLeg.quaternion"||i==="RightUpLeg.quaternion"||i==="RightLeg.quaternion")){const o=this.poseStraight[i],l=s.angleTo(o);s.rotateTowards(o,(1-this.opt.modelMovementFactor)*l)}s.t=this.animClock,s.d=e}return n}setPoseFromTemplate(t,e=2e3){const n=t&&this.poseTarget&&this.poseTarget.template&&(this.poseTarget.template.standing&&t.lying||this.poseTarget.template.lying&&t.standing),i=t&&t===this.poseCurrentTemplate,s=this.poseWeightOnLeft;let o=n?1e3:e;if(n?(this.poseCurrentTemplate=this.poseTemplates.oneknee,setTimeout(()=>{this.setPoseFromTemplate(t,e)},o)):this.poseCurrentTemplate=t||this.poseCurrentTemplate,this.poseTarget=this.poseFactory(this.poseCurrentTemplate,o),this.poseWeightOnLeft=!0,(!i&&!s||i&&s)&&(this.poseTarget.props=this.mirrorPose(this.poseTarget.props),this.poseWeightOnLeft=!this.poseWeightOnLeft),this.gesture)for(let[l,c]of Object.entries(this.gesture))this.poseTarget.props.hasOwnProperty(l)&&(this.poseTarget.props[l].copy(c),this.poseTarget.props[l].t=c.t,this.poseTarget.props[l].d=c.d);Object.keys(this.poseDelta.props).forEach(l=>{this.poseTarget.props.hasOwnProperty(l)||(this.poseTarget.props[l]=this.poseBase.props[l].clone(),this.poseTarget.props[l].t=this.animClock,this.poseTarget.props[l].d=o)})}getValue(t){return this.mtAvatar[t]?.value}setValue(t,e,n=null){this.mtAvatar.hasOwnProperty(t)&&Object.assign(this.mtAvatar[t],{system:e,systemd:n,needsUpdate:!0})}getMoodNames(){return Object.keys(this.animMoods)}getMood(){return this.opt.avatarMood}setMood(t){if(t=(t||"").trim().toLowerCase(),!this.animMoods.hasOwnProperty(t))throw new Error("Unknown mood.");this.moodName=t,this.mood=this.animMoods[this.moodName];for(let e of Object.keys(this.mtAvatar)){let n=this.mtBaselineExceptions.hasOwnProperty(e)?this.mtBaselineExceptions[e]:this.mtBaselineDefault;this.mood.baseline.hasOwnProperty(e)?n=this.mood.baseline[e]:this.avatar.baseline?.hasOwnProperty(e)&&(n=this.avatar.baseline[e]),this.setBaselineValue(e,n)}this.mood.anims.forEach(e=>{let n=this.animQueue.findIndex(i=>i.template.name===e.name);n!==-1&&this.animQueue.splice(n,1),this.animQueue.push(this.animFactory(e,-1))})}async initializeFBXAnimationLoader(){try{const{FBXAnimationLoader:t}=await Promise.resolve().then(()=>require("./fbxAnimationLoader-CNrfhJRz.cjs"));this.fbxAnimationLoader=new t(this.armature),console.log("FBX Animation Loader initialized")}catch(t){console.warn("FBX Animation Loader not available:",t),this.fbxAnimationLoader=null}}setBodyMovement(t){this.bodyMovement=t,this.avatar&&(this.avatar.bodyMovement=t),console.log("Body movement set to:",t),t==="idle"&&this.unlockAvatarPosition(),this.applyBodyMovementAnimation()}async applyBodyMovementAnimation(){if(!this.armature||!this.animQueue){console.log("Avatar not ready for body movement animations");return}console.log("Avatar is running:",this.isRunning),console.log("Animation queue exists:",!!this.animQueue);const t=this.animQueue.length;this.animQueue=this.animQueue.filter(i=>!i.template.name.startsWith("bodyMovement"));const e=this.animQueue.length;if(console.log(`Filtered animation queue: ${t} -> ${e} animations`),this.bodyMovement==="idle"){this.fbxAnimationLoader&&this.fbxAnimationLoader.stopCurrentAnimation();return}if(this.fbxAnimationLoader)try{await this.fbxAnimationLoader.playGestureAnimation(this.bodyMovement,this.movementIntensity),console.log("Applied FBX body movement animation:",this.bodyMovement);return}catch(i){console.warn("FBX animation failed, falling back to code animation:",i)}const n=this.createBodyMovementAnimation(this.bodyMovement);if(console.log("Created movement animation:",n),n)try{const i=this.animFactory(n,!0);i&&i.ts&&i.ts.length>0?(this.animQueue.push(i),console.log("Applied code-based body movement animation:",this.bodyMovement),console.log("Animation queue length:",this.animQueue.length),console.log("Animation object:",i)):(console.error("Invalid animation object created for:",this.bodyMovement),console.error("Animation object:",i))}catch(i){console.error("Error creating body movement animation:",i)}}lockAvatarPosition(){if(!this.armature){console.warn("Cannot lock position: armature not available");return}this.originalPosition||(this.originalPosition={x:this.armature.position.x,y:this.armature.position.y,z:this.armature.position.z},console.log("Original position stored:",this.originalPosition)),this.lockedPosition={x:this.armature.position.x,y:this.armature.position.y,z:this.armature.position.z},console.log("Avatar position locked at current position:",this.lockedPosition)}unlockAvatarPosition(){this.armature&&this.originalPosition?(this.armature.position.set(this.originalPosition.x,this.originalPosition.y,this.originalPosition.z),console.log("Avatar position restored to original:",this.originalPosition)):this.armature&&(this.armature.position.set(0,0,0),console.log("Avatar position reset to center (0,0,0)")),this.lockedPosition=null,this.originalPosition=null,console.log("Avatar position unlocked")}maintainLockedPosition(){this.lockedPosition&&this.armature&&this.armature.position.set(this.lockedPosition.x,this.lockedPosition.y,this.lockedPosition.z)}createBodyMovementAnimation(t){const e=this.movementIntensity||.5,n={walking:{name:"bodyMovement_walking",delay:[500,2e3],dt:[800,1200],vs:{bodyRotateY:[-.1*e,.1*e,0],bodyRotateZ:[-.05*e,.05*e,0],bodyRotateX:[-.02*e,.02*e,0]}},prancing:{name:"bodyMovement_prancing",delay:[300,1e3],dt:[400,800],vs:{bodyRotateY:[-.15*e,.15*e,0],bodyRotateZ:[-.08*e,.08*e,0],bodyRotateX:[-.05*e,.05*e,0]}},gesturing:{name:"bodyMovement_gesturing",delay:[400,1500],dt:[600,1e3],vs:{bodyRotateY:[-.08*e,.08*e,0],bodyRotateZ:[-.03*e,.03*e,0]}},dancing:{name:"bodyMovement_dancing",delay:[200,600],dt:[400,800],vs:{bodyRotateY:[-.25*e,.25*e,0],bodyRotateZ:[-.15*e,.15*e,0],bodyRotateX:[-.1*e,.1*e,0]}},dancing2:{name:"bodyMovement_dancing2",delay:[150,500],dt:[300,700],vs:{bodyRotateY:[-.3*e,.3*e,0],bodyRotateZ:[-.2*e,.2*e,0],bodyRotateX:[-.12*e,.12*e,0]}},dancing3:{name:"bodyMovement_dancing3",delay:[100,400],dt:[200,600],vs:{bodyRotateY:[-.35*e,.35*e,0],bodyRotateZ:[-.25*e,.25*e,0],bodyRotateX:[-.15*e,.15*e,0]}},excited:{name:"bodyMovement_excited",delay:[200,600],dt:[300,700],vs:{bodyRotateY:[-.12*e,.12*e,0],bodyRotateZ:[-.06*e,.06*e,0],bodyRotateX:[-.04*e,.04*e,0]}},happy:{name:"bodyMovement_happy",delay:[300,800],dt:[500,1e3],vs:{bodyRotateY:[-.08*e,.08*e,0],bodyRotateZ:[-.04*e,.04*e,0],bodyRotateX:[-.02*e,.02*e,0]}},surprised:{name:"bodyMovement_surprised",delay:[100,300],dt:[200,500],vs:{bodyRotateY:[-.05*e,.05*e,0],bodyRotateZ:[-.03*e,.03*e,0],bodyRotateX:[-.01*e,.01*e,0]}},thinking:{name:"bodyMovement_thinking",delay:[800,2e3],dt:[1e3,1500],vs:{bodyRotateY:[-.06*e,.06*e,0],bodyRotateZ:[-.03*e,.03*e,0],bodyRotateX:[-.02*e,.02*e,0]}},nodding:{name:"bodyMovement_nodding",delay:[400,800],dt:[300,600],vs:{bodyRotateX:[-.1*e,.1*e,0],bodyRotateY:[-.02*e,.02*e,0]}},shaking:{name:"bodyMovement_shaking",delay:[200,400],dt:[150,300],vs:{bodyRotateY:[-.15*e,.15*e,0],bodyRotateZ:[-.05*e,.05*e,0]}},celebration:{name:"bodyMovement_celebration",delay:[100,300],dt:[200,500],vs:{bodyRotateY:[-.2*e,.2*e,0],bodyRotateZ:[-.1*e,.1*e,0],bodyRotateX:[-.08*e,.08*e,0]}},energetic:{name:"bodyMovement_energetic",delay:[150,400],dt:[250,500],vs:{bodyRotateY:[-.18*e,.18*e,0],bodyRotateZ:[-.12*e,.12*e,0],bodyRotateX:[-.08*e,.08*e,0]}},swaying:{name:"bodyMovement_swaying",delay:[600,1200],dt:[800,1e3],vs:{bodyRotateY:[-.1*e,.1*e,0],bodyRotateZ:[-.05*e,.05*e,0]}},bouncing:{name:"bodyMovement_bouncing",delay:[300,600],dt:[400,700],vs:{bodyRotateY:[-.05*e,.05*e,0]}}};if(t==="dancing"){const i=["dancing","dancing2","dancing3"],s=i[Math.floor(Math.random()*i.length)];return n[s]||n.dancing}return n[t]||null}playRandomDance(){const t=["dancing","dancing2","dancing3"],e=t[Math.floor(Math.random()*t.length)];this.setBodyMovement(e)}playReaction(t){["happy","surprised","thinking","nodding","shaking","celebration","energetic","swaying","bouncing"].includes(t)?(this.setBodyMovement(t),["surprised","nodding","shaking","celebration"].includes(t)&&setTimeout(()=>{this.setBodyMovement("idle")},3e3)):console.warn("Invalid reaction type:",t)}playCelebration(){this.playReaction("celebration"),setTimeout(()=>{this.playRandomDance()},2e3)}setMovementIntensity(t){this.movementIntensity=Math.max(0,Math.min(1,t)),this.avatar&&(this.avatar.movementIntensity=this.movementIntensity),console.log("Movement intensity set to:",this.movementIntensity),this.fbxAnimationLoader&&this.fbxAnimationLoader.setIntensity(this.movementIntensity),this.applyBodyMovementAnimation()}setShowFullAvatar(t){this.showFullAvatar=t,this.avatar&&(this.avatar.showFullAvatar=t),console.log("Show full avatar set to:",t),t&&this.viewName!=="full"?(console.log("Changing camera view to full"),this.setView("full")):!t&&this.viewName!=="upper"?(console.log("Changing camera view to upper"),this.setView("upper")):console.log("Camera view already set to:",this.viewName)}getMorphTargetNames(){return["eyesRotateX","eyesRotateY",...Object.keys(this.mtAvatar)].sort()}getBaselineValue(t){if(t==="eyesRotateY"){const e=this.getBaselineValue("eyeLookOutLeft");if(e===void 0)return;const n=this.getBaselineValue("eyeLookInLeft");return n===void 0||this.getBaselineValue("eyeLookOutRight")===void 0||this.getBaselineValue("eyeLookInRight")===void 0?void 0:e-n}else if(t==="eyesRotateX"){const e=this.getBaselineValue("eyesLookDown");if(e===void 0)return;const n=this.getBaselineValue("eyesLookUp");return n===void 0?void 0:e-n}else return this.mtAvatar[t]?.baseline}setBaselineValue(t,e){t==="eyesRotateY"?(this.setBaselineValue("eyeLookOutLeft",e===null?null:e>0?e:0),this.setBaselineValue("eyeLookInLeft",e===null?null:e>0?0:-e),this.setBaselineValue("eyeLookOutRight",e===null?null:e>0?0:-e),this.setBaselineValue("eyeLookInRight",e===null?null:e>0?e:0)):t==="eyesRotateX"?(this.setBaselineValue("eyesLookDown",e===null?null:e>0?e:0),this.setBaselineValue("eyesLookUp",e===null?null:e>0?0:-e)):this.mtAvatar.hasOwnProperty(t)&&Object.assign(this.mtAvatar[t],{base:null,baseline:e,needsUpdate:!0})}getFixedValue(t){if(t==="eyesRotateY"){const e=this.getFixedValue("eyeLookOutLeft");if(e===null)return null;const n=this.getFixedValue("eyeLookInLeft");return n===null||this.getFixedValue("eyeLookOutRight")===null||this.getFixedValue("eyeLookInRight")===null?null:e-n}else if(t==="eyesRotateX"){const e=this.getFixedValue("eyesLookDown");if(e===null)return null;const n=this.getFixedValue("eyesLookUp");return n===null?null:e-n}else return this.mtAvatar[t]?.fixed}setFixedValue(t,e,n=null){t==="eyesRotateY"?(this.setFixedValue("eyeLookOutLeft",e===null?null:e>0?e:0,n),this.setFixedValue("eyeLookInLeft",e===null?null:e>0?0:-e,n),this.setFixedValue("eyeLookOutRight",e===null?null:e>0?0:-e,n),this.setFixedValue("eyeLookInRight",e===null?null:e>0?e:0,n)):t==="eyesRotateX"?(this.setFixedValue("eyesLookDown",e===null?null:e>0?e:0,n),this.setFixedValue("eyesLookUp",e===null?null:e>0?0:-e,n)):this.mtAvatar.hasOwnProperty(t)&&Object.assign(this.mtAvatar[t],{fixed:e,needsUpdate:!0})}animFactory(t,e=!1,n=1,i=1,s=!1){const o={template:t,ts:[0],vs:{}};let l=t;for(;;)if(l.hasOwnProperty(this.stateName))(this.stateName==="speaking"||this.stateName==="idle")&&console.log("Selected state:",this.stateName,"for avatar body:",this.avatar?.body),l=l[this.stateName];else if(l.hasOwnProperty(this.moodName))l=l[this.moodName];else if(l.hasOwnProperty(this.poseName))l=l[this.poseName];else if(l.hasOwnProperty(this.viewName))l=l[this.viewName];else if(this.avatar&&this.avatar.body&&l.hasOwnProperty(this.avatar.body))console.log("Applying gender-specific override:",this.avatar.body,"for state:",this.stateName,"keys:",Object.keys(l)),l=l[this.avatar.body];else if(l.hasOwnProperty("alt")){let r=l.alt[0];if(l.alt.length>1){const u=Math.random();let a=0;for(let d=0;d<l.alt.length;d++){let h=this.valueFn(l.alt[d].p);if(a+=h===void 0?(1-a)/(l.alt.length-1-d):h,u<a){r=l.alt[d];break}}}l=r,this.avatar&&this.avatar.body&&l.hasOwnProperty(this.avatar.body)&&console.log("Found gender override in selected alternative:",this.avatar.body,"keys:",Object.keys(l));continue}else break;let c=this.valueFn(l.delay)||0;if(Array.isArray(c)&&(c=this.gaussianRandom(...c)),l.hasOwnProperty("dt"))l.dt.forEach((r,u)=>{let a=this.valueFn(r);Array.isArray(a)&&(a=this.gaussianRandom(...a)),o.ts[u+1]=o.ts[u]+a});else{let r=Object.values(l.vs).reduce((u,a)=>a.length>u?a.length:u,0);o.ts=Array(r+1).fill(0)}s?o.ts=o.ts.map(r=>c+r*n):o.ts=o.ts.map(r=>this.animClock+c+r*n),l.vs&&l.vs.pose&&console.log("Pose being selected from vs.pose:",l.vs.pose,"for avatar body:",this.avatar?.body);for(let[r,u]of Object.entries(l.vs)){const a=this.getBaselineValue(r),d=u.map(h=>(h=this.valueFn(h),h===null?null:typeof h=="function"?h:typeof h=="string"||h instanceof String?r==="pose"&&this.avatar&&this.avatar.body==="M"&&(h==="hip"||h==="side")?(console.log("Intercepting pose",h,"in animation factory, overriding to wide for male avatar"),"wide"):h.slice():Array.isArray(h)?r==="gesture"?h.slice():(a===void 0?0:a)+i*this.gaussianRandom(...h):typeof h=="boolean"?h:h instanceof Object&&h.constructor===Object?Object.assign({},h):(a===void 0?0:a)+i*h));r==="eyesRotateY"?(o.vs.eyeLookOutLeft=[null,...d.map(h=>h>0?h:0)],o.vs.eyeLookInLeft=[null,...d.map(h=>h>0?0:-h)],o.vs.eyeLookOutRight=[null,...d.map(h=>h>0?0:-h)],o.vs.eyeLookInRight=[null,...d.map(h=>h>0?h:0)]):r==="eyesRotateX"?(o.vs.eyesLookDown=[null,...d.map(h=>h>0?h:0)],o.vs.eyesLookUp=[null,...d.map(h=>h>0?0:-h)]):o.vs[r]=[null,...d]}for(let r of Object.keys(o.vs))for(;o.vs[r].length<=o.ts.length;)o.vs[r].push(o.vs[r][o.vs[r].length-1]);return t.hasOwnProperty("mood")&&(o.mood=this.valueFn(t.mood).slice()),e&&(o.loop=e),o}valueAnimationSeq(t,e,n,i,s,o=null){t=this.valueFn(t),e=this.valueFn(e),s<n&&(s=n),s>i&&(s=i);let l=(e-t)/(i-n);return o&&(l*=o((s-n)/(i-n))),l*s+(t-l*n)}gaussianRandom(t,e,n=1,i=5){let s=0;for(let o=0;o<i;o++)s+=Math.random();return t+Math.pow(s/i,n)*(e-t)}sigmoidFactory(t){function e(i){return 1/(1+Math.exp(-t*i))-.5}var n=.5/e(1);return function(i){return n*e(2*Math.max(Math.min(i,1),0)-1)+.5}}convertRange(t,e,n){return(t-e[0])*(n[1]-n[0])/(e[1]-e[0])+n[0]}animate(t){if(!this.isRunning)return;let e;if(this.isAvatarOnly)e=t;else{if(requestAnimationFrame(this.animate.bind(this)),e=t-this.animTimeLast,e<this.animFrameDur)return;this.animTimeLast=t}e=e/this.animSlowdownRate,this.animClock+=e,this.maintainLockedPosition();let n,i,s,o,l=0;if(this.stats&&this.stats.begin(),this.isListening){for(this.listeningAnalyzer.getByteFrequencyData(this.volumeFrequencyData),n=2,s=10;n<s;n++)this.volumeFrequencyData[n]>l&&(l=this.volumeFrequencyData[n]);this.listeningVolume=(this.listeningVolume+l)/2,this.listeningActive?(this.listeningTimerTotal+=e,this.listeningVolume<this.listeningSilenceThresholdLevel?(this.listeningTimer+=e,this.listeningTimer>this.listeningSilenceThresholdMs&&(this.listeningOnchange&&this.listeningOnchange("stop",this.listeningTimer),this.listeningActive=!1,this.listeningTimer=0,this.listeningTimerTotal=0)):this.listeningTimer*=.5,this.listeningTimerTotal>this.listeningActiveDurationMax&&(this.listeningOnchange&&this.listeningOnchange("maxactive"),this.listeningTimerTotal=0)):(this.listeningTimerTotal+=e,this.listeningVolume>this.listeningActiveThresholdLevel?(this.listeningTimer+=e,this.listeningTimer>this.listeningActiveThresholdMs&&(this.listeningOnchange&&this.listeningOnchange("start"),this.listeningActive=!0,this.listeningTimer=0,this.listeningTimerTotal=0)):this.listeningTimer*=.5,this.listeningTimerTotal>this.listeningSilenceDurationMax&&(this.listeningOnchange&&this.listeningOnchange("maxsilence"),this.listeningTimerTotal=0))}if(this.isSpeaking)for(l=0,this.audioAnalyzerNode.getByteFrequencyData(this.volumeFrequencyData),n=2,s=10;n<s;n++)this.volumeFrequencyData[n]>l&&(l=this.volumeFrequencyData[n]);let c=null,r=null;const u=[];for(n=0,s=this.animQueue.length;n<s;n++){const a=this.animQueue[n];if(!(!a||!a.ts||!a.ts.length||this.animClock<a.ts[0])){for(i=a.ndx||0,o=a.ts.length;i<o&&!(this.animClock<a.ts[i]);i++)for(let[d,h]of Object.entries(a.vs))if(this.mtAvatar.hasOwnProperty(d)){if(h[i+1]===null)continue;const g=this.mtAvatar[d];if(h[i]===null&&(h[i]=g.value),i===o-1)g.newvalue=h[i];else{g.newvalue=h[i+1];const x=a.ts[i+1]-a.ts[i];let f=1;x>1e-4&&(f=(this.animClock-a.ts[i])/x),f<1&&(g.easing&&(f=g.easing(f)),g.newvalue=(1-f)*h[i]+f*g.newvalue),g.ref&&g.ref!==a.vs&&g.ref.hasOwnProperty(d)&&delete g.ref[d],g.ref=a.vs}if(l)switch(d){case"viseme_aa":case"viseme_E":case"viseme_I":case"viseme_O":case"viseme_U":g.newvalue*=1+l/255-.5}g.needsUpdate=!0}else d==="eyeContact"&&h[i]!==null&&c!==!1?c=!!h[i]:d==="headMove"&&h[i]!==null&&r!==!1?h[i]===0?r=!1:(Math.random()<h[i]&&(r=!0),h[i]=null):h[i]!==null&&(u.push({mt:d,val:h[i]}),h[i]=null);i===o?(a.hasOwnProperty("mood")&&this.setMood(a.mood),a.loop?(o=this.isSpeaking&&(a.template.name==="head"||a.template.name==="eyes")?4:1,this.animQueue[n]=this.animFactory(a.template,a.loop>0?a.loop-1:a.loop,1,1/o)):(this.animQueue.splice(n--,1),s--)):a.ndx=i-1}}for(let a=0,d=u.length;a<d;a++)switch(i=u[a].val,u[a].mt){case"speak":this.speakText(i);break;case"subtitles":this.onSubtitles&&typeof this.onSubtitles=="function"&&this.onSubtitles(i);break;case"pose":this.avatar&&this.avatar.body==="M"&&(i==="hip"||i==="side")&&this.poseTemplates.wide&&(i="wide",console.log("Overriding pose",i==="hip"?"hip":"side","to wide for male avatar")),this.poseName=i,console.log("Setting pose to:",this.poseName,"for avatar body:",this.avatar?.body,"state:",this.stateName),this.setPoseFromTemplate(this.poseTemplates[this.poseName]);break;case"gesture":this.playGesture(...i);break;case"function":i&&typeof i=="function"&&i();break;case"moveto":Object.entries(i.props).forEach(h=>{h[1]?this.poseTarget.props[h[0]].copy(h[1]):this.poseTarget.props[h[0]].copy(this.getPoseTemplateProp(h[0])),this.poseTarget.props[h[0]].t=this.animClock,this.poseTarget.props[h[0]].d=h[1]&&h[1].d?h[1].d:h.duration||2e3});break;case"handLeft":this.ikSolve({iterations:20,root:"LeftShoulder",effector:"LeftHandMiddle1",links:[{link:"LeftHand",minx:-.5,maxx:.5,miny:-1,maxy:1,minz:-.5,maxz:.5},{link:"LeftForeArm",minx:-.5,maxx:1.5,miny:-1.5,maxy:1.5,minz:-.5,maxz:3},{link:"LeftArm",minx:-1.5,maxx:1.5,miny:0,maxy:0,minz:-1,maxz:3}]},i.x?new y.Vector3(i.x,i.y,i.z):null,!0,i.d);break;case"handRight":this.ikSolve({iterations:20,root:"RightShoulder",effector:"RightHandMiddle1",links:[{link:"RightHand",minx:-.5,maxx:.5,miny:-1,maxy:1,minz:-.5,maxz:.5,maxAngle:.1},{link:"RightForeArm",minx:-.5,maxx:1.5,miny:-1.5,maxy:1.5,minz:-3,maxz:.5,maxAngle:.2},{link:"RightArm",minx:-1.5,maxx:1.5,miny:0,maxy:0,minz:-1,maxz:3}]},i.x?new y.Vector3(i.x,i.y,i.z):null,!0,i.d);break}if((c||r)&&(G.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]),G.x=Math.max(-.9,Math.min(.9,2*G.x-.5)),G.y=Math.max(-.9,Math.min(.9,-2.5*G.y)),c?(Object.assign(this.mtAvatar.eyesLookDown,{system:G.x<0?-G.x:0,needsUpdate:!0}),Object.assign(this.mtAvatar.eyesLookUp,{system:G.x<0?0:G.x,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookInLeft,{system:G.y<0?-G.y:0,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookOutLeft,{system:G.y<0?0:G.y,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookInRight,{system:G.y<0?0:G.y,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookOutRight,{system:G.y<0?-G.y:0,needsUpdate:!0}),r&&(n=-this.mtAvatar.bodyRotateY.value,i=this.gaussianRandom(-.2,.2),this.animQueue.push(this.animFactory({name:"headmove",dt:[[1e3,2e3],[1e3,2e3,1,2],[1e3,2e3],[1e3,2e3,1,2]],vs:{headRotateY:[n,n,0],headRotateX:[i,i,0],headRotateZ:[-n/4,-n/4,0]}})))):(n=this.mtAvatar.eyeLookInLeft.value-this.mtAvatar.eyeLookOutLeft.value,i=this.gaussianRandom(-.2,.2),this.animQueue.push(this.animFactory({name:"headmove",dt:[[1e3,2e3],[1e3,2e3,1,2],[1e3,2e3],[1e3,2e3,1,2]],vs:{headRotateY:[null,n,n,0],headRotateX:[null,i,i,0],headRotateZ:[null,-n/4,-n/4,0],eyeLookInLeft:[null,0],eyeLookOutLeft:[null,0],eyeLookInRight:[null,0],eyeLookOutRight:[null,0],eyeContact:[0]}})))),e>2*this.animFrameDur&&(e=2*this.animFrameDur),(this.viewName!=="full"||this.isAvatarOnly)&&(n=this.mtRandomized[Math.floor(Math.random()*this.mtRandomized.length)],i=this.mtAvatar[n],i.needsUpdate||Object.assign(i,{base:(this.mood.baseline[n]||0)+(1+l/255)*Math.random()/5,needsUpdate:!0})),this.updatePoseBase(this.animClock),this.mixer&&this.mixer.update(e/1e3*this.mixer.timeScale),this.updatePoseDelta(),this.applyShoulderAdjustmentToBones(),(this.isSpeaking||this.isListening)&&c?l>this.volumeMax?(this.volumeHeadBase=.05,Math.random()>.6&&(this.volumeHeadTarget=-.05-Math.random()/15),this.volumeMax=l):(this.volumeMax*=.92,this.volumeHeadTarget=this.volumeHeadBase-.9*(this.volumeHeadBase-this.volumeHeadTarget)):(this.volumeHeadTarget=0,this.volumeMax=0),n=this.volumeHeadTarget-this.volumeHeadCurrent,i=Math.abs(n),i>1e-4&&(o=i*(this.volumeHeadEasing(Math.min(1,this.volumeHeadVelocity*e/1e3/i)/2+.5)-.5),this.volumeHeadCurrent+=Math.sign(n)*Math.min(i,o)),Math.abs(this.volumeHeadCurrent)>1e-4&&(J.setFromAxisAngle(dt,this.volumeHeadCurrent),this.objectNeck.quaternion.multiply(J)),De.setFromObject(this.armature),this.objectLeftToeBase.getWorldPosition(fe),fe.sub(this.armature.position),this.objectRightToeBase.getWorldPosition(xe),xe.sub(this.armature.position),this.objectHips.position.y-=De.min.y/2,this.objectHips.position.x-=(fe.x+xe.x)/4,this.objectHips.position.z-=(fe.z+xe.z)/2,this.dynamicbones.update(e),this.fbxAnimationLoader&&this.fbxAnimationLoader.update(),this.opt.update&&this.opt.update(e),this.updateMorphTargets(e),this.isAvatarOnly)this.stats&&this.stats.end();else{if(this.cameraClock!==null&&this.cameraClock<1e3){this.cameraClock+=e,this.cameraClock>1e3&&(this.cameraClock=1e3);let a=new y.Spherical().setFromVector3(this.cameraStart),d=new y.Spherical().setFromVector3(this.cameraEnd);a.phi+=this.easing(this.cameraClock/1e3)*(d.phi-a.phi),a.theta+=this.easing(this.cameraClock/1e3)*(d.theta-a.theta),a.radius+=this.easing(this.cameraClock/1e3)*(d.radius-a.radius),a.makeSafe(),this.camera.position.setFromSpherical(a),this.controlsStart.x!==this.controlsEnd.x?this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd,this.easing(this.cameraClock/1e3))):(a.setFromVector3(this.controlsStart),d.setFromVector3(this.controlsEnd),a.phi+=this.easing(this.cameraClock/1e3)*(d.phi-a.phi),a.theta+=this.easing(this.cameraClock/1e3)*(d.theta-a.theta),a.radius+=this.easing(this.cameraClock/1e3)*(d.radius-a.radius),a.makeSafe(),this.controls.target.setFromSpherical(a)),this.controls.update()}this.controls.autoRotate&&this.controls.update(),this.stats&&this.stats.end(),this.render()}}resetLips(){this.visemeNames.forEach(t=>{this.morphs.forEach(e=>{const n=e.morphTargetDictionary["viseme_"+t];n!==void 0&&(e.morphTargetInfluences[n]=0)})})}lipsyncGetProcessor(t,e="./"){if(!this.lipsync.hasOwnProperty(t)){const n=t.toLowerCase(),i="Lipsync"+t.charAt(0).toUpperCase()+t.slice(1);try{const s=Oe[n];s&&s[i]?(this.lipsync[t]=new s[i],console.log(`Loaded lip-sync module for ${t}`)):console.warn(`Lip-sync module for ${t} not found. Available modules:`,Object.keys(Oe))}catch(s){console.warn(`Failed to load lip-sync module for ${t}:`,s)}}}lipsyncPreProcessText(t,e){return(this.lipsync[e]||Object.values(this.lipsync)[0]).preProcessText(t)}lipsyncWordsToVisemes(t,e){return(this.lipsync[e]||Object.values(this.lipsync)[0]).wordsToVisemes(t)}speakText(t,e=null,n=null,i=null){e=e||{};const s=/[!\.\?\n\p{Extended_Pictographic}]/ug,o=/[ ]/ug,l=/[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug,c=/[\p{Extended_Pictographic}]/ug,r=e.lipsyncLang||this.avatar.lipsyncLang||this.opt.lipsyncLang;let u="",a="",d=0,h=[],g=[];const x=Array.from(this.segmenter.segment(t),f=>f.segment);for(let f=0;f<x.length;f++){const w=f===x.length-1,D=x[f].match(l);let p=x[f].match(s);const O=x[f].match(c),M=x[f].match(o);if(p&&!w&&!O&&x[f+1].match(s)&&(p=!1),n&&(u+=x[f]),D&&(!i||i.every(I=>f<I[0]||f>I[1]))&&(a+=x[f]),(M||p||w)&&(a.length&&(a=this.lipsyncPreProcessText(a,r),a.length&&h.push({mark:d,word:a})),u.length&&(g.push({mark:d,template:{name:"subtitles"},ts:[0],vs:{subtitles:[u]}}),u=""),a.length)){const I=this.lipsyncWordsToVisemes(a,r);if(I&&I.visemes&&I.visemes.length){const S=I.times[I.visemes.length-1]+I.durations[I.visemes.length-1];for(let A=0;A<I.visemes.length;A++)g.push({mark:d,template:{name:"viseme"},ts:[(I.times[A]-.6)/S,(I.times[A]+.5)/S,(I.times[A]+I.durations[A]+.5)/S],vs:{["viseme_"+I.visemes[A]]:[null,I.visemes[A]==="PP"||I.visemes[A]==="FF"?.9:.6,0]}})}a="",d++}if(p||w){if(h.length||w&&g.length){const I={anim:g};n&&(I.onSubtitles=n),h.length&&!e.avatarMute&&(I.text=h,e.avatarMood&&(I.mood=e.avatarMood),e.ttsLang&&(I.lang=e.ttsLang),e.ttsVoice&&(I.voice=e.ttsVoice),e.ttsRate&&(I.rate=e.ttsRate),e.ttsVoice&&(I.pitch=e.ttsPitch),e.ttsVolume&&(I.volume=e.ttsVolume)),this.speechQueue.push(I),h=[],a="",d=0,g=[]}if(O){let I=this.animEmojis[x[f]];I&&I.link&&(I=this.animEmojis[I.link]),I&&this.speechQueue.push({emoji:I})}this.speechQueue.push({break:100})}}this.speechQueue.push({break:1e3}),this.startSpeaking()}async speakEmoji(t){let e=this.animEmojis[t];e&&e.link&&(e=this.animEmojis[e.link]),e&&this.speechQueue.push({emoji:e}),this.startSpeaking()}async speakBreak(t){this.speechQueue.push({break:t}),this.startSpeaking()}async speakMarker(t){this.speechQueue.push({marker:t}),this.startSpeaking()}async playBackgroundAudio(t){let n=await(await fetch(t)).arrayBuffer();this.stopBackgroundAudio(),this.audioBackgroundSource=this.audioCtx.createBufferSource(),this.audioBackgroundSource.loop=!0,this.audioBackgroundSource.buffer=await this.audioCtx.decodeAudioData(n),this.audioBackgroundSource.playbackRate.value=1/this.animSlowdownRate,this.audioBackgroundSource.connect(this.audioBackgroundGainNode),this.audioBackgroundSource.start(0)}stopBackgroundAudio(){try{this.audioBackgroundSource.stop()}catch{}this.audioBackgroundSource.disconnect()}async setReverb(t=null){if(t){let n=await(await fetch(t)).arrayBuffer();this.audioReverbNode.buffer=await this.audioCtx.decodeAudioData(n)}else{const e=this.audioCtx.sampleRate,n=this.audioCtx.createBuffer(2,e,e);n.getChannelData(0)[0]=1,n.getChannelData(1)[0]=1,this.audioReverbNode.buffer=n}}setMixerGain(t,e=null,n=0){t!==null&&(this.audioSpeechGainNode.gain.cancelScheduledValues(this.audioCtx.currentTime),n?(this.audioSpeechGainNode.gain.setValueAtTime(Math.max(this.audioSpeechGainNode.gain.value,1e-4),this.audioCtx.currentTime),this.audioSpeechGainNode.gain.exponentialRampToValueAtTime(Math.max(t,1e-4),this.audioCtx.currentTime+n)):this.audioSpeechGainNode.gain.setValueAtTime(t,this.audioCtx.currentTime)),e!==null&&(this.audioBackgroundGainNode.gain.cancelScheduledValues(this.audioCtx.currentTime),n?(this.audioBackgroundGainNode.gain.setValueAtTime(Math.max(this.audioBackgroundGainNode.gain.value,1e-4),this.audioCtx.currentTime),this.audioBackgroundGainNode.gain.exponentialRampToValueAtTime(Math.max(e,1e-4),this.audioCtx.currentTime+n)):this.audioBackgroundGainNode.gain.setValueAtTime(e,this.audioCtx.currentTime))}speakAudio(t,e=null,n=null){e=e||{};const i=e.lipsyncLang||this.avatar.lipsyncLang||this.opt.lipsyncLang,s={};if(t.words){let o=[];for(let l=0;l<t.words.length;l++){const c=t.words[l],r=t.wtimes[l];let u=t.wdurations[l];if(c.length&&(n&&o.push({template:{name:"subtitles"},ts:[r],vs:{subtitles:[" "+c]}}),!t.visemes)){const a=this.lipsyncPreProcessText(c,i),d=this.lipsyncWordsToVisemes(a,i);if(d&&d.visemes&&d.visemes.length){const h=d.times[d.visemes.length-1]+d.durations[d.visemes.length-1],g=Math.min(u,Math.max(0,u-d.visemes.length*150));let x=.6+this.convertRange(g,[0,u],[0,.4]);if(u=Math.min(u,d.visemes.length*200),h>0)for(let f=0;f<d.visemes.length;f++){const w=r+d.times[f]/h*u,D=d.durations[f]/h*u;o.push({template:{name:"viseme"},ts:[w-Math.min(60,2*D/3),w+Math.min(25,D/2),w+D+Math.min(60,D/2)],vs:{["viseme_"+d.visemes[f]]:[null,d.visemes[f]==="PP"||d.visemes[f]==="FF"?.9:x,0]}})}}}}if(t.visemes)for(let l=0;l<t.visemes.length;l++){const c=t.visemes[l],r=t.vtimes[l],u=t.vdurations[l];o.push({template:{name:"viseme"},ts:[r-2*u/3,r+u/2,r+u+u/2],vs:{["viseme_"+c]:[null,c==="PP"||c==="FF"?.9:.6,0]}})}if(t.markers)for(let l=0;l<t.markers.length;l++){const c=t.markers[l],r=t.mtimes[l];o.push({template:{name:"markers"},ts:[r],vs:{function:[c]}})}o.length&&(s.anim=o)}if(t.audio&&(s.audio=t.audio),t.anim?.name){let o=this.animFactory(t.anim,!1,1,1,!0);s.anim?s.anim.push(o):s.anim=[o]}n&&(s.onSubtitles=n),e.isRaw&&(s.isRaw=!0),Object.keys(s).length&&(this.speechQueue.push(s),s.isRaw||this.speechQueue.push({break:300}),this.startSpeaking())}async playAudio(t=!1){if(!(!this.armature||this.isAudioPlaying&&!t))if(this.isAudioPlaying=!0,this.audioPlaylist.length){const e=this.audioPlaylist.shift();if(this.audioCtx.state==="suspended"||this.audioCtx.state==="interrupted"){const s=this.audioCtx.resume(),o=new Promise((l,c)=>setTimeout(()=>c("p2"),1e3));try{await Promise.race([s,o])}catch{console.log("Can't play audio. Web Audio API suspended. This is often due to calling some speak method before the first user action, which is typically prevented by the browser."),this.playAudio(!0);return}}let n;if(Array.isArray(e.audio)){let s=this.concatArrayBuffers(e.audio);n=this.pcmToAudioBuffer(s)}else n=e.audio;this.audioSpeechSource=this.audioCtx.createBufferSource(),this.audioSpeechSource.buffer=n,this.audioSpeechSource.playbackRate.value=1/this.animSlowdownRate,this.audioSpeechSource.connect(this.audioAnalyzerNode),this.audioSpeechSource.addEventListener("ended",()=>{this.audioSpeechSource.disconnect(),this.playAudio(!0)},{once:!0});let i=0;e.anim&&(e.isRaw||(i=Math.abs(Math.min(0,...e.anim.map(s=>Math.min(...s.ts))))),e.anim.forEach(s=>{for(let o=0;o<s.ts.length;o++)s.ts[o]=this.animClock+s.ts[o]+i;this.animQueue.push(s)})),this.audioSpeechSource.start(i/1e3)}else this.isAudioPlaying=!1,this.startSpeaking(!0)}async synthesizeWithBrowserTTS(t){return new Promise((e,n)=>{const i=t.text.map(p=>p.word).join(" "),s=new SpeechSynthesisUtterance(i),o=t.lang||this.avatar.ttsLang||this.opt.ttsLang||"en-US",l=(t.rate||this.avatar.ttsRate||this.opt.ttsRate||1)+this.mood.speech.deltaRate,c=(t.pitch||this.avatar.ttsPitch||this.opt.ttsPitch||1)+this.mood.speech.deltaPitch,r=(t.volume||this.avatar.ttsVolume||this.opt.ttsVolume||1)+this.mood.speech.deltaVolume;s.lang=o,s.rate=Math.max(.1,Math.min(10,l)),s.pitch=Math.max(0,Math.min(2,c)),s.volume=Math.max(0,Math.min(1,r));const u=speechSynthesis.getVoices(),a=t.voice||this.avatar.ttsVoice||this.opt.ttsVoice;if(a&&u.length>0){const p=u.find(O=>O.name.includes(a)||O.lang===o);p&&(s.voice=p)}const d=i.length*100/s.rate,h=this.audioCtx.createBuffer(1,this.audioCtx.sampleRate*(d/1e3),this.audioCtx.sampleRate),g=this.avatar.lipsyncLang||this.opt.lipsyncLang||"en",x=this.lipsyncPreProcessText(i,g),f=this.lipsyncWordsToVisemes(x,g);console.log("Browser TTS Lip-sync Debug:",{text:i,lipsyncLang:g,processedText:x,lipsyncData:f,hasVisemes:f&&f.visemes&&f.visemes.length>0,estimatedDuration:d});const w=[];if(f&&f.visemes&&f.visemes.length>0){const p=f.times[f.visemes.length-1]+f.durations[f.visemes.length-1];for(let O=0;O<f.visemes.length;O++){const M=f.visemes[O],I=f.times[O]/p,S=f.durations[O]/p,A=I*d,z=S*d;w.push({template:{name:"viseme"},ts:[A-Math.min(60,2*z/3),A+Math.min(25,z/2),A+z+Math.min(60,z/2)],vs:{["viseme_"+M]:[null,M==="PP"||M==="FF"?.9:.6,0]}})}}const D=[...t.anim,...w];this.audioPlaylist.push({anim:D,audio:h}),this.onSubtitles=t.onSubtitles||null,this.resetLips(),t.mood&&this.setMood(t.mood),this.playAudio(),s.onend=()=>{e()},s.onerror=p=>{console.error("Speech synthesis error:",p.error),n(p.error)},speechSynthesis.speak(s)})}async synthesizeWithElevenLabsTTS(t){const e=t.text.map(d=>d.word).join(" "),n=t.voice||this.avatar.ttsVoice||this.opt.ttsVoice||"21m00Tcm4TlvDq8ikWAM",i={text:e,model_id:"eleven_monolingual_v1",voice_settings:{stability:.5,similarity_boost:.5,style:0,use_speaker_boost:!0}},s=await fetch(`${this.opt.ttsEndpoint}/${n}`,{method:"POST",headers:{Accept:"audio/mpeg","Content-Type":"application/json","xi-api-key":this.opt.ttsApikey},body:JSON.stringify(i)});if(!s.ok)throw new Error(`ElevenLabs TTS error: ${s.status} ${s.statusText}`);const o=await s.arrayBuffer(),l=await this.audioCtx.decodeAudioData(o);console.log("Using text-based lip-sync for debugging...");const c=this.avatar.lipsyncLang||this.opt.lipsyncLang||"en";let r;try{console.log("Lip-sync modules available:",{hasLipsync:!!this.lipsync,lipsyncKeys:this.lipsync?Object.keys(this.lipsync):[],lipsyncLang:c});const d=this.lipsyncPreProcessText(e,c),h=this.lipsyncWordsToVisemes(d,c);if(console.log("Lip-sync data:",{processedText:d,lipsyncData:h,hasVisemes:h&&h.visemes&&h.visemes.length>0}),h&&h.visemes&&h.visemes.length>0)r={visemes:h.visemes.map((g,x)=>({viseme:g,startTime:x*l.duration/h.visemes.length,endTime:(x+1)*l.duration/h.visemes.length,duration:l.duration/h.visemes.length,intensity:.7})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}};else throw new Error("No visemes generated from text")}catch(d){console.error("Text-based lip-sync failed, using fallback:",d);const h=e.toLowerCase().split(/\s+/),g=[];for(const x of h)for(const f of x){let w="aa";"aeiou".includes(f)?w="aa":"bp".includes(f)?w="PP":"fv".includes(f)?w="FF":"st".includes(f)?w="SS":"dln".includes(f)?w="DD":"kg".includes(f)?w="kk":"rw".includes(f)&&(w="RR"),g.push(w)}r={visemes:g.map((x,f)=>({viseme:x,startTime:f*l.duration/g.length,endTime:(f+1)*l.duration/g.length,duration:l.duration/g.length,intensity:.6})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}}}console.log("ElevenLabs TTS Audio Analysis:",{text:e,audioDuration:l.duration,visemeCount:r.visemes?r.visemes.length:0,wordCount:r.words?r.words.length:0,features:{onsets:r.features&&r.features.onsets?r.features.onsets.length:0,boundaries:r.features&&r.features.phonemeBoundaries?r.features.phonemeBoundaries.length:0},visemes:r.visemes?r.visemes.slice(0,3):[]});const u=[];if(r.visemes&&r.visemes.length>0){console.log("ElevenLabs: Generating lip-sync animation from",r.visemes.length,"visemes");for(let d=0;d<r.visemes.length;d++){const h=r.visemes[d],g=h.startTime*1e3,x=h.duration*1e3,f=h.intensity;u.push({template:{name:"viseme"},ts:[g-Math.min(60,2*x/3),g+Math.min(25,x/2),g+x+Math.min(60,x/2)],vs:{["viseme_"+h.viseme]:[null,f,0]}})}console.log("ElevenLabs: Generated",u.length,"lip-sync animation frames")}else console.warn("ElevenLabs: No visemes available for lip-sync animation");const a=[...t.anim,...u];console.log("ElevenLabs: Combined animation frames:",a.length,"(original:",t.anim.length,"+ lipsync:",u.length,")"),this.audioPlaylist.push({anim:a,audio:l}),this.onSubtitles=t.onSubtitles||null,this.resetLips(),t.mood&&this.setMood(t.mood),this.playAudio()}async synthesizeWithDeepgramTTS(t){const e=t.text.map(d=>d.word).join(" "),n=t.voice||this.avatar.ttsVoice||this.opt.ttsVoice||"aura-2-thalia-en",i=`${this.opt.ttsEndpoint}?model=${n}`,s=await fetch(i,{method:"POST",headers:{Authorization:`Token ${this.opt.ttsApikey}`,"Content-Type":"text/plain",Accept:"audio/mpeg"},body:e});if(!s.ok)throw new Error(`Deepgram TTS error: ${s.status} ${s.statusText}`);const o=await s.arrayBuffer(),l=await this.audioCtx.decodeAudioData(o);console.log("Using text-based lip-sync for Deepgram...");const c=this.avatar.lipsyncLang||this.opt.lipsyncLang||"en";let r;try{console.log("Lip-sync modules available:",{hasLipsync:!!this.lipsync,lipsyncKeys:this.lipsync?Object.keys(this.lipsync):[],lipsyncLang:c});const d=this.lipsyncPreProcessText(e,c),h=this.lipsyncWordsToVisemes(d,c);if(console.log("Lip-sync data:",{processedText:d,lipsyncData:h,hasVisemes:h&&h.visemes&&h.visemes.length>0}),h&&h.visemes&&h.visemes.length>0)r={visemes:h.visemes.map((g,x)=>({viseme:g,startTime:x*l.duration/h.visemes.length,endTime:(x+1)*l.duration/h.visemes.length,duration:l.duration/h.visemes.length,intensity:.7})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}};else throw new Error("No visemes generated from text")}catch(d){console.error("Text-based lip-sync failed, using fallback:",d);const h=e.toLowerCase().split(/\s+/),g=[];for(const x of h)for(const f of x){let w="aa";"aeiou".includes(f)?w="aa":"bp".includes(f)?w="PP":"fv".includes(f)?w="FF":"st".includes(f)?w="SS":"dln".includes(f)?w="DD":"kg".includes(f)?w="kk":"rw".includes(f)&&(w="RR"),g.push(w)}r={visemes:g.map((x,f)=>({viseme:x,startTime:f*l.duration/g.length,endTime:(f+1)*l.duration/g.length,duration:l.duration/g.length,intensity:.6})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}}}console.log("Deepgram TTS Audio Analysis:",{text:e,audioDuration:l.duration,visemeCount:r.visemes?r.visemes.length:0,wordCount:r.words?r.words.length:0,features:{onsets:r.features&&r.features.onsets?r.features.onsets.length:0,boundaries:r.features&&r.features.phonemeBoundaries?r.features.phonemeBoundaries.length:0},visemes:r.visemes?r.visemes.slice(0,3):[]});const u=[];if(r.visemes&&r.visemes.length>0){console.log("Deepgram: Generating lip-sync animation from",r.visemes.length,"visemes");for(let d=0;d<r.visemes.length;d++){const h=r.visemes[d],g=h.startTime*1e3,x=h.duration*1e3,f=h.intensity;u.push({template:{name:"viseme"},ts:[g-Math.min(60,2*x/3),g+Math.min(25,x/2),g+x+Math.min(60,x/2)],vs:{["viseme_"+h.viseme]:[null,f,0]}})}console.log("Deepgram: Generated",u.length,"lip-sync animation frames")}else console.warn("Deepgram: No visemes available for lip-sync animation");const a=[...t.anim,...u];console.log("Deepgram: Combined animation frames:",a.length,"(original:",t.anim.length,"+ lipsync:",u.length,")"),this.audioPlaylist.push({anim:a,audio:l}),this.onSubtitles=t.onSubtitles||null,this.resetLips(),t.mood&&this.setMood(t.mood),this.playAudio()}async synthesizeWithAzureTTS(t){const e=t.text.map(a=>a.word).join(" "),i=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("react/jsx-runtime"),v=require("react"),Ge=require("three"),Xe=require("three/addons/controls/OrbitControls.js"),Ze=require("three/addons/loaders/GLTFLoader.js"),je=require("three/addons/loaders/DRACOLoader.js"),Pe=require("three/addons/loaders/FBXLoader.js"),Ye=require("three/addons/environments/RoomEnvironment.js"),Qe=require("three/addons/libs/stats.module.js");var He=typeof document<"u"?document.currentScript:null;function qe(U){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(U){for(const e in U)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(U,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>U[e]})}}return t.default=U,Object.freeze(t)}const y=qe(Ge);let m,le,ce;const H=[0,0,0,0],F=new y.Vector3,ke=new y.Vector3,se=new y.Vector3,we=new y.Vector3;new y.Plane;new y.Ray;new y.Euler;const ae=new y.Quaternion,Be=new y.Quaternion,pe=new y.Matrix4,ge=new y.Matrix4;new y.Vector3;const Ce=new y.Vector3(0,0,1),_e=new y.Vector3(1,0,0),Ke=new y.Vector3(0,1,0),Je=new y.Vector3(0,0,1);class $e{constructor(t=null){this.opt=Object.assign({warmupMs:2e3,sensitivityFactor:1,movementFactor:1,isExcludes:!0,isPivots:!0,isLimits:!0,helperBoneColor1:16711680,helperBoneColor2:16238028,helperLinkColor1:16711680,helperLinkColor2:255,helperExcludesColor:11184895},t||{}),this.scene=null,this.armature=null,this.config=[],this.data=[],this.dict={},this.objectsUpdate=[],this.helpers={isActive:!1,isShowAll:!1,points:{bones:[],pivots:[],object:null},lines:{bones:[],object:null},excludes:{bones:[],deltaLocals:[],radii:[],objects:[]}},this.running=!1,this.timerMs=0}getOptionValue(t){return this.opt[t]}setOptionValue(t,e){this.opt[t]=e,this.helpers.isActive&&this.showHelpers()}getBoneNames(){return this.data.map(t=>t.name)}getValue(t,e){if(this.scene===null)throw new Error("Dynamic bones has not been setup yet.");if(!this.dict.hasOwnProperty(t))throw new Error("Dynamic bone '"+t+"' not found.");const n=this.dict[t];let i;if(e==="type")i=n.type;else if(e==="stiffness")i=n.k.every(s=>s===n.k[0])?n.k[0]:[...n.k];else if(e==="damping")i=n.c.every(s=>s===n.c[0])?n.c[0]:[...n.c];else if(e==="external")i=n.ext<1?n.ext:null;else if(e==="limits")i=n.limits?.map(s=>s===null?null:[...s]);else if(e==="deltaLocal")i=n.dl?[...n.dl]:null;else if(e==="excludes")i=n.excludes?[...n.excludes.map(s=>{const o={bone:s.bone.name.slice(),radius:s.radius};return s.deltaLocal&&(o.deltaLocal=[...s.deltaLocal]),o})]:null;else if(e==="deltaWorld")i=n.dw?[...n.dw]:null;else if(e==="pivot")i=n.pivot;else if(e==="helper")i=n.helper;else throw new Error("Unsupported property '"+e+"'.");return i}setValue(t,e,n){if(this.scene===null)throw new Error("Dynamic bones has not been setup yet.");if(!this.dict.hasOwnProperty(t))throw new Error("Dynamic bone '"+t+"' not found.");const i=this.dict[t];if(e==="type"){if(!n)throw new Error("Parameter 'type' not set.");if(typeof n!="string")throw new Error("Type must be a string.");switch(n){case"point":i.isPoint=!0,i.isX=!0,i.isY=!0,i.isZ=!0,i.isT=!1;break;case"link":i.isPoint=!1,i.isX=!0,i.isY=!1,i.isZ=!0,i.isT=!1;break;case"mix1":i.isPoint=!1,i.isX=!0,i.isY=!0,i.isZ=!0,i.isT=!1;break;case"mix2":i.isPoint=!1,i.isX=!0,i.isY=!1,i.isZ=!0,i.isT=!0;break;case"full":i.isPoint=!1,i.isX=!0,i.isY=!0,i.isZ=!0,i.isT=!0;break;default:throw new Error("Unknown type'"+n+"'.")}i.type=n.slice()}else if(e==="stiffness"){if(!n)throw new Error("Parameter 'stiffness' not set.");if(!Number.isNaN(n)&&n>=0)i.k=Array(4).fill(n);else if(Array.isArray(n)&&n.length===4&&n.every(s=>s>=0))i.k=[...n];else throw new Error("Stiffness must be a non-negative number or an array of four non-negative numbers.")}else if(e==="damping"){if(!n)throw new Error("Parameter 'damping' not set.");if(!Number.isNaN(n)&&n>=0)i.c=Array(4).fill(n);else if(Array.isArray(n)&&n.length===4&&n.every(s=>s>=0))i.c=[...n];else throw new Error("Damping must be a non-negative number or an array of four non-negative numbers.")}else if(e==="external")if(n==null)i.ext=1;else if(!Number.isNaN(n)&&n>=0&&n<=1)i.ext=n;else throw new Error("External (if set) must be a number between [0,1].");else if(e==="limits")if(n==null)i.limits=null;else{if(!Array.isArray(n)||n.length!==4)throw new Error("Limits (if set) must null, or an array of four arrays.");if(!n.every(s=>s===null||Array.isArray(s)&&s.length===2&&(s[0]===null||!Number.isNaN(s[0]))&&(s[1]===null||!Number.isNaN(s))))throw new Error("Limit values must be null or numbers.");i.limits=[n[0]?[...n[0]]:null,n[1]?[...n[1]]:null,n[2]?[...n[2]]:null,n[3]?[...n[3]]:null]}else if(e==="excludes"){if(n==null)i.excludes=null;else{if(!Array.isArray(n))throw new Error("Excludes (if set) must null, or an array.");i.excludes=[],n.forEach((s,o)=>{if(!s.bone)throw new Error("Bone not specified in #"+o+" exclude.");if(typeof s.bone!="string"||s.bone.length===0)throw new Error("Bone name must be a non-empty string in #"+o+" exclude.");const l=this.armature.getObjectByName(s.bone);if(!l)throw new Error("Bone '"+s.bone+"' not found in #"+o+" exclude.");if(Number.isNaN(s.radius)&&s.radius>=0)throw new Error("Radius must be a non-negative number in #"+o+" exclude.");const c={bone:l,radius:s.radius,radiusSq:s.radius*s.radius,deltaLocal:null};if(s.deltaLocal){if(!Array.isArray(s.deltaLocal)||s.deltaLocal.length!==3||s.deltaLocal.some(r=>Number.isNaN(r)))throw new Error("deltaLocal must be an array of three numbers in #"+o+" exclude.");c.deltaLocal=[...s.deltaLocal]}i.excludes.push(c)})}this.showHelpers()}else if(e==="helper"){if(n==null)i.helper=null;else{if(n!==!1&&n!==!0)throw new Error("Helper, if set, must be false or true.");i.helper=n}this.showHelpers()}else if(e==="pivot")if(n==null)i.pivot=null;else{if(n!==!1&&n!==!0)throw new Error("Pivot, if set, must be false or true.");if(n===!0&&i.type===0)throw new Error("Point type bone can't be a pivot.");i.pivot=n}else if(e==="deltaLocal")if(n==null)i.dl=null;else{if(!Array.isArray(n)||n.length!==3)throw new Error("deltaLocal, is set, must be an array of three numbers.");if(!n.every(s=>!Number.isNaN(s)))throw new Error("deltaLocal values must be numbers.");i.dl=[...n]}else if(e==="deltaWorld")if(n==null)i.dw=null;else{if(!Array.isArray(n)||n.length!==3)throw new Error("deltaWorld, is set, must be an array of three values.");if(!n.every(s=>!Number.isNaN(s)))throw new Error("deltaWorld values must be numbers.");i.dw=[...n]}else throw new Error("Unsupported property "+e)}getConfig(){return this.data.map(t=>{const e={bone:t.name.slice()};return["type","stiffness","damping","external","deltaLocal","deltaWorld","limits","excludes","pivot","helper"].forEach(n=>{m=this.getValue(t.name,n),m&&(e[n]=m)}),e})}sortBones(){if(this.scene===null)throw new Error("Dynamic bones has not been setup yet.");let t=0;const e=new WeakMap;this.armature.traverse(o=>{e.has(o)||(e.set(o,t),t++)}),this.data.sort((o,l)=>e.get(o.bone)-e.get(l.bone)),this.data.forEach(o=>{m=this.dict[o.boneParent.name],m&&(m.children||(m.children=[]),m.children.push(o))}),this.objectsUpdate=[];const n=new WeakSet,i=o=>o.parent?.isBone?[o,...i(o.parent)]:[o],s=o=>{i(o).forEach(c=>{n.has(c)||(this.objectsUpdate.push(c),n.add(c))})};this.data.forEach(o=>{s(o.bone),o.excludes&&o.excludes.forEach(l=>{s(l.bone)})}),this.objectsUpdate.sort((o,l)=>e.get(o)-e.get(l))}setup(t,e,n){this.dispose();const i=(s,o)=>{if(!s)throw this.dispose(),new Error(o)};i(t?.isScene,"First parameter must be Scene."),this.scene=t,i(e?.isObject3D,"Second parameter must be the armature Object3D."),this.armature=e,i(Array.isArray(n),"Third parameter must be an array of bone configs."),this.config=n,this.config.forEach((s,o)=>{const l="Config item #"+o+": ";i(s.bone,l+"Bone not specified.");const c=s.bone;i(typeof c=="string"&&c.length>0,l+"Bone name must be a non-empty string.");const r=this.armature.getObjectByName(c);i(r,l+"Bone '"+c+"' not found."),i(r.parent?.isBone,l+"Bone must have a parent bone."),i(this.data.every(a=>a.bone!==r),l+"Bone '"+c+"' already exists."),r.updateMatrixWorld(!0);const u={name:c,bone:r,boneParent:r.parent,vBasis:r.position.clone(),vWorld:r.parent.getWorldPosition(F).clone(),qBasis:r.parent.quaternion.clone(),l:r.position.length(),p:[0,0,0,0],v:[0,0,0,0],a:[0,0,0,0],ev:[0,0,0,0],ea:[0,0,0,0]};u.boneParent.matrixWorld.decompose(F,ae,se),F.copy(Ce).applyQuaternion(ae).setY(0).normalize(),ae.premultiply(Be.setFromUnitVectors(Ce,F).invert()).normalize(),u.qWorldInverseYaw=ae.clone().normalize(),this.data.push(u),this.dict[c]=u;try{this.setValue(c,"type",s.type),this.setValue(c,"stiffness",s.stiffness),this.setValue(c,"damping",s.damping),this.setValue(c,"external",s.external),this.setValue(c,"limits",s.limits),this.setValue(c,"excludes",s.excludes),this.setValue(c,"deltaLocal",s.deltaLocal),this.setValue(c,"deltaWorld",s.deltaWorld),this.setValue(c,"pivot",s.pivot),this.setValue(c,"helper",s.helper)}catch(a){i(!1,l+a)}}),this.sortBones(),this.start()}update(t){if(!this.running)return;let e,n,i,s,o;for(this.timerMs+=t,t>1e3&&(this.timerMs=0),t/=1e3,e=0,i=this.objectsUpdate.length;e<i;e++)o=this.objectsUpdate[e],o.updateMatrix(),o.parent===null?o.matrixWorld.copy(o.matrix):o.matrixWorld.multiplyMatrices(o.parent.matrixWorld,o.matrix),o.matrixWorldNeedsUpdate=!1;for(e=0,i=this.data.length;e<i;e++){if(o=this.data[e],F.copy(o.vWorld),pe.copy(o.boneParent.matrixWorld),ge.copy(pe).invert(),o.vWorld.setFromMatrixPosition(pe),F.applyMatrix4(ge),F.length()>.5&&(console.info("Info: Unrealistic jump of "+F.length().toFixed(2)+" meters."),F.setLength(.5)),F.applyQuaternion(o.bone.quaternion),H[0]=F.x,H[1]=F.y,H[2]=-F.z,H[3]=F.length()/3,o.children)for(n=0,s=o.children.length;n<s;n++)m=o.children[n],H[0]-=m.v[0]*t/3,H[1]-=m.v[1]*t/3,H[2]+=m.v[2]*t/3,H[3]-=m.v[3]*t/3;if(m=this.opt.sensitivityFactor,H[0]*=o.ext*m,H[1]*=o.ext*m,H[2]*=o.ext*m,H[3]*=o.ext*m,o.isX&&(m=H[0]/t,o.ea[0]=(m-o.ev[0])/t,o.ev[0]=m,o.a[0]=-o.k[0]*o.p[0]-o.c[0]*o.v[0]-o.ea[0],o.p[0]+=o.v[0]*t+o.a[0]*t*t/2+H[0],m=o.v[0]+o.a[0]*t/2,m=-o.k[0]*o.p[0]-o.c[0]*m-o.ea[0],o.v[0]=o.v[0]+(m+o.a[0])*t/2),o.isY&&(m=H[1]/t,o.ea[1]=(m-o.ev[1])/t,o.ev[1]=m,o.a[1]=-o.k[1]*o.p[1]-o.c[1]*o.v[1]-o.ea[1],o.p[1]+=o.v[1]*t+o.a[1]*t*t/2+H[1],m=o.v[1]+o.a[1]*t/2,m=-o.k[1]*o.p[1]-o.c[1]*m-o.ea[1],o.v[1]=o.v[1]+(m+o.a[1])*t/2),o.isZ&&(m=H[2]/t,o.ea[2]=(m-o.ev[2])/t,o.ev[2]=m,o.a[2]=-o.k[2]*o.p[2]-o.c[2]*o.v[2]-o.ea[2],o.p[2]+=o.v[2]*t+o.a[2]*t*t/2+H[2],m=o.v[2]+o.a[2]*t/2,m=-o.k[2]*o.p[2]-o.c[2]*m-o.ea[2],o.v[2]=o.v[2]+(m+o.a[2])*t/2),o.isT&&(m=H[3]/t,o.ea[3]=(m-o.ev[3])/t,o.ev[3]=m,o.a[3]=-o.k[3]*o.p[3]-o.c[3]*o.v[3]-o.ea[3],o.p[3]+=o.v[3]*t+o.a[3]*t*t/2+H[3],m=o.v[3]+o.a[3]*t/2,m=-o.k[3]*o.p[3]-o.c[3]*m-o.ea[3],o.v[3]=o.v[3]+(m+o.a[3])*t/2),this.timerMs<this.opt.warmupMs&&(o.v[0]*=1e-4,o.p[0]*=1e-4,o.v[1]*=1e-4,o.p[1]*=1e-4,o.v[2]*=1e-4,o.p[2]*=1e-4,o.v[3]*=1e-4,o.p[3]*=1e-4),H[0]=o.p[0],H[1]=o.p[1],H[2]=o.p[2],H[3]=o.p[3],m=this.opt.movementFactor,H[0]*=m,H[1]*=m,H[2]*=m,H[3]*=m,o.dl&&(m=o.dl,H[0]+=m[0],H[1]+=m[1],H[2]+=m[2]),o.dw&&(m=o.dw,F.set(o.vBasis.x+H[0],o.vBasis.y+H[1],o.vBasis.z+H[2]),F.applyMatrix4(pe),F.x+=m[0],F.y+=m[1],F.z+=m[2],F.applyMatrix4(ge),H[0]+=F.x-o.vBasis.x,H[1]+=F.y-o.vBasis.y,H[2]+=F.z-o.vBasis.z),o.limits&&this.opt.isLimits&&(m=o.limits,m[0]&&(m[0][0]!==null&&H[0]<m[0][0]&&(H[0]=m[0][0]),m[0][1]!==null&&H[0]>m[0][1]&&(H[0]=m[0][1])),m[1]&&(m[1][0]!==null&&H[1]<m[1][0]&&(H[1]=m[1][0]),m[1][1]!==null&&H[1]>m[1][1]&&(H[1]=m[1][1])),m[2]&&(m[2][0]!==null&&H[2]<m[2][0]&&(H[2]=m[2][0]),m[2][1]!==null&&H[2]>m[2][1]&&(H[2]=m[2][1])),m[3]&&(m[3][0]!==null&&H[3]<m[3][0]&&(H[3]=m[3][0]),m[3][1]!==null&&H[3]>m[3][1]&&(H[3]=m[3][1]))),o.isPoint)o.bone.position.set(o.vBasis.x+H[0],o.vBasis.y+H[1],o.vBasis.z-H[2]);else if(o.boneParent.quaternion.copy(o.qBasis),o.pivot&&this.opt.isPivots&&(o.boneParent.updateWorldMatrix(!1,!1),o.boneParent.matrixWorld.decompose(F,ae,se),F.copy(Ce).applyQuaternion(ae).setY(0).normalize(),ae.premultiply(Be.setFromUnitVectors(Ce,F).invert()).normalize(),o.boneParent.quaternion.multiply(ae.invert()),o.boneParent.quaternion.multiply(o.qWorldInverseYaw)),o.isZ&&(m=Math.atan(H[0]/o.l),ae.setFromAxisAngle(Je,-m),o.boneParent.quaternion.multiply(ae)),o.isY&&(m=o.l/3,m=m*Math.tanh(H[1]/m),o.bone.position.setLength(o.l+m)),o.isX&&(m=Math.atan(H[2]/o.l),ae.setFromAxisAngle(_e,-m),o.boneParent.quaternion.multiply(ae)),o.isT&&(m=1.5*Math.tanh(H[3]*1.5),ae.setFromAxisAngle(Ke,-m),o.boneParent.quaternion.multiply(ae)),o.boneParent.updateWorldMatrix(!1,!0),o.excludes&&this.opt.isExcludes)for(n=0,s=o.excludes.length;n<s;n++)m=o.excludes[n],se.set(0,0,0),m.deltaLocal&&(se.x+=m.deltaLocal[0],se.y+=m.deltaLocal[1],se.z+=m.deltaLocal[2]),se.applyMatrix4(m.bone.matrixWorld),ge.copy(o.boneParent.matrixWorld).invert(),se.applyMatrix4(ge),F.copy(o.bone.position),!(F.distanceToSquared(se)>=m.radiusSq)&&(ce=F.length(),le=se.length(),!(le>m.radius+ce)&&(le<Math.abs(m.radius-ce)||(le=(le*le+ce*ce-m.radiusSq)/(2*le),se.normalize(),we.copy(se).multiplyScalar(le),le=Math.sqrt(ce*ce-le*le),F.subVectors(F,we).projectOnPlane(se).normalize().multiplyScalar(le),ke.subVectors(o.vBasis,we).projectOnPlane(se).normalize(),ce=ke.dot(F),ce<0&&(ce=Math.sqrt(le*le-ce*ce),ke.multiplyScalar(ce),F.add(ke)),F.add(we).normalize(),se.copy(o.bone.position).normalize(),ae.setFromUnitVectors(se,F),o.boneParent.quaternion.premultiply(ae),o.boneParent.updateWorldMatrix(!1,!0))))}this.helpers.isActive&&this.updateHelpers()}showHelpers(t){if(this.hideHelpers(),this.helpers.isShowAll=t===void 0?this.helpers.isShowAll:t===!0,m=this.helpers,this.data.forEach(e=>{(this.helpers.isShowAll||e.helper===!0)&&(m.points.bones.push(e.bone),m.points.pivots.push(e.pivot),e.type!==0&&m.lines.bones.push(e.bone),e.excludes&&e.excludes.forEach(n=>{let i=!1;for(let s=0;s<m.excludes.bones.length;s++)if(m.excludes.bones[s]===n.bone&&m.excludes.radii[s]===n.radius&&!(m.excludes.deltaLocals[s]===null&&n.deltaLocal!==null)&&!(m.excludes.deltaLocals[s]!==null&&n.deltaLocal===null)&&!(m.excludes.deltaLocals[s]!==null&&m.excludes.deltaLocals[s].some((o,l)=>o!==n.deltaLocal[l]))){i=!0;break}i||(m.excludes.bones.push(n.bone),m.excludes.radii.push(n.radius),m.excludes.deltaLocals.push(n.deltaLocal?[...n.deltaLocal]:null),m.excludes.objects.push(null))}))}),m=this.helpers.excludes,this.opt.isExcludes&&m.bones.length&&m.bones.forEach((e,n)=>{const i=new y.SphereGeometry(m.radii[n],6,6),s=new y.MeshBasicMaterial({depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0,wireframe:!0,color:this.opt.helperExcludesColor});m.objects[n]=new y.Mesh(i,s),m.objects[n].renderOrder=997,e.add(m.objects[n]),m.deltaLocals[n]&&m.objects[n].position.set(m.deltaLocals[n][0],m.deltaLocals[n][1],m.deltaLocals[n][2])}),m=this.helpers.points,m.bones.length){this.helpers.isActive=!0;const e=new y.BufferGeometry,n=m.bones.map(c=>[0,0,0]).flat();e.setAttribute("position",new y.Float32BufferAttribute(n,3));const i=new y.Color(this.opt.helperBoneColor1),s=new y.Color(this.opt.helperBoneColor2),o=m.pivots.map(c=>c&&this.opt.isPivots?[s.r,s.g,s.b]:[i.r,i.g,i.b]).flat();e.setAttribute("color",new y.Float32BufferAttribute(o,3));const l=new y.PointsMaterial({depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0,size:.2,vertexColors:!0});m.object=new y.Points(e,l),m.object.renderOrder=998,m.object.matrix=this.armature.matrixWorld,m.object.matrixAutoUpdate=!1,this.scene.add(m.object)}if(m=this.helpers.lines,m.bones.length){const e=new y.BufferGeometry,n=m.bones.map(c=>[0,0,0,0,0,0]).flat();e.setAttribute("position",new y.Float32BufferAttribute(n,3));const i=new y.Color(this.opt.helperLinkColor1),s=new y.Color(this.opt.helperLinkColor2),o=m.bones.map(c=>[i.r,i.g,i.b,s.r,s.g,s.b]).flat();e.setAttribute("color",new y.Float32BufferAttribute(o,3));const l=new y.LineBasicMaterial({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});m.object=new y.LineSegments(e,l),m.object.renderOrder=999,m.object.matrix=this.armature.matrixWorld,m.object.matrixAutoUpdate=!1,this.scene.add(m.object)}}updateHelpers(){if(m=this.helpers.points,m.bones.length){ge.copy(this.armature.matrixWorld).invert();const t=m.object.geometry.getAttribute("position");for(let e=0,n=m.bones.length;e<n;e++)pe.multiplyMatrices(ge,m.bones[e].matrixWorld),F.setFromMatrixPosition(pe),t.setXYZ(e,F.x,F.y,F.z);t.needsUpdate=!0,m.object.updateMatrixWorld()}if(m=this.helpers.lines,m.bones.length){ge.copy(this.armature.matrixWorld).invert();const t=m.object.geometry.getAttribute("position");for(let e=0,n=0,i=m.bones.length;e<i;e++,n+=2)pe.multiplyMatrices(ge,m.bones[e].matrixWorld),F.setFromMatrixPosition(pe),t.setXYZ(n,F.x,F.y,F.z),pe.multiplyMatrices(ge,m.bones[e].parent.matrixWorld),F.setFromMatrixPosition(pe),t.setXYZ(n+1,F.x,F.y,F.z);t.needsUpdate=!0,m.object.updateMatrixWorld()}}hideHelpers(){[this.helpers.points,this.helpers.lines].forEach(t=>{t.bones=[],t.object&&(this.scene.remove(t.object),t.object.geometry.dispose(),t.object.material.dispose(),t.object=null)}),m=this.helpers.excludes,m.objects.forEach((t,e)=>{t&&(m.bones[e].remove(t),t.geometry.dispose(),t.material.dispose())}),m.bones=[],m.deltaLocals=[],m.radii=[],m.objects=[],this.helpers.isActive=!1}start(){this.data.length&&(this.running=!0,this.timerMs=0,this.showHelpers())}stop(){this.running=!1,this.hideHelpers();for(let t=0,e=this.data.length;t<e;t++){const n=this.data[t];n.bone.position.copy(n.vBasis),n.boneParent.quaternion.copy(n.qBasis)}}dispose(){this.stop(),this.scene=null,this.armature=null,this.config=[],this.data=[],this.dict={},this.objectsUpdate=[],this.timerMs=0}}class et{constructor(t){this.audioContext=t,this.analyzer=null,this.dataArray=null,this.bufferLength=0}async analyzeAudio(t,e){const n=t.sampleRate,i=t.duration,s=t.getChannelData(0),o=this.extractAudioFeatures(s,n);return this.generateTimingData(o,e,i)}extractAudioFeatures(t,e){const n={energy:[],spectralCentroid:[],zeroCrossingRate:[],mfcc:[],onsets:[],phonemeBoundaries:[]},i=1024,s=512,o=Math.floor((t.length-i)/s)+1;for(let l=0;l<o;l++){const c=l*s,r=Math.min(c+i,t.length),u=t.slice(c,r),a=this.calculateEnergy(u);n.energy.push(a);const d=this.calculateSpectralCentroid(u);n.spectralCentroid.push(d);const h=this.calculateZeroCrossingRate(u);n.zeroCrossingRate.push(h);const g=this.calculateMFCC(u);n.mfcc.push(g)}return n.onsets=this.detectOnsets(n.energy),n.phonemeBoundaries=this.detectPhonemeBoundaries(n),n}calculateEnergy(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return e/t.length}calculateSpectralCentroid(t){const e=this.fft(t);let n=0,i=0;for(let s=0;s<e.length/2;s++){const o=Math.sqrt(e[s*2]*e[s*2]+e[s*2+1]*e[s*2+1]);n+=s*o,i+=o}return i>0?n/i:0}calculateZeroCrossingRate(t){let e=0;for(let n=1;n<t.length;n++)t[n]>=0!=t[n-1]>=0&&e++;return e/(t.length-1)}calculateMFCC(t){const e=this.fft(t),n=[];for(let i=0;i<13;i++){let s=0;for(let o=0;o<e.length/2;o++){const l=Math.sqrt(e[o*2]*e[o*2]+e[o*2+1]*e[o*2+1]);s+=l*Math.cos(Math.PI*i*(o+.5)/(e.length/2))}n.push(s)}return n}fft(t){const e=t.length,n=new Float32Array(e*2);for(let i=0;i<e;i++)n[i*2]=t[i],n[i*2+1]=0;for(let i=1,s=0;i<e;i++){let o=e>>1;for(;s&o;)s^=o,o>>=1;if(s^=o,i<s){const l=n[i*2],c=n[i*2+1];n[i*2]=n[s*2],n[i*2+1]=n[s*2+1],n[s*2]=l,n[s*2+1]=c}}for(let i=2;i<=e;i<<=1){const s=-2*Math.PI/i,o=Math.cos(s),l=Math.sin(s);for(let c=0;c<e;c+=i){let r=1,u=0;for(let a=0;a<i/2;a++){const d=n[(c+a)*2],h=n[(c+a)*2+1],g=n[(c+a+i/2)*2]*r-n[(c+a+i/2)*2+1]*u,x=n[(c+a+i/2)*2]*u+n[(c+a+i/2)*2+1]*r;n[(c+a)*2]=d+g,n[(c+a)*2+1]=h+x,n[(c+a+i/2)*2]=d-g,n[(c+a+i/2)*2+1]=h-x;const f=r*o-u*l,w=r*l+u*o;r=f,u=w}}}return n}detectOnsets(t){const e=[];let s=-.1;for(let o=1;o<t.length;o++){const l=t[o]-t[o-1],c=o*.023;l>.1&&c-s>.1&&(e.push(c),s=c)}return e}detectPhonemeBoundaries(t){const e=[],{energy:n,spectralCentroid:i,zeroCrossingRate:s}=t;for(let o=1;o<n.length;o++){const l=o*.023,c=Math.abs(n[o]-n[o-1]),r=Math.abs(i[o]-i[o-1]),u=Math.abs(s[o]-s[o-1]);c+r*.1+u*.5>.2&&e.push(l)}return e}generateTimingData(t,e,n){const i=e.toLowerCase().split(/\s+/);t.phonemeBoundaries,t.onsets;const s=[];let o=0;for(let c=0;c<i.length;c++){const r=i[c],u=this.estimateWordDuration(r,n/i.length);s.push({word:r,startTime:o,endTime:o+u,duration:u}),o+=u}const l=this.generateVisemeTimings(t,e,n);return{words:s,visemes:l,duration:n,features:t}}estimateWordDuration(t,e){const n=Math.max(.5,Math.min(2,t.length/5)),i=this.getWordComplexity(t);return e*n*i}getWordComplexity(t){const e=(t.match(/[bcdfghjklmnpqrstvwxyz]{2,}/g)||[]).length,n=(t.match(/[aeiou]{2,}/g)||[]).length;return 1+e*.2+n*.1}generateVisemeTimings(t,e,n){const i=[],s=t.phonemeBoundaries;t.onsets;const o=this.textToVisemes(e);let l=0,c=0;for(let r=0;r<s.length&&l<o.length;r++){const u=s[r],a=o[l],d=t.energy[Math.floor(u/.023)]||0,h=this.calculateVisemeDuration(a,d);i.push({viseme:a,startTime:c,endTime:c+h,duration:h,intensity:Math.min(1,d*2)}),c+=h,l++}for(;l<o.length;){const r=o[l],u=this.calculateVisemeDuration(r,.5);i.push({viseme:r,startTime:c,endTime:c+u,duration:u,intensity:.6}),c+=u,l++}return i}textToVisemes(t){const e={a:"aa",e:"E",i:"I",o:"O",u:"U",ae:"aa",ai:"aa",au:"O",ea:"E",ee:"E",ei:"E",ie:"I",oa:"O",oo:"U",ou:"U",b:"PP",p:"PP",m:"PP",f:"FF",v:"FF",th:"SS",s:"SS",z:"SS",sh:"SS",ch:"SS",d:"DD",t:"DD",n:"nn",l:"nn",k:"kk",g:"kk",ng:"kk",r:"RR",w:"RR",y:"I",h:"kk"},n=[],i=t.toLowerCase().replace(/[^a-z\s]/g,"").split(/\s+/);for(const s of i){let o=0;for(;o<s.length;){let l=!1;for(let c=3;c>=2;c--){const r=s.substr(o,c);if(e[r]){n.push(e[r]),o+=c,l=!0;break}}if(!l){const c=s[o];e[c]&&n.push(e[c]),o++}}}return n}calculateVisemeDuration(t,e){const i={aa:.15,E:.12,I:.1,O:.14,U:.13,PP:.08,FF:.1,SS:.12,DD:.11,kk:.09,nn:.1,RR:.11}[t]||.1,s=.5+e*.5;return i*s}}class tt{constructor(){this.rules={A:["[A] =aa"," [ARE] =aa RR"," [AR]O=aa RR","[AR]#=E RR"," ^[AS]#=E SS","[A]WA=aa","[AW]=aa"," :[ANY]=E nn I","[A]^+#=E","#:[ALLY]=aa nn I"," [AL]#=aa nn","[AGAIN]=aa kk E nn","#:[AG]E=I kk","[A]^+:#=aa",":[A]^+ =E","[A]^%=E"," [ARR]=aa RR","[ARR]=aa RR"," :[AR] =aa RR","[AR] =E","[AR]=aa RR","[AIR]=E RR","[AI]=E","[AY]=E","[AU]=aa","#:[AL] =aa nn","#:[ALS] =aa nn SS","[ALK]=aa kk","[AL]^=aa nn"," :[ABLE]=E PP aa nn","[ABLE]=aa PP aa nn","[ANG]+=E nn kk","[A]=aa"],B:[" [BE]^#=PP I","[BEING]=PP I I nn"," [BOTH] =PP O TH"," [BUS]#=PP I SS","[BUIL]=PP I nn","[B]=PP"],C:[" [CH]^=kk","^E[CH]=kk","[CH]=CH"," S[CI]#=SS aa","[CI]A=SS","[CI]O=SS","[CI]EN=SS","[C]+=SS","[CK]=kk","[COM]%=kk aa PP","[C]=kk"],D:["#:[DED] =DD I DD",".E[D] =DD","#^:E[D] =DD"," [DE]^#=DD I"," [DO] =DD U"," [DOES]=DD aa SS"," [DOING]=DD U I nn"," [DOW]=DD aa","[DU]A=kk U","[D]=DD"],E:["#:[E] =","'^:[E] ="," :[E] =I","#[ED] =DD","#:[E]D =","[EV]ER=E FF","[E]^%=I","[ERI]#=I RR I","[ERI]=E RR I","#:[ER]#=E","[ER]#=E RR","[ER]=E"," [EVEN]=I FF E nn","#:[E]W=","@[EW]=U","[EW]=I U","[E]O=I","#:&[ES] =I SS","#:[E]S =","#:[ELY] =nn I","#:[EMENT]=PP E nn DD","[EFUL]=FF U nn","[EE]=I","[EARN]=E nn"," [EAR]^=E","[EAD]=E DD","#:[EA] =I aa","[EA]SU=E","[EA]=I","[EIGH]=E","[EI]=I"," [EYE]=aa","[EY]=I","[EU]=I U","[E]=E"],F:["[FUL]=FF U nn","[F]=FF"],G:["[GIV]=kk I FF"," [G]I^=kk","[GE]T=kk E","SU[GGES]=kk kk E SS","[GG]=kk"," B#[G]=kk","[G]+=kk","[GREAT]=kk RR E DD","#[GH]=","[G]=kk"],H:[" [HAV]=I aa FF"," [HERE]=I I RR"," [HOUR]=aa EE","[HOW]=I aa","[H]#=I","[H]="],I:[" [IN]=I nn"," [I] =aa","[IN]D=aa nn","[IER]=I E","#:R[IED] =I DD","[IED] =aa DD","[IEN]=I E nn","[IE]T=aa E"," :[I]%=aa","[I]%=I","[IE]=I","[I]^+:#=I","[IR]#=aa RR","[IZ]%=aa SS","[IS]%=aa SS","[I]D%=aa","+^[I]^+=I","[I]T%=aa","#^:[I]^+=I","[I]^+=aa","[IR]=E","[IGH]=aa","[ILD]=aa nn DD","[IGN] =aa nn","[IGN]^=aa nn","[IGN]%=aa nn","[IQUE]=I kk","[I]=I"],J:["[J]=kk"],K:[" [K]N=","[K]=kk"],L:["[LO]C#=nn O","L[L]=","#^:[L]%=aa nn","[LEAD]=nn I DD","[L]=nn"],M:["[MOV]=PP U FF","[M]=PP"],N:["E[NG]+=nn kk","[NG]R=nn kk","[NG]#=nn kk","[NGL]%=nn kk aa nn","[NG]=nn","[NK]=nn kk"," [NOW] =nn aa","[N]=nn"],O:["[OF] =aa FF","[OROUGH]=E O","#:[OR] =E","#:[ORS] =E SS","[OR]=aa RR"," [ONE]=FF aa nn","[OW]=O"," [OVER]=O FF E","[OV]=aa FF","[O]^%=O","[O]^EN=O","[O]^I#=O","[OL]D=O nn","[OUGHT]=aa DD","[OUGH]=aa FF"," [OU]=aa","H[OU]S#=aa","[OUS]=aa SS","[OUR]=aa RR","[OULD]=U DD","^[OU]^L=aa","[OUP]=U OO","[OU]=aa","[OY]=O","[OING]=O I nn","[OI]=O","[OOR]=aa RR","[OOK]=U kk","[OOD]=U DD","[OO]=U","[O]E=O","[O] =O","[OA]=O"," [ONLY]=O nn nn I"," [ONCE]=FF aa nn SS","[ON'T]=O nn DD","C[O]N=aa","[O]NG=aa"," ^:[O]N=aa","I[ON]=aa nn","#:[ON] =aa nn","#^[ON]=aa nn","[O]ST =O","[OF]^=aa FF","[OTHER]=aa TH E","[OSS] =aa SS","#^:[OM]=aa PP","[O]=aa"],P:["[PH]=FF","[PEOP]=PP I PP","[POW]=PP aa","[PUT] =PP U DD","[P]=PP"],Q:["[QUAR]=kk FF aa RR","[QU]=kk FF","[Q]=kk"],R:[" [RE]^#=RR I","[R]=RR"],S:["[SH]=SS","#[SION]=SS aa nn","[SOME]=SS aa PP","#[SUR]#=SS E","[SUR]#=SS E","#[SU]#=SS U","#[SSU]#=SS U","#[SED] =SS DD","#[S]#=SS","[SAID]=SS E DD","^[SION]=SS aa nn","[S]S=",".[S] =SS","#:.E[S] =SS","#^:##[S] =SS","#^:#[S] =SS","U[S] =SS"," :#[S] =SS"," [SCH]=SS kk","[S]C+=","#[SM]=SS PP","#[SN]'=SS aa nn","[S]=SS"],T:[" [THE] =TH aa","[TO] =DD U","[THAT] =TH aa DD"," [THIS] =TH I SS"," [THEY]=TH E"," [THERE]=TH E RR","[THER]=TH E","[THEIR]=TH E RR"," [THAN] =TH aa nn"," [THEM] =TH E PP","[THESE] =TH I SS"," [THEN]=TH E nn","[THROUGH]=TH RR U","[THOSE]=TH O SS","[THOUGH] =TH O"," [THUS]=TH aa SS","[TH]=TH","#:[TED] =DD I DD","S[TI]#N=CH","[TI]O=SS","[TI]A=SS","[TIEN]=SS aa nn","[TUR]#=CH E","[TU]A=CH U"," [TWO]=DD U","[T]=DD"],U:[" [UN]I=I U nn"," [UN]=aa nn"," [UPON]=aa PP aa nn","@[UR]#=U RR","[UR]#=I U RR","[UR]=E","[U]^ =aa","[U]^^=aa","[UY]=aa"," G[U]#=","G[U]%=","G[U]#=FF","#N[U]=I U","@[U]=I","[U]=I U"],V:["[VIEW]=FF I U","[V]=FF"],W:[" [WERE]=FF E","[WA]S=FF aa","[WA]T=FF aa","[WHERE]=FF E RR","[WHAT]=FF aa DD","[WHOL]=I O nn","[WHO]=I U","[WH]=FF","[WAR]=FF aa RR","[WOR]^=FF E","[WR]=RR","[W]=FF"],X:[" [X]=SS","[X]=kk SS"],Y:["[YOUNG]=I aa nn"," [YOU]=I U"," [YES]=I E SS"," [Y]=I","#^:[Y] =I","#^:[Y]I=I"," :[Y] =aa"," :[Y]#=aa"," :[Y]^+:#=I"," :[Y]^#=I","[Y]=I"],Z:["[Z]=SS"]};const t={"#":"[AEIOUY]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ED|ING|ELY)","&":"(?:[SCGZXJ]|CH|SH)","@":"(?:[TSRDLZNJ]|TH|CH|SH)","^":"[BCDFGHJKLMNPQRSTVWXZ]","+":"[EIY]",":":"[BCDFGHJKLMNPQRSTVWXZ]*"," ":"\\b"};Object.keys(this.rules).forEach(e=>{this.rules[e]=this.rules[e].map(n=>{const i=n.indexOf("["),s=n.indexOf("]"),o=n.indexOf("="),l=n.substring(0,i),c=n.substring(i+1,s),r=n.substring(s+1,o),u=n.substring(o+1),a={regex:"",move:0,visemes:[]};let d="";d+=[...l].map(g=>t[g]||g).join("");const h=[...c];return h[0]=h[0].toLowerCase(),d+=h.join(""),a.move=h.length,d+=[...r].map(g=>t[g]||g).join(""),a.regex=new RegExp(d),u.length&&u.split(" ").forEach(g=>{a.visemes.push(g)}),a})}),this.visemeDurations={aa:.95,E:.9,I:.92,O:.96,U:.95,PP:1.08,SS:1.23,TH:1,DD:1.05,FF:1,kk:1.21,nn:.88,RR:.88,DD:1.05,sil:1},this.specialDurations={" ":1,",":3,"-":.5,"'":.5},this.digits=["oh","one","two","three","four","five","six","seven","eight","nine"],this.ones=["","one","two","three","four","five","six","seven","eight","nine"],this.tens=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],this.teens=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],this.decades={20:"twenties",30:"thirties",40:"forties",50:"fifties",60:"sixties",70:"seventies",80:"eighties",90:"nineties"},this.ordinals={1:"first",2:"second",3:"third",4:"fourth",5:"fifth",6:"sixth",7:"seventh",8:"eighth",9:"ninth",10:"tenth",11:"eleventh",12:"twelfth",13:"thirteenth",14:"fourteenth",15:"fifteenth",16:"sixteenth",17:"seventeeth",18:"eighteenth",19:"nineteenth",20:"twentieth",30:"thirtieth",40:"fortieth",50:"fiftieth",60:"sixtieth",70:"seventieth",80:"eightieth",90:"ninetieth"},this.symbols={"%":"percent","€":"euros","&":"and","+":"plus",$:"dollars"},this.symbolsReg=/[%€&\+\$]/g}convert_digit_by_digit(t){t=String(t).split("");let e="";for(let n=0;n<t.length;n++)e+=this.digits[t[n]]+" ";return e=e.substring(0,e.length-1),e}convert_sets_of_two(t){let e=String(t).substring(0,2),n=String(t).substring(2,4),i=this.convert_tens(e);return i+=" "+this.convert_tens(n),i}convert_millions(t){return t>=1e6?this.convert_millions(Math.floor(t/1e6))+" million "+this.convert_thousands(t%1e6):this.convert_thousands(t)}convert_thousands(t){return t>=1e3?this.convert_hundreds(Math.floor(t/1e3))+" thousand "+this.convert_hundreds(t%1e3):this.convert_hundreds(t)}convert_hundreds(t){return t>99?this.ones[Math.floor(t/100)]+" hundred "+this.convert_tens(t%100):this.convert_tens(t)}convert_tens(t){return t<10?(Number(t)!=0&&t.toString().startsWith("0")?"oh ":"")+this.ones[Number(t)]:t>=10&&t<20?this.teens[t-10]:(this.tens[Math.floor(t/10)]+" "+this.ones[t%10]).trim()}convertNumberToWords(t,e=!1){const n=parseFloat(t);if(t=="0")return"zero";if(t<0)return" minus "+this.convertNumberToWords(Math.abs(t).toString(),e).trim();if(n&&!Number.isInteger(n)){const i=n.toString().split(".");return this.convertNumberToWords(i[0],e).trim()+" point "+this.convert_digit_by_digit(i[1]).trim()}else return t.toString().startsWith("0")?this.convert_digit_by_digit(t).trim():!e&&(t<1e3&&t>99&&t%100!==0||t>1e4&&t<1e6)?this.convert_digit_by_digit(t).trim():!e&&(t>1e3&&t<2e3||t>2009&&t<3e3)?t%100!=0?this.convert_sets_of_two(t).trim():this.convert_tens(t.toString().substring(0,2)).trim()+" hundred":this.convert_millions(t).trim()}convertDecade(t){const e=parseInt(t),n=!isNaN(e)&&t.length===2,i=!isNaN(e)&&t.length>2&&e>0&&e<=3e3,s=i&&e%1e3===0?Math.floor(e/1e3):null,o=i&&!s?Math.floor(e/100):null,l=n||i?Math.floor(e%100/10)*10:null;let c=[];return s?c.push(this.convertNumberToWords(s).trim(),"thousands"):(o&&c.push(this.convertNumberToWords(o).trim()),l?c.push(this.decades[l]||this.convertNumberToWords(l).trim()+"s"):o?c.push("hundreds"):c.push(t)),c.join(" ")}convertOrdinal(t){if(this.ordinals.hasOwnProperty(t))return this.ordinals[t];const e=Math.floor(t/100),n=Math.floor(t%100/10)*10,i=t%10;let s=[];return e&&(s.push(this.convertNumberToWords(e).trim()),n||i?s.push("hundred"):s.push("hundredth")),n&&(i?s.push(this.convertNumberToWords(n).trim()):s.push(this.ordinals[n])),i&&s.push(this.ordinals[i]),s.join(" ")}preProcessText(t){let e=t.replace('/[#_*":;]/g',"");return e=e.replace(this.symbolsReg,n=>" "+this.symbols[n]+" "),/\d/.test(e)&&(e=e.replace(/\b(\d{2,4})[''']?\s?[sS](?=\s|[.,!?;:]|$)/g,(n,i)=>{const s=this.convertDecade(i);return s===i?n:s}),e=e.replace(/\b(\d+)\s*(st|nd|rd|th)(?=\s|[.,!?;:]|$)/gi,(n,i)=>this.convertOrdinal(Number(i))),e=e.replace(/\b(\w*?)(\d+)([A-Za-z]+)\b/g,(n,i,s,o)=>{const l=this.convertNumberToWords(s);return`${i}${l} ${o}`}).replace(/\b([A-Za-z]+)(\d+)(\w*?)\b/g,(n,i,s,o)=>{const l=this.convertNumberToWords(s);return`${i} ${l}${o}`}),e=e.replace(/-?(?:\d{1,3}(?:,\d{3})+|\d+)(\.\d+)?/g,(n,i)=>{let s=n,o=!1;return/,/.test(s)&&(s=s.replace(/,/g,""),o=!0),i&&(o=!0),this.convertNumberToWords(s,o)})),e=e.replace(/(\D)\1\1+/g,"$1$1").replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC").trim(),e}wordsToVisemes(t){let e={words:t.toUpperCase(),visemes:[],times:[],durations:[],i:0},n=0;const i=[...e.words];for(;e.i<i.length;){const s=i[e.i],o=this.rules[s];if(o)for(let l=0;l<o.length;l++){const c=o[l];if((e.words.substring(0,e.i)+s.toLowerCase()+e.words.substring(e.i+1)).match(c.regex)){c.visemes.forEach(a=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===a){const d=.7*(this.visemeDurations[a]||1);e.durations[e.durations.length-1]+=d,n+=d}else{const d=this.visemeDurations[a]||1;e.visemes.push(a),e.times.push(n),e.durations.push(d),n+=d}}),e.i+=c.move;break}}else e.i++,n+=this.specialDurations[s]||0}return e}}const nt=Object.freeze(Object.defineProperty({__proto__:null,LipsyncEn:tt},Symbol.toStringTag,{value:"Module"}));class it{constructor(){this.rules={A:["[AH]=aa","[AU]=aa U","[AI]=aa I","[AE]=E","[A]H=aa","[A]U=aa U","[A]I=aa I"," [AN] =aa nn"," [AM] =aa PP","[ARR]=aa RR","[AR]=aa RR"," [ALS]=aa nn SS","[AL]=aa nn","[AUCH]=aa U kk","[ABER]=aa PP E RR","[A]=aa"],Ä:["[Ä]H=E","[ÄU]=O","[Ä]=E"],B:["[B]=PP"],C:["[CH]S=kk SS","[CH]=kk"," [CH]=kk","#[CH]=kk","[CK]=kk","[C]H=kk","[C]=kk"],D:[" [DAS] =DD aa SS"," [DEN] =DD E nn"," [DER] =DD E RR"," [DIE] =DD I"," [DU] =DD U"," [DURCH]=DD U RR kk","[D]=DD"],E:["[EI]=aa I","[EU]=O","[EH]=E"," [ER] =E RR"," [ES] =E SS"," [EIN] =aa I nn"," [EINE]=aa I nn aa","[ER]#=E","[ER]=E RR","[EN]#=aa nn","[E]=E"],F:["[F]=FF"],G:["[G]=kk"],H:[" [HAT] =I aa DD"," [HABEN]=I aa PP aa nn"," [HIER]=I I RR"," [HEUTE]=I O DD aa","[H]="],I:[" [ICH] =I kk"," [IHR] =I RR"," [IN] =I nn"," [IST] =I SS DD"," [IM] =I PP","[IE]=I","[IH]=I","[I]=I"],J:["[J]=I"],K:["[K]=kk"],L:["[L]=nn"],M:[" [MIT] =PP I DD"," [MAN] =PP aa nn"," [MEHR]=PP E RR"," [MICH]=PP I kk","[M]=PP"],N:[" [NICHT]=nn I kk DD"," [NUR] =nn U RR"," [NACH]=nn aa kk"," [NOCH]=nn aa kk","[NG]=nn kk","[N]=nn"],O:["[OO]=U","[OH]=O","[OU]=aa U"," [ODER]=O DD E RR"," [OHNE]=O nn aa","[Ö]=E","[O]=aa"],Ö:["[ÖH]=E","[Ö]=E"],P:["[PF]=FF FF","[PH]=FF","[P]=PP"],Q:["[QU]=kk FF","[Q]=kk"],R:["[R]=RR"],S:["[SCH]=SS","[SP]=SS PP","[ST]=SS DD","[SS]=SS","[S]=SS"],ß:["[ß]=SS"],T:["[TZ]=DD SS","[TH]=DD","[T]=DD"],U:[" [UND] =U nn DD"," [UM] =U PP"," [UNTER]=U nn DD E RR"," [UNS] =U nn SS","[UH]=U","[ÜH]=I U","[Ü]=I U","[U]=U"],Ü:["[ÜH]=I U","[Ü]=I U"],V:[" [VON] =FF aa nn"," [VOR] =FF aa RR"," [VIEL]=FF I nn","[V]=FF"],W:[" [WAS] =FF aa SS"," [WIR] =FF I RR"," [WIE] =FF I"," [WENN]=FF E nn"," [WILL]=FF I nn"," [WO] =FF aa"," [WIEDER]=FF I DD E RR","[W]=FF"],X:["[X]=kk SS"],Y:["[Y]=I"],Z:[" [ZU] =DD SS U"," [ZUM] =DD SS U PP"," [ZUR] =DD SS U RR"," [ZEIT]=DD SS aa I DD","[Z]=DD SS"]};const t={"#":"[AEIOUÄÖÜ]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ED|ING|ELY|EN|TE|ST)","&":"(?:[SCGZXJ]|CH|SCH|TZ)","@":"(?:[TSRDLZNJ]|TH|CH|SCH)","^":"[BCDFGHJKLMNPQRSTVWXYZß]","+":"[EIY]",":":"[BCDFGHJKLMNPQRSTVWXYZß]*"," ":"\\b"};Object.keys(this.rules).forEach(e=>{this.rules[e]=this.rules[e].map(n=>{const i=n.indexOf("["),s=n.indexOf("]"),o=n.indexOf("="),l=n.substring(0,i),c=n.substring(i+1,s),r=n.substring(s+1,o),u=n.substring(o+1),a={regex:"",move:0,visemes:[]};let d="";d+=[...l].map(g=>t[g]||g).join("");const h=[...c];return h[0]=h[0].toLowerCase(),d+=h.join(""),a.move=h.length,d+=[...r].map(g=>t[g]||g).join(""),a.regex=new RegExp(d),u.length&&u.split(" ").forEach(g=>{a.visemes.push(g)}),a})}),this.visemeDurations={aa:1,E:.85,I:.9,O:1.05,U:1,PP:1.15,SS:1.2,TH:1,DD:1.1,FF:1.05,kk:1.25,nn:.85,RR:.9,sil:1},this.specialDurations={" ":1,",":3,"-":.5,"'":.5,".":4,"!":3,"?":3},this.digits=["null","eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun"],this.ones=["","ein","zwei","drei","vier","fünf","sechs","sieben","acht","neun"],this.tens=["","","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"],this.teens=["zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn"],this.symbols={"%":"prozent","€":"euro","&":"und","+":"plus",$:"dollar","=":"gleich","@":"at","#":"hashtag"},this.symbolsReg=/[%€&\+\$=@#]/g}convert_digit_by_digit(t){t=String(t).split("");let e="";for(let n=0;n<t.length;n++)e+=this.digits[t[n]]+" ";return e=e.substring(0,e.length-1),e}convert_millions(t){if(t>=1e6){const e=Math.floor(t/1e6),n=t%1e6;let i=this.convert_thousands(e);return i+=e===1?" million ":" millionen ",n>0&&(i+=this.convert_thousands(n)),i}else return this.convert_thousands(t)}convert_thousands(t){if(t>=1e3){const e=Math.floor(t/1e3),n=t%1e3;let i="";return e===1?i="eintausend":i=this.convert_hundreds(e)+"tausend",n>0&&(i+=this.convert_hundreds(n)),i}else return this.convert_hundreds(t)}convert_hundreds(t){if(t>99){const e=Math.floor(t/100),n=t%100;let i="";return e===1?i="einhundert":i=this.ones[e]+"hundert",n>0&&(i+=this.convert_tens(n)),i}else return this.convert_tens(t)}convert_tens(t){if(t<10)return this.ones[Number(t)]||"";if(t>=10&&t<20)return this.teens[t-10];{const e=Math.floor(t/10),n=t%10;return n===0?this.tens[e]:this.ones[n]+"und"+this.tens[e]}}convertNumberToWords(t){const e=String(t);return t=="0"?"null":e.startsWith("0")?this.convert_digit_by_digit(t):e.length===4&&(t<1e3||t>2100)?this.convert_digit_by_digit(t):this.convert_millions(Number(t))}preProcessText(t){return t.replace(/[#_*\":;]/g,"").replace(this.symbolsReg,e=>" "+this.symbols[e]+" ").replace(/(\d)\.(\d)/g,"$1 komma $2").replace(/(\d),(\d)/g,"$1 komma $2").replace(/\d+/g,this.convertNumberToWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replace(/\s+/g," ").toLowerCase().trim()}wordsToVisemes(t){let e={words:t.toUpperCase(),visemes:[],times:[],durations:[],i:0},n=0;const i=[...e.words];for(;e.i<i.length;){const s=i[e.i],o=this.rules[s];if(o){let l=!1;for(let c=0;c<o.length;c++){const r=o[c];if((e.words.substring(0,e.i)+s.toLowerCase()+e.words.substring(e.i+1)).match(r.regex)){r.visemes.forEach(d=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===d){const h=.7*(this.visemeDurations[d]||1);e.durations[e.durations.length-1]+=h,n+=h}else{const h=this.visemeDurations[d]||1;e.visemes.push(d),e.times.push(n),e.durations.push(h),n+=h}}),e.i+=r.move,l=!0;break}}l||(e.i++,n+=this.specialDurations[s]||0)}else e.i++,n+=this.specialDurations[s]||0}return e}}const ot=Object.freeze(Object.defineProperty({__proto__:null,LipsyncDe:it},Symbol.toStringTag,{value:"Module"}));class st{constructor(){this.rules={A:["[AN]C=aa nn","[AN]G=aa nn","[AN]T=aa nn","[AN]D=aa nn","[AN] =aa nn","[AN]$=aa nn","[AM]P=aa nn","[AM]B=aa nn","[AM] =aa nn","[AM]$=aa nn","[AI]N=E nn","[AIM]=E nn","[AIN]=E nn","[AU]=O","[AUX]=O","[AUT]=O","[AI]=E","[AY]=E","[A]=aa"],À:["[À]=aa"],Â:["[Â]=aa"],B:[" [B] =PP","[BB]=PP","[B]=PP"],C:["[C]E=SS","[C]I=SS","[C]Y=SS","[C]È=SS","[C]É=SS","[C]Ê=SS","[CH]=SS","[C]A=kk","[C]O=kk","[C]U=kk","[C]L=kk","[C]R=kk","[CK]=kk","[C]=kk"],Ç:["[Ç]=SS"],D:["[D]=DD"],E:["[EN]C=aa nn","[EN]T=aa nn","[EN]D=aa nn","[EN] =aa nn","[EN]$=aa nn","[EM]P=aa nn","[EM]B=aa nn","[EM] =aa nn","[EM]$=aa nn","[EAU]=O","[EAU]X=O","[EU]=U","[EUX]=U","[EUR]=U RR","[EI]=E","[EIN]=E nn","[ER] =E","[ER]$=E","[EZ] =E","[EZ]$=E","[ED] =E","[ED]$=E"," [E] =","[E] =","[E]$=","[E]S =","[E]S$=","[E]NT =","[E]NT$=","[È]=E","[É]=E","[Ê]=E","[Ë]=E","[E]=E"],È:["[È]=E"],É:["[É]=E"],Ê:["[Ê]=E"],Ë:["[Ë]=E"],F:["[FF]=FF","[F]=FF","[PH]=FF"],G:["[G]E=SS","[G]I=SS","[G]Y=SS","[G]È=SS","[G]É=SS","[G]Ê=SS","[GN]=nn I","[GN]E=nn","[GN]A=nn aa","[GN]O=nn O","[GU]E=kk","[GU]I=kk","[GU]A=kk FF aa","[GU]O=kk FF O","[G]A=kk","[G]O=kk","[G]U=kk","[G]L=kk","[G]R=kk","[GG]=kk","[G]=kk"],H:["[H]="],I:["[IN]C=E nn","[IN]T=E nn","[IN]D=E nn","[IN] =E nn","[IN]$=E nn","[IM]P=E nn","[IM]B=E nn","[IM] =E nn","[IM]$=E nn","[IEN]=I E nn","[IER]=I E","[IEU]=I U","[IEZ]=I E","[ILL]E=I","[ILLE]=I","[ILL]=I","[Î]=I","[Ï]=I","[I]=I"],Î:["[Î]=I"],Ï:["[Ï]=I"],J:["[J]=SS"],K:["[K]=kk"],L:["[LL]E=","[LLE]=","[LL]A=I aa","[LL]O=I O","[LL]U=I U","[LL]I=I","[LL]=I","[L]=nn"],M:["[MM]=PP","[M]=PP"],N:["[NN]=nn","[N]=nn"],O:["[ON]C=O nn","[ON]T=O nn","[ON]D=O nn","[ON] =O nn","[ON]$=O nn","[OM]P=O nn","[OM]B=O nn","[OM] =O nn","[OM]$=O nn","[OI]N=FF E nn","[OI]G=FF aa","[OI]S=FF aa","[OI]T=FF aa","[OI]X=FF aa","[OI]=FF aa","[OU]=U","[OÙ]=U","[OÛ]=U","[OEU]=U","[OEUR]=U RR","[OUGH]=U FF","[OUGH]T=U","[Ô]=O","[O]=O"],Ô:["[Ô]=O"],Ù:["[Ù]=U"],Û:["[Û]=U"],P:["[PH]=FF","[PP]=PP","[P]=PP"],Q:["[QU]=kk","[Q]=kk"],R:["[RR]=RR","[R]=RR"],S:["#[S]#=SS"," [S]=SS","[SS]=SS","[S] =","[S]$=","[SC]E=SS","[SC]I=SS","[SC]Y=SS","[S]=SS"],T:["[TI]A=SS I aa","[TI]E=SS I E","[TI]O=SS I O","[TI]ON=SS I O nn","[TH]=DD","[TT]=DD","[T] =","[T]$=","[T]=DD"],U:["[UN]C=U nn","[UN]T=U nn","[UN]D=U nn","[UN] =U nn","[UN]$=U nn","[UM]=U nn","[UE]=I","[UEI]=I E","[UEIL]=I I","[UILL]=I","[Ù]=U","[Û]=U","[Ü]=I U","[U]=I U"],Ü:["[Ü]=I U"],V:["[V]=FF"],W:["[W]=FF"],X:["[X] =","[X]$=","#[X]#=kk SS"," [X]=kk SS","[X]=kk SS"],Y:["[Y]=I"," [Y]=I","[YE]=I E","[YA]=I aa","[YO]=I O","[YU]=I U"],Z:["[Z]=SS"]};const t={"#":"[AEIOUYÀÂÈÉÊËÎÏÔÙÛÜ]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ÉS|ÈS|ÊS|ENT|MENT|TION|SION)","&":"(?:[SCGZXJ]|CH|SH|GN)","@":"(?:[TSRDLZNJ]|TH|CH|SH|GN)","^":"[BCDFGHJKLMNPQRSTVWXZÇ]+","+":"[EIYÈÉÊËÎÏ]",":":"[BCDFGHJKLMNPQRSTVWXZÇ]*"," ":"\\b",$:"$"};Object.keys(this.rules).forEach(e=>{this.rules[e]=this.rules[e].map(n=>{const i=n.indexOf("["),s=n.indexOf("]"),o=n.indexOf("="),l=n.substring(0,i),c=n.substring(i+1,s),r=n.substring(s+1,o),u=n.substring(o+1),a={regex:"",move:0,visemes:[]};let d="";d+=[...l].map(g=>t[g]||g).join("");const h=[...c];return h[0]=h[0].toLowerCase(),d+=h.join(""),a.move=h.length,d+=[...r].map(g=>t[g]||g).join(""),a.regex=new RegExp(d,"i"),u.length&&u.split(" ").forEach(g=>{g&&a.visemes.push(g)}),a})}),this.visemeDurations={aa:1,E:.95,I:.9,O:1.05,U:.95,PP:1.1,SS:1.25,TH:1,DD:1.05,FF:1,kk:1.2,nn:.88,RR:1.15,sil:1},this.specialDurations={" ":1,",":2.5,".":3.5,";":2.8,":":2.2,"!":3.2,"?":3.2,"-":.8,"'":.3,'"':.3,"(":1.5,")":1.5},this.digits=["zéro","un","deux","trois","quatre","cinq","six","sept","huit","neuf"],this.ones=["","un","deux","trois","quatre","cinq","six","sept","huit","neuf"],this.teens=["dix","onze","douze","treize","quatorze","quinze","seize","dix-sept","dix-huit","dix-neuf"],this.tens=["","dix","vingt","trente","quarante","cinquante","soixante","soixante-dix","quatre-vingts","quatre-vingt-dix"],this.symbols={"%":"pourcent","€":"euros","&":"et","+":"plus",$:"dollars","=":"égale","@":"arobase","#":"dièse","°":"degrés"},this.symbolsReg=/[%€&\+\$=@#°]/g}convert_digit_by_digit(t){t=String(t).split("");let e="";for(let n=0;n<t.length;n++)e+=this.digits[t[n]]+" ";return e=e.substring(0,e.length-1),e}convert_tens(t){if(t<10)return this.ones[t]||"";if(t>=10&&t<20)return this.teens[t-10];if(t>=70&&t<80){const e=t-60;return e===11?"soixante et onze":"soixante-"+this.teens[e-10]}else if(t>=90){const e=t-80;return e===11?"quatre-vingt-onze":"quatre-vingt-"+this.teens[e-10]}else{const e=Math.floor(t/10),n=t%10;return e===8&&n===0?"quatre-vingts":e===8?"quatre-vingt-"+this.ones[n]:(e===2||e===3||e===4||e===5||e===6)&&n===1?this.tens[e]+" et un":n===0?this.tens[e]:this.tens[e]+"-"+this.ones[n]}}convert_hundreds(t){if(t>=100){const e=Math.floor(t/100),n=t%100;let i="";return e===1?i="cent":(i=this.ones[e]+" cent",n===0&&(i+="s")),n>0&&(i+=" "+this.convert_tens(n)),i}else return this.convert_tens(t)}convert_thousands(t){if(t>=1e3){const e=Math.floor(t/1e3),n=t%1e3;let i="";return e===1?i="mille":i=this.convert_hundreds(e)+" mille",n>0&&(i+=" "+this.convert_hundreds(n)),i}else return this.convert_hundreds(t)}convert_millions(t){if(t>=1e6){const e=Math.floor(t/1e6),n=t%1e6;let i="";return e===1?i="un million":i=this.convert_hundreds(e)+" millions",n>0&&(i+=" "+this.convert_thousands(n)),i}else return this.convert_thousands(t)}convertNumberToWords(t){const e=String(t);return t==="0"||t===0?"zéro":e.startsWith("0")?this.convert_digit_by_digit(t):this.convert_millions(Number(t))}preProcessText(t){return t.replace(/[#_*\":;]/g,"").replace(this.symbolsReg,e=>" "+this.symbols[e]+" ").replace(/(\d)[,.](\d)/g,"$1 virgule $2").replace(/\d+/g,this.convertNumberToWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replace(/\s+/g," ").replace(/'/g,"'").trim()}wordsToVisemes(t){let e={words:t.toUpperCase(),visemes:[],times:[],durations:[],i:0},n=0;const i=[...e.words];for(;e.i<i.length;){const s=i[e.i],o=this.rules[s];if(o){let l=!1;for(let c=0;c<o.length;c++){const r=o[c];if((e.words.substring(0,e.i)+s.toLowerCase()+e.words.substring(e.i+1)).match(r.regex)){r.visemes.forEach(d=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===d){const h=.7*(this.visemeDurations[d]||1);e.durations[e.durations.length-1]+=h,n+=h}else{const h=this.visemeDurations[d]||1;e.visemes.push(d),e.times.push(n),e.durations.push(h),n+=h}}),e.i+=r.move,l=!0;break}}l||(e.i++,n+=this.specialDurations[s]||0)}else e.i++,n+=this.specialDurations[s]||0}return e}}const at=Object.freeze(Object.defineProperty({__proto__:null,LipsyncFr:st},Symbol.toStringTag,{value:"Module"}));class rt{constructor(){this.visemes={a:"aa",e:"E",i:"I",o:"O",u:"U",y:"U",ä:"aa",ö:"O",å:"O",b:"PP",c:"SS",d:"DD",f:"FF",g:"kk",h:"kk",j:"I",k:"kk",l:"nn",m:"PP",n:"nn",p:"PP",q:"kk",r:"RR",s:"SS",t:"DD",v:"FF",w:"FF",x:"SS",z:"SS"},this.visemeDurations={aa:.95,E:.9,I:.92,O:.96,U:.95,PP:1.08,SS:1.23,DD:1.05,FF:1,kk:1.21,nn:.88,RR:.88,DD:1.05,sil:1},this.specialDurations={" ":1,",":3,"-":.5},this.numbers=["nolla","yksi","kaksi","kolme","neljä","viisi","kuusi","seitsemän","kahdeksan","yhdeksän","kymmenen","yksitoista","kaksitoista","kolmetoista","neljätoista","viisitoista","kuusitoista","seitsemäntoista","kahdeksantoista","yhdeksäntoista"],this.symbols={"%":"prosenttia","€":"euroa","&":"ja","+":"plus",$:"dollaria"},this.symbolsReg=/[%€&\+\$]/g}numberToFinnishWords(t){const e=[];let n=parseFloat(t);if(n===void 0)return t;let i=(s,o,l,c,r)=>{if(s<o)return s;const u=Math.floor(s/o);return e.push(l+(u===1?c:this.numberToFinnishWords(u.toString())+r)),s-u*o};if(n<0&&(e.push("miinus "),n=Math.abs(n)),n=i(n,1e9," ","miljardi"," miljardia"),n=i(n,1e6," ","miljoona"," miljoonaa"),n=i(n,1e3,"","tuhat","tuhatta"),n=i(n,100," ","sata","sataa"),n>20&&(n=i(n,10,"","","kymmentä")),n>=1){let s=Math.floor(n);e.push(this.numbers[s]),n-=s}if(n>=0&&Math.abs(parseFloat(t))<1&&e.push("nolla"),n>0){let s=t.split(".");if(s.length>1){e.push(" pilkku");let o=[...s[s.length-1]];for(let l=0;l<o.length;l++)e.push(" "+this.numbers[o[l]])}}return e.join("").trim()}preProcessText(t){return t.replace(/[#_*\'\":;]/g,"").replace(this.symbolsReg,e=>" "+this.symbols[e]+" ").replace(/(\d)\,(\d)/g,"$1 pilkku $2").replace(/\d+/g,this.numberToFinnishWords.bind(this)).replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u0307\u0309\u030b-\u036f]/g,"").normalize("NFC").trim()}wordsToVisemes(t){let e={words:t,visemes:[],times:[],durations:[]},n=0;const i=[...t];for(let s=0;s<i.length;s++){const o=this.visemes[i[s].toLowerCase()];if(o)if(e.visemes.length&&e.visemes[e.visemes.length-1]===o){const l=.7*(this.visemeDurations[o]||1);e.durations[e.durations.length-1]+=l,n+=l}else{const l=this.visemeDurations[o]||1;e.visemes.push(o),e.times.push(n),e.durations.push(l),n+=l}else n+=this.specialDurations[i[s]]||0}return e}}const lt=Object.freeze(Object.defineProperty({__proto__:null,LipsyncFi:rt},Symbol.toStringTag,{value:"Module"}));class ut{constructor(){this.visemes={a:"aa",ą:"O",e:"E",ę:"E",ė:"E",i:"I",į:"I",o:"O",u:"U",ū:"U",ų:"U",y:"I",b:"PP",c:"SS",č:"SS",d:"DD",f:"FF",g:"kk",h:"kk",j:"I",k:"kk",l:"nn",m:"PP",n:"nn",p:"PP",q:"kk",r:"RR",s:"SS",š:"CH",t:"DD",v:"FF",w:"FF",x:"SS",z:"SS",ž:"SS"},this.durations={a:.95,ą:1.5,e:.9,ę:1.5,ė:1.5,i:.92,į:1.5,o:.96,u:.95,ū:1.5,ų:1.5,y:1.5,b:1.08,c:1.23,d:1.05,f:1,g:1.21,h:1.21,j:.92,k:1.21,l:.88,m:1.08,n:.88,p:1.08,q:1.21,r:.88,s:1.23,š:1.23,t:1.05,v:1,w:1,x:1.23,z:1.23,ž:1.23},this.pauses={" ":1,",":3,"-":.5},this.numbers=["nulis","vienas","du","trys","keturi","penki","šeši","septyni","aštuoni","devyni","dešimt","vienuolika","dvylika","trylika","keturiolika","penkiolika","šešiolika","septyniolika","aštuoniolika","devyniolika"],this.tens=[this.numbers[0],this.numbers[10],"dvidešimt","trisdešimt","keturiasdešimt","penkiasdešimt","šešiasdešimt","septyniasdešimt","aštuoniasdešimt","devyniasdešimt"]}numberToLithuanianWords(t){const e=[];let n=parseFloat(t);if(n===void 0)return t;let i=(s,o,l,c,r)=>{if(s<o)return s;const u=Math.floor(s/o);return u===1?e.push(this.numbers[1]):e.push(this.numberToLithuanianWords(u.toString())),u%10===1?e.push(l):u%10===0||u%100>10&&u%100<20?e.push(r):e.push(c),s-u*o};n<0&&(e.push("minus"),n=Math.abs(n)),n=i(n,1e9,"milijardas","milijardai","milijardų"),n=i(n,1e6,"milijonas","milijonai","milijonų"),n=i(n,1e3,"tūkstantis","tūkstančiai","tūkstančių"),n=i(n,100,"šimtas","šimtai","šimtų");for(let s=this.tens.length-1;s>=1;s--)if(n>=10*s){e.push(this.tens[s]),n=n-10*s;break}if(n>=1){let s=Math.floor(n);e.push(this.numbers[s]),n-=s}if(n>=0&&Math.abs(parseFloat(t))<1&&e.push(this.numbers[0]),n>0){let s=t.split(".");if(s.length>1){e.push("kablelis");let o=[...s[s.length-1]];for(let l=0;l<o.length;l++)e.push(this.numbers[o[l]])}}return e.join(" ").trim()}preProcessText(t){return t.replace(`/[#_*'":;]/g`,"").replaceAll("0 %","0 procentų ").replaceAll("1 %","1 procentas ").replaceAll("%"," procentai ").replaceAll("0 €","0 eurų ").replaceAll("1 €","1 euras ").replaceAll("€"," eurai ").replaceAll("0 $","0 dolerių ").replaceAll("1 $","1 doleris ").replaceAll("$"," doleriai ").replaceAll("&"," ir ").replaceAll("+"," pliusas ").replace(/(\d)\,(\d)/g,"$1 kablelis $2").replace(/\d+/g,this.numberToLithuanianWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u0303\u0305\u0306\u0308-\u0327\u0329-\u036f]/g,"").normalize("NFC").trim()}wordsToVisemes(t){let e={words:t,visemes:[],times:[],durations:[]},n=0;const i=[...t];for(let s=0;s<i.length;s++){const o=i[s].toLowerCase(),l=this.visemes[o];if(l)if(e.visemes.length&&e.visemes[e.visemes.length-1]===l){const c=.7*(this.durations[o]||1);e.durations[e.durations.length-1]+=c,n+=c}else{const c=this.durations[o]||1;e.visemes.push(l),e.times.push(n),e.durations.push(c),n+=c}else n+=this.pauses[i[s]]||0}return e}}const ct=Object.freeze(Object.defineProperty({__proto__:null,LipsyncLt:ut},Symbol.toStringTag,{value:"Module"})),ht=new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy5fc2FtcGxlUmF0ZSAqIHNpbGVuY2VEdXJhdGlvblNlY29uZHMpIC8gMTI4KTsKCiAgICAvLyBNZXRyaWNzIGNvbmZpZ3VyYXRpb24gdmlhIG9wdGlvbnMKICAgIGNvbnN0IG1ldHJpY3NDZmcgPSBvcHRpb25zPy5wcm9jZXNzb3JPcHRpb25zPy5tZXRyaWNzIHx8IHt9OwogICAgdGhpcy5fbWV0cmljc0VuYWJsZWQgPSBtZXRyaWNzQ2ZnLmVuYWJsZWQgIT09IGZhbHNlOwogICAgY29uc3QgaW50ZXJ2YWxIeiA9ICh0eXBlb2YgbWV0cmljc0NmZy5pbnRlcnZhbEh6ID09PSAibnVtYmVyIiAmJiBtZXRyaWNzQ2ZnLmludGVydmFsSHogPiAwKQogICAgICA/IG1ldHJpY3NDZmcuaW50ZXJ2YWxIeiA6IDI7CiAgICAvLyBNZXRyaWNzIHN0YXRlIChsb3ctb3ZlcmhlYWQpCiAgICB0aGlzLl9mcmFtZXNQcm9jZXNzZWQgPSAwOwogICAgdGhpcy5fdW5kZXJydW5CbG9ja3MgPSAwOwogICAgdGhpcy5fbWF4UXVldWVTYW1wbGVzID0gMDsKICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSAwOwogICAgLy8gQ29udmVydCB0byBmcmFtZXMgYmV0d2VlbiByZXBvcnRzCiAgICB0aGlzLl9tZXRyaWNzSW50ZXJ2YWxGcmFtZXMgPSBNYXRoLm1heCgxMjgsIE1hdGgucm91bmQodGhpcy5fc2FtcGxlUmF0ZSAvIGludGVydmFsSHopKTsKCiAgICB0aGlzLnJlc2V0KCk7CiAgfQoKICAvKioKICAgKiBSZXNldHMgdGhlIHdvcmtsZXQgdG8gaXRzIGluaXRpYWwgSURMRSBzdGF0ZS4KICAgKi8KICByZXNldCgpIHsKICAgIHRoaXMuX2J1ZmZlclF1ZXVlID0gW107CiAgICB0aGlzLl9jdXJyZW50Q2h1bmsgPSBudWxsOwogICAgdGhpcy5fY3VycmVudENodW5rT2Zmc2V0ID0gMDsKICAgIHRoaXMuX3N0YXRlID0gUGxheWJhY2tXb3JrbGV0LkZTTS5JRExFOwoKICAgIHRoaXMuX25vTW9yZURhdGFSZWNlaXZlZCA9IGZhbHNlOwogICAgdGhpcy5fc2lsZW5jZUZyYW1lc0NvdW50ID0gMDsKICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IGZhbHNlOwogICAgLy8gUmVzZXQgbWF4IHF1ZXVlIHRyYWNrZXIgb25seSB3aGVuIGdvaW5nIGlkbGUKICAgIHRoaXMuX21heFF1ZXVlU2FtcGxlcyA9IDA7CiAgfQoKICBoYW5kbGVNZXNzYWdlKGV2ZW50KSB7CiAgICBjb25zdCB7IHR5cGUsIGRhdGEgfSA9IGV2ZW50LmRhdGE7CgogICAgLy8gSU5URVJSVVBUOiBUaGUgbWFpbiB0aHJlYWQgd2FudHMgdG8gc3RvcCBpbW1lZGlhdGVseS4KICAgIGlmICh0eXBlID09PSAic3RvcCIpIHsKICAgICAgdGhpcy5yZXNldCgpOwogICAgICAvLyBTZW5kIGZpbmFsIG1ldHJpY3Mgc2hvd2luZyBjbGVhcmVkIHN0YXRlCiAgICAgIGlmICh0aGlzLl9tZXRyaWNzRW5hYmxlZCkgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICB0eXBlOiAibWV0cmljcyIsCiAgICAgICAgICAgIGRhdGE6IHsKICAgICAgICAgICAgICBzdGF0ZTogUGxheWJhY2tXb3JrbGV0LkZTTS5JRExFLAogICAgICAgICAgICAgIHF1ZXVlZFNhbXBsZXM6IDAsCiAgICAgICAgICAgICAgcXVldWVkTXM6IDAsCiAgICAgICAgICAgICAgbWF4UXVldWVkTXM6IE1hdGgucm91bmQoKHRoaXMuX21heFF1ZXVlU2FtcGxlcyAvIHRoaXMuX3NhbXBsZVJhdGUpICogMTAwMCksCiAgICAgICAgICAgICAgdW5kZXJydW5CbG9ja3M6IHRoaXMuX3VuZGVycnVuQmxvY2tzLAogICAgICAgICAgICAgIGZyYW1lc1Byb2Nlc3NlZDogdGhpcy5fZnJhbWVzUHJvY2Vzc2VkCiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgIH0gY2F0Y2ggKF8pIHsgfQogICAgICB9CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBNYWluIHRocmVhZCBoYXMgc2lnbmFsZWQgdGhhdCBubyBtb3JlIGF1ZGlvIGNodW5rcyB3aWxsIGJlIHNlbnQgZm9yIHRoaXMgdXR0ZXJhbmNlLgogICAgaWYgKHR5cGUgPT09ICJuby1tb3JlLWRhdGEiKSB7CiAgICAgIHRoaXMuX25vTW9yZURhdGFSZWNlaXZlZCA9IHRydWU7CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBVcGRhdGUgbWV0cmljcyBjb25maWd1cmF0aW9uIGF0IHJ1bnRpbWUKICAgIGlmICh0eXBlID09PSAiY29uZmlnLW1ldHJpY3MiICYmIGRhdGEgJiYgdHlwZW9mIGRhdGEgPT09ICJvYmplY3QiKSB7CiAgICAgIGlmICgiZW5hYmxlZCIgaW4gZGF0YSkgdGhpcy5fbWV0cmljc0VuYWJsZWQgPSAhIWRhdGEuZW5hYmxlZDsKICAgICAgaWYgKHR5cGVvZiBkYXRhLmludGVydmFsSHogPT09ICJudW1iZXIiICYmIGRhdGEuaW50ZXJ2YWxIeiA+IDApIHsKICAgICAgICBjb25zdCBpbnRlcnZhbEh6ID0gZGF0YS5pbnRlcnZhbEh6OwogICAgICAgIHRoaXMuX21ldHJpY3NJbnRlcnZhbEZyYW1lcyA9IE1hdGgubWF4KDEyOCwgTWF0aC5yb3VuZCh0aGlzLl9zYW1wbGVSYXRlIC8gaW50ZXJ2YWxIeikpOwogICAgICB9CiAgICAgIC8vIFJlc2V0IHBhY2luZyBzbyB0aGUgbmV4dCByZXBvcnQgYWxpZ25zIHdpdGggbmV3IGludGVydmFsCiAgICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSB0aGlzLl9mcmFtZXNQcm9jZXNzZWQ7CiAgICAgIHJldHVybjsKICAgIH0KCiAgICAvLyBOZXcgYXVkaW8gZGF0YSBoYXMgYXJyaXZlZC4KICAgIGlmICh0eXBlID09PSAiYXVkaW9EYXRhIiAmJiBkYXRhIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIpIHsKICAgICAgdGhpcy5fbm9Nb3JlRGF0YVJlY2VpdmVkID0gZmFsc2U7CiAgICAgIC8vIElmIHdlIHdlcmUgaWRsZSwgdGhpcyBuZXcgZGF0YSBraWNrcyBvZmYgdGhlIHBsYXliYWNrLgogICAgICBpZiAodGhpcy5fc3RhdGUgPT09IFBsYXliYWNrV29ya2xldC5GU00uSURMRSkgewogICAgICAgIHRoaXMuX3N0YXRlID0gUGxheWJhY2tXb3JrbGV0LkZTTS5QTEFZSU5HOwogICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7IHR5cGU6ICJwbGF5YmFjay1zdGFydGVkIiB9KTsKICAgICAgfQoKICAgICAgLy8gV2Ugb25seSBxdWV1ZSBkYXRhIGlmIHdlIGFyZSBpbiB0aGUgUExBWUlORyBzdGF0ZS4gVGhpcyBwcmV2ZW50cwogICAgICAvLyBkYXRhIGZyb20gYSBwcmV2aW91cywgaW50ZXJydXB0ZWQgc3RyZWFtIGZyb20gbGluZ2VyaW5nLgogICAgICBpZiAodGhpcy5fc3RhdGUgPT09IFBsYXliYWNrV29ya2xldC5GU00uUExBWUlORykgewogICAgICAgIC8vIFN0b3JlIGFzIEludDE2QXJyYXkgdmlldyB0byBhdm9pZCBjb25zdHJ1Y3RpbmcgaXQgaW4gcHJvY2VzcygpCiAgICAgICAgdGhpcy5fYnVmZmVyUXVldWUucHVzaChuZXcgSW50MTZBcnJheShkYXRhKSk7CiAgICAgICAgdGhpcy5fc2lsZW5jZUZyYW1lc0NvdW50ID0gMDsgLy8gUmVzZXQgc2lsZW5jZSBjb3VudGVyIG9uIG5ldyBkYXRhCiAgICAgIH0KICAgIH0KICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBvdXRwdXRDaGFubmVsID0gb3V0cHV0c1swXT8uWzBdOwogICAgaWYgKCFvdXRwdXRDaGFubmVsKSB7CiAgICAgIHJldHVybiB0cnVlOyAvLyBLZWVwIGFsaXZlIGV2ZW4gaWYgb3V0cHV0IGlzIHRlbXBvcmFyaWx5IGRpc2Nvbm5lY3RlZAogICAgfQoKICAgIC8vIElmIHdlIGFyZSBub3QgcGxheWluZywganVzdCBvdXRwdXQgc2lsZW5jZSBhbmQgd2FpdC4KICAgIGlmICh0aGlzLl9zdGF0ZSAhPT0gUGxheWJhY2tXb3JrbGV0LkZTTS5QTEFZSU5HKSB7CiAgICAgIG91dHB1dENoYW5uZWwuZmlsbCgwKTsKICAgICAgcmV0dXJuIHRydWU7IC8vIEFsd2F5cyByZXR1cm4gdHJ1ZSB0byBrZWVwIHRoZSBwcm9jZXNzb3IgYWxpdmUKICAgIH0KCiAgICAvLyBDb3JlIFBMQVlJTkcgTG9naWMKICAgIGNvbnN0IGJsb2NrU2l6ZSA9IG91dHB1dENoYW5uZWwubGVuZ3RoOwogICAgbGV0IHNhbXBsZXNDb3BpZWQgPSAwOwoKICAgIHdoaWxlIChzYW1wbGVzQ29waWVkIDwgYmxvY2tTaXplKSB7CiAgICAgIGlmICghdGhpcy5fY3VycmVudENodW5rIHx8IHRoaXMuX2N1cnJlbnRDaHVua09mZnNldCA+PSB0aGlzLl9jdXJyZW50Q2h1bmsubGVuZ3RoKSB7CiAgICAgICAgaWYgKHRoaXMuX2J1ZmZlclF1ZXVlLmxlbmd0aCA+IDApIHsKICAgICAgICAgIHRoaXMuX2N1cnJlbnRDaHVuayA9IHRoaXMuX2J1ZmZlclF1ZXVlLnNoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3ZlKSwgcHJvY2VzcyBpdC4KICAgICAgaWYgKHRoaXMuX2N1cnJlbnRDaHVuaykgewogICAgICAgIGNvbnN0IHNhbXBsZXNUb0NvcHkgPSBNYXRoLm1pbigKICAgICAgICAgIGJsb2NrU2l6ZSAtIHNhbXBsZXNDb3BpZWQsCiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmsubGVuZ3RoIC0gdGhpcy5fY3VycmVudENodW5rT2Zmc2V0CiAgICAgICAgKTsKICAgICAgICAvLyBEaXJlY3RseSB3cml0ZSB0byBvdXRwdXRDaGFubmVsIHRvIGF2b2lkIGV4dHJhIGNvcHkKICAgICAgICBjb25zdCBzcmMgPSB0aGlzLl9jdXJyZW50Q2h1bms7CiAgICAgICAgY29uc3QgYmFzZVNyYyA9IHRoaXMuX2N1cnJlbnRDaHVua09mZnNldDsKICAgICAgICBjb25zdCBiYXNlRHN0ID0gc2FtcGxlc0NvcGllZDsKICAgICAgICBjb25zdCBzY2FsZSA9IHRoaXMuX3NjYWxlOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2FtcGxlc1RvQ29weTsgaSsrKSB7CiAgICAgICAgICBvdXRwdXRDaGFubmVsW2Jhc2VEc3QgKyBpXSA9IHNyY1tiYXNlU3JjICsgaV0gKiBzY2FsZTsKICAgICAgICB9CgogICAgICAgIHRoaXMuX2N1cnJlbnRDaHVua09mZnNldCArPSBzYW1wbGVzVG9Db3B5OwogICAgICAgIHNhbXBsZXNDb3BpZWQgKz0gc2FtcGxlc1RvQ29weTsKICAgICAgfQogICAgfQoKICAgIC8vIFplcm8tZmlsbCB0aGUgcmVtYWluZGVyLCBpZiBhbnksIG9uY2UgcGVyIGJsb2NrCiAgICBpZiAoc2FtcGxlc0NvcGllZCA8IGJsb2NrU2l6ZSkgewogICAgICBvdXRwdXRDaGFubmVsLmZpbGwoMCwgc2FtcGxlc0NvcGllZCk7CiAgICB9CgogICAgLy8gVXBkYXRlIG1ldHJpY3MgKG9wdGlvbmFsKQogICAgaWYgKHRoaXMuX21ldHJpY3NFbmFibGVkKSB7CiAgICAgIHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZCArPSBibG9ja1NpemU7CgogICAgICAvLyBUcmFjayBxdWV1ZSBkZXB0aCBpbiBzYW1wbGVzIChhcHByb3hpbWF0ZSkKICAgICAgbGV0IHF1ZXVlZFNhbXBsZXMgPSAwOwogICAgICBpZiAodGhpcy5fY3VycmVudENodW5rKSBxdWV1ZWRTYW1wbGVzICs9IE1hdGgubWF4KDAsIHRoaXMuX2N1cnJlbnRDaHVuay5sZW5ndGggLSB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQpOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuX2J1ZmZlclF1ZXVlLmxlbmd0aDsgaSsrKSBxdWV1ZWRTYW1wbGVzICs9IHRoaXMuX2J1ZmZlclF1ZXVlW2ldLmxlbmd0aDsKICAgICAgaWYgKHF1ZXVlZFNhbXBsZXMgPiB0aGlzLl9tYXhRdWV1ZVNhbXBsZXMpIHRoaXMuX21heFF1ZXVlU2FtcGxlcyA9IHF1ZXVlZFNhbXBsZXM7CgogICAgICAvLyBQZXJpb2RpY2FsbHkgc2VuZCBtZXRyaWNzIHRvIG1haW4gdGhyZWFkCiAgICAgIGlmICh0aGlzLl9mcmFtZXNQcm9jZXNzZWQgLSB0aGlzLl9sYXN0TWV0cmljc1NlbnRBdEZyYW1lID49IHRoaXMuX21ldHJpY3NJbnRlcnZhbEZyYW1lcykgewogICAgICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSB0aGlzLl9mcmFtZXNQcm9jZXNzZWQ7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHR5cGU6ICJtZXRyaWNzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=",typeof document>"u"?require("url").pathToFileURL(__filename).href:He&&He.tagName.toUpperCase()==="SCRIPT"&&He.src||new URL("index.cjs",document.baseURI).href),Oe={en:nt,de:ot,fr:at,fi:lt,lt:ct},J=new y.Quaternion,G=new y.Euler,fe=new y.Vector3,xe=new y.Vector3,De=new y.Box3;new y.Matrix4;new y.Matrix4;new y.Vector3;new y.Vector3(0,0,1);const dt=new y.Vector3(1,0,0);new y.Vector3(0,1,0);new y.Vector3(0,0,1);class Te{constructor(t,e=null){this.nodeAvatar=t,this.opt={jwtGet:null,ttsEndpoint:"",ttsApikey:null,ttsTrimStart:0,ttsTrimEnd:400,ttsLang:"fi-FI",ttsVoice:"fi-FI-Standard-A",ttsRate:1,ttsPitch:0,ttsVolume:.3,mixerGainSpeech:1.2,mixerGainBackground:null,lipsyncLang:"fi",lipsyncModules:["fi","en","lt"],pcmSampleRate:22050,modelRoot:"Armature",modelPixelRatio:1,modelFPS:30,modelMovementFactor:1,cameraView:"full",dracoEnabled:!1,dracoDecoderPath:"https://www.gstatic.com/draco/v1/decoders/",cameraDistance:0,cameraX:0,cameraY:0,cameraRotateX:0,cameraRotateY:0,cameraRotateEnable:!0,cameraPanEnable:!1,cameraZoomEnable:!1,lightAmbientColor:16777215,lightAmbientIntensity:1.25,lightDirectColor:8947882,lightDirectIntensity:12,lightDirectPhi:1,lightDirectTheta:2,lightSpotIntensity:0,lightSpotColor:3377407,lightSpotPhi:.1,lightSpotTheta:4,lightSpotDispersion:1,avatarMood:"neutral",avatarMute:!1,avatarIdleEyeContact:.6,avatarIdleHeadMove:.5,avatarSpeakingEyeContact:.8,avatarSpeakingHeadMove:.5,avatarIgnoreCamera:!1,listeningSilenceThresholdLevel:40,listeningSilenceThresholdMs:2e3,listeningSilenceDurationMax:1e4,listeningActiveThresholdLevel:75,listeningActiveThresholdMs:300,listeningActiveDurationMax:24e4,update:null,avatarOnly:!1,avatarOnlyScene:null,avatarOnlyCamera:null,statsNode:null,statsStyle:null},Object.assign(this.opt,e||{}),this.opt.statsNode&&(this.stats=new Qe,this.opt.statsStyle&&(this.stats.dom.style.cssText=this.opt.statsStyle),this.opt.statsNode.appendChild(this.stats.dom)),this.poseTemplates={side:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.003,y:-.017,z:.1},"Spine.rotation":{x:-.103,y:-.002,z:-.063},"Spine1.rotation":{x:.042,y:-.02,z:-.069},"Spine2.rotation":{x:.131,y:-.012,z:-.065},"Neck.rotation":{x:.027,y:.006,z:0},"Head.rotation":{x:.077,y:-.065,z:0},"LeftShoulder.rotation":{x:1.599,y:.084,z:-1.77},"LeftArm.rotation":{x:1.364,y:.052,z:-.044},"LeftForeArm.rotation":{x:.002,y:-.007,z:.331},"LeftHand.rotation":{x:.104,y:-.067,z:-.174},"LeftHandThumb1.rotation":{x:.231,y:.258,z:.355},"LeftHandThumb2.rotation":{x:-.106,y:-.339,z:-.454},"LeftHandThumb3.rotation":{x:-.02,y:-.142,z:-.004},"LeftHandIndex1.rotation":{x:.148,y:.032,z:-.069},"LeftHandIndex2.rotation":{x:.326,y:-.049,z:-.029},"LeftHandIndex3.rotation":{x:.247,y:-.053,z:-.073},"LeftHandMiddle1.rotation":{x:.238,y:-.057,z:-.089},"LeftHandMiddle2.rotation":{x:.469,y:-.036,z:-.081},"LeftHandMiddle3.rotation":{x:.206,y:-.015,z:-.017},"LeftHandRing1.rotation":{x:.187,y:-.118,z:-.157},"LeftHandRing2.rotation":{x:.579,y:.02,z:-.097},"LeftHandRing3.rotation":{x:.272,y:.021,z:-.063},"LeftHandPinky1.rotation":{x:.405,y:-.182,z:-.138},"LeftHandPinky2.rotation":{x:.613,y:.128,z:-.144},"LeftHandPinky3.rotation":{x:.268,y:.094,z:-.081},"RightShoulder.rotation":{x:1.541,y:.192,z:1.775},"RightArm.rotation":{x:1.273,y:-.352,z:-.067},"RightForeArm.rotation":{x:-.011,y:-.031,z:-.357},"RightHand.rotation":{x:-.008,y:.312,z:-.028},"RightHandThumb1.rotation":{x:.23,y:-.258,z:-.355},"RightHandThumb2.rotation":{x:-.107,y:.339,z:.454},"RightHandThumb3.rotation":{x:-.02,y:.142,z:.004},"RightHandIndex1.rotation":{x:.148,y:-.031,z:.069},"RightHandIndex2.rotation":{x:.326,y:.049,z:.029},"RightHandIndex3.rotation":{x:.247,y:.053,z:.073},"RightHandMiddle1.rotation":{x:.237,y:.057,z:.089},"RightHandMiddle2.rotation":{x:.469,y:.036,z:.081},"RightHandMiddle3.rotation":{x:.206,y:.015,z:.017},"RightHandRing1.rotation":{x:.204,y:.086,z:.135},"RightHandRing2.rotation":{x:.579,y:-.02,z:.098},"RightHandRing3.rotation":{x:.272,y:-.021,z:.063},"RightHandPinky1.rotation":{x:.404,y:.182,z:.137},"RightHandPinky2.rotation":{x:.613,y:-.128,z:.144},"RightHandPinky3.rotation":{x:.268,y:-.094,z:.081},"LeftUpLeg.rotation":{x:.096,y:.209,z:2.983},"LeftLeg.rotation":{x:-.053,y:.042,z:-.017},"LeftFoot.rotation":{x:1.091,y:.15,z:.026},"LeftToeBase.rotation":{x:.469,y:-.07,z:-.015},"RightUpLeg.rotation":{x:-.307,y:-.219,z:2.912},"RightLeg.rotation":{x:-.359,y:.164,z:.015},"RightFoot.rotation":{x:1.035,y:.11,z:.005},"RightToeBase.rotation":{x:.467,y:.07,z:.015}}},hip:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.036,y:.09,z:.135},"Spine.rotation":{x:.076,y:-.035,z:.01},"Spine1.rotation":{x:-.096,y:.013,z:-.094},"Spine2.rotation":{x:-.014,y:.002,z:-.097},"Neck.rotation":{x:.034,y:-.051,z:-.075},"Head.rotation":{x:.298,y:-.1,z:.154},"LeftShoulder.rotation":{x:1.694,y:.011,z:-1.68},"LeftArm.rotation":{x:1.343,y:.177,z:-.153},"LeftForeArm.rotation":{x:-.049,y:.134,z:.351},"LeftHand.rotation":{x:.057,y:-.189,z:-.026},"LeftHandThumb1.rotation":{x:.368,y:-.066,z:.438},"LeftHandThumb2.rotation":{x:-.156,y:.029,z:-.369},"LeftHandThumb3.rotation":{x:.034,y:-.009,z:.016},"LeftHandIndex1.rotation":{x:.157,y:-.002,z:-.171},"LeftHandIndex2.rotation":{x:.099,y:0,z:0},"LeftHandIndex3.rotation":{x:.1,y:0,z:0},"LeftHandMiddle1.rotation":{x:.222,y:-.019,z:-.16},"LeftHandMiddle2.rotation":{x:.142,y:0,z:0},"LeftHandMiddle3.rotation":{x:.141,y:0,z:0},"LeftHandRing1.rotation":{x:.333,y:-.039,z:-.174},"LeftHandRing2.rotation":{x:.214,y:0,z:0},"LeftHandRing3.rotation":{x:.213,y:0,z:0},"LeftHandPinky1.rotation":{x:.483,y:-.069,z:-.189},"LeftHandPinky2.rotation":{x:.312,y:0,z:0},"LeftHandPinky3.rotation":{x:.309,y:0,z:0},"RightShoulder.rotation":{x:1.597,y:.012,z:1.816},"RightArm.rotation":{x:.618,y:-1.274,z:-.266},"RightForeArm.rotation":{x:-.395,y:-.097,z:-1.342},"RightHand.rotation":{x:-.816,y:-.057,z:-.976},"RightHandThumb1.rotation":{x:.42,y:.23,z:-1.172},"RightHandThumb2.rotation":{x:-.027,y:.361,z:.122},"RightHandThumb3.rotation":{x:.076,y:.125,z:-.371},"RightHandIndex1.rotation":{x:-.158,y:-.045,z:.033},"RightHandIndex2.rotation":{x:.391,y:.051,z:.025},"RightHandIndex3.rotation":{x:.317,y:.058,z:.07},"RightHandMiddle1.rotation":{x:.486,y:.066,z:.014},"RightHandMiddle2.rotation":{x:.718,y:.055,z:.07},"RightHandMiddle3.rotation":{x:.453,y:.019,z:.013},"RightHandRing1.rotation":{x:.591,y:.241,z:.11},"RightHandRing2.rotation":{x:1.014,y:.023,z:.097},"RightHandRing3.rotation":{x:.708,y:.008,z:.066},"RightHandPinky1.rotation":{x:1.02,y:.305,z:.051},"RightHandPinky2.rotation":{x:1.187,y:-.028,z:.191},"RightHandPinky3.rotation":{x:.872,y:-.031,z:.121},"LeftUpLeg.rotation":{x:-.095,y:-.058,z:-3.338},"LeftLeg.rotation":{x:-.366,y:.287,z:-.021},"LeftFoot.rotation":{x:1.131,y:.21,z:.176},"LeftToeBase.rotation":{x:.739,y:-.068,z:-.001},"RightUpLeg.rotation":{x:-.502,y:.362,z:3.153},"RightLeg.rotation":{x:-1.002,y:.109,z:.008},"RightFoot.rotation":{x:.626,y:-.097,z:-.194},"RightToeBase.rotation":{x:1.33,y:.288,z:-.078}}},turn:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.07,y:-.604,z:-.004},"Spine.rotation":{x:-.007,y:.003,z:.071},"Spine1.rotation":{x:-.053,y:.024,z:-.06},"Spine2.rotation":{x:.074,y:.013,z:-.068},"Neck.rotation":{x:.03,y:.186,z:-.077},"Head.rotation":{x:.045,y:.243,z:-.086},"LeftShoulder.rotation":{x:1.717,y:-.085,z:-1.761},"LeftArm.rotation":{x:1.314,y:.07,z:-.057},"LeftForeArm.rotation":{x:-.151,y:.714,z:.302},"LeftHand.rotation":{x:-.069,y:.003,z:-.118},"LeftHandThumb1.rotation":{x:.23,y:.258,z:.354},"LeftHandThumb2.rotation":{x:-.107,y:-.338,z:-.455},"LeftHandThumb3.rotation":{x:-.015,y:-.142,z:.002},"LeftHandIndex1.rotation":{x:.145,y:.032,z:-.069},"LeftHandIndex2.rotation":{x:.323,y:-.049,z:-.028},"LeftHandIndex3.rotation":{x:.249,y:-.053,z:-.074},"LeftHandMiddle1.rotation":{x:.235,y:-.057,z:-.088},"LeftHandMiddle2.rotation":{x:.468,y:-.036,z:-.081},"LeftHandMiddle3.rotation":{x:.203,y:-.015,z:-.017},"LeftHandRing1.rotation":{x:.185,y:-.118,z:-.157},"LeftHandRing2.rotation":{x:.578,y:.02,z:-.097},"LeftHandRing3.rotation":{x:.27,y:.021,z:-.063},"LeftHandPinky1.rotation":{x:.404,y:-.182,z:-.138},"LeftHandPinky2.rotation":{x:.612,y:.128,z:-.144},"LeftHandPinky3.rotation":{x:.267,y:.094,z:-.081},"RightShoulder.rotation":{x:1.605,y:.17,z:1.625},"RightArm.rotation":{x:1.574,y:-.655,z:.388},"RightForeArm.rotation":{x:-.36,y:-.849,z:-.465},"RightHand.rotation":{x:.114,y:.416,z:-.069},"RightHandThumb1.rotation":{x:.486,y:.009,z:-.492},"RightHandThumb2.rotation":{x:-.073,y:-.01,z:.284},"RightHandThumb3.rotation":{x:-.054,y:-.006,z:.209},"RightHandIndex1.rotation":{x:.245,y:-.014,z:.052},"RightHandIndex2.rotation":{x:.155,y:0,z:0},"RightHandIndex3.rotation":{x:.153,y:0,z:0},"RightHandMiddle1.rotation":{x:.238,y:.004,z:.028},"RightHandMiddle2.rotation":{x:.15,y:0,z:0},"RightHandMiddle3.rotation":{x:.149,y:0,z:0},"RightHandRing1.rotation":{x:.267,y:.012,z:.007},"RightHandRing2.rotation":{x:.169,y:0,z:0},"RightHandRing3.rotation":{x:.167,y:0,z:0},"RightHandPinky1.rotation":{x:.304,y:.018,z:-.021},"RightHandPinky2.rotation":{x:.192,y:0,z:0},"RightHandPinky3.rotation":{x:.19,y:0,z:0},"LeftUpLeg.rotation":{x:-.001,y:-.058,z:-3.238},"LeftLeg.rotation":{x:-.29,y:.058,z:-.021},"LeftFoot.rotation":{x:1.288,y:.168,z:.183},"LeftToeBase.rotation":{x:.363,y:-.09,z:-.01},"RightUpLeg.rotation":{x:-.1,y:.36,z:3.062},"RightLeg.rotation":{x:-.67,y:-.304,z:.043},"RightFoot.rotation":{x:1.195,y:-.159,z:-.294},"RightToeBase.rotation":{x:.737,y:.164,z:-.002}}},bend:{bend:!0,standing:!0,props:{"Hips.position":{x:-.007,y:.943,z:-.001},"Hips.rotation":{x:1.488,y:-.633,z:1.435},"Spine.rotation":{x:-.126,y:.007,z:-.057},"Spine1.rotation":{x:-.134,y:.009,z:.01},"Spine2.rotation":{x:-.019,y:0,z:-.002},"Neck.rotation":{x:-.159,y:.572,z:-.108},"Head.rotation":{x:-.064,y:.716,z:-.257},"RightShoulder.rotation":{x:1.625,y:-.043,z:1.382},"RightArm.rotation":{x:.746,y:-.96,z:-1.009},"RightForeArm.rotation":{x:-.199,y:-.528,z:-.38},"RightHand.rotation":{x:-.261,y:-.043,z:-.027},"RightHandThumb1.rotation":{x:.172,y:-.138,z:-.445},"RightHandThumb2.rotation":{x:-.158,y:.327,z:.545},"RightHandThumb3.rotation":{x:-.062,y:.138,z:.152},"RightHandIndex1.rotation":{x:.328,y:-.005,z:.132},"RightHandIndex2.rotation":{x:.303,y:.049,z:.028},"RightHandIndex3.rotation":{x:.241,y:.046,z:.077},"RightHandMiddle1.rotation":{x:.309,y:.074,z:.089},"RightHandMiddle2.rotation":{x:.392,y:.036,z:.081},"RightHandMiddle3.rotation":{x:.199,y:.014,z:.019},"RightHandRing1.rotation":{x:.239,y:.143,z:.091},"RightHandRing2.rotation":{x:.275,y:-.02,z:.097},"RightHandRing3.rotation":{x:.248,y:-.023,z:.061},"RightHandPinky1.rotation":{x:.211,y:.154,z:.029},"RightHandPinky2.rotation":{x:.348,y:-.128,z:.144},"RightHandPinky3.rotation":{x:.21,y:-.091,z:.065},"LeftShoulder.rotation":{x:1.626,y:-.027,z:-1.367},"LeftArm.rotation":{x:1.048,y:.737,z:.712},"LeftForeArm.rotation":{x:-.508,y:.879,z:.625},"LeftHand.rotation":{x:.06,y:-.243,z:-.079},"LeftHandThumb1.rotation":{x:.187,y:-.072,z:.346},"LeftHandThumb2.rotation":{x:-.066,y:.008,z:-.256},"LeftHandThumb3.rotation":{x:-.085,y:.014,z:-.334},"LeftHandIndex1.rotation":{x:-.1,y:.016,z:-.058},"LeftHandIndex2.rotation":{x:.334,y:0,z:0},"LeftHandIndex3.rotation":{x:.281,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.056,y:0,z:0},"LeftHandMiddle2.rotation":{x:.258,y:0,z:0},"LeftHandMiddle3.rotation":{x:.26,y:0,z:0},"LeftHandRing1.rotation":{x:-.067,y:-.002,z:.008},"LeftHandRing2.rotation":{x:.259,y:0,z:0},"LeftHandRing3.rotation":{x:.276,y:0,z:0},"LeftHandPinky1.rotation":{x:-.128,y:-.007,z:.042},"LeftHandPinky2.rotation":{x:.227,y:0,z:0},"LeftHandPinky3.rotation":{x:.145,y:0,z:0},"RightUpLeg.rotation":{x:-1.507,y:.2,z:-3.043},"RightLeg.rotation":{x:-.689,y:-.124,z:.017},"RightFoot.rotation":{x:.909,y:.008,z:-.093},"RightToeBase.rotation":{x:.842,y:.075,z:-.008},"LeftUpLeg.rotation":{x:-1.449,y:-.2,z:3.018},"LeftLeg.rotation":{x:-.74,y:-.115,z:-.008},"LeftFoot.rotation":{x:1.048,y:-.058,z:.117},"LeftToeBase.rotation":{x:.807,y:-.067,z:.003}}},back:{standing:!0,props:{"Hips.position":{x:0,y:1,z:0},"Hips.rotation":{x:-.732,y:-1.463,z:-.637},"Spine.rotation":{x:-.171,y:.106,z:.157},"Spine1.rotation":{x:-.044,y:.138,z:-.059},"Spine2.rotation":{x:.082,y:.133,z:-.074},"Neck.rotation":{x:.39,y:.591,z:-.248},"Head.rotation":{x:-.001,y:.596,z:-.057},"LeftShoulder.rotation":{x:1.676,y:.007,z:-1.892},"LeftArm.rotation":{x:-5.566,y:1.188,z:-.173},"LeftForeArm.rotation":{x:-.673,y:-.105,z:1.702},"LeftHand.rotation":{x:-.469,y:-.739,z:.003},"LeftHandThumb1.rotation":{x:.876,y:.274,z:.793},"LeftHandThumb2.rotation":{x:.161,y:-.23,z:-.172},"LeftHandThumb3.rotation":{x:.078,y:.027,z:.156},"LeftHandIndex1.rotation":{x:-.085,y:-.002,z:.009},"LeftHandIndex2.rotation":{x:.176,y:0,z:-.002},"LeftHandIndex3.rotation":{x:-.036,y:.001,z:-.035},"LeftHandMiddle1.rotation":{x:.015,y:.144,z:-.076},"LeftHandMiddle2.rotation":{x:.378,y:-.007,z:-.077},"LeftHandMiddle3.rotation":{x:-.141,y:-.001,z:.031},"LeftHandRing1.rotation":{x:.039,y:.02,z:-.2},"LeftHandRing2.rotation":{x:.25,y:-.002,z:-.073},"LeftHandRing3.rotation":{x:.236,y:.006,z:-.075},"LeftHandPinky1.rotation":{x:.172,y:-.033,z:-.275},"LeftHandPinky2.rotation":{x:.216,y:.043,z:-.054},"LeftHandPinky3.rotation":{x:.325,y:.078,z:-.13},"RightShoulder.rotation":{x:2.015,y:-.168,z:1.706},"RightArm.rotation":{x:.203,y:-1.258,z:-.782},"RightForeArm.rotation":{x:-.658,y:-.133,z:-1.401},"RightHand.rotation":{x:-1.504,y:.375,z:-.005},"RightHandThumb1.rotation":{x:.413,y:-.158,z:-1.121},"RightHandThumb2.rotation":{x:-.142,y:-.008,z:.209},"RightHandThumb3.rotation":{x:-.091,y:.021,z:.142},"RightHandIndex1.rotation":{x:-.167,y:.014,z:-.072},"RightHandIndex2.rotation":{x:.474,y:.009,z:.051},"RightHandIndex3.rotation":{x:.115,y:.006,z:.047},"RightHandMiddle1.rotation":{x:.385,y:.019,z:.144},"RightHandMiddle2.rotation":{x:.559,y:.035,z:.101},"RightHandMiddle3.rotation":{x:.229,y:0,z:.027},"RightHandRing1.rotation":{x:.48,y:.026,z:.23},"RightHandRing2.rotation":{x:.772,y:.038,z:.109},"RightHandRing3.rotation":{x:.622,y:.039,z:.106},"RightHandPinky1.rotation":{x:.767,y:.288,z:.353},"RightHandPinky2.rotation":{x:.886,y:.049,z:.122},"RightHandPinky3.rotation":{x:.662,y:.044,z:.113},"LeftUpLeg.rotation":{x:-.206,y:-.268,z:-3.343},"LeftLeg.rotation":{x:-.333,y:.757,z:-.043},"LeftFoot.rotation":{x:1.049,y:.167,z:.287},"LeftToeBase.rotation":{x:.672,y:-.069,z:-.004},"RightUpLeg.rotation":{x:.055,y:-.226,z:3.037},"RightLeg.rotation":{x:-.559,y:.39,z:-.001},"RightFoot.rotation":{x:1.2,y:.133,z:.085},"RightToeBase.rotation":{x:.92,y:.093,z:-.013}}},straight:{standing:!0,props:{"Hips.position":{x:0,y:.989,z:.001},"Hips.rotation":{x:.047,y:.007,z:-.007},"Spine.rotation":{x:-.143,y:-.007,z:.005},"Spine1.rotation":{x:-.043,y:-.014,z:.012},"Spine2.rotation":{x:.072,y:-.013,z:.013},"Neck.rotation":{x:.048,y:-.003,z:.012},"Head.rotation":{x:.05,y:-.02,z:-.017},"LeftShoulder.rotation":{x:1.62,y:-.166,z:-1.605},"LeftArm.rotation":{x:1.275,y:.544,z:-.092},"LeftForeArm.rotation":{x:0,y:0,z:.302},"LeftHand.rotation":{x:-.225,y:-.154,z:.11},"LeftHandThumb1.rotation":{x:.435,y:-.044,z:.457},"LeftHandThumb2.rotation":{x:-.028,y:.002,z:-.246},"LeftHandThumb3.rotation":{x:-.236,y:-.025,z:.113},"LeftHandIndex1.rotation":{x:.218,y:.008,z:-.081},"LeftHandIndex2.rotation":{x:.165,y:-.001,z:-.017},"LeftHandIndex3.rotation":{x:.165,y:-.001,z:-.017},"LeftHandMiddle1.rotation":{x:.235,y:-.011,z:-.065},"LeftHandMiddle2.rotation":{x:.182,y:-.002,z:-.019},"LeftHandMiddle3.rotation":{x:.182,y:-.002,z:-.019},"LeftHandRing1.rotation":{x:.316,y:-.017,z:.008},"LeftHandRing2.rotation":{x:.253,y:-.003,z:-.026},"LeftHandRing3.rotation":{x:.255,y:-.003,z:-.026},"LeftHandPinky1.rotation":{x:.336,y:-.062,z:.088},"LeftHandPinky2.rotation":{x:.276,y:-.004,z:-.028},"LeftHandPinky3.rotation":{x:.276,y:-.004,z:-.028},"RightShoulder.rotation":{x:1.615,y:.064,z:1.53},"RightArm.rotation":{x:1.313,y:-.424,z:.131},"RightForeArm.rotation":{x:0,y:0,z:-.317},"RightHand.rotation":{x:-.158,y:-.639,z:-.196},"RightHandThumb1.rotation":{x:.44,y:.048,z:-.549},"RightHandThumb2.rotation":{x:-.056,y:-.008,z:.274},"RightHandThumb3.rotation":{x:-.258,y:.031,z:-.095},"RightHandIndex1.rotation":{x:.169,y:-.011,z:.105},"RightHandIndex2.rotation":{x:.134,y:.001,z:.011},"RightHandIndex3.rotation":{x:.134,y:.001,z:.011},"RightHandMiddle1.rotation":{x:.288,y:.014,z:.092},"RightHandMiddle2.rotation":{x:.248,y:.003,z:.02},"RightHandMiddle3.rotation":{x:.249,y:.003,z:.02},"RightHandRing1.rotation":{x:.369,y:.019,z:.006},"RightHandRing2.rotation":{x:.321,y:.004,z:.026},"RightHandRing3.rotation":{x:.323,y:.004,z:.026},"RightHandPinky1.rotation":{x:.468,y:.085,z:-.03},"RightHandPinky2.rotation":{x:.427,y:.007,z:.034},"RightHandPinky3.rotation":{x:.142,y:.001,z:.012},"LeftUpLeg.rotation":{x:-.077,y:-.058,z:3.126},"LeftLeg.rotation":{x:-.252,y:.001,z:-.018},"LeftFoot.rotation":{x:1.315,y:-.064,z:.315},"LeftToeBase.rotation":{x:.577,y:-.07,z:-.009},"RightUpLeg.rotation":{x:-.083,y:-.032,z:3.124},"RightLeg.rotation":{x:-.272,y:-.003,z:.021},"RightFoot.rotation":{x:1.342,y:.076,z:-.222},"RightToeBase.rotation":{x:.44,y:.069,z:.016}}},wide:{standing:!0,props:{"Hips.position":{x:0,y:1.017,z:.016},"Hips.rotation":{x:.064,y:-.048,z:.059},"Spine.rotation":{x:-.123,y:0,z:-.018},"Spine1.rotation":{x:.014,y:.003,z:-.006},"Spine2.rotation":{x:.04,y:.003,z:-.007},"Neck.rotation":{x:.101,y:.007,z:-.035},"Head.rotation":{x:-.091,y:-.049,z:.105},"RightShoulder.rotation":{x:1.831,y:.017,z:1.731},"RightArm.rotation":{x:-1.673,y:-1.102,z:-3.132},"RightForeArm.rotation":{x:.265,y:.23,z:-.824},"RightHand.rotation":{x:-.52,y:.345,z:-.061},"RightHandThumb1.rotation":{x:.291,y:.056,z:-.428},"RightHandThumb2.rotation":{x:.025,y:.005,z:.166},"RightHandThumb3.rotation":{x:-.089,y:.009,z:.068},"RightHandIndex1.rotation":{x:.392,y:-.015,z:.11},"RightHandIndex2.rotation":{x:.391,y:.001,z:.004},"RightHandIndex3.rotation":{x:.326,y:0,z:.003},"RightHandMiddle1.rotation":{x:.285,y:.068,z:.081},"RightHandMiddle2.rotation":{x:.519,y:.004,z:.011},"RightHandMiddle3.rotation":{x:.252,y:0,z:.001},"RightHandRing1.rotation":{x:.207,y:.133,z:.146},"RightHandRing2.rotation":{x:.597,y:.004,z:.004},"RightHandRing3.rotation":{x:.292,y:.002,z:.012},"RightHandPinky1.rotation":{x:.338,y:.182,z:.136},"RightHandPinky2.rotation":{x:.533,y:.002,z:.004},"RightHandPinky3.rotation":{x:.194,y:0,z:.002},"LeftShoulder.rotation":{x:1.83,y:-.063,z:-1.808},"LeftArm.rotation":{x:-1.907,y:1.228,z:-2.959},"LeftForeArm.rotation":{x:-.159,y:.268,z:.572},"LeftHand.rotation":{x:.069,y:-.498,z:-.025},"LeftHandThumb1.rotation":{x:.738,y:.123,z:.178},"LeftHandThumb2.rotation":{x:-.26,y:.028,z:-.477},"LeftHandThumb3.rotation":{x:-.448,y:.093,z:-.661},"LeftHandIndex1.rotation":{x:1.064,y:.005,z:-.13},"LeftHandIndex2.rotation":{x:1.55,y:-.143,z:-.136},"LeftHandIndex3.rotation":{x:.722,y:-.076,z:-.127},"LeftHandMiddle1.rotation":{x:1.095,y:-.091,z:.006},"LeftHandMiddle2.rotation":{x:1.493,y:-.174,z:-.151},"LeftHandMiddle3.rotation":{x:.651,y:-.031,z:-.087},"LeftHandRing1.rotation":{x:1.083,y:-.224,z:.072},"LeftHandRing2.rotation":{x:1.145,y:-.107,z:-.195},"LeftHandRing3.rotation":{x:1.208,y:-.134,z:-.158},"LeftHandPinky1.rotation":{x:.964,y:-.383,z:.128},"LeftHandPinky2.rotation":{x:1.457,y:-.146,z:-.159},"LeftHandPinky3.rotation":{x:1.019,y:-.102,z:-.141},"RightUpLeg.rotation":{x:-.221,y:-.233,z:2.87},"RightLeg.rotation":{x:-.339,y:-.043,z:-.041},"RightFoot.rotation":{x:1.081,y:.177,z:.114},"RightToeBase.rotation":{x:.775,y:0,z:0},"LeftUpLeg.rotation":{x:-.185,y:.184,z:3.131},"LeftLeg.rotation":{x:-.408,y:.129,z:.02},"LeftFoot.rotation":{x:1.167,y:-.002,z:-.007},"LeftToeBase.rotation":{x:.723,y:0,z:0}}},oneknee:{kneeling:!0,props:{"Hips.position":{x:-.005,y:.415,z:-.017},"Hips.rotation":{x:-.25,y:.04,z:-.238},"Spine.rotation":{x:.037,y:.043,z:.047},"Spine1.rotation":{x:.317,y:.103,z:.066},"Spine2.rotation":{x:.433,y:.109,z:.054},"Neck.rotation":{x:-.156,y:-.092,z:.059},"Head.rotation":{x:-.398,y:-.032,z:.018},"RightShoulder.rotation":{x:1.546,y:.119,z:1.528},"RightArm.rotation":{x:.896,y:-.247,z:-.512},"RightForeArm.rotation":{x:.007,y:0,z:-1.622},"RightHand.rotation":{x:1.139,y:-.853,z:.874},"RightHandThumb1.rotation":{x:.176,y:.107,z:-.311},"RightHandThumb2.rotation":{x:-.047,y:-.003,z:.12},"RightHandThumb3.rotation":{x:0,y:0,z:0},"RightHandIndex1.rotation":{x:.186,y:.005,z:.125},"RightHandIndex2.rotation":{x:.454,y:.005,z:.015},"RightHandIndex3.rotation":{x:0,y:0,z:0},"RightHandMiddle1.rotation":{x:.444,y:.035,z:.127},"RightHandMiddle2.rotation":{x:.403,y:-.006,z:-.04},"RightHandMiddle3.rotation":{x:0,y:0,z:0},"RightHandRing1.rotation":{x:.543,y:.074,z:.121},"RightHandRing2.rotation":{x:.48,y:-.018,z:-.063},"RightHandRing3.rotation":{x:0,y:0,z:0},"RightHandPinky1.rotation":{x:.464,y:.086,z:.113},"RightHandPinky2.rotation":{x:.667,y:-.06,z:-.128},"RightHandPinky3.rotation":{x:0,y:0,z:0},"LeftShoulder.rotation":{x:1.545,y:-.116,z:-1.529},"LeftArm.rotation":{x:.799,y:.631,z:.556},"LeftForeArm.rotation":{x:-.002,y:.007,z:.926},"LeftHand.rotation":{x:-.508,y:.439,z:.502},"LeftHandThumb1.rotation":{x:.651,y:-.035,z:.308},"LeftHandThumb2.rotation":{x:-.053,y:.008,z:-.11},"LeftHandThumb3.rotation":{x:0,y:0,z:0},"LeftHandIndex1.rotation":{x:.662,y:-.053,z:-.116},"LeftHandIndex2.rotation":{x:.309,y:-.004,z:-.02},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:.501,y:-.062,z:-.12},"LeftHandMiddle2.rotation":{x:.144,y:-.002,z:.016},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.397,y:-.029,z:-.143},"LeftHandRing2.rotation":{x:.328,y:.01,z:.059},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.194,y:.008,z:-.164},"LeftHandPinky2.rotation":{x:.38,y:.031,z:.128},"LeftHandPinky3.rotation":{x:0,y:0,z:0},"RightUpLeg.rotation":{x:-1.594,y:-.251,z:2.792},"RightLeg.rotation":{x:-2.301,y:-.073,z:.055},"RightFoot.rotation":{x:1.553,y:-.207,z:-.094},"RightToeBase.rotation":{x:.459,y:.069,z:.016},"LeftUpLeg.rotation":{x:-.788,y:-.236,z:-2.881},"LeftLeg.rotation":{x:-2.703,y:.012,z:-.047},"LeftFoot.rotation":{x:2.191,y:-.102,z:.019},"LeftToeBase.rotation":{x:1.215,y:-.027,z:.01}}},kneel:{kneeling:!0,lying:!0,props:{"Hips.position":{x:0,y:.532,z:-.002},"Hips.rotation":{x:.018,y:-.008,z:-.017},"Spine.rotation":{x:-.139,y:-.01,z:.002},"Spine1.rotation":{x:.002,y:-.002,z:.001},"Spine2.rotation":{x:.028,y:-.002,z:.001},"Neck.rotation":{x:-.007,y:0,z:-.002},"Head.rotation":{x:-.02,y:-.008,z:-.004},"LeftShoulder.rotation":{x:1.77,y:-.428,z:-1.588},"LeftArm.rotation":{x:.911,y:.343,z:.083},"LeftForeArm.rotation":{x:0,y:0,z:.347},"LeftHand.rotation":{x:.033,y:-.052,z:-.105},"LeftHandThumb1.rotation":{x:.508,y:-.22,z:.708},"LeftHandThumb2.rotation":{x:-.323,y:-.139,z:-.56},"LeftHandThumb3.rotation":{x:-.328,y:.16,z:-.301},"LeftHandIndex1.rotation":{x:.178,y:.248,z:.045},"LeftHandIndex2.rotation":{x:.236,y:-.002,z:-.019},"LeftHandIndex3.rotation":{x:-.062,y:0,z:.005},"LeftHandMiddle1.rotation":{x:.123,y:-.005,z:-.019},"LeftHandMiddle2.rotation":{x:.589,y:-.014,z:-.045},"LeftHandMiddle3.rotation":{x:.231,y:-.002,z:-.019},"LeftHandRing1.rotation":{x:.196,y:-.008,z:-.091},"LeftHandRing2.rotation":{x:.483,y:-.009,z:-.038},"LeftHandRing3.rotation":{x:.367,y:-.005,z:-.029},"LeftHandPinky1.rotation":{x:.191,y:-.269,z:-.246},"LeftHandPinky2.rotation":{x:.37,y:-.006,z:-.029},"LeftHandPinky3.rotation":{x:.368,y:-.005,z:-.029},"RightShoulder.rotation":{x:1.73,y:.434,z:1.715},"RightArm.rotation":{x:.841,y:-.508,z:-.155},"RightForeArm.rotation":{x:0,y:0,z:-.355},"RightHand.rotation":{x:.091,y:.137,z:.197},"RightHandThumb1.rotation":{x:.33,y:.051,z:-.753},"RightHandThumb2.rotation":{x:-.113,y:.075,z:.612},"RightHandThumb3.rotation":{x:-.271,y:-.166,z:.164},"RightHandIndex1.rotation":{x:.073,y:.001,z:-.093},"RightHandIndex2.rotation":{x:.338,y:.006,z:.034},"RightHandIndex3.rotation":{x:.131,y:.001,z:.013},"RightHandMiddle1.rotation":{x:.13,y:.005,z:-.017},"RightHandMiddle2.rotation":{x:.602,y:.018,z:.058},"RightHandMiddle3.rotation":{x:-.031,y:0,z:-.003},"RightHandRing1.rotation":{x:.351,y:.019,z:.045},"RightHandRing2.rotation":{x:.19,y:.002,z:.019},"RightHandRing3.rotation":{x:.21,y:.002,z:.021},"RightHandPinky1.rotation":{x:.256,y:.17,z:.118},"RightHandPinky2.rotation":{x:.451,y:.01,z:.045},"RightHandPinky3.rotation":{x:.346,y:.006,z:.035},"LeftUpLeg.rotation":{x:-.06,y:.1,z:-2.918},"LeftLeg.rotation":{x:-1.933,y:-.01,z:.011},"LeftFoot.rotation":{x:.774,y:-.162,z:-.144},"LeftToeBase.rotation":{x:1.188,y:0,z:0},"RightUpLeg.rotation":{x:-.099,y:-.057,z:2.922},"RightLeg.rotation":{x:-1.93,y:.172,z:-.02},"RightFoot.rotation":{x:.644,y:.251,z:.212},"RightToeBase.rotation":{x:.638,y:-.034,z:-.001}}},sitting:{sitting:!0,lying:!0,props:{"Hips.position":{x:0,y:.117,z:.005},"Hips.rotation":{x:-.411,y:-.049,z:.056},"Spine.rotation":{x:.45,y:-.039,z:-.116},"Spine1.rotation":{x:.092,y:-.076,z:.08},"Spine2.rotation":{x:.073,y:.035,z:.066},"Neck.rotation":{x:.051,y:.053,z:-.079},"Head.rotation":{x:-.169,y:.009,z:.034},"LeftShoulder.rotation":{x:1.756,y:-.037,z:-1.301},"LeftArm.rotation":{x:-.098,y:.016,z:1.006},"LeftForeArm.rotation":{x:-.089,y:.08,z:.837},"LeftHand.rotation":{x:.262,y:-.399,z:.3},"LeftHandThumb1.rotation":{x:.149,y:-.043,z:.452},"LeftHandThumb2.rotation":{x:.032,y:.006,z:-.162},"LeftHandThumb3.rotation":{x:-.086,y:-.005,z:-.069},"LeftHandIndex1.rotation":{x:.145,y:.032,z:-.069},"LeftHandIndex2.rotation":{x:.325,y:-.001,z:-.004},"LeftHandIndex3.rotation":{x:.253,y:0,z:-.003},"LeftHandMiddle1.rotation":{x:.186,y:-.051,z:-.091},"LeftHandMiddle2.rotation":{x:.42,y:-.003,z:-.011},"LeftHandMiddle3.rotation":{x:.153,y:.001,z:-.001},"LeftHandRing1.rotation":{x:.087,y:-.19,z:-.078},"LeftHandRing2.rotation":{x:.488,y:-.004,z:-.005},"LeftHandRing3.rotation":{x:.183,y:-.001,z:-.012},"LeftHandPinky1.rotation":{x:.205,y:-.262,z:.051},"LeftHandPinky2.rotation":{x:.407,y:-.002,z:-.004},"LeftHandPinky3.rotation":{x:.068,y:0,z:-.002},"RightShoulder.rotation":{x:1.619,y:-.139,z:1.179},"RightArm.rotation":{x:.17,y:-.037,z:-1.07},"RightForeArm.rotation":{x:-.044,y:-.056,z:-.665},"RightHand.rotation":{x:.278,y:.454,z:-.253},"RightHandThumb1.rotation":{x:.173,y:.089,z:-.584},"RightHandThumb2.rotation":{x:-.003,y:-.004,z:.299},"RightHandThumb3.rotation":{x:-.133,y:-.002,z:.235},"RightHandIndex1.rotation":{x:.393,y:-.023,z:.108},"RightHandIndex2.rotation":{x:.391,y:.001,z:.004},"RightHandIndex3.rotation":{x:.326,y:0,z:.003},"RightHandMiddle1.rotation":{x:.285,y:.062,z:.086},"RightHandMiddle2.rotation":{x:.519,y:.003,z:.011},"RightHandMiddle3.rotation":{x:.252,y:-.001,z:.001},"RightHandRing1.rotation":{x:.207,y:.122,z:.155},"RightHandRing2.rotation":{x:.597,y:.004,z:.005},"RightHandRing3.rotation":{x:.292,y:.001,z:.012},"RightHandPinky1.rotation":{x:.338,y:.171,z:.149},"RightHandPinky2.rotation":{x:.533,y:.002,z:.004},"RightHandPinky3.rotation":{x:.194,y:0,z:.002},"LeftUpLeg.rotation":{x:-1.957,y:.083,z:-2.886},"LeftLeg.rotation":{x:-1.46,y:.123,z:.005},"LeftFoot.rotation":{x:-.013,y:.016,z:.09},"LeftToeBase.rotation":{x:.744,y:0,z:0},"RightUpLeg.rotation":{x:-1.994,y:.125,z:2.905},"RightLeg.rotation":{x:-1.5,y:-.202,z:-.006},"RightFoot.rotation":{x:-.012,y:-.065,z:.081},"RightToeBase.rotation":{x:.758,y:0,z:0}}}},this.gestureTemplates={handup:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.815,y:[-.4,0,1,2],z:1.575},"LeftHand.rotation":{x:-.529,y:-.2,z:.022},"LeftHandThumb1.rotation":{x:.745,y:-.526,z:.604},"LeftHandThumb2.rotation":{x:-.107,y:-.01,z:-.142},"LeftHandThumb3.rotation":{x:0,y:.001,z:0},"LeftHandIndex1.rotation":{x:-.126,y:-.035,z:-.087},"LeftHandIndex2.rotation":{x:.255,y:.007,z:-.085},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.019,y:-.128,z:-.082},"LeftHandMiddle2.rotation":{x:.233,y:.019,z:-.074},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.005,y:-.241,z:-.122},"LeftHandRing2.rotation":{x:.261,y:.021,z:-.076},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.059,y:-.336,z:-.2},"LeftHandPinky2.rotation":{x:.153,y:.019,z:.001},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},index:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.815,y:[-.4,0,1,2],z:1.575},"LeftHand.rotation":{x:-.276,y:-.506,z:-.208},"LeftHandThumb1.rotation":{x:.579,y:.228,z:.363},"LeftHandThumb2.rotation":{x:-.027,y:-.04,z:-.662},"LeftHandThumb3.rotation":{x:0,y:.001,z:0},"LeftHandIndex1.rotation":{x:0,y:-.105,z:.225},"LeftHandIndex2.rotation":{x:.256,y:-.103,z:-.213},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:1.453,y:.07,z:.021},"LeftHandMiddle2.rotation":{x:1.599,y:.062,z:.07},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:1.528,y:-.073,z:.052},"LeftHandRing2.rotation":{x:1.386,y:.044,z:.053},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:1.65,y:-.204,z:.031},"LeftHandPinky2.rotation":{x:1.302,y:.071,z:.085},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},ok:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,1],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.415,y:[-.4,0,1,2],z:1.575},"LeftHand.rotation":{x:-.476,y:-.506,z:-.208},"LeftHandThumb1.rotation":{x:.703,y:.445,z:.899},"LeftHandThumb2.rotation":{x:-.312,y:-.04,z:-.938},"LeftHandThumb3.rotation":{x:-.37,y:.024,z:-.393},"LeftHandIndex1.rotation":{x:.8,y:-.086,z:-.091},"LeftHandIndex2.rotation":{x:1.123,y:-.046,z:-.074},"LeftHandIndex3.rotation":{x:.562,y:-.013,z:-.043},"LeftHandMiddle1.rotation":{x:-.019,y:-.128,z:-.082},"LeftHandMiddle2.rotation":{x:.233,y:.019,z:-.074},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.005,y:-.241,z:-.122},"LeftHandRing2.rotation":{x:.261,y:.021,z:-.076},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.059,y:-.336,z:-.2},"LeftHandPinky2.rotation":{x:.153,y:.019,z:.001},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},thumbup:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-.415,y:.206,z:1.575},"LeftHand.rotation":{x:-.276,y:-.506,z:-.208},"LeftHandThumb1.rotation":{x:.208,y:-.189,z:.685},"LeftHandThumb2.rotation":{x:.129,y:-.285,z:-.163},"LeftHandThumb3.rotation":{x:-.047,y:.068,z:.401},"LeftHandIndex1.rotation":{x:1.412,y:-.102,z:-.152},"LeftHandIndex2.rotation":{x:1.903,y:-.16,z:-.114},"LeftHandIndex3.rotation":{x:.535,y:-.017,z:-.062},"LeftHandMiddle1.rotation":{x:1.424,y:-.103,z:-.12},"LeftHandMiddle2.rotation":{x:1.919,y:-.162,z:-.114},"LeftHandMiddle3.rotation":{x:.44,y:-.012,z:-.051},"LeftHandRing1.rotation":{x:1.619,y:-.127,z:-.053},"LeftHandRing2.rotation":{x:1.898,y:-.16,z:-.115},"LeftHandRing3.rotation":{x:.262,y:-.004,z:-.031},"LeftHandPinky1.rotation":{x:1.661,y:-.131,z:-.016},"LeftHandPinky2.rotation":{x:1.715,y:-.067,z:-.13},"LeftHandPinky3.rotation":{x:.627,y:-.023,z:-.071}},thumbdown:{"LeftShoulder.rotation":{x:[1.5,2,1,2],y:[.2,.4,1,2],z:[-1.5,-1.3,1,2]},"LeftArm.rotation":{x:[1.5,1.7,1,2],y:[-.6,-.4,1,2],z:[1,1.2,1,2]},"LeftForeArm.rotation":{x:-2.015,y:.406,z:1.575},"LeftHand.rotation":{x:-.176,y:-.206,z:-.208},"LeftHandThumb1.rotation":{x:.208,y:-.189,z:.685},"LeftHandThumb2.rotation":{x:.129,y:-.285,z:-.163},"LeftHandThumb3.rotation":{x:-.047,y:.068,z:.401},"LeftHandIndex1.rotation":{x:1.412,y:-.102,z:-.152},"LeftHandIndex2.rotation":{x:1.903,y:-.16,z:-.114},"LeftHandIndex3.rotation":{x:.535,y:-.017,z:-.062},"LeftHandMiddle1.rotation":{x:1.424,y:-.103,z:-.12},"LeftHandMiddle2.rotation":{x:1.919,y:-.162,z:-.114},"LeftHandMiddle3.rotation":{x:.44,y:-.012,z:-.051},"LeftHandRing1.rotation":{x:1.619,y:-.127,z:-.053},"LeftHandRing2.rotation":{x:1.898,y:-.16,z:-.115},"LeftHandRing3.rotation":{x:.262,y:-.004,z:-.031},"LeftHandPinky1.rotation":{x:1.661,y:-.131,z:-.016},"LeftHandPinky2.rotation":{x:1.715,y:-.067,z:-.13},"LeftHandPinky3.rotation":{x:.627,y:-.023,z:-.071}},side:{"LeftShoulder.rotation":{x:1.755,y:-.035,z:-1.63},"LeftArm.rotation":{x:1.263,y:-.955,z:1.024},"LeftForeArm.rotation":{x:0,y:0,z:.8},"LeftHand.rotation":{x:-.36,y:-1.353,z:-.184},"LeftHandThumb1.rotation":{x:.137,y:-.049,z:.863},"LeftHandThumb2.rotation":{x:-.293,y:.153,z:-.193},"LeftHandThumb3.rotation":{x:-.271,y:-.17,z:.18},"LeftHandIndex1.rotation":{x:-.018,y:.007,z:.28},"LeftHandIndex2.rotation":{x:.247,y:-.003,z:-.025},"LeftHandIndex3.rotation":{x:.13,y:-.001,z:-.013},"LeftHandMiddle1.rotation":{x:.333,y:-.015,z:.182},"LeftHandMiddle2.rotation":{x:.313,y:-.005,z:-.032},"LeftHandMiddle3.rotation":{x:.294,y:-.004,z:-.03},"LeftHandRing1.rotation":{x:.456,y:-.028,z:-.092},"LeftHandRing2.rotation":{x:.53,y:-.014,z:-.052},"LeftHandRing3.rotation":{x:.478,y:-.012,z:-.047},"LeftHandPinky1.rotation":{x:.647,y:-.049,z:-.184},"LeftHandPinky2.rotation":{x:.29,y:-.004,z:-.029},"LeftHandPinky3.rotation":{x:.501,y:-.013,z:-.049}},shrug:{"Neck.rotation":{x:[-.3,.3,1,2],y:[-.3,.3,1,2],z:[-.1,.1]},"Head.rotation":{x:[-.3,.3],y:[-.3,.3],z:[-.1,.1]},"RightShoulder.rotation":{x:1.732,y:-.058,z:1.407},"RightArm.rotation":{x:1.305,y:.46,z:.118},"RightForeArm.rotation":{x:[0,2],y:[-1,.2],z:-1.637},"RightHand.rotation":{x:-.048,y:.165,z:-.39},"RightHandThumb1.rotation":{x:1.467,y:.599,z:-1.315},"RightHandThumb2.rotation":{x:-.255,y:-.123,z:.119},"RightHandThumb3.rotation":{x:0,y:-.002,z:0},"RightHandIndex1.rotation":{x:-.293,y:-.066,z:-.112},"RightHandIndex2.rotation":{x:.181,y:.007,z:.069},"RightHandIndex3.rotation":{x:0,y:0,z:0},"RightHandMiddle1.rotation":{x:-.063,y:-.041,z:.032},"RightHandMiddle2.rotation":{x:.149,y:.005,z:.05},"RightHandMiddle3.rotation":{x:0,y:0,z:0},"RightHandRing1.rotation":{x:.152,y:-.03,z:.132},"RightHandRing2.rotation":{x:.194,y:.007,z:.058},"RightHandRing3.rotation":{x:0,y:0,z:0},"RightHandPinky1.rotation":{x:.306,y:-.015,z:.257},"RightHandPinky2.rotation":{x:.15,y:-.003,z:-.003},"RightHandPinky3.rotation":{x:0,y:0,z:0},"LeftShoulder.rotation":{x:1.713,y:.141,z:-1.433},"LeftArm.rotation":{x:1.136,y:-.422,z:-.416},"LeftForeArm.rotation":{x:1.42,y:.123,z:1.506},"LeftHand.rotation":{x:.073,y:-.138,z:.064},"LeftHandThumb1.rotation":{x:1.467,y:-.599,z:1.314},"LeftHandThumb2.rotation":{x:-.255,y:.123,z:-.119},"LeftHandThumb3.rotation":{x:0,y:.001,z:0},"LeftHandIndex1.rotation":{x:-.293,y:.066,z:.112},"LeftHandIndex2.rotation":{x:.181,y:-.007,z:-.069},"LeftHandIndex3.rotation":{x:0,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.062,y:.041,z:-.032},"LeftHandMiddle2.rotation":{x:.149,y:-.005,z:-.05},"LeftHandMiddle3.rotation":{x:0,y:0,z:0},"LeftHandRing1.rotation":{x:.152,y:.03,z:-.132},"LeftHandRing2.rotation":{x:.194,y:-.007,z:-.058},"LeftHandRing3.rotation":{x:0,y:0,z:0},"LeftHandPinky1.rotation":{x:.306,y:.015,z:-.257},"LeftHandPinky2.rotation":{x:.15,y:.003,z:.003},"LeftHandPinky3.rotation":{x:0,y:0,z:0}},namaste:{"RightShoulder.rotation":{x:1.758,y:.099,z:1.604},"RightArm.rotation":{x:.862,y:-.292,z:-.932},"RightForeArm.rotation":{x:.083,y:.066,z:-1.791},"RightHand.rotation":{x:-.52,y:-.001,z:-.176},"RightHandThumb1.rotation":{x:.227,y:.418,z:-.776},"RightHandThumb2.rotation":{x:-.011,y:-.003,z:.171},"RightHandThumb3.rotation":{x:-.041,y:-.001,z:-.013},"RightHandIndex1.rotation":{x:-.236,y:.003,z:-.028},"RightHandIndex2.rotation":{x:.004,y:0,z:.001},"RightHandIndex3.rotation":{x:.002,y:0,z:0},"RightHandMiddle1.rotation":{x:-.236,y:.003,z:-.028},"RightHandMiddle2.rotation":{x:.004,y:0,z:.001},"RightHandMiddle3.rotation":{x:.002,y:0,z:0},"RightHandRing1.rotation":{x:-.236,y:.003,z:-.028},"RightHandRing2.rotation":{x:.004,y:0,z:.001},"RightHandRing3.rotation":{x:.002,y:0,z:0},"RightHandPinky1.rotation":{x:-.236,y:.003,z:-.028},"RightHandPinky2.rotation":{x:.004,y:0,z:.001},"RightHandPinky3.rotation":{x:.002,y:0,z:0},"LeftShoulder.rotation":{x:1.711,y:-.002,z:-1.625},"LeftArm.rotation":{x:.683,y:.334,z:.977},"LeftForeArm.rotation":{x:.086,y:-.066,z:1.843},"LeftHand.rotation":{x:-.595,y:-.229,z:.096},"LeftHandThumb1.rotation":{x:.404,y:-.05,z:.537},"LeftHandThumb2.rotation":{x:-.02,y:.004,z:-.154},"LeftHandThumb3.rotation":{x:-.049,y:.002,z:-.019},"LeftHandIndex1.rotation":{x:-.113,y:-.001,z:.014},"LeftHandIndex2.rotation":{x:.003,y:0,z:0},"LeftHandIndex3.rotation":{x:.002,y:0,z:0},"LeftHandMiddle1.rotation":{x:-.113,y:-.001,z:.014},"LeftHandMiddle2.rotation":{x:.004,y:0,z:0},"LeftHandMiddle3.rotation":{x:.002,y:0,z:0},"LeftHandRing1.rotation":{x:-.113,y:-.001,z:.014},"LeftHandRing2.rotation":{x:.003,y:0,z:0},"LeftHandRing3.rotation":{x:.002,y:0,z:0},"LeftHandPinky1.rotation":{x:-.122,y:-.001,z:-.057},"LeftHandPinky2.rotation":{x:.012,y:.001,z:.07},"LeftHandPinky3.rotation":{x:.002,y:0,z:0}}},this.poseDelta={props:{"Hips.quaternion":{x:0,y:0,z:0},"Spine.quaternion":{x:0,y:0,z:0},"Spine1.quaternion":{x:0,y:0,z:0},"Neck.quaternion":{x:0,y:0,z:0},"Head.quaternion":{x:0,y:0,z:0},"Spine1.scale":{x:0,y:0,z:0},"Neck.scale":{x:0,y:0,z:0},"LeftArm.scale":{x:0,y:0,z:0},"RightArm.scale":{x:0,y:0,z:0}}},["Left","Right"].forEach(l=>{["Leg","UpLeg","Arm","ForeArm","Hand"].forEach(c=>{this.poseDelta.props[l+c+".quaternion"]={x:0,y:0,z:0}}),["HandThumb","HandIndex","HandMiddle","HandRing","HandPinky"].forEach(c=>{this.poseDelta.props[l+c+"1.quaternion"]={x:0,y:0,z:0},this.poseDelta.props[l+c+"2.quaternion"]={x:0,y:0,z:0},this.poseDelta.props[l+c+"3.quaternion"]={x:0,y:0,z:0}})});const n=new Set;Object.values(this.poseTemplates).forEach(l=>{Object.keys(this.propsToThreeObjects(l.props)).forEach(c=>n.add(c))}),Object.keys(this.poseDelta.props).forEach(l=>{n.add(l)}),this.posePropNames=[...n],this.poseName="side",this.poseWeightOnLeft=!0,this.gesture=null,this.poseCurrentTemplate=this.poseTemplates[this.poseName],this.poseStraight=this.propsToThreeObjects(this.poseTemplates.straight.props),this.poseBase=this.poseFactory(this.poseCurrentTemplate),this.poseTarget=this.poseFactory(this.poseCurrentTemplate),this.poseAvatar=null,this.avatarHeight=1.7,this.animTemplateEyes={name:"eyes",idle:{alt:[{p:()=>this.avatar?.hasOwnProperty("avatarIdleEyeContact")?this.avatar.avatarIdleEyeContact:this.opt.avatarIdleEyeContact,delay:[200,5e3],dt:[200,[2e3,5e3],[3e3,1e4,1,2]],vs:{headMove:[this.avatar?.hasOwnProperty("avatarIdleHeadMove")?this.avatar.avatarIdleHeadMove:this.opt.avatarIdleHeadMove],eyesRotateY:[[-.6,.6]],eyesRotateX:[[-.2,.6]],eyeContact:[null,1]}},{delay:[200,5e3],dt:[200,[2e3,5e3,1,2]],vs:{headMove:[this.avatar?.hasOwnProperty("avatarIdleHeadMove")?this.avatar.avatarIdleHeadMove:this.opt.avatarIdleHeadMove],eyesRotateY:[[-.6,.6]],eyesRotateX:[[-.2,.6]]}}]},speaking:{alt:[{p:()=>this.avatar?.hasOwnProperty("avatarSpeakingEyeContact")?this.avatar.avatarSpeakingEyeContact:this.opt.avatarSpeakingEyeContact,delay:[200,5e3],dt:[0,[3e3,1e4,1,2],[2e3,5e3]],vs:{eyeContact:[1,null],headMove:[null,this.avatar?.hasOwnProperty("avatarSpeakingHeadMove")?this.avatar.avatarSpeakingHeadMove:this.opt.avatarSpeakingHeadMove,null],eyesRotateY:[null,[-.6,.6]],eyesRotateX:[null,[-.2,.6]]}},{delay:[200,5e3],dt:[200,[2e3,5e3,1,2]],vs:{headMove:[this.avatar?.hasOwnProperty("avatarSpeakingHeadMove")?this.avatar.avatarSpeakingHeadMove:this.opt.avatarSpeakingHeadMove,null],eyesRotateY:[[-.6,.6]],eyesRotateX:[[-.2,.6]]}}]}},this.animTemplateBlink={name:"blink",alt:[{p:.85,delay:[1e3,8e3,1,2],dt:[50,[100,300],100],vs:{eyeBlinkLeft:[1,1,0],eyeBlinkRight:[1,1,0]}},{delay:[1e3,4e3,1,2],dt:[50,[100,200],100,[10,400,0],50,[100,200],100],vs:{eyeBlinkLeft:[1,1,0,0,1,1,0],eyeBlinkRight:[1,1,0,0,1,1,0]}}]},this.animMoods={neutral:{baseline:{eyesLookDown:0},speech:{deltaRate:0,deltaPitch:0,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1200,500,1e3],vs:{chestInhale:[.5,.5,0]}},{name:"pose",alt:[{p:.5,delay:[5e3,3e4],vs:{pose:["side"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.3,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{delay:[5e3,3e4],vs:{pose:["straight"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}}]},{name:"head",idle:{delay:[0,1e3],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.3,.3]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},happy:{baseline:{mouthSmile:.2,eyesLookDown:0},speech:{deltaRate:0,deltaPitch:.1,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1200,500,1e3],vs:{chestInhale:[.5,.5,0]}},{name:"pose",idle:{alt:[{p:.6,delay:[5e3,3e4],vs:{pose:["side"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.2,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.1,delay:[5e3,3e4],vs:{pose:["straight"]}},{delay:[5e3,1e4],vs:{pose:["wide"]}},{delay:[1e3,3e3],vs:{pose:["turn"]}}]},speaking:{alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{p:.4,delay:[5e3,3e4],vs:{pose:["straight"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}},{delay:[5e3,2e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}}]}},{name:"head",idle:{dt:[[1e3,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.3,.3]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthLeft:[[0,.3,2]],mouthSmile:[[0,.2,3]],mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},angry:{baseline:{eyesLookDown:.1,browDownLeft:.6,browDownRight:.6,jawForward:.3,mouthFrownLeft:.7,mouthFrownRight:.7,mouthRollLower:.2,mouthShrugLower:.3,handFistLeft:1,handFistRight:1},speech:{deltaRate:-.2,deltaPitch:.2,deltaVolume:0},anims:[{name:"breathing",delay:500,dt:[1e3,500,1e3],vs:{chestInhale:[.7,.7,0]}},{name:"pose",alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]}},{p:.4,delay:[5e3,3e4],vs:{pose:["straight"]}},{p:.2,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["wide"]}}}]},{name:"head",idle:{delay:[100,500],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.2,.2]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},sad:{baseline:{eyesLookDown:.2,browDownRight:.1,browInnerUp:.6,browOuterUpRight:.2,eyeSquintLeft:.7,eyeSquintRight:.7,mouthFrownLeft:.8,mouthFrownRight:.8,mouthLeft:.2,mouthPucker:.5,mouthRollLower:.2,mouthRollUpper:.2,mouthShrugLower:.2,mouthShrugUpper:.2,mouthStretchLeft:.4},speech:{deltaRate:-.2,deltaPitch:-.2,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1e3,500,1e3],vs:{chestInhale:[.3,.3,0]}},{name:"pose",alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]}},{p:.4,delay:[5e3,3e4],vs:{pose:["straight"]}},{delay:[5e3,2e4],vs:{pose:["side"]},full:{delay:[5e3,2e4],vs:{pose:["oneknee"]}}}]},{name:"head",idle:{delay:[100,500],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.2,.2]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},fear:{baseline:{browInnerUp:.7,eyeSquintLeft:.5,eyeSquintRight:.5,eyeWideLeft:.6,eyeWideRight:.6,mouthClose:.1,mouthFunnel:.3,mouthShrugLower:.5,mouthShrugUpper:.5},speech:{deltaRate:-.2,deltaPitch:0,deltaVolume:0},anims:[{name:"breathing",delay:500,dt:[1e3,500,1e3],vs:{chestInhale:[.7,.7,0]}},{name:"pose",alt:[{p:.8,delay:[5e3,3e4],vs:{pose:["side"]}},{delay:[5e3,3e4],vs:{pose:["straight"]}},{delay:[5e3,2e4],vs:{pose:["wide"]}},{delay:[5e3,2e4],vs:{pose:["side"]},full:{delay:[5e3,2e4],vs:{pose:["oneknee"]}}}]},{name:"head",idle:{delay:[100,500],dt:[[200,3e3]],vs:{bodyRotateX:[[-.06,.12]],bodyRotateY:[[-.7,.7]],bodyRotateZ:[[-.1,.1]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},disgust:{baseline:{browDownLeft:.7,browDownRight:.1,browInnerUp:.3,eyeSquintLeft:1,eyeSquintRight:1,eyeWideLeft:.5,eyeWideRight:.5,eyesRotateX:.05,mouthLeft:.4,mouthPressLeft:.3,mouthRollLower:.3,mouthShrugLower:.3,mouthShrugUpper:.8,mouthUpperUpLeft:.3,noseSneerLeft:1,noseSneerRight:.7},speech:{deltaRate:-.2,deltaPitch:0,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1e3,500,1e3],vs:{chestInhale:[.5,.5,0]}},{name:"pose",alt:[{delay:[5e3,2e4],vs:{pose:["side"]}}]},{name:"head",idle:{delay:[100,500],dt:[[200,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.2,.2]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.animTemplateBlink,{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[100,500],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[0,.3,2]],browOuterUpLeft:[[0,.3,2]],browOuterUpRight:[[0,.3,2]]}}]},love:{baseline:{browInnerUp:.4,browOuterUpLeft:.2,browOuterUpRight:.2,mouthSmile:.2,eyeBlinkLeft:.6,eyeBlinkRight:.6,eyeWideLeft:.7,eyeWideRight:.7,bodyRotateX:.1,mouthDimpleLeft:.1,mouthDimpleRight:.1,mouthPressLeft:.2,mouthShrugUpper:.2,mouthUpperUpLeft:.1,mouthUpperUpRight:.1},speech:{deltaRate:-.1,deltaPitch:-.7,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1500,500,1500],vs:{chestInhale:[.8,.8,0]}},{name:"pose",alt:[{p:.4,delay:[5e3,3e4],vs:{pose:["side"]}},{p:.2,delay:[5e3,3e4],vs:{pose:["straight"]}},{p:.2,delay:[5e3,3e4],vs:{pose:["hip"]},M:{delay:[5e3,3e4],vs:{pose:["side"]}}},{delay:[5e3,1e4],vs:{pose:["side"]},full:{delay:[5e3,1e4],vs:{pose:["kneel"]}}},{delay:[1e3,3e3],vs:{pose:["turn"]},M:{delay:[1e3,3e3],vs:{pose:["wide"]}}},{delay:[1e3,3e3],vs:{pose:["back"]},M:{delay:[1e3,3e3],vs:{pose:["wide"]}}},{delay:[5e3,2e4],vs:{pose:["side"]},M:{delay:[5e3,2e4],vs:{pose:["side"]}},full:{delay:[5e3,2e4],vs:{pose:["bend"]}}},{delay:[1e3,3e3],vs:{pose:["side"]},full:{delay:[5e3,1e4],vs:{pose:["oneknee"]}}}]},{name:"head",idle:{dt:[[1e3,5e3]],vs:{bodyRotateX:[[-.04,.1]],bodyRotateY:[[-.3,.3]],bodyRotateZ:[[-.08,.08]]}},speaking:{dt:[[0,1e3,0]],vs:{bodyRotateX:[[-.05,.15,1,2]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.1,.1]]}}},this.animTemplateEyes,this.deepCopy(this.animTemplateBlink,l=>{l.alt[0].delay[0]=l.alt[1].delay[0]=2e3}),{name:"mouth",delay:[1e3,5e3],dt:[[100,500],[100,5e3,2]],vs:{mouthLeft:[[0,.3,2]],mouthRollLower:[[0,.3,2]],mouthRollUpper:[[0,.3,2]],mouthStretchLeft:[[0,.3]],mouthStretchRight:[[0,.3]],mouthPucker:[[0,.3]]}},{name:"misc",delay:[100,5e3],dt:[[500,1e3],[1e3,5e3,2]],vs:{eyeSquintLeft:[[0,.3,2]],eyeSquintRight:[[0,.3,2]],browInnerUp:[[.3,.6,2]],browOuterUpLeft:[[.1,.3,2]],browOuterUpRight:[[.1,.3,2]]}}]},sleep:{baseline:{eyeBlinkLeft:1,eyeBlinkRight:1,eyesClosed:.6},speech:{deltaRate:0,deltaPitch:-.2,deltaVolume:0},anims:[{name:"breathing",delay:1500,dt:[1e3,500,1e3],vs:{chestInhale:[.6,.6,0]}},{name:"pose",alt:[{delay:[5e3,2e4],vs:{pose:["side"]}}]},{name:"head",delay:[1e3,5e3],dt:[[2e3,1e4]],vs:{bodyRotateX:[[0,.4]],bodyRotateY:[[-.1,.1]],bodyRotateZ:[[-.04,.04]]}},{name:"eyes",delay:10010,dt:[],vs:{}},{name:"blink",delay:10020,dt:[],vs:{}},{name:"mouth",delay:10030,dt:[],vs:{}},{name:"misc",delay:10040,dt:[],vs:{}}]}},this.moodName=this.opt.avatarMood||"neutral",this.mood=this.animMoods[this.moodName],this.mood||(this.moodName="neutral",this.mood=this.animMoods.neutral),this.animEmojis={"😐":{dt:[300,2e3],rescale:[0,1],vs:{pose:["straight"],browInnerUp:[.4],eyeWideLeft:[.7],eyeWideRight:[.7],mouthPressLeft:[.6],mouthPressRight:[.6],mouthRollLower:[.3],mouthStretchLeft:[1],mouthStretchRight:[1]}},"😶":{link:"😐"},"😏":{dt:[300,2e3],rescale:[0,1],vs:{eyeContact:[0],browDownRight:[.1],browInnerUp:[.7],browOuterUpRight:[.2],eyeLookInRight:[.7],eyeLookOutLeft:[.7],eyeSquintLeft:[1],eyeSquintRight:[.8],eyesRotateY:[.7],mouthLeft:[.4],mouthPucker:[.4],mouthShrugLower:[.3],mouthShrugUpper:[.2],mouthSmile:[.2],mouthSmileLeft:[.4],mouthSmileRight:[.2],mouthStretchLeft:[.5],mouthUpperUpLeft:[.6],noseSneerLeft:[.7]}},"🙂":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5]}},"🙃":{link:"🙂"},"😊":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.6],eyeSquintLeft:[1],eyeSquintRight:[1],mouthSmile:[.7],noseSneerLeft:[.7],noseSneerRight:[.7]}},"😇":{link:"😊"},"😀":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.6],jawOpen:[.1],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😃":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.6],eyeWideLeft:[.7],eyeWideRight:[.7],jawOpen:[.1],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😄":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],jawOpen:[.2],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😁":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],jawOpen:[.3],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthPressLeft:[.5],mouthPressRight:[.5],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😆":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.6],jawOpen:[.3],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthPressLeft:[.5],mouthPressRight:[.5],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"😝":{dt:[300,100,1500,500,500],rescale:[0,0,1,0,0],vs:{browInnerUp:[.8],eyesClosed:[1],jawOpen:[.7],mouthFunnel:[.5],mouthSmile:[1],tongueOut:[0,1,1,0]}},"😋":{link:"😝"},"😛":{link:"😝"},"😛":{link:"😝"},"😜":{link:"😝"},"🤪":{link:"😝"},"😂":{dt:[300,2e3],rescale:[0,1],vs:{browInnerUp:[.3],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.6],jawOpen:[.3],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthPressLeft:[.5],mouthPressRight:[.5],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"🤣":{link:"😂"},"😅":{link:"😂"},"😉":{dt:[500,200,500,500],rescale:[0,0,0,1],vs:{mouthSmile:[.5],mouthOpen:[.2],mouthSmileLeft:[0,.5,0],eyeBlinkLeft:[0,.7,0],eyeBlinkRight:[0,0,0],bodyRotateX:[.05,.05,.05,0],bodyRotateZ:[-.05,-.05,-.05,0],browDownLeft:[0,.7,0],cheekSquintLeft:[0,.7,0],eyeSquintLeft:[0,1,0],eyesClosed:[0]}},"😭":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[1],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.1],jawOpen:[0],mouthFrownLeft:[1],mouthFrownRight:[1],mouthOpen:[.5],mouthPucker:[.5],mouthUpperUpLeft:[.6],mouthUpperUpRight:[.6]}},"🥺":{dt:[1e3,1e3],rescale:[0,1],vs:{browDownLeft:[.2],browDownRight:[.2],browInnerUp:[1],eyeWideLeft:[.9],eyeWideRight:[.9],eyesClosed:[.1],mouthClose:[.2],mouthFrownLeft:[1],mouthFrownRight:[1],mouthPressLeft:[.4],mouthPressRight:[.4],mouthPucker:[1],mouthRollLower:[.6],mouthRollUpper:[.2],mouthUpperUpLeft:[.8],mouthUpperUpRight:[.8]}},"😞":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[.7],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.5],bodyRotateX:[.3],mouthClose:[.2],mouthFrownLeft:[1],mouthFrownRight:[1],mouthPucker:[1],mouthRollLower:[1],mouthShrugLower:[.2],mouthUpperUpLeft:[.8],mouthUpperUpRight:[.8]}},"😔":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[1],eyeSquintLeft:[1],eyeSquintRight:[1],eyesClosed:[.5],bodyRotateX:[.3],mouthClose:[.2],mouthFrownLeft:[1],mouthFrownRight:[1],mouthPressLeft:[.4],mouthPressRight:[.4],mouthPucker:[1],mouthRollLower:[.6],mouthRollUpper:[.2],mouthUpperUpLeft:[.8],mouthUpperUpRight:[.8]}},"😳":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[1],eyeWideLeft:[.5],eyeWideRight:[.5],eyesRotateY:[.05],eyesRotateX:[.05],mouthClose:[.2],mouthFunnel:[.5],mouthPucker:[.4],mouthRollLower:[.4],mouthRollUpper:[.4]}},"☹️":{dt:[500,1500],rescale:[0,1],vs:{mouthFrownLeft:[1],mouthFrownRight:[1],mouthPucker:[.1],mouthRollLower:[.8]}},"😚":{dt:[500,1e3,1e3],rescale:[0,1,0],vs:{browInnerUp:[.6],eyeBlinkLeft:[1],eyeBlinkRight:[1],eyeSquintLeft:[1],eyeSquintRight:[1],mouthPucker:[0,.5],noseSneerLeft:[0,.7],noseSneerRight:[0,.7],viseme_U:[0,1]}},"😘":{dt:[500,500,200,500],rescale:[0,0,0,1],vs:{browInnerUp:[.6],eyeBlinkLeft:[0,0,1,0],eyeBlinkRight:[0],eyesRotateY:[0],bodyRotateY:[0],bodyRotateX:[0,.05,.05,0],bodyRotateZ:[0,-.05,-.05,0],eyeSquintLeft:[1],eyeSquintRight:[1],mouthPucker:[0,.5,0],noseSneerLeft:[0,.7],noseSneerRight:[.7],viseme_U:[0,1]}},"🥰":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[.6],eyeSquintLeft:[1],eyeSquintRight:[1],mouthSmile:[.7],noseSneerLeft:[.7],noseSneerRight:[.7]}},"😍":{dt:[1e3,1e3],rescale:[0,1],vs:{browInnerUp:[.6],jawOpen:[.1],mouthDimpleLeft:[.2],mouthDimpleRight:[.2],mouthOpen:[.3],mouthPressLeft:[.3],mouthPressRight:[.3],mouthRollLower:[.4],mouthShrugUpper:[.4],mouthSmile:[.7],mouthUpperUpLeft:[.3],mouthUpperUpRight:[.3],noseSneerLeft:[.4],noseSneerRight:[.4]}},"🤩":{link:"😍"},"😡":{dt:[1e3,1500],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],eyesLookUp:[.2],jawForward:[.3],mouthFrownLeft:[1],mouthFrownRight:[1],bodyRotateX:[.15]}},"😠":{dt:[1e3,1500],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],eyesLookUp:[.2],jawForward:[.3],mouthFrownLeft:[1],mouthFrownRight:[1],bodyRotateX:[.15]}},"🤬":{link:"😠"},"😒":{dt:[1e3,1e3],rescale:[0,1],vs:{eyeContact:[0],browDownRight:[.1],browInnerUp:[.7],browOuterUpRight:[.2],eyeLookInRight:[.7],eyeLookOutLeft:[.7],eyeSquintLeft:[1],eyeSquintRight:[.8],eyesRotateY:[.7],mouthFrownLeft:[1],mouthFrownRight:[1],mouthLeft:[.2],mouthPucker:[.5],mouthRollLower:[.2],mouthRollUpper:[.2],mouthShrugLower:[.2],mouthShrugUpper:[.2],mouthStretchLeft:[.5]}},"😱":{dt:[500,1500],rescale:[0,1],vs:{browInnerUp:[.8],eyeWideLeft:[.5],eyeWideRight:[.5],jawOpen:[.7],mouthFunnel:[.5]}},"😬":{dt:[500,1500],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],browInnerUp:[1],mouthDimpleLeft:[.5],mouthDimpleRight:[.5],mouthLowerDownLeft:[1],mouthLowerDownRight:[1],mouthPressLeft:[.4],mouthPressRight:[.4],mouthPucker:[.5],mouthSmile:[.1],mouthSmileLeft:[.2],mouthSmileRight:[.2],mouthStretchLeft:[1],mouthStretchRight:[1],mouthUpperUpLeft:[1],mouthUpperUpRight:[1]}},"🙄":{dt:[500,1500],rescale:[0,1],vs:{browInnerUp:[.8],eyeWideLeft:[1],eyeWideRight:[1],eyesRotateX:[-.8],bodyRotateX:[.15],mouthPucker:[.5],mouthRollLower:[.6],mouthRollUpper:[.5],mouthShrugLower:[0],mouthSmile:[0]}},"🤔":{dt:[500,1500],rescale:[0,1],vs:{browDownLeft:[1],browOuterUpRight:[1],eyeSquintLeft:[.6],mouthFrownLeft:[.7],mouthFrownRight:[.7],mouthLowerDownLeft:[.3],mouthPressRight:[.4],mouthPucker:[.1],mouthRight:[.5],mouthRollLower:[.5],mouthRollUpper:[.2],handRight:[{x:.1,y:.1,z:.1,d:1e3},{d:1e3}],handFistRight:[.1]}},"👀":{dt:[500,1500],rescale:[0,1],vs:{eyesRotateY:[-.8]}},"😴":{dt:[5e3,5e3],rescale:[0,1],vs:{eyeBlinkLeft:[1],eyeBlinkRight:[1],bodyRotateX:[.2],bodyRotateZ:[.1]}},"✋":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["handup",2,!0],null]}},"🤚":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["handup",2],null]}},"👋":{link:"✋"},"👍":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["thumbup",2],null]}},"👎":{dt:[300,2e3],rescale:[0,1],vs:{browDownLeft:[1],browDownRight:[1],eyesLookUp:[.2],jawForward:[.3],mouthFrownLeft:[1],mouthFrownRight:[1],bodyRotateX:[.15],gesture:[["thumbdown",2],null]}},"👌":{dt:[300,2e3],rescale:[0,1],vs:{mouthSmile:[.5],gesture:[["ok",2],null]}},"🤷♂️":{dt:[1e3,1500],rescale:[0,1],vs:{gesture:[["shrug",2],null]}},"🤷♀️":{link:"🤷♂️"},"🤷":{link:"🤷♂️"},"🙏":{dt:[1500,300,1e3],rescale:[0,1,0],vs:{eyeBlinkLeft:[0,1],eyeBlinkRight:[0,1],bodyRotateX:[0],bodyRotateZ:[.1],gesture:[["namaste",2],null]}},yes:{dt:[[200,500],[200,500],[200,500],[200,500]],vs:{headMove:[0],headRotateX:[[.1,.2],.1,[.1,.2],0],headRotateZ:[[-.2,.2]]}},no:{dt:[[200,500],[200,500],[200,500],[200,500],[200,500]],vs:{headMove:[0],headRotateY:[[-.1,-.05],[.05,.1],[-.1,-.05],[.05,.1],0],headRotateZ:[[-.2,.2]]}}},this.mtAvatar={},this.mtCustoms=["handFistLeft","handFistRight","bodyRotateX","bodyRotateY","bodyRotateZ","headRotateX","headRotateY","headRotateZ","chestInhale"],this.mtEasingDefault=this.sigmoidFactory(5),this.mtAccDefault=.01,this.mtAccExceptions={eyeBlinkLeft:.1,eyeBlinkRight:.1,eyeLookOutLeft:.1,eyeLookInLeft:.1,eyeLookOutRight:.1,eyeLookInRight:.1},this.mtMaxVDefault=5,this.mtMaxVExceptions={bodyRotateX:1,bodyRotateY:1,bodyRotateZ:1},this.mtBaselineDefault=0,this.mtBaselineExceptions={bodyRotateX:null,bodyRotateY:null,bodyRotateZ:null,eyeLookOutLeft:null,eyeLookInLeft:null,eyeLookOutRight:null,eyeLookInRight:null,eyesLookDown:null,eyesLookUp:null},this.mtMinDefault=0,this.mtMinExceptions={bodyRotateX:-1,bodyRotateY:-1,bodyRotateZ:-1,headRotateX:-1,headRotateY:-1,headRotateZ:-1},this.mtMaxDefault=1,this.mtMaxExceptions={},this.mtLimits={eyeBlinkLeft:l=>Math.max(l,(this.mtAvatar.eyesLookDown.value+this.mtAvatar.browDownLeft.value)/2),eyeBlinkRight:l=>Math.max(l,(this.mtAvatar.eyesLookDown.value+this.mtAvatar.browDownRight.value)/2)},this.mtOnchange={eyesLookDown:()=>{this.mtAvatar.eyeBlinkLeft.needsUpdate=!0,this.mtAvatar.eyeBlinkRight.needsUpdate=!0},browDownLeft:()=>{this.mtAvatar.eyeBlinkLeft.needsUpdate=!0},browDownRight:()=>{this.mtAvatar.eyeBlinkRight.needsUpdate=!0}},this.mtRandomized=["mouthDimpleLeft","mouthDimpleRight","mouthLeft","mouthPressLeft","mouthPressRight","mouthStretchLeft","mouthStretchRight","mouthShrugLower","mouthShrugUpper","noseSneerLeft","noseSneerRight","mouthRollLower","mouthRollUpper","browDownLeft","browDownRight","browOuterUpLeft","browOuterUpRight","cheekPuff","cheekSquintLeft","cheekSquintRight"],this.mtExtras=[{key:"mouthOpen",mix:{jawOpen:.5}},{key:"mouthSmile",mix:{mouthSmileLeft:.8,mouthSmileRight:.8}},{key:"eyesClosed",mix:{eyeBlinkLeft:1,eyeBlinkRight:1}},{key:"eyesLookUp",mix:{eyeLookUpLeft:1,eyeLookUpRight:1}},{key:"eyesLookDown",mix:{eyeLookDownLeft:1,eyeLookDownRight:1}}],this.animQueue=[],this.animClips=[],this.animPoses=[],this.animFrameDur=1e3/this.opt.modelFPS,this.animClock=0,this.animSlowdownRate=1,this.animTimeLast=0,this.easing=this.sigmoidFactory(5),this.lipsync={},this.opt.lipsyncModules.forEach(l=>{this.lipsyncGetProcessor(l)}),this.visemeNames=["aa","E","I","O","U","PP","SS","TH","DD","FF","kk","nn","RR","CH","sil"],this.segmenter=new Intl.Segmenter("en",{granularity:"grapheme"}),this.initAudioGraph(),this.audioPlaylist=[],this.volumeFrequencyData=new Uint8Array(16),this.volumeMax=0,this.volumeHeadBase=0,this.volumeHeadTarget=0,this.volumeHeadCurrent=0,this.volumeHeadVelocity=.15,this.volumeHeadEasing=this.sigmoidFactory(3),this.isListening=!1,this.listeningAnalyzer=null,this.listeningActive=!1,this.listeningVolume=0,this.listeningSilenceThresholdLevel=this.opt.listeningSilenceThresholdLevel,this.listeningSilenceThresholdMs=this.opt.listeningSilenceThresholdMs,this.listeningSilenceDurationMax=this.opt.listeningSilenceDurationMax,this.listeningActiveThresholdLevel=this.opt.listeningActiveThresholdLevel,this.listeningActiveThresholdMs=this.opt.listeningActiveThresholdMs,this.listeningActiveDurationMax=this.opt.listeningActiveDurationMax,this.listeningTimer=0,this.listeningTimerTotal=0,this.dracoEnabled=this.opt.dracoEnabled,this.dracoDecoderPath=this.opt.dracoDecoderPath;const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";this.b64Lookup=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let l=0;l<i.length;l++)this.b64Lookup[i.charCodeAt(l)]=l;if(this.stateName="idle",this.speechQueue=[],this.isSpeaking=!1,this.isListening=!1,this.opt.ttsEndpoint){let l=new Audio;if(l.canPlayType("audio/ogg"))this.ttsAudioEncoding="OGG-OPUS";else if(l.canPlayType("audio/mp3"))this.ttsAudioEncoding="MP3";else throw new Error("There was no support for either OGG or MP3 audio.")}if(this.isAvatarOnly=this.opt.avatarOnly,this.isAvatarOnly)this.scene=this.opt.avatarOnlyScene,this.camera=this.opt.avatarOnlyCamera;else{this.renderer=new y.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(this.opt.modelPixelRatio*window.devicePixelRatio),this.renderer.setSize(this.nodeAvatar.clientWidth,this.nodeAvatar.clientHeight),this.renderer.outputColorSpace=y.SRGBColorSpace,this.renderer.toneMapping=y.ACESFilmicToneMapping,this.renderer.shadowMap.enabled=!1,this.nodeAvatar.appendChild(this.renderer.domElement),this.camera=new y.PerspectiveCamera(10,this.nodeAvatar.clientWidth/this.nodeAvatar.clientHeight,.1,2e3),this.scene=new y.Scene,this.lightAmbient=new y.AmbientLight(new y.Color(this.opt.lightAmbientColor),this.opt.lightAmbientIntensity),this.lightDirect=new y.DirectionalLight(new y.Color(this.opt.lightDirectColor),this.opt.lightDirectIntensity),this.lightSpot=new y.SpotLight(new y.Color(this.opt.lightSpotColor),this.opt.lightSpotIntensity,0,this.opt.lightSpotDispersion),this.setLighting(this.opt);const l=new y.PMREMGenerator(this.renderer);l.compileEquirectangularShader(),this.scene.environment=l.fromScene(new Ye.RoomEnvironment).texture,this.resizeobserver=new ResizeObserver(this.onResize.bind(this)),this.resizeobserver.observe(this.nodeAvatar),this.controls=new Xe.OrbitControls(this.camera,this.renderer.domElement),this.controls.enableZoom=this.opt.cameraZoomEnable,this.controls.enableRotate=this.opt.cameraRotateEnable,this.controls.enablePan=this.opt.cameraPanEnable,this.controls.minDistance=2,this.controls.maxDistance=2e3,this.controls.autoRotateSpeed=0,this.controls.autoRotate=!1,this.controls.update(),this.cameraClock=null}this.ikMesh=new y.SkinnedMesh;const s={LeftShoulder:null,LeftArm:"LeftShoulder",LeftForeArm:"LeftArm",LeftHand:"LeftForeArm",LeftHandMiddle1:"LeftHand",RightShoulder:null,RightArm:"RightShoulder",RightForeArm:"RightArm",RightHand:"RightForeArm",RightHandMiddle1:"RightHand"},o=[];Object.entries(s).forEach((l,c)=>{const r=new y.Bone;r.name=l[0],l[1]?this.ikMesh.getObjectByName(l[1]).add(r):this.ikMesh.add(r),o.push(r)}),this.ikMesh.bind(new y.Skeleton(o)),this.dynamicbones=new $e,this.isStreaming=!1,this.streamWorkletNode=null,this.streamAudioStartTime=null,this.streamWaitForAudioChunks=!0,this.streamLipsyncLang=null,this.streamLipsyncType="visemes",this.streamLipsyncQueue=[]}initAudioGraph(t=null){if(this.audioCtx&&this.audioCtx.state!=="closed"&&this.audioCtx.close(),t?this.audioCtx=new AudioContext({sampleRate:t}):this.audioCtx=new AudioContext,this.audioSpeechSource=this.audioCtx.createBufferSource(),this.audioBackgroundSource=this.audioCtx.createBufferSource(),this.audioBackgroundGainNode=this.audioCtx.createGain(),this.audioSpeechGainNode=this.audioCtx.createGain(),this.audioStreamGainNode=this.audioCtx.createGain(),this.audioAnalyzerNode=this.audioCtx.createAnalyser(),this.audioAnalyzerNode.fftSize=256,this.audioAnalyzerNode.smoothingTimeConstant=.1,this.audioAnalyzerNode.minDecibels=-70,this.audioAnalyzerNode.maxDecibels=-10,this.audioAnalyzer=new et(this.audioCtx),this.audioReverbNode=this.audioCtx.createConvolver(),this.audioBackgroundGainNode.connect(this.audioReverbNode),this.audioAnalyzerNode.connect(this.audioSpeechGainNode),this.audioSpeechGainNode.connect(this.audioReverbNode),this.audioStreamGainNode.connect(this.audioReverbNode),this.audioReverbNode.connect(this.audioCtx.destination),this.setReverb(this.currentReverb||null),this.setMixerGain(this.opt.mixerGainSpeech,this.opt.mixerGainBackground),this.workletLoaded=!1,this.streamWorkletNode){try{this.streamWorkletNode.port.postMessage({type:"stop"}),this.streamWorkletNode.disconnect(),this.isStreaming=!1}catch(e){console.error("Error disconnecting streamWorkletNode:",e)}this.streamWorkletNode=null}}valueFn(t){return typeof t=="function"?t():t}deepCopy(t,e=null){const n=JSON.parse(JSON.stringify(t));return e&&typeof e=="function"&&e(n),n}b64ToArrayBuffer(t){let e=3*t.length/4;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const n=new ArrayBuffer(e),i=new Uint8Array(n);let s,o=0,l,c,r,u;for(s=0;s<t.length;s+=4)l=this.b64Lookup[t.charCodeAt(s)],c=this.b64Lookup[t.charCodeAt(s+1)],r=this.b64Lookup[t.charCodeAt(s+2)],u=this.b64Lookup[t.charCodeAt(s+3)],i[o++]=l<<2|c>>4,i[o++]=(c&15)<<4|r>>2,i[o++]=(r&3)<<6|u&63;return n}concatArrayBuffers(t){if(t.length===1)return t[0];let e=0;for(let o=0;o<t.length;o++)e+=t[o].byteLength;let n=new ArrayBuffer(e),i=new Uint8Array(n),s=0;for(let o=0;o<t.length;o++)i.set(new Uint8Array(t[o]),s),s+=t[o].byteLength;return n}pcmToAudioBuffer(t){const e=new Int16Array(t),n=new Float32Array(e.length);for(let s=0;s<e.length;s++)n[s]=e[s]>=32768?-(65536-e[s])/32768:e[s]/32767;const i=this.audioCtx.createBuffer(1,n.length,this.opt.pcmSampleRate);return i.copyToChannel(n,0,0),i}propsToThreeObjects(t){const e={};for(let[n,i]of Object.entries(t)){const s=n.split(".");let o=Array.isArray(i.x)?this.gaussianRandom(...i.x):i.x,l=Array.isArray(i.y)?this.gaussianRandom(...i.y):i.y,c=Array.isArray(i.z)?this.gaussianRandom(...i.z):i.z;s[1]==="position"||s[1]==="scale"?e[n]=new y.Vector3(o,l,c):s[1]==="rotation"?(n=s[0]+".quaternion",e[n]=new y.Quaternion().setFromEuler(new y.Euler(o,l,c,"XYZ")).normalize()):s[1]==="quaternion"&&(e[n]=new y.Quaternion(o,l,c,i.w).normalize())}return e}clearThree(t){for(;t.children.length;)this.clearThree(t.children[0]),t.remove(t.children[0]);t.geometry&&t.geometry.dispose(),t.material&&(Object.keys(t.material).forEach(e=>{t.material[e]&&t.material[e]!==null&&typeof t.material[e].dispose=="function"&&t.material[e].dispose()}),t.material.dispose())}addMixedMorphTarget(t,e,n,i=!1){t.forEach(s=>{if(!i&&s.morphTargetDictionary.hasOwnProperty(e))return;const o=s.geometry;let l=null,c=null;for(const[r,u]of Object.entries(n))if(s.morphTargetDictionary.hasOwnProperty(r)){const a=s.morphTargetDictionary[r],d=o.morphAttributes.position[a],h=o.morphAttributes.normal?.[a];l||(l=new y.Float32BufferAttribute(d.count*3,3),h&&(c=new y.Float32BufferAttribute(d.count*3,3)));for(let g=0;g<d.count;g++){const x=l.getX(g)+d.getX(g)*u,f=l.getY(g)+d.getY(g)*u,w=l.getZ(g)+d.getZ(g)*u;l.setXYZ(g,x,f,w)}if(h)for(let g=0;g<d.count;g++){const x=c.getX(g)+h.getX(g)*u,f=c.getY(g)+h.getY(g)*u,w=c.getZ(g)+h.getZ(g)*u;c.setXYZ(g,x,f,w)}}if(l){o.morphAttributes.position.push(l),c&&o.morphAttributes.normal.push(c);const r=o.morphAttributes.position.length-1;s.morphTargetInfluences[r]=0,s.morphTargetDictionary[e]=r}})}async showAvatar(t,e=null){if(!t||!t.hasOwnProperty("url"))throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");const n=new Ze.GLTFLoader;if(this.dracoEnabled){const r=new je.DRACOLoader;r.setDecoderPath(this.dracoDecoderPath),n.setDRACOLoader(r)}let i=await n.loadAsync(t.url,e);const s=[this.opt.modelRoot];if(this.posePropNames.forEach(r=>s.push(r.split(".")[0])),s.forEach(r=>{if(!i.scene.getObjectByName(r))throw new Error("Avatar object "+r+" not found")}),this.stop(),this.avatar=t,this.bodyMovement=t.bodyMovement||"idle",this.movementIntensity=t.movementIntensity||.5,this.showFullAvatar=t.showFullAvatar||!1,this.fbxAnimationLoader=null,this.dynamicbones.dispose(),this.mixer=null,this.isAvatarOnly?this.armature&&this.clearThree(this.armature):this.armature&&this.clearThree(this.scene),this.armature=i.scene.getObjectByName(this.opt.modelRoot),this.armature.scale.setScalar(1),this.animations=i.animations,this.userData=i.userData,this.morphs=[],this.armature.traverse(r=>{r.morphTargetInfluences&&r.morphTargetInfluences.length&&r.morphTargetDictionary&&this.morphs.push(r),r.frustumCulled=!1}),this.morphs.length===0)throw new Error("Blend shapes not found");const o=new Set(this.mtCustoms);this.morphs.forEach(r=>{Object.keys(r.morphTargetDictionary).forEach(u=>o.add(u))}),this.mtExtras.forEach(r=>{o.has(r.key)||(this.addMixedMorphTarget(this.morphs,r.key,r.mix),o.add(r.key))});const l={};if(o.forEach(r=>{l[r]={fixed:null,realtime:null,system:null,systemd:null,newvalue:null,ref:null,min:this.mtMinExceptions.hasOwnProperty(r)?this.mtMinExceptions[r]:this.mtMinDefault,max:this.mtMaxExceptions.hasOwnProperty(r)?this.mtMaxExceptions[r]:this.mtMaxDefault,easing:this.mtEasingDefault,base:null,v:0,needsUpdate:!0,acc:(this.mtAccExceptions.hasOwnProperty(r)?this.mtAccExceptions[r]:this.mtAccDefault)/1e3,maxv:(this.mtMaxVExceptions.hasOwnProperty(r)?this.mtMaxVExceptions[r]:this.mtMaxVDefault)/1e3,limit:this.mtLimits.hasOwnProperty(r)?this.mtLimits[r]:null,onchange:this.mtOnchange.hasOwnProperty(r)?this.mtOnchange[r]:null,baseline:this.avatar.baseline?.hasOwnProperty(r)?this.avatar.baseline[r]:this.mtBaselineExceptions.hasOwnProperty(r)?this.mtBaselineExceptions[r]:this.mtBaselineDefault,ms:[],is:[]},l[r].value=l[r].baseline,l[r].applied=l[r].baseline;const u=this.mtAvatar[r];u&&["fixed","system","systemd","realtime","base","v","value","applied"].forEach(a=>{l[r][a]=u[a]}),this.morphs.forEach(a=>{const d=a.morphTargetDictionary[r];d!==void 0&&(l[r].ms.push(a.morphTargetInfluences),l[r].is.push(d),a.morphTargetInfluences[d]=l[r].applied)})}),this.mtAvatar=l,this.poseAvatar={props:{}},this.posePropNames.forEach(r=>{const u=r.split("."),a=this.armature.getObjectByName(u[0]);this.poseAvatar.props[r]=a[u[1]],this.poseBase.props.hasOwnProperty(r)?this.poseAvatar.props[r].copy(this.poseBase.props[r]):this.poseBase.props[r]=this.poseAvatar.props[r].clone(),this.poseDelta.props.hasOwnProperty(r)&&!this.poseTarget.props.hasOwnProperty(r)&&(this.poseTarget.props[r]=this.poseAvatar.props[r].clone()),this.poseTarget.props[r].t=this.animClock,this.poseTarget.props[r].d=2e3}),this.ikMesh.traverse(r=>{r.isBone&&r.position.copy(this.armature.getObjectByName(r.name).position)}),this.isAvatarOnly?this.scene&&this.scene.add(this.armature):(this.scene.add(i.scene),this.scene.add(this.lightAmbient),this.scene.add(this.lightDirect),this.scene.add(this.lightSpot),this.lightSpot.target=this.armature.getObjectByName("Head")),t.hasOwnProperty("modelDynamicBones"))try{this.dynamicbones.setup(this.scene,this.armature,t.modelDynamicBones)}catch(r){console.error("Dynamic bones setup failed: "+r)}this.objectLeftToeBase=this.armature.getObjectByName("LeftToeBase"),this.objectRightToeBase=this.armature.getObjectByName("RightToeBase"),this.objectLeftEye=this.armature.getObjectByName("LeftEye"),this.objectRightEye=this.armature.getObjectByName("RightEye"),this.objectLeftArm=this.armature.getObjectByName("LeftArm"),this.objectRightArm=this.armature.getObjectByName("RightArm"),this.objectHips=this.armature.getObjectByName("Hips"),this.objectHead=this.armature.getObjectByName("Head"),this.objectNeck=this.armature.getObjectByName("Neck");const c=new y.Vector3;this.objectLeftEye.getWorldPosition(c),this.avatarHeight=c.y+.2,this.viewName||this.setView(this.opt.cameraView),this.setMood(this.avatar.avatarMood||this.moodName||this.opt.avatarMood),this.avatar.body==="M"&&this.poseTemplates.wide&&(this.poseName="wide",this.setPoseFromTemplate(this.poseTemplates.wide,0),console.log("Set initial male-appropriate pose: wide")),this.initializeFBXAnimationLoader(),this.bodyMovement&&this.bodyMovement!=="idle"&&this.applyBodyMovementAnimation(),this.start()}getViewNames(){return["full","mid","upper","head"]}getView(){return this.viewName}setView(t,e=null){if(t=t||this.viewName,t!=="full"&&t!=="upper"&&t!=="head"&&t!=="mid")return;if(!this.armature){this.opt.cameraView=t;return}if(this.viewName=t||this.viewName,e=e||{},this.isAvatarOnly)return;const n=e.hasOwnProperty("cameraX")?e.cameraX:this.opt.cameraX,i=e.hasOwnProperty("cameraY")?e.cameraY:this.opt.cameraY,s=e.hasOwnProperty("cameraDistance")?e.cameraDistance:this.opt.cameraDistance,o=e.hasOwnProperty("cameraRotateX")?e.cameraRotateX:this.opt.cameraRotateX,l=e.hasOwnProperty("cameraRotateY")?e.cameraRotateY:this.opt.cameraRotateY,c=this.camera.fov*(Math.PI/180);let r=-n*Math.tan(c/2),u=(1-i)*Math.tan(c/2),a=s;switch(this.viewName){case"head":a+=2,u=u*a+4*this.avatarHeight/5;break;case"upper":a+=4.5,u=u*a+2*this.avatarHeight/3;break;case"mid":a+=8,u=u*a+this.avatarHeight/3;break;default:a+=12,u=u*a}r=r*a,this.controlsEnd=new y.Vector3(r,u,0),this.cameraEnd=new y.Vector3(r,u,a).applyEuler(new y.Euler(o,l,0)),this.cameraClock===null&&(this.controls.target.copy(this.controlsEnd),this.camera.position.copy(this.cameraEnd)),this.controlsStart=this.controls.target.clone(),this.cameraStart=this.camera.position.clone(),this.cameraClock=0}setLighting(t){this.isAvatarOnly||(t=t||{},t.hasOwnProperty("lightAmbientColor")&&this.lightAmbient.color.set(new y.Color(t.lightAmbientColor)),t.hasOwnProperty("lightAmbientIntensity")&&(this.lightAmbient.intensity=t.lightAmbientIntensity,this.lightAmbient.visible=t.lightAmbientIntensity!==0),t.hasOwnProperty("lightDirectColor")&&this.lightDirect.color.set(new y.Color(t.lightDirectColor)),t.hasOwnProperty("lightDirectIntensity")&&(this.lightDirect.intensity=t.lightDirectIntensity,this.lightDirect.visible=t.lightDirectIntensity!==0),t.hasOwnProperty("lightDirectPhi")&&t.hasOwnProperty("lightDirectTheta")&&this.lightDirect.position.setFromSphericalCoords(2,t.lightDirectPhi,t.lightDirectTheta),t.hasOwnProperty("lightSpotColor")&&this.lightSpot.color.set(new y.Color(t.lightSpotColor)),t.hasOwnProperty("lightSpotIntensity")&&(this.lightSpot.intensity=t.lightSpotIntensity,this.lightSpot.visible=t.lightSpotIntensity!==0),t.hasOwnProperty("lightSpotPhi")&&t.hasOwnProperty("lightSpotTheta")&&(this.lightSpot.position.setFromSphericalCoords(2,t.lightSpotPhi,t.lightSpotTheta),this.lightSpot.position.add(new y.Vector3(0,1.5,0))),t.hasOwnProperty("lightSpotDispersion")&&(this.lightSpot.angle=t.lightSpotDispersion))}render(){this.isRunning&&!this.isAvatarOnly&&this.renderer&&this.renderer.render(this.scene,this.camera)}onResize(){!this.isAvatarOnly&&this.renderer&&(this.camera.aspect=this.nodeAvatar.clientWidth/this.nodeAvatar.clientHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.nodeAvatar.clientWidth,this.nodeAvatar.clientHeight),this.controls.update(),this.render())}updatePoseBase(t){for(const[e,n]of Object.entries(this.poseTarget.props)){const i=this.poseAvatar.props[e];if(i){let s=(t-n.t)/n.d;s>1||!this.poseBase.props.hasOwnProperty(e)?i.copy(n):i.isQuaternion?i.copy(this.poseBase.props[e].slerp(n,this.easing(s))):i.isVector3&&i.copy(this.poseBase.props[e].lerp(n,this.easing(s)))}}this.applyShoulderAdjustment()}applyShoulderAdjustment(){const t=new y.Euler,e=.6,n=.7;if(this.poseAvatar.props["LeftShoulder.quaternion"]){const i=this.poseAvatar.props["LeftShoulder.quaternion"];t.setFromQuaternion(i,"XYZ"),t.x>n?t.x=e:t.x>e&&(t.x=e+(t.x-e)*.2),i.setFromEuler(t,"XYZ")}if(this.poseAvatar.props["RightShoulder.quaternion"]){const i=this.poseAvatar.props["RightShoulder.quaternion"];t.setFromQuaternion(i,"XYZ"),t.x>n?t.x=e:t.x>e&&(t.x=e+(t.x-e)*.2),i.setFromEuler(t,"XYZ")}}applyShoulderAdjustmentToBones(){if(!this.armature)return;const t=this.armature.getObjectByName("LeftShoulder"),e=this.armature.getObjectByName("RightShoulder");if(!t||!e)return;const n=new y.Euler,i=new y.Quaternion,o=this.mixer&&this.currentFBXAction&&this.currentFBXAction.isRunning()?.5:.6,l=.7;if(t.quaternion){n.setFromQuaternion(t.quaternion,"XYZ");const c=n.x;n.x>l?n.x=l+(n.x-l)*(1-o):n.x>.5&&(n.x=n.x*(1-o*.5)),Math.abs(n.x-c)>.01&&(i.setFromEuler(n,"XYZ"),t.quaternion.copy(i),t.updateMatrixWorld(!0))}if(e.quaternion){n.setFromQuaternion(e.quaternion,"XYZ");const c=n.x;n.x>l?n.x=l+(n.x-l)*(1-o):n.x>.5&&(n.x=n.x*(1-o*.5)),Math.abs(n.x-c)>.01&&(i.setFromEuler(n,"XYZ"),e.quaternion.copy(i),e.updateMatrixWorld(!0))}}updatePoseDelta(){for(const[t,e]of Object.entries(this.poseDelta.props)){if(e.x===0&&e.y===0&&e.z===0)continue;G.set(e.x,e.y,e.z);const n=this.poseAvatar.props[t];n.isQuaternion?(J.setFromEuler(G),n.multiply(J)):n.isVector3&&n.add(G)}}updateMorphTargets(t){for(let[e,n]of Object.entries(this.mtAvatar)){if(!n.needsUpdate)continue;let i=null,s=null;if(n.fixed!==null){if(i=n.fixed,n.system=null,n.systemd=null,n.newvalue=null,n.ref&&n.ref.hasOwnProperty(e)&&delete n.ref[e],n.ref=null,n.base=null,n.value===i){n.needsUpdate=!1;continue}}else n.realtime!==null?(n.ref=null,n.base=null,s=n.realtime):n.system!==null?(i=n.system,n.newvalue=null,n.ref&&n.ref.hasOwnProperty(e)&&delete n.ref[e],n.ref=null,n.base=null,n.systemd!==null?n.systemd===0?(i=null,n.system=null,n.systemd=null):(n.systemd-=t,n.systemd<0&&(n.systemd=0),n.value===i&&(i=null)):n.value===i&&(i=null,n.system=null)):n.newvalue!==null?(n.ref=null,n.base=null,s=n.newvalue,n.newvalue=null):n.base!==null?(i=n.base,n.ref=null,n.value===i&&(i=null,n.base=null,n.needsUpdate=!1)):(n.ref=null,n.baseline!==null&&n.value!==n.baseline?(i=n.baseline,n.base=n.baseline):n.needsUpdate=!1);if(i!==null){let o=i-n.value;o>=0?o<.005?(s=i,n.v=0):(n.v<n.maxv&&(n.v+=n.acc*t),n.v>=0?s=n.value+o*(1-Math.exp(-n.v*t)):s=n.value+n.v*t*(1-Math.exp(n.v*t))):o>-.005?(s=i,n.v=0):(n.v>-n.maxv&&(n.v-=n.acc*t),n.v>=0?s=n.value+n.v*t*(1-Math.exp(-n.v*t)):s=n.value+o*(1-Math.exp(n.v*t)))}if(n.limit!==null){if(s!==null&&s!==n.value&&(n.value=s,n.onchange!==null&&n.onchange(s)),s=n.limit(n.value),s===n.applied)continue}else{if(s===null||s===n.value)continue;n.value=s,n.onchange!==null&&n.onchange(s)}switch(n.applied=s,n.applied<n.min&&(n.applied=n.min),n.applied>n.max&&(n.applied=n.max),e){case"headRotateX":this.poseDelta.props["Head.quaternion"].x=n.applied+this.mtAvatar.bodyRotateX.applied;break;case"headRotateY":this.poseDelta.props["Head.quaternion"].y=n.applied+this.mtAvatar.bodyRotateY.applied;break;case"headRotateZ":this.poseDelta.props["Head.quaternion"].z=n.applied+this.mtAvatar.bodyRotateZ.applied;break;case"bodyRotateX":this.poseDelta.props["Head.quaternion"].x=n.applied+this.mtAvatar.headRotateX.applied,this.poseDelta.props["Spine1.quaternion"].x=n.applied/2,this.poseDelta.props["Spine.quaternion"].x=n.applied/8,this.poseDelta.props["Hips.quaternion"].x=n.applied/24;break;case"bodyRotateY":this.poseDelta.props["Head.quaternion"].y=n.applied+this.mtAvatar.headRotateY.applied,this.poseDelta.props["Spine1.quaternion"].y=n.applied/2,this.poseDelta.props["Spine.quaternion"].y=n.applied/2,this.poseDelta.props["Hips.quaternion"].y=n.applied/4,this.poseDelta.props["LeftUpLeg.quaternion"].y=n.applied/2,this.poseDelta.props["RightUpLeg.quaternion"].y=n.applied/2,this.poseDelta.props["LeftLeg.quaternion"].y=n.applied/4,this.poseDelta.props["RightLeg.quaternion"].y=n.applied/4;break;case"bodyRotateZ":this.poseDelta.props["Head.quaternion"].z=n.applied+this.mtAvatar.headRotateZ.applied,this.poseDelta.props["Spine1.quaternion"].z=n.applied/12,this.poseDelta.props["Spine.quaternion"].z=n.applied/12,this.poseDelta.props["Hips.quaternion"].z=n.applied/24;break;case"handFistLeft":case"handFistRight":const o=e.substring(8);["HandThumb","HandIndex","HandMiddle","HandRing","HandPinky"].forEach((u,a)=>{a===0?(this.poseDelta.props[o+u+"1.quaternion"].x=0,this.poseDelta.props[o+u+"2.quaternion"].z=(o==="Left"?-1:1)*n.applied,this.poseDelta.props[o+u+"3.quaternion"].z=(o==="Left"?-1:1)*n.applied):(this.poseDelta.props[o+u+"1.quaternion"].x=n.applied,this.poseDelta.props[o+u+"2.quaternion"].x=1.5*n.applied,this.poseDelta.props[o+u+"3.quaternion"].x=1.5*n.applied)});break;case"chestInhale":const l=n.applied/20,c={x:l,y:l/2,z:3*l},r={x:1/(1+l)-1,y:1/(1+l/2)-1,z:1/(1+3*l)-1};this.poseDelta.props["Spine1.scale"]=c,this.poseDelta.props["Neck.scale"]=r,this.poseDelta.props["LeftArm.scale"]=r,this.poseDelta.props["RightArm.scale"]=r;break;default:for(let u=0,a=n.ms.length;u<a;u++)n.ms[u][n.is[u]]=n.applied}}}getPoseString(t,e=1e3){let n="{";return Object.entries(t).forEach((i,s)=>{const o=i[0].split(".");if(o[1]==="position"||o[1]==="rotation"||o[1]==="quaternion"){const l=o[1]==="quaternion"?o[0]+".rotation":i[0],c=i[1].isQuaternion?new y.Euler().setFromQuaternion(i[1]):i[1];n+=(s?", ":"")+"'"+l+"':{",n+="x:"+Math.round(c.x*e)/e,n+=", y:"+Math.round(c.y*e)/e,n+=", z:"+Math.round(c.z*e)/e,n+="}"}}),n+="}",n}getPoseTemplateProp(t){const e=t.split(".");let n=e[0]+"."+(e[1]==="rotation"?"quaternion":e[1]);if(this.gesture&&this.gesture.hasOwnProperty(n))return this.gesture[n].clone();{let i=e[0]+"."+(e[1]==="quaternion"?"rotation":e[1]);this.poseWeightOnLeft||(i.startsWith("Left")?(i="Right"+i.substring(4),n="Right"+n.substring(4)):i.startsWith("Right")&&(i="Left"+i.substring(5),n="Left"+n.substring(5)));let s;if(this.poseTarget.template.props.hasOwnProperty(n)){const o={};o[n]=this.poseTarget.template.props[n],s=this.propsToThreeObjects(o)[n]}else if(this.poseTarget.template.props.hasOwnProperty(i)){const o={};o[i]=this.poseTarget.template.props[i],s=this.propsToThreeObjects(o)[n]}return s&&!this.poseWeightOnLeft&&s.isQuaternion&&(s.x*=-1,s.w*=-1),s}}mirrorPose(t){const e={};for(let[n,i]of Object.entries(t))i.isQuaternion&&(n.startsWith("Left")?n="Right"+n.substring(4):n.startsWith("Right")&&(n="Left"+n.substring(5)),i.x*=-1,i.w*=-1),e[n]=i.clone(),e[n].t=i.t,e[n].d=i.d;return e}poseFactory(t,e=2e3){const n={template:t,props:this.propsToThreeObjects(t.props)};for(const[i,s]of Object.entries(n.props)){if(this.opt.modelMovementFactor<1&&t.standing&&(i==="Hips.quaternion"||i==="Spine.quaternion"||i==="Spine1.quaternion"||i==="Spine2.quaternion"||i==="Neck.quaternion"||i==="LeftUpLeg.quaternion"||i==="LeftLeg.quaternion"||i==="RightUpLeg.quaternion"||i==="RightLeg.quaternion")){const o=this.poseStraight[i],l=s.angleTo(o);s.rotateTowards(o,(1-this.opt.modelMovementFactor)*l)}s.t=this.animClock,s.d=e}return n}setPoseFromTemplate(t,e=2e3){const n=t&&this.poseTarget&&this.poseTarget.template&&(this.poseTarget.template.standing&&t.lying||this.poseTarget.template.lying&&t.standing),i=t&&t===this.poseCurrentTemplate,s=this.poseWeightOnLeft;let o=n?1e3:e;if(n?(this.poseCurrentTemplate=this.poseTemplates.oneknee,setTimeout(()=>{this.setPoseFromTemplate(t,e)},o)):this.poseCurrentTemplate=t||this.poseCurrentTemplate,this.poseTarget=this.poseFactory(this.poseCurrentTemplate,o),this.poseWeightOnLeft=!0,(!i&&!s||i&&s)&&(this.poseTarget.props=this.mirrorPose(this.poseTarget.props),this.poseWeightOnLeft=!this.poseWeightOnLeft),this.gesture)for(let[l,c]of Object.entries(this.gesture))this.poseTarget.props.hasOwnProperty(l)&&(this.poseTarget.props[l].copy(c),this.poseTarget.props[l].t=c.t,this.poseTarget.props[l].d=c.d);Object.keys(this.poseDelta.props).forEach(l=>{this.poseTarget.props.hasOwnProperty(l)||(this.poseTarget.props[l]=this.poseBase.props[l].clone(),this.poseTarget.props[l].t=this.animClock,this.poseTarget.props[l].d=o)})}getValue(t){return this.mtAvatar[t]?.value}setValue(t,e,n=null){this.mtAvatar.hasOwnProperty(t)&&Object.assign(this.mtAvatar[t],{system:e,systemd:n,needsUpdate:!0})}getMoodNames(){return Object.keys(this.animMoods)}getMood(){return this.opt.avatarMood}setMood(t){if(t=(t||"").trim().toLowerCase(),!this.animMoods.hasOwnProperty(t))throw new Error("Unknown mood.");this.moodName=t,this.mood=this.animMoods[this.moodName];for(let e of Object.keys(this.mtAvatar)){let n=this.mtBaselineExceptions.hasOwnProperty(e)?this.mtBaselineExceptions[e]:this.mtBaselineDefault;this.mood.baseline.hasOwnProperty(e)?n=this.mood.baseline[e]:this.avatar.baseline?.hasOwnProperty(e)&&(n=this.avatar.baseline[e]),this.setBaselineValue(e,n)}this.mood.anims.forEach(e=>{let n=this.animQueue.findIndex(i=>i.template.name===e.name);n!==-1&&this.animQueue.splice(n,1),this.animQueue.push(this.animFactory(e,-1))})}async initializeFBXAnimationLoader(){try{const{FBXAnimationLoader:t}=await Promise.resolve().then(()=>require("./fbxAnimationLoader-CNrfhJRz.cjs"));this.fbxAnimationLoader=new t(this.armature),console.log("FBX Animation Loader initialized")}catch(t){console.warn("FBX Animation Loader not available:",t),this.fbxAnimationLoader=null}}setBodyMovement(t){this.bodyMovement=t,this.avatar&&(this.avatar.bodyMovement=t),console.log("Body movement set to:",t),t==="idle"&&this.unlockAvatarPosition(),this.applyBodyMovementAnimation()}async applyBodyMovementAnimation(){if(!this.armature||!this.animQueue){console.log("Avatar not ready for body movement animations");return}console.log("Avatar is running:",this.isRunning),console.log("Animation queue exists:",!!this.animQueue);const t=this.animQueue.length;this.animQueue=this.animQueue.filter(i=>!i.template.name.startsWith("bodyMovement"));const e=this.animQueue.length;if(console.log(`Filtered animation queue: ${t} -> ${e} animations`),this.bodyMovement==="idle"){this.fbxAnimationLoader&&this.fbxAnimationLoader.stopCurrentAnimation();return}if(this.fbxAnimationLoader)try{await this.fbxAnimationLoader.playGestureAnimation(this.bodyMovement,this.movementIntensity),console.log("Applied FBX body movement animation:",this.bodyMovement);return}catch(i){console.warn("FBX animation failed, falling back to code animation:",i)}const n=this.createBodyMovementAnimation(this.bodyMovement);if(console.log("Created movement animation:",n),n)try{const i=this.animFactory(n,!0);i&&i.ts&&i.ts.length>0?(this.animQueue.push(i),console.log("Applied code-based body movement animation:",this.bodyMovement),console.log("Animation queue length:",this.animQueue.length),console.log("Animation object:",i)):(console.error("Invalid animation object created for:",this.bodyMovement),console.error("Animation object:",i))}catch(i){console.error("Error creating body movement animation:",i)}}lockAvatarPosition(){if(!this.armature){console.warn("Cannot lock position: armature not available");return}this.originalPosition||(this.originalPosition={x:this.armature.position.x,y:this.armature.position.y,z:this.armature.position.z},console.log("Original position stored:",this.originalPosition)),this.lockedPosition={x:this.armature.position.x,y:this.armature.position.y,z:this.armature.position.z},console.log("Avatar position locked at current position:",this.lockedPosition)}unlockAvatarPosition(){this.armature&&this.originalPosition?(this.armature.position.set(this.originalPosition.x,this.originalPosition.y,this.originalPosition.z),console.log("Avatar position restored to original:",this.originalPosition)):this.armature&&(this.armature.position.set(0,0,0),console.log("Avatar position reset to center (0,0,0)")),this.lockedPosition=null,this.originalPosition=null,console.log("Avatar position unlocked")}maintainLockedPosition(){this.lockedPosition&&this.armature&&this.armature.position.set(this.lockedPosition.x,this.lockedPosition.y,this.lockedPosition.z)}createBodyMovementAnimation(t){const e=this.movementIntensity||.5,n={walking:{name:"bodyMovement_walking",delay:[500,2e3],dt:[800,1200],vs:{bodyRotateY:[-.1*e,.1*e,0],bodyRotateZ:[-.05*e,.05*e,0],bodyRotateX:[-.02*e,.02*e,0]}},prancing:{name:"bodyMovement_prancing",delay:[300,1e3],dt:[400,800],vs:{bodyRotateY:[-.15*e,.15*e,0],bodyRotateZ:[-.08*e,.08*e,0],bodyRotateX:[-.05*e,.05*e,0]}},gesturing:{name:"bodyMovement_gesturing",delay:[400,1500],dt:[600,1e3],vs:{bodyRotateY:[-.08*e,.08*e,0],bodyRotateZ:[-.03*e,.03*e,0]}},dancing:{name:"bodyMovement_dancing",delay:[200,600],dt:[400,800],vs:{bodyRotateY:[-.25*e,.25*e,0],bodyRotateZ:[-.15*e,.15*e,0],bodyRotateX:[-.1*e,.1*e,0]}},dancing2:{name:"bodyMovement_dancing2",delay:[150,500],dt:[300,700],vs:{bodyRotateY:[-.3*e,.3*e,0],bodyRotateZ:[-.2*e,.2*e,0],bodyRotateX:[-.12*e,.12*e,0]}},dancing3:{name:"bodyMovement_dancing3",delay:[100,400],dt:[200,600],vs:{bodyRotateY:[-.35*e,.35*e,0],bodyRotateZ:[-.25*e,.25*e,0],bodyRotateX:[-.15*e,.15*e,0]}},excited:{name:"bodyMovement_excited",delay:[200,600],dt:[300,700],vs:{bodyRotateY:[-.12*e,.12*e,0],bodyRotateZ:[-.06*e,.06*e,0],bodyRotateX:[-.04*e,.04*e,0]}},happy:{name:"bodyMovement_happy",delay:[300,800],dt:[500,1e3],vs:{bodyRotateY:[-.08*e,.08*e,0],bodyRotateZ:[-.04*e,.04*e,0],bodyRotateX:[-.02*e,.02*e,0]}},surprised:{name:"bodyMovement_surprised",delay:[100,300],dt:[200,500],vs:{bodyRotateY:[-.05*e,.05*e,0],bodyRotateZ:[-.03*e,.03*e,0],bodyRotateX:[-.01*e,.01*e,0]}},thinking:{name:"bodyMovement_thinking",delay:[800,2e3],dt:[1e3,1500],vs:{bodyRotateY:[-.06*e,.06*e,0],bodyRotateZ:[-.03*e,.03*e,0],bodyRotateX:[-.02*e,.02*e,0]}},nodding:{name:"bodyMovement_nodding",delay:[400,800],dt:[300,600],vs:{bodyRotateX:[-.1*e,.1*e,0],bodyRotateY:[-.02*e,.02*e,0]}},shaking:{name:"bodyMovement_shaking",delay:[200,400],dt:[150,300],vs:{bodyRotateY:[-.15*e,.15*e,0],bodyRotateZ:[-.05*e,.05*e,0]}},celebration:{name:"bodyMovement_celebration",delay:[100,300],dt:[200,500],vs:{bodyRotateY:[-.2*e,.2*e,0],bodyRotateZ:[-.1*e,.1*e,0],bodyRotateX:[-.08*e,.08*e,0]}},energetic:{name:"bodyMovement_energetic",delay:[150,400],dt:[250,500],vs:{bodyRotateY:[-.18*e,.18*e,0],bodyRotateZ:[-.12*e,.12*e,0],bodyRotateX:[-.08*e,.08*e,0]}},swaying:{name:"bodyMovement_swaying",delay:[600,1200],dt:[800,1e3],vs:{bodyRotateY:[-.1*e,.1*e,0],bodyRotateZ:[-.05*e,.05*e,0]}},bouncing:{name:"bodyMovement_bouncing",delay:[300,600],dt:[400,700],vs:{bodyRotateY:[-.05*e,.05*e,0]}}};if(t==="dancing"){const i=["dancing","dancing2","dancing3"],s=i[Math.floor(Math.random()*i.length)];return n[s]||n.dancing}return n[t]||null}playRandomDance(){const t=["dancing","dancing2","dancing3"],e=t[Math.floor(Math.random()*t.length)];this.setBodyMovement(e)}playReaction(t){["happy","surprised","thinking","nodding","shaking","celebration","energetic","swaying","bouncing"].includes(t)?(this.setBodyMovement(t),["surprised","nodding","shaking","celebration"].includes(t)&&setTimeout(()=>{this.setBodyMovement("idle")},3e3)):console.warn("Invalid reaction type:",t)}playCelebration(){this.playReaction("celebration"),setTimeout(()=>{this.playRandomDance()},2e3)}setMovementIntensity(t){this.movementIntensity=Math.max(0,Math.min(1,t)),this.avatar&&(this.avatar.movementIntensity=this.movementIntensity),console.log("Movement intensity set to:",this.movementIntensity),this.fbxAnimationLoader&&this.fbxAnimationLoader.setIntensity(this.movementIntensity),this.applyBodyMovementAnimation()}setShowFullAvatar(t){this.showFullAvatar=t,this.avatar&&(this.avatar.showFullAvatar=t),console.log("Show full avatar set to:",t),t&&this.viewName!=="full"?(console.log("Changing camera view to full"),this.setView("full")):!t&&this.viewName!=="upper"?(console.log("Changing camera view to upper"),this.setView("upper")):console.log("Camera view already set to:",this.viewName)}getMorphTargetNames(){return["eyesRotateX","eyesRotateY",...Object.keys(this.mtAvatar)].sort()}getBaselineValue(t){if(t==="eyesRotateY"){const e=this.getBaselineValue("eyeLookOutLeft");if(e===void 0)return;const n=this.getBaselineValue("eyeLookInLeft");return n===void 0||this.getBaselineValue("eyeLookOutRight")===void 0||this.getBaselineValue("eyeLookInRight")===void 0?void 0:e-n}else if(t==="eyesRotateX"){const e=this.getBaselineValue("eyesLookDown");if(e===void 0)return;const n=this.getBaselineValue("eyesLookUp");return n===void 0?void 0:e-n}else return this.mtAvatar[t]?.baseline}setBaselineValue(t,e){t==="eyesRotateY"?(this.setBaselineValue("eyeLookOutLeft",e===null?null:e>0?e:0),this.setBaselineValue("eyeLookInLeft",e===null?null:e>0?0:-e),this.setBaselineValue("eyeLookOutRight",e===null?null:e>0?0:-e),this.setBaselineValue("eyeLookInRight",e===null?null:e>0?e:0)):t==="eyesRotateX"?(this.setBaselineValue("eyesLookDown",e===null?null:e>0?e:0),this.setBaselineValue("eyesLookUp",e===null?null:e>0?0:-e)):this.mtAvatar.hasOwnProperty(t)&&Object.assign(this.mtAvatar[t],{base:null,baseline:e,needsUpdate:!0})}getFixedValue(t){if(t==="eyesRotateY"){const e=this.getFixedValue("eyeLookOutLeft");if(e===null)return null;const n=this.getFixedValue("eyeLookInLeft");return n===null||this.getFixedValue("eyeLookOutRight")===null||this.getFixedValue("eyeLookInRight")===null?null:e-n}else if(t==="eyesRotateX"){const e=this.getFixedValue("eyesLookDown");if(e===null)return null;const n=this.getFixedValue("eyesLookUp");return n===null?null:e-n}else return this.mtAvatar[t]?.fixed}setFixedValue(t,e,n=null){t==="eyesRotateY"?(this.setFixedValue("eyeLookOutLeft",e===null?null:e>0?e:0,n),this.setFixedValue("eyeLookInLeft",e===null?null:e>0?0:-e,n),this.setFixedValue("eyeLookOutRight",e===null?null:e>0?0:-e,n),this.setFixedValue("eyeLookInRight",e===null?null:e>0?e:0,n)):t==="eyesRotateX"?(this.setFixedValue("eyesLookDown",e===null?null:e>0?e:0,n),this.setFixedValue("eyesLookUp",e===null?null:e>0?0:-e,n)):this.mtAvatar.hasOwnProperty(t)&&Object.assign(this.mtAvatar[t],{fixed:e,needsUpdate:!0})}animFactory(t,e=!1,n=1,i=1,s=!1){const o={template:t,ts:[0],vs:{}};let l=t;for(;;)if(l.hasOwnProperty(this.stateName))(this.stateName==="speaking"||this.stateName==="idle")&&console.log("Selected state:",this.stateName,"for avatar body:",this.avatar?.body),l=l[this.stateName];else if(l.hasOwnProperty(this.moodName))l=l[this.moodName];else if(l.hasOwnProperty(this.poseName))l=l[this.poseName];else if(l.hasOwnProperty(this.viewName))l=l[this.viewName];else if(this.avatar&&this.avatar.body&&l.hasOwnProperty(this.avatar.body))console.log("Applying gender-specific override:",this.avatar.body,"for state:",this.stateName,"keys:",Object.keys(l)),l=l[this.avatar.body];else if(l.hasOwnProperty("alt")){let r=l.alt[0];if(l.alt.length>1){const u=Math.random();let a=0;for(let d=0;d<l.alt.length;d++){let h=this.valueFn(l.alt[d].p);if(a+=h===void 0?(1-a)/(l.alt.length-1-d):h,u<a){r=l.alt[d];break}}}l=r,this.avatar&&this.avatar.body&&l.hasOwnProperty(this.avatar.body)&&console.log("Found gender override in selected alternative:",this.avatar.body,"keys:",Object.keys(l));continue}else break;let c=this.valueFn(l.delay)||0;if(Array.isArray(c)&&(c=this.gaussianRandom(...c)),l.hasOwnProperty("dt"))l.dt.forEach((r,u)=>{let a=this.valueFn(r);Array.isArray(a)&&(a=this.gaussianRandom(...a)),o.ts[u+1]=o.ts[u]+a});else{let r=Object.values(l.vs).reduce((u,a)=>a.length>u?a.length:u,0);o.ts=Array(r+1).fill(0)}s?o.ts=o.ts.map(r=>c+r*n):o.ts=o.ts.map(r=>this.animClock+c+r*n),l.vs&&l.vs.pose&&console.log("Pose being selected from vs.pose:",l.vs.pose,"for avatar body:",this.avatar?.body);for(let[r,u]of Object.entries(l.vs)){const a=this.getBaselineValue(r),d=u.map(h=>(h=this.valueFn(h),h===null?null:typeof h=="function"?h:typeof h=="string"||h instanceof String?r==="pose"&&this.avatar&&this.avatar.body==="M"&&(h==="hip"||h==="side")?(console.log("Intercepting pose",h,"in animation factory, overriding to wide for male avatar"),"wide"):h.slice():Array.isArray(h)?r==="gesture"?h.slice():(a===void 0?0:a)+i*this.gaussianRandom(...h):typeof h=="boolean"?h:h instanceof Object&&h.constructor===Object?Object.assign({},h):(a===void 0?0:a)+i*h));r==="eyesRotateY"?(o.vs.eyeLookOutLeft=[null,...d.map(h=>h>0?h:0)],o.vs.eyeLookInLeft=[null,...d.map(h=>h>0?0:-h)],o.vs.eyeLookOutRight=[null,...d.map(h=>h>0?0:-h)],o.vs.eyeLookInRight=[null,...d.map(h=>h>0?h:0)]):r==="eyesRotateX"?(o.vs.eyesLookDown=[null,...d.map(h=>h>0?h:0)],o.vs.eyesLookUp=[null,...d.map(h=>h>0?0:-h)]):o.vs[r]=[null,...d]}for(let r of Object.keys(o.vs))for(;o.vs[r].length<=o.ts.length;)o.vs[r].push(o.vs[r][o.vs[r].length-1]);return t.hasOwnProperty("mood")&&(o.mood=this.valueFn(t.mood).slice()),e&&(o.loop=e),o}valueAnimationSeq(t,e,n,i,s,o=null){t=this.valueFn(t),e=this.valueFn(e),s<n&&(s=n),s>i&&(s=i);let l=(e-t)/(i-n);return o&&(l*=o((s-n)/(i-n))),l*s+(t-l*n)}gaussianRandom(t,e,n=1,i=5){let s=0;for(let o=0;o<i;o++)s+=Math.random();return t+Math.pow(s/i,n)*(e-t)}sigmoidFactory(t){function e(i){return 1/(1+Math.exp(-t*i))-.5}var n=.5/e(1);return function(i){return n*e(2*Math.max(Math.min(i,1),0)-1)+.5}}convertRange(t,e,n){return(t-e[0])*(n[1]-n[0])/(e[1]-e[0])+n[0]}animate(t){if(!this.isRunning)return;let e;if(this.isAvatarOnly)e=t;else{if(requestAnimationFrame(this.animate.bind(this)),e=t-this.animTimeLast,e<this.animFrameDur)return;this.animTimeLast=t}e=e/this.animSlowdownRate,this.animClock+=e,this.maintainLockedPosition();let n,i,s,o,l=0;if(this.stats&&this.stats.begin(),this.isListening){for(this.listeningAnalyzer.getByteFrequencyData(this.volumeFrequencyData),n=2,s=10;n<s;n++)this.volumeFrequencyData[n]>l&&(l=this.volumeFrequencyData[n]);this.listeningVolume=(this.listeningVolume+l)/2,this.listeningActive?(this.listeningTimerTotal+=e,this.listeningVolume<this.listeningSilenceThresholdLevel?(this.listeningTimer+=e,this.listeningTimer>this.listeningSilenceThresholdMs&&(this.listeningOnchange&&this.listeningOnchange("stop",this.listeningTimer),this.listeningActive=!1,this.listeningTimer=0,this.listeningTimerTotal=0)):this.listeningTimer*=.5,this.listeningTimerTotal>this.listeningActiveDurationMax&&(this.listeningOnchange&&this.listeningOnchange("maxactive"),this.listeningTimerTotal=0)):(this.listeningTimerTotal+=e,this.listeningVolume>this.listeningActiveThresholdLevel?(this.listeningTimer+=e,this.listeningTimer>this.listeningActiveThresholdMs&&(this.listeningOnchange&&this.listeningOnchange("start"),this.listeningActive=!0,this.listeningTimer=0,this.listeningTimerTotal=0)):this.listeningTimer*=.5,this.listeningTimerTotal>this.listeningSilenceDurationMax&&(this.listeningOnchange&&this.listeningOnchange("maxsilence"),this.listeningTimerTotal=0))}if(this.isSpeaking)for(l=0,this.audioAnalyzerNode.getByteFrequencyData(this.volumeFrequencyData),n=2,s=10;n<s;n++)this.volumeFrequencyData[n]>l&&(l=this.volumeFrequencyData[n]);let c=null,r=null;const u=[];for(n=0,s=this.animQueue.length;n<s;n++){const a=this.animQueue[n];if(!(!a||!a.ts||!a.ts.length||this.animClock<a.ts[0])){for(i=a.ndx||0,o=a.ts.length;i<o&&!(this.animClock<a.ts[i]);i++)for(let[d,h]of Object.entries(a.vs))if(this.mtAvatar.hasOwnProperty(d)){if(h[i+1]===null)continue;const g=this.mtAvatar[d];if(h[i]===null&&(h[i]=g.value),i===o-1)g.newvalue=h[i];else{g.newvalue=h[i+1];const x=a.ts[i+1]-a.ts[i];let f=1;x>1e-4&&(f=(this.animClock-a.ts[i])/x),f<1&&(g.easing&&(f=g.easing(f)),g.newvalue=(1-f)*h[i]+f*g.newvalue),g.ref&&g.ref!==a.vs&&g.ref.hasOwnProperty(d)&&delete g.ref[d],g.ref=a.vs}if(l)switch(d){case"viseme_aa":case"viseme_E":case"viseme_I":case"viseme_O":case"viseme_U":g.newvalue*=1+l/255-.5}g.needsUpdate=!0}else d==="eyeContact"&&h[i]!==null&&c!==!1?c=!!h[i]:d==="headMove"&&h[i]!==null&&r!==!1?h[i]===0?r=!1:(Math.random()<h[i]&&(r=!0),h[i]=null):h[i]!==null&&(u.push({mt:d,val:h[i]}),h[i]=null);i===o?(a.hasOwnProperty("mood")&&this.setMood(a.mood),a.loop?(o=this.isSpeaking&&(a.template.name==="head"||a.template.name==="eyes")?4:1,this.animQueue[n]=this.animFactory(a.template,a.loop>0?a.loop-1:a.loop,1,1/o)):(this.animQueue.splice(n--,1),s--)):a.ndx=i-1}}for(let a=0,d=u.length;a<d;a++)switch(i=u[a].val,u[a].mt){case"speak":this.speakText(i);break;case"subtitles":this.onSubtitles&&typeof this.onSubtitles=="function"&&this.onSubtitles(i);break;case"pose":this.avatar&&this.avatar.body==="M"&&(i==="hip"||i==="side")&&this.poseTemplates.wide&&(i="wide",console.log("Overriding pose",i==="hip"?"hip":"side","to wide for male avatar")),this.poseName=i,console.log("Setting pose to:",this.poseName,"for avatar body:",this.avatar?.body,"state:",this.stateName),this.setPoseFromTemplate(this.poseTemplates[this.poseName]);break;case"gesture":this.playGesture(...i);break;case"function":i&&typeof i=="function"&&i();break;case"moveto":Object.entries(i.props).forEach(h=>{h[1]?this.poseTarget.props[h[0]].copy(h[1]):this.poseTarget.props[h[0]].copy(this.getPoseTemplateProp(h[0])),this.poseTarget.props[h[0]].t=this.animClock,this.poseTarget.props[h[0]].d=h[1]&&h[1].d?h[1].d:h.duration||2e3});break;case"handLeft":this.ikSolve({iterations:20,root:"LeftShoulder",effector:"LeftHandMiddle1",links:[{link:"LeftHand",minx:-.5,maxx:.5,miny:-1,maxy:1,minz:-.5,maxz:.5},{link:"LeftForeArm",minx:-.5,maxx:1.5,miny:-1.5,maxy:1.5,minz:-.5,maxz:3},{link:"LeftArm",minx:-1.5,maxx:1.5,miny:0,maxy:0,minz:-1,maxz:3}]},i.x?new y.Vector3(i.x,i.y,i.z):null,!0,i.d);break;case"handRight":this.ikSolve({iterations:20,root:"RightShoulder",effector:"RightHandMiddle1",links:[{link:"RightHand",minx:-.5,maxx:.5,miny:-1,maxy:1,minz:-.5,maxz:.5,maxAngle:.1},{link:"RightForeArm",minx:-.5,maxx:1.5,miny:-1.5,maxy:1.5,minz:-3,maxz:.5,maxAngle:.2},{link:"RightArm",minx:-1.5,maxx:1.5,miny:0,maxy:0,minz:-1,maxz:3}]},i.x?new y.Vector3(i.x,i.y,i.z):null,!0,i.d);break}if((c||r)&&(G.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]),G.x=Math.max(-.9,Math.min(.9,2*G.x-.5)),G.y=Math.max(-.9,Math.min(.9,-2.5*G.y)),c?(Object.assign(this.mtAvatar.eyesLookDown,{system:G.x<0?-G.x:0,needsUpdate:!0}),Object.assign(this.mtAvatar.eyesLookUp,{system:G.x<0?0:G.x,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookInLeft,{system:G.y<0?-G.y:0,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookOutLeft,{system:G.y<0?0:G.y,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookInRight,{system:G.y<0?0:G.y,needsUpdate:!0}),Object.assign(this.mtAvatar.eyeLookOutRight,{system:G.y<0?-G.y:0,needsUpdate:!0}),r&&(n=-this.mtAvatar.bodyRotateY.value,i=this.gaussianRandom(-.2,.2),this.animQueue.push(this.animFactory({name:"headmove",dt:[[1e3,2e3],[1e3,2e3,1,2],[1e3,2e3],[1e3,2e3,1,2]],vs:{headRotateY:[n,n,0],headRotateX:[i,i,0],headRotateZ:[-n/4,-n/4,0]}})))):(n=this.mtAvatar.eyeLookInLeft.value-this.mtAvatar.eyeLookOutLeft.value,i=this.gaussianRandom(-.2,.2),this.animQueue.push(this.animFactory({name:"headmove",dt:[[1e3,2e3],[1e3,2e3,1,2],[1e3,2e3],[1e3,2e3,1,2]],vs:{headRotateY:[null,n,n,0],headRotateX:[null,i,i,0],headRotateZ:[null,-n/4,-n/4,0],eyeLookInLeft:[null,0],eyeLookOutLeft:[null,0],eyeLookInRight:[null,0],eyeLookOutRight:[null,0],eyeContact:[0]}})))),e>2*this.animFrameDur&&(e=2*this.animFrameDur),(this.viewName!=="full"||this.isAvatarOnly)&&(n=this.mtRandomized[Math.floor(Math.random()*this.mtRandomized.length)],i=this.mtAvatar[n],i.needsUpdate||Object.assign(i,{base:(this.mood.baseline[n]||0)+(1+l/255)*Math.random()/5,needsUpdate:!0})),this.updatePoseBase(this.animClock),this.mixer&&this.mixer.update(e/1e3*this.mixer.timeScale),this.updatePoseDelta(),this.applyShoulderAdjustmentToBones(),(this.isSpeaking||this.isListening)&&c?l>this.volumeMax?(this.volumeHeadBase=.05,Math.random()>.6&&(this.volumeHeadTarget=-.05-Math.random()/15),this.volumeMax=l):(this.volumeMax*=.92,this.volumeHeadTarget=this.volumeHeadBase-.9*(this.volumeHeadBase-this.volumeHeadTarget)):(this.volumeHeadTarget=0,this.volumeMax=0),n=this.volumeHeadTarget-this.volumeHeadCurrent,i=Math.abs(n),i>1e-4&&(o=i*(this.volumeHeadEasing(Math.min(1,this.volumeHeadVelocity*e/1e3/i)/2+.5)-.5),this.volumeHeadCurrent+=Math.sign(n)*Math.min(i,o)),Math.abs(this.volumeHeadCurrent)>1e-4&&(J.setFromAxisAngle(dt,this.volumeHeadCurrent),this.objectNeck.quaternion.multiply(J)),De.setFromObject(this.armature),this.objectLeftToeBase.getWorldPosition(fe),fe.sub(this.armature.position),this.objectRightToeBase.getWorldPosition(xe),xe.sub(this.armature.position),this.objectHips.position.y-=De.min.y/2,this.objectHips.position.x-=(fe.x+xe.x)/4,this.objectHips.position.z-=(fe.z+xe.z)/2,this.dynamicbones.update(e),this.fbxAnimationLoader&&this.fbxAnimationLoader.update(),this.opt.update&&this.opt.update(e),this.updateMorphTargets(e),this.isAvatarOnly)this.stats&&this.stats.end();else{if(this.cameraClock!==null&&this.cameraClock<1e3){this.cameraClock+=e,this.cameraClock>1e3&&(this.cameraClock=1e3);let a=new y.Spherical().setFromVector3(this.cameraStart),d=new y.Spherical().setFromVector3(this.cameraEnd);a.phi+=this.easing(this.cameraClock/1e3)*(d.phi-a.phi),a.theta+=this.easing(this.cameraClock/1e3)*(d.theta-a.theta),a.radius+=this.easing(this.cameraClock/1e3)*(d.radius-a.radius),a.makeSafe(),this.camera.position.setFromSpherical(a),this.controlsStart.x!==this.controlsEnd.x?this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd,this.easing(this.cameraClock/1e3))):(a.setFromVector3(this.controlsStart),d.setFromVector3(this.controlsEnd),a.phi+=this.easing(this.cameraClock/1e3)*(d.phi-a.phi),a.theta+=this.easing(this.cameraClock/1e3)*(d.theta-a.theta),a.radius+=this.easing(this.cameraClock/1e3)*(d.radius-a.radius),a.makeSafe(),this.controls.target.setFromSpherical(a)),this.controls.update()}this.controls.autoRotate&&this.controls.update(),this.stats&&this.stats.end(),this.render()}}resetLips(){this.visemeNames.forEach(t=>{this.morphs.forEach(e=>{const n=e.morphTargetDictionary["viseme_"+t];n!==void 0&&(e.morphTargetInfluences[n]=0)})})}lipsyncGetProcessor(t,e="./"){if(!this.lipsync.hasOwnProperty(t)){const n=t.toLowerCase(),i="Lipsync"+t.charAt(0).toUpperCase()+t.slice(1);try{const s=Oe[n];s&&s[i]?(this.lipsync[t]=new s[i],console.log(`Loaded lip-sync module for ${t}`)):console.warn(`Lip-sync module for ${t} not found. Available modules:`,Object.keys(Oe))}catch(s){console.warn(`Failed to load lip-sync module for ${t}:`,s)}}}lipsyncPreProcessText(t,e){return(this.lipsync[e]||Object.values(this.lipsync)[0]).preProcessText(t)}lipsyncWordsToVisemes(t,e){return(this.lipsync[e]||Object.values(this.lipsync)[0]).wordsToVisemes(t)}speakText(t,e=null,n=null,i=null){e=e||{};const s=/[!\.\?\n\p{Extended_Pictographic}]/ug,o=/[ ]/ug,l=/[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug,c=/[\p{Extended_Pictographic}]/ug,r=e.lipsyncLang||this.avatar.lipsyncLang||this.opt.lipsyncLang;let u="",a="",d=0,h=[],g=[];const x=Array.from(this.segmenter.segment(t),f=>f.segment);for(let f=0;f<x.length;f++){const w=f===x.length-1,D=x[f].match(l);let p=x[f].match(s);const O=x[f].match(c),M=x[f].match(o);if(p&&!w&&!O&&x[f+1].match(s)&&(p=!1),n&&(u+=x[f]),D&&(!i||i.every(I=>f<I[0]||f>I[1]))&&(a+=x[f]),(M||p||w)&&(a.length&&(a=this.lipsyncPreProcessText(a,r),a.length&&h.push({mark:d,word:a})),u.length&&(g.push({mark:d,template:{name:"subtitles"},ts:[0],vs:{subtitles:[u]}}),u=""),a.length)){const I=this.lipsyncWordsToVisemes(a,r);if(I&&I.visemes&&I.visemes.length){const S=I.times[I.visemes.length-1]+I.durations[I.visemes.length-1];for(let A=0;A<I.visemes.length;A++)g.push({mark:d,template:{name:"viseme"},ts:[(I.times[A]-.6)/S,(I.times[A]+.5)/S,(I.times[A]+I.durations[A]+.5)/S],vs:{["viseme_"+I.visemes[A]]:[null,I.visemes[A]==="PP"||I.visemes[A]==="FF"?.9:.6,0]}})}a="",d++}if(p||w){if(h.length||w&&g.length){const I={anim:g};n&&(I.onSubtitles=n),h.length&&!e.avatarMute&&(I.text=h,e.avatarMood&&(I.mood=e.avatarMood),e.ttsLang&&(I.lang=e.ttsLang),e.ttsVoice&&(I.voice=e.ttsVoice),e.ttsRate&&(I.rate=e.ttsRate),e.ttsVoice&&(I.pitch=e.ttsPitch),e.ttsVolume&&(I.volume=e.ttsVolume)),this.speechQueue.push(I),h=[],a="",d=0,g=[]}if(O){let I=this.animEmojis[x[f]];I&&I.link&&(I=this.animEmojis[I.link]),I&&this.speechQueue.push({emoji:I})}this.speechQueue.push({break:100})}}this.speechQueue.push({break:1e3}),this.startSpeaking()}async speakEmoji(t){let e=this.animEmojis[t];e&&e.link&&(e=this.animEmojis[e.link]),e&&this.speechQueue.push({emoji:e}),this.startSpeaking()}async speakBreak(t){this.speechQueue.push({break:t}),this.startSpeaking()}async speakMarker(t){this.speechQueue.push({marker:t}),this.startSpeaking()}async playBackgroundAudio(t){let n=await(await fetch(t)).arrayBuffer();this.stopBackgroundAudio(),this.audioBackgroundSource=this.audioCtx.createBufferSource(),this.audioBackgroundSource.loop=!0,this.audioBackgroundSource.buffer=await this.audioCtx.decodeAudioData(n),this.audioBackgroundSource.playbackRate.value=1/this.animSlowdownRate,this.audioBackgroundSource.connect(this.audioBackgroundGainNode),this.audioBackgroundSource.start(0)}stopBackgroundAudio(){try{this.audioBackgroundSource.stop()}catch{}this.audioBackgroundSource.disconnect()}async setReverb(t=null){if(t){let n=await(await fetch(t)).arrayBuffer();this.audioReverbNode.buffer=await this.audioCtx.decodeAudioData(n)}else{const e=this.audioCtx.sampleRate,n=this.audioCtx.createBuffer(2,e,e);n.getChannelData(0)[0]=1,n.getChannelData(1)[0]=1,this.audioReverbNode.buffer=n}}setMixerGain(t,e=null,n=0){t!==null&&(this.audioSpeechGainNode.gain.cancelScheduledValues(this.audioCtx.currentTime),n?(this.audioSpeechGainNode.gain.setValueAtTime(Math.max(this.audioSpeechGainNode.gain.value,1e-4),this.audioCtx.currentTime),this.audioSpeechGainNode.gain.exponentialRampToValueAtTime(Math.max(t,1e-4),this.audioCtx.currentTime+n)):this.audioSpeechGainNode.gain.setValueAtTime(t,this.audioCtx.currentTime)),e!==null&&(this.audioBackgroundGainNode.gain.cancelScheduledValues(this.audioCtx.currentTime),n?(this.audioBackgroundGainNode.gain.setValueAtTime(Math.max(this.audioBackgroundGainNode.gain.value,1e-4),this.audioCtx.currentTime),this.audioBackgroundGainNode.gain.exponentialRampToValueAtTime(Math.max(e,1e-4),this.audioCtx.currentTime+n)):this.audioBackgroundGainNode.gain.setValueAtTime(e,this.audioCtx.currentTime))}speakAudio(t,e=null,n=null){e=e||{};const i=e.lipsyncLang||this.avatar.lipsyncLang||this.opt.lipsyncLang,s={};if(t.words){let o=[];for(let l=0;l<t.words.length;l++){const c=t.words[l],r=t.wtimes[l];let u=t.wdurations[l];if(c.length&&(n&&o.push({template:{name:"subtitles"},ts:[r],vs:{subtitles:[" "+c]}}),!t.visemes)){const a=this.lipsyncPreProcessText(c,i),d=this.lipsyncWordsToVisemes(a,i);if(d&&d.visemes&&d.visemes.length){const h=d.times[d.visemes.length-1]+d.durations[d.visemes.length-1],g=Math.min(u,Math.max(0,u-d.visemes.length*150));let x=.6+this.convertRange(g,[0,u],[0,.4]);if(u=Math.min(u,d.visemes.length*200),h>0)for(let f=0;f<d.visemes.length;f++){const w=r+d.times[f]/h*u,D=d.durations[f]/h*u;o.push({template:{name:"viseme"},ts:[w-Math.min(60,2*D/3),w+Math.min(25,D/2),w+D+Math.min(60,D/2)],vs:{["viseme_"+d.visemes[f]]:[null,d.visemes[f]==="PP"||d.visemes[f]==="FF"?.9:x,0]}})}}}}if(t.visemes)for(let l=0;l<t.visemes.length;l++){const c=t.visemes[l],r=t.vtimes[l],u=t.vdurations[l];o.push({template:{name:"viseme"},ts:[r-2*u/3,r+u/2,r+u+u/2],vs:{["viseme_"+c]:[null,c==="PP"||c==="FF"?.9:.6,0]}})}if(t.markers)for(let l=0;l<t.markers.length;l++){const c=t.markers[l],r=t.mtimes[l];o.push({template:{name:"markers"},ts:[r],vs:{function:[c]}})}o.length&&(s.anim=o)}if(t.audio&&(s.audio=t.audio),t.anim?.name){let o=this.animFactory(t.anim,!1,1,1,!0);s.anim?s.anim.push(o):s.anim=[o]}n&&(s.onSubtitles=n),e.isRaw&&(s.isRaw=!0),Object.keys(s).length&&(this.speechQueue.push(s),s.isRaw||this.speechQueue.push({break:300}),this.startSpeaking())}async playAudio(t=!1){if(!(!this.armature||this.isAudioPlaying&&!t))if(this.isAudioPlaying=!0,this.audioPlaylist.length){const e=this.audioPlaylist.shift();if(this.audioCtx.state==="suspended"||this.audioCtx.state==="interrupted"){const s=this.audioCtx.resume(),o=new Promise((l,c)=>setTimeout(()=>c("p2"),1e3));try{await Promise.race([s,o])}catch{console.log("Can't play audio. Web Audio API suspended. This is often due to calling some speak method before the first user action, which is typically prevented by the browser."),this.playAudio(!0);return}}let n;if(Array.isArray(e.audio)){let s=this.concatArrayBuffers(e.audio);n=this.pcmToAudioBuffer(s)}else n=e.audio;this.audioSpeechSource=this.audioCtx.createBufferSource(),this.audioSpeechSource.buffer=n,this.audioSpeechSource.playbackRate.value=1/this.animSlowdownRate,this.audioSpeechSource.connect(this.audioAnalyzerNode),this.audioSpeechSource.addEventListener("ended",()=>{this.audioSpeechSource.disconnect(),this.playAudio(!0)},{once:!0});let i=0;e.anim&&(e.isRaw||(i=Math.abs(Math.min(0,...e.anim.map(s=>Math.min(...s.ts))))),e.anim.forEach(s=>{for(let o=0;o<s.ts.length;o++)s.ts[o]=this.animClock+s.ts[o]+i;this.animQueue.push(s)})),this.audioSpeechSource.start(i/1e3)}else this.isAudioPlaying=!1,this.startSpeaking(!0)}async synthesizeWithBrowserTTS(t){return new Promise((e,n)=>{const i=t.text.map(p=>p.word).join(" "),s=new SpeechSynthesisUtterance(i),o=t.lang||this.avatar.ttsLang||this.opt.ttsLang||"en-US",l=(t.rate||this.avatar.ttsRate||this.opt.ttsRate||1)+this.mood.speech.deltaRate,c=(t.pitch||this.avatar.ttsPitch||this.opt.ttsPitch||1)+this.mood.speech.deltaPitch,r=(t.volume||this.avatar.ttsVolume||this.opt.ttsVolume||1)+this.mood.speech.deltaVolume;s.lang=o,s.rate=Math.max(.1,Math.min(10,l)),s.pitch=Math.max(0,Math.min(2,c)),s.volume=Math.max(0,Math.min(1,r));const u=speechSynthesis.getVoices(),a=t.voice||this.avatar.ttsVoice||this.opt.ttsVoice;if(a&&u.length>0){const p=u.find(O=>O.name.includes(a)||O.lang===o);p&&(s.voice=p)}const d=i.length*100/s.rate,h=this.audioCtx.createBuffer(1,this.audioCtx.sampleRate*(d/1e3),this.audioCtx.sampleRate),g=this.avatar.lipsyncLang||this.opt.lipsyncLang||"en",x=this.lipsyncPreProcessText(i,g),f=this.lipsyncWordsToVisemes(x,g);console.log("Browser TTS Lip-sync Debug:",{text:i,lipsyncLang:g,processedText:x,lipsyncData:f,hasVisemes:f&&f.visemes&&f.visemes.length>0,estimatedDuration:d});const w=[];if(f&&f.visemes&&f.visemes.length>0){const p=f.times[f.visemes.length-1]+f.durations[f.visemes.length-1];for(let O=0;O<f.visemes.length;O++){const M=f.visemes[O],I=f.times[O]/p,S=f.durations[O]/p,A=I*d,z=S*d;w.push({template:{name:"viseme"},ts:[A-Math.min(60,2*z/3),A+Math.min(25,z/2),A+z+Math.min(60,z/2)],vs:{["viseme_"+M]:[null,M==="PP"||M==="FF"?.9:.6,0]}})}}const D=[...t.anim,...w];this.audioPlaylist.push({anim:D,audio:h}),this.onSubtitles=t.onSubtitles||null,this.resetLips(),t.mood&&this.setMood(t.mood),this.playAudio(),s.onend=()=>{e()},s.onerror=p=>{console.error("Speech synthesis error:",p.error),n(p.error)},speechSynthesis.speak(s)})}async synthesizeWithElevenLabsTTS(t){const e=t.text.map(d=>d.word).join(" "),n=t.voice||this.avatar.ttsVoice||this.opt.ttsVoice||"21m00Tcm4TlvDq8ikWAM",i={text:e,model_id:"eleven_monolingual_v1",voice_settings:{stability:.5,similarity_boost:.5,style:0,use_speaker_boost:!0}},s=await fetch(`${this.opt.ttsEndpoint}/${n}`,{method:"POST",headers:{Accept:"audio/mpeg","Content-Type":"application/json","xi-api-key":this.opt.ttsApikey},body:JSON.stringify(i)});if(!s.ok)throw new Error(`ElevenLabs TTS error: ${s.status} ${s.statusText}`);const o=await s.arrayBuffer(),l=await this.audioCtx.decodeAudioData(o);console.log("Using text-based lip-sync for debugging...");const c=this.avatar.lipsyncLang||this.opt.lipsyncLang||"en";let r;try{console.log("Lip-sync modules available:",{hasLipsync:!!this.lipsync,lipsyncKeys:this.lipsync?Object.keys(this.lipsync):[],lipsyncLang:c});const d=this.lipsyncPreProcessText(e,c),h=this.lipsyncWordsToVisemes(d,c);if(console.log("Lip-sync data:",{processedText:d,lipsyncData:h,hasVisemes:h&&h.visemes&&h.visemes.length>0}),h&&h.visemes&&h.visemes.length>0)r={visemes:h.visemes.map((g,x)=>({viseme:g,startTime:x*l.duration/h.visemes.length,endTime:(x+1)*l.duration/h.visemes.length,duration:l.duration/h.visemes.length,intensity:.7})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}};else throw new Error("No visemes generated from text")}catch(d){console.error("Text-based lip-sync failed, using fallback:",d);const h=e.toLowerCase().split(/\s+/),g=[];for(const x of h)for(const f of x){let w="aa";"aeiou".includes(f)?w="aa":"bp".includes(f)?w="PP":"fv".includes(f)?w="FF":"st".includes(f)?w="SS":"dln".includes(f)?w="DD":"kg".includes(f)?w="kk":"rw".includes(f)&&(w="RR"),g.push(w)}r={visemes:g.map((x,f)=>({viseme:x,startTime:f*l.duration/g.length,endTime:(f+1)*l.duration/g.length,duration:l.duration/g.length,intensity:.6})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}}}console.log("ElevenLabs TTS Audio Analysis:",{text:e,audioDuration:l.duration,visemeCount:r.visemes?r.visemes.length:0,wordCount:r.words?r.words.length:0,features:{onsets:r.features&&r.features.onsets?r.features.onsets.length:0,boundaries:r.features&&r.features.phonemeBoundaries?r.features.phonemeBoundaries.length:0},visemes:r.visemes?r.visemes.slice(0,3):[]});const u=[];if(r.visemes&&r.visemes.length>0){console.log("ElevenLabs: Generating lip-sync animation from",r.visemes.length,"visemes");for(let d=0;d<r.visemes.length;d++){const h=r.visemes[d],g=h.startTime*1e3,x=h.duration*1e3,f=h.intensity;u.push({template:{name:"viseme"},ts:[g-Math.min(60,2*x/3),g+Math.min(25,x/2),g+x+Math.min(60,x/2)],vs:{["viseme_"+h.viseme]:[null,f,0]}})}console.log("ElevenLabs: Generated",u.length,"lip-sync animation frames")}else console.warn("ElevenLabs: No visemes available for lip-sync animation");const a=[...t.anim,...u];console.log("ElevenLabs: Combined animation frames:",a.length,"(original:",t.anim.length,"+ lipsync:",u.length,")"),this.audioPlaylist.push({anim:a,audio:l}),this.onSubtitles=t.onSubtitles||null,this.resetLips(),t.mood&&this.setMood(t.mood),this.playAudio()}async synthesizeWithDeepgramTTS(t){const e=t.text.map(d=>d.word).join(" "),n=t.voice||this.avatar.ttsVoice||this.opt.ttsVoice||"aura-2-thalia-en",i=`${this.opt.ttsEndpoint}?model=${n}`,s=await fetch(i,{method:"POST",headers:{Authorization:`Token ${this.opt.ttsApikey}`,"Content-Type":"text/plain",Accept:"audio/mpeg"},body:e});if(!s.ok)throw new Error(`Deepgram TTS error: ${s.status} ${s.statusText}`);const o=await s.arrayBuffer(),l=await this.audioCtx.decodeAudioData(o);console.log("Using text-based lip-sync for Deepgram...");const c=this.avatar.lipsyncLang||this.opt.lipsyncLang||"en";let r;try{console.log("Lip-sync modules available:",{hasLipsync:!!this.lipsync,lipsyncKeys:this.lipsync?Object.keys(this.lipsync):[],lipsyncLang:c});const d=this.lipsyncPreProcessText(e,c),h=this.lipsyncWordsToVisemes(d,c);if(console.log("Lip-sync data:",{processedText:d,lipsyncData:h,hasVisemes:h&&h.visemes&&h.visemes.length>0}),h&&h.visemes&&h.visemes.length>0)r={visemes:h.visemes.map((g,x)=>({viseme:g,startTime:x*l.duration/h.visemes.length,endTime:(x+1)*l.duration/h.visemes.length,duration:l.duration/h.visemes.length,intensity:.7})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}};else throw new Error("No visemes generated from text")}catch(d){console.error("Text-based lip-sync failed, using fallback:",d);const h=e.toLowerCase().split(/\s+/),g=[];for(const x of h)for(const f of x){let w="aa";"aeiou".includes(f)?w="aa":"bp".includes(f)?w="PP":"fv".includes(f)?w="FF":"st".includes(f)?w="SS":"dln".includes(f)?w="DD":"kg".includes(f)?w="kk":"rw".includes(f)&&(w="RR"),g.push(w)}r={visemes:g.map((x,f)=>({viseme:x,startTime:f*l.duration/g.length,endTime:(f+1)*l.duration/g.length,duration:l.duration/g.length,intensity:.6})),words:[],duration:l.duration,features:{onsets:[],boundaries:[]}}}console.log("Deepgram TTS Audio Analysis:",{text:e,audioDuration:l.duration,visemeCount:r.visemes?r.visemes.length:0,wordCount:r.words?r.words.length:0,features:{onsets:r.features&&r.features.onsets?r.features.onsets.length:0,boundaries:r.features&&r.features.phonemeBoundaries?r.features.phonemeBoundaries.length:0},visemes:r.visemes?r.visemes.slice(0,3):[]});const u=[];if(r.visemes&&r.visemes.length>0){console.log("Deepgram: Generating lip-sync animation from",r.visemes.length,"visemes");for(let d=0;d<r.visemes.length;d++){const h=r.visemes[d],g=h.startTime*1e3,x=h.duration*1e3,f=h.intensity;u.push({template:{name:"viseme"},ts:[g-Math.min(60,2*x/3),g+Math.min(25,x/2),g+x+Math.min(60,x/2)],vs:{["viseme_"+h.viseme]:[null,f,0]}})}console.log("Deepgram: Generated",u.length,"lip-sync animation frames")}else console.warn("Deepgram: No visemes available for lip-sync animation");const a=[...t.anim,...u];console.log("Deepgram: Combined animation frames:",a.length,"(original:",t.anim.length,"+ lipsync:",u.length,")"),this.audioPlaylist.push({anim:a,audio:l}),this.onSubtitles=t.onSubtitles||null,this.resetLips(),t.mood&&this.setMood(t.mood),this.playAudio()}async synthesizeWithAzureTTS(t){const e=t.text.map(a=>a.word).join(" "),i=`
|
|
2
2
|
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">
|
|
3
3
|
<voice name="${t.voice||this.avatar.ttsVoice||this.opt.ttsVoice||"en-US-AriaNeural"}">
|
|
4
4
|
${e}
|