UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 8.71 kB
import{n as e,r as t}from"./rolldown-runtime-CNOWq4Kh.js";import{_c as n,gc as r,hc as i,mc as a,pc as o,vc as s}from"./control-ui-boot-shared-DFTSUQQ0.js";var c=t({MascotAnimator:()=>y});function l(e,t){let n=e/t%1;return n<0?n+1:n}function u(e,t,n){let r=a(e);return r<t?s(r/t):r>n?s((1-r)/(1-n)):1}var d,f,p,m,h,g,_,v,y;function b(){return(b=e((()=>{r(),d=(1n<<64n)-1n,f=11400714819323198485n,p=2685821657736338717n,m=Math.PI*2,h=.16,g={wave:1.5,hop:.7,celebrate:2.4,sigh:1.8,yawn:2,wipeBrow:2,clawSnap:.6,donHardHat:1},_={idle:null,curious:null,thinking:null,attentive:null,happy:`hop`,celebrating:`celebrate`,sad:`sigh`,sleepy:`yawn`,working:`donHardHat`},v=class{constructor(e){let t=BigInt.asUintN(64,BigInt(e));this.state=t===0n?f:t}next(){return this.state^=this.state>>12n,this.state=BigInt.asUintN(64,this.state),this.state^=this.state<<25n,this.state=BigInt.asUintN(64,this.state),this.state^=this.state>>27n,this.state=BigInt.asUintN(64,this.state),this.state*p&d}unit(){return Number(this.next()>>11n)/9007199254740992}},y=class{constructor(){this.rng=new v(BigInt(Date.now())),this.currentMood=`idle`,this.startTime=null,this.lastPoseTime=0,this.activeGesture=null,this.activeGestureStart=0,this.pendingGesture=null,this.pendingGestureAt=0,this.nextBlinkAt=0,this.pendingDoubleBlink=!1,this.blinkStarts=[],this.nextGlanceAt=0,this.gazeHoldUntil=0,this.gazeTarget={x:0,y:0},this.currentGaze={x:0,y:0},this.nextClawSnapAt=0,this.nextMoodBeatAt=0,this.teaseActive=!1,this.teaseChangedAt=0}setMood(e,t){if(e===this.currentMood)return;this.currentMood=e,this.pendingGesture=null,this.activeGesture=null,this.rescheduleMoodBeat(t);let n=_[e];n&&this.startGesture(n,t)}setTease(e,t){this.teaseActive=e,this.teaseChangedAt=t}poseAt(e){this.startTime===null&&(this.startTime=e,this.lastPoseTime=e,this.nextBlinkAt=e+this.random(.8,2.4),this.nextGlanceAt=e+this.random(1.5,4),this.nextClawSnapAt=e+this.random(2,5),this.rescheduleMoodBeat(e),(this.currentMood===`idle`||this.currentMood===`curious`||this.currentMood===`happy`)&&(this.pendingGesture=`wave`,this.pendingGestureAt=e+.9));let t=a(e-this.lastPoseTime,0,.1);this.lastPoseTime=e,this.advanceSchedules(e);let n=this.basePose(this.currentMood,e);if(this.applyGaze(n,this.currentMood,e,t),this.applyBlinks(n,e),this.activeGesture){let t=(e-this.activeGestureStart)/g[this.activeGesture];t>=1?this.activeGesture=null:this.applyGesture(this.activeGesture,n,t)}return this.teaseActive&&e>=this.teaseChangedAt&&(n.mouthRound=Math.max(n.mouthRound,.5),n.gaze={x:0,y:.6}),o(n)}advanceSchedules(e){if(e>=this.nextBlinkAt&&(this.blinkStarts.push(e),this.pendingDoubleBlink?(this.pendingDoubleBlink=!1,this.nextBlinkAt=e+this.blinkInterval()):this.random(0,1)<.14?(this.pendingDoubleBlink=!0,this.nextBlinkAt=e+.34):this.nextBlinkAt=e+this.blinkInterval()),this.blinkStarts=this.blinkStarts.filter(t=>e-t<=h),e>=this.nextGlanceAt){let t=this.random(.5,1),n=this.random(0,m);this.gazeTarget={x:Math.cos(n)*t,y:Math.sin(n)*t*.6},this.gazeHoldUntil=e+this.random(.7,1.9),this.nextGlanceAt=this.gazeHoldUntil+this.glanceInterval()}else e>=this.gazeHoldUntil&&(this.gazeTarget={x:0,y:0});if(e>=this.nextClawSnapAt&&(this.activeGesture===null&&this.currentMood!==`sad`&&this.currentMood!==`working`&&this.startGesture(`clawSnap`,e),this.nextClawSnapAt=e+this.random(4,9)),e>=this.nextMoodBeatAt&&(this.activeGesture===null&&(this.currentMood===`sad`?this.startGesture(`sigh`,e):this.currentMood===`sleepy`?this.startGesture(`yawn`,e):this.currentMood===`working`&&this.startGesture(`wipeBrow`,e)),this.rescheduleMoodBeat(e)),this.pendingGesture&&e>=this.pendingGestureAt&&this.activeGesture===null){let t=this.pendingGesture;this.pendingGesture=null,this.startGesture(t,e)}}basePose(e,t){let r=i();switch(e){case`idle`:r.floatOffset=-4.8*(1-Math.cos(m*l(t,4))),r.antennaDegrees=-3*Math.sin(m*l(t,2));break;case`curious`:r.floatOffset=-4.2*(1-Math.cos(m*l(t,3.4))),r.antennaDegrees=-4*Math.sin(m*l(t,1.7)),r.bodyTilt=1.6*Math.sin(m*l(t,5.2));break;case`thinking`:r.floatOffset=-3.2*(1-Math.cos(m*l(t,5))),r.antennaDegrees=-5*Math.sin(m*l(t,1.3)),r.bodyTilt=2*Math.sin(m*l(t,6)),r.eyeGlowOpacity=.9+.1*Math.sin(m*l(t,.8));break;case`working`:{let e=l(t,.95);if(e<.05)r.rightClawDegrees=-6;else if(e<.6)r.rightClawDegrees=-6-28*s((e-.05)/.55);else if(e<.72){let t=a((e-.6)/.12);r.rightClawDegrees=-34+46*t*t}else r.rightClawDegrees=12-18*s((e-.72)/.28);r.leftClawDegrees=4+2*Math.sin(m*e);let i=n(a((e-.72)/.14));if(r.floatOffset=-2*(1-Math.cos(m*l(t,3.8)))+.8*i,r.bodyStretch=1-.03*i,r.bodyTilt=2.2+.6*Math.sin(m*l(t,5)),e>=.72){let t=a((e-.72)/.28);r.antennaDegrees=6*(1-t)*Math.sin(t*3*Math.PI)}r.leftEyeOpenness=.85,r.rightEyeOpenness=.85,r.mouthCurve=.18,r.hardHat=1,r.effect=`sparks`;let o=(e-.72)%1;r.effectPhase=o<0?o+1:o;break}case`happy`:r.floatOffset=-6*(1-Math.cos(m*l(t,3))),r.antennaDegrees=-4.5*Math.sin(m*l(t,1.6)),r.mouthCurve=.55+.1*Math.sin(m*l(t,3)),r.happyEyes=.35;break;case`celebrating`:{let e=Math.abs(Math.sin(m*l(t,1.6)));r.floatOffset=-9*e,r.bodyStretch=1+.03*e,r.antennaDegrees=-6*Math.sin(m*l(t,.8));let n=Math.sin(m*l(t,.9));r.leftClawDegrees=20+8*n,r.rightClawDegrees=-20+8*n,r.mouthCurve=.9,r.mouthOpen=.35,r.happyEyes=.7,r.glowScale=1.1,r.effect=`sparkles`,r.effectPhase=l(t,2.2);break}case`sad`:r.floatOffset=-2.4*(1-Math.cos(m*l(t,5.5))),r.antennaDegrees=-1.5*Math.sin(m*l(t,3)),r.antennaDroop=.75,r.mouthCurve=-.55,r.eyeGlowOpacity=.6;break;case`sleepy`:r.floatOffset=-2*(1-Math.cos(m*l(t,6))),r.antennaDroop=.35,r.leftEyeOpenness=.22+.08*Math.sin(m*l(t,3)),r.rightEyeOpenness=r.leftEyeOpenness,r.eyeGlowOpacity=.5,r.mouthRound=.15,r.bodyTilt=2.5*Math.sin(m*l(t,6)),r.effect=`zzz`,r.effectPhase=l(t,3);break;case`attentive`:r.floatOffset=-3*(1-Math.cos(m*l(t,4))),r.antennaDegrees=-2.5*Math.sin(m*l(t,2)),r.mouthCurve=.25}return r}applyGaze(e,t,n,r){let i=this.gazeTarget;switch(t){case`thinking`:i={x:.4*Math.sin(m*l(n,3.8)),y:-.55};break;case`working`:i={x:.55+.04*Math.sin(m*l(n,4.6)),y:.45+.02*Math.cos(m*l(n,3.9))};break;case`attentive`:i={x:i.x*.5,y:.35};break;case`sad`:i={x:i.x*.3,y:.5};break;case`sleepy`:i={x:0,y:.4}}let a=1-Math.exp(-r*9);this.currentGaze.x+=(i.x-this.currentGaze.x)*a,this.currentGaze.y+=(i.y-this.currentGaze.y)*a,e.gaze={...this.currentGaze}}applyBlinks(e,t){if(!(e.happyEyes>=.6))for(let r of this.blinkStarts){let i=(t-r)/h;if(i<0||i>1)continue;let a=n(i);e.leftEyeOpenness=Math.min(e.leftEyeOpenness,1-a),e.rightEyeOpenness=Math.min(e.rightEyeOpenness,1-a),e.eyeGlowOpacity*=Math.max(.3,1-a)}}applyGesture(e,t,r){let i=a(r);switch(e){case`wave`:{let e=u(i,.18,.82);t.rightClawDegrees+=e*(-28+9*Math.sin(i*6*Math.PI)),t.bodyTilt+=-2*e,t.mouthCurve=Math.max(t.mouthCurve,.5*e);break}case`hop`:{let e=n(a((i-.2)/.6));t.floatOffset+=-9*e,t.bodyStretch+=.045*e-.1*n(a(i/.2))-.06*n(a((i-.82)/.18)),t.mouthCurve=Math.max(t.mouthCurve,.4*e);break}case`celebrate`:{let e=u(i,.12,.88),r=Math.abs(Math.sin(i*4*Math.PI));t.floatOffset+=-11*r*e,t.bodyStretch+=.035*r*e,t.leftClawDegrees+=38*e,t.rightClawDegrees+=-38*e,t.happyEyes=Math.max(t.happyEyes,e),t.mouthCurve=Math.max(t.mouthCurve,e),t.mouthOpen=Math.max(t.mouthOpen,.6*n(i)),t.antennaDroop=0,t.glowScale=Math.max(t.glowScale,1+.2*e),t.effect=`sparkles`,t.effectPhase=i;break}case`sigh`:{let e=s(a(i/.3)),n=s(a((i-.3)/.45));t.bodyStretch+=.025*e-.08*n*(1-a((i-.85)/.15)),t.gaze={x:t.gaze.x,y:.5*n},t.antennaDroop=Math.min(1,t.antennaDroop+.15*n);break}case`yawn`:{let e=u(i,.3,.75);t.mouthRound=Math.max(t.mouthRound,.9*e),t.leftEyeOpenness=Math.min(t.leftEyeOpenness,1-.9*e),t.rightEyeOpenness=Math.min(t.rightEyeOpenness,1-.9*e),t.bodyStretch+=.03*e,t.bodyTilt+=-2*e;break}case`clawSnap`:t.leftClawDegrees+=-8*n(a(i/.7)),t.rightClawDegrees+=-8*n(a((i-.25)/.7));break;case`donHardHat`:{let e=s(a(i/.55));t.hardHat=Math.min(t.hardHat,e),i<.55&&(t.gaze={x:0,y:-.9*(1-i)}),t.bodyStretch-=.04*n(a((i-.5)/.2));let r=n(a((i-.7)/.3));t.leftClawDegrees+=-8*r,t.rightClawDegrees+=8*r;break}case`wipeBrow`:{let e=u(i,.2,.8);t.leftClawDegrees*=1-e,t.rightClawDegrees*=1-e,t.leftClawDegrees+=38*e*(.9+.1*Math.sin(i*5*Math.PI)),t.bodyTilt*=1-e,t.bodyStretch+=.02*e,t.happyEyes=Math.max(t.happyEyes,.7*e),t.mouthCurve=Math.max(t.mouthCurve,.5*e),t.gaze={x:t.gaze.x*(1-e),y:t.gaze.y*(1-e)},t.effect=`sweat`,t.effectPhase=i;break}}}startGesture(e,t){this.activeGesture=e,this.activeGestureStart=t}random(e,t){return e+(t-e)*this.rng.unit()}blinkInterval(){return this.currentMood===`attentive`?this.random(1.8,4):this.random(2.2,5.5)}glanceInterval(){return this.currentMood===`curious`?this.random(1.6,4):this.currentMood===`thinking`?this.random(1.2,3):this.random(3,8)}rescheduleMoodBeat(e){this.nextMoodBeatAt=e+this.random(6,12)}}})))()}export{c as n,b as t};