@w0nna_dev/lina-widget 1.0.1 → 1.0.3
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/lina-widget.es.js +61 -52
- package/dist/lina-widget.umd.js +18 -18
- package/dist/src/core/orb/OrbRenderer.d.ts +1 -0
- package/dist/src/core/orb/glow.glsl.d.ts +1 -1
- package/dist/src/core/orb/orb.vert.glsl.d.ts +1 -1
- package/dist/src/lina/core/LinaOrbRenderer.d.ts +3 -1
- package/dist/src/orb/core/OrbRenderer.d.ts +1 -0
- package/dist/src/orb/shaders/glow.glsl.d.ts +1 -1
- package/dist/src/orb/shaders/orb.vert.glsl.d.ts +1 -1
- package/package.json +1 -1
package/dist/lina-widget.es.js
CHANGED
|
@@ -39088,13 +39088,13 @@ void main() {
|
|
|
39088
39088
|
// Multi-layered noise displacement
|
|
39089
39089
|
vec3 noisePos = pos * uNoiseScale + t * 0.3;
|
|
39090
39090
|
|
|
39091
|
-
// Base organic movement
|
|
39092
|
-
float baseNoise = fbm(noisePos,
|
|
39091
|
+
// Base organic movement - very smooth, minimal detail
|
|
39092
|
+
float baseNoise = fbm(noisePos, 2) * 0.05;
|
|
39093
39093
|
|
|
39094
|
-
// Audio-reactive displacement
|
|
39095
|
-
float bassDisplacement = snoise(noisePos * 0.
|
|
39096
|
-
float midDisplacement = snoise(noisePos *
|
|
39097
|
-
float trebleDisplacement = snoise(noisePos *
|
|
39094
|
+
// Audio-reactive displacement - very low frequencies for smooth waves
|
|
39095
|
+
float bassDisplacement = snoise(noisePos * 0.3 + t * 0.1) * uAudioBass * 0.08 * uAudioReactivity;
|
|
39096
|
+
float midDisplacement = snoise(noisePos * 0.4 + t * 0.12) * uAudioMid * 0.05 * uAudioReactivity;
|
|
39097
|
+
float trebleDisplacement = snoise(noisePos * 0.5 + t * 0.15) * uAudioTreble * 0.02 * uAudioReactivity;
|
|
39098
39098
|
|
|
39099
39099
|
// Combine all displacement
|
|
39100
39100
|
float totalDisplacement = baseNoise + bassDisplacement + midDisplacement + trebleDisplacement;
|
|
@@ -39102,8 +39102,8 @@ void main() {
|
|
|
39102
39102
|
// Apply morphing strength
|
|
39103
39103
|
totalDisplacement *= uMorphStrength;
|
|
39104
39104
|
|
|
39105
|
-
// Add breathing effect
|
|
39106
|
-
float breathing = sin(uTime * 0.
|
|
39105
|
+
// Add breathing effect - very subtle
|
|
39106
|
+
float breathing = sin(uTime * 0.3) * 0.005 * (1.0 + uAudioLevel * 0.2);
|
|
39107
39107
|
totalDisplacement += breathing;
|
|
39108
39108
|
|
|
39109
39109
|
// Apply displacement along normal
|
|
@@ -39335,9 +39335,9 @@ varying vec3 vPosition;
|
|
|
39335
39335
|
varying float vIntensity;
|
|
39336
39336
|
|
|
39337
39337
|
void main() {
|
|
39338
|
-
// Pulsing effect
|
|
39339
|
-
float pulse = sin(uTime * uPulseSpeed) * 0.
|
|
39340
|
-
pulse += uAudioLevel * 0.
|
|
39338
|
+
// Pulsing effect - very subtle
|
|
39339
|
+
float pulse = sin(uTime * uPulseSpeed * 0.3) * 0.03 + 0.97;
|
|
39340
|
+
pulse += uAudioLevel * 0.15;
|
|
39341
39341
|
|
|
39342
39342
|
// Smooth radial glow using pre-calculated intensity
|
|
39343
39343
|
float glow = vIntensity * uGlowIntensity * pulse;
|
|
@@ -39373,16 +39373,16 @@ void main() {
|
|
|
39373
39373
|
segments: 128,
|
|
39374
39374
|
colors: _s,
|
|
39375
39375
|
morphStrength: 1,
|
|
39376
|
-
noiseScale:
|
|
39377
|
-
noiseSpeed: 0.
|
|
39376
|
+
noiseScale: 0.8,
|
|
39377
|
+
noiseSpeed: 0.15,
|
|
39378
39378
|
glowIntensity: 0.8,
|
|
39379
39379
|
idleGlowMultiplier: 0.4,
|
|
39380
39380
|
fresnelPower: 2.5,
|
|
39381
39381
|
rotationSpeed: 0.1,
|
|
39382
|
-
audioReactivity:
|
|
39383
|
-
//
|
|
39384
|
-
audioSmoothing: 0.
|
|
39385
|
-
//
|
|
39382
|
+
audioReactivity: 1,
|
|
39383
|
+
// Gentle displacement (default: 1.0)
|
|
39384
|
+
audioSmoothing: 0.03,
|
|
39385
|
+
// Ultra smooth response (0.03 = very slow, 1.0 = instant)
|
|
39386
39386
|
idleMorphMultiplier: 0.25,
|
|
39387
39387
|
// Calm idle state (was 0.3)
|
|
39388
39388
|
colorContrast: 1.5
|
|
@@ -39395,18 +39395,25 @@ class yu {
|
|
|
39395
39395
|
mid: 0,
|
|
39396
39396
|
treble: 0,
|
|
39397
39397
|
level: 0
|
|
39398
|
+
}, this.smoothedUniforms = {
|
|
39399
|
+
bass: 0,
|
|
39400
|
+
mid: 0,
|
|
39401
|
+
treble: 0,
|
|
39402
|
+
level: 0
|
|
39398
39403
|
}, this.canvasPadding = 3, this.animate = () => {
|
|
39399
39404
|
this.animationId = requestAnimationFrame(this.animate);
|
|
39400
39405
|
const a = this.clock.getElapsedTime();
|
|
39401
|
-
|
|
39402
|
-
|
|
39403
|
-
|
|
39404
|
-
this.orbMaterial.uniforms.
|
|
39406
|
+
this.clock.getDelta();
|
|
39407
|
+
const c = 0.02;
|
|
39408
|
+
if (this.smoothedUniforms.bass += (this.audioValues.bass - this.smoothedUniforms.bass) * c, this.smoothedUniforms.mid += (this.audioValues.mid - this.smoothedUniforms.mid) * c, this.smoothedUniforms.treble += (this.audioValues.treble - this.smoothedUniforms.treble) * c, this.smoothedUniforms.level += (this.audioValues.level - this.smoothedUniforms.level) * c, this.orbMaterial) {
|
|
39409
|
+
this.orbMaterial.uniforms.uTime.value = a, this.orbMaterial.uniforms.uAudioBass.value = this.smoothedUniforms.bass, this.orbMaterial.uniforms.uAudioMid.value = this.smoothedUniforms.mid, this.orbMaterial.uniforms.uAudioTreble.value = this.smoothedUniforms.treble, this.orbMaterial.uniforms.uAudioLevel.value = this.smoothedUniforms.level;
|
|
39410
|
+
const l = this.isActive ? this.config.morphStrength * 1.2 : this.config.morphStrength * this.config.idleMorphMultiplier, d = this.orbMaterial.uniforms.uMorphStrength.value;
|
|
39411
|
+
this.orbMaterial.uniforms.uMorphStrength.value += (l - d) * 0.02;
|
|
39405
39412
|
}
|
|
39406
39413
|
if (this.glowMaterial) {
|
|
39407
|
-
this.glowMaterial.uniforms.uTime.value = a, this.glowMaterial.uniforms.uAudioLevel.value = this.
|
|
39408
|
-
const
|
|
39409
|
-
this.glowMaterial.uniforms.uGlowIntensity.value += (
|
|
39414
|
+
this.glowMaterial.uniforms.uTime.value = a, this.glowMaterial.uniforms.uAudioLevel.value = this.smoothedUniforms.level;
|
|
39415
|
+
const l = this.isActive ? this.config.glowIntensity * 1.2 : this.config.glowIntensity * this.config.idleGlowMultiplier, d = this.glowMaterial.uniforms.uGlowIntensity.value;
|
|
39416
|
+
this.glowMaterial.uniforms.uGlowIntensity.value += (l - d) * 0.02;
|
|
39410
39417
|
}
|
|
39411
39418
|
this.currentRotation.x += (this.targetRotation.x - this.currentRotation.x) * 0.05, this.currentRotation.y += (this.targetRotation.y - this.currentRotation.y) * 0.05, this.orb && (this.orb.rotation.x = this.currentRotation.x + a * this.config.rotationSpeed * 0.3, this.orb.rotation.y = this.currentRotation.y + a * this.config.rotationSpeed), this.glowMesh && (this.glowMesh.rotation.x = this.currentRotation.x + a * this.config.rotationSpeed * 0.3, this.glowMesh.rotation.y = this.currentRotation.y + a * this.config.rotationSpeed), this.renderer.render(this.scene, this.camera);
|
|
39412
39419
|
}, this.handleResize = () => {
|
|
@@ -39540,7 +39547,7 @@ class yu {
|
|
|
39540
39547
|
}
|
|
39541
39548
|
class bu {
|
|
39542
39549
|
constructor(e = {}) {
|
|
39543
|
-
this.audioContext = null, this.analyser = null, this.source = null, this.localSource = null, this.mixer = null, this.frequencyData = new Uint8Array(0), this.waveformData = new Float32Array(0), this.smoothedBass = 0, this.smoothedMid = 0, this.smoothedTreble = 0, this.smoothedLevel = 0, this.smoothingFactor = 0.
|
|
39550
|
+
this.audioContext = null, this.analyser = null, this.source = null, this.localSource = null, this.mixer = null, this.frequencyData = new Uint8Array(0), this.waveformData = new Float32Array(0), this.smoothedBass = 0, this.smoothedMid = 0, this.smoothedTreble = 0, this.smoothedLevel = 0, this.smoothingFactor = 0.04, this.options = {
|
|
39544
39551
|
fftSize: e.fftSize ?? 2048,
|
|
39545
39552
|
smoothingTimeConstant: e.smoothingTimeConstant ?? 0.8,
|
|
39546
39553
|
minDecibels: e.minDecibels ?? -90,
|
|
@@ -40052,7 +40059,7 @@ var QM = Object.defineProperty, ew = Object.getOwnPropertyDescriptor, Mt = (i, e
|
|
|
40052
40059
|
};
|
|
40053
40060
|
let bt = class extends Qi {
|
|
40054
40061
|
constructor() {
|
|
40055
|
-
super(...arguments), this.callManager = new jo(), this.orbRenderer = null, this.audioAnalyzer = null, this.soundManager = null, this.orbContainerRef = No(), this.animationId = null, this.callStatus = "idle", this.microphoneEnabled = !1, this.buttonStartText = "Try to call", this.buttonConnectingText = "Connecting...", this.size = 370, this.containerPadding = 45, this.theme = "default", this.themeMode = "auto", this.orbColors = {}, this.glowIntensity = 0.8, this.idleGlowMultiplier = 0.4, this.morphStrength = 1, this.noiseScale =
|
|
40062
|
+
super(...arguments), this.callManager = new jo(), this.orbRenderer = null, this.audioAnalyzer = null, this.soundManager = null, this.orbContainerRef = No(), this.animationId = null, this.callStatus = "idle", this.microphoneEnabled = !1, this.buttonStartText = "Try to call", this.buttonConnectingText = "Connecting...", this.size = 370, this.containerPadding = 45, this.theme = "default", this.themeMode = "auto", this.orbColors = {}, this.glowIntensity = 0.8, this.idleGlowMultiplier = 0.4, this.morphStrength = 1, this.noiseScale = 0.8, this.noiseSpeed = 0.15, this.fresnelPower = 2.5, this.rotationSpeed = 0.1, this.audioReactivity = 1, this.audioSmoothing = 0.03, this.idleMorphMultiplier = 0.25, this.colorContrast = 1.5, this.soundEnabled = !0, this.soundVolume = 0.15, this.handleAudioTrack = async (i) => {
|
|
40056
40063
|
const t = i.detail;
|
|
40057
40064
|
if (!(!t || !this.audioAnalyzer))
|
|
40058
40065
|
try {
|
|
@@ -40310,7 +40317,7 @@ let bt = class extends Qi {
|
|
|
40310
40317
|
|
|
40311
40318
|
.call-button {
|
|
40312
40319
|
position: absolute;
|
|
40313
|
-
top:
|
|
40320
|
+
top: 48%;
|
|
40314
40321
|
left: 50%;
|
|
40315
40322
|
transform: translate(-50%, -50%);
|
|
40316
40323
|
display: flex;
|
|
@@ -40566,7 +40573,7 @@ var tw = Object.defineProperty, nw = Object.getOwnPropertyDescriptor, wt = (i, e
|
|
|
40566
40573
|
};
|
|
40567
40574
|
let _t = class extends Qi {
|
|
40568
40575
|
constructor() {
|
|
40569
|
-
super(...arguments), this.callManager = new jo(), this.orbRenderer = null, this.audioAnalyzer = null, this.soundManager = null, this.orbContainerRef = No(), this.animationId = null, this.callStatus = "idle", this.microphoneEnabled = !1, this.buttonStartText = "Call", this.buttonConnectingText = "Connecting...", this.position = "bottom-right", this.size = 120, this.theme = "default", this.themeMode = "auto", this.orbColors = {}, this.glowIntensity = 0.8, this.idleGlowMultiplier = 0.4, this.morphStrength = 1, this.noiseScale =
|
|
40576
|
+
super(...arguments), this.callManager = new jo(), this.orbRenderer = null, this.audioAnalyzer = null, this.soundManager = null, this.orbContainerRef = No(), this.animationId = null, this.callStatus = "idle", this.microphoneEnabled = !1, this.buttonStartText = "Call", this.buttonConnectingText = "Connecting...", this.position = "bottom-right", this.size = 120, this.theme = "default", this.themeMode = "auto", this.orbColors = {}, this.glowIntensity = 0.8, this.idleGlowMultiplier = 0.4, this.morphStrength = 1, this.noiseScale = 0.8, this.noiseSpeed = 0.15, this.fresnelPower = 2.5, this.rotationSpeed = 0.1, this.audioReactivity = 1, this.audioSmoothing = 0.03, this.idleMorphMultiplier = 0.25, this.colorContrast = 1.5, this.soundEnabled = !0, this.soundVolume = 0.15, this.handleAudioTrack = async (i) => {
|
|
40570
40577
|
const t = i.detail;
|
|
40571
40578
|
if (!(!t || !this.audioAnalyzer))
|
|
40572
40579
|
try {
|
|
@@ -40811,7 +40818,7 @@ let _t = class extends Qi {
|
|
|
40811
40818
|
|
|
40812
40819
|
.call-button {
|
|
40813
40820
|
position: absolute;
|
|
40814
|
-
top:
|
|
40821
|
+
top: 48%;
|
|
40815
40822
|
left: 50%;
|
|
40816
40823
|
transform: translate(-50%, -50%);
|
|
40817
40824
|
display: flex;
|
|
@@ -41064,7 +41071,7 @@ var iw = Object.defineProperty, sw = Object.getOwnPropertyDescriptor, At = (i, e
|
|
|
41064
41071
|
};
|
|
41065
41072
|
let St = class extends Qi {
|
|
41066
41073
|
constructor() {
|
|
41067
|
-
super(...arguments), this.callManager = new jo(), this.orbRenderer = null, this.audioAnalyzer = null, this.soundManager = null, this.orbContainerRef = No(), this.animationId = null, this.callStatus = "idle", this.microphoneEnabled = !1, this.buttonStartText = "Talk to AI Agent", this.buttonConnectingText = "Connecting...", this.buttonEndText = "End call", this.orbSize = 48, this.theme = "default", this.themeMode = "auto", this.orbColors = {}, this.glowIntensity = 0.8, this.idleGlowMultiplier = 0.4, this.morphStrength = 1, this.noiseScale =
|
|
41074
|
+
super(...arguments), this.callManager = new jo(), this.orbRenderer = null, this.audioAnalyzer = null, this.soundManager = null, this.orbContainerRef = No(), this.animationId = null, this.callStatus = "idle", this.microphoneEnabled = !1, this.buttonStartText = "Talk to AI Agent", this.buttonConnectingText = "Connecting...", this.buttonEndText = "End call", this.orbSize = 48, this.theme = "default", this.themeMode = "auto", this.orbColors = {}, this.glowIntensity = 0.8, this.idleGlowMultiplier = 0.4, this.morphStrength = 1, this.noiseScale = 0.8, this.noiseSpeed = 0.15, this.fresnelPower = 2.5, this.rotationSpeed = 0.1, this.audioReactivity = 1, this.audioSmoothing = 0.03, this.idleMorphMultiplier = 0.25, this.colorContrast = 1.5, this.soundEnabled = !0, this.soundVolume = 0.15, this.handleAudioTrack = async (i) => {
|
|
41068
41075
|
const t = i.detail;
|
|
41069
41076
|
if (!(!t || !this.audioAnalyzer))
|
|
41070
41077
|
try {
|
|
@@ -41528,37 +41535,39 @@ const rw = {
|
|
|
41528
41535
|
};
|
|
41529
41536
|
class aw {
|
|
41530
41537
|
constructor(e, t = {}) {
|
|
41531
|
-
this.shellSegments = [], this.coreInner = null, this.coreOuter = null, this.coreGlow = null, this.pulseRings = [], this.particles = null, this.particlePositions = null, this.particleVelocities = null, this.animationId = null, this._currentState = "idle", this._currentEmotion = "neutral", this.targetConfig = { ...rl.idle }, this.currentConfig = { ...rl.idle }, this.
|
|
41538
|
+
this.shellSegments = [], this.coreInner = null, this.coreOuter = null, this.coreGlow = null, this.pulseRings = [], this.particles = null, this.particlePositions = null, this.particleVelocities = null, this.animationId = null, this._currentState = "idle", this._currentEmotion = "neutral", this.targetConfig = { ...rl.idle }, this.currentConfig = { ...rl.idle }, this.targetAudioLevel = 0, this.currentAudioLevel = 0, this.audioVelocity = 0, this.targetPulseColor = new Ue("#a855f7"), this.currentPulseColor = new Ue("#a855f7"), this.targetRotation = { x: 0, y: 0 }, this.currentRotation = { x: 0, y: 0 }, this.time = 0, this.animate = () => {
|
|
41532
41539
|
this.animationId = requestAnimationFrame(this.animate);
|
|
41533
41540
|
const n = this.clock.getDelta();
|
|
41534
41541
|
this.time += n;
|
|
41535
41542
|
const s = 0.05;
|
|
41536
41543
|
this.currentConfig.coreIntensity += (this.targetConfig.coreIntensity - this.currentConfig.coreIntensity) * s, this.currentConfig.lightningCount += (this.targetConfig.lightningCount - this.currentConfig.lightningCount) * s, this.currentConfig.lightningIntensity += (this.targetConfig.lightningIntensity - this.currentConfig.lightningIntensity) * s, this.currentConfig.particleSpeed += (this.targetConfig.particleSpeed - this.currentConfig.particleSpeed) * s, this.currentConfig.coreScale += (this.targetConfig.coreScale - this.currentConfig.coreScale) * s;
|
|
41537
|
-
const r =
|
|
41538
|
-
|
|
41539
|
-
|
|
41540
|
-
|
|
41541
|
-
const
|
|
41542
|
-
this.
|
|
41544
|
+
const r = 0.08, o = 0.75, a = (this.targetAudioLevel - this.currentAudioLevel) * r;
|
|
41545
|
+
this.audioVelocity += a, this.audioVelocity *= o, this.currentAudioLevel += this.audioVelocity, this.currentAudioLevel = Math.max(0, Math.min(1, this.currentAudioLevel));
|
|
41546
|
+
const c = 1 + this.currentAudioLevel * 0.4;
|
|
41547
|
+
if (this.coreLight && (this.coreLight.intensity = 3 + this.currentConfig.coreIntensity * 2 * c), this.coreInner) {
|
|
41548
|
+
const l = this.coreInner.material;
|
|
41549
|
+
l.uniforms && (l.uniforms.uTime.value = this.time, l.uniforms.uIntensity.value = this.currentConfig.coreIntensity * c);
|
|
41550
|
+
const d = this.currentConfig.coreScale * 0.9 * c;
|
|
41551
|
+
this.coreInner.scale.setScalar(d);
|
|
41543
41552
|
}
|
|
41544
41553
|
if (this.coreOuter) {
|
|
41545
|
-
const
|
|
41546
|
-
|
|
41547
|
-
const
|
|
41548
|
-
this.coreOuter.scale.setScalar(
|
|
41554
|
+
const l = this.coreOuter.material;
|
|
41555
|
+
l.uniforms.uTime.value = this.time, l.uniforms.uIntensity.value = this.currentConfig.coreIntensity * c;
|
|
41556
|
+
const d = this.currentConfig.coreScale * c;
|
|
41557
|
+
this.coreOuter.scale.setScalar(d);
|
|
41549
41558
|
}
|
|
41550
41559
|
if (this.coreGlow) {
|
|
41551
|
-
const
|
|
41552
|
-
|
|
41553
|
-
const
|
|
41554
|
-
this.coreGlow.scale.setScalar(
|
|
41560
|
+
const l = this.coreGlow.material;
|
|
41561
|
+
l.uniforms.uTime.value = this.time, l.uniforms.uIntensity.value = this.currentConfig.coreIntensity * 0.7 * c;
|
|
41562
|
+
const d = 1 + Math.sin(this.time * 1.5) * 0.03 * this.currentConfig.coreIntensity;
|
|
41563
|
+
this.coreGlow.scale.setScalar(d);
|
|
41555
41564
|
}
|
|
41556
41565
|
this.updateParticles(n), this.currentPulseColor.lerp(this.targetPulseColor, 0.08);
|
|
41557
|
-
for (const
|
|
41558
|
-
const
|
|
41559
|
-
|
|
41560
|
-
const
|
|
41561
|
-
|
|
41566
|
+
for (const l of this.pulseRings) {
|
|
41567
|
+
const d = l.material;
|
|
41568
|
+
d.uniforms.uTime.value = this.time, d.uniforms.uAudioLevel.value = this.currentAudioLevel, d.uniforms.uIntensity.value = this.currentConfig.coreIntensity, d.uniforms.uColor.value.copy(this.currentPulseColor);
|
|
41569
|
+
const u = l.ringConfig;
|
|
41570
|
+
l.rotation.y += 3e-3 * u.speed, l.rotation.x = u.tiltX + Math.sin(this.time * 0.5 + u.phase) * 0.1, l.rotation.z = u.tiltZ + Math.cos(this.time * 0.4 + u.phase) * 0.08;
|
|
41562
41571
|
}
|
|
41563
41572
|
this.currentRotation.x += (this.targetRotation.x - this.currentRotation.x) * 0.05, this.currentRotation.y += (this.targetRotation.y - this.currentRotation.y) * 0.05, this.scene.rotation.x = this.currentRotation.x, this.scene.rotation.y = this.currentRotation.y, this.renderer.render(this.scene, this.camera);
|
|
41564
41573
|
}, this.handleResize = () => {
|
|
@@ -42071,7 +42080,7 @@ class aw {
|
|
|
42071
42080
|
return this._currentState;
|
|
42072
42081
|
}
|
|
42073
42082
|
setAudioLevel(e) {
|
|
42074
|
-
this.
|
|
42083
|
+
this.targetAudioLevel = Math.max(0, Math.min(1, e));
|
|
42075
42084
|
}
|
|
42076
42085
|
/**
|
|
42077
42086
|
* Set emotion for pulse line color
|
|
@@ -42125,7 +42134,7 @@ var ow = Object.defineProperty, cw = Object.getOwnPropertyDescriptor, Ln = (i, e
|
|
|
42125
42134
|
};
|
|
42126
42135
|
let gn = class extends Qi {
|
|
42127
42136
|
constructor() {
|
|
42128
|
-
super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.size = 300, this.headerLogo = "HANC.ai", this.headerTitle = "Lina-Voice AI", this.showBranding = !0, this.version = "v1.0.
|
|
42137
|
+
super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.size = 300, this.headerLogo = "HANC.ai", this.headerTitle = "Lina-Voice AI", this.showBranding = !0, this.version = "v1.0.3", this.agentId = "", this.voiceServiceUrl = "", this.btnStartText = "Start", this.btnEndText = "End", this.colors = {}, this.currentState = "idle", this.callStatus = "idle", this._hasMicPermission = null, this.handleCallClick = async () => {
|
|
42129
42138
|
if (this.callStatus === "mic-denied")
|
|
42130
42139
|
try {
|
|
42131
42140
|
(await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), this._hasMicPermission = !0, this.callStatus = "idle";
|
package/dist/lina-widget.umd.js
CHANGED
|
@@ -4213,13 +4213,13 @@ void main() {
|
|
|
4213
4213
|
// Multi-layered noise displacement
|
|
4214
4214
|
vec3 noisePos = pos * uNoiseScale + t * 0.3;
|
|
4215
4215
|
|
|
4216
|
-
// Base organic movement
|
|
4217
|
-
float baseNoise = fbm(noisePos,
|
|
4216
|
+
// Base organic movement - very smooth, minimal detail
|
|
4217
|
+
float baseNoise = fbm(noisePos, 2) * 0.05;
|
|
4218
4218
|
|
|
4219
|
-
// Audio-reactive displacement
|
|
4220
|
-
float bassDisplacement = snoise(noisePos * 0.
|
|
4221
|
-
float midDisplacement = snoise(noisePos *
|
|
4222
|
-
float trebleDisplacement = snoise(noisePos *
|
|
4219
|
+
// Audio-reactive displacement - very low frequencies for smooth waves
|
|
4220
|
+
float bassDisplacement = snoise(noisePos * 0.3 + t * 0.1) * uAudioBass * 0.08 * uAudioReactivity;
|
|
4221
|
+
float midDisplacement = snoise(noisePos * 0.4 + t * 0.12) * uAudioMid * 0.05 * uAudioReactivity;
|
|
4222
|
+
float trebleDisplacement = snoise(noisePos * 0.5 + t * 0.15) * uAudioTreble * 0.02 * uAudioReactivity;
|
|
4223
4223
|
|
|
4224
4224
|
// Combine all displacement
|
|
4225
4225
|
float totalDisplacement = baseNoise + bassDisplacement + midDisplacement + trebleDisplacement;
|
|
@@ -4227,8 +4227,8 @@ void main() {
|
|
|
4227
4227
|
// Apply morphing strength
|
|
4228
4228
|
totalDisplacement *= uMorphStrength;
|
|
4229
4229
|
|
|
4230
|
-
// Add breathing effect
|
|
4231
|
-
float breathing = sin(uTime * 0.
|
|
4230
|
+
// Add breathing effect - very subtle
|
|
4231
|
+
float breathing = sin(uTime * 0.3) * 0.005 * (1.0 + uAudioLevel * 0.2);
|
|
4232
4232
|
totalDisplacement += breathing;
|
|
4233
4233
|
|
|
4234
4234
|
// Apply displacement along normal
|
|
@@ -4451,9 +4451,9 @@ varying vec3 vPosition;
|
|
|
4451
4451
|
varying float vIntensity;
|
|
4452
4452
|
|
|
4453
4453
|
void main() {
|
|
4454
|
-
// Pulsing effect
|
|
4455
|
-
float pulse = sin(uTime * uPulseSpeed) * 0.
|
|
4456
|
-
pulse += uAudioLevel * 0.
|
|
4454
|
+
// Pulsing effect - very subtle
|
|
4455
|
+
float pulse = sin(uTime * uPulseSpeed * 0.3) * 0.03 + 0.97;
|
|
4456
|
+
pulse += uAudioLevel * 0.15;
|
|
4457
4457
|
|
|
4458
4458
|
// Smooth radial glow using pre-calculated intensity
|
|
4459
4459
|
float glow = vIntensity * uGlowIntensity * pulse;
|
|
@@ -4468,7 +4468,7 @@ void main() {
|
|
|
4468
4468
|
// Softer alpha for more diffuse appearance
|
|
4469
4469
|
gl_FragColor = vec4(glowColor, glow * 0.4);
|
|
4470
4470
|
}
|
|
4471
|
-
`,As={primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},oM={size:1,segments:128,colors:As,morphStrength:1,noiseScale:1.5,noiseSpeed:.3,glowIntensity:.8,idleGlowMultiplier:.4,fresnelPower:2.5,rotationSpeed:.1,audioReactivity:3,audioSmoothing:.9,idleMorphMultiplier:.25,colorContrast:1.5};class hu{constructor(e,t={}){this.orb=null,this.glowMesh=null,this.orbMaterial=null,this.glowMaterial=null,this.animationId=null,this.isActive=!1,this.targetRotation={x:0,y:0},this.currentRotation={x:0,y:0},this.audioValues={bass:0,mid:0,treble:0,level:0},this.canvasPadding=3,this.animate=()=>{this.animationId=requestAnimationFrame(this.animate);const a=this.clock.getElapsedTime();if(this.clock.getDelta(),this.orbMaterial){this.orbMaterial.uniforms.uTime.value=a,this.orbMaterial.uniforms.uAudioBass.value=this.audioValues.bass,this.orbMaterial.uniforms.uAudioMid.value=this.audioValues.mid,this.orbMaterial.uniforms.uAudioTreble.value=this.audioValues.treble,this.orbMaterial.uniforms.uAudioLevel.value=this.audioValues.level;const c=this.isActive?this.config.morphStrength*1.5:this.config.morphStrength*this.config.idleMorphMultiplier,l=this.orbMaterial.uniforms.uMorphStrength.value;this.orbMaterial.uniforms.uMorphStrength.value+=(c-l)*.05}if(this.glowMaterial){this.glowMaterial.uniforms.uTime.value=a,this.glowMaterial.uniforms.uAudioLevel.value=this.audioValues.level;const c=this.isActive?this.config.glowIntensity*1.5:this.config.glowIntensity*this.config.idleGlowMultiplier,l=this.glowMaterial.uniforms.uGlowIntensity.value;this.glowMaterial.uniforms.uGlowIntensity.value+=(c-l)*.05}this.currentRotation.x+=(this.targetRotation.x-this.currentRotation.x)*.05,this.currentRotation.y+=(this.targetRotation.y-this.currentRotation.y)*.05,this.orb&&(this.orb.rotation.x=this.currentRotation.x+a*this.config.rotationSpeed*.3,this.orb.rotation.y=this.currentRotation.y+a*this.config.rotationSpeed),this.glowMesh&&(this.glowMesh.rotation.x=this.currentRotation.x+a*this.config.rotationSpeed*.3,this.glowMesh.rotation.y=this.currentRotation.y+a*this.config.rotationSpeed),this.renderer.render(this.scene,this.camera)},this.handleResize=()=>{const a=this.container.clientWidth*this.canvasPadding,c=this.container.clientHeight*this.canvasPadding;this.camera.aspect=a/c,this.camera.updateProjectionMatrix(),this.renderer.setSize(a,c)},this.handleMouseMove=a=>{const c=this.container.getBoundingClientRect(),l=(a.clientX-c.left)/c.width*2-1,d=-((a.clientY-c.top)/c.height)*2+1;this.targetRotation.x=d*.3,this.targetRotation.y=l*.3},this.handleMouseLeave=()=>{this.targetRotation.x=0,this.targetRotation.y=0},this.container=e,this.config={...oM,...t},this.clock=new Nm,this.scene=new Mm;const n=e.clientWidth*this.canvasPadding,s=e.clientHeight*this.canvasPadding,r=n/s;this.camera=new xn(45,r,.1,100),this.camera.position.z=9,this.renderer=new ug({antialias:!0,alpha:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(n,s),this.renderer.setClearColor(0,0);const o=this.renderer.domElement;o.style.position="absolute",o.style.left="50%",o.style.top="50%",o.style.transform="translate(-50%, -50%)",o.style.pointerEvents="none",e.appendChild(o),this.createOrb(),window.addEventListener("resize",this.handleResize),e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseleave",this.handleMouseLeave)}createOrb(){const e={...As,...this.config.colors},t=new Qd(this.config.size,this.config.segments/4);this.orbMaterial=new en({vertexShader:iM,fragmentShader:sM,uniforms:{uTime:{value:0},uAudioBass:{value:0},uAudioMid:{value:0},uAudioTreble:{value:0},uAudioLevel:{value:0},uMorphStrength:{value:this.config.morphStrength},uNoiseScale:{value:this.config.noiseScale},uNoiseSpeed:{value:this.config.noiseSpeed},uAudioReactivity:{value:this.config.audioReactivity},uColorPrimary:{value:new Fe(e.primary)},uColorSecondary:{value:new Fe(e.secondary)},uColorAccent:{value:new Fe(e.accent)},uColorDepth:{value:new Fe(e.depth||As.depth)},uColorHighlight:{value:new Fe(e.highlight||As.highlight)},uFresnelPower:{value:this.config.fresnelPower},uGlowIntensity:{value:this.config.glowIntensity},uColorContrast:{value:this.config.colorContrast}},transparent:!0,side:_i}),this.orb=new Sn(t,this.orbMaterial),this.scene.add(this.orb);const n=new yr(this.config.size,64,64);this.glowMaterial=new en({vertexShader:rM,fragmentShader:aM,uniforms:{uTime:{value:0},uAudioLevel:{value:0},uGlowColor:{value:new Fe(e.glow)},uGlowIntensity:{value:this.config.glowIntensity*.6},uPulseSpeed:{value:2}},transparent:!0,side:tn,blending:Ji,depthWrite:!1}),this.glowMesh=new Sn(n,this.glowMaterial),this.scene.add(this.glowMesh)}updateAudio(e){const t=this.config.audioSmoothing;this.audioValues.bass+=(e.bass-this.audioValues.bass)*t,this.audioValues.mid+=(e.mid-this.audioValues.mid)*t,this.audioValues.treble+=(e.treble-this.audioValues.treble)*t,this.audioValues.level+=(e.level-this.audioValues.level)*t}setSimulatedAudio(e,t,n,s){const r=this.config.audioSmoothing;this.audioValues.bass+=(e-this.audioValues.bass)*r,this.audioValues.mid+=(t-this.audioValues.mid)*r,this.audioValues.treble+=(n-this.audioValues.treble)*r,this.audioValues.level+=(s-this.audioValues.level)*r}setActive(e){this.isActive=e}setColors(e){const t={...As,...this.config.colors,...e};this.orbMaterial&&(this.orbMaterial.uniforms.uColorPrimary.value.set(t.primary),this.orbMaterial.uniforms.uColorSecondary.value.set(t.secondary),this.orbMaterial.uniforms.uColorAccent.value.set(t.accent),this.orbMaterial.uniforms.uColorDepth.value.set(t.depth||As.depth),this.orbMaterial.uniforms.uColorHighlight.value.set(t.highlight||As.highlight)),this.glowMaterial&&this.glowMaterial.uniforms.uGlowColor.value.set(t.glow)}setGlowSettings(e,t){this.config.glowIntensity=e,this.config.idleGlowMultiplier=t}start(){this.animationId===null&&(this.clock.start(),this.animate())}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}getCanvas(){return this.renderer.domElement}destroy(){this.stop(),window.removeEventListener("resize",this.handleResize),this.container.removeEventListener("mousemove",this.handleMouseMove),this.container.removeEventListener("mouseleave",this.handleMouseLeave),this.orb&&(this.orb.geometry.dispose(),this.scene.remove(this.orb)),this.glowMesh&&(this.glowMesh.geometry.dispose(),this.scene.remove(this.glowMesh)),this.orbMaterial&&this.orbMaterial.dispose(),this.glowMaterial&&this.glowMaterial.dispose(),this.renderer.dispose(),this.renderer.domElement.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}class fu{constructor(e={}){this.audioContext=null,this.analyser=null,this.source=null,this.localSource=null,this.mixer=null,this.frequencyData=new Uint8Array(0),this.waveformData=new Float32Array(0),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0,this.smoothingFactor=.3,this.options={fftSize:e.fftSize??2048,smoothingTimeConstant:e.smoothingTimeConstant??.8,minDecibels:e.minDecibels??-90,maxDecibels:e.maxDecibels??-10}}async connectStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect(),this.source=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.source.connect(this.mixer)}async connectLocalStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.localSource&&this.localSource.disconnect(),this.localSource=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.localSource.connect(this.mixer)}setupMixerAndAnalyser(){this.audioContext&&(this.mixer||(this.mixer=this.audioContext.createGain(),this.mixer.gain.value=1),this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,this.mixer.disconnect(),this.mixer.connect(this.analyser),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize))}async connectAudioElement(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect();const t=this.audioContext.createMediaElementSource(e);this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,t.connect(this.analyser),this.analyser.connect(this.audioContext.destination),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize)}getAudioData(){if(!this.analyser)return{bass:0,mid:0,treble:0,level:0,waveform:new Float32Array(0),frequency:new Uint8Array(0)};this.analyser.getByteFrequencyData(this.frequencyData),this.analyser.getFloatTimeDomainData(this.waveformData);const{bass:e,mid:t,treble:n}=this.calculateFrequencyBands(),s=this.calculateOverallLevel();return this.smoothedBass+=(e-this.smoothedBass)*this.smoothingFactor,this.smoothedMid+=(t-this.smoothedMid)*this.smoothingFactor,this.smoothedTreble+=(n-this.smoothedTreble)*this.smoothingFactor,this.smoothedLevel+=(s-this.smoothedLevel)*this.smoothingFactor,{bass:this.smoothedBass,mid:this.smoothedMid,treble:this.smoothedTreble,level:this.smoothedLevel,waveform:this.waveformData,frequency:this.frequencyData}}calculateFrequencyBands(){if(!this.audioContext||this.frequencyData.length===0)return{bass:0,mid:0,treble:0};const e=this.audioContext.sampleRate,t=this.frequencyData.length,n=e/(t*2),s=Math.floor(250/n),r=Math.floor(2e3/n);let o=0,a=0,c=0;for(let h=0;h<t;h++){const f=this.frequencyData[h]/255;h<s?o+=f:h<r?a+=f:c+=f}const l=s>0?o/s:0,d=r-s>0?a/(r-s):0,u=t-r>0?c/(t-r):0;return{bass:Math.pow(l,.8),mid:Math.pow(d,.9),treble:Math.pow(u,1.1)}}calculateOverallLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let n=0;n<this.frequencyData.length;n++)e+=this.frequencyData[n];const t=e/this.frequencyData.length/255;return Math.pow(t,.8)}getPeakLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let t=0;t<this.frequencyData.length;t++)this.frequencyData[t]>e&&(e=this.frequencyData[t]);return e/255}isActive(){return this.audioContext!==null&&this.audioContext.state==="running"}disconnect(){this.source&&(this.source.disconnect(),this.source=null),this.localSource&&(this.localSource.disconnect(),this.localSource=null),this.mixer&&(this.mixer.disconnect(),this.mixer=null),this.analyser&&(this.analyser.disconnect(),this.analyser=null),this.audioContext&&(this.audioContext.close(),this.audioContext=null),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0}getAudioContext(){return this.audioContext}getAnalyser(){return this.analyser}}class $o{constructor(e={}){this.audioContext=null,this.config={enabled:!0,volume:.15,...e}}async ensureContext(){if(!this.config.enabled)return null;if(!this.audioContext)try{this.audioContext=new(window.AudioContext||window.webkitAudioContext)}catch{return console.warn("Web Audio API not supported"),null}return this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.audioContext}async prewarm(){await this.ensureContext()}createTone(e,t,n,s,r="sine"){const o=e.createOscillator(),a=e.createGain();o.type=r,o.frequency.setValueAtTime(t,n);const c=.05,l=.1,d=.7,u=.3;return a.gain.setValueAtTime(0,n),a.gain.linearRampToValueAtTime(this.config.volume,n+c),a.gain.linearRampToValueAtTime(this.config.volume*d,n+c+l),a.gain.setValueAtTime(this.config.volume*d,n+s-u),a.gain.linearRampToValueAtTime(0,n+s),o.connect(a),{oscillator:o,gain:a}}async playCallStartSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const{oscillator:s,gain:r}=this.createTone(e,880,t,.12,"sine");r.connect(n),s.start(t),s.stop(t+.12);const{oscillator:o,gain:a}=this.createTone(e,1046,t+.08,.15,"sine");a.connect(n),o.start(t+.08),o.stop(t+.23),setTimeout(()=>{try{s.disconnect()}catch{}try{o.disconnect()}catch{}},300)}async playCallEndSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const{oscillator:s,gain:r}=this.createTone(e,660,t,.2,"sine");r.connect(n),s.start(t),s.stop(t+.2),setTimeout(()=>{try{s.disconnect()}catch{}},250)}setConfig(e){this.config={...this.config,...e}}setEnabled(e){this.config.enabled=e}setVolume(e){this.config.volume=Math.max(0,Math.min(1,e))}getConfig(){return{...this.config}}isEnabled(){return this.config.enabled}destroy(){this.audioContext&&(this.audioContext.close(),this.audioContext=null)}}const di={default:{primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},emerald:{primary:"#10b981",secondary:"#34d399",accent:"#6ee7b7",glow:"#34d399",atmosphere:"#a7f3d0",depth:"#064e3b",highlight:"#d1fae5"},rose:{primary:"#f43f5e",secondary:"#fb7185",accent:"#fda4af",glow:"#fb7185",atmosphere:"#fecdd3",depth:"#881337",highlight:"#ffe4e6"},amber:{primary:"#f59e0b",secondary:"#fbbf24",accent:"#fcd34d",glow:"#fbbf24",atmosphere:"#fde68a",depth:"#78350f",highlight:"#fef3c7"},cyan:{primary:"#06b6d4",secondary:"#22d3ee",accent:"#67e8f9",glow:"#22d3ee",atmosphere:"#a5f3fc",depth:"#164e63",highlight:"#cffafe"},purple:{primary:"#9333ea",secondary:"#a855f7",accent:"#c084fc",glow:"#a855f7",atmosphere:"#d8b4fe",depth:"#581c87",highlight:"#f3e8ff"},blue:{primary:"#2563eb",secondary:"#3b82f6",accent:"#60a5fa",glow:"#3b82f6",atmosphere:"#93c5fd",depth:"#1e3a8a",highlight:"#dbeafe"}},ui={indigo:{primary:"#3730a3",secondary:"#4338ca",accent:"#4f46e5",glow:"#3730a3",atmosphere:"#4338ca",depth:"#1e1b4b",highlight:"#a5b4fc"},violet:{primary:"#5b21b6",secondary:"#6d28d9",accent:"#7c3aed",glow:"#5b21b6",atmosphere:"#6d28d9",depth:"#2e1065",highlight:"#c4b5fd"},teal:{primary:"#0f766e",secondary:"#0d9488",accent:"#14b8a6",glow:"#0f766e",atmosphere:"#0d9488",depth:"#042f2e",highlight:"#5eead4"},orange:{primary:"#c2410c",secondary:"#ea580c",accent:"#f97316",glow:"#c2410c",atmosphere:"#ea580c",depth:"#431407",highlight:"#fed7aa"},blue:{primary:"#1d4ed8",secondary:"#2563eb",accent:"#3b82f6",glow:"#1d4ed8",atmosphere:"#2563eb",depth:"#1e3a8a",highlight:"#93c5fd"},pink:{primary:"#be185d",secondary:"#db2777",accent:"#ec4899",glow:"#be185d",atmosphere:"#db2777",depth:"#500724",highlight:"#f9a8d4"}};function cM(i,e="dark"){const t=e==="dark"?di:ui;return t[i]||t[Object.keys(t)[0]]}function lM(i="dark"){return Object.keys(i==="dark"?di:ui)}const Sr={default:{dark:{colors:di.default,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.indigo,glowIntensity:1.8,idleGlowMultiplier:1.2}},emerald:{dark:{colors:di.emerald,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.teal,glowIntensity:1.8,idleGlowMultiplier:1.2}},rose:{dark:{colors:di.rose,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.pink,glowIntensity:1.8,idleGlowMultiplier:1.2}},amber:{dark:{colors:di.amber,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.orange,glowIntensity:1.8,idleGlowMultiplier:1.2}},cyan:{dark:{colors:di.cyan,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}},purple:{dark:{colors:di.purple,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.violet,glowIntensity:1.8,idleGlowMultiplier:1.2}},blue:{dark:{colors:di.blue,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}}},dM=Object.fromEntries(Object.entries(Sr).map(([i,e])=>[i,e.dark])),uM=Object.fromEntries(Object.entries(Sr).map(([i,e])=>[i,e.light]));function hg(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function pa(i,e="auto"){const t=Sr[i]||Sr.default,n=e==="auto"?hg():e;return t[n]}function hM(){return Object.keys(Sr)}function fg(i,e,t="auto"){const n=pa(e,t);i.orbColors=n.colors,i.glowIntensity=n.glowIntensity,i.idleGlowMultiplier=n.idleGlowMultiplier}function fM(i,e){if(typeof window>"u")return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{const s=t.matches?"dark":"light";fg(i,e,s)};return n(),t.addEventListener("change",n),()=>{t.removeEventListener("change",n)}}var pM=Object.defineProperty,mM=Object.getOwnPropertyDescriptor,Tt=(i,e,t,n)=>{for(var s=n>1?void 0:n?mM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&pM(e,t,s),s};$.InlineCall=class extends Ui{constructor(){super(...arguments),this.callManager=new ro,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=xa(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Try to call",this.buttonConnectingText="Connecting...",this.size=370,this.containerPadding=45,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale=1.5,this.noiseSpeed=.3,this.fresnelPower=2.5,this.rotationSpeed=.1,this.audioReactivity=3,this.audioSmoothing=.9,this.idleMorphMultiplier=.25,this.colorContrast=1.5,this.soundEnabled=!0,this.soundVolume=.15,this.handleAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectStream(s)}catch(s){console.error("Failed to connect audio stream:",s)}},this.handleLocalAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectLocalStream(s)}catch(s){console.error("Failed to connect local audio stream:",s)}},this.handleMicrophoneEnabled=()=>{this.microphoneEnabled=!0},this.handleMicrophoneDisabled=()=>{this.microphoneEnabled=!1},this.handleStatusChange=e=>{var n,s,r,o,a;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(o=this.orbRenderer)==null||o.setActive(!1),(a=this.audioAnalyzer)==null||a.disconnect(),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle",this.startIdleAnimation())},3e3);break}},this.toggleCall=async()=>{var e;this.agentId&&((e=this.soundManager)==null||e.prewarm(),this.callStatus==="idle"?(this.callStatus="connecting",await this.callManager.makeCall({agentId:this.agentId})):this.callStatus==="connected"&&this.callManager.hangUp())}}connectedCallback(){super.connectedCallback(),this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.soundManager=new $o({enabled:this.soundEnabled,volume:this.soundVolume}),this.callManager.addEventListener("status-changed",this.handleStatusChange),this.callManager.addEventListener("audio-track",this.handleAudioTrack),this.callManager.addEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.addEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.addEventListener("microphone-disabled",this.handleMicrophoneDisabled)}disconnectedCallback(){var e;super.disconnectedCallback(),this.callManager.removeEventListener("status-changed",this.handleStatusChange),this.callManager.removeEventListener("audio-track",this.handleAudioTrack),this.callManager.removeEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.removeEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.removeEventListener("microphone-disabled",this.handleMicrophoneDisabled),this.callManager.hangUp(),this.cleanupOrb(),(e=this.soundManager)==null||e.destroy(),this.soundManager=null}firstUpdated(){this.applyTheme(),this.initializeOrb()}updated(e){var t,n;super.updated(e),e.has("agentId")&&(this.callManager.hangUp(),this.callStatus="idle"),e.has("voiceServiceUrl")&&this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),(e.has("theme")||e.has("themeMode"))&&this.applyTheme(),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}applyTheme(){if(this.theme){const e=pa(this.theme,this.themeMode);this.orbColors=e.colors,this.glowIntensity=e.glowIntensity,this.idleGlowMultiplier=e.idleGlowMultiplier,this.orbRenderer&&(this.orbRenderer.setColors(this.orbColors),this.orbRenderer.setGlowSettings(this.glowIntensity,this.idleGlowMultiplier))}}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new hu(e,{size:1,colors:this.orbColors,glowIntensity:this.glowIntensity,idleGlowMultiplier:this.idleGlowMultiplier,morphStrength:this.morphStrength,noiseScale:this.noiseScale,noiseSpeed:this.noiseSpeed,fresnelPower:this.fresnelPower,rotationSpeed:this.rotationSpeed,audioReactivity:this.audioReactivity,audioSmoothing:this.audioSmoothing,idleMorphMultiplier:this.idleMorphMultiplier,colorContrast:this.colorContrast}),this.audioAnalyzer=new fu,this.orbRenderer.start(),this.startIdleAnimation())}cleanupOrb(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.audioAnalyzer)==null||e.disconnect(),(t=this.orbRenderer)==null||t.destroy(),this.audioAnalyzer=null,this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(this.callStatus!=="idle"||!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.5)*.15+.15,s=Math.sin(t*.7+1)*.12+.12,r=Math.sin(t*.9+2)*.08+.08,o=(n+s+r)/3;this.orbRenderer.setSimulatedAudio(n,s,r,o),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startRealAudioLoop(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{var n;if(this.callStatus!=="connected"||!this.orbRenderer)return;const t=(n=this.audioAnalyzer)==null?void 0:n.getAudioData();t&&this.orbRenderer.updateAudio(t),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}getButtonIcon(){return this.callStatus==="connecting"?Rt`
|
|
4471
|
+
`,As={primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},oM={size:1,segments:128,colors:As,morphStrength:1,noiseScale:.8,noiseSpeed:.15,glowIntensity:.8,idleGlowMultiplier:.4,fresnelPower:2.5,rotationSpeed:.1,audioReactivity:1,audioSmoothing:.03,idleMorphMultiplier:.25,colorContrast:1.5};class hu{constructor(e,t={}){this.orb=null,this.glowMesh=null,this.orbMaterial=null,this.glowMaterial=null,this.animationId=null,this.isActive=!1,this.targetRotation={x:0,y:0},this.currentRotation={x:0,y:0},this.audioValues={bass:0,mid:0,treble:0,level:0},this.smoothedUniforms={bass:0,mid:0,treble:0,level:0},this.canvasPadding=3,this.animate=()=>{this.animationId=requestAnimationFrame(this.animate);const a=this.clock.getElapsedTime();this.clock.getDelta();const c=.02;if(this.smoothedUniforms.bass+=(this.audioValues.bass-this.smoothedUniforms.bass)*c,this.smoothedUniforms.mid+=(this.audioValues.mid-this.smoothedUniforms.mid)*c,this.smoothedUniforms.treble+=(this.audioValues.treble-this.smoothedUniforms.treble)*c,this.smoothedUniforms.level+=(this.audioValues.level-this.smoothedUniforms.level)*c,this.orbMaterial){this.orbMaterial.uniforms.uTime.value=a,this.orbMaterial.uniforms.uAudioBass.value=this.smoothedUniforms.bass,this.orbMaterial.uniforms.uAudioMid.value=this.smoothedUniforms.mid,this.orbMaterial.uniforms.uAudioTreble.value=this.smoothedUniforms.treble,this.orbMaterial.uniforms.uAudioLevel.value=this.smoothedUniforms.level;const l=this.isActive?this.config.morphStrength*1.2:this.config.morphStrength*this.config.idleMorphMultiplier,d=this.orbMaterial.uniforms.uMorphStrength.value;this.orbMaterial.uniforms.uMorphStrength.value+=(l-d)*.02}if(this.glowMaterial){this.glowMaterial.uniforms.uTime.value=a,this.glowMaterial.uniforms.uAudioLevel.value=this.smoothedUniforms.level;const l=this.isActive?this.config.glowIntensity*1.2:this.config.glowIntensity*this.config.idleGlowMultiplier,d=this.glowMaterial.uniforms.uGlowIntensity.value;this.glowMaterial.uniforms.uGlowIntensity.value+=(l-d)*.02}this.currentRotation.x+=(this.targetRotation.x-this.currentRotation.x)*.05,this.currentRotation.y+=(this.targetRotation.y-this.currentRotation.y)*.05,this.orb&&(this.orb.rotation.x=this.currentRotation.x+a*this.config.rotationSpeed*.3,this.orb.rotation.y=this.currentRotation.y+a*this.config.rotationSpeed),this.glowMesh&&(this.glowMesh.rotation.x=this.currentRotation.x+a*this.config.rotationSpeed*.3,this.glowMesh.rotation.y=this.currentRotation.y+a*this.config.rotationSpeed),this.renderer.render(this.scene,this.camera)},this.handleResize=()=>{const a=this.container.clientWidth*this.canvasPadding,c=this.container.clientHeight*this.canvasPadding;this.camera.aspect=a/c,this.camera.updateProjectionMatrix(),this.renderer.setSize(a,c)},this.handleMouseMove=a=>{const c=this.container.getBoundingClientRect(),l=(a.clientX-c.left)/c.width*2-1,d=-((a.clientY-c.top)/c.height)*2+1;this.targetRotation.x=d*.3,this.targetRotation.y=l*.3},this.handleMouseLeave=()=>{this.targetRotation.x=0,this.targetRotation.y=0},this.container=e,this.config={...oM,...t},this.clock=new Nm,this.scene=new Mm;const n=e.clientWidth*this.canvasPadding,s=e.clientHeight*this.canvasPadding,r=n/s;this.camera=new xn(45,r,.1,100),this.camera.position.z=9,this.renderer=new ug({antialias:!0,alpha:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(n,s),this.renderer.setClearColor(0,0);const o=this.renderer.domElement;o.style.position="absolute",o.style.left="50%",o.style.top="50%",o.style.transform="translate(-50%, -50%)",o.style.pointerEvents="none",e.appendChild(o),this.createOrb(),window.addEventListener("resize",this.handleResize),e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseleave",this.handleMouseLeave)}createOrb(){const e={...As,...this.config.colors},t=new Qd(this.config.size,this.config.segments/4);this.orbMaterial=new en({vertexShader:iM,fragmentShader:sM,uniforms:{uTime:{value:0},uAudioBass:{value:0},uAudioMid:{value:0},uAudioTreble:{value:0},uAudioLevel:{value:0},uMorphStrength:{value:this.config.morphStrength},uNoiseScale:{value:this.config.noiseScale},uNoiseSpeed:{value:this.config.noiseSpeed},uAudioReactivity:{value:this.config.audioReactivity},uColorPrimary:{value:new Fe(e.primary)},uColorSecondary:{value:new Fe(e.secondary)},uColorAccent:{value:new Fe(e.accent)},uColorDepth:{value:new Fe(e.depth||As.depth)},uColorHighlight:{value:new Fe(e.highlight||As.highlight)},uFresnelPower:{value:this.config.fresnelPower},uGlowIntensity:{value:this.config.glowIntensity},uColorContrast:{value:this.config.colorContrast}},transparent:!0,side:_i}),this.orb=new Sn(t,this.orbMaterial),this.scene.add(this.orb);const n=new yr(this.config.size,64,64);this.glowMaterial=new en({vertexShader:rM,fragmentShader:aM,uniforms:{uTime:{value:0},uAudioLevel:{value:0},uGlowColor:{value:new Fe(e.glow)},uGlowIntensity:{value:this.config.glowIntensity*.6},uPulseSpeed:{value:2}},transparent:!0,side:tn,blending:Ji,depthWrite:!1}),this.glowMesh=new Sn(n,this.glowMaterial),this.scene.add(this.glowMesh)}updateAudio(e){const t=this.config.audioSmoothing;this.audioValues.bass+=(e.bass-this.audioValues.bass)*t,this.audioValues.mid+=(e.mid-this.audioValues.mid)*t,this.audioValues.treble+=(e.treble-this.audioValues.treble)*t,this.audioValues.level+=(e.level-this.audioValues.level)*t}setSimulatedAudio(e,t,n,s){const r=this.config.audioSmoothing;this.audioValues.bass+=(e-this.audioValues.bass)*r,this.audioValues.mid+=(t-this.audioValues.mid)*r,this.audioValues.treble+=(n-this.audioValues.treble)*r,this.audioValues.level+=(s-this.audioValues.level)*r}setActive(e){this.isActive=e}setColors(e){const t={...As,...this.config.colors,...e};this.orbMaterial&&(this.orbMaterial.uniforms.uColorPrimary.value.set(t.primary),this.orbMaterial.uniforms.uColorSecondary.value.set(t.secondary),this.orbMaterial.uniforms.uColorAccent.value.set(t.accent),this.orbMaterial.uniforms.uColorDepth.value.set(t.depth||As.depth),this.orbMaterial.uniforms.uColorHighlight.value.set(t.highlight||As.highlight)),this.glowMaterial&&this.glowMaterial.uniforms.uGlowColor.value.set(t.glow)}setGlowSettings(e,t){this.config.glowIntensity=e,this.config.idleGlowMultiplier=t}start(){this.animationId===null&&(this.clock.start(),this.animate())}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}getCanvas(){return this.renderer.domElement}destroy(){this.stop(),window.removeEventListener("resize",this.handleResize),this.container.removeEventListener("mousemove",this.handleMouseMove),this.container.removeEventListener("mouseleave",this.handleMouseLeave),this.orb&&(this.orb.geometry.dispose(),this.scene.remove(this.orb)),this.glowMesh&&(this.glowMesh.geometry.dispose(),this.scene.remove(this.glowMesh)),this.orbMaterial&&this.orbMaterial.dispose(),this.glowMaterial&&this.glowMaterial.dispose(),this.renderer.dispose(),this.renderer.domElement.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}class fu{constructor(e={}){this.audioContext=null,this.analyser=null,this.source=null,this.localSource=null,this.mixer=null,this.frequencyData=new Uint8Array(0),this.waveformData=new Float32Array(0),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0,this.smoothingFactor=.04,this.options={fftSize:e.fftSize??2048,smoothingTimeConstant:e.smoothingTimeConstant??.8,minDecibels:e.minDecibels??-90,maxDecibels:e.maxDecibels??-10}}async connectStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect(),this.source=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.source.connect(this.mixer)}async connectLocalStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.localSource&&this.localSource.disconnect(),this.localSource=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.localSource.connect(this.mixer)}setupMixerAndAnalyser(){this.audioContext&&(this.mixer||(this.mixer=this.audioContext.createGain(),this.mixer.gain.value=1),this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,this.mixer.disconnect(),this.mixer.connect(this.analyser),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize))}async connectAudioElement(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect();const t=this.audioContext.createMediaElementSource(e);this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,t.connect(this.analyser),this.analyser.connect(this.audioContext.destination),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize)}getAudioData(){if(!this.analyser)return{bass:0,mid:0,treble:0,level:0,waveform:new Float32Array(0),frequency:new Uint8Array(0)};this.analyser.getByteFrequencyData(this.frequencyData),this.analyser.getFloatTimeDomainData(this.waveformData);const{bass:e,mid:t,treble:n}=this.calculateFrequencyBands(),s=this.calculateOverallLevel();return this.smoothedBass+=(e-this.smoothedBass)*this.smoothingFactor,this.smoothedMid+=(t-this.smoothedMid)*this.smoothingFactor,this.smoothedTreble+=(n-this.smoothedTreble)*this.smoothingFactor,this.smoothedLevel+=(s-this.smoothedLevel)*this.smoothingFactor,{bass:this.smoothedBass,mid:this.smoothedMid,treble:this.smoothedTreble,level:this.smoothedLevel,waveform:this.waveformData,frequency:this.frequencyData}}calculateFrequencyBands(){if(!this.audioContext||this.frequencyData.length===0)return{bass:0,mid:0,treble:0};const e=this.audioContext.sampleRate,t=this.frequencyData.length,n=e/(t*2),s=Math.floor(250/n),r=Math.floor(2e3/n);let o=0,a=0,c=0;for(let h=0;h<t;h++){const f=this.frequencyData[h]/255;h<s?o+=f:h<r?a+=f:c+=f}const l=s>0?o/s:0,d=r-s>0?a/(r-s):0,u=t-r>0?c/(t-r):0;return{bass:Math.pow(l,.8),mid:Math.pow(d,.9),treble:Math.pow(u,1.1)}}calculateOverallLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let n=0;n<this.frequencyData.length;n++)e+=this.frequencyData[n];const t=e/this.frequencyData.length/255;return Math.pow(t,.8)}getPeakLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let t=0;t<this.frequencyData.length;t++)this.frequencyData[t]>e&&(e=this.frequencyData[t]);return e/255}isActive(){return this.audioContext!==null&&this.audioContext.state==="running"}disconnect(){this.source&&(this.source.disconnect(),this.source=null),this.localSource&&(this.localSource.disconnect(),this.localSource=null),this.mixer&&(this.mixer.disconnect(),this.mixer=null),this.analyser&&(this.analyser.disconnect(),this.analyser=null),this.audioContext&&(this.audioContext.close(),this.audioContext=null),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0}getAudioContext(){return this.audioContext}getAnalyser(){return this.analyser}}class $o{constructor(e={}){this.audioContext=null,this.config={enabled:!0,volume:.15,...e}}async ensureContext(){if(!this.config.enabled)return null;if(!this.audioContext)try{this.audioContext=new(window.AudioContext||window.webkitAudioContext)}catch{return console.warn("Web Audio API not supported"),null}return this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.audioContext}async prewarm(){await this.ensureContext()}createTone(e,t,n,s,r="sine"){const o=e.createOscillator(),a=e.createGain();o.type=r,o.frequency.setValueAtTime(t,n);const c=.05,l=.1,d=.7,u=.3;return a.gain.setValueAtTime(0,n),a.gain.linearRampToValueAtTime(this.config.volume,n+c),a.gain.linearRampToValueAtTime(this.config.volume*d,n+c+l),a.gain.setValueAtTime(this.config.volume*d,n+s-u),a.gain.linearRampToValueAtTime(0,n+s),o.connect(a),{oscillator:o,gain:a}}async playCallStartSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const{oscillator:s,gain:r}=this.createTone(e,880,t,.12,"sine");r.connect(n),s.start(t),s.stop(t+.12);const{oscillator:o,gain:a}=this.createTone(e,1046,t+.08,.15,"sine");a.connect(n),o.start(t+.08),o.stop(t+.23),setTimeout(()=>{try{s.disconnect()}catch{}try{o.disconnect()}catch{}},300)}async playCallEndSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const{oscillator:s,gain:r}=this.createTone(e,660,t,.2,"sine");r.connect(n),s.start(t),s.stop(t+.2),setTimeout(()=>{try{s.disconnect()}catch{}},250)}setConfig(e){this.config={...this.config,...e}}setEnabled(e){this.config.enabled=e}setVolume(e){this.config.volume=Math.max(0,Math.min(1,e))}getConfig(){return{...this.config}}isEnabled(){return this.config.enabled}destroy(){this.audioContext&&(this.audioContext.close(),this.audioContext=null)}}const di={default:{primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},emerald:{primary:"#10b981",secondary:"#34d399",accent:"#6ee7b7",glow:"#34d399",atmosphere:"#a7f3d0",depth:"#064e3b",highlight:"#d1fae5"},rose:{primary:"#f43f5e",secondary:"#fb7185",accent:"#fda4af",glow:"#fb7185",atmosphere:"#fecdd3",depth:"#881337",highlight:"#ffe4e6"},amber:{primary:"#f59e0b",secondary:"#fbbf24",accent:"#fcd34d",glow:"#fbbf24",atmosphere:"#fde68a",depth:"#78350f",highlight:"#fef3c7"},cyan:{primary:"#06b6d4",secondary:"#22d3ee",accent:"#67e8f9",glow:"#22d3ee",atmosphere:"#a5f3fc",depth:"#164e63",highlight:"#cffafe"},purple:{primary:"#9333ea",secondary:"#a855f7",accent:"#c084fc",glow:"#a855f7",atmosphere:"#d8b4fe",depth:"#581c87",highlight:"#f3e8ff"},blue:{primary:"#2563eb",secondary:"#3b82f6",accent:"#60a5fa",glow:"#3b82f6",atmosphere:"#93c5fd",depth:"#1e3a8a",highlight:"#dbeafe"}},ui={indigo:{primary:"#3730a3",secondary:"#4338ca",accent:"#4f46e5",glow:"#3730a3",atmosphere:"#4338ca",depth:"#1e1b4b",highlight:"#a5b4fc"},violet:{primary:"#5b21b6",secondary:"#6d28d9",accent:"#7c3aed",glow:"#5b21b6",atmosphere:"#6d28d9",depth:"#2e1065",highlight:"#c4b5fd"},teal:{primary:"#0f766e",secondary:"#0d9488",accent:"#14b8a6",glow:"#0f766e",atmosphere:"#0d9488",depth:"#042f2e",highlight:"#5eead4"},orange:{primary:"#c2410c",secondary:"#ea580c",accent:"#f97316",glow:"#c2410c",atmosphere:"#ea580c",depth:"#431407",highlight:"#fed7aa"},blue:{primary:"#1d4ed8",secondary:"#2563eb",accent:"#3b82f6",glow:"#1d4ed8",atmosphere:"#2563eb",depth:"#1e3a8a",highlight:"#93c5fd"},pink:{primary:"#be185d",secondary:"#db2777",accent:"#ec4899",glow:"#be185d",atmosphere:"#db2777",depth:"#500724",highlight:"#f9a8d4"}};function cM(i,e="dark"){const t=e==="dark"?di:ui;return t[i]||t[Object.keys(t)[0]]}function lM(i="dark"){return Object.keys(i==="dark"?di:ui)}const Sr={default:{dark:{colors:di.default,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.indigo,glowIntensity:1.8,idleGlowMultiplier:1.2}},emerald:{dark:{colors:di.emerald,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.teal,glowIntensity:1.8,idleGlowMultiplier:1.2}},rose:{dark:{colors:di.rose,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.pink,glowIntensity:1.8,idleGlowMultiplier:1.2}},amber:{dark:{colors:di.amber,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.orange,glowIntensity:1.8,idleGlowMultiplier:1.2}},cyan:{dark:{colors:di.cyan,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}},purple:{dark:{colors:di.purple,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.violet,glowIntensity:1.8,idleGlowMultiplier:1.2}},blue:{dark:{colors:di.blue,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:ui.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}}},dM=Object.fromEntries(Object.entries(Sr).map(([i,e])=>[i,e.dark])),uM=Object.fromEntries(Object.entries(Sr).map(([i,e])=>[i,e.light]));function hg(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function pa(i,e="auto"){const t=Sr[i]||Sr.default,n=e==="auto"?hg():e;return t[n]}function hM(){return Object.keys(Sr)}function fg(i,e,t="auto"){const n=pa(e,t);i.orbColors=n.colors,i.glowIntensity=n.glowIntensity,i.idleGlowMultiplier=n.idleGlowMultiplier}function fM(i,e){if(typeof window>"u")return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{const s=t.matches?"dark":"light";fg(i,e,s)};return n(),t.addEventListener("change",n),()=>{t.removeEventListener("change",n)}}var pM=Object.defineProperty,mM=Object.getOwnPropertyDescriptor,Tt=(i,e,t,n)=>{for(var s=n>1?void 0:n?mM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&pM(e,t,s),s};$.InlineCall=class extends Ui{constructor(){super(...arguments),this.callManager=new ro,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=xa(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Try to call",this.buttonConnectingText="Connecting...",this.size=370,this.containerPadding=45,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale=.8,this.noiseSpeed=.15,this.fresnelPower=2.5,this.rotationSpeed=.1,this.audioReactivity=1,this.audioSmoothing=.03,this.idleMorphMultiplier=.25,this.colorContrast=1.5,this.soundEnabled=!0,this.soundVolume=.15,this.handleAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectStream(s)}catch(s){console.error("Failed to connect audio stream:",s)}},this.handleLocalAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectLocalStream(s)}catch(s){console.error("Failed to connect local audio stream:",s)}},this.handleMicrophoneEnabled=()=>{this.microphoneEnabled=!0},this.handleMicrophoneDisabled=()=>{this.microphoneEnabled=!1},this.handleStatusChange=e=>{var n,s,r,o,a;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(o=this.orbRenderer)==null||o.setActive(!1),(a=this.audioAnalyzer)==null||a.disconnect(),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle",this.startIdleAnimation())},3e3);break}},this.toggleCall=async()=>{var e;this.agentId&&((e=this.soundManager)==null||e.prewarm(),this.callStatus==="idle"?(this.callStatus="connecting",await this.callManager.makeCall({agentId:this.agentId})):this.callStatus==="connected"&&this.callManager.hangUp())}}connectedCallback(){super.connectedCallback(),this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.soundManager=new $o({enabled:this.soundEnabled,volume:this.soundVolume}),this.callManager.addEventListener("status-changed",this.handleStatusChange),this.callManager.addEventListener("audio-track",this.handleAudioTrack),this.callManager.addEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.addEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.addEventListener("microphone-disabled",this.handleMicrophoneDisabled)}disconnectedCallback(){var e;super.disconnectedCallback(),this.callManager.removeEventListener("status-changed",this.handleStatusChange),this.callManager.removeEventListener("audio-track",this.handleAudioTrack),this.callManager.removeEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.removeEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.removeEventListener("microphone-disabled",this.handleMicrophoneDisabled),this.callManager.hangUp(),this.cleanupOrb(),(e=this.soundManager)==null||e.destroy(),this.soundManager=null}firstUpdated(){this.applyTheme(),this.initializeOrb()}updated(e){var t,n;super.updated(e),e.has("agentId")&&(this.callManager.hangUp(),this.callStatus="idle"),e.has("voiceServiceUrl")&&this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),(e.has("theme")||e.has("themeMode"))&&this.applyTheme(),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}applyTheme(){if(this.theme){const e=pa(this.theme,this.themeMode);this.orbColors=e.colors,this.glowIntensity=e.glowIntensity,this.idleGlowMultiplier=e.idleGlowMultiplier,this.orbRenderer&&(this.orbRenderer.setColors(this.orbColors),this.orbRenderer.setGlowSettings(this.glowIntensity,this.idleGlowMultiplier))}}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new hu(e,{size:1,colors:this.orbColors,glowIntensity:this.glowIntensity,idleGlowMultiplier:this.idleGlowMultiplier,morphStrength:this.morphStrength,noiseScale:this.noiseScale,noiseSpeed:this.noiseSpeed,fresnelPower:this.fresnelPower,rotationSpeed:this.rotationSpeed,audioReactivity:this.audioReactivity,audioSmoothing:this.audioSmoothing,idleMorphMultiplier:this.idleMorphMultiplier,colorContrast:this.colorContrast}),this.audioAnalyzer=new fu,this.orbRenderer.start(),this.startIdleAnimation())}cleanupOrb(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.audioAnalyzer)==null||e.disconnect(),(t=this.orbRenderer)==null||t.destroy(),this.audioAnalyzer=null,this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(this.callStatus!=="idle"||!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.5)*.15+.15,s=Math.sin(t*.7+1)*.12+.12,r=Math.sin(t*.9+2)*.08+.08,o=(n+s+r)/3;this.orbRenderer.setSimulatedAudio(n,s,r,o),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startRealAudioLoop(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{var n;if(this.callStatus!=="connected"||!this.orbRenderer)return;const t=(n=this.audioAnalyzer)==null?void 0:n.getAudioData();t&&this.orbRenderer.updateAudio(t),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}getButtonIcon(){return this.callStatus==="connecting"?Rt`
|
|
4472
4472
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" class="hanc-spinner">
|
|
4473
4473
|
<circle
|
|
4474
4474
|
cx="8"
|
|
@@ -4582,7 +4582,7 @@ void main() {
|
|
|
4582
4582
|
|
|
4583
4583
|
.call-button {
|
|
4584
4584
|
position: absolute;
|
|
4585
|
-
top:
|
|
4585
|
+
top: 48%;
|
|
4586
4586
|
left: 50%;
|
|
4587
4587
|
transform: translate(-50%, -50%);
|
|
4588
4588
|
display: flex;
|
|
@@ -4750,7 +4750,7 @@ void main() {
|
|
|
4750
4750
|
display: inline-block;
|
|
4751
4751
|
contain: layout style;
|
|
4752
4752
|
}
|
|
4753
|
-
`,Tt([pe({type:String,attribute:"agent-id"})],$.InlineCall.prototype,"agentId",2),Tt([pe({type:String,attribute:"voice-service-url"})],$.InlineCall.prototype,"voiceServiceUrl",2),Tt([Fi()],$.InlineCall.prototype,"callStatus",2),Tt([Fi()],$.InlineCall.prototype,"microphoneEnabled",2),Tt([pe({type:String,attribute:"button-start-text"})],$.InlineCall.prototype,"buttonStartText",2),Tt([pe({type:String,attribute:"button-connecting-text"})],$.InlineCall.prototype,"buttonConnectingText",2),Tt([pe({type:Number,attribute:"size"})],$.InlineCall.prototype,"size",2),Tt([pe({type:Number,attribute:"container-padding"})],$.InlineCall.prototype,"containerPadding",2),Tt([pe({type:String,attribute:"theme",reflect:!0})],$.InlineCall.prototype,"theme",2),Tt([pe({type:String,attribute:"theme-mode"})],$.InlineCall.prototype,"themeMode",2),Tt([pe({type:Object,attribute:"orb-colors"})],$.InlineCall.prototype,"orbColors",2),Tt([pe({type:Number,attribute:"glow-intensity"})],$.InlineCall.prototype,"glowIntensity",2),Tt([pe({type:Number,attribute:"idle-glow-multiplier"})],$.InlineCall.prototype,"idleGlowMultiplier",2),Tt([pe({type:Number,attribute:"morph-strength"})],$.InlineCall.prototype,"morphStrength",2),Tt([pe({type:Number,attribute:"noise-scale"})],$.InlineCall.prototype,"noiseScale",2),Tt([pe({type:Number,attribute:"noise-speed"})],$.InlineCall.prototype,"noiseSpeed",2),Tt([pe({type:Number,attribute:"fresnel-power"})],$.InlineCall.prototype,"fresnelPower",2),Tt([pe({type:Number,attribute:"rotation-speed"})],$.InlineCall.prototype,"rotationSpeed",2),Tt([pe({type:Number,attribute:"audio-reactivity"})],$.InlineCall.prototype,"audioReactivity",2),Tt([pe({type:Number,attribute:"audio-smoothing"})],$.InlineCall.prototype,"audioSmoothing",2),Tt([pe({type:Number,attribute:"idle-morph-multiplier"})],$.InlineCall.prototype,"idleMorphMultiplier",2),Tt([pe({type:Number,attribute:"color-contrast"})],$.InlineCall.prototype,"colorContrast",2),Tt([pe({type:Boolean,attribute:"sound-enabled"})],$.InlineCall.prototype,"soundEnabled",2),Tt([pe({type:Number,attribute:"sound-volume"})],$.InlineCall.prototype,"soundVolume",2),$.InlineCall=Tt([_a("hanc-ai-inline-call")],$.InlineCall);var gM=Object.defineProperty,vM=Object.getOwnPropertyDescriptor,Ct=(i,e,t,n)=>{for(var s=n>1?void 0:n?vM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&gM(e,t,s),s};$.FloatingCall=class extends Ui{constructor(){super(...arguments),this.callManager=new ro,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=xa(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Call",this.buttonConnectingText="Connecting...",this.position="bottom-right",this.size=120,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale
|
|
4753
|
+
`,Tt([pe({type:String,attribute:"agent-id"})],$.InlineCall.prototype,"agentId",2),Tt([pe({type:String,attribute:"voice-service-url"})],$.InlineCall.prototype,"voiceServiceUrl",2),Tt([Fi()],$.InlineCall.prototype,"callStatus",2),Tt([Fi()],$.InlineCall.prototype,"microphoneEnabled",2),Tt([pe({type:String,attribute:"button-start-text"})],$.InlineCall.prototype,"buttonStartText",2),Tt([pe({type:String,attribute:"button-connecting-text"})],$.InlineCall.prototype,"buttonConnectingText",2),Tt([pe({type:Number,attribute:"size"})],$.InlineCall.prototype,"size",2),Tt([pe({type:Number,attribute:"container-padding"})],$.InlineCall.prototype,"containerPadding",2),Tt([pe({type:String,attribute:"theme",reflect:!0})],$.InlineCall.prototype,"theme",2),Tt([pe({type:String,attribute:"theme-mode"})],$.InlineCall.prototype,"themeMode",2),Tt([pe({type:Object,attribute:"orb-colors"})],$.InlineCall.prototype,"orbColors",2),Tt([pe({type:Number,attribute:"glow-intensity"})],$.InlineCall.prototype,"glowIntensity",2),Tt([pe({type:Number,attribute:"idle-glow-multiplier"})],$.InlineCall.prototype,"idleGlowMultiplier",2),Tt([pe({type:Number,attribute:"morph-strength"})],$.InlineCall.prototype,"morphStrength",2),Tt([pe({type:Number,attribute:"noise-scale"})],$.InlineCall.prototype,"noiseScale",2),Tt([pe({type:Number,attribute:"noise-speed"})],$.InlineCall.prototype,"noiseSpeed",2),Tt([pe({type:Number,attribute:"fresnel-power"})],$.InlineCall.prototype,"fresnelPower",2),Tt([pe({type:Number,attribute:"rotation-speed"})],$.InlineCall.prototype,"rotationSpeed",2),Tt([pe({type:Number,attribute:"audio-reactivity"})],$.InlineCall.prototype,"audioReactivity",2),Tt([pe({type:Number,attribute:"audio-smoothing"})],$.InlineCall.prototype,"audioSmoothing",2),Tt([pe({type:Number,attribute:"idle-morph-multiplier"})],$.InlineCall.prototype,"idleMorphMultiplier",2),Tt([pe({type:Number,attribute:"color-contrast"})],$.InlineCall.prototype,"colorContrast",2),Tt([pe({type:Boolean,attribute:"sound-enabled"})],$.InlineCall.prototype,"soundEnabled",2),Tt([pe({type:Number,attribute:"sound-volume"})],$.InlineCall.prototype,"soundVolume",2),$.InlineCall=Tt([_a("hanc-ai-inline-call")],$.InlineCall);var gM=Object.defineProperty,vM=Object.getOwnPropertyDescriptor,Ct=(i,e,t,n)=>{for(var s=n>1?void 0:n?vM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&gM(e,t,s),s};$.FloatingCall=class extends Ui{constructor(){super(...arguments),this.callManager=new ro,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=xa(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Call",this.buttonConnectingText="Connecting...",this.position="bottom-right",this.size=120,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale=.8,this.noiseSpeed=.15,this.fresnelPower=2.5,this.rotationSpeed=.1,this.audioReactivity=1,this.audioSmoothing=.03,this.idleMorphMultiplier=.25,this.colorContrast=1.5,this.soundEnabled=!0,this.soundVolume=.15,this.handleAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectStream(s)}catch(s){console.error("Failed to connect audio stream:",s)}},this.handleLocalAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectLocalStream(s)}catch(s){console.error("Failed to connect local audio stream:",s)}},this.handleMicrophoneEnabled=()=>{this.microphoneEnabled=!0},this.handleMicrophoneDisabled=()=>{this.microphoneEnabled=!1},this.handleStatusChange=e=>{var n,s,r,o,a;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(o=this.orbRenderer)==null||o.setActive(!1),(a=this.audioAnalyzer)==null||a.disconnect(),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle",this.startIdleAnimation())},3e3);break}},this.toggleCall=async()=>{var e;this.agentId&&((e=this.soundManager)==null||e.prewarm(),this.callStatus==="idle"?(this.callStatus="connecting",await this.callManager.makeCall({agentId:this.agentId})):this.callStatus==="connected"&&this.callManager.hangUp())}}connectedCallback(){super.connectedCallback(),this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.soundManager=new $o({enabled:this.soundEnabled,volume:this.soundVolume}),this.callManager.addEventListener("status-changed",this.handleStatusChange),this.callManager.addEventListener("audio-track",this.handleAudioTrack),this.callManager.addEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.addEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.addEventListener("microphone-disabled",this.handleMicrophoneDisabled)}disconnectedCallback(){var e;super.disconnectedCallback(),this.callManager.removeEventListener("status-changed",this.handleStatusChange),this.callManager.removeEventListener("audio-track",this.handleAudioTrack),this.callManager.removeEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.removeEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.removeEventListener("microphone-disabled",this.handleMicrophoneDisabled),this.callManager.hangUp(),this.cleanupOrb(),(e=this.soundManager)==null||e.destroy(),this.soundManager=null}firstUpdated(){this.applyTheme(),this.initializeOrb()}updated(e){var t,n;super.updated(e),e.has("agentId")&&(this.callManager.hangUp(),this.callStatus="idle"),e.has("voiceServiceUrl")&&this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),(e.has("theme")||e.has("themeMode"))&&this.applyTheme(),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}applyTheme(){if(this.theme){const e=pa(this.theme,this.themeMode);this.orbColors=e.colors,this.glowIntensity=e.glowIntensity,this.idleGlowMultiplier=e.idleGlowMultiplier,this.orbRenderer&&(this.orbRenderer.setColors(this.orbColors),this.orbRenderer.setGlowSettings(this.glowIntensity,this.idleGlowMultiplier))}}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new hu(e,{size:1,colors:this.orbColors,glowIntensity:this.glowIntensity,idleGlowMultiplier:this.idleGlowMultiplier,morphStrength:this.morphStrength,noiseScale:this.noiseScale,noiseSpeed:this.noiseSpeed,fresnelPower:this.fresnelPower,rotationSpeed:this.rotationSpeed,audioReactivity:this.audioReactivity,audioSmoothing:this.audioSmoothing,idleMorphMultiplier:this.idleMorphMultiplier,colorContrast:this.colorContrast}),this.audioAnalyzer=new fu,this.orbRenderer.start(),this.startIdleAnimation())}cleanupOrb(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.audioAnalyzer)==null||e.disconnect(),(t=this.orbRenderer)==null||t.destroy(),this.audioAnalyzer=null,this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(this.callStatus!=="idle"||!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.5)*.15+.15,s=Math.sin(t*.7+1)*.12+.12,r=Math.sin(t*.9+2)*.08+.08,o=(n+s+r)/3;this.orbRenderer.setSimulatedAudio(n,s,r,o),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startRealAudioLoop(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{var n;if(this.callStatus!=="connected"||!this.orbRenderer)return;const t=(n=this.audioAnalyzer)==null?void 0:n.getAudioData();t&&this.orbRenderer.updateAudio(t),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}getButtonIcon(){return this.callStatus==="connecting"?Rt`
|
|
4754
4754
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" class="hanc-spinner">
|
|
4755
4755
|
<circle
|
|
4756
4756
|
cx="8"
|
|
@@ -4852,7 +4852,7 @@ void main() {
|
|
|
4852
4852
|
|
|
4853
4853
|
.call-button {
|
|
4854
4854
|
position: absolute;
|
|
4855
|
-
top:
|
|
4855
|
+
top: 48%;
|
|
4856
4856
|
left: 50%;
|
|
4857
4857
|
transform: translate(-50%, -50%);
|
|
4858
4858
|
display: flex;
|
|
@@ -5017,7 +5017,7 @@ void main() {
|
|
|
5017
5017
|
:host {
|
|
5018
5018
|
display: block;
|
|
5019
5019
|
}
|
|
5020
|
-
`,Ct([pe({type:String,attribute:"agent-id"})],$.FloatingCall.prototype,"agentId",2),Ct([pe({type:String,attribute:"voice-service-url"})],$.FloatingCall.prototype,"voiceServiceUrl",2),Ct([Fi()],$.FloatingCall.prototype,"callStatus",2),Ct([Fi()],$.FloatingCall.prototype,"microphoneEnabled",2),Ct([pe({type:String,attribute:"button-start-text"})],$.FloatingCall.prototype,"buttonStartText",2),Ct([pe({type:String,attribute:"button-connecting-text"})],$.FloatingCall.prototype,"buttonConnectingText",2),Ct([pe({type:String,attribute:"position"})],$.FloatingCall.prototype,"position",2),Ct([pe({type:Number,attribute:"size"})],$.FloatingCall.prototype,"size",2),Ct([pe({type:String,attribute:"theme"})],$.FloatingCall.prototype,"theme",2),Ct([pe({type:String,attribute:"theme-mode"})],$.FloatingCall.prototype,"themeMode",2),Ct([pe({type:Object,attribute:"orb-colors"})],$.FloatingCall.prototype,"orbColors",2),Ct([pe({type:Number,attribute:"glow-intensity"})],$.FloatingCall.prototype,"glowIntensity",2),Ct([pe({type:Number,attribute:"idle-glow-multiplier"})],$.FloatingCall.prototype,"idleGlowMultiplier",2),Ct([pe({type:Number,attribute:"morph-strength"})],$.FloatingCall.prototype,"morphStrength",2),Ct([pe({type:Number,attribute:"noise-scale"})],$.FloatingCall.prototype,"noiseScale",2),Ct([pe({type:Number,attribute:"noise-speed"})],$.FloatingCall.prototype,"noiseSpeed",2),Ct([pe({type:Number,attribute:"fresnel-power"})],$.FloatingCall.prototype,"fresnelPower",2),Ct([pe({type:Number,attribute:"rotation-speed"})],$.FloatingCall.prototype,"rotationSpeed",2),Ct([pe({type:Number,attribute:"audio-reactivity"})],$.FloatingCall.prototype,"audioReactivity",2),Ct([pe({type:Number,attribute:"audio-smoothing"})],$.FloatingCall.prototype,"audioSmoothing",2),Ct([pe({type:Number,attribute:"idle-morph-multiplier"})],$.FloatingCall.prototype,"idleMorphMultiplier",2),Ct([pe({type:Number,attribute:"color-contrast"})],$.FloatingCall.prototype,"colorContrast",2),Ct([pe({type:Boolean,attribute:"sound-enabled"})],$.FloatingCall.prototype,"soundEnabled",2),Ct([pe({type:Number,attribute:"sound-volume"})],$.FloatingCall.prototype,"soundVolume",2),$.FloatingCall=Ct([_a("hanc-ai-floating-call")],$.FloatingCall);var yM=Object.defineProperty,bM=Object.getOwnPropertyDescriptor,Et=(i,e,t,n)=>{for(var s=n>1?void 0:n?bM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&yM(e,t,s),s};$.PillCall=class extends Ui{constructor(){super(...arguments),this.callManager=new ro,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=xa(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Talk to AI Agent",this.buttonConnectingText="Connecting...",this.buttonEndText="End call",this.orbSize=48,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale
|
|
5020
|
+
`,Ct([pe({type:String,attribute:"agent-id"})],$.FloatingCall.prototype,"agentId",2),Ct([pe({type:String,attribute:"voice-service-url"})],$.FloatingCall.prototype,"voiceServiceUrl",2),Ct([Fi()],$.FloatingCall.prototype,"callStatus",2),Ct([Fi()],$.FloatingCall.prototype,"microphoneEnabled",2),Ct([pe({type:String,attribute:"button-start-text"})],$.FloatingCall.prototype,"buttonStartText",2),Ct([pe({type:String,attribute:"button-connecting-text"})],$.FloatingCall.prototype,"buttonConnectingText",2),Ct([pe({type:String,attribute:"position"})],$.FloatingCall.prototype,"position",2),Ct([pe({type:Number,attribute:"size"})],$.FloatingCall.prototype,"size",2),Ct([pe({type:String,attribute:"theme"})],$.FloatingCall.prototype,"theme",2),Ct([pe({type:String,attribute:"theme-mode"})],$.FloatingCall.prototype,"themeMode",2),Ct([pe({type:Object,attribute:"orb-colors"})],$.FloatingCall.prototype,"orbColors",2),Ct([pe({type:Number,attribute:"glow-intensity"})],$.FloatingCall.prototype,"glowIntensity",2),Ct([pe({type:Number,attribute:"idle-glow-multiplier"})],$.FloatingCall.prototype,"idleGlowMultiplier",2),Ct([pe({type:Number,attribute:"morph-strength"})],$.FloatingCall.prototype,"morphStrength",2),Ct([pe({type:Number,attribute:"noise-scale"})],$.FloatingCall.prototype,"noiseScale",2),Ct([pe({type:Number,attribute:"noise-speed"})],$.FloatingCall.prototype,"noiseSpeed",2),Ct([pe({type:Number,attribute:"fresnel-power"})],$.FloatingCall.prototype,"fresnelPower",2),Ct([pe({type:Number,attribute:"rotation-speed"})],$.FloatingCall.prototype,"rotationSpeed",2),Ct([pe({type:Number,attribute:"audio-reactivity"})],$.FloatingCall.prototype,"audioReactivity",2),Ct([pe({type:Number,attribute:"audio-smoothing"})],$.FloatingCall.prototype,"audioSmoothing",2),Ct([pe({type:Number,attribute:"idle-morph-multiplier"})],$.FloatingCall.prototype,"idleMorphMultiplier",2),Ct([pe({type:Number,attribute:"color-contrast"})],$.FloatingCall.prototype,"colorContrast",2),Ct([pe({type:Boolean,attribute:"sound-enabled"})],$.FloatingCall.prototype,"soundEnabled",2),Ct([pe({type:Number,attribute:"sound-volume"})],$.FloatingCall.prototype,"soundVolume",2),$.FloatingCall=Ct([_a("hanc-ai-floating-call")],$.FloatingCall);var yM=Object.defineProperty,bM=Object.getOwnPropertyDescriptor,Et=(i,e,t,n)=>{for(var s=n>1?void 0:n?bM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&yM(e,t,s),s};$.PillCall=class extends Ui{constructor(){super(...arguments),this.callManager=new ro,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=xa(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Talk to AI Agent",this.buttonConnectingText="Connecting...",this.buttonEndText="End call",this.orbSize=48,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale=.8,this.noiseSpeed=.15,this.fresnelPower=2.5,this.rotationSpeed=.1,this.audioReactivity=1,this.audioSmoothing=.03,this.idleMorphMultiplier=.25,this.colorContrast=1.5,this.soundEnabled=!0,this.soundVolume=.15,this.handleAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectStream(s)}catch(s){console.error("Failed to connect audio stream:",s)}},this.handleLocalAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectLocalStream(s)}catch(s){console.error("Failed to connect local audio stream:",s)}},this.handleMicrophoneEnabled=()=>{this.microphoneEnabled=!0},this.handleMicrophoneDisabled=()=>{this.microphoneEnabled=!1},this.handleStatusChange=e=>{var n,s,r,o,a;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(o=this.orbRenderer)==null||o.setActive(!1),(a=this.audioAnalyzer)==null||a.disconnect(),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle",this.startIdleAnimation())},3e3);break}},this.toggleCall=async()=>{var e;this.agentId&&((e=this.soundManager)==null||e.prewarm(),this.callStatus==="idle"?(this.callStatus="connecting",await this.callManager.makeCall({agentId:this.agentId})):this.callStatus==="connected"&&this.callManager.hangUp())}}connectedCallback(){super.connectedCallback(),this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.soundManager=new $o({enabled:this.soundEnabled,volume:this.soundVolume}),this.callManager.addEventListener("status-changed",this.handleStatusChange),this.callManager.addEventListener("audio-track",this.handleAudioTrack),this.callManager.addEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.addEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.addEventListener("microphone-disabled",this.handleMicrophoneDisabled)}disconnectedCallback(){var e;super.disconnectedCallback(),this.callManager.removeEventListener("status-changed",this.handleStatusChange),this.callManager.removeEventListener("audio-track",this.handleAudioTrack),this.callManager.removeEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.removeEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.removeEventListener("microphone-disabled",this.handleMicrophoneDisabled),this.callManager.hangUp(),this.cleanupOrb(),(e=this.soundManager)==null||e.destroy(),this.soundManager=null}firstUpdated(){this.applyTheme(),this.initializeOrb()}updated(e){var t,n;super.updated(e),e.has("agentId")&&(this.callManager.hangUp(),this.callStatus="idle"),e.has("voiceServiceUrl")&&this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),(e.has("theme")||e.has("themeMode"))&&this.applyTheme(),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}applyTheme(){if(this.theme){const e=pa(this.theme,this.themeMode);this.orbColors=e.colors,this.glowIntensity=e.glowIntensity,this.idleGlowMultiplier=e.idleGlowMultiplier,this.orbRenderer&&(this.orbRenderer.setColors(this.orbColors),this.orbRenderer.setGlowSettings(this.glowIntensity,this.idleGlowMultiplier))}}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new hu(e,{size:1,colors:this.orbColors,glowIntensity:this.glowIntensity,idleGlowMultiplier:this.idleGlowMultiplier,morphStrength:this.morphStrength,noiseScale:this.noiseScale,noiseSpeed:this.noiseSpeed,fresnelPower:this.fresnelPower,rotationSpeed:this.rotationSpeed,audioReactivity:this.audioReactivity,audioSmoothing:this.audioSmoothing,idleMorphMultiplier:this.idleMorphMultiplier,colorContrast:this.colorContrast}),this.audioAnalyzer=new fu,this.orbRenderer.start(),this.startIdleAnimation())}cleanupOrb(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.audioAnalyzer)==null||e.disconnect(),(t=this.orbRenderer)==null||t.destroy(),this.audioAnalyzer=null,this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(this.callStatus!=="idle"||!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.5)*.15+.15,s=Math.sin(t*.7+1)*.12+.12,r=Math.sin(t*.9+2)*.08+.08,o=(n+s+r)/3;this.orbRenderer.setSimulatedAudio(n,s,r,o),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startRealAudioLoop(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{var n;if(this.callStatus!=="connected"||!this.orbRenderer)return;const t=(n=this.audioAnalyzer)==null?void 0:n.getAudioData();t&&this.orbRenderer.updateAudio(t),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}getButtonIcon(){return this.callStatus==="connecting"?Rt`
|
|
5021
5021
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" class="hanc-spinner">
|
|
5022
5022
|
<circle
|
|
5023
5023
|
cx="8"
|
|
@@ -5206,7 +5206,7 @@ void main() {
|
|
|
5206
5206
|
display: inline-block;
|
|
5207
5207
|
contain: layout style;
|
|
5208
5208
|
}
|
|
5209
|
-
`,Et([pe({type:String,attribute:"agent-id"})],$.PillCall.prototype,"agentId",2),Et([pe({type:String,attribute:"voice-service-url"})],$.PillCall.prototype,"voiceServiceUrl",2),Et([Fi()],$.PillCall.prototype,"callStatus",2),Et([Fi()],$.PillCall.prototype,"microphoneEnabled",2),Et([pe({type:String,attribute:"button-start-text"})],$.PillCall.prototype,"buttonStartText",2),Et([pe({type:String,attribute:"button-connecting-text"})],$.PillCall.prototype,"buttonConnectingText",2),Et([pe({type:String,attribute:"button-end-text"})],$.PillCall.prototype,"buttonEndText",2),Et([pe({type:Number,attribute:"orb-size"})],$.PillCall.prototype,"orbSize",2),Et([pe({type:String,attribute:"theme"})],$.PillCall.prototype,"theme",2),Et([pe({type:String,attribute:"theme-mode"})],$.PillCall.prototype,"themeMode",2),Et([pe({type:Object,attribute:"orb-colors"})],$.PillCall.prototype,"orbColors",2),Et([pe({type:Number,attribute:"glow-intensity"})],$.PillCall.prototype,"glowIntensity",2),Et([pe({type:Number,attribute:"idle-glow-multiplier"})],$.PillCall.prototype,"idleGlowMultiplier",2),Et([pe({type:Number,attribute:"morph-strength"})],$.PillCall.prototype,"morphStrength",2),Et([pe({type:Number,attribute:"noise-scale"})],$.PillCall.prototype,"noiseScale",2),Et([pe({type:Number,attribute:"noise-speed"})],$.PillCall.prototype,"noiseSpeed",2),Et([pe({type:Number,attribute:"fresnel-power"})],$.PillCall.prototype,"fresnelPower",2),Et([pe({type:Number,attribute:"rotation-speed"})],$.PillCall.prototype,"rotationSpeed",2),Et([pe({type:Number,attribute:"audio-reactivity"})],$.PillCall.prototype,"audioReactivity",2),Et([pe({type:Number,attribute:"audio-smoothing"})],$.PillCall.prototype,"audioSmoothing",2),Et([pe({type:Number,attribute:"idle-morph-multiplier"})],$.PillCall.prototype,"idleMorphMultiplier",2),Et([pe({type:Number,attribute:"color-contrast"})],$.PillCall.prototype,"colorContrast",2),Et([pe({type:Boolean,attribute:"sound-enabled"})],$.PillCall.prototype,"soundEnabled",2),Et([pe({type:Number,attribute:"sound-volume"})],$.PillCall.prototype,"soundVolume",2),$.PillCall=Et([_a("hanc-ai-pill-call")],$.PillCall);const _M={core:"#ffffff",coreGlow:"#a855f7",lightning:"#c084fc",shell:"#1e1b2e",shellInner:"#0f0d17",particles:"#e9d5ff",pulseNeutral:"#a855f7",pulseJoy:"#22c55e",pulseThinking:"#3b82f6",pulseInterrupted:"#ef4444"},pu={idle:{shellOpen:0,coreIntensity:.6,lightningCount:2,lightningIntensity:.3,particleSpeed:.3,coreScale:.7},listening:{shellOpen:.15,coreIntensity:.8,lightningCount:4,lightningIntensity:.5,particleSpeed:.5,coreScale:.8},thinking:{shellOpen:.25,coreIntensity:1,lightningCount:6,lightningIntensity:.7,particleSpeed:.7,coreScale:.9},speaking:{shellOpen:.4,coreIntensity:1.2,lightningCount:10,lightningIntensity:1,particleSpeed:1,coreScale:1}};class pg{constructor(e,t={}){this.shellSegments=[],this.coreInner=null,this.coreOuter=null,this.coreGlow=null,this.pulseRings=[],this.particles=null,this.particlePositions=null,this.particleVelocities=null,this.animationId=null,this._currentState="idle",this._currentEmotion="neutral",this.targetConfig={...pu.idle},this.currentConfig={...pu.idle},this.
|
|
5209
|
+
`,Et([pe({type:String,attribute:"agent-id"})],$.PillCall.prototype,"agentId",2),Et([pe({type:String,attribute:"voice-service-url"})],$.PillCall.prototype,"voiceServiceUrl",2),Et([Fi()],$.PillCall.prototype,"callStatus",2),Et([Fi()],$.PillCall.prototype,"microphoneEnabled",2),Et([pe({type:String,attribute:"button-start-text"})],$.PillCall.prototype,"buttonStartText",2),Et([pe({type:String,attribute:"button-connecting-text"})],$.PillCall.prototype,"buttonConnectingText",2),Et([pe({type:String,attribute:"button-end-text"})],$.PillCall.prototype,"buttonEndText",2),Et([pe({type:Number,attribute:"orb-size"})],$.PillCall.prototype,"orbSize",2),Et([pe({type:String,attribute:"theme"})],$.PillCall.prototype,"theme",2),Et([pe({type:String,attribute:"theme-mode"})],$.PillCall.prototype,"themeMode",2),Et([pe({type:Object,attribute:"orb-colors"})],$.PillCall.prototype,"orbColors",2),Et([pe({type:Number,attribute:"glow-intensity"})],$.PillCall.prototype,"glowIntensity",2),Et([pe({type:Number,attribute:"idle-glow-multiplier"})],$.PillCall.prototype,"idleGlowMultiplier",2),Et([pe({type:Number,attribute:"morph-strength"})],$.PillCall.prototype,"morphStrength",2),Et([pe({type:Number,attribute:"noise-scale"})],$.PillCall.prototype,"noiseScale",2),Et([pe({type:Number,attribute:"noise-speed"})],$.PillCall.prototype,"noiseSpeed",2),Et([pe({type:Number,attribute:"fresnel-power"})],$.PillCall.prototype,"fresnelPower",2),Et([pe({type:Number,attribute:"rotation-speed"})],$.PillCall.prototype,"rotationSpeed",2),Et([pe({type:Number,attribute:"audio-reactivity"})],$.PillCall.prototype,"audioReactivity",2),Et([pe({type:Number,attribute:"audio-smoothing"})],$.PillCall.prototype,"audioSmoothing",2),Et([pe({type:Number,attribute:"idle-morph-multiplier"})],$.PillCall.prototype,"idleMorphMultiplier",2),Et([pe({type:Number,attribute:"color-contrast"})],$.PillCall.prototype,"colorContrast",2),Et([pe({type:Boolean,attribute:"sound-enabled"})],$.PillCall.prototype,"soundEnabled",2),Et([pe({type:Number,attribute:"sound-volume"})],$.PillCall.prototype,"soundVolume",2),$.PillCall=Et([_a("hanc-ai-pill-call")],$.PillCall);const _M={core:"#ffffff",coreGlow:"#a855f7",lightning:"#c084fc",shell:"#1e1b2e",shellInner:"#0f0d17",particles:"#e9d5ff",pulseNeutral:"#a855f7",pulseJoy:"#22c55e",pulseThinking:"#3b82f6",pulseInterrupted:"#ef4444"},pu={idle:{shellOpen:0,coreIntensity:.6,lightningCount:2,lightningIntensity:.3,particleSpeed:.3,coreScale:.7},listening:{shellOpen:.15,coreIntensity:.8,lightningCount:4,lightningIntensity:.5,particleSpeed:.5,coreScale:.8},thinking:{shellOpen:.25,coreIntensity:1,lightningCount:6,lightningIntensity:.7,particleSpeed:.7,coreScale:.9},speaking:{shellOpen:.4,coreIntensity:1.2,lightningCount:10,lightningIntensity:1,particleSpeed:1,coreScale:1}};class pg{constructor(e,t={}){this.shellSegments=[],this.coreInner=null,this.coreOuter=null,this.coreGlow=null,this.pulseRings=[],this.particles=null,this.particlePositions=null,this.particleVelocities=null,this.animationId=null,this._currentState="idle",this._currentEmotion="neutral",this.targetConfig={...pu.idle},this.currentConfig={...pu.idle},this.targetAudioLevel=0,this.currentAudioLevel=0,this.audioVelocity=0,this.targetPulseColor=new Fe("#a855f7"),this.currentPulseColor=new Fe("#a855f7"),this.targetRotation={x:0,y:0},this.currentRotation={x:0,y:0},this.time=0,this.animate=()=>{this.animationId=requestAnimationFrame(this.animate);const n=this.clock.getDelta();this.time+=n;const s=.05;this.currentConfig.coreIntensity+=(this.targetConfig.coreIntensity-this.currentConfig.coreIntensity)*s,this.currentConfig.lightningCount+=(this.targetConfig.lightningCount-this.currentConfig.lightningCount)*s,this.currentConfig.lightningIntensity+=(this.targetConfig.lightningIntensity-this.currentConfig.lightningIntensity)*s,this.currentConfig.particleSpeed+=(this.targetConfig.particleSpeed-this.currentConfig.particleSpeed)*s,this.currentConfig.coreScale+=(this.targetConfig.coreScale-this.currentConfig.coreScale)*s;const r=.08,o=.75,a=(this.targetAudioLevel-this.currentAudioLevel)*r;this.audioVelocity+=a,this.audioVelocity*=o,this.currentAudioLevel+=this.audioVelocity,this.currentAudioLevel=Math.max(0,Math.min(1,this.currentAudioLevel));const c=1+this.currentAudioLevel*.4;if(this.coreLight&&(this.coreLight.intensity=3+this.currentConfig.coreIntensity*2*c),this.coreInner){const l=this.coreInner.material;l.uniforms&&(l.uniforms.uTime.value=this.time,l.uniforms.uIntensity.value=this.currentConfig.coreIntensity*c);const d=this.currentConfig.coreScale*.9*c;this.coreInner.scale.setScalar(d)}if(this.coreOuter){const l=this.coreOuter.material;l.uniforms.uTime.value=this.time,l.uniforms.uIntensity.value=this.currentConfig.coreIntensity*c;const d=this.currentConfig.coreScale*c;this.coreOuter.scale.setScalar(d)}if(this.coreGlow){const l=this.coreGlow.material;l.uniforms.uTime.value=this.time,l.uniforms.uIntensity.value=this.currentConfig.coreIntensity*.7*c;const d=1+Math.sin(this.time*1.5)*.03*this.currentConfig.coreIntensity;this.coreGlow.scale.setScalar(d)}this.updateParticles(n),this.currentPulseColor.lerp(this.targetPulseColor,.08);for(const l of this.pulseRings){const d=l.material;d.uniforms.uTime.value=this.time,d.uniforms.uAudioLevel.value=this.currentAudioLevel,d.uniforms.uIntensity.value=this.currentConfig.coreIntensity,d.uniforms.uColor.value.copy(this.currentPulseColor);const u=l.ringConfig;l.rotation.y+=.003*u.speed,l.rotation.x=u.tiltX+Math.sin(this.time*.5+u.phase)*.1,l.rotation.z=u.tiltZ+Math.cos(this.time*.4+u.phase)*.08}this.currentRotation.x+=(this.targetRotation.x-this.currentRotation.x)*.05,this.currentRotation.y+=(this.targetRotation.y-this.currentRotation.y)*.05,this.scene.rotation.x=this.currentRotation.x,this.scene.rotation.y=this.currentRotation.y,this.renderer.render(this.scene,this.camera)},this.handleResize=()=>{const n=this.container.clientWidth*this.config.canvasPadding,s=this.container.clientHeight*this.config.canvasPadding;this.camera.aspect=n/s,this.camera.updateProjectionMatrix(),this.renderer.setSize(n,s)},this.handleMouseMove=n=>{const s=this.container.getBoundingClientRect(),r=(n.clientX-s.left)/s.width*2-1,o=-((n.clientY-s.top)/s.height)*2+1;this.targetRotation.x=o*.3,this.targetRotation.y=r*.3},this.handleMouseLeave=()=>{this.targetRotation.x=0,this.targetRotation.y=0},this.container=e,this.config={size:t.size??1,shellSegments:t.shellSegments??6,colors:t.colors??{},canvasPadding:t.canvasPadding??2},this.colors={..._M,...t.colors},this.clock=new Nm,this.initScene(),this.createShell(),this.createCore(),this.createParticles(),window.addEventListener("resize",this.handleResize),e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseleave",this.handleMouseLeave)}initScene(){this.scene=new Mm;const e=this.container.clientWidth*this.config.canvasPadding,t=this.container.clientHeight*this.config.canvasPadding;this.camera=new xn(50,e/t,.1,100),this.camera.position.z=3.5,this.renderer=new ug({antialias:!0,alpha:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(e,t),this.renderer.setClearColor(0,0);const n=this.renderer.domElement;n.style.position="absolute",n.style.left="50%",n.style.top="50%",n.style.transform="translate(-50%, -50%)",n.style.pointerEvents="none",this.container.appendChild(n)}createShell(){const e=new zS(1710638,.6);this.scene.add(e);const t=new iu(16777215,1);t.position.set(3,4,5),this.scene.add(t);const n=new iu(9133302,.4);n.position.set(-3,2,3),this.scene.add(n);const s=new iu(6514417,.5);s.position.set(0,-2,-4),this.scene.add(s);const r=new FS(new Fe(this.colors.coreGlow),4,6);r.position.set(0,0,0),this.scene.add(r),this.coreLight=r}createCore(){const e=this.config.size*.3,t=new yr(e*.5,64,64),n=new en({uniforms:{uTime:{value:0},uIntensity:{value:1}},vertexShader:`
|
|
5210
5210
|
varying vec3 vNormal;
|
|
5211
5211
|
varying vec3 vPosition;
|
|
5212
5212
|
void main() {
|
|
@@ -5524,7 +5524,7 @@ void main() {
|
|
|
5524
5524
|
|
|
5525
5525
|
gl_FragColor = vec4(color, alpha * 0.8);
|
|
5526
5526
|
}
|
|
5527
|
-
`,transparent:!0,blending:Ji,depthWrite:!1});this.particles=new IS(s,r),this.particleMaterial=r,this.scene.add(this.particles)}resetParticleFromCore(e){if(!this.particlePositions||!this.particleVelocities)return;const t=e*3,n=Math.random()*Math.PI*2,s=Math.acos(2*Math.random()-1),r=this.config.size*(.1+Math.random()*.15);this.particlePositions[t]=Math.sin(s)*Math.cos(n)*r,this.particlePositions[t+1]=Math.cos(s)*r,this.particlePositions[t+2]=Math.sin(s)*Math.sin(n)*r;const o=.0027+Math.random()*.008;this.particleVelocities[t]=this.particlePositions[t]/r*o,this.particleVelocities[t+1]=this.particlePositions[t+1]/r*o,this.particleVelocities[t+2]=this.particlePositions[t+2]/r*o,this.particleVelocities[t]+=(Math.random()-.5)*.0013,this.particleVelocities[t+1]+=(Math.random()-.5)*.0013,this.particleVelocities[t+2]+=(Math.random()-.5)*.0013}updateParticles(e){if(!this.particlePositions||!this.particleVelocities||!this.particles)return;const t=this.currentConfig.particleSpeed,n=this.config.size*.7;this.particleMaterial&&(this.particleMaterial.uniforms.uTime.value=this.time);for(let s=0;s<this.particlePositions.length/3;s++){const r=s*3;this.particlePositions[r]+=this.particleVelocities[r]*t,this.particlePositions[r+1]+=this.particleVelocities[r+1]*t,this.particlePositions[r+2]+=this.particleVelocities[r+2]*t,(Math.sqrt(this.particlePositions[r]**2+this.particlePositions[r+1]**2+this.particlePositions[r+2]**2)>=n||Math.random()<.003)&&this.resetParticleFromCore(s)}this.particles.geometry.attributes.position.needsUpdate=!0}setState(e){this._currentState=e,this.targetConfig={...pu[e]}}getState(){return this._currentState}setAudioLevel(e){this.audioLevel=Math.max(0,Math.min(1,e))}setEmotion(e){switch(this._currentEmotion=e,e){case"joy":this.targetPulseColor.set(this.colors.pulseJoy);break;case"thinking":this.targetPulseColor.set(this.colors.pulseThinking);break;case"interrupted":this.targetPulseColor.set(this.colors.pulseInterrupted);break;default:this.targetPulseColor.set(this.colors.pulseNeutral)}}getEmotion(){return this._currentEmotion}setColors(e){this.colors={...this.colors,...e},e.coreGlow&&this.coreOuter&&this.coreOuter.material.uniforms.uColorOuter.value.set(e.coreGlow),e.coreGlow&&this.coreGlow&&this.coreGlow.material.uniforms.uColor.value.set(e.coreGlow),e.particles&&this.particleMaterial&&this.particleMaterial.uniforms.uColor.value.set(e.particles),e.coreGlow&&this.coreLight&&this.coreLight.color.set(e.coreGlow),(e.pulseNeutral||e.pulseJoy||e.pulseThinking||e.pulseInterrupted)&&this.setEmotion(this._currentEmotion)}start(){this.animationId===null&&(this.clock.start(),this.animate())}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}getCanvas(){return this.renderer.domElement}destroy(){this.stop(),window.removeEventListener("resize",this.handleResize),this.container.removeEventListener("mousemove",this.handleMouseMove),this.container.removeEventListener("mouseleave",this.handleMouseLeave),this.shellSegments.forEach(e=>{e.geometry.dispose(),e.material.dispose()}),this.coreInner&&(this.coreInner.geometry.dispose(),this.coreInner.material.dispose()),this.coreOuter&&(this.coreOuter.geometry.dispose(),this.coreOuter.material.dispose()),this.coreGlow&&(this.coreGlow.geometry.dispose(),this.coreGlow.material.dispose());for(const e of this.pulseRings)e.geometry.dispose(),e.material.dispose();this.pulseRings=[],this.particles&&(this.particles.geometry.dispose(),this.particles.material.dispose()),this.renderer.dispose(),this.renderer.domElement.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}var SM=Object.defineProperty,xM=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var s=n>1?void 0:n?xM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&SM(e,t,s),s};$.LinaWidget=class extends Ui{constructor(){super(...arguments),this.orbRenderer=null,this.orbContainerRef=xa(),this.audioSimPhase=0,this.animationId=null,this.callManager=null,this.size=300,this.headerLogo="HANC.ai",this.headerTitle="Lina-Voice AI",this.showBranding=!0,this.version="v1.0.0",this.agentId="",this.voiceServiceUrl="",this.btnStartText="Start",this.btnEndText="End",this.colors={},this.currentState="idle",this.callStatus="idle",this._hasMicPermission=null,this.handleCallClick=async()=>{if(this.callStatus==="mic-denied")try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(t=>t.stop()),this._hasMicPermission=!0,this.callStatus="idle"}catch{return}this.callStatus==="active"||this.callStatus==="connecting"?await this.endCall():this.callStatus==="idle"&&await this.startCall()}}connectedCallback(){super.connectedCallback(),this.checkMicrophonePermission()}disconnectedCallback(){super.disconnectedCallback(),this.cleanup()}firstUpdated(){this.initializeOrb()}async checkMicrophonePermission(){try{const e=await navigator.permissions.query({name:"microphone"});this._hasMicPermission=e.state==="granted",e.addEventListener("change",()=>{this._hasMicPermission=e.state==="granted",e.state==="denied"?this.callStatus="mic-denied":this.callStatus==="mic-denied"&&(this.callStatus="idle")})}catch{this._hasMicPermission=null}}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new pg(e,{size:1,colors:this.colors}),this.orbRenderer.start(),this.startIdleAnimation())}initializeCallManager(){this.callManager||(this.callManager=new ro,this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.callManager.addEventListener("status-changed",(e=>{const t=e.detail;this.handleCallStatusChange(t)})),this.callManager.addEventListener("audio-track",(e=>{const t=e.detail;if(t){const n=new MediaStream([t]);this.connectAudioStream(n)}})),this.callManager.addEventListener("microphone-disabled",()=>{this.callStatus==="active"&&(this._hasMicPermission=!1)}),this.callManager.addEventListener("error",(e=>{var t,n;console.error("Call error:",(t=e.detail)==null?void 0:t.error),this.callStatus="error",this.currentState="idle",(n=this.orbRenderer)==null||n.setState("idle"),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle")},3e3)})))}handleCallStatusChange(e){var t,n,s,r;switch(e){case"connecting":case"ringing":this.callStatus="connecting",this.currentState="listening",(t=this.orbRenderer)==null||t.setState("listening");break;case"connected":case"agent-connected":this.callStatus="active",this.currentState="speaking",(n=this.orbRenderer)==null||n.setState("speaking"),this.startActiveAnimation();break;case"disconnecting":this.callStatus="ending";break;case"disconnected":this.callStatus="idle",this.currentState="idle",(s=this.orbRenderer)==null||s.setState("idle"),this.startIdleAnimation();break;case"error":this.callStatus="error",this.currentState="idle",(r=this.orbRenderer)==null||r.setState("idle");break}}cleanup(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.callManager)==null||e.hangUp(),(t=this.orbRenderer)==null||t.destroy(),this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.4)*.08+Math.sin(t*.7)*.04+.15;this.orbRenderer.setAudioLevel(n),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startActiveAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId),this.audioSimPhase=Math.random()*Math.PI*2;const e=()=>{if(!this.orbRenderer||this.callStatus!=="active"){this.startIdleAnimation();return}this.audioSimPhase+=.03;const t=Math.sin(this.audioSimPhase*.25)*.25+.45,n=Math.sin(this.audioSimPhase*2)*.15,s=Math.sin(this.audioSimPhase*4.5)*.08,r=(Math.random()-.5)*.08,o=Math.random()>.97?Math.random()*.2:0,a=Math.max(0,Math.min(1,t+n+s+r+o));this.orbRenderer.setAudioLevel(a),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}connectAudioStream(e){if(!this.orbRenderer)return;this.animationId!==null&&cancelAnimationFrame(this.animationId);const t=new AudioContext,n=t.createAnalyser();n.fftSize=256,t.createMediaStreamSource(e).connect(n);const r=new Uint8Array(n.frequencyBinCount),o=()=>{if(!this.orbRenderer||this.callStatus!=="active"){t.close(),this.startIdleAnimation();return}n.getByteFrequencyData(r);let a=0;for(let d=0;d<r.length;d++)a+=r[d];const c=a/r.length/255,l=Math.pow(c,.7)*1.2;this.orbRenderer.setAudioLevel(Math.min(1,l)),this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}async startCall(){var e,t,n,s;if(this._hasMicPermission!==!0)try{(await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})).getTracks().forEach(o=>o.stop()),this._hasMicPermission=!0}catch{this._hasMicPermission=!1,this.callStatus="mic-denied";return}if(this.agentId&&this.voiceServiceUrl){this.initializeCallManager(),this.callStatus="connecting",this.currentState="listening",(e=this.orbRenderer)==null||e.setState("listening");try{await((t=this.callManager)==null?void 0:t.makeCall({agentId:this.agentId}))}catch(r){console.error("Failed to start call:",r),this.callStatus="error",setTimeout(()=>{var o;this.callStatus==="error"&&(this.callStatus="idle",this.currentState="idle",(o=this.orbRenderer)==null||o.setState("idle"))},3e3)}}else this.callStatus="connecting",this.currentState="listening",(n=this.orbRenderer)==null||n.setState("listening"),await new Promise(r=>setTimeout(r,1500)),this.callStatus="active",this.currentState="speaking",(s=this.orbRenderer)==null||s.setState("speaking"),this.startActiveAnimation(),this.dispatchEvent(new CustomEvent("call-start",{detail:{agentId:"demo",timestamp:Date.now()},bubbles:!0,composed:!0}))}async endCall(){var e;this.callStatus="ending",this.callManager&&await this.callManager.hangUp(),this.callStatus="idle",this.currentState="idle",(e=this.orbRenderer)==null||e.setState("idle"),this.startIdleAnimation(),this.dispatchEvent(new CustomEvent("call-end",{detail:{timestamp:Date.now()},bubbles:!0,composed:!0}))}setState(e){var t;this.currentState=e,(t=this.orbRenderer)==null||t.setState(e)}setAudioLevel(e){var t;(t=this.orbRenderer)==null||t.setAudioLevel(e)}setColors(e){var t;this.colors={...this.colors,...e},(t=this.orbRenderer)==null||t.setColors(e)}setEmotion(e){var t;(t=this.orbRenderer)==null||t.setEmotion(e)}getEmotion(){var e;return(e=this.orbRenderer)==null?void 0:e.getEmotion()}getState(){return this.currentState}getCallStatus(){return this.callStatus}getButtonContent(){switch(this.callStatus){case"connecting":return Rt`
|
|
5527
|
+
`,transparent:!0,blending:Ji,depthWrite:!1});this.particles=new IS(s,r),this.particleMaterial=r,this.scene.add(this.particles)}resetParticleFromCore(e){if(!this.particlePositions||!this.particleVelocities)return;const t=e*3,n=Math.random()*Math.PI*2,s=Math.acos(2*Math.random()-1),r=this.config.size*(.1+Math.random()*.15);this.particlePositions[t]=Math.sin(s)*Math.cos(n)*r,this.particlePositions[t+1]=Math.cos(s)*r,this.particlePositions[t+2]=Math.sin(s)*Math.sin(n)*r;const o=.0027+Math.random()*.008;this.particleVelocities[t]=this.particlePositions[t]/r*o,this.particleVelocities[t+1]=this.particlePositions[t+1]/r*o,this.particleVelocities[t+2]=this.particlePositions[t+2]/r*o,this.particleVelocities[t]+=(Math.random()-.5)*.0013,this.particleVelocities[t+1]+=(Math.random()-.5)*.0013,this.particleVelocities[t+2]+=(Math.random()-.5)*.0013}updateParticles(e){if(!this.particlePositions||!this.particleVelocities||!this.particles)return;const t=this.currentConfig.particleSpeed,n=this.config.size*.7;this.particleMaterial&&(this.particleMaterial.uniforms.uTime.value=this.time);for(let s=0;s<this.particlePositions.length/3;s++){const r=s*3;this.particlePositions[r]+=this.particleVelocities[r]*t,this.particlePositions[r+1]+=this.particleVelocities[r+1]*t,this.particlePositions[r+2]+=this.particleVelocities[r+2]*t,(Math.sqrt(this.particlePositions[r]**2+this.particlePositions[r+1]**2+this.particlePositions[r+2]**2)>=n||Math.random()<.003)&&this.resetParticleFromCore(s)}this.particles.geometry.attributes.position.needsUpdate=!0}setState(e){this._currentState=e,this.targetConfig={...pu[e]}}getState(){return this._currentState}setAudioLevel(e){this.targetAudioLevel=Math.max(0,Math.min(1,e))}setEmotion(e){switch(this._currentEmotion=e,e){case"joy":this.targetPulseColor.set(this.colors.pulseJoy);break;case"thinking":this.targetPulseColor.set(this.colors.pulseThinking);break;case"interrupted":this.targetPulseColor.set(this.colors.pulseInterrupted);break;default:this.targetPulseColor.set(this.colors.pulseNeutral)}}getEmotion(){return this._currentEmotion}setColors(e){this.colors={...this.colors,...e},e.coreGlow&&this.coreOuter&&this.coreOuter.material.uniforms.uColorOuter.value.set(e.coreGlow),e.coreGlow&&this.coreGlow&&this.coreGlow.material.uniforms.uColor.value.set(e.coreGlow),e.particles&&this.particleMaterial&&this.particleMaterial.uniforms.uColor.value.set(e.particles),e.coreGlow&&this.coreLight&&this.coreLight.color.set(e.coreGlow),(e.pulseNeutral||e.pulseJoy||e.pulseThinking||e.pulseInterrupted)&&this.setEmotion(this._currentEmotion)}start(){this.animationId===null&&(this.clock.start(),this.animate())}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}getCanvas(){return this.renderer.domElement}destroy(){this.stop(),window.removeEventListener("resize",this.handleResize),this.container.removeEventListener("mousemove",this.handleMouseMove),this.container.removeEventListener("mouseleave",this.handleMouseLeave),this.shellSegments.forEach(e=>{e.geometry.dispose(),e.material.dispose()}),this.coreInner&&(this.coreInner.geometry.dispose(),this.coreInner.material.dispose()),this.coreOuter&&(this.coreOuter.geometry.dispose(),this.coreOuter.material.dispose()),this.coreGlow&&(this.coreGlow.geometry.dispose(),this.coreGlow.material.dispose());for(const e of this.pulseRings)e.geometry.dispose(),e.material.dispose();this.pulseRings=[],this.particles&&(this.particles.geometry.dispose(),this.particles.material.dispose()),this.renderer.dispose(),this.renderer.domElement.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}var SM=Object.defineProperty,xM=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var s=n>1?void 0:n?xM(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&SM(e,t,s),s};$.LinaWidget=class extends Ui{constructor(){super(...arguments),this.orbRenderer=null,this.orbContainerRef=xa(),this.audioSimPhase=0,this.animationId=null,this.callManager=null,this.size=300,this.headerLogo="HANC.ai",this.headerTitle="Lina-Voice AI",this.showBranding=!0,this.version="v1.0.3",this.agentId="",this.voiceServiceUrl="",this.btnStartText="Start",this.btnEndText="End",this.colors={},this.currentState="idle",this.callStatus="idle",this._hasMicPermission=null,this.handleCallClick=async()=>{if(this.callStatus==="mic-denied")try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(t=>t.stop()),this._hasMicPermission=!0,this.callStatus="idle"}catch{return}this.callStatus==="active"||this.callStatus==="connecting"?await this.endCall():this.callStatus==="idle"&&await this.startCall()}}connectedCallback(){super.connectedCallback(),this.checkMicrophonePermission()}disconnectedCallback(){super.disconnectedCallback(),this.cleanup()}firstUpdated(){this.initializeOrb()}async checkMicrophonePermission(){try{const e=await navigator.permissions.query({name:"microphone"});this._hasMicPermission=e.state==="granted",e.addEventListener("change",()=>{this._hasMicPermission=e.state==="granted",e.state==="denied"?this.callStatus="mic-denied":this.callStatus==="mic-denied"&&(this.callStatus="idle")})}catch{this._hasMicPermission=null}}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new pg(e,{size:1,colors:this.colors}),this.orbRenderer.start(),this.startIdleAnimation())}initializeCallManager(){this.callManager||(this.callManager=new ro,this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.callManager.addEventListener("status-changed",(e=>{const t=e.detail;this.handleCallStatusChange(t)})),this.callManager.addEventListener("audio-track",(e=>{const t=e.detail;if(t){const n=new MediaStream([t]);this.connectAudioStream(n)}})),this.callManager.addEventListener("microphone-disabled",()=>{this.callStatus==="active"&&(this._hasMicPermission=!1)}),this.callManager.addEventListener("error",(e=>{var t,n;console.error("Call error:",(t=e.detail)==null?void 0:t.error),this.callStatus="error",this.currentState="idle",(n=this.orbRenderer)==null||n.setState("idle"),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle")},3e3)})))}handleCallStatusChange(e){var t,n,s,r;switch(e){case"connecting":case"ringing":this.callStatus="connecting",this.currentState="listening",(t=this.orbRenderer)==null||t.setState("listening");break;case"connected":case"agent-connected":this.callStatus="active",this.currentState="speaking",(n=this.orbRenderer)==null||n.setState("speaking"),this.startActiveAnimation();break;case"disconnecting":this.callStatus="ending";break;case"disconnected":this.callStatus="idle",this.currentState="idle",(s=this.orbRenderer)==null||s.setState("idle"),this.startIdleAnimation();break;case"error":this.callStatus="error",this.currentState="idle",(r=this.orbRenderer)==null||r.setState("idle");break}}cleanup(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.callManager)==null||e.hangUp(),(t=this.orbRenderer)==null||t.destroy(),this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.4)*.08+Math.sin(t*.7)*.04+.15;this.orbRenderer.setAudioLevel(n),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startActiveAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId),this.audioSimPhase=Math.random()*Math.PI*2;const e=()=>{if(!this.orbRenderer||this.callStatus!=="active"){this.startIdleAnimation();return}this.audioSimPhase+=.03;const t=Math.sin(this.audioSimPhase*.25)*.25+.45,n=Math.sin(this.audioSimPhase*2)*.15,s=Math.sin(this.audioSimPhase*4.5)*.08,r=(Math.random()-.5)*.08,o=Math.random()>.97?Math.random()*.2:0,a=Math.max(0,Math.min(1,t+n+s+r+o));this.orbRenderer.setAudioLevel(a),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}connectAudioStream(e){if(!this.orbRenderer)return;this.animationId!==null&&cancelAnimationFrame(this.animationId);const t=new AudioContext,n=t.createAnalyser();n.fftSize=256,t.createMediaStreamSource(e).connect(n);const r=new Uint8Array(n.frequencyBinCount),o=()=>{if(!this.orbRenderer||this.callStatus!=="active"){t.close(),this.startIdleAnimation();return}n.getByteFrequencyData(r);let a=0;for(let d=0;d<r.length;d++)a+=r[d];const c=a/r.length/255,l=Math.pow(c,.7)*1.2;this.orbRenderer.setAudioLevel(Math.min(1,l)),this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}async startCall(){var e,t,n,s;if(this._hasMicPermission!==!0)try{(await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})).getTracks().forEach(o=>o.stop()),this._hasMicPermission=!0}catch{this._hasMicPermission=!1,this.callStatus="mic-denied";return}if(this.agentId&&this.voiceServiceUrl){this.initializeCallManager(),this.callStatus="connecting",this.currentState="listening",(e=this.orbRenderer)==null||e.setState("listening");try{await((t=this.callManager)==null?void 0:t.makeCall({agentId:this.agentId}))}catch(r){console.error("Failed to start call:",r),this.callStatus="error",setTimeout(()=>{var o;this.callStatus==="error"&&(this.callStatus="idle",this.currentState="idle",(o=this.orbRenderer)==null||o.setState("idle"))},3e3)}}else this.callStatus="connecting",this.currentState="listening",(n=this.orbRenderer)==null||n.setState("listening"),await new Promise(r=>setTimeout(r,1500)),this.callStatus="active",this.currentState="speaking",(s=this.orbRenderer)==null||s.setState("speaking"),this.startActiveAnimation(),this.dispatchEvent(new CustomEvent("call-start",{detail:{agentId:"demo",timestamp:Date.now()},bubbles:!0,composed:!0}))}async endCall(){var e;this.callStatus="ending",this.callManager&&await this.callManager.hangUp(),this.callStatus="idle",this.currentState="idle",(e=this.orbRenderer)==null||e.setState("idle"),this.startIdleAnimation(),this.dispatchEvent(new CustomEvent("call-end",{detail:{timestamp:Date.now()},bubbles:!0,composed:!0}))}setState(e){var t;this.currentState=e,(t=this.orbRenderer)==null||t.setState(e)}setAudioLevel(e){var t;(t=this.orbRenderer)==null||t.setAudioLevel(e)}setColors(e){var t;this.colors={...this.colors,...e},(t=this.orbRenderer)==null||t.setColors(e)}setEmotion(e){var t;(t=this.orbRenderer)==null||t.setEmotion(e)}getEmotion(){var e;return(e=this.orbRenderer)==null?void 0:e.getEmotion()}getState(){return this.currentState}getCallStatus(){return this.callStatus}getButtonContent(){switch(this.callStatus){case"connecting":return Rt`
|
|
5528
5528
|
<svg viewBox="0 0 24 24" fill="none">
|
|
5529
5529
|
<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-dasharray="50 20" stroke-linecap="round"/>
|
|
5530
5530
|
</svg>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const glowVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = (modelViewMatrix * vec4(position, 1.0)).xyz;\n\n // Scale up for glow halo\n vec3 pos = position * 1.3;\n\n // Pre-calculate view intensity for smooth falloff\n vec3 viewDir = normalize(-vPosition);\n vIntensity = pow(1.0 - abs(dot(viewDir, vNormal)), 1.5);\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
2
|
-
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect\n float pulse = sin(uTime * uPulseSpeed) * 0.
|
|
2
|
+
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect - very subtle\n float pulse = sin(uTime * uPulseSpeed * 0.3) * 0.03 + 0.97;\n pulse += uAudioLevel * 0.15;\n\n // Smooth radial glow using pre-calculated intensity\n float glow = vIntensity * uGlowIntensity * pulse;\n\n // Very soft falloff for diffuse glow\n glow = pow(glow, 0.8);\n glow *= smoothstep(0.0, 0.3, vIntensity);\n\n // Color with audio reactivity\n vec3 glowColor = uGlowColor * (1.0 + uAudioLevel * 0.5);\n\n // Softer alpha for more diffuse appearance\n gl_FragColor = vec4(glowColor, glow * 0.4);\n}\n";
|
|
3
3
|
export declare const atmosphereVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = position;\n\n // Scale for outer atmosphere\n vec3 pos = position * 1.5;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
4
4
|
export declare const atmosphereFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uAtmosphereColor;\nuniform float uAtmosphereIntensity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vec3 viewDirection = normalize(cameraPosition - vPosition);\n\n // Inverse fresnel for atmosphere (stronger at edges, fading to center)\n float intensity = pow(1.0 - max(dot(viewDirection, vNormal), 0.0), 3.0);\n\n // Audio pulsing\n float pulse = 1.0 + uAudioLevel * 0.4;\n\n // Breathing animation\n float breathing = sin(uTime * 0.5) * 0.1 + 0.9;\n\n float alpha = intensity * uAtmosphereIntensity * pulse * breathing;\n\n // Fade out at very edges\n alpha *= smoothstep(1.0, 0.3, intensity);\n\n vec3 color = uAtmosphereColor * (1.0 + uAudioLevel * 0.3);\n\n gl_FragColor = vec4(color, alpha * 0.4);\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement\n float baseNoise = fbm(noisePos,
|
|
1
|
+
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement - very smooth, minimal detail\n float baseNoise = fbm(noisePos, 2) * 0.05;\n\n // Audio-reactive displacement - very low frequencies for smooth waves\n float bassDisplacement = snoise(noisePos * 0.3 + t * 0.1) * uAudioBass * 0.08 * uAudioReactivity;\n float midDisplacement = snoise(noisePos * 0.4 + t * 0.12) * uAudioMid * 0.05 * uAudioReactivity;\n float trebleDisplacement = snoise(noisePos * 0.5 + t * 0.15) * uAudioTreble * 0.02 * uAudioReactivity;\n\n // Combine all displacement\n float totalDisplacement = baseNoise + bassDisplacement + midDisplacement + trebleDisplacement;\n\n // Apply morphing strength\n totalDisplacement *= uMorphStrength;\n\n // Add breathing effect - very subtle\n float breathing = sin(uTime * 0.3) * 0.005 * (1.0 + uAudioLevel * 0.2);\n totalDisplacement += breathing;\n\n // Apply displacement along normal\n pos += normal * totalDisplacement;\n\n vDisplacement = totalDisplacement;\n vElevation = pos.y;\n vPosition = pos;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
@@ -39,7 +39,9 @@ export declare class LinaOrbRenderer {
|
|
|
39
39
|
private _currentEmotion;
|
|
40
40
|
private targetConfig;
|
|
41
41
|
private currentConfig;
|
|
42
|
-
private
|
|
42
|
+
private targetAudioLevel;
|
|
43
|
+
private currentAudioLevel;
|
|
44
|
+
private audioVelocity;
|
|
43
45
|
private targetPulseColor;
|
|
44
46
|
private currentPulseColor;
|
|
45
47
|
private targetRotation;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const glowVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = (modelViewMatrix * vec4(position, 1.0)).xyz;\n\n // Scale up for glow halo\n vec3 pos = position * 1.3;\n\n // Pre-calculate view intensity for smooth falloff\n vec3 viewDir = normalize(-vPosition);\n vIntensity = pow(1.0 - abs(dot(viewDir, vNormal)), 1.5);\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
2
|
-
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect\n float pulse = sin(uTime * uPulseSpeed) * 0.
|
|
2
|
+
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect - very subtle\n float pulse = sin(uTime * uPulseSpeed * 0.3) * 0.03 + 0.97;\n pulse += uAudioLevel * 0.15;\n\n // Smooth radial glow using pre-calculated intensity\n float glow = vIntensity * uGlowIntensity * pulse;\n\n // Very soft falloff for diffuse glow\n glow = pow(glow, 0.8);\n glow *= smoothstep(0.0, 0.3, vIntensity);\n\n // Color with audio reactivity\n vec3 glowColor = uGlowColor * (1.0 + uAudioLevel * 0.5);\n\n // Softer alpha for more diffuse appearance\n gl_FragColor = vec4(glowColor, glow * 0.4);\n}\n";
|
|
3
3
|
export declare const atmosphereVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = position;\n\n // Scale for outer atmosphere\n vec3 pos = position * 1.5;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
4
4
|
export declare const atmosphereFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uAtmosphereColor;\nuniform float uAtmosphereIntensity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vec3 viewDirection = normalize(cameraPosition - vPosition);\n\n // Inverse fresnel for atmosphere (stronger at edges, fading to center)\n float intensity = pow(1.0 - max(dot(viewDirection, vNormal), 0.0), 3.0);\n\n // Audio pulsing\n float pulse = 1.0 + uAudioLevel * 0.4;\n\n // Breathing animation\n float breathing = sin(uTime * 0.5) * 0.1 + 0.9;\n\n float alpha = intensity * uAtmosphereIntensity * pulse * breathing;\n\n // Fade out at very edges\n alpha *= smoothstep(1.0, 0.3, intensity);\n\n vec3 color = uAtmosphereColor * (1.0 + uAudioLevel * 0.3);\n\n gl_FragColor = vec4(color, alpha * 0.4);\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement\n float baseNoise = fbm(noisePos,
|
|
1
|
+
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement - very smooth, minimal detail\n float baseNoise = fbm(noisePos, 2) * 0.05;\n\n // Audio-reactive displacement - very low frequencies for smooth waves\n float bassDisplacement = snoise(noisePos * 0.3 + t * 0.1) * uAudioBass * 0.08 * uAudioReactivity;\n float midDisplacement = snoise(noisePos * 0.4 + t * 0.12) * uAudioMid * 0.05 * uAudioReactivity;\n float trebleDisplacement = snoise(noisePos * 0.5 + t * 0.15) * uAudioTreble * 0.02 * uAudioReactivity;\n\n // Combine all displacement\n float totalDisplacement = baseNoise + bassDisplacement + midDisplacement + trebleDisplacement;\n\n // Apply morphing strength\n totalDisplacement *= uMorphStrength;\n\n // Add breathing effect - very subtle\n float breathing = sin(uTime * 0.3) * 0.005 * (1.0 + uAudioLevel * 0.2);\n totalDisplacement += breathing;\n\n // Apply displacement along normal\n pos += normal * totalDisplacement;\n\n vDisplacement = totalDisplacement;\n vElevation = pos.y;\n vPosition = pos;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|