@active-reach/web-sdk 1.46.3 → 1.47.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/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-C-Go3Pm5.mjs → analytics-DAZx4Jcj.mjs} +44 -1
- package/dist/analytics-DAZx4Jcj.mjs.map +1 -0
- package/dist/cdn.d.ts.map +1 -1
- package/dist/chat/AegisChat.d.ts +21 -0
- package/dist/chat/AegisChat.d.ts.map +1 -1
- package/dist/chat/index.d.ts +2 -0
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/launcher-spec.d.ts +46 -0
- package/dist/chat/launcher-spec.d.ts.map +1 -0
- package/dist/chat/qr.d.ts +19 -0
- package/dist/chat/qr.d.ts.map +1 -0
- package/dist/chat/whatsapp-launcher.d.ts +45 -0
- package/dist/chat/whatsapp-launcher.d.ts.map +1 -0
- package/dist/ecommerce/index.d.ts.map +1 -1
- package/dist/ecommerce/types.d.ts +6 -0
- package/dist/ecommerce/types.d.ts.map +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +6 -1
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/actions.d.ts +6 -0
- package/dist/inapp/actions.d.ts.map +1 -1
- package/dist/inapp/item-touch.d.ts +26 -0
- package/dist/inapp/item-touch.d.ts.map +1 -0
- package/dist/inapp/renderers/active-web-chat.d.ts.map +1 -1
- package/dist/inapp/renderers/types.d.ts +9 -0
- package/dist/inapp/renderers/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +536 -22
- package/dist/index.js.map +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/dist/analytics-C-Go3Pm5.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Storage, r as redactUrl, l as logger, A as Aegis } from "./analytics-
|
|
2
|
-
import { B, E, N, R, U, m } from "./analytics-
|
|
1
|
+
import { S as Storage, r as redactUrl, a as recordInAppItemTouch, l as logger, A as Aegis } from "./analytics-DAZx4Jcj.mjs";
|
|
2
|
+
import { B, E, N, R, U, m } from "./analytics-DAZx4Jcj.mjs";
|
|
3
3
|
import { a as assetIdOf } from "./AegisWebPush-BE9wJcx0.mjs";
|
|
4
4
|
import { A } from "./AegisWebPush-BE9wJcx0.mjs";
|
|
5
5
|
function debounce(func, wait) {
|
|
@@ -4813,6 +4813,380 @@ function appendNodes(parent, nodes) {
|
|
|
4813
4813
|
function appendWaMarkup(parent, text) {
|
|
4814
4814
|
appendNodes(parent, parseWaMarkup(text));
|
|
4815
4815
|
}
|
|
4816
|
+
const LAUNCHER_SIZE_PX = 56;
|
|
4817
|
+
const LAUNCHER_OFFSET_DESKTOP_PX = 20;
|
|
4818
|
+
const LAUNCHER_OFFSET_MOBILE_PX = 16;
|
|
4819
|
+
const LAUNCHER_BOTTOM_MOBILE_PX = 84;
|
|
4820
|
+
const LAUNCHER_MOBILE_MAX_PX = 767;
|
|
4821
|
+
const LAUNCHER_Z_INDEX = 2147483e3;
|
|
4822
|
+
const LAUNCHER_Z_INDEX_BEHIND = 900;
|
|
4823
|
+
const LAUNCHER_BOTTOM_VAR = "--aegis-launcher-bottom";
|
|
4824
|
+
const LAUNCHER_ATTR = "data-aegis-launcher";
|
|
4825
|
+
function launcherHostMode() {
|
|
4826
|
+
if (typeof document === "undefined") return "on";
|
|
4827
|
+
const v = document.documentElement.getAttribute(LAUNCHER_ATTR);
|
|
4828
|
+
return v === "off" || v === "behind" ? v : "on";
|
|
4829
|
+
}
|
|
4830
|
+
function isLauncherOff() {
|
|
4831
|
+
return launcherHostMode() === "off";
|
|
4832
|
+
}
|
|
4833
|
+
function launcherRootCss(rootClass) {
|
|
4834
|
+
const d = LAUNCHER_OFFSET_DESKTOP_PX;
|
|
4835
|
+
const m2 = LAUNCHER_OFFSET_MOBILE_PX;
|
|
4836
|
+
return `.${rootClass}{position:fixed;bottom:var(${LAUNCHER_BOTTOM_VAR},${d}px);right:${d}px;z-index:${LAUNCHER_Z_INDEX}}.${rootClass}--bottom-left{left:${d}px;right:auto}html[${LAUNCHER_ATTR}="behind"] .${rootClass}{z-index:${LAUNCHER_Z_INDEX_BEHIND}}html[${LAUNCHER_ATTR}="off"] .${rootClass}{display:none!important}@media (max-width:${LAUNCHER_MOBILE_MAX_PX}px){.${rootClass}{bottom:var(${LAUNCHER_BOTTOM_VAR},${LAUNCHER_BOTTOM_MOBILE_PX}px);right:${m2}px}.${rootClass}--bottom-left{left:${m2}px;right:auto}}`;
|
|
4837
|
+
}
|
|
4838
|
+
const ECC_PER_BLOCK_L = [0, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28];
|
|
4839
|
+
const BLOCKS_L = [0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8];
|
|
4840
|
+
const MAX_VERSION = 20;
|
|
4841
|
+
function rawDataModules(ver) {
|
|
4842
|
+
let r = (16 * ver + 128) * ver + 64;
|
|
4843
|
+
if (ver >= 2) {
|
|
4844
|
+
const n = Math.floor(ver / 7) + 2;
|
|
4845
|
+
r -= (25 * n - 10) * n - 55;
|
|
4846
|
+
if (ver >= 7) r -= 36;
|
|
4847
|
+
}
|
|
4848
|
+
return r;
|
|
4849
|
+
}
|
|
4850
|
+
function dataCodewords(ver) {
|
|
4851
|
+
return Math.floor(rawDataModules(ver) / 8) - ECC_PER_BLOCK_L[ver] * BLOCKS_L[ver];
|
|
4852
|
+
}
|
|
4853
|
+
function utf8(text) {
|
|
4854
|
+
return Array.from(new TextEncoder().encode(text));
|
|
4855
|
+
}
|
|
4856
|
+
function gfMul(x, y) {
|
|
4857
|
+
let z = 0;
|
|
4858
|
+
for (let i = 7; i >= 0; i--) {
|
|
4859
|
+
z = z << 1 ^ (z >>> 7) * 285;
|
|
4860
|
+
z ^= (y >>> i & 1) * x;
|
|
4861
|
+
}
|
|
4862
|
+
return z;
|
|
4863
|
+
}
|
|
4864
|
+
function rsDivisor(degree) {
|
|
4865
|
+
const result = new Array(degree).fill(0);
|
|
4866
|
+
result[degree - 1] = 1;
|
|
4867
|
+
let root = 1;
|
|
4868
|
+
for (let i = 0; i < degree; i++) {
|
|
4869
|
+
for (let j = 0; j < degree; j++) {
|
|
4870
|
+
result[j] = gfMul(result[j], root);
|
|
4871
|
+
if (j + 1 < degree) result[j] ^= result[j + 1];
|
|
4872
|
+
}
|
|
4873
|
+
root = gfMul(root, 2);
|
|
4874
|
+
}
|
|
4875
|
+
return result;
|
|
4876
|
+
}
|
|
4877
|
+
function rsRemainder(data, divisor) {
|
|
4878
|
+
const result = new Array(divisor.length).fill(0);
|
|
4879
|
+
for (const b of data) {
|
|
4880
|
+
const factor = b ^ result.shift();
|
|
4881
|
+
result.push(0);
|
|
4882
|
+
divisor.forEach((coef, i) => {
|
|
4883
|
+
result[i] ^= gfMul(coef, factor);
|
|
4884
|
+
});
|
|
4885
|
+
}
|
|
4886
|
+
return result;
|
|
4887
|
+
}
|
|
4888
|
+
function alignmentPositions(ver, size) {
|
|
4889
|
+
if (ver === 1) return [];
|
|
4890
|
+
const n = Math.floor(ver / 7) + 2;
|
|
4891
|
+
const step = Math.ceil((ver * 4 + 4) / (n * 2 - 2)) * 2;
|
|
4892
|
+
const out = [6];
|
|
4893
|
+
for (let pos = size - 7; out.length < n; pos -= step) out.splice(1, 0, pos);
|
|
4894
|
+
return out;
|
|
4895
|
+
}
|
|
4896
|
+
const MASKS = [
|
|
4897
|
+
(x, y) => (x + y) % 2 === 0,
|
|
4898
|
+
(_x, y) => y % 2 === 0,
|
|
4899
|
+
(x) => x % 3 === 0,
|
|
4900
|
+
(x, y) => (x + y) % 3 === 0,
|
|
4901
|
+
(x, y) => (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0,
|
|
4902
|
+
(x, y) => x * y % 2 + x * y % 3 === 0,
|
|
4903
|
+
(x, y) => (x * y % 2 + x * y % 3) % 2 === 0,
|
|
4904
|
+
(x, y) => ((x + y) % 2 + x * y % 3) % 2 === 0
|
|
4905
|
+
];
|
|
4906
|
+
function penalty(m2, size) {
|
|
4907
|
+
let p = 0;
|
|
4908
|
+
const FINDER = [true, false, true, true, true, false, true, false, false, false, false];
|
|
4909
|
+
const matchAt = (get, start, rev) => {
|
|
4910
|
+
for (let k = 0; k < 11; k++) {
|
|
4911
|
+
if (get(start + k) !== FINDER[rev ? 10 - k : k]) return false;
|
|
4912
|
+
}
|
|
4913
|
+
return true;
|
|
4914
|
+
};
|
|
4915
|
+
for (let a = 0; a < size; a++) {
|
|
4916
|
+
for (const horiz of [true, false]) {
|
|
4917
|
+
const get = (i) => horiz ? m2[a][i] : m2[i][a];
|
|
4918
|
+
let run = 1;
|
|
4919
|
+
for (let i = 1; i < size; i++) {
|
|
4920
|
+
if (get(i) === get(i - 1)) {
|
|
4921
|
+
run++;
|
|
4922
|
+
if (run === 5) p += 3;
|
|
4923
|
+
else if (run > 5) p += 1;
|
|
4924
|
+
} else run = 1;
|
|
4925
|
+
}
|
|
4926
|
+
for (let s = 0; s + 11 <= size; s++) {
|
|
4927
|
+
if (matchAt(get, s, false)) p += 40;
|
|
4928
|
+
if (matchAt(get, s, true)) p += 40;
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
}
|
|
4932
|
+
let dark = 0;
|
|
4933
|
+
for (let y = 0; y < size; y++) {
|
|
4934
|
+
for (let x = 0; x < size; x++) {
|
|
4935
|
+
if (m2[y][x]) dark++;
|
|
4936
|
+
if (x + 1 < size && y + 1 < size && m2[y][x] === m2[y][x + 1] && m2[y][x] === m2[y + 1][x] && m2[y][x] === m2[y + 1][x + 1]) p += 3;
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
const total = size * size;
|
|
4940
|
+
p += (Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1) * 10;
|
|
4941
|
+
return p;
|
|
4942
|
+
}
|
|
4943
|
+
function encodeQr(text) {
|
|
4944
|
+
const bytes = utf8(text);
|
|
4945
|
+
let ver = 1;
|
|
4946
|
+
for (; ver <= MAX_VERSION; ver++) {
|
|
4947
|
+
const ccBits = ver < 10 ? 8 : 16;
|
|
4948
|
+
if (4 + ccBits + bytes.length * 8 <= dataCodewords(ver) * 8) break;
|
|
4949
|
+
}
|
|
4950
|
+
if (ver > MAX_VERSION) throw new Error("qr: text too long");
|
|
4951
|
+
const size = ver * 4 + 17;
|
|
4952
|
+
const bits = [];
|
|
4953
|
+
const put = (val, len) => {
|
|
4954
|
+
for (let i = len - 1; i >= 0; i--) bits.push(val >>> i & 1);
|
|
4955
|
+
};
|
|
4956
|
+
put(4, 4);
|
|
4957
|
+
put(bytes.length, ver < 10 ? 8 : 16);
|
|
4958
|
+
bytes.forEach((b) => put(b, 8));
|
|
4959
|
+
const capBits = dataCodewords(ver) * 8;
|
|
4960
|
+
put(0, Math.min(4, capBits - bits.length));
|
|
4961
|
+
put(0, (8 - bits.length % 8) % 8);
|
|
4962
|
+
for (let pad = 236; bits.length < capBits; pad ^= 236 ^ 17) put(pad, 8);
|
|
4963
|
+
const data = [];
|
|
4964
|
+
for (let i = 0; i < bits.length; i += 8) {
|
|
4965
|
+
let v = 0;
|
|
4966
|
+
for (let j = 0; j < 8; j++) v = v << 1 | bits[i + j];
|
|
4967
|
+
data.push(v);
|
|
4968
|
+
}
|
|
4969
|
+
const nBlocks = BLOCKS_L[ver];
|
|
4970
|
+
const eccLen = ECC_PER_BLOCK_L[ver];
|
|
4971
|
+
const raw = Math.floor(rawDataModules(ver) / 8);
|
|
4972
|
+
const nShort = nBlocks - raw % nBlocks;
|
|
4973
|
+
const shortLen = Math.floor(raw / nBlocks);
|
|
4974
|
+
const div = rsDivisor(eccLen);
|
|
4975
|
+
const blocks = [];
|
|
4976
|
+
for (let i = 0, k = 0; i < nBlocks; i++) {
|
|
4977
|
+
const dat = data.slice(k, k + shortLen - eccLen + (i < nShort ? 0 : 1));
|
|
4978
|
+
k += dat.length;
|
|
4979
|
+
const ecc = rsRemainder(dat, div);
|
|
4980
|
+
if (i < nShort) dat.push(0);
|
|
4981
|
+
blocks.push(dat.concat(ecc));
|
|
4982
|
+
}
|
|
4983
|
+
const all = [];
|
|
4984
|
+
for (let i = 0; i < blocks[0].length; i++) {
|
|
4985
|
+
blocks.forEach((blk, j) => {
|
|
4986
|
+
if (i !== shortLen - eccLen || j >= nShort) all.push(blk[i]);
|
|
4987
|
+
});
|
|
4988
|
+
}
|
|
4989
|
+
const m2 = Array.from({ length: size }, () => new Array(size).fill(false));
|
|
4990
|
+
const fn = Array.from({ length: size }, () => new Array(size).fill(false));
|
|
4991
|
+
const set = (x, y, dark) => {
|
|
4992
|
+
m2[y][x] = dark;
|
|
4993
|
+
fn[y][x] = true;
|
|
4994
|
+
};
|
|
4995
|
+
for (let i = 0; i < size; i++) {
|
|
4996
|
+
set(6, i, i % 2 === 0);
|
|
4997
|
+
set(i, 6, i % 2 === 0);
|
|
4998
|
+
}
|
|
4999
|
+
for (const [cx, cy] of [[3, 3], [size - 4, 3], [3, size - 4]]) {
|
|
5000
|
+
for (let dy = -4; dy <= 4; dy++) {
|
|
5001
|
+
for (let dx = -4; dx <= 4; dx++) {
|
|
5002
|
+
const x = cx + dx;
|
|
5003
|
+
const y = cy + dy;
|
|
5004
|
+
if (x < 0 || y < 0 || x >= size || y >= size) continue;
|
|
5005
|
+
const d = Math.max(Math.abs(dx), Math.abs(dy));
|
|
5006
|
+
set(x, y, d !== 2 && d !== 4);
|
|
5007
|
+
}
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
const al = alignmentPositions(ver, size);
|
|
5011
|
+
al.forEach((ax, i) => {
|
|
5012
|
+
al.forEach((ay, j) => {
|
|
5013
|
+
if (i === 0 && j === 0 || i === 0 && j === al.length - 1 || i === al.length - 1 && j === 0) return;
|
|
5014
|
+
for (let dy = -2; dy <= 2; dy++) {
|
|
5015
|
+
for (let dx = -2; dx <= 2; dx++) set(ax + dx, ay + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
|
|
5016
|
+
}
|
|
5017
|
+
});
|
|
5018
|
+
});
|
|
5019
|
+
const drawFormat = (mask) => {
|
|
5020
|
+
const d = 1 << 3 | mask;
|
|
5021
|
+
let rem = d;
|
|
5022
|
+
for (let i = 0; i < 10; i++) rem = rem << 1 ^ (rem >>> 9) * 1335;
|
|
5023
|
+
const f = (d << 10 | rem) ^ 21522;
|
|
5024
|
+
const bit = (i) => (f >>> i & 1) !== 0;
|
|
5025
|
+
for (let i = 0; i <= 5; i++) set(8, i, bit(i));
|
|
5026
|
+
set(8, 7, bit(6));
|
|
5027
|
+
set(8, 8, bit(7));
|
|
5028
|
+
set(7, 8, bit(8));
|
|
5029
|
+
for (let i = 9; i < 15; i++) set(14 - i, 8, bit(i));
|
|
5030
|
+
for (let i = 0; i < 8; i++) set(size - 1 - i, 8, bit(i));
|
|
5031
|
+
for (let i = 8; i < 15; i++) set(8, size - 15 + i, bit(i));
|
|
5032
|
+
set(8, size - 8, true);
|
|
5033
|
+
};
|
|
5034
|
+
drawFormat(0);
|
|
5035
|
+
if (ver >= 7) {
|
|
5036
|
+
let rem = ver;
|
|
5037
|
+
for (let i = 0; i < 12; i++) rem = rem << 1 ^ (rem >>> 11) * 7973;
|
|
5038
|
+
const v = ver << 12 | rem;
|
|
5039
|
+
for (let i = 0; i < 18; i++) {
|
|
5040
|
+
const dark = (v >>> i & 1) !== 0;
|
|
5041
|
+
const a = size - 11 + i % 3;
|
|
5042
|
+
const b = Math.floor(i / 3);
|
|
5043
|
+
set(a, b, dark);
|
|
5044
|
+
set(b, a, dark);
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
let idx = 0;
|
|
5048
|
+
for (let right = size - 1; right >= 1; right -= 2) {
|
|
5049
|
+
if (right === 6) right = 5;
|
|
5050
|
+
for (let vert = 0; vert < size; vert++) {
|
|
5051
|
+
for (let j = 0; j < 2; j++) {
|
|
5052
|
+
const x = right - j;
|
|
5053
|
+
const upward = (right + 1 & 2) === 0;
|
|
5054
|
+
const y = upward ? size - 1 - vert : vert;
|
|
5055
|
+
if (!fn[y][x] && idx < all.length * 8) {
|
|
5056
|
+
m2[y][x] = (all[idx >>> 3] >>> 7 - (idx & 7) & 1) !== 0;
|
|
5057
|
+
idx++;
|
|
5058
|
+
}
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
const applyMask = (mask) => {
|
|
5063
|
+
for (let y = 0; y < size; y++) {
|
|
5064
|
+
for (let x = 0; x < size; x++) if (!fn[y][x] && MASKS[mask](x, y)) m2[y][x] = !m2[y][x];
|
|
5065
|
+
}
|
|
5066
|
+
};
|
|
5067
|
+
let best = 0;
|
|
5068
|
+
let bestPen = Infinity;
|
|
5069
|
+
for (let mask = 0; mask < 8; mask++) {
|
|
5070
|
+
applyMask(mask);
|
|
5071
|
+
drawFormat(mask);
|
|
5072
|
+
const p = penalty(m2, size);
|
|
5073
|
+
if (p < bestPen) {
|
|
5074
|
+
bestPen = p;
|
|
5075
|
+
best = mask;
|
|
5076
|
+
}
|
|
5077
|
+
applyMask(mask);
|
|
5078
|
+
}
|
|
5079
|
+
applyMask(best);
|
|
5080
|
+
drawFormat(best);
|
|
5081
|
+
return { size, version: ver, modules: m2 };
|
|
5082
|
+
}
|
|
5083
|
+
function qrToSvg(qr, px = 168) {
|
|
5084
|
+
const q = 4;
|
|
5085
|
+
const dim = qr.size + q * 2;
|
|
5086
|
+
let d = "";
|
|
5087
|
+
for (let y = 0; y < qr.size; y++) {
|
|
5088
|
+
for (let x = 0; x < qr.size; x++) {
|
|
5089
|
+
if (qr.modules[y][x]) d += `M${x + q},${y + q}h1v1h-1z`;
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${px}" height="${px}" viewBox="0 0 ${dim} ${dim}" shape-rendering="crispEdges" role="img" aria-label="QR code"><rect width="${dim}" height="${dim}" fill="#fff"/><path d="${d}" fill="#000"/></svg>`;
|
|
5093
|
+
}
|
|
5094
|
+
const MAX_PRODUCT_NAME_CHARS = 80;
|
|
5095
|
+
const REF_VALUE_RE = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
5096
|
+
let chatContext = {};
|
|
5097
|
+
function setChatContext(ctx) {
|
|
5098
|
+
chatContext = ctx ? { ...chatContext, ...ctx } : {};
|
|
5099
|
+
}
|
|
5100
|
+
function getChatContext() {
|
|
5101
|
+
return chatContext;
|
|
5102
|
+
}
|
|
5103
|
+
function parseChatWhatsapp(raw) {
|
|
5104
|
+
if (!raw || typeof raw !== "object") return null;
|
|
5105
|
+
const r = raw;
|
|
5106
|
+
if (typeof r.default !== "string" || !digitsOf(r.default)) return null;
|
|
5107
|
+
const by = {};
|
|
5108
|
+
if (r.by_location && typeof r.by_location === "object") {
|
|
5109
|
+
for (const [k, v] of Object.entries(r.by_location)) {
|
|
5110
|
+
if (typeof v === "string" && digitsOf(v)) by[k] = v;
|
|
5111
|
+
}
|
|
5112
|
+
}
|
|
5113
|
+
return { default: r.default, by_location: by };
|
|
5114
|
+
}
|
|
5115
|
+
function pickWhatsappNumber(p, locationId) {
|
|
5116
|
+
var _a;
|
|
5117
|
+
return (locationId ? (_a = p.by_location) == null ? void 0 : _a[locationId] : void 0) ?? p.default;
|
|
5118
|
+
}
|
|
5119
|
+
function digitsOf(num2) {
|
|
5120
|
+
return num2.replace(/\D/g, "");
|
|
5121
|
+
}
|
|
5122
|
+
function buildPrefill(ctx = chatContext) {
|
|
5123
|
+
const name = (ctx.productName ?? "").trim().slice(0, MAX_PRODUCT_NAME_CHARS);
|
|
5124
|
+
let text = name ? `Hi! I have a question about ${name}` : "Hi! I have a question";
|
|
5125
|
+
if (ctx.sku && REF_VALUE_RE.test(ctx.sku)) text += `
|
|
5126
|
+
(ref p.${ctx.sku})`;
|
|
5127
|
+
else if (ctx.storeSlug && REF_VALUE_RE.test(ctx.storeSlug)) text += `
|
|
5128
|
+
(ref s.${ctx.storeSlug})`;
|
|
5129
|
+
return text;
|
|
5130
|
+
}
|
|
5131
|
+
function buildWaLink(number, text) {
|
|
5132
|
+
return `https://wa.me/${digitsOf(number)}?text=${encodeURIComponent(text)}`;
|
|
5133
|
+
}
|
|
5134
|
+
function isPhoneLike() {
|
|
5135
|
+
var _a, _b;
|
|
5136
|
+
if (typeof window === "undefined") return false;
|
|
5137
|
+
const touch = typeof navigator !== "undefined" && (navigator.maxTouchPoints ?? 0) > 0;
|
|
5138
|
+
const narrow = ((_b = (_a = window.matchMedia) == null ? void 0 : _a.call(window, `(max-width: ${LAUNCHER_MOBILE_MAX_PX}px)`)) == null ? void 0 : _b.matches) === true;
|
|
5139
|
+
return touch || narrow;
|
|
5140
|
+
}
|
|
5141
|
+
const WHATSAPP_GLYPH_SVG = '<svg width="30" height="30" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17.47 14.38c-.3-.15-1.76-.87-2.03-.97-.27-.1-.47-.15-.67.15-.2.3-.77.97-.94 1.17-.17.2-.35.22-.64.07-.3-.15-1.26-.46-2.4-1.48-.88-.79-1.48-1.76-1.66-2.06-.17-.3-.02-.46.13-.6.13-.13.3-.35.45-.52.15-.17.2-.3.3-.5.1-.2.05-.37-.03-.52-.07-.15-.67-1.62-.92-2.22-.24-.58-.49-.5-.67-.51h-.57c-.2 0-.52.07-.8.37-.27.3-1.04 1.02-1.04 2.48 0 1.46 1.07 2.88 1.21 3.07.15.2 2.1 3.2 5.08 4.49.71.31 1.26.49 1.7.63.71.23 1.36.2 1.87.12.57-.09 1.76-.72 2.01-1.41.25-.7.25-1.29.17-1.41-.07-.12-.27-.2-.57-.35z"/><path d="M12.04 2C6.58 2 2.13 6.45 2.13 11.91c0 1.75.46 3.45 1.32 4.95L2.05 22l5.25-1.38a9.9 9.9 0 0 0 4.74 1.21c5.46 0 9.91-4.45 9.91-9.91C21.95 6.45 17.5 2 12.04 2zm0 18.15c-1.48 0-2.93-.4-4.2-1.15l-.3-.18-3.12.82.83-3.04-.2-.31a8.2 8.2 0 0 1-1.26-4.38c0-4.54 3.7-8.24 8.25-8.24 4.54 0 8.24 3.7 8.24 8.24 0 4.54-3.7 8.24-8.24 8.24z" fill-rule="evenodd"/></svg>';
|
|
5142
|
+
function buildWhatsappCard(link, onClose) {
|
|
5143
|
+
const card = document.createElement("div");
|
|
5144
|
+
card.className = "aegis-wa-card";
|
|
5145
|
+
card.setAttribute("role", "dialog");
|
|
5146
|
+
card.setAttribute("aria-label", "Chat on WhatsApp");
|
|
5147
|
+
card.tabIndex = -1;
|
|
5148
|
+
const close = document.createElement("button");
|
|
5149
|
+
close.type = "button";
|
|
5150
|
+
close.className = "aegis-wa-card-close";
|
|
5151
|
+
close.setAttribute("aria-label", "Close");
|
|
5152
|
+
close.innerHTML = lucideSvg("x", { size: 16 });
|
|
5153
|
+
close.addEventListener("click", onClose);
|
|
5154
|
+
const title = document.createElement("div");
|
|
5155
|
+
title.className = "aegis-wa-card-title";
|
|
5156
|
+
title.textContent = "Chat with us on WhatsApp";
|
|
5157
|
+
const qr = document.createElement("div");
|
|
5158
|
+
qr.className = "aegis-wa-card-qr";
|
|
5159
|
+
try {
|
|
5160
|
+
qr.innerHTML = qrToSvg(encodeQr(link));
|
|
5161
|
+
} catch {
|
|
5162
|
+
qr.style.display = "none";
|
|
5163
|
+
}
|
|
5164
|
+
const hint = document.createElement("div");
|
|
5165
|
+
hint.className = "aegis-wa-card-hint";
|
|
5166
|
+
hint.textContent = "Scan with your phone camera";
|
|
5167
|
+
const a = document.createElement("a");
|
|
5168
|
+
a.className = "aegis-wa-card-link";
|
|
5169
|
+
a.href = link;
|
|
5170
|
+
a.target = "_blank";
|
|
5171
|
+
a.rel = "noopener noreferrer";
|
|
5172
|
+
a.textContent = "Open WhatsApp on this computer";
|
|
5173
|
+
card.append(close, title, qr, hint, a);
|
|
5174
|
+
return card;
|
|
5175
|
+
}
|
|
5176
|
+
function whatsappCss(sizePx, offsetPx) {
|
|
5177
|
+
return `
|
|
5178
|
+
.aegis-wa-bubble{width:${sizePx}px;height:${sizePx}px;border-radius:9999px;border:none;background:#25d366;color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 8px 24px rgba(0,0,0,.18);transition:transform .18s ease,box-shadow .18s ease;position:relative}
|
|
5179
|
+
.aegis-wa-bubble:hover{transform:translateY(-2px) scale(1.04);box-shadow:0 12px 28px rgba(0,0,0,.22)}
|
|
5180
|
+
.aegis-wa-card{position:absolute;bottom:${sizePx + 12}px;right:0;width:248px;max-width:calc(100vw - ${2 * offsetPx}px);box-sizing:border-box;background:#fff;color:#0f172a;border:1px solid #e2e8f0;border-radius:16px;box-shadow:0 16px 48px rgba(0,0,0,.24);padding:16px;display:none;flex-direction:column;align-items:center;gap:8px;font-size:14px}
|
|
5181
|
+
.aegis-wa-card--open{display:flex}
|
|
5182
|
+
.aegis-chat-root--bottom-left .aegis-wa-card{left:0;right:auto}
|
|
5183
|
+
.aegis-wa-card-close{position:absolute;top:4px;right:4px;width:32px;height:32px;padding:4px;box-sizing:border-box;border:none;background:transparent;color:#64748b;cursor:pointer;border-radius:9999px;display:flex;align-items:center;justify-content:center}
|
|
5184
|
+
.aegis-wa-card-title{font-weight:600;padding:0 20px}
|
|
5185
|
+
.aegis-wa-card-qr{line-height:0;border:1px solid #e2e8f0;border-radius:8px;overflow:hidden}
|
|
5186
|
+
.aegis-wa-card-hint{font-size:12px;color:#64748b}
|
|
5187
|
+
.aegis-wa-card-link{display:block;text-align:center;background:#25d366;color:#fff;text-decoration:none;font-weight:600;border-radius:9999px;padding:8px 14px;font-size:13px}
|
|
5188
|
+
`;
|
|
5189
|
+
}
|
|
4816
5190
|
const WORKSPACE_MISMATCH_CODE = "chat_workspace_mismatch";
|
|
4817
5191
|
const REMINT_WINDOW_MS = 3e4;
|
|
4818
5192
|
const AUTH_STOPPED_TEXT = "Sorry, chat is unavailable right now. Please try again in a moment.";
|
|
@@ -4896,6 +5270,9 @@ class AegisChat {
|
|
|
4896
5270
|
this.logoUrl = config.logoUrl;
|
|
4897
5271
|
this.position = config.position ?? "bottom-right";
|
|
4898
5272
|
this.displayMode = config.displayMode ?? "bubble";
|
|
5273
|
+
this.whatsapp = config.whatsapp;
|
|
5274
|
+
this.getLocationId = config.getLocationId;
|
|
5275
|
+
this.onLauncherOpened = config.onLauncherOpened;
|
|
4899
5276
|
this.agentPersona = config.agentPersona;
|
|
4900
5277
|
this.quickReplies = config.quickReplies;
|
|
4901
5278
|
this.onSessionStart = config.onSessionStart;
|
|
@@ -4909,6 +5286,15 @@ class AegisChat {
|
|
|
4909
5286
|
if (this.initialized || typeof document === "undefined") return;
|
|
4910
5287
|
this.initialized = true;
|
|
4911
5288
|
this.injectStyles();
|
|
5289
|
+
if (isLauncherOff()) {
|
|
5290
|
+
this.initialized = false;
|
|
5291
|
+
return;
|
|
5292
|
+
}
|
|
5293
|
+
if (this.whatsapp) {
|
|
5294
|
+
this.mountWhatsapp();
|
|
5295
|
+
currentLauncher = this;
|
|
5296
|
+
return;
|
|
5297
|
+
}
|
|
4912
5298
|
this.mount();
|
|
4913
5299
|
currentLauncher = this;
|
|
4914
5300
|
if (this.displayMode !== "nav") this.scheduleAttention();
|
|
@@ -4920,29 +5306,42 @@ class AegisChat {
|
|
|
4920
5306
|
}
|
|
4921
5307
|
/** Programmatic open (used by the proactive TriggerEngine wiring). */
|
|
4922
5308
|
openPanel(prefill) {
|
|
4923
|
-
var _a, _b, _c, _d;
|
|
5309
|
+
var _a, _b, _c, _d, _e;
|
|
5310
|
+
if (this.whatsapp) {
|
|
5311
|
+
this.openWhatsapp();
|
|
5312
|
+
return;
|
|
5313
|
+
}
|
|
4924
5314
|
if (!this.panel) this.initialize();
|
|
5315
|
+
if (!this.panel) return;
|
|
4925
5316
|
if (this.open) return;
|
|
5317
|
+
try {
|
|
5318
|
+
(_a = this.onLauncherOpened) == null ? void 0 : _a.call(this, "web_chat");
|
|
5319
|
+
} catch {
|
|
5320
|
+
}
|
|
4926
5321
|
this.open = true;
|
|
4927
5322
|
this.hasInteracted = true;
|
|
4928
5323
|
this.streamRefused = false;
|
|
4929
5324
|
try {
|
|
4930
|
-
(
|
|
5325
|
+
(_b = this.onSessionStart) == null ? void 0 : _b.call(this);
|
|
4931
5326
|
} catch {
|
|
4932
5327
|
}
|
|
4933
5328
|
this.dismissAttention();
|
|
4934
|
-
(
|
|
4935
|
-
(
|
|
5329
|
+
(_c = this.panel) == null ? void 0 : _c.classList.add("aegis-chat-panel--open");
|
|
5330
|
+
(_d = this.bubble) == null ? void 0 : _d.classList.add("aegis-chat-bubble--hidden");
|
|
4936
5331
|
this.bindViewport();
|
|
4937
5332
|
this.revealLatest();
|
|
4938
5333
|
this.clearUnread();
|
|
4939
5334
|
if (prefill && this.input) this.input.value = prefill;
|
|
4940
5335
|
void this.resumeSession();
|
|
4941
5336
|
this.startPolling();
|
|
4942
|
-
(
|
|
5337
|
+
(_e = this.input) == null ? void 0 : _e.focus();
|
|
4943
5338
|
}
|
|
4944
5339
|
closePanel() {
|
|
4945
5340
|
var _a, _b, _c;
|
|
5341
|
+
if (this.whatsapp) {
|
|
5342
|
+
this.closeWhatsappCard();
|
|
5343
|
+
return;
|
|
5344
|
+
}
|
|
4946
5345
|
const wasOpen = this.open;
|
|
4947
5346
|
this.open = false;
|
|
4948
5347
|
(_a = this.panel) == null ? void 0 : _a.classList.remove("aegis-chat-panel--open");
|
|
@@ -4958,11 +5357,13 @@ class AegisChat {
|
|
|
4958
5357
|
}
|
|
4959
5358
|
}
|
|
4960
5359
|
destroy() {
|
|
4961
|
-
var _a;
|
|
5360
|
+
var _a, _b;
|
|
4962
5361
|
this.unbindViewport();
|
|
4963
5362
|
this.disconnectSSE();
|
|
4964
5363
|
this.stopPolling();
|
|
4965
|
-
(_a = this.
|
|
5364
|
+
(_a = this.waDismiss) == null ? void 0 : _a.call(this);
|
|
5365
|
+
this.waDismiss = void 0;
|
|
5366
|
+
(_b = this.root) == null ? void 0 : _b.remove();
|
|
4966
5367
|
this.initialized = false;
|
|
4967
5368
|
if (currentLauncher === this) currentLauncher = null;
|
|
4968
5369
|
}
|
|
@@ -5200,6 +5601,73 @@ class AegisChat {
|
|
|
5200
5601
|
}
|
|
5201
5602
|
return SPARKLE;
|
|
5202
5603
|
}
|
|
5604
|
+
/** WhatsApp mode: a green WhatsApp button. Phone → wa.me; desktop → QR card. */
|
|
5605
|
+
mountWhatsapp() {
|
|
5606
|
+
const root = document.createElement("div");
|
|
5607
|
+
root.className = `aegis-chat-root aegis-chat-root--${this.position}`;
|
|
5608
|
+
const bubble = document.createElement("button");
|
|
5609
|
+
bubble.type = "button";
|
|
5610
|
+
bubble.className = "aegis-wa-bubble";
|
|
5611
|
+
bubble.setAttribute("aria-label", "Chat on WhatsApp");
|
|
5612
|
+
bubble.innerHTML = WHATSAPP_GLYPH_SVG;
|
|
5613
|
+
bubble.addEventListener("click", () => this.openWhatsapp());
|
|
5614
|
+
root.appendChild(bubble);
|
|
5615
|
+
document.body.appendChild(root);
|
|
5616
|
+
this.root = root;
|
|
5617
|
+
this.bubble = bubble;
|
|
5618
|
+
}
|
|
5619
|
+
/** The number for the outlet being viewed → open WhatsApp (phone) or the QR card (desktop). */
|
|
5620
|
+
openWhatsapp() {
|
|
5621
|
+
var _a, _b;
|
|
5622
|
+
if (!this.whatsapp) return;
|
|
5623
|
+
if (!this.root) this.initialize();
|
|
5624
|
+
if (!this.root) return;
|
|
5625
|
+
if (this.waCard) {
|
|
5626
|
+
this.closeWhatsappCard();
|
|
5627
|
+
return;
|
|
5628
|
+
}
|
|
5629
|
+
const number = pickWhatsappNumber(this.whatsapp, ((_a = this.getLocationId) == null ? void 0 : _a.call(this)) ?? null);
|
|
5630
|
+
const link = buildWaLink(number, buildPrefill());
|
|
5631
|
+
try {
|
|
5632
|
+
(_b = this.onLauncherOpened) == null ? void 0 : _b.call(this, "whatsapp");
|
|
5633
|
+
} catch {
|
|
5634
|
+
}
|
|
5635
|
+
if (isPhoneLike()) {
|
|
5636
|
+
window.open(link, "_blank", "noopener");
|
|
5637
|
+
return;
|
|
5638
|
+
}
|
|
5639
|
+
this.closeWhatsappCard(false);
|
|
5640
|
+
const card = buildWhatsappCard(link, () => this.closePanel());
|
|
5641
|
+
card.classList.add("aegis-wa-card--open");
|
|
5642
|
+
this.root.appendChild(card);
|
|
5643
|
+
this.waCard = card;
|
|
5644
|
+
const onKey = (e) => {
|
|
5645
|
+
if (e.key === "Escape") this.closeWhatsappCard();
|
|
5646
|
+
};
|
|
5647
|
+
const onOutside = (e) => {
|
|
5648
|
+
var _a2;
|
|
5649
|
+
const t = e.target;
|
|
5650
|
+
if (t && (card.contains(t) || ((_a2 = this.bubble) == null ? void 0 : _a2.contains(t)))) return;
|
|
5651
|
+
this.closeWhatsappCard();
|
|
5652
|
+
};
|
|
5653
|
+
document.addEventListener("keydown", onKey);
|
|
5654
|
+
document.addEventListener("pointerdown", onOutside, true);
|
|
5655
|
+
this.waDismiss = () => {
|
|
5656
|
+
document.removeEventListener("keydown", onKey);
|
|
5657
|
+
document.removeEventListener("pointerdown", onOutside, true);
|
|
5658
|
+
};
|
|
5659
|
+
card.focus();
|
|
5660
|
+
}
|
|
5661
|
+
closeWhatsappCard(restoreFocus = true) {
|
|
5662
|
+
var _a, _b;
|
|
5663
|
+
(_a = this.waDismiss) == null ? void 0 : _a.call(this);
|
|
5664
|
+
this.waDismiss = void 0;
|
|
5665
|
+
const card = this.waCard;
|
|
5666
|
+
this.waCard = void 0;
|
|
5667
|
+
if (!card) return;
|
|
5668
|
+
card.remove();
|
|
5669
|
+
if (restoreFocus) (_b = this.bubble) == null ? void 0 : _b.focus();
|
|
5670
|
+
}
|
|
5203
5671
|
mount() {
|
|
5204
5672
|
const root = document.createElement("div");
|
|
5205
5673
|
root.className = `aegis-chat-root aegis-chat-root--${this.position}`;
|
|
@@ -5843,13 +6311,14 @@ class AegisChat {
|
|
|
5843
6311
|
}
|
|
5844
6312
|
}
|
|
5845
6313
|
const CHAT_CSS = `
|
|
5846
|
-
|
|
5847
|
-
.aegis-chat-root
|
|
6314
|
+
${launcherRootCss("aegis-chat-root")}
|
|
6315
|
+
.aegis-chat-root{${fontFamilyCss("body")}}
|
|
6316
|
+
${whatsappCss(LAUNCHER_SIZE_PX, LAUNCHER_OFFSET_MOBILE_PX)}
|
|
5848
6317
|
.aegis-chat-root--bottom-left .aegis-chat-panel{left:0;right:auto}
|
|
5849
6318
|
.aegis-chat-bubble-logo{width:34px;height:34px;border-radius:9999px;object-fit:cover}
|
|
5850
|
-
.aegis-chat-bubble{width
|
|
6319
|
+
.aegis-chat-bubble{width:${LAUNCHER_SIZE_PX}px;height:${LAUNCHER_SIZE_PX}px;border-radius:9999px;border:none;background:var(--aegis-chat-accent,#4169e1);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 8px 24px rgba(0,0,0,.18);transition:transform .18s ease,box-shadow .18s ease;position:relative;animation:aegis-chat-in .4s cubic-bezier(.16,1,.3,1)}
|
|
5851
6320
|
.aegis-chat-bubble:hover{transform:translateY(-2px) scale(1.04);box-shadow:0 12px 28px rgba(0,0,0,.22)}
|
|
5852
|
-
.aegis-chat-bubble--hidden{display:none}
|
|
6321
|
+
.aegis-chat-bubble--hidden,.aegis-wa-bubble.aegis-chat-bubble--hidden{display:none}
|
|
5853
6322
|
/* Attention pulse — an expanding accent ring that draws the eye to a live, ready assistant. */
|
|
5854
6323
|
.aegis-chat-bubble--pulse::before{content:"";position:absolute;inset:0;border-radius:9999px;background:var(--aegis-chat-accent,#4169e1);z-index:-1;animation:aegis-chat-pulse 1.8s ease-out infinite}
|
|
5855
6324
|
.aegis-chat-bubble--pulse{animation:aegis-chat-in .4s cubic-bezier(.16,1,.3,1),aegis-chat-nudge 1.8s ease-in-out 2}
|
|
@@ -5857,7 +6326,7 @@ const CHAT_CSS = `
|
|
|
5857
6326
|
@keyframes aegis-chat-pulse{0%{transform:scale(1);opacity:.55}100%{transform:scale(1.9);opacity:0}}
|
|
5858
6327
|
@keyframes aegis-chat-nudge{0%,100%{transform:translateY(0)}25%{transform:translateY(-5px)}50%{transform:translateY(0)}}
|
|
5859
6328
|
/* One-time greeting tooltip */
|
|
5860
|
-
.aegis-chat-tip{position:absolute;bottom:
|
|
6329
|
+
.aegis-chat-tip{position:absolute;bottom:12px;right:${LAUNCHER_SIZE_PX + 14}px;max-width:230px;background:#fff;color:#0f172a;border:1px solid #e2e8f0;border-radius:14px;border-bottom-right-radius:4px;box-shadow:0 10px 30px rgba(0,0,0,.16);padding:10px 30px 10px 13px;font-size:13.5px;line-height:1.4;cursor:pointer;opacity:0;transform:translateX(8px) scale(.92);transform-origin:bottom right;pointer-events:none;transition:opacity .25s ease,transform .25s ease}
|
|
5861
6330
|
.aegis-chat-tip--show{opacity:1;transform:translateX(0) scale(1);pointer-events:auto}
|
|
5862
6331
|
.aegis-chat-tip-close{position:absolute;top:5px;right:6px;width:18px;height:18px;border:none;background:transparent;color:#94a3b8;font-size:12px;line-height:1;cursor:pointer;border-radius:9999px}
|
|
5863
6332
|
.aegis-chat-tip-close:hover{background:#f1f5f9;color:#475569}
|
|
@@ -5916,10 +6385,9 @@ const CHAT_CSS = `
|
|
|
5916
6385
|
.aegis-chat-media-img{max-width:200px;max-height:200px;border-radius:12px;object-fit:cover;cursor:pointer;display:block}
|
|
5917
6386
|
.aegis-chat-media-file{display:inline-flex;align-items:center;gap:6px;padding:8px 12px;border-radius:12px;background:#fff;border:1px solid #e2e8f0;font-size:13px;color:#0f172a;text-decoration:none;max-width:220px}
|
|
5918
6387
|
.aegis-chat-msg--customer .aegis-chat-media-file{background:rgba(255,255,255,.18);border-color:transparent;color:#fff}
|
|
5919
|
-
/* Mobile:
|
|
5920
|
-
|
|
6388
|
+
/* Mobile: dock position comes from launcher-spec (hosts raise it with
|
|
6389
|
+
--aegis-launcher-bottom); widen the panel and reduce the tooltip width. */
|
|
5921
6390
|
@media (max-width:767px){
|
|
5922
|
-
.aegis-chat-root{bottom:84px;right:16px}
|
|
5923
6391
|
/* Full-page chat on mobile — the open panel covers the whole viewport (incl.
|
|
5924
6392
|
the bottom nav) like a native chat screen, instead of a floating card. */
|
|
5925
6393
|
.aegis-chat-panel{position:fixed;inset:0;left:0;right:0;width:100vw;height:100vh;height:100dvh;max-width:none;max-height:none;border-radius:0}
|
|
@@ -6509,6 +6977,7 @@ function renderActiveWebChat(ctx, creds) {
|
|
|
6509
6977
|
const accent = str(ic.chat_accent_color);
|
|
6510
6978
|
const logo = str(ic.chat_logo_url);
|
|
6511
6979
|
const icon = str(ic.chat_icon);
|
|
6980
|
+
const whatsapp = parseChatWhatsapp(ic.chat_whatsapp);
|
|
6512
6981
|
const cfg = {
|
|
6513
6982
|
writeKey: creds.writeKey,
|
|
6514
6983
|
apiHost: creds.apiHost,
|
|
@@ -6519,7 +6988,19 @@ function renderActiveWebChat(ctx, creds) {
|
|
|
6519
6988
|
title: str(ic.chat_title),
|
|
6520
6989
|
greeting: str(ic.chat_greeting),
|
|
6521
6990
|
accentColor: accent ? ctx.sanitizeColor(accent) : void 0,
|
|
6522
|
-
icon: icon === "sparkle" || icon === "chat" || icon === "logo" ? icon : void 0,
|
|
6991
|
+
icon: icon === "sparkle" || icon === "chat" || icon === "logo" ? icon : icon === "whatsapp" ? "chat" : void 0,
|
|
6992
|
+
whatsapp: whatsapp ?? void 0,
|
|
6993
|
+
getLocationId: ctx.getLocationId,
|
|
6994
|
+
// `chat.launcher_opened` — source = the surface the host declared, mode =
|
|
6995
|
+
// whatsapp | web_chat. Declared in CHANNEL_CANONICAL_EVENT_MAP server side.
|
|
6996
|
+
onLauncherOpened: (mode) => {
|
|
6997
|
+
var _a, _b;
|
|
6998
|
+
const source = ((_a = ctx.getSurface) == null ? void 0 : _a.call(ctx)) ?? void 0;
|
|
6999
|
+
(_b = ctx.track) == null ? void 0 : _b.call(ctx, "chat.launcher_opened", { source, mode, campaign_id: ctx.campaign.id });
|
|
7000
|
+
if (mode === "whatsapp") {
|
|
7001
|
+
ctx.trackEvent(ctx.campaign.id, "clicked", { meta: { action: "launcher_opened", mode } });
|
|
7002
|
+
}
|
|
7003
|
+
},
|
|
6523
7004
|
logoUrl: logo ? ctx.sanitizeUrl(logo) ?? void 0 : void 0,
|
|
6524
7005
|
position: ic.chat_position === "bottom-left" ? "bottom-left" : void 0,
|
|
6525
7006
|
surfaceStyle: ic.chat_theme === "tinted" ? "tinted" : void 0,
|
|
@@ -6540,8 +7021,8 @@ function renderActiveWebChat(ctx, creds) {
|
|
|
6540
7021
|
chat.initialize();
|
|
6541
7022
|
activeInstance = chat;
|
|
6542
7023
|
const proactive = ic.chat_proactive || {};
|
|
6543
|
-
const wantExit = proactive.exit_intent === true;
|
|
6544
|
-
const wantIdle = proactive.cart_idle === true;
|
|
7024
|
+
const wantExit = !whatsapp && proactive.exit_intent === true;
|
|
7025
|
+
const wantIdle = !whatsapp && proactive.cart_idle === true;
|
|
6545
7026
|
if (wantExit || wantIdle) {
|
|
6546
7027
|
const engine = new TriggerEngine();
|
|
6547
7028
|
if (wantExit) {
|
|
@@ -11073,6 +11554,16 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11073
11554
|
trackEvent: (id, evt, extra) => {
|
|
11074
11555
|
void this.trackEvent(id, evt, extra);
|
|
11075
11556
|
},
|
|
11557
|
+
getLocationId: () => this.currentLocationId ?? null,
|
|
11558
|
+
getSurface: () => this.currentSurface ?? this.currentScreen ?? null,
|
|
11559
|
+
track: (eventName, properties) => {
|
|
11560
|
+
var _a2;
|
|
11561
|
+
try {
|
|
11562
|
+
const host = window.aegis;
|
|
11563
|
+
(_a2 = host == null ? void 0 : host.track) == null ? void 0 : _a2.call(host, eventName, properties);
|
|
11564
|
+
} catch {
|
|
11565
|
+
}
|
|
11566
|
+
},
|
|
11076
11567
|
sanitizeUrl: (url) => this.sanitizeUrl(url),
|
|
11077
11568
|
navigate: (url, buttonId) => this.navigateToCampaignAction(campaign, url, buttonId),
|
|
11078
11569
|
dispatchAction: (action) => this.dispatchAction(action, campaign.id),
|
|
@@ -12033,6 +12524,26 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
12033
12524
|
setOnAction(handler) {
|
|
12034
12525
|
this.onActionHandler = handler;
|
|
12035
12526
|
}
|
|
12527
|
+
/**
|
|
12528
|
+
* IA6: stamp an item action with the campaign that showed it and remember the
|
|
12529
|
+
* touch, so a later product-page add of the same sku carries it too.
|
|
12530
|
+
*/
|
|
12531
|
+
withCampaignSource(action, campaignId) {
|
|
12532
|
+
var _a;
|
|
12533
|
+
if (!campaignId || action.type !== "add_to_cart" && action.type !== "open_product") return action;
|
|
12534
|
+
const variantId = (_a = this.campaigns.find((c) => c.id === campaignId)) == null ? void 0 : _a.assigned_variant_id;
|
|
12535
|
+
const surface = this.currentSurface ?? this.currentScreen ?? void 0;
|
|
12536
|
+
if (action.sku) {
|
|
12537
|
+
recordInAppItemTouch({ campaign_id: campaignId, sku: action.sku, variant_id: variantId, surface });
|
|
12538
|
+
}
|
|
12539
|
+
if (action.type !== "add_to_cart") return action;
|
|
12540
|
+
return {
|
|
12541
|
+
...action,
|
|
12542
|
+
sourceCampaignId: campaignId,
|
|
12543
|
+
...variantId ? { sourceVariantId: variantId } : {},
|
|
12544
|
+
...surface ? { sourceSurface: surface } : {}
|
|
12545
|
+
};
|
|
12546
|
+
}
|
|
12036
12547
|
/**
|
|
12037
12548
|
* Canonical CTA-action dispatcher (CANONICAL_ACTION_MODEL_TRACKER.md). ONE path
|
|
12038
12549
|
* for every host-facing CTA action:
|
|
@@ -12045,8 +12556,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
12045
12556
|
* so they're one behaviour delivered to the host's single `onAction` handler.
|
|
12046
12557
|
* (Phase E.2 hard cutover — the legacy `aegis:*` DOM events were removed.)
|
|
12047
12558
|
*/
|
|
12048
|
-
dispatchAction(
|
|
12559
|
+
dispatchAction(rawAction, campaignId) {
|
|
12049
12560
|
var _a;
|
|
12561
|
+
const action = this.withCampaignSource(rawAction, campaignId);
|
|
12050
12562
|
let handled = false;
|
|
12051
12563
|
try {
|
|
12052
12564
|
handled = ((_a = this.onActionHandler) == null ? void 0 : _a.call(this, action)) === true;
|
|
@@ -16573,7 +17085,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
16573
17085
|
this.initialized = false;
|
|
16574
17086
|
this.armedInAppTriggers = /* @__PURE__ */ new Set();
|
|
16575
17087
|
{
|
|
16576
|
-
const v = "1.
|
|
17088
|
+
const v = "1.47.1";
|
|
16577
17089
|
try {
|
|
16578
17090
|
globalThis.__AEGIS_SDK_VERSION__ = v;
|
|
16579
17091
|
} catch {
|
|
@@ -17068,6 +17580,7 @@ export {
|
|
|
17068
17580
|
aegis as default,
|
|
17069
17581
|
deriveDeviceFingerprint,
|
|
17070
17582
|
fallbackUrlForAction,
|
|
17583
|
+
getChatContext,
|
|
17071
17584
|
getCurrentLauncher,
|
|
17072
17585
|
isReplaceableRailTitle,
|
|
17073
17586
|
mountScratchSurface,
|
|
@@ -17078,6 +17591,7 @@ export {
|
|
|
17078
17591
|
renderPreview,
|
|
17079
17592
|
resolveRailHeading,
|
|
17080
17593
|
scratchFoilPalette,
|
|
17594
|
+
setChatContext,
|
|
17081
17595
|
throttle,
|
|
17082
17596
|
writeFirstPartyCookie
|
|
17083
17597
|
};
|