@wysdym/agent 1.23.0 → 1.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +17 -17
- package/dist/index.es.js +263 -281
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -2090,8 +2090,8 @@ function requireLottie() {
|
|
|
2090
2090
|
function ve(me) {
|
|
2091
2091
|
me.t.a.length === 0 && "m" in me.t.p;
|
|
2092
2092
|
}
|
|
2093
|
-
var
|
|
2094
|
-
return
|
|
2093
|
+
var be = {};
|
|
2094
|
+
return be.completeData = he, be.checkColors = pe, be.checkChars = se, be.checkPathProperties = le, be.checkShapes = ue, be.completeLayers = Q, be;
|
|
2095
2095
|
}
|
|
2096
2096
|
if (L.dataManager || (L.dataManager = H()), L.assetLoader || (L.assetLoader = /* @__PURE__ */ (function() {
|
|
2097
2097
|
function Q(J) {
|
|
@@ -2757,7 +2757,7 @@ function requireLottie() {
|
|
|
2757
2757
|
for (ee = 0; ee < A; ee += 1)
|
|
2758
2758
|
n[ee].animation.setVolume(ne, ce);
|
|
2759
2759
|
}
|
|
2760
|
-
function
|
|
2760
|
+
function be(ne) {
|
|
2761
2761
|
var ce;
|
|
2762
2762
|
for (ce = 0; ce < A; ce += 1)
|
|
2763
2763
|
n[ce].animation.mute(ne);
|
|
@@ -2767,7 +2767,7 @@ function requireLottie() {
|
|
|
2767
2767
|
for (ce = 0; ce < A; ce += 1)
|
|
2768
2768
|
n[ce].animation.unmute(ne);
|
|
2769
2769
|
}
|
|
2770
|
-
return T.registerAnimation = V, T.loadAnimation = z, T.setSpeed = H, T.setDirection = $, T.play = Q, T.pause = G, T.stop = Y, T.togglePause = Z, T.searchAnimations = se, T.resize = le, T.goToAndStop = K, T.destroy = ie, T.freeze = ue, T.unfreeze = he, T.setVolume = ve, T.mute =
|
|
2770
|
+
return T.registerAnimation = V, T.loadAnimation = z, T.setSpeed = H, T.setDirection = $, T.play = Q, T.pause = G, T.stop = Y, T.togglePause = Z, T.searchAnimations = se, T.resize = le, T.goToAndStop = K, T.destroy = ie, T.freeze = ue, T.unfreeze = he, T.setVolume = ve, T.mute = be, T.unmute = me, T.getRegisteredAnimations = B, T;
|
|
2771
2771
|
})(), BezierFactory = (function() {
|
|
2772
2772
|
var T = {};
|
|
2773
2773
|
T.getBezierEasing = P;
|
|
@@ -2959,9 +2959,9 @@ function requireLottie() {
|
|
|
2959
2959
|
Q < 0 ? Q = 0 : Q > 1 && (Q = 1);
|
|
2960
2960
|
var G = V(Q, J);
|
|
2961
2961
|
j = j > 1 ? 1 : j;
|
|
2962
|
-
var K = V(j, J), Y, Z = W.length, ie = 1 - G, se = 1 - K, le = ie * ie * ie, pe = G * ie * ie * 3, ue = G * G * ie * 3, he = G * G * G, ve = ie * ie * se,
|
|
2962
|
+
var K = V(j, J), Y, Z = W.length, ie = 1 - G, se = 1 - K, le = ie * ie * ie, pe = G * ie * ie * 3, ue = G * G * ie * 3, he = G * G * G, ve = ie * ie * se, be = G * ie * se + ie * G * se + ie * ie * K, me = G * G * se + ie * G * K + G * ie * K, ne = G * G * K, ce = ie * se * se, ee = G * se * se + ie * K * se + ie * se * K, te = G * K * se + ie * K * K + G * se * K, oe = G * K * K, ae = se * se * se, de = K * se * se + se * K * se + se * se * K, ge = K * K * se + se * K * K + K * se * K, ye = K * K * K;
|
|
2963
2963
|
for (Y = 0; Y < Z; Y += 1)
|
|
2964
|
-
U[Y * 4] = T.round((le * W[Y] + pe * H[Y] + ue * $[Y] + he * z[Y]) * 1e3) / 1e3, U[Y * 4 + 1] = T.round((ve * W[Y] +
|
|
2964
|
+
U[Y * 4] = T.round((le * W[Y] + pe * H[Y] + ue * $[Y] + he * z[Y]) * 1e3) / 1e3, U[Y * 4 + 1] = T.round((ve * W[Y] + be * H[Y] + me * $[Y] + ne * z[Y]) * 1e3) / 1e3, U[Y * 4 + 2] = T.round((ce * W[Y] + ee * H[Y] + te * $[Y] + oe * z[Y]) * 1e3) / 1e3, U[Y * 4 + 3] = T.round((ae * W[Y] + de * H[Y] + ge * $[Y] + ye * z[Y]) * 1e3) / 1e3;
|
|
2965
2965
|
return U;
|
|
2966
2966
|
}
|
|
2967
2967
|
return {
|
|
@@ -3022,8 +3022,8 @@ function requireLottie() {
|
|
|
3022
3022
|
else if (T <= J)
|
|
3023
3023
|
A[0] = V.s[0], A[1] = V.s[1], A[2] = V.s[2];
|
|
3024
3024
|
else {
|
|
3025
|
-
var
|
|
3026
|
-
quaternionToEuler(A, slerp(
|
|
3025
|
+
var be = createQuaternion(V.s), me = createQuaternion(G), ne = (T - J) / (j - J);
|
|
3026
|
+
quaternionToEuler(A, slerp(be, me, ne));
|
|
3027
3027
|
}
|
|
3028
3028
|
else
|
|
3029
3029
|
for (L = 0; L < O; L += 1)
|
|
@@ -3248,13 +3248,13 @@ function requireLottie() {
|
|
|
3248
3248
|
})(), ShapePropertyFactory = (function() {
|
|
3249
3249
|
var T = -999999;
|
|
3250
3250
|
function n(j, J, G) {
|
|
3251
|
-
var K = G.lastIndex, Y, Z, ie, se, le, pe, ue, he, ve,
|
|
3252
|
-
if (j <
|
|
3253
|
-
Y =
|
|
3254
|
-
else if (j >=
|
|
3255
|
-
Y =
|
|
3251
|
+
var K = G.lastIndex, Y, Z, ie, se, le, pe, ue, he, ve, be = this.keyframes;
|
|
3252
|
+
if (j < be[0].t - this.offsetTime)
|
|
3253
|
+
Y = be[0].s[0], ie = !0, K = 0;
|
|
3254
|
+
else if (j >= be[be.length - 1].t - this.offsetTime)
|
|
3255
|
+
Y = be[be.length - 1].s ? be[be.length - 1].s[0] : be[be.length - 2].e[0], ie = !0;
|
|
3256
3256
|
else {
|
|
3257
|
-
for (var me = K, ne =
|
|
3257
|
+
for (var me = K, ne = be.length - 1, ce = !0, ee, te, oe; ce && (ee = be[me], te = be[me + 1], !(te.t - this.offsetTime > j)); )
|
|
3258
3258
|
me < ne - 1 ? me += 1 : ce = !1;
|
|
3259
3259
|
if (oe = this.keyframesMetadata[me] || {}, ie = ee.h === 1, K = me, !ie) {
|
|
3260
3260
|
if (j >= te.t - this.offsetTime)
|
|
@@ -3354,20 +3354,20 @@ function requireLottie() {
|
|
|
3354
3354
|
this.elem.globalData.frameId !== this.frameId && (this.frameId = this.elem.globalData.frameId, this.iterateDynamicProperties(), this._mdf && this.convertToPath());
|
|
3355
3355
|
},
|
|
3356
3356
|
convertStarToPath: function() {
|
|
3357
|
-
var G = Math.floor(this.pt.v) * 2, K = Math.PI * 2 / G, Y = !0, Z = this.or.v, ie = this.ir.v, se = this.os.v, le = this.is.v, pe = 2 * Math.PI * Z / (G * 2), ue = 2 * Math.PI * ie / (G * 2), he, ve,
|
|
3357
|
+
var G = Math.floor(this.pt.v) * 2, K = Math.PI * 2 / G, Y = !0, Z = this.or.v, ie = this.ir.v, se = this.os.v, le = this.is.v, pe = 2 * Math.PI * Z / (G * 2), ue = 2 * Math.PI * ie / (G * 2), he, ve, be, me, ne = -Math.PI / 2;
|
|
3358
3358
|
ne += this.r.v;
|
|
3359
3359
|
var ce = this.data.d === 3 ? -1 : 1;
|
|
3360
3360
|
for (this.v._length = 0, he = 0; he < G; he += 1) {
|
|
3361
|
-
ve = Y ? Z : ie,
|
|
3361
|
+
ve = Y ? Z : ie, be = Y ? se : le, me = Y ? pe : ue;
|
|
3362
3362
|
var ee = ve * Math.cos(ne), te = ve * Math.sin(ne), oe = ee === 0 && te === 0 ? 0 : te / Math.sqrt(ee * ee + te * te), ae = ee === 0 && te === 0 ? 0 : -ee / Math.sqrt(ee * ee + te * te);
|
|
3363
|
-
ee += +this.p.v[0], te += +this.p.v[1], this.v.setTripleAt(ee, te, ee - oe * me *
|
|
3363
|
+
ee += +this.p.v[0], te += +this.p.v[1], this.v.setTripleAt(ee, te, ee - oe * me * be * ce, te - ae * me * be * ce, ee + oe * me * be * ce, te + ae * me * be * ce, he, !0), Y = !Y, ne += K * ce;
|
|
3364
3364
|
}
|
|
3365
3365
|
},
|
|
3366
3366
|
convertPolygonToPath: function() {
|
|
3367
3367
|
var G = Math.floor(this.pt.v), K = Math.PI * 2 / G, Y = this.or.v, Z = this.os.v, ie = 2 * Math.PI * Y / (G * 4), se, le = -Math.PI * 0.5, pe = this.data.d === 3 ? -1 : 1;
|
|
3368
3368
|
for (le += this.r.v, this.v._length = 0, se = 0; se < G; se += 1) {
|
|
3369
|
-
var ue = Y * Math.cos(le), he = Y * Math.sin(le), ve = ue === 0 && he === 0 ? 0 : he / Math.sqrt(ue * ue + he * he),
|
|
3370
|
-
ue += +this.p.v[0], he += +this.p.v[1], this.v.setTripleAt(ue, he, ue - ve * ie * Z * pe, he -
|
|
3369
|
+
var ue = Y * Math.cos(le), he = Y * Math.sin(le), ve = ue === 0 && he === 0 ? 0 : he / Math.sqrt(ue * ue + he * he), be = ue === 0 && he === 0 ? 0 : -ue / Math.sqrt(ue * ue + he * he);
|
|
3370
|
+
ue += +this.p.v[0], he += +this.p.v[1], this.v.setTripleAt(ue, he, ue - ve * ie * Z * pe, he - be * ie * Z * pe, ue + ve * ie * Z * pe, he + be * ie * Z * pe, se, !0), le += K * pe;
|
|
3371
3371
|
}
|
|
3372
3372
|
this.paths.length = 0, this.paths[0] = this.v;
|
|
3373
3373
|
}
|
|
@@ -3464,8 +3464,8 @@ function requireLottie() {
|
|
|
3464
3464
|
var we = this.props;
|
|
3465
3465
|
if (ee === 1 && te === 0 && oe === 0 && ae === 0 && de === 0 && ge === 1 && ye === 0 && Ee === 0 && Pe === 0 && Ie === 0 && Re === 1 && Le === 0)
|
|
3466
3466
|
return we[12] = we[12] * ee + we[15] * Me, we[13] = we[13] * ge + we[15] * Se, we[14] = we[14] * Re + we[15] * Ce, we[15] *= xe, this._identityCalculated = !1, this;
|
|
3467
|
-
var Oe = we[0], De = we[1], We = we[2], Fe = we[3], ze = we[4], Ne = we[5],
|
|
3468
|
-
return we[0] = Oe * ee + De * de + We * Pe + Fe * Me, we[1] = Oe * te + De * ge + We * Ie + Fe * Se, we[2] = Oe * oe + De * ye + We * Re + Fe * Ce, we[3] = Oe * ae + De * Ee + We * Le + Fe * xe, we[4] = ze * ee + Ne * de +
|
|
3467
|
+
var Oe = we[0], De = we[1], We = we[2], Fe = we[3], ze = we[4], Ne = we[5], Ve = we[6], Ye = we[7], Xe = we[8], qe = we[9], Qe = we[10], Ge = we[11], et = we[12], nt = we[13], Ze = we[14], tt = we[15];
|
|
3468
|
+
return we[0] = Oe * ee + De * de + We * Pe + Fe * Me, we[1] = Oe * te + De * ge + We * Ie + Fe * Se, we[2] = Oe * oe + De * ye + We * Re + Fe * Ce, we[3] = Oe * ae + De * Ee + We * Le + Fe * xe, we[4] = ze * ee + Ne * de + Ve * Pe + Ye * Me, we[5] = ze * te + Ne * ge + Ve * Ie + Ye * Se, we[6] = ze * oe + Ne * ye + Ve * Re + Ye * Ce, we[7] = ze * ae + Ne * Ee + Ve * Le + Ye * xe, we[8] = Xe * ee + qe * de + Qe * Pe + Ge * Me, we[9] = Xe * te + qe * ge + Qe * Ie + Ge * Se, we[10] = Xe * oe + qe * ye + Qe * Re + Ge * Ce, we[11] = Xe * ae + qe * Ee + Qe * Le + Ge * xe, we[12] = et * ee + nt * de + Ze * Pe + tt * Me, we[13] = et * te + nt * ge + Ze * Ie + tt * Se, we[14] = et * oe + nt * ye + Ze * Re + tt * Ce, we[15] = et * ae + nt * Ee + Ze * Le + tt * xe, this._identityCalculated = !1, this;
|
|
3469
3469
|
}
|
|
3470
3470
|
function Q(ee) {
|
|
3471
3471
|
var te = ee.props;
|
|
@@ -3537,7 +3537,7 @@ function requireLottie() {
|
|
|
3537
3537
|
var ae;
|
|
3538
3538
|
return this.isIdentity() ? ae = [ee, te, oe] : ae = [ee * this.props[0] + te * this.props[4] + oe * this.props[8] + this.props[12], ee * this.props[1] + te * this.props[5] + oe * this.props[9] + this.props[13], ee * this.props[2] + te * this.props[6] + oe * this.props[10] + this.props[14]], ae;
|
|
3539
3539
|
}
|
|
3540
|
-
function
|
|
3540
|
+
function be(ee, te) {
|
|
3541
3541
|
if (this.isIdentity())
|
|
3542
3542
|
return ee + "," + te;
|
|
3543
3543
|
var oe = this.props;
|
|
@@ -3557,7 +3557,7 @@ function requireLottie() {
|
|
|
3557
3557
|
return "matrix(" + te + "," + oe + "," + ae + "," + de + "," + ge + "," + ye + ")";
|
|
3558
3558
|
}
|
|
3559
3559
|
return function() {
|
|
3560
|
-
this.reset = R, this.rotate = L, this.rotateX = O, this.rotateY = N, this.rotateZ = V, this.skew = U, this.skewFromAxis = q, this.shear = B, this.scale = W, this.setTransform = z, this.translate = H, this.transform = $, this.multiply = Q, this.applyToPoint = Y, this.applyToX = Z, this.applyToY = ie, this.applyToZ = se, this.applyToPointArray = ve, this.applyToTriplePoints = he, this.applyToPointStringified =
|
|
3560
|
+
this.reset = R, this.rotate = L, this.rotateX = O, this.rotateY = N, this.rotateZ = V, this.skew = U, this.skewFromAxis = q, this.shear = B, this.scale = W, this.setTransform = z, this.translate = H, this.transform = $, this.multiply = Q, this.applyToPoint = Y, this.applyToX = Z, this.applyToY = ie, this.applyToZ = se, this.applyToPointArray = ve, this.applyToTriplePoints = he, this.applyToPointStringified = be, this.toCSS = me, this.to2dCSS = ce, this.clone = G, this.cloneFromProps = K, this.equals = J, this.inversePoints = ue, this.inversePoint = pe, this.getInverseMatrix = le, this._t = this.transform, this.isIdentity = j, this._identity = !0, this._identityCalculated = !1, this.props = createTypedArray("float32", 16), this.reset();
|
|
3561
3561
|
};
|
|
3562
3562
|
})();
|
|
3563
3563
|
function _typeof$3(T) {
|
|
@@ -4546,10 +4546,10 @@ function requireLottie() {
|
|
|
4546
4546
|
function ve() {
|
|
4547
4547
|
this.isLoaded = !0;
|
|
4548
4548
|
}
|
|
4549
|
-
var
|
|
4549
|
+
var be = function() {
|
|
4550
4550
|
this.fonts = [], this.chars = null, this.typekitLoaded = 0, this.isLoaded = !1, this._warned = !1, this.initTime = Date.now(), this.setIsLoadedBinded = this.setIsLoaded.bind(this), this.checkLoadedFontsBinded = this.checkLoadedFonts.bind(this);
|
|
4551
4551
|
};
|
|
4552
|
-
|
|
4552
|
+
be.isModifier = Z, be.isZeroWidthJoiner = ie, be.isFlagEmoji = pe, be.isRegionalCode = le, be.isCombinedCharacter = ue, be.isRegionalFlag = he, be.isVariationSelector = se, be.BLACK_FLAG_CODE_POINT = A;
|
|
4553
4553
|
var me = {
|
|
4554
4554
|
addChars: j,
|
|
4555
4555
|
addFonts: Q,
|
|
@@ -4559,7 +4559,7 @@ function requireLottie() {
|
|
|
4559
4559
|
checkLoadedFonts: H,
|
|
4560
4560
|
setIsLoaded: ve
|
|
4561
4561
|
};
|
|
4562
|
-
return
|
|
4562
|
+
return be.prototype = me, be;
|
|
4563
4563
|
})();
|
|
4564
4564
|
function SlotManager(T) {
|
|
4565
4565
|
this.animationData = T;
|
|
@@ -5565,7 +5565,7 @@ function requireLottie() {
|
|
|
5565
5565
|
ue || (ue = Math.sqrt(Math.pow(Q[0] - j[0], 2) + Math.pow(Q[1] - j[1], 2)));
|
|
5566
5566
|
var he = Math.atan2(j[1] - Q[1], j[0] - Q[0]), ve = W.h.v;
|
|
5567
5567
|
ve >= 1 ? ve = 0.99 : ve <= -1 && (ve = -0.99);
|
|
5568
|
-
var
|
|
5568
|
+
var be = ue * ve, me = Math.cos(he + W.a.v) * be + Q[0], ne = Math.sin(he + W.a.v) * be + Q[1];
|
|
5569
5569
|
H.setAttribute("fx", me), H.setAttribute("fy", ne), $ && !W.g._collapsable && (W.of.setAttribute("fx", me), W.of.setAttribute("fy", ne));
|
|
5570
5570
|
}
|
|
5571
5571
|
}
|
|
@@ -5767,9 +5767,9 @@ function requireLottie() {
|
|
|
5767
5767
|
ue += J.ascent * T.finalSize / 100, this.canResize && T.finalSize > this.minimumFontSize && pe < ue ? (T.finalSize -= 1, T.finalLineHeight = T.finalSize * T.lh / T.s) : (T.finalText = he, L = T.finalText.length, se = !1);
|
|
5768
5768
|
}
|
|
5769
5769
|
H = -Z, K = 0;
|
|
5770
|
-
var
|
|
5770
|
+
var be = 0, me;
|
|
5771
5771
|
for (R = 0; R < L; R += 1)
|
|
5772
|
-
if (O = !1, me = T.finalText[R], ie = me.charCodeAt(0), ie === 13 || ie === 3 ? (
|
|
5772
|
+
if (O = !1, me = T.finalText[R], ie = me.charCodeAt(0), ie === 13 || ie === 3 ? (be = 0, z.push(H), $ = H > $ ? H : $, H = -2 * Z, V = "", O = !0, W += 1) : V = me, n.chars ? (G = n.getCharData(me, J.fStyle, n.getFontByName(T.f).fFamily), K = O ? 0 : G.w * T.finalSize / 100) : K = n.measureText(V, T.f, T.finalSize), me === " " ? be += K + Z : (H += K + Z + be, be = 0), A.push({
|
|
5773
5773
|
l: K,
|
|
5774
5774
|
an: K,
|
|
5775
5775
|
add: U,
|
|
@@ -5958,23 +5958,23 @@ function requireLottie() {
|
|
|
5958
5958
|
Y = Z[G].points, K = Y[J - 1], $ = Y[J], ie = $.partialLength;
|
|
5959
5959
|
}
|
|
5960
5960
|
q = W.length, V = 0, B = 0;
|
|
5961
|
-
var
|
|
5961
|
+
var be = T.finalSize * 1.2 * 0.714, me = !0, ne, ce, ee, te, oe;
|
|
5962
5962
|
te = A.length;
|
|
5963
5963
|
var ae, de = -1, ge, ye, Ee, Pe = H, Ie = G, Re = J, Le = -1, Me, Se, Ce, xe, we, Oe, De, We, Fe = "", ze = this.defaultPropsArray, Ne;
|
|
5964
5964
|
if (T.j === 2 || T.j === 1) {
|
|
5965
|
-
var
|
|
5965
|
+
var Ve = 0, Ye = 0, Xe = T.j === 2 ? -0.5 : -1, qe = 0, Qe = !0;
|
|
5966
5966
|
for (U = 0; U < q; U += 1)
|
|
5967
5967
|
if (W[U].n) {
|
|
5968
|
-
for (
|
|
5969
|
-
W[qe].animatorJustifyOffset =
|
|
5970
|
-
|
|
5968
|
+
for (Ve && (Ve += Ye); qe < U; )
|
|
5969
|
+
W[qe].animatorJustifyOffset = Ve, qe += 1;
|
|
5970
|
+
Ve = 0, Qe = !0;
|
|
5971
5971
|
} else {
|
|
5972
5972
|
for (ee = 0; ee < te; ee += 1)
|
|
5973
|
-
ne = A[ee].a, ne.t.propType && (Qe && T.j === 2 && (Ye += ne.t.v * Xe), ce = A[ee].s, ae = ce.getMult(W[U].anIndexes[ee], R.a[ee].s.totalChars), ae.length ?
|
|
5973
|
+
ne = A[ee].a, ne.t.propType && (Qe && T.j === 2 && (Ye += ne.t.v * Xe), ce = A[ee].s, ae = ce.getMult(W[U].anIndexes[ee], R.a[ee].s.totalChars), ae.length ? Ve += ne.t.v * ae[0] * Xe : Ve += ne.t.v * ae * Xe);
|
|
5974
5974
|
Qe = !1;
|
|
5975
5975
|
}
|
|
5976
|
-
for (
|
|
5977
|
-
W[qe].animatorJustifyOffset =
|
|
5976
|
+
for (Ve && (Ve += Ye); qe < U; )
|
|
5977
|
+
W[qe].animatorJustifyOffset = Ve, qe += 1;
|
|
5978
5978
|
}
|
|
5979
5979
|
for (U = 0; U < q; U += 1) {
|
|
5980
5980
|
if (L.reset(), Me = 1, W[U].n)
|
|
@@ -5997,10 +5997,10 @@ function requireLottie() {
|
|
|
5997
5997
|
for (ee = 0; ee < te; ee += 1)
|
|
5998
5998
|
ne = A[ee].a, ne.p.propType && (ce = A[ee].s, ae = ce.getMult(W[U].anIndexes[ee], R.a[ee].s.totalChars), ae.length ? Ge += ne.p.v[0] * ae[0] : Ge += ne.p.v[0] * ae), ne.a.propType && (ce = A[ee].s, ae = ce.getMult(W[U].anIndexes[ee], R.a[ee].s.totalChars), ae.length ? Ge += ne.a.v[0] * ae[0] : Ge += ne.a.v[0] * ae);
|
|
5999
5999
|
for (j = !0, this._pathData.a.v && (H = W[0].an * 0.5 + (se - this._pathData.f.v - W[0].an * 0.5 - W[W.length - 1].an * 0.5) * de / (q - 1), H += this._pathData.f.v); j; )
|
|
6000
|
-
Q + ie >= H + Ge || !Y ? (le = (H + Ge - Q) / $.partialLength, ye = K.point[0] + ($.point[0] - K.point[0]) * le, Ee = K.point[1] + ($.point[1] - K.point[1]) * le, L.translate(-P[0] * W[U].an * 5e-3, -(P[1] *
|
|
6000
|
+
Q + ie >= H + Ge || !Y ? (le = (H + Ge - Q) / $.partialLength, ye = K.point[0] + ($.point[0] - K.point[0]) * le, Ee = K.point[1] + ($.point[1] - K.point[1]) * le, L.translate(-P[0] * W[U].an * 5e-3, -(P[1] * be) * 0.01), j = !1) : Y && (Q += $.partialLength, J += 1, J >= Y.length && (J = 0, G += 1, Z[G] ? Y = Z[G].points : ue.v.c ? (J = 0, G = 0, Y = Z[G].points) : (Q -= $.partialLength, Y = null)), Y && (K = $, $ = Y[J], ie = $.partialLength));
|
|
6001
6001
|
ge = W[U].an / 2 - W[U].add, L.translate(-ge, 0, 0);
|
|
6002
6002
|
} else
|
|
6003
|
-
ge = W[U].an / 2 - W[U].add, L.translate(-ge, 0, 0), L.translate(-P[0] * W[U].an * 5e-3, -P[1] *
|
|
6003
|
+
ge = W[U].an / 2 - W[U].add, L.translate(-ge, 0, 0), L.translate(-P[0] * W[U].an * 5e-3, -P[1] * be * 0.01, 0);
|
|
6004
6004
|
for (ee = 0; ee < te; ee += 1)
|
|
6005
6005
|
ne = A[ee].a, ne.t.propType && (ce = A[ee].s, ae = ce.getMult(W[U].anIndexes[ee], R.a[ee].s.totalChars), (V !== 0 || T.j !== 0) && (this._hasMaskedPath ? ae.length ? H += ne.t.v * ae[0] : H += ne.t.v * ae : ae.length ? V += ne.t.v * ae[0] : V += ne.t.v * ae));
|
|
6006
6006
|
for (T.strokeWidthAnim && (Ce = T.sw || 0), T.strokeColorAnim && (T.sc ? Se = [T.sc[0], T.sc[1], T.sc[2]] : Se = [0, 0, 0]), T.fillColorAnim && T.fc && (xe = [T.fc[0], T.fc[1], T.fc[2]]), ee = 0; ee < te; ee += 1)
|
|
@@ -6021,7 +6021,7 @@ function requireLottie() {
|
|
|
6021
6021
|
for (ee = 0; ee < te; ee += 1)
|
|
6022
6022
|
ne = A[ee].a, ne.p.propType && (ce = A[ee].s, ae = ce.getMult(W[U].anIndexes[ee], R.a[ee].s.totalChars), this._hasMaskedPath ? ae.length ? L.translate(0, ne.p.v[1] * ae[0], -ne.p.v[2] * ae[1]) : L.translate(0, ne.p.v[1] * ae, -ne.p.v[2] * ae) : ae.length ? L.translate(ne.p.v[0] * ae[0], ne.p.v[1] * ae[1], -ne.p.v[2] * ae[2]) : L.translate(ne.p.v[0] * ae, ne.p.v[1] * ae, -ne.p.v[2] * ae));
|
|
6023
6023
|
if (T.strokeWidthAnim && (Oe = Ce < 0 ? 0 : Ce), T.strokeColorAnim && (De = "rgb(" + Math.round(Se[0] * 255) + "," + Math.round(Se[1] * 255) + "," + Math.round(Se[2] * 255) + ")"), T.fillColorAnim && T.fc && (We = "rgb(" + Math.round(xe[0] * 255) + "," + Math.round(xe[1] * 255) + "," + Math.round(xe[2] * 255) + ")"), this._hasMaskedPath) {
|
|
6024
|
-
if (L.translate(0, -T.ls), L.translate(0, P[1] *
|
|
6024
|
+
if (L.translate(0, -T.ls), L.translate(0, P[1] * be * 0.01 + B, 0), this._pathData.p.v) {
|
|
6025
6025
|
pe = ($.point[1] - K.point[1]) / ($.point[0] - K.point[0]);
|
|
6026
6026
|
var et = Math.atan(pe) * 180 / Math.PI;
|
|
6027
6027
|
$.point[0] < K.point[0] && (et += 180), L.rotate(-et * Math.PI / 180);
|
|
@@ -6036,7 +6036,7 @@ function requireLottie() {
|
|
|
6036
6036
|
L.translate(W[U].animatorJustifyOffset + T.justifyOffset + (T.boxWidth - T.lineWidths[W[U].line]) / 2, 0, 0);
|
|
6037
6037
|
break;
|
|
6038
6038
|
}
|
|
6039
|
-
L.translate(0, -T.ls), L.translate(ge, 0, 0), L.translate(P[0] * W[U].an * 5e-3, P[1] *
|
|
6039
|
+
L.translate(0, -T.ls), L.translate(ge, 0, 0), L.translate(P[0] * W[U].an * 5e-3, P[1] * be * 0.01, 0), V += W[U].l + T.tr * 1e-3 * T.finalSize;
|
|
6040
6040
|
}
|
|
6041
6041
|
O === "html" ? Fe = L.toCSS() : O === "svg" ? Fe = L.to2dCSS() : ze = [L.props[0], L.props[1], L.props[2], L.props[3], L.props[4], L.props[5], L.props[6], L.props[7], L.props[8], L.props[9], L.props[10], L.props[11], L.props[12], L.props[13], L.props[14], L.props[15]], Ne = Me;
|
|
6042
6042
|
}
|
|
@@ -7561,9 +7561,9 @@ function requireLottie() {
|
|
|
7561
7561
|
for (ie = 0; ie < A; ie++)
|
|
7562
7562
|
le[ie] = le[se = U & se + G[ie % Y] + (K = le[ie])], le[se] = K;
|
|
7563
7563
|
Z.g = function(pe) {
|
|
7564
|
-
for (var ue, he = 0, ve = Z.i,
|
|
7565
|
-
ue = me[ve = U & ve + 1], he = he * A + me[U & (me[ve] = me[
|
|
7566
|
-
return Z.i = ve, Z.j =
|
|
7564
|
+
for (var ue, he = 0, ve = Z.i, be = Z.j, me = Z.S; pe--; )
|
|
7565
|
+
ue = me[ve = U & ve + 1], he = he * A + me[U & (me[ve] = me[be = U & be + ue]) + (me[be] = ue)];
|
|
7566
|
+
return Z.i = ve, Z.j = be, he;
|
|
7567
7567
|
};
|
|
7568
7568
|
}
|
|
7569
7569
|
function H(G, K) {
|
|
@@ -9340,7 +9340,7 @@ var _excluded$1 = ["animationData", "loop", "autoplay", "initialSegment", "onCom
|
|
|
9340
9340
|
}, ve = function(de, ge) {
|
|
9341
9341
|
var ye;
|
|
9342
9342
|
(ye = Z.current) === null || ye === void 0 || ye.goToAndStop(de, ge);
|
|
9343
|
-
},
|
|
9343
|
+
}, be = function(de) {
|
|
9344
9344
|
var ge;
|
|
9345
9345
|
(ge = Z.current) === null || ge === void 0 || ge.setDirection(de);
|
|
9346
9346
|
}, me = function(de, ge) {
|
|
@@ -9451,7 +9451,7 @@ var _excluded$1 = ["animationData", "loop", "autoplay", "initialSegment", "onCom
|
|
|
9451
9451
|
setSpeed: ue,
|
|
9452
9452
|
goToAndStop: ve,
|
|
9453
9453
|
goToAndPlay: he,
|
|
9454
|
-
setDirection:
|
|
9454
|
+
setDirection: be,
|
|
9455
9455
|
playSegments: me,
|
|
9456
9456
|
setSubframe: ne,
|
|
9457
9457
|
getDuration: ce,
|
|
@@ -14981,8 +14981,8 @@ function requireLoglevel() {
|
|
|
14981
14981
|
}
|
|
14982
14982
|
if (typeof ue === P)
|
|
14983
14983
|
try {
|
|
14984
|
-
var he = window.document.cookie, ve = encodeURIComponent(Y),
|
|
14985
|
-
|
|
14984
|
+
var he = window.document.cookie, ve = encodeURIComponent(Y), be = he.indexOf(ve + "=");
|
|
14985
|
+
be !== -1 && (ue = /^([^;]+)/.exec(he.slice(be + ve.length + 1))[1]);
|
|
14986
14986
|
} catch {
|
|
14987
14987
|
}
|
|
14988
14988
|
return j.levels[ue] === void 0 && (ue = void 0), ue;
|
|
@@ -15205,7 +15205,7 @@ function requireEvents() {
|
|
|
15205
15205
|
if (typeof he == "function")
|
|
15206
15206
|
n(he, this, Z);
|
|
15207
15207
|
else
|
|
15208
|
-
for (var ve = he.length,
|
|
15208
|
+
for (var ve = he.length, be = H(he, ve), ie = 0; ie < ve; ++ie) n(be[ie], this, Z);
|
|
15209
15209
|
return !0;
|
|
15210
15210
|
};
|
|
15211
15211
|
function B(K, Y, Z, ie) {
|
|
@@ -24171,7 +24171,7 @@ class LocalParticipant extends Participant {
|
|
|
24171
24171
|
this.log.debug("finished recording preconnect buffer", Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(n))), n.stopPreConnectBuffer();
|
|
24172
24172
|
}
|
|
24173
24173
|
}), le && new Promise((he, ve) => __awaiter(this, void 0, void 0, function* () {
|
|
24174
|
-
var
|
|
24174
|
+
var be, me, ne, ce, ee, te;
|
|
24175
24175
|
try {
|
|
24176
24176
|
this.log.debug("waiting for agent", Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(n)));
|
|
24177
24177
|
const ge = setTimeout(() => {
|
|
@@ -24190,7 +24190,7 @@ class LocalParticipant extends Participant {
|
|
|
24190
24190
|
}
|
|
24191
24191
|
});
|
|
24192
24192
|
try {
|
|
24193
|
-
for (var oe = !0, ae = __asyncValues(le), de; de = yield ae.next(),
|
|
24193
|
+
for (var oe = !0, ae = __asyncValues(le), de; de = yield ae.next(), be = de.done, !be; oe = !0) {
|
|
24194
24194
|
ce = de.value, oe = !1;
|
|
24195
24195
|
const Pe = ce;
|
|
24196
24196
|
yield Ee.write(Pe);
|
|
@@ -24201,7 +24201,7 @@ class LocalParticipant extends Participant {
|
|
|
24201
24201
|
};
|
|
24202
24202
|
} finally {
|
|
24203
24203
|
try {
|
|
24204
|
-
!oe && !
|
|
24204
|
+
!oe && !be && (ne = ae.return) && (yield ne.call(ae));
|
|
24205
24205
|
} finally {
|
|
24206
24206
|
if (me) throw me.error;
|
|
24207
24207
|
}
|
|
@@ -27775,7 +27775,7 @@ const elevenLabsErrorLogger = new ElevenLabsErrorLogger(), useElevenLabsManager
|
|
|
27775
27775
|
}), P?.(oe);
|
|
27776
27776
|
},
|
|
27777
27777
|
onMessage: (oe) => {
|
|
27778
|
-
|
|
27778
|
+
be(), console.log("[ElevenLabsManager] 📨 Message received:", JSON.stringify(oe).substring(0, 300)), A?.(oe);
|
|
27779
27779
|
}
|
|
27780
27780
|
}), [N, V] = useState("disconnected"), [B, U] = useState(null), [q, W] = useState([]), z = useRef(null);
|
|
27781
27781
|
useEffect(() => {
|
|
@@ -28145,7 +28145,7 @@ const elevenLabsErrorLogger = new ElevenLabsErrorLogger(), useElevenLabsManager
|
|
|
28145
28145
|
H.current && (clearInterval(H.current), H.current = null, $.current = !1, console.log("[ElevenLabsManager] 🛑 Session renewal stopped"));
|
|
28146
28146
|
}, []), ve = useCallback(() => {
|
|
28147
28147
|
U(null);
|
|
28148
|
-
}, []),
|
|
28148
|
+
}, []), be = useCallback(() => {
|
|
28149
28149
|
j.current = Date.now();
|
|
28150
28150
|
}, []), me = useCallback(async (oe, ae = 3) => {
|
|
28151
28151
|
if (N === "connecting" || N === "reconnecting")
|
|
@@ -28232,7 +28232,7 @@ const elevenLabsErrorLogger = new ElevenLabsErrorLogger(), useElevenLabsManager
|
|
|
28232
28232
|
startSessionRenewal: ue,
|
|
28233
28233
|
stopSessionRenewal: he,
|
|
28234
28234
|
clearError: ve,
|
|
28235
|
-
updateActivity:
|
|
28235
|
+
updateActivity: be,
|
|
28236
28236
|
manualReconnect: me,
|
|
28237
28237
|
sendKeepAlive: ce,
|
|
28238
28238
|
// Audio control
|
|
@@ -28448,7 +28448,7 @@ const elevenLabsErrorLogger = new ElevenLabsErrorLogger(), useElevenLabsManager
|
|
|
28448
28448
|
};
|
|
28449
28449
|
console.log("[useVoiceSessionV2] 🎯 Adding first message to store:", me), L([me]), console.log("[useVoiceSessionV2] 🎤 Setting agent as speaking for initial message"), z.setAgentSpeaking && z.setAgentSpeaking(!0);
|
|
28450
28450
|
}
|
|
28451
|
-
const
|
|
28451
|
+
const be = setTimeout(() => {
|
|
28452
28452
|
throw console.error("[useVoiceSessionV2] ⏰ Session start timeout - taking too long"), new Error("Session start timeout - taking too long");
|
|
28453
28453
|
}, 3e4);
|
|
28454
28454
|
try {
|
|
@@ -28490,11 +28490,11 @@ const elevenLabsErrorLogger = new ElevenLabsErrorLogger(), useElevenLabsManager
|
|
|
28490
28490
|
companyToken: V || ""
|
|
28491
28491
|
}
|
|
28492
28492
|
});
|
|
28493
|
-
if (clearTimeout(
|
|
28493
|
+
if (clearTimeout(be), console.log("[useVoiceSessionV2] 📊 ElevenLabs session result:", ce), ce)
|
|
28494
28494
|
return G.startSessionRenewal(), U.current = !0, console.log("[useVoiceSessionV2] 🎯 Session started - ElevenLabs will manage speaking/listening states"), console.log("[useVoiceSessionV2] ✅ Voice session started successfully"), !0;
|
|
28495
28495
|
throw new Error("Failed to start ElevenLabs session");
|
|
28496
28496
|
} catch (me) {
|
|
28497
|
-
throw clearTimeout(
|
|
28497
|
+
throw clearTimeout(be), me;
|
|
28498
28498
|
}
|
|
28499
28499
|
} catch (le) {
|
|
28500
28500
|
return console.error("[useVoiceSessionV2] ❌ Failed to start voice session:", le), B.current && (B.current.getTracks().forEach((pe) => pe.stop()), B.current = null), le instanceof Error && le.name === "NotAllowedError" ? O("Microphone access denied. Please allow microphone access to use voice mode.") : O(`Failed to start voice mode: ${le instanceof Error ? le.message : "Unknown error"}`), !1;
|
|
@@ -31211,13 +31211,13 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31211
31211
|
}
|
|
31212
31212
|
console.log("[SocketService] Authenticating..."), socket.emit("authenticate", { token: authToken });
|
|
31213
31213
|
}, getSocket = () => socket, useWidgetStore = ({ companyToken: T, agentId: n, analyticsService: P, mode: A = "floating", initialExpanded: R = !1 }) => {
|
|
31214
|
-
const [L, O] = useState(R), [N, V] = useState(!1), [B, U] = useState(!1), [q, W] = useState(null), [z, H] = useState(null), [$, Q] = useState(null), [j, J] = useState(null), [G, K] = useState(!1), [Y, Z] = useState(!1), [ie, se] = useState("voice"), [le, pe] = useState(0), [ue, he] = useState([]), [ve,
|
|
31214
|
+
const [L, O] = useState(R), [N, V] = useState(!1), [B, U] = useState(!1), [q, W] = useState(null), [z, H] = useState(null), [$, Q] = useState(null), [j, J] = useState(null), [G, K] = useState(!1), [Y, Z] = useState(!1), [ie, se] = useState("voice"), [le, pe] = useState(0), [ue, he] = useState([]), [ve, be] = useState(""), [me, ne] = useState(!1), [ce, ee] = useState(null), [te, oe] = useState(null), [ae, de] = useState(null), [ge, ye] = useState(!1), [Ee, Pe] = useState(!1), [Ie, Re] = useState(!1), [Le, Me] = useState(!1), [Se, Ce] = useState(!1), [xe, we] = useState("active"), [Oe, De] = useState(!1), [We, Fe] = useState("idle"), [ze, Ne] = useState(void 0), [Ve, Ye] = useState(!1), [Xe, qe] = useState(!1), [Qe, Ge] = useState("form_active"), [et, nt] = useState(!1);
|
|
31215
31215
|
useEffect(() => {
|
|
31216
|
-
console.log("[WidgetStoreV2] 📋 hasActiveForm changed to:",
|
|
31217
|
-
}, [
|
|
31218
|
-
const fe = (
|
|
31219
|
-
const
|
|
31220
|
-
console.log("[WidgetStoreV2]
|
|
31216
|
+
console.log("[WidgetStoreV2] 📋 hasActiveForm changed to:", Ve);
|
|
31217
|
+
}, [Ve]), useEffect(() => {
|
|
31218
|
+
const fe = (ke) => {
|
|
31219
|
+
const _e = (ke?.detail ?? {}).force_display ?? !1;
|
|
31220
|
+
console.log("[WidgetStoreV2] show_email_form event received", { force_display: _e }), Me(!0), Ce(_e);
|
|
31221
31221
|
};
|
|
31222
31222
|
return window.addEventListener("show_email_form", fe), () => window.removeEventListener("show_email_form", fe);
|
|
31223
31223
|
}, []);
|
|
@@ -31228,7 +31228,7 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31228
31228
|
}, []), at = useCallback((fe) => {
|
|
31229
31229
|
J(fe), fe && P?.setJwt(fe);
|
|
31230
31230
|
}, [P]), mt = useCallback((fe) => {
|
|
31231
|
-
he((
|
|
31231
|
+
he((ke) => [...ke, fe]);
|
|
31232
31232
|
}, []), St = useCallback(async () => {
|
|
31233
31233
|
if (n) {
|
|
31234
31234
|
U(!0), W(null);
|
|
@@ -31239,46 +31239,28 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31239
31239
|
});
|
|
31240
31240
|
if (!fe.ok)
|
|
31241
31241
|
throw new Error("Failed to get bootstrap JWT");
|
|
31242
|
-
const { access_token:
|
|
31243
|
-
at(
|
|
31242
|
+
const { access_token: ke } = await fe.json();
|
|
31243
|
+
at(ke);
|
|
31244
31244
|
const Ae = await fetch(buildApiUrl(`api/widget/session/agent-config/${n}`), {
|
|
31245
31245
|
method: "GET",
|
|
31246
31246
|
headers: {
|
|
31247
|
-
Authorization: `Bearer ${
|
|
31247
|
+
Authorization: `Bearer ${ke}`,
|
|
31248
31248
|
"Content-Type": "application/json"
|
|
31249
31249
|
}
|
|
31250
31250
|
});
|
|
31251
31251
|
if (!Ae.ok)
|
|
31252
31252
|
throw new Error(`Failed to load agent: ${Ae.statusText}`);
|
|
31253
|
-
const
|
|
31254
|
-
oe(
|
|
31255
|
-
id: Te.id,
|
|
31256
|
-
name: Te.name,
|
|
31257
|
-
agent_instructions: Te.agent_instructions,
|
|
31258
|
-
agent_first_message: Te.agent_first_message,
|
|
31259
|
-
require_email: Te.require_email,
|
|
31260
|
-
company_id: Te.company_id,
|
|
31261
|
-
allKeys: Object.keys(Te)
|
|
31262
|
-
}), console.log("[WidgetStoreV2] 📧 EMAIL CAPTURE DEBUG:", {
|
|
31263
|
-
require_email_value: Te.require_email,
|
|
31264
|
-
require_email_type: typeof Te.require_email,
|
|
31265
|
-
require_email_stringify: JSON.stringify(Te.require_email),
|
|
31266
|
-
is_truthy: !!Te.require_email,
|
|
31267
|
-
is_exactly_true: Te.require_email === !0,
|
|
31268
|
-
is_exactly_false: Te.require_email === !1,
|
|
31269
|
-
is_null_or_undefined: Te.require_email == null,
|
|
31270
|
-
all_agent_keys: Object.keys(Te),
|
|
31271
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
31272
|
-
});
|
|
31253
|
+
const _e = await Ae.json();
|
|
31254
|
+
oe(_e), console.log("[WidgetStoreV2] Agent loaded:", _e.name, { require_email: _e.require_email });
|
|
31273
31255
|
} catch (fe) {
|
|
31274
31256
|
console.error("[WidgetStoreV2] ❌ Failed to load agent:", fe);
|
|
31275
|
-
const
|
|
31257
|
+
const ke = fe instanceof Error ? fe.message : "Unknown error";
|
|
31276
31258
|
console.error("[WidgetStoreV2] ❌ Error details:", {
|
|
31277
|
-
message:
|
|
31259
|
+
message: ke,
|
|
31278
31260
|
error: fe,
|
|
31279
31261
|
companyToken: T,
|
|
31280
31262
|
agentId: n
|
|
31281
|
-
}), W(`Failed to load agent: ${
|
|
31263
|
+
}), W(`Failed to load agent: ${ke}`);
|
|
31282
31264
|
} finally {
|
|
31283
31265
|
U(!1);
|
|
31284
31266
|
}
|
|
@@ -31295,7 +31277,7 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31295
31277
|
console.warn("[WidgetStoreV2] ⚠️ No JWT token available for CTA authentication, skipping...");
|
|
31296
31278
|
return;
|
|
31297
31279
|
}
|
|
31298
|
-
const fe = new AbortController(),
|
|
31280
|
+
const fe = new AbortController(), ke = setTimeout(() => fe.abort(), 5e3), Ae = await fetch(buildApiUrl(`api/widget/custom-cta/${n}`), {
|
|
31299
31281
|
method: "GET",
|
|
31300
31282
|
headers: {
|
|
31301
31283
|
Authorization: `Bearer ${j || $}`,
|
|
@@ -31303,14 +31285,14 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31303
31285
|
},
|
|
31304
31286
|
signal: fe.signal
|
|
31305
31287
|
});
|
|
31306
|
-
if (clearTimeout(
|
|
31307
|
-
const
|
|
31308
|
-
de(
|
|
31288
|
+
if (clearTimeout(ke), console.log("[WidgetStoreV2] 🎨 CTA response status:", Ae.status, Ae.statusText), console.log("[WidgetStoreV2] 🎨 CTA response headers:", Object.fromEntries(Ae.headers.entries())), Ae.ok) {
|
|
31289
|
+
const _e = await Ae.json(), Be = _e.has_cta && _e.cta ? _e.cta : null;
|
|
31290
|
+
de(Be), console.log("[WidgetStoreV2] ✅ Custom CTA loaded:", Be?.button_text ?? "none");
|
|
31309
31291
|
} else {
|
|
31310
31292
|
console.warn("[WidgetStoreV2] ⚠️ Custom CTA endpoint returned status:", Ae.status, Ae.statusText);
|
|
31311
31293
|
try {
|
|
31312
|
-
const
|
|
31313
|
-
console.warn("[WidgetStoreV2] ⚠️ CTA error response body:",
|
|
31294
|
+
const _e = await Ae.text();
|
|
31295
|
+
console.warn("[WidgetStoreV2] ⚠️ CTA error response body:", _e);
|
|
31314
31296
|
} catch {
|
|
31315
31297
|
console.warn("[WidgetStoreV2] ⚠️ Could not read CTA error response body");
|
|
31316
31298
|
}
|
|
@@ -31323,37 +31305,37 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31323
31305
|
let fe = j || $;
|
|
31324
31306
|
if (!fe)
|
|
31325
31307
|
try {
|
|
31326
|
-
const
|
|
31308
|
+
const ke = await fetch(buildApiUrl(`api/widget/bootstrap?agent_id=${n}`), {
|
|
31327
31309
|
method: "GET",
|
|
31328
31310
|
headers: { "Content-Type": "application/json" }
|
|
31329
31311
|
});
|
|
31330
|
-
if (!
|
|
31331
|
-
fe = (await
|
|
31312
|
+
if (!ke.ok) return;
|
|
31313
|
+
fe = (await ke.json()).access_token, at(fe);
|
|
31332
31314
|
} catch {
|
|
31333
31315
|
return;
|
|
31334
31316
|
}
|
|
31335
31317
|
try {
|
|
31336
|
-
const
|
|
31318
|
+
const ke = await fetch(buildApiUrl(`api/widget/session/agent-config/${n}`), {
|
|
31337
31319
|
method: "GET",
|
|
31338
31320
|
headers: {
|
|
31339
31321
|
Authorization: `Bearer ${fe}`,
|
|
31340
31322
|
"Content-Type": "application/json"
|
|
31341
31323
|
}
|
|
31342
31324
|
});
|
|
31343
|
-
if (!
|
|
31344
|
-
const Ae = await
|
|
31345
|
-
oe(Ae), Ae.require_email === !1 && (Me(!1), Ce(!1)), console.log("[WidgetStoreV2]
|
|
31346
|
-
} catch (
|
|
31347
|
-
console.warn("[WidgetStoreV2] ⚠️ Failed to refresh agent config:",
|
|
31325
|
+
if (!ke.ok) return;
|
|
31326
|
+
const Ae = await ke.json();
|
|
31327
|
+
oe(Ae), Ae.require_email === !1 && (Me(!1), Ce(!1)), console.log("[WidgetStoreV2] Agent config refreshed:", { require_email: Ae.require_email });
|
|
31328
|
+
} catch (ke) {
|
|
31329
|
+
console.warn("[WidgetStoreV2] ⚠️ Failed to refresh agent config:", ke);
|
|
31348
31330
|
}
|
|
31349
31331
|
}, [T, n, j, $]);
|
|
31350
31332
|
useEffect(() => {
|
|
31351
|
-
const fe = (
|
|
31352
|
-
(
|
|
31333
|
+
const fe = (ke) => {
|
|
31334
|
+
(ke?.detail ?? {}).agentId === n && (wt(), ct());
|
|
31353
31335
|
};
|
|
31354
31336
|
return window.addEventListener("wysdym-agent-config-updated", fe), () => window.removeEventListener("wysdym-agent-config-updated", fe);
|
|
31355
31337
|
}, [n, wt, ct]);
|
|
31356
|
-
const Tt = $ || j || "",
|
|
31338
|
+
const Tt = $ || j || "", Te = useVoiceSessionV2({
|
|
31357
31339
|
agent: te,
|
|
31358
31340
|
agentId: n,
|
|
31359
31341
|
sessionId: z || "",
|
|
@@ -31385,29 +31367,29 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31385
31367
|
});
|
|
31386
31368
|
if (!fe.ok)
|
|
31387
31369
|
throw console.error("[WidgetStoreV2] ❌ Bootstrap response failed:", fe.status, fe.statusText), new Error("Failed to get bootstrap JWT");
|
|
31388
|
-
const { access_token:
|
|
31389
|
-
console.log("[WidgetStoreV2] ✅ Got bootstrap JWT"), at(
|
|
31370
|
+
const { access_token: ke } = await fe.json();
|
|
31371
|
+
console.log("[WidgetStoreV2] ✅ Got bootstrap JWT"), at(ke);
|
|
31390
31372
|
try {
|
|
31391
31373
|
const $e = await fetch(buildApiUrl(`api/widget/session/agent-config/${n}`), {
|
|
31392
31374
|
method: "GET",
|
|
31393
31375
|
headers: {
|
|
31394
|
-
Authorization: `Bearer ${
|
|
31376
|
+
Authorization: `Bearer ${ke}`,
|
|
31395
31377
|
"Content-Type": "application/json"
|
|
31396
31378
|
}
|
|
31397
31379
|
});
|
|
31398
31380
|
if ($e.ok) {
|
|
31399
31381
|
const Ke = await $e.json();
|
|
31400
|
-
oe(Ke), console.log("[WidgetStoreV2]
|
|
31382
|
+
oe(Ke), console.log("[WidgetStoreV2] Agent config refreshed for session:", { require_email: Ke.require_email });
|
|
31401
31383
|
}
|
|
31402
31384
|
} catch ($e) {
|
|
31403
31385
|
console.warn("[WidgetStoreV2] ⚠️ Failed to refresh agent config, using cached:", $e);
|
|
31404
31386
|
}
|
|
31405
31387
|
const Ae = P ? await P.getAnonymousUserId() : typeof localStorage < "u" ? localStorage.getItem(`wysdym_anonymous_user_${T}`) : null;
|
|
31406
31388
|
console.log("[WidgetStoreV2] 📡 Creating session via intake...", { anonymousUserId: Ae ? `${Ae.slice(0, 8)}...` : null });
|
|
31407
|
-
const
|
|
31389
|
+
const _e = await fetch(buildApiUrl("api/widget/session/intake"), {
|
|
31408
31390
|
method: "POST",
|
|
31409
31391
|
headers: {
|
|
31410
|
-
Authorization: `Bearer ${
|
|
31392
|
+
Authorization: `Bearer ${ke}`,
|
|
31411
31393
|
"Content-Type": "application/json"
|
|
31412
31394
|
},
|
|
31413
31395
|
body: JSON.stringify({
|
|
@@ -31418,25 +31400,25 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31418
31400
|
anonymous_user_id: Ae || void 0
|
|
31419
31401
|
})
|
|
31420
31402
|
});
|
|
31421
|
-
if (!
|
|
31422
|
-
throw console.error("[WidgetStoreV2] ❌ Intake response failed:",
|
|
31423
|
-
const
|
|
31424
|
-
console.log("[WidgetStoreV2] ✅ Got session data:", { session_id:
|
|
31403
|
+
if (!_e.ok)
|
|
31404
|
+
throw console.error("[WidgetStoreV2] ❌ Intake response failed:", _e.status, _e.statusText), new Error(`Failed to create session: ${_e.statusText}`);
|
|
31405
|
+
const Be = await _e.json(), { session_id: Ue, widget_jwt: je, has_email: Je } = Be;
|
|
31406
|
+
console.log("[WidgetStoreV2] ✅ Got session data:", { session_id: Ue, hasJwt: !!je, has_email: Je }), H(Ue), Q(je), Z(!0), K(!1), Re(!!Je), console.log("[WidgetStoreV2] 🔌 Initializing socket for session:", Ue), initializeSocket(Ue, je), console.log("[WidgetStoreV2] ✅ Direct session started:", Ue), console.log("[WidgetStoreV2] ⏳ Voice session will start automatically...");
|
|
31425
31407
|
} catch (fe) {
|
|
31426
31408
|
console.error("[WidgetStoreV2] ❌ Failed to start direct session:", fe), W(`Failed to start session: ${fe instanceof Error ? fe.message : "Unknown error"}`), U(!1);
|
|
31427
31409
|
}
|
|
31428
31410
|
}, [T, n, A, P]), It = useCallback(async (fe) => {
|
|
31429
|
-
const
|
|
31430
|
-
if (console.log("[WidgetStoreV2]
|
|
31411
|
+
const ke = $ || j, Ae = z && $;
|
|
31412
|
+
if (console.log("[WidgetStoreV2] Email submit:", { email: fe, hasActiveSession: !!Ae }), !ke) {
|
|
31431
31413
|
console.error("[WidgetStoreV2] ❌ Missing JWT for email submission");
|
|
31432
31414
|
return;
|
|
31433
31415
|
}
|
|
31434
31416
|
ne(!0), ee(null);
|
|
31435
31417
|
try {
|
|
31436
31418
|
if (Ae) {
|
|
31437
|
-
const
|
|
31438
|
-
console.log("[WidgetStoreV2]
|
|
31439
|
-
const
|
|
31419
|
+
const _e = P ? await P.getAnonymousUserId() : typeof localStorage < "u" ? localStorage.getItem(`wysdym_anonymous_user_${T}`) : null;
|
|
31420
|
+
console.log("[WidgetStoreV2] Updating email for session");
|
|
31421
|
+
const Be = await fetch(buildApiUrl(`api/widget/session/update-email/${z}`), {
|
|
31440
31422
|
method: "POST",
|
|
31441
31423
|
headers: {
|
|
31442
31424
|
Authorization: `Bearer ${$}`,
|
|
@@ -31444,17 +31426,17 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31444
31426
|
},
|
|
31445
31427
|
body: JSON.stringify({
|
|
31446
31428
|
email: fe.trim(),
|
|
31447
|
-
anonymous_user_id:
|
|
31429
|
+
anonymous_user_id: _e || void 0
|
|
31448
31430
|
})
|
|
31449
31431
|
});
|
|
31450
|
-
if (!
|
|
31451
|
-
const je = await
|
|
31452
|
-
throw new Error(`Failed to update email: ${
|
|
31432
|
+
if (!Be.ok) {
|
|
31433
|
+
const je = await Be.text();
|
|
31434
|
+
throw new Error(`Failed to update email: ${Be.statusText} ${je}`);
|
|
31453
31435
|
}
|
|
31454
|
-
const
|
|
31455
|
-
console.log("[WidgetStoreV2]
|
|
31436
|
+
const Ue = await Be.json();
|
|
31437
|
+
console.log("[WidgetStoreV2] Email updated successfully"), Pe(!0), Re(!0), Me(!1), Ce(!1), console.log("[WidgetStoreV2] ✅ Email updated successfully");
|
|
31456
31438
|
} else {
|
|
31457
|
-
const
|
|
31439
|
+
const _e = P ? await P.getAnonymousUserId() : typeof localStorage < "u" ? localStorage.getItem(`wysdym_anonymous_user_${T}`) : null, Be = await fetch(buildApiUrl("api/widget/session/intake"), {
|
|
31458
31440
|
method: "POST",
|
|
31459
31441
|
headers: {
|
|
31460
31442
|
Authorization: `Bearer ${j}`,
|
|
@@ -31467,20 +31449,20 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31467
31449
|
needs: [],
|
|
31468
31450
|
challenges: [],
|
|
31469
31451
|
agent_id: n,
|
|
31470
|
-
anonymous_user_id:
|
|
31452
|
+
anonymous_user_id: _e || void 0
|
|
31471
31453
|
})
|
|
31472
31454
|
});
|
|
31473
|
-
if (!
|
|
31474
|
-
throw new Error(`Failed to submit email: ${
|
|
31475
|
-
const
|
|
31476
|
-
console.log("[WidgetStoreV2]
|
|
31477
|
-
const { session_id: je, widget_jwt: Je } =
|
|
31455
|
+
if (!Be.ok)
|
|
31456
|
+
throw new Error(`Failed to submit email: ${Be.statusText}`);
|
|
31457
|
+
const Ue = await Be.json();
|
|
31458
|
+
console.log("[WidgetStoreV2] Intake session created");
|
|
31459
|
+
const { session_id: je, widget_jwt: Je } = Ue;
|
|
31478
31460
|
if (!je || !Je)
|
|
31479
31461
|
throw new Error("Invalid response from intake endpoint");
|
|
31480
31462
|
H(je), Q(Je), K(!1), Z(!0), Pe(!0), Re(!0), Me(!1), Ce(!1), console.log("[WidgetStoreV2] 🔌 Initializing socket for session:", je), initializeSocket(je, Je), console.log("[WidgetStoreV2] ✅ Email submitted successfully");
|
|
31481
31463
|
}
|
|
31482
|
-
} catch (
|
|
31483
|
-
console.error("[WidgetStoreV2] ❌ Failed to submit email:",
|
|
31464
|
+
} catch (_e) {
|
|
31465
|
+
console.error("[WidgetStoreV2] ❌ Failed to submit email:", _e), ee(`Failed to submit email: ${_e instanceof Error ? _e.message : "Unknown error"}`);
|
|
31484
31466
|
} finally {
|
|
31485
31467
|
ne(!1);
|
|
31486
31468
|
}
|
|
@@ -31491,8 +31473,8 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31491
31473
|
return console.error("[WidgetStoreV2] ❌ Cannot reconnect: missing session data"), !1;
|
|
31492
31474
|
try {
|
|
31493
31475
|
if (console.log("[WidgetStoreV2] 🔄 Manual reconnection initiated by user..."), nt(!0), ie === "voice") {
|
|
31494
|
-
const fe = ue.filter((
|
|
31495
|
-
return await
|
|
31476
|
+
const fe = ue.filter((_e) => _e.role === "user").slice(-1)[0]?.content || "", ke = ue.filter((_e) => _e.role === "assistant").slice(-1)[0]?.content || "";
|
|
31477
|
+
return await Te.startVoiceSession(!0, fe, ke) ? (console.log("[WidgetStoreV2] ✅ Voice session reconnected successfully"), qe(!1), !0) : (W("Failed to reconnect voice. Please try again."), !1);
|
|
31496
31478
|
} else
|
|
31497
31479
|
return await rt.startTextSession() ? (console.log("[WidgetStoreV2] ✅ Text session reconnected successfully"), !0) : (W("Failed to reconnect. Please try again."), !1);
|
|
31498
31480
|
} catch (fe) {
|
|
@@ -31500,23 +31482,23 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31500
31482
|
} finally {
|
|
31501
31483
|
nt(!1);
|
|
31502
31484
|
}
|
|
31503
|
-
}, [z, j, $, ie, ue,
|
|
31485
|
+
}, [z, j, $, ie, ue, Te, rt]), Lt = useCallback(() => {
|
|
31504
31486
|
A === "floating" && O(!0);
|
|
31505
31487
|
}, [A]), vt = useCallback(() => {
|
|
31506
31488
|
O(!1);
|
|
31507
|
-
}, []),
|
|
31489
|
+
}, []), Ct = useCallback(() => {
|
|
31508
31490
|
Ze.current = Date.now(), tt.current = setInterval(() => {
|
|
31509
31491
|
if (Ze.current) {
|
|
31510
31492
|
const fe = Math.floor((Date.now() - Ze.current) / 1e3);
|
|
31511
31493
|
pe(fe);
|
|
31512
31494
|
}
|
|
31513
31495
|
}, 1e3);
|
|
31514
|
-
}, []),
|
|
31496
|
+
}, []), _t = useCallback(() => {
|
|
31515
31497
|
tt.current && (clearInterval(tt.current), tt.current = null), Ze.current = null;
|
|
31516
31498
|
}, []);
|
|
31517
31499
|
useEffect(() => {
|
|
31518
|
-
|
|
31519
|
-
}, [
|
|
31500
|
+
Te.isConnected && !Ze.current && Ct();
|
|
31501
|
+
}, [Te.isConnected, Ct]), useEffect(() => {
|
|
31520
31502
|
}, []), useEffect(() => {
|
|
31521
31503
|
A === "floating" && L && !te && !N && !ht.current && (ht.current = !0, console.log("[WidgetStoreV2] 🚀 Widget expanded, auto-loading agent..."), St());
|
|
31522
31504
|
}, [A, L, te, N, St]), useEffect(() => {
|
|
@@ -31528,19 +31510,19 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31528
31510
|
demoStarted: Y,
|
|
31529
31511
|
hasAgent: !!te,
|
|
31530
31512
|
agentName: te?.name,
|
|
31531
|
-
isConnected:
|
|
31532
|
-
isConnecting:
|
|
31513
|
+
isConnected: Te.isConnected,
|
|
31514
|
+
isConnecting: Te.isConnecting,
|
|
31533
31515
|
alreadyInitialized: st.current,
|
|
31534
31516
|
mode: A,
|
|
31535
31517
|
sessionId: z || "none",
|
|
31536
31518
|
hasJwt: !!(j || $)
|
|
31537
|
-
}), Y && te && !
|
|
31538
|
-
const fe = te && (z || !te.require_email),
|
|
31519
|
+
}), Y && te && !Te.isConnected && !Te.isConnecting && !st.current) {
|
|
31520
|
+
const fe = te && (z || !te.require_email), ke = j || $;
|
|
31539
31521
|
console.log("[WidgetStoreV2] 🎤 Voice session init check:", {
|
|
31540
31522
|
hasRequiredData: fe,
|
|
31541
|
-
hasJwt:
|
|
31523
|
+
hasJwt: ke,
|
|
31542
31524
|
sessionId: z || "none"
|
|
31543
|
-
}), fe &&
|
|
31525
|
+
}), fe && ke ? (st.current = !0, console.log("[WidgetStoreV2] 🎤 Starting voice session for", A, "mode..."), (async () => {
|
|
31544
31526
|
try {
|
|
31545
31527
|
if (console.log("[WidgetStoreV2] 🎤 About to call startVoiceSession..."), !z || !(j || $) || !te) {
|
|
31546
31528
|
console.error("[WidgetStoreV2] ❌ Missing data for voice session:", {
|
|
@@ -31550,22 +31532,22 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31550
31532
|
}), U(!1);
|
|
31551
31533
|
return;
|
|
31552
31534
|
}
|
|
31553
|
-
const
|
|
31554
|
-
console.log("[WidgetStoreV2] 🎤 Voice session startVoiceSession called, result:",
|
|
31555
|
-
} catch (
|
|
31556
|
-
console.error("[WidgetStoreV2] ❌ Voice session error:",
|
|
31535
|
+
const _e = await Te.startVoiceSession();
|
|
31536
|
+
console.log("[WidgetStoreV2] 🎤 Voice session startVoiceSession called, result:", _e), _e ? (console.log("[WidgetStoreV2] ✅ Voice session started successfully"), U(!1)) : (console.warn("[WidgetStoreV2] ⚠️ Voice session failed to start"), st.current = !1, U(!1));
|
|
31537
|
+
} catch (_e) {
|
|
31538
|
+
console.error("[WidgetStoreV2] ❌ Voice session error:", _e), st.current = !1, U(!1);
|
|
31557
31539
|
}
|
|
31558
31540
|
})()) : console.log("[WidgetStoreV2] ⏳ Waiting for voice session data...");
|
|
31559
31541
|
} else
|
|
31560
31542
|
console.log("[WidgetStoreV2] ⏳ Voice session init conditions not met:", {
|
|
31561
31543
|
demoStarted: Y,
|
|
31562
31544
|
hasAgent: !!te,
|
|
31563
|
-
isConnected:
|
|
31564
|
-
isConnecting:
|
|
31545
|
+
isConnected: Te.isConnected,
|
|
31546
|
+
isConnecting: Te.isConnecting,
|
|
31565
31547
|
alreadyInitialized: st.current,
|
|
31566
|
-
reason: Y ? te ?
|
|
31548
|
+
reason: Y ? te ? Te.isConnected ? "already connected" : Te.isConnecting ? "already connecting" : "already initialized" : "no agent" : "demo not started"
|
|
31567
31549
|
});
|
|
31568
|
-
}, [Y, te, z, j, $,
|
|
31550
|
+
}, [Y, te, z, j, $, Te.isConnected, Te.isConnecting, U, A]);
|
|
31569
31551
|
const Ot = useCallback(async () => {
|
|
31570
31552
|
if (n) {
|
|
31571
31553
|
V(!0), W(null);
|
|
@@ -31576,19 +31558,19 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31576
31558
|
});
|
|
31577
31559
|
if (!fe.ok)
|
|
31578
31560
|
throw new Error("Failed to get bootstrap JWT");
|
|
31579
|
-
const { access_token:
|
|
31580
|
-
at(
|
|
31561
|
+
const { access_token: ke } = await fe.json();
|
|
31562
|
+
at(ke);
|
|
31581
31563
|
const Ae = await fetch(buildApiUrl(`api/widget/session/agent-config/${n}`), {
|
|
31582
31564
|
method: "GET",
|
|
31583
31565
|
headers: {
|
|
31584
|
-
Authorization: `Bearer ${
|
|
31566
|
+
Authorization: `Bearer ${ke}`,
|
|
31585
31567
|
"Content-Type": "application/json"
|
|
31586
31568
|
}
|
|
31587
31569
|
});
|
|
31588
31570
|
if (!Ae.ok)
|
|
31589
31571
|
throw new Error(`Failed to load agent: ${Ae.statusText}`);
|
|
31590
|
-
const
|
|
31591
|
-
oe(
|
|
31572
|
+
const _e = await Ae.json();
|
|
31573
|
+
oe(_e), console.log("[WidgetStoreV2] ✅ Agent loaded:", _e.name);
|
|
31592
31574
|
} catch (fe) {
|
|
31593
31575
|
console.error("[WidgetStoreV2] ❌ Failed to load agent:", fe);
|
|
31594
31576
|
} finally {
|
|
@@ -31597,8 +31579,8 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31597
31579
|
}
|
|
31598
31580
|
}, [T, n]);
|
|
31599
31581
|
useEffect(() => () => {
|
|
31600
|
-
|
|
31601
|
-
}, [
|
|
31582
|
+
_t();
|
|
31583
|
+
}, [_t]), useEffect(() => {
|
|
31602
31584
|
}, [L]);
|
|
31603
31585
|
const yt = useCallback(async () => {
|
|
31604
31586
|
if (ft.current) {
|
|
@@ -31609,7 +31591,7 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31609
31591
|
try {
|
|
31610
31592
|
if (z && $)
|
|
31611
31593
|
try {
|
|
31612
|
-
const fe = buildApiUrl(`api/widget/session/${z}/end`),
|
|
31594
|
+
const fe = buildApiUrl(`api/widget/session/${z}/end`), ke = await fetch(fe, {
|
|
31613
31595
|
method: "POST",
|
|
31614
31596
|
headers: {
|
|
31615
31597
|
Authorization: `Bearer ${$}`,
|
|
@@ -31617,29 +31599,29 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31617
31599
|
"Content-Type": "application/json"
|
|
31618
31600
|
}
|
|
31619
31601
|
});
|
|
31620
|
-
if (
|
|
31602
|
+
if (ke.ok)
|
|
31621
31603
|
console.log("[WidgetStoreV2] ✅ Session ended on backend successfully");
|
|
31622
31604
|
else {
|
|
31623
|
-
const Ae = await
|
|
31624
|
-
console.warn("[WidgetStoreV2] ⚠️ Failed to end session on backend:",
|
|
31605
|
+
const Ae = await ke.text();
|
|
31606
|
+
console.warn("[WidgetStoreV2] ⚠️ Failed to end session on backend:", ke.status, Ae);
|
|
31625
31607
|
}
|
|
31626
31608
|
} catch (fe) {
|
|
31627
31609
|
console.error("[WidgetStoreV2] ⚠️ Error calling end endpoint:", fe);
|
|
31628
31610
|
}
|
|
31629
31611
|
else
|
|
31630
31612
|
console.warn("[WidgetStoreV2] ⚠️ No sessionId or widgetJwt available for backend session end");
|
|
31631
|
-
|
|
31613
|
+
Te.isConnected && await Te.endVoiceSession(), rt.isConnected && await rt.endTextSession(), Z(!1), ye(!0), st.current = !1, ht.current = !1, pt.current = !1, A === "inline" && (H(null), Q(null), at(null), he([]), W(null), U(!1)), A === "floating" && vt();
|
|
31632
31614
|
} catch (fe) {
|
|
31633
31615
|
console.error("[WidgetStoreV2] ❌ Error ending call:", fe), ut(`Failed to end call: ${fe instanceof Error ? fe.message : "Unknown error"}`);
|
|
31634
31616
|
} finally {
|
|
31635
31617
|
ft.current = !1;
|
|
31636
31618
|
}
|
|
31637
|
-
}, [
|
|
31619
|
+
}, [Te, rt, vt, A, z, $, T]), lt = useCallback(async () => {
|
|
31638
31620
|
console.log("[WidgetStoreV2] Pausing session...");
|
|
31639
31621
|
try {
|
|
31640
|
-
if (
|
|
31622
|
+
if (Te.isConnected)
|
|
31641
31623
|
try {
|
|
31642
|
-
await
|
|
31624
|
+
await Te.endVoiceSession(), console.log("[WidgetStoreV2] Voice session ended due to pause");
|
|
31643
31625
|
} catch (fe) {
|
|
31644
31626
|
console.error("[WidgetStoreV2] Error ending voice session on pause:", fe);
|
|
31645
31627
|
}
|
|
@@ -31654,8 +31636,8 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31654
31636
|
}
|
|
31655
31637
|
});
|
|
31656
31638
|
if (fe.ok) {
|
|
31657
|
-
const
|
|
31658
|
-
console.log("[WidgetStoreV2] Session paused successfully:",
|
|
31639
|
+
const ke = await fe.json();
|
|
31640
|
+
console.log("[WidgetStoreV2] Session paused successfully:", ke), we("paused"), updateStatus("paused");
|
|
31659
31641
|
} else fe.status === 401 || fe.status === 403 ? (console.warn("[WidgetStoreV2] JWT expired during pause, will need to re-bootstrap on resume"), we("paused")) : console.error("[WidgetStoreV2] Failed to pause session:", fe.statusText);
|
|
31660
31642
|
} catch (fe) {
|
|
31661
31643
|
console.error("[WidgetStoreV2] Error calling pause endpoint:", fe), we("paused");
|
|
@@ -31672,14 +31654,14 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31672
31654
|
} catch (fe) {
|
|
31673
31655
|
console.error("[WidgetStoreV2] Error in pauseSession:", fe);
|
|
31674
31656
|
}
|
|
31675
|
-
}, [z, $, T,
|
|
31657
|
+
}, [z, $, T, Te, P]), Ft = useCallback(async (fe) => {
|
|
31676
31658
|
if (!$ || !z) {
|
|
31677
31659
|
console.warn("[WidgetStoreV2] Skipping CTA tracking: missing credentials", { sessionId: z, hasJwt: !!$ });
|
|
31678
31660
|
return;
|
|
31679
31661
|
}
|
|
31680
31662
|
P && P.trackCTAClick(fe.id, fe.button_text);
|
|
31681
31663
|
try {
|
|
31682
|
-
const
|
|
31664
|
+
const ke = await fetch(buildApiUrl("api/widget/custom-cta/click"), {
|
|
31683
31665
|
method: "POST",
|
|
31684
31666
|
headers: {
|
|
31685
31667
|
Authorization: `Bearer ${$}`,
|
|
@@ -31690,9 +31672,9 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31690
31672
|
widget_session_id: z
|
|
31691
31673
|
})
|
|
31692
31674
|
});
|
|
31693
|
-
if (
|
|
31694
|
-
const
|
|
31695
|
-
sessionStorage.setItem("lastCtaClickId",
|
|
31675
|
+
if (ke.ok) {
|
|
31676
|
+
const _e = await ke.json();
|
|
31677
|
+
sessionStorage.setItem("lastCtaClickId", _e.id);
|
|
31696
31678
|
}
|
|
31697
31679
|
if (fe.open_in_new_tab !== !1)
|
|
31698
31680
|
window.open(fe.href, "_blank", "noopener,noreferrer");
|
|
@@ -31712,8 +31694,8 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31712
31694
|
lastMessage: ue.length > 0 ? ue[ue.length - 1].content : void 0
|
|
31713
31695
|
}
|
|
31714
31696
|
}), sessionStorage.setItem(CTA_SAME_TAB_REDIRECT_KEY, "1");
|
|
31715
|
-
} catch (
|
|
31716
|
-
console.warn("[WidgetStoreV2] Failed to pause before same-tab redirect:",
|
|
31697
|
+
} catch (_e) {
|
|
31698
|
+
console.warn("[WidgetStoreV2] Failed to pause before same-tab redirect:", _e), saveSession({
|
|
31717
31699
|
sessionId: z,
|
|
31718
31700
|
widgetJwt: $,
|
|
31719
31701
|
agentId: n,
|
|
@@ -31726,40 +31708,40 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31726
31708
|
}
|
|
31727
31709
|
window.location.href = fe.href;
|
|
31728
31710
|
}
|
|
31729
|
-
} catch (
|
|
31730
|
-
console.error("[WidgetStoreV2] Error handling CTA click:",
|
|
31711
|
+
} catch (ke) {
|
|
31712
|
+
console.error("[WidgetStoreV2] Error handling CTA click:", ke);
|
|
31731
31713
|
const Ae = fe.open_in_new_tab !== !1 ? "_blank" : "_self";
|
|
31732
31714
|
window.open(fe.href, Ae, fe.open_in_new_tab !== !1 ? "noopener,noreferrer" : void 0);
|
|
31733
31715
|
}
|
|
31734
31716
|
}, [$, z, n, T, P, lt, ue]);
|
|
31735
31717
|
useEffect(() => {
|
|
31736
|
-
|
|
31737
|
-
}, [
|
|
31718
|
+
Te.setAgentSpeaking && Te.setAgentSpeaking(Te.isAgentSpeaking);
|
|
31719
|
+
}, [Te.isAgentSpeaking, Te.setAgentSpeaking]);
|
|
31738
31720
|
const Nt = useCallback((fe) => {
|
|
31739
31721
|
Q(fe);
|
|
31740
|
-
}, []), bt = useCallback(async (fe,
|
|
31722
|
+
}, []), bt = useCallback(async (fe, ke) => {
|
|
31741
31723
|
console.log("[WidgetStoreV2] Resuming session...");
|
|
31742
|
-
const Ae = fe ?? z,
|
|
31743
|
-
if (!Ae || !
|
|
31724
|
+
const Ae = fe ?? z, _e = ke ?? $;
|
|
31725
|
+
if (!Ae || !_e)
|
|
31744
31726
|
return console.error("[WidgetStoreV2] Cannot resume: missing session ID or JWT"), !1;
|
|
31745
31727
|
try {
|
|
31746
|
-
const
|
|
31728
|
+
const Be = await fetch(buildApiUrl(`api/widget/session/${Ae}/resume`), {
|
|
31747
31729
|
method: "POST",
|
|
31748
31730
|
headers: {
|
|
31749
|
-
Authorization: `Bearer ${
|
|
31731
|
+
Authorization: `Bearer ${_e}`,
|
|
31750
31732
|
"X-Client-Token": T,
|
|
31751
31733
|
"Content-Type": "application/json"
|
|
31752
31734
|
}
|
|
31753
31735
|
});
|
|
31754
|
-
if (
|
|
31755
|
-
const
|
|
31756
|
-
console.log("[WidgetStoreV2] Session resumed successfully:",
|
|
31736
|
+
if (Be.ok) {
|
|
31737
|
+
const Ue = await Be.json();
|
|
31738
|
+
console.log("[WidgetStoreV2] Session resumed successfully:", Ue), H(Ae), Q(_e), we("active"), De(!1), updateStatus("active");
|
|
31757
31739
|
let je = "", Je = "";
|
|
31758
31740
|
try {
|
|
31759
31741
|
const $e = await fetch(buildApiUrl(`api/widget/session/${Ae}/history`), {
|
|
31760
31742
|
method: "GET",
|
|
31761
31743
|
headers: {
|
|
31762
|
-
Authorization: `Bearer ${
|
|
31744
|
+
Authorization: `Bearer ${_e}`,
|
|
31763
31745
|
"X-Client-Token": T,
|
|
31764
31746
|
"Content-Type": "application/json"
|
|
31765
31747
|
}
|
|
@@ -31780,18 +31762,18 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31780
31762
|
} catch ($e) {
|
|
31781
31763
|
console.error("[WidgetStoreV2] Error loading history:", $e);
|
|
31782
31764
|
}
|
|
31783
|
-
return ie === "voice" && await
|
|
31765
|
+
return ie === "voice" && await Te.startVoiceSession(!0, je, Je), P && P.trackEvent("session_resumed", "Session Resumed", {
|
|
31784
31766
|
sessionId: Ae
|
|
31785
31767
|
}), !0;
|
|
31786
|
-
} else if (
|
|
31768
|
+
} else if (Be.status === 401 || Be.status === 403) {
|
|
31787
31769
|
console.warn("[WidgetStoreV2] JWT expired during resume, re-bootstrapping...");
|
|
31788
31770
|
try {
|
|
31789
|
-
const
|
|
31771
|
+
const Ue = await fetch(buildApiUrl(`api/widget/bootstrap?agent_id=${n}`), {
|
|
31790
31772
|
method: "GET",
|
|
31791
31773
|
headers: { "Content-Type": "application/json" }
|
|
31792
31774
|
});
|
|
31793
|
-
if (
|
|
31794
|
-
const { access_token: je } = await
|
|
31775
|
+
if (Ue.ok) {
|
|
31776
|
+
const { access_token: je } = await Ue.json();
|
|
31795
31777
|
if (at(je), Q(je), (await fetch(buildApiUrl(`api/widget/session/${Ae}/resume`), {
|
|
31796
31778
|
method: "POST",
|
|
31797
31779
|
headers: {
|
|
@@ -31826,16 +31808,16 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31826
31808
|
return !0;
|
|
31827
31809
|
}
|
|
31828
31810
|
}
|
|
31829
|
-
} catch (
|
|
31830
|
-
console.error("[WidgetStoreV2] Re-bootstrap failed:",
|
|
31811
|
+
} catch (Ue) {
|
|
31812
|
+
console.error("[WidgetStoreV2] Re-bootstrap failed:", Ue);
|
|
31831
31813
|
}
|
|
31832
31814
|
return clearSession(), De(!1), W("Session expired. Please start a new conversation."), !1;
|
|
31833
31815
|
} else
|
|
31834
|
-
return console.error("[WidgetStoreV2] Failed to resume session:",
|
|
31835
|
-
} catch (
|
|
31836
|
-
return console.error("[WidgetStoreV2] Error resuming session:",
|
|
31816
|
+
return console.error("[WidgetStoreV2] Failed to resume session:", Be.statusText), !1;
|
|
31817
|
+
} catch (Be) {
|
|
31818
|
+
return console.error("[WidgetStoreV2] Error resuming session:", Be), !1;
|
|
31837
31819
|
}
|
|
31838
|
-
}, [z, $, T, n, ie,
|
|
31820
|
+
}, [z, $, T, n, ie, Te, P]), Vt = useCallback(async () => {
|
|
31839
31821
|
console.log("[WidgetStoreV2] Ending session with persistence cleanup...");
|
|
31840
31822
|
try {
|
|
31841
31823
|
if (z && $)
|
|
@@ -31861,34 +31843,34 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31861
31843
|
}, [lt]), xt = useCallback(async () => {
|
|
31862
31844
|
console.log("[WidgetStoreV2] Tab visible - checking for resumable session");
|
|
31863
31845
|
try {
|
|
31864
|
-
const fe = sessionStorage.getItem("lastCtaClickId"),
|
|
31846
|
+
const fe = sessionStorage.getItem("lastCtaClickId"), ke = hasValidSession() ? loadSession() : null, Ae = ke?.widgetJwt || $;
|
|
31865
31847
|
if (fe && Ae && fe !== "agent-redirect")
|
|
31866
31848
|
try {
|
|
31867
31849
|
await fetch(buildApiUrl(`api/widget/custom-cta/return/${fe}`), {
|
|
31868
31850
|
method: "POST",
|
|
31869
31851
|
headers: { Authorization: `Bearer ${Ae}` }
|
|
31870
31852
|
});
|
|
31871
|
-
} catch (
|
|
31872
|
-
console.error("[WidgetStoreV2] Error tracking CTA return:",
|
|
31853
|
+
} catch (_e) {
|
|
31854
|
+
console.error("[WidgetStoreV2] Error tracking CTA return:", _e);
|
|
31873
31855
|
}
|
|
31874
|
-
if (fe && sessionStorage.removeItem("lastCtaClickId"), hasValidSession() &&
|
|
31856
|
+
if (fe && sessionStorage.removeItem("lastCtaClickId"), hasValidSession() && ke && ke && ke.status === "paused") {
|
|
31875
31857
|
if (fe) {
|
|
31876
31858
|
console.log("[WidgetStoreV2] Returning from CTA - auto-resuming session");
|
|
31877
31859
|
try {
|
|
31878
|
-
await bt(
|
|
31879
|
-
} catch (
|
|
31880
|
-
console.error("[WidgetStoreV2] Auto-resume failed:",
|
|
31860
|
+
await bt(ke.sessionId, ke.widgetJwt);
|
|
31861
|
+
} catch (_e) {
|
|
31862
|
+
console.error("[WidgetStoreV2] Auto-resume failed:", _e), H(ke.sessionId), Q(ke.widgetJwt), we("resumable"), De(!0);
|
|
31881
31863
|
}
|
|
31882
31864
|
return;
|
|
31883
31865
|
}
|
|
31884
|
-
if (console.log("[WidgetStoreV2] Found paused session, marking as resumable"), H(
|
|
31866
|
+
if (console.log("[WidgetStoreV2] Found paused session, marking as resumable"), H(ke.sessionId), Q(ke.widgetJwt), we("resumable"), De(!0), ke.conversationState && console.log("[WidgetStoreV2] Restoring conversation state:", ke.conversationState), P)
|
|
31885
31867
|
try {
|
|
31886
31868
|
P.trackEvent("session_resumable", "Session Resumable", {
|
|
31887
|
-
sessionId:
|
|
31888
|
-
messageCount:
|
|
31869
|
+
sessionId: ke.sessionId,
|
|
31870
|
+
messageCount: ke.conversationState?.messageCount || 0
|
|
31889
31871
|
});
|
|
31890
|
-
} catch (
|
|
31891
|
-
console.error("[WidgetStoreV2] Error tracking resumable event:",
|
|
31872
|
+
} catch (_e) {
|
|
31873
|
+
console.error("[WidgetStoreV2] Error tracking resumable event:", _e);
|
|
31892
31874
|
}
|
|
31893
31875
|
}
|
|
31894
31876
|
} catch (fe) {
|
|
@@ -31897,19 +31879,19 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31897
31879
|
}, [z, $, P, bt]), Pt = useCallback(async () => {
|
|
31898
31880
|
if (!sessionStorage.getItem(CTA_SAME_TAB_REDIRECT_KEY)) return;
|
|
31899
31881
|
sessionStorage.removeItem(CTA_SAME_TAB_REDIRECT_KEY);
|
|
31900
|
-
const
|
|
31901
|
-
!
|
|
31882
|
+
const ke = hasValidSession() ? loadSession() : null;
|
|
31883
|
+
!ke || ke.status !== "paused" || ke.agentId !== n || ke.companyToken !== T || (console.log("[WidgetStoreV2] Same-tab CTA redirect detected - restoring session for resume"), H(ke.sessionId), Q(ke.widgetJwt), we("resumable"), De(!0));
|
|
31902
31884
|
}, [n, T]);
|
|
31903
31885
|
useEffect(() => {
|
|
31904
31886
|
Pt();
|
|
31905
31887
|
}, [Pt]), useEffect(() => {
|
|
31906
31888
|
const fe = () => {
|
|
31907
|
-
const
|
|
31908
|
-
if (
|
|
31889
|
+
const ke = Date.now();
|
|
31890
|
+
if (ke - kt.current < At) {
|
|
31909
31891
|
console.log("[WidgetStoreV2] Visibility change debounced");
|
|
31910
31892
|
return;
|
|
31911
31893
|
}
|
|
31912
|
-
kt.current =
|
|
31894
|
+
kt.current = ke, ot.current && clearTimeout(ot.current), ot.current = setTimeout(() => {
|
|
31913
31895
|
document.visibilityState === "hidden" ? Et() : document.visibilityState === "visible" && xt();
|
|
31914
31896
|
}, 0);
|
|
31915
31897
|
};
|
|
@@ -31920,8 +31902,8 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31920
31902
|
const fe = () => {
|
|
31921
31903
|
if (!(!z || !$) && !sessionStorage.getItem(CTA_SAME_TAB_REDIRECT_KEY))
|
|
31922
31904
|
try {
|
|
31923
|
-
const
|
|
31924
|
-
fetch(
|
|
31905
|
+
const ke = buildApiUrl(`api/widget/session/${z}/end`), Ae = JSON.stringify({ reason: "beforeunload" });
|
|
31906
|
+
fetch(ke, {
|
|
31925
31907
|
method: "POST",
|
|
31926
31908
|
headers: {
|
|
31927
31909
|
Authorization: `Bearer ${$}`,
|
|
@@ -31930,11 +31912,11 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31930
31912
|
},
|
|
31931
31913
|
body: Ae,
|
|
31932
31914
|
keepalive: !0
|
|
31933
|
-
}).catch((
|
|
31934
|
-
console.warn("[WidgetStoreV2] End session keepalive failed:",
|
|
31915
|
+
}).catch((_e) => {
|
|
31916
|
+
console.warn("[WidgetStoreV2] End session keepalive failed:", _e);
|
|
31935
31917
|
});
|
|
31936
|
-
} catch (
|
|
31937
|
-
console.warn("[WidgetStoreV2] Failed to send endSession beacon on unload:",
|
|
31918
|
+
} catch (ke) {
|
|
31919
|
+
console.warn("[WidgetStoreV2] Failed to send endSession beacon on unload:", ke);
|
|
31938
31920
|
}
|
|
31939
31921
|
};
|
|
31940
31922
|
return window.addEventListener("beforeunload", fe), () => window.removeEventListener("beforeunload", fe);
|
|
@@ -31956,49 +31938,49 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
31956
31938
|
if (!z || !$) return;
|
|
31957
31939
|
const fe = getSocket();
|
|
31958
31940
|
if (!fe) return;
|
|
31959
|
-
const
|
|
31960
|
-
console.log("[WidgetStoreV2] Tool call event:",
|
|
31941
|
+
const ke = (Ue) => {
|
|
31942
|
+
console.log("[WidgetStoreV2] Tool call event:", Ue), Fe("calling_tool"), Ne(Ue.tool_name), setTimeout(() => {
|
|
31961
31943
|
Fe("idle"), Ne(void 0);
|
|
31962
31944
|
}, 5e3);
|
|
31963
31945
|
}, Ae = () => {
|
|
31964
31946
|
Fe("speaking"), Ne(void 0);
|
|
31965
|
-
},
|
|
31947
|
+
}, _e = () => {
|
|
31966
31948
|
Fe("idle"), Ne(void 0);
|
|
31967
|
-
},
|
|
31968
|
-
if (console.log("[WidgetStoreV2] Agent message event:",
|
|
31969
|
-
console.log("[WidgetStoreV2] Sending message to ElevenLabs:",
|
|
31949
|
+
}, Be = (Ue) => {
|
|
31950
|
+
if (console.log("[WidgetStoreV2] Agent message event:", Ue), Ue.message && Te.conversation?.sendUserMessage) {
|
|
31951
|
+
console.log("[WidgetStoreV2] Sending message to ElevenLabs:", Ue.message);
|
|
31970
31952
|
try {
|
|
31971
|
-
|
|
31953
|
+
Te.conversation.sendUserMessage(Ue.message);
|
|
31972
31954
|
} catch (je) {
|
|
31973
31955
|
console.error("[WidgetStoreV2] Failed to send message to ElevenLabs:", je);
|
|
31974
31956
|
}
|
|
31975
31957
|
}
|
|
31976
31958
|
};
|
|
31977
|
-
return fe.on("tool_call",
|
|
31978
|
-
fe.off("tool_call",
|
|
31959
|
+
return fe.on("tool_call", ke), fe.on("agent_speaking", Ae), fe.on("agent_idle", _e), fe.on("agent_message", Be), () => {
|
|
31960
|
+
fe.off("tool_call", ke), fe.off("agent_speaking", Ae), fe.off("agent_idle", _e), fe.off("agent_message", Be);
|
|
31979
31961
|
};
|
|
31980
|
-
}, [z, $,
|
|
31981
|
-
|
|
31982
|
-
}, [
|
|
31962
|
+
}, [z, $, Te, se]), useEffect(() => {
|
|
31963
|
+
Te.isAgentSpeaking ? (Fe("speaking"), Ne(void 0)) : Te.isListening && (Fe("idle"), Ne(void 0));
|
|
31964
|
+
}, [Te.isAgentSpeaking, Te.isListening]);
|
|
31983
31965
|
const dt = useRef(!1);
|
|
31984
31966
|
useEffect(() => {
|
|
31985
|
-
|
|
31967
|
+
Te.isConnected && (dt.current = !0), !Te.isConnected && dt.current && console.log("[WidgetStoreV2] 🔍 Disconnection detected, checking conditions:", {
|
|
31986
31968
|
wasConnected: dt.current,
|
|
31987
|
-
isConnected:
|
|
31988
|
-
isConnecting:
|
|
31969
|
+
isConnected: Te.isConnected,
|
|
31970
|
+
isConnecting: Te.isConnecting,
|
|
31989
31971
|
inputMode: ie,
|
|
31990
31972
|
demoStarted: Y,
|
|
31991
31973
|
userEndedCall: ge,
|
|
31992
|
-
hasActiveForm:
|
|
31993
|
-
shouldShowPrompt: dt.current && !
|
|
31994
|
-
}), dt.current && !
|
|
31974
|
+
hasActiveForm: Ve,
|
|
31975
|
+
shouldShowPrompt: dt.current && !Te.isConnected && !Te.isConnecting && ie === "voice" && Y && !ge
|
|
31976
|
+
}), dt.current && !Te.isConnected && !Te.isConnecting && ie === "voice" && Y && !ge && (console.log("[WidgetStoreV2] 🔌 Voice disconnected - showing reconnection prompt"), Ve ? Ge("form_active") : Te.error ? Ge("error") : Ge("timeout"), qe(!0)), Te.isConnected && (qe(!1), nt(!1));
|
|
31995
31977
|
}, [
|
|
31996
|
-
|
|
31997
|
-
|
|
31998
|
-
|
|
31978
|
+
Te.isConnected,
|
|
31979
|
+
Te.isConnecting,
|
|
31980
|
+
Te.error,
|
|
31999
31981
|
ie,
|
|
32000
31982
|
Y,
|
|
32001
|
-
|
|
31983
|
+
Ve,
|
|
32002
31984
|
ge
|
|
32003
31985
|
]);
|
|
32004
31986
|
const Bt = useCallback(async (fe) => {
|
|
@@ -32013,22 +31995,22 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
32013
31995
|
role: "user",
|
|
32014
31996
|
message: fe.trim()
|
|
32015
31997
|
})
|
|
32016
|
-
}).then((
|
|
32017
|
-
|
|
32018
|
-
}).catch((
|
|
31998
|
+
}).then((ke) => {
|
|
31999
|
+
ke.ok || console.error("[WidgetStoreV2] log-message failed:", ke.status, ke.statusText);
|
|
32000
|
+
}).catch((ke) => console.error("[WidgetStoreV2] Failed to log text message (network):", ke)) : console.warn("[WidgetStoreV2] Skipping log-message: missing sessionId or widgetJwt", { sessionId: z, hasJwt: !!$ }), Te.isConnected && Te.conversation))
|
|
32019
32001
|
try {
|
|
32020
|
-
await
|
|
32021
|
-
} catch (
|
|
32022
|
-
console.error("[WidgetStoreV2] Failed to send text via voice session:",
|
|
32002
|
+
await Te.conversation.sendUserMessage(fe);
|
|
32003
|
+
} catch (ke) {
|
|
32004
|
+
console.error("[WidgetStoreV2] Failed to send text via voice session:", ke);
|
|
32023
32005
|
}
|
|
32024
|
-
}, [
|
|
32025
|
-
if (!(!
|
|
32006
|
+
}, [Te.isConnected, Te.conversation, mt, z, $]), Ut = useCallback(() => {
|
|
32007
|
+
if (!(!Te.isConnected || !Te.conversation))
|
|
32026
32008
|
try {
|
|
32027
|
-
|
|
32009
|
+
Te.conversation.sendUserActivity?.();
|
|
32028
32010
|
} catch (fe) {
|
|
32029
32011
|
console.warn("[WidgetStoreV2] sendUserActivity failed:", fe);
|
|
32030
32012
|
}
|
|
32031
|
-
}, [
|
|
32013
|
+
}, [Te.isConnected, Te.conversation]);
|
|
32032
32014
|
return {
|
|
32033
32015
|
// State
|
|
32034
32016
|
isExpanded: L,
|
|
@@ -32060,20 +32042,20 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
32060
32042
|
aiStatus: We,
|
|
32061
32043
|
currentToolName: ze,
|
|
32062
32044
|
// Dynamic UI state
|
|
32063
|
-
hasActiveForm:
|
|
32045
|
+
hasActiveForm: Ve,
|
|
32064
32046
|
setHasActiveForm: Ye,
|
|
32065
32047
|
// Voice reconnection state
|
|
32066
32048
|
showReconnectionPrompt: Xe,
|
|
32067
32049
|
disconnectionReason: Qe,
|
|
32068
32050
|
isReconnecting: et,
|
|
32069
32051
|
// Voice session state
|
|
32070
|
-
isConnected:
|
|
32071
|
-
isConnecting:
|
|
32072
|
-
connectionState:
|
|
32073
|
-
isAgentSpeaking:
|
|
32074
|
-
isListening:
|
|
32075
|
-
audioData:
|
|
32076
|
-
micLevel:
|
|
32052
|
+
isConnected: Te.isConnected,
|
|
32053
|
+
isConnecting: Te.isConnecting,
|
|
32054
|
+
connectionState: Te.connectionState,
|
|
32055
|
+
isAgentSpeaking: Te.isAgentSpeaking,
|
|
32056
|
+
isListening: Te.isListening,
|
|
32057
|
+
audioData: Te.audioData,
|
|
32058
|
+
micLevel: Te.micLevel,
|
|
32077
32059
|
// Actions
|
|
32078
32060
|
expandWidget: Lt,
|
|
32079
32061
|
closeWidget: vt,
|
|
@@ -32091,22 +32073,22 @@ const MAX_RECONNECT_ATTEMPTS = 10, BASE_RECONNECT_DELAY = 1e3, initializeSocket
|
|
|
32091
32073
|
pauseSession: lt,
|
|
32092
32074
|
endSession: Vt,
|
|
32093
32075
|
// Voice session actions
|
|
32094
|
-
startVoiceSession:
|
|
32095
|
-
endVoiceSession:
|
|
32076
|
+
startVoiceSession: Te.startVoiceSession,
|
|
32077
|
+
endVoiceSession: Te.endVoiceSession,
|
|
32096
32078
|
// Text session actions
|
|
32097
32079
|
startTextSession: rt.startTextSession,
|
|
32098
32080
|
endTextSession: rt.endTextSession,
|
|
32099
32081
|
handleTextSubmit: rt.handleTextSubmit,
|
|
32100
32082
|
// Setters
|
|
32101
|
-
setTextInput:
|
|
32083
|
+
setTextInput: be,
|
|
32102
32084
|
setError: ut,
|
|
32103
32085
|
// Clear error
|
|
32104
32086
|
clearError: Rt,
|
|
32105
32087
|
// Media stream reference
|
|
32106
|
-
mediaStreamRef:
|
|
32088
|
+
mediaStreamRef: Te.mediaStreamRef,
|
|
32107
32089
|
// Audio control
|
|
32108
|
-
muteMicrophone:
|
|
32109
|
-
muteAgentAudio:
|
|
32090
|
+
muteMicrophone: Te.muteMicrophone,
|
|
32091
|
+
muteAgentAudio: Te.muteAgentAudio,
|
|
32110
32092
|
// Unified UI helpers
|
|
32111
32093
|
addMessage: mt,
|
|
32112
32094
|
sendTextDuringVoice: Bt,
|
|
@@ -33984,8 +33966,8 @@ const ShowMePanel = ({
|
|
|
33984
33966
|
if (!Oe) return;
|
|
33985
33967
|
const De = (Ne) => {
|
|
33986
33968
|
if (!Ne || Ne.startsWith("http://") || Ne.startsWith("https://")) return Ne;
|
|
33987
|
-
const
|
|
33988
|
-
return Ne.startsWith("/") ? `${
|
|
33969
|
+
const Ve = getCurrentBackendUrl();
|
|
33970
|
+
return Ne.startsWith("/") ? `${Ve}${Ne}` : `${Ve}/${Ne.replace(/^\//, "")}`;
|
|
33989
33971
|
}, We = Oe.storage_url ? De(Oe.storage_url) : void 0, Fe = Oe.external_url ? De(Oe.external_url) : void 0;
|
|
33990
33972
|
let ze = null;
|
|
33991
33973
|
Oe.asset_type === "image" && We ? ze = { type: "image", url: We, alt: Oe.asset_name } : Oe.asset_type === "video" && Fe ? ze = { type: "url", url: Fe, title: Oe.asset_name } : Fe ? ze = { type: "url", url: Fe, title: Oe.asset_name } : We && (ze = { type: "url", url: We, title: Oe.asset_name }), ze && (le(ze), ue(!1));
|
|
@@ -34113,7 +34095,7 @@ const ShowMePanel = ({
|
|
|
34113
34095
|
j.sendTextDuringVoice(Ce);
|
|
34114
34096
|
},
|
|
34115
34097
|
[j.sendTextDuringVoice, j.handleEmailSubmit, j.showEmailFormRequestedByAgent, j.agent?.require_email, j.emailSubmitted, j.sessionHasEmail, j.forceDisplayEmailForm, j.agent?.force_display_email]
|
|
34116
|
-
),
|
|
34098
|
+
), be = useCallback(() => {
|
|
34117
34099
|
const Se = useVoiceStore.getState(), Ce = !Se.isMicMuted;
|
|
34118
34100
|
Se.toggleMic(), j.muteMicrophone(Ce);
|
|
34119
34101
|
}, [j.muteMicrophone]), me = useCallback(() => {
|
|
@@ -34355,7 +34337,7 @@ const ShowMePanel = ({
|
|
|
34355
34337
|
onSend: ve,
|
|
34356
34338
|
isMicMuted: ge,
|
|
34357
34339
|
isAgentMuted: ye,
|
|
34358
|
-
onToggleMic:
|
|
34340
|
+
onToggleMic: be,
|
|
34359
34341
|
onToggleAgentAudio: me,
|
|
34360
34342
|
isConnected: j.isConnected,
|
|
34361
34343
|
onEndCall: j.endCall,
|