1import{u as F}from"./useSetState.RAGWIOkA.js";import{u as w}from"./useEffect.DOBomi6c.js";import{aw as G,aH as H,a$ as Q,bd as W,aT as Y,aZ as Z,dd as A,cg as E,de as q,aP as I,aC as X,df as ee,aQ as te,dV as ae}from"./entry.D_dqNKaD.js";import{r as k}from"./rive.CnABUSJ3.js";import{s as se}from"./interval.BPOv_HR-.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"1efaec818d93a34fc75e3041dd55939e084a0ab6"};var f=new n.Error().stack;f&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[f]="e1f6d06d-e1f3-4ba1-a7e3-9a1ced180fda",n._sentryDebugIdIdentifier="sentry-dbid-e1f6d06d-e1f3-4ba1-a7e3-9a1ced180fda")}catch{}})();k.RuntimeLoader.setWasmUrl("/riv/rive.wasm");const ue=G({props:{rive:{type:Object},mediaType:{type:String,default:""},autoplay:{type:Boolean,default:!1},id:{type:String,default:""},singleton:{type:Boolean,default:!1},onClick:{type:Function},playingStatus:{type:String,default:"sent"}},setup(n){const{learnLangs:f}=H(),L=I(!1),{avatarLipJsonUrl:P}=Q(),o=W(),b=I(null),v=E(null),S=E(new Map),x=E({}),T=Y(),[D,K]=F({lipJson:{}}),r=I(null),u=I(null),{playAudio:U,isPlaying:M,getAudioElementRef:j,isEnded:C,currentGender:z,currentTask:$}=Z({singleton:n.singleton}),B=te(()=>{var i,l;const a={lesson_w:"w",lesson_s:"s",lesson_c:"c"},t=`ld-${ae[T.learnLangKey]||f[T.learnLang].level_1}-${z.value}-${a[((i=$.value)==null?void 0:i.type)??""]}-${(l=$.value)==null?void 0:l.id}`,s=D.lipJson[t];return s?s.trim().split(` 2`).map(c=>{const[y,m,g]=c.split(" ");return{id:parseInt(y,10)+100,start:parseInt(m,10),duration:parseInt(g,10)}}):[]}),N=()=>{var c,y,m;if(!b.value)return;const a=b.value,e=window.devicePixelRatio||1,t=((c=n.rive)==null?void 0:c.width)??392,s=((y=n.rive)==null?void 0:y.height)??554;a.width=t*e,a.height=s*e,a.style.width=`${t}px`,a.style.height=`${s}px`;const i=a.getContext("2d");i&&i.scale(e,e);const l=new k.Rive({src:((m=n.rive)==null?void 0:m.rivUrl)??"/riv/ld_speakanimation_392_554_pose02_0210.riv",canvas:a,autoplay:!0,stateMachines:["InLesson"],onLoad:()=>{l.resizeDrawingSurfaceToCanvas(),v.value=l;const g={},J=new Map,V=l.stateMachineInputs("InLesson");for(const h of V){const R=parseInt(h.name);!ee(R)&&R>=0?J.set(R,h):g[h.name]=h}S.value=J,x.value=g,!L.value&&n.autoplay&&(U({type:n.mediaType,id:n.id,playStatus:n.playingStatus}),L.value=!0)}})},d=(a,e)=>{S.value&&S.value.forEach((t,s)=>{s==a?t.value=e:t.value!==0&&(t.value=0)})},O=()=>{if(!M.value||!v.value)return;const a=j();if(!a.value)return;const e=a.value.currentTime*1e3,t=B.value.find(s=>e>=s.start&&e<=s.start+s.duration);if(t){let s=(e-t.start)*100/t.duration;d(t.id,Math.max(0,Math.min(100,Math.floor(s))))}else d(null,0),d(100,100)},_=(a,e)=>{var s,i;const t=(s=x.value)==null?void 0:s[a];if(typeof(t==null?void 0:t.fire)=="function"){t.fire();return}e&&((i=v.value)==null||i.play(e))},p=(a=!0)=>{r.value&&(clearInterval(r.value),r.value=null),u.value&&(clearTimeout(u.value),u.value=null),d(null,0),d(100,100),a&&(u.value=setTimeout(()=>{_("Reset","Reset")},50))};return w(()=>(A(async()=>{if(!T.learnLangKey)return;const e=async i=>{const[l,c]=await A(()=>$fetch(P(i)));return l?(console.warn("avatar lip json fetch failed",P(i),l),{}):c??{}},[t,s]=await Promise.all([e("f"),e("m")]);K({lipJson:q(t,s)??{}})}),N(),()=>{var e;p(!1),(e=v.value)==null||e.cleanup()}),[]),w(()=>(M.value&&!o.state.shieldModal?r.value||(r.value=se(O,16)):p(!0),()=>{r.value&&clearInterval(r.value)}),[()=>M.value,()=>o.state.shieldModal]),w(()=>{C.value&&p(!0)},[()=>C.value]),w(()=>{o.state.shieldModal&&(p(!1),u.value&&clearTimeout(u.value),o.state.answer===o.state.chosenAnswer?_("Correct"):_("Incorrect"))},[()=>o.state.shieldModal]),()=>X("canvas",{ref:b},null)}});export{ue as P};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.