customer-chat-sdk 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/customer-sdk.cjs.js +11 -5
- package/dist/customer-sdk.esm.js +11 -5
- package/dist/customer-sdk.min.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cd55183185a9b3ae.png +0 -0
- package/dist/core/IconManager.interact.example.d.ts +0 -36
- package/dist/core/IconManager.interact.example.d.ts.map +0 -1
- package/dist/core/IframeManager.d.ts +0 -111
- package/dist/core/IframeManager.d.ts.map +0 -1
- package/dist/core/SimpleSDK.d.ts +0 -111
- package/dist/core/SimpleSDK.d.ts.map +0 -1
- package/dist/simple.d.ts +0 -14
- package/dist/simple.d.ts.map +0 -1
package/dist/customer-sdk.cjs.js
CHANGED
|
@@ -29660,11 +29660,11 @@ class CustomerServiceSDK {
|
|
|
29660
29660
|
/**
|
|
29661
29661
|
* 初始化 SDK
|
|
29662
29662
|
* @param config SDK配置
|
|
29663
|
-
* @param options UI
|
|
29663
|
+
* @param options UI选项 或 截图回调(可选)
|
|
29664
29664
|
* @param forceReinit 是否强制重新初始化(用于更新token等配置)
|
|
29665
29665
|
* @returns 返回初始化信息(包含设备ID等)
|
|
29666
29666
|
*/
|
|
29667
|
-
async init(config,
|
|
29667
|
+
async init(config, options, forceReinit = false) {
|
|
29668
29668
|
// 防止并发初始化
|
|
29669
29669
|
if (this.isInitializing) {
|
|
29670
29670
|
throw new Error('SDK is already initializing. Please wait for the current initialization to complete.');
|
|
@@ -29783,8 +29783,14 @@ class CustomerServiceSDK {
|
|
|
29783
29783
|
...config.screenshot,
|
|
29784
29784
|
debug: this.debug // 直接传递 debug 标志
|
|
29785
29785
|
};
|
|
29786
|
-
|
|
29787
|
-
|
|
29786
|
+
// 检查 options 是否包含 sendData 回调(ScreenshotMessageCallback)
|
|
29787
|
+
const sendToExternal = options && 'sendData' in options ? options.sendData : undefined;
|
|
29788
|
+
if (this.debug) {
|
|
29789
|
+
console.log('[CustomerServiceSDK] 初始化截图管理器:');
|
|
29790
|
+
console.log(' options:', options ? '存在' : 'null/undefined', options);
|
|
29791
|
+
console.log(' sendData:', sendToExternal ? '存在' : 'undefined', typeof sendToExternal);
|
|
29792
|
+
}
|
|
29793
|
+
this.screenshotManager = new ScreenshotManager(targetElement, screenshotOptions, sendToExternal);
|
|
29788
29794
|
// 自动启用截图功能(用于测试,实际使用时需要通过 iframe 消息启用)
|
|
29789
29795
|
this.screenshotManager.enable(true);
|
|
29790
29796
|
if (this.debug) {
|
|
@@ -30094,7 +30100,7 @@ let globalSDKInstance = null;
|
|
|
30094
30100
|
/**
|
|
30095
30101
|
* 初始化 Customer SDK
|
|
30096
30102
|
* @param config SDK配置
|
|
30097
|
-
* @param options UI
|
|
30103
|
+
* @param options UI选项 或 截图回调(可选)
|
|
30098
30104
|
* @param forceReinit 是否强制重新初始化(用于更新token等配置)
|
|
30099
30105
|
* @returns 返回初始化信息(包含设备ID等)
|
|
30100
30106
|
*/
|
package/dist/customer-sdk.esm.js
CHANGED
|
@@ -29656,11 +29656,11 @@ class CustomerServiceSDK {
|
|
|
29656
29656
|
/**
|
|
29657
29657
|
* 初始化 SDK
|
|
29658
29658
|
* @param config SDK配置
|
|
29659
|
-
* @param options UI
|
|
29659
|
+
* @param options UI选项 或 截图回调(可选)
|
|
29660
29660
|
* @param forceReinit 是否强制重新初始化(用于更新token等配置)
|
|
29661
29661
|
* @returns 返回初始化信息(包含设备ID等)
|
|
29662
29662
|
*/
|
|
29663
|
-
async init(config,
|
|
29663
|
+
async init(config, options, forceReinit = false) {
|
|
29664
29664
|
// 防止并发初始化
|
|
29665
29665
|
if (this.isInitializing) {
|
|
29666
29666
|
throw new Error('SDK is already initializing. Please wait for the current initialization to complete.');
|
|
@@ -29779,8 +29779,14 @@ class CustomerServiceSDK {
|
|
|
29779
29779
|
...config.screenshot,
|
|
29780
29780
|
debug: this.debug // 直接传递 debug 标志
|
|
29781
29781
|
};
|
|
29782
|
-
|
|
29783
|
-
|
|
29782
|
+
// 检查 options 是否包含 sendData 回调(ScreenshotMessageCallback)
|
|
29783
|
+
const sendToExternal = options && 'sendData' in options ? options.sendData : undefined;
|
|
29784
|
+
if (this.debug) {
|
|
29785
|
+
console.log('[CustomerServiceSDK] 初始化截图管理器:');
|
|
29786
|
+
console.log(' options:', options ? '存在' : 'null/undefined', options);
|
|
29787
|
+
console.log(' sendData:', sendToExternal ? '存在' : 'undefined', typeof sendToExternal);
|
|
29788
|
+
}
|
|
29789
|
+
this.screenshotManager = new ScreenshotManager(targetElement, screenshotOptions, sendToExternal);
|
|
29784
29790
|
// 自动启用截图功能(用于测试,实际使用时需要通过 iframe 消息启用)
|
|
29785
29791
|
this.screenshotManager.enable(true);
|
|
29786
29792
|
if (this.debug) {
|
|
@@ -30090,7 +30096,7 @@ let globalSDKInstance = null;
|
|
|
30090
30096
|
/**
|
|
30091
30097
|
* 初始化 Customer SDK
|
|
30092
30098
|
* @param config SDK配置
|
|
30093
|
-
* @param options UI
|
|
30099
|
+
* @param options UI选项 或 截图回调(可选)
|
|
30094
30100
|
* @param forceReinit 是否强制重新初始化(用于更新token等配置)
|
|
30095
30101
|
* @returns 返回初始化信息(包含设备ID等)
|
|
30096
30102
|
*/
|
package/dist/customer-sdk.min.js
CHANGED
|
@@ -35,4 +35,4 @@ e.mode.CTRGladman=function(){var A=e.lib.BlockCipherMode.extend();function t(A){
|
|
|
35
35
|
|
|
36
36
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
37
|
*/
|
|
38
|
-
function(){var A=e,t=A.lib,n=t.WordArray,r=t.Hasher,o=A.algo,i=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),c=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),l=n.create([0,1518500249,1859775393,2400959708,2840853838]),u=n.create([1352829926,1548603684,1836072691,2053994217,0]),h=o.RIPEMD160=r.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(A,e){for(var t=0;t<16;t++){var n=e+t,r=A[n];A[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o,h,m,C,Q,y,U,F,b,v,E,H=this._hash.words,I=l.words,x=u.words,S=i.words,L=s.words,D=a.words,M=c.words;for(y=o=H[0],U=h=H[1],F=m=H[2],b=C=H[3],v=Q=H[4],t=0;t<80;t+=1)E=o+A[e+S[t]]|0,E+=t<16?g(h,m,C)+I[0]:t<32?d(h,m,C)+I[1]:t<48?B(h,m,C)+I[2]:t<64?f(h,m,C)+I[3]:w(h,m,C)+I[4],E=(E=p(E|=0,D[t]))+Q|0,o=Q,Q=C,C=p(m,10),m=h,h=E,E=y+A[e+L[t]]|0,E+=t<16?w(U,F,b)+x[0]:t<32?f(U,F,b)+x[1]:t<48?B(U,F,b)+x[2]:t<64?d(U,F,b)+x[3]:g(U,F,b)+x[4],E=(E=p(E|=0,M[t]))+v|0,y=v,v=b,b=p(F,10),F=U,U=E;E=H[1]+m+b|0,H[1]=H[2]+C+v|0,H[2]=H[3]+Q+y|0,H[3]=H[4]+o+U|0,H[4]=H[0]+h+F|0,H[0]=E},_doFinalize:function(){var A=this._data,e=A.words,t=8*this._nDataBytes,n=8*A.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(t<<8|t>>>24)|4278255360&(t<<24|t>>>8),A.sigBytes=4*(e.length+1),this._process();for(var r=this._hash,o=r.words,i=0;i<5;i++){var s=o[i];o[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return r},clone:function(){var A=r.clone.call(this);return A._hash=this._hash.clone(),A}});function g(A,e,t){return A^e^t}function d(A,e,t){return A&e|~A&t}function B(A,e,t){return(A|~e)^t}function f(A,e,t){return A&t|e&~t}function w(A,e,t){return A^(e|~t)}function p(A,e){return A<<e|A>>>32-e}A.RIPEMD160=r._createHelper(h),A.HmacRIPEMD160=r._createHmacHelper(h)}(),e.RIPEMD160)}(xr)),Dr(),Mr||(Mr=1,function(A){var e,t,n,r,o,i,s,a,c;A.exports=(c=Yn(),pr(),Dr(),n=(t=(e=c).lib).Base,r=t.WordArray,i=(o=e.algo).SHA256,s=o.HMAC,a=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:i,iterations:25e4}),init:function(A){this.cfg=this.cfg.extend(A)},compute:function(A,e){for(var t=this.cfg,n=s.create(t.hasher,A),o=r.create(),i=r.create([1]),a=o.words,c=i.words,l=t.keySize,u=t.iterations;a.length<l;){var h=n.update(e).finalize(i);n.reset();for(var g=h.words,d=g.length,B=h,f=1;f<u;f++){B=n.finalize(B),n.reset();for(var w=B.words,p=0;p<d;p++)g[p]^=w[p]}o.concat(h),c[0]++}return o.sigBytes=4*l,o}}),e.PBKDF2=function(A,e,t){return a.create(t).compute(A,e)},c.PBKDF2)}(kr)),Rr(),Vr(),Wr(),Jr(),Zr(),qr(),Ao||(Ao=1,function(A){var e,t;A.exports=(t=Yn(),Vr(),t.mode.ECB=((e=t.lib.BlockCipherMode.extend()).Encryptor=e.extend({processBlock:function(A,e){this._cipher.encryptBlock(A,e)}}),e.Decryptor=e.extend({processBlock:function(A,e){this._cipher.decryptBlock(A,e)}}),e),t.mode.ECB)}(eo)),to||(to=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.AnsiX923={pad:function(A,e){var t=A.sigBytes,n=4*e,r=n-t%n,o=t+r-1;A.clamp(),A.words[o>>>2]|=r<<24-o%4*8,A.sigBytes+=r},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Ansix923)}(no)),ro||(ro=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.Iso10126={pad:function(A,t){var n=4*t,r=n-A.sigBytes%n;A.concat(e.lib.WordArray.random(r-1)).concat(e.lib.WordArray.create([r<<24],1))},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Iso10126)}(oo)),io||(io=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.Iso97971={pad:function(A,t){A.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(A,t)},unpad:function(A){e.pad.ZeroPadding.unpad(A),A.sigBytes--}},e.pad.Iso97971)}(so)),ao||(ao=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.ZeroPadding={pad:function(A,e){var t=4*e;A.clamp(),A.sigBytes+=t-(A.sigBytes%t||t)},unpad:function(A){var e=A.words,t=A.sigBytes-1;for(t=A.sigBytes-1;t>=0;t--)if(e[t>>>2]>>>24-t%4*8&255){A.sigBytes=t+1;break}}},e.pad.ZeroPadding)}(co)),lo||(lo=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding)}(uo)),ho||(ho=1,function(A){var e,t,n,r;A.exports=(r=Yn(),Vr(),t=(e=r).lib.CipherParams,n=e.enc.Hex,e.format.Hex={stringify:function(A){return A.ciphertext.toString(n)},parse:function(A){var e=n.parse(A);return t.create({ciphertext:e})}},r.format.Hex)}(go)),Bo||(Bo=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.BlockCipher,n=A.algo,r=[],o=[],i=[],s=[],a=[],c=[],l=[],u=[],h=[],g=[];!function(){for(var A=[],e=0;e<256;e++)A[e]=e<128?e<<1:e<<1^283;var t=0,n=0;for(e=0;e<256;e++){var d=n^n<<1^n<<2^n<<3^n<<4;d=d>>>8^255&d^99,r[t]=d,o[d]=t;var B=A[t],f=A[B],w=A[f],p=257*A[d]^16843008*d;i[t]=p<<24|p>>>8,s[t]=p<<16|p>>>16,a[t]=p<<8|p>>>24,c[t]=p,p=16843009*w^65537*f^257*B^16843008*t,l[d]=p<<24|p>>>8,u[d]=p<<16|p>>>16,h[d]=p<<8|p>>>24,g[d]=p,t?(t=B^A[A[A[w^B]]],n^=A[A[n]]):t=n=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],B=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var A=this._keyPriorReset=this._key,e=A.words,t=A.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i<n;i++)i<t?o[i]=e[i]:(c=o[i-1],i%t?t>6&&i%t==4&&(c=r[c>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c]):(c=r[(c=c<<8|c>>>24)>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c],c^=d[i/t|0]<<24),o[i]=o[i-t]^c);for(var s=this._invKeySchedule=[],a=0;a<n;a++){if(i=n-a,a%4)var c=o[i];else c=o[i-4];s[a]=a<4||i<=4?c:l[r[c>>>24]]^u[r[c>>>16&255]]^h[r[c>>>8&255]]^g[r[255&c]]}}},encryptBlock:function(A,e){this._doCryptBlock(A,e,this._keySchedule,i,s,a,c,r)},decryptBlock:function(A,e){var t=A[e+1];A[e+1]=A[e+3],A[e+3]=t,this._doCryptBlock(A,e,this._invKeySchedule,l,u,h,g,o),t=A[e+1],A[e+1]=A[e+3],A[e+3]=t},_doCryptBlock:function(A,e,t,n,r,o,i,s){for(var a=this._nRounds,c=A[e]^t[0],l=A[e+1]^t[1],u=A[e+2]^t[2],h=A[e+3]^t[3],g=4,d=1;d<a;d++){var B=n[c>>>24]^r[l>>>16&255]^o[u>>>8&255]^i[255&h]^t[g++],f=n[l>>>24]^r[u>>>16&255]^o[h>>>8&255]^i[255&c]^t[g++],w=n[u>>>24]^r[h>>>16&255]^o[c>>>8&255]^i[255&l]^t[g++],p=n[h>>>24]^r[c>>>16&255]^o[l>>>8&255]^i[255&u]^t[g++];c=B,l=f,u=w,h=p}B=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&h])^t[g++],f=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^t[g++],w=(s[u>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^t[g++],p=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^t[g++],A[e]=B,A[e+1]=f,A[e+2]=w,A[e+3]=p},keySize:8});A.AES=t._createHelper(B)}(),e.AES)}(fo)),mo(),Co||(Co=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=n.RC4=t.extend({_doReset:function(){for(var A=this._key,e=A.words,t=A.sigBytes,n=this._S=[],r=0;r<256;r++)n[r]=r;r=0;for(var o=0;r<256;r++){var i=r%t,s=e[i>>>2]>>>24-i%4*8&255;o=(o+n[r]+s)%256;var a=n[r];n[r]=n[o],n[o]=a}this._i=this._j=0},_doProcessBlock:function(A,e){A[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var A=this._S,e=this._i,t=this._j,n=0,r=0;r<4;r++){t=(t+A[e=(e+1)%256])%256;var o=A[e];A[e]=A[t],A[t]=o,n|=A[(A[e]+A[t])%256]<<24-8*r}return this._i=e,this._j=t,n}A.RC4=t._createHelper(r);var i=n.RC4Drop=r.extend({cfg:r.cfg.extend({drop:192}),_doReset:function(){r._doReset.call(this);for(var A=this.cfg.drop;A>0;A--)o.call(this)}});A.RC4Drop=t._createHelper(i)}(),e.RC4)}(Qo)),yo||(yo=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.Rabbit=t.extend({_doReset:function(){for(var A=this._key.words,e=this.cfg.iv,t=0;t<4;t++)A[t]=16711935&(A[t]<<8|A[t]>>>24)|4278255360&(A[t]<<24|A[t]>>>8);var n=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],r=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];for(this._b=0,t=0;t<4;t++)a.call(this);for(t=0;t<8;t++)r[t]^=n[t+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,h=l<<16|65535&c;for(r[0]^=c,r[1]^=u,r[2]^=l,r[3]^=h,r[4]^=c,r[5]^=u,r[6]^=l,r[7]^=h,t=0;t<4;t++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.Rabbit=t._createHelper(s)}(),e.Rabbit)}(Uo)),Fo||(Fo=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.RabbitLegacy=t.extend({_doReset:function(){var A=this._key.words,e=this.cfg.iv,t=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],n=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];this._b=0;for(var r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)n[r]^=t[r+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,h=l<<16|65535&c;for(n[0]^=c,n[1]^=u,n[2]^=l,n[3]^=h,n[4]^=c,n[5]^=u,n[6]^=l,n[7]^=h,r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.RabbitLegacy=t._createHelper(s)}(),e.RabbitLegacy)}(bo)),Ho(),e)}(Wn);var Io=Wn.exports;class xo{constructor(){this.iconManager=null,this.screenshotManager=null,this.config=null,this.isInitialized=!1,this.isInitializing=!1,this.initResult=null,this.debug=!1,this.lastIconConfig=null}async init(A,t,n=!1){if(this.isInitializing)throw new Error("SDK is already initializing. Please wait for the current initialization to complete.");if(this.isInitialized&&!n){if(this.debug&&console.warn("CustomerSDK already initialized, returning cached result. Use forceReinit=true to reinitialize."),this.initResult)return this.initResult;throw new Error("SDK already initialized but cannot retrieve initialization info")}this.isInitializing=!0,this.isInitialized&&n&&(this.debug&&console.log("Force reinitializing SDK..."),this.screenshotManager?.destroy(),this.screenshotManager=null,this.isInitialized=!1),this.config=A,this.debug=A.debug??!1;try{const t=await this.getDeviceId();this.debug&&console.log("Raw Device ID:",t);const n=this.getReferrer(A),r=Io.MD5(t+n).toString();this.debug&&(console.log("Raw Device ID:",t),console.log("MD5 Device ID (for frontend):",r),console.log("Referrer used:",n));const o={deviceId:r,referrer:n,agent:A.agent,timestamp:Date.now()},i=A.iconPosition??this.lastIconConfig?.position,s=A.target??this.lastIconConfig?.target;if(this.isIconConfigChanged(i,s)?(this.iconManager&&(this.iconManager.hide(),this.iconManager=null,this.debug&&console.log("Icon config changed, recreating icon manager")),this.iconManager=new e(i,this.debug,s,{sideAttach:A.sideAttach??!0,sideHideRatio:A.sideHideRatio??.5,magnetic:A.magnetic??!0,magneticDirection:A.magneticDirection??"x",margin:A.margin??10,autoAttachDelay:A.autoAttachDelay??3e3}),await this.iconManager.show(),this.lastIconConfig={position:i,target:s}):(this.iconManager?(await this.iconManager.show(),this.debug&&console.log("Icon config unchanged, keeping existing icon manager")):(this.iconManager=new e(i,this.debug,s,{sideAttach:A.sideAttach??!0,sideHideRatio:A.sideHideRatio??.5,magnetic:A.magnetic??!0,magneticDirection:A.magneticDirection??"x",margin:A.margin??10,autoAttachDelay:A.autoAttachDelay??3e3}),await this.iconManager.show()),this.lastIconConfig={position:i,target:s}),this.iconManager.onClick(()=>{this.clearNotification()}),A.screenshot){const e=document.body,t={...A.screenshot,debug:this.debug};this.screenshotManager=new dt(e,t,void 0),this.screenshotManager.enable(!0),this.debug&&console.log("CustomerSDK screenshot manager initialized and enabled")}return this.isInitialized=!0,this.initResult=o,this.debug&&console.log("CustomerSDK initialized successfully (icon + screenshot only)"),o}catch(A){console.error("Failed to initialize CustomerSDK:",A);try{this.iconManager&&(this.iconManager.hide(),this.iconManager=null),this.screenshotManager&&(this.screenshotManager.destroy(),this.screenshotManager=null),this.isInitialized=!1,this.initResult=null}catch(A){console.error("Error during cleanup after initialization failure:",A)}throw A}finally{this.isInitializing=!1}}showIcon(){this.iconManager?.show()}hideIcon(){this.iconManager?.hide()}setIconPosition(A){this.iconManager?.setPosition(A)}setIconCoordinates(A){this.iconManager?.setIconPosition(A)}setIconStyle(A){this.iconManager?.setStyle(A)}onIconClick(A){this.iconManager?.onClick(A)}getConnectionStatus(){return this.isInitialized}showNotification(A=1,e={}){this.iconManager?(this.iconManager.showNotification({badgeCount:"string"==typeof A?0:A,badgeText:"string"==typeof A?A:"",pulse:e.pulse||!1}),e.autoHide&&e.autoHide>0&&setTimeout(()=>{this.iconManager?.clearNotification()},e.autoHide)):this.debug&&console.warn("SDK not initialized")}clearNotification(){this.iconManager?.clearNotification()}setScreenshotTarget(A){this.screenshotManager?.setTargetElement(A)}async captureScreenshot(A=!1){return this.screenshotManager?await this.screenshotManager.captureOnce(A):(this.debug&&console.warn("截图功能未启用"),!1)}enableScreenshot(A){this.screenshotManager?(this.screenshotManager.enable(A),this.debug&&console.log("📸 截图功能已"+(A?"启用":"禁用"))):this.debug&&console.warn("截图管理器未初始化")}getScreenshotState(){return this.screenshotManager?.getState()||null}updateScreenshotOptions(A){this.screenshotManager?(this.screenshotManager.updateOptions(A),this.debug&&console.log("📸 截图配置已更新:",A)):this.debug&&console.warn("截图管理器未初始化,无法更新配置")}triggerScreenshotConfig(A){this.screenshotManager?(this.screenshotManager.handleScreenshotConfig(A),this.debug&&console.log("[CustomerServiceSDK] Screenshot config triggered:",A)):this.debug&&console.warn("[CustomerServiceSDK] ScreenshotManager not initialized")}destroy(){this.iconManager?.hide(),this.screenshotManager?.destroy(),this.iconManager=null,this.screenshotManager=null,this.config=null,this.initResult=null,this.lastIconConfig=null,this.isInitialized=!1,this.debug&&console.log("CustomerSDK destroyed")}getInitResult(){return this.initResult}async generateInitResult(A){const e=await this.getDeviceId(),t=this.config?.referrer||this.getReferrer(this.config||{}),n=Io.MD5(e+t).toString(),r=A||this.config?.agent;return this.debug&&console.log("Generated InitResult:",{deviceId:n,referrer:t,agent:r,timestamp:Date.now()}),{deviceId:n,referrer:t,agent:r,timestamp:Date.now()}}async getDeviceId(){this.debug&&console.log("🔍 Starting to get device fingerprint...");try{this.debug&&console.log("📦 Loading FingerprintJS...");const A=await Gn.load();this.debug&&console.log("🎯 Getting device fingerprint...");const e=await A.get();return this.debug&&(console.log("✅ FingerprintJS result:",e),console.log("🆔 Device ID obtained:",e.visitorId)),e.visitorId}catch(A){this.debug&&console.warn("❌ Failed to get device fingerprint, using fallback:",A);const e="device_"+Date.now()+"_"+Math.random().toString(36).substr(2,9);return this.debug&&console.log("🆔 Fallback Device ID:",e),e}}isIconConfigChanged(A,e){if(!this.lastIconConfig)return!0;const t=JSON.stringify(this.lastIconConfig.position)!==JSON.stringify(A),n=this.lastIconConfig.target;let r=!1;return n!==e&&(r="string"==typeof n&&"string"==typeof e?n!==e:(n instanceof HTMLElement&&HTMLElement,!0)),t||r}getReferrer(A){return A.referrer||document.referrer||document.location.href}}let So=null;const Lo=async(A,e,t=!1)=>(So||(So=new xo),await So.init(A,e,t)),Do=()=>{if(!So)throw new Error("SDK not initialized. Call init() first.");return So},Mo=()=>{Do().showIcon()},ko=()=>{Do().hideIcon()},Ko=A=>{Do().setIconPosition(A)},To=A=>{Do().setIconCoordinates(A)},Ro=A=>{Do().setIconStyle(A)},Po=A=>{Do().onIconClick(A)},Oo=()=>Do().getConnectionStatus(),Vo=()=>Do().getInitResult(),No=async A=>{const e=Do();return await e.generateInitResult(A)},Go=(A=1,e={})=>{Do().showNotification(A,e)},Wo=()=>{Do().clearNotification()},_o=()=>{Do().destroy(),So=null},Xo=A=>{Do().setScreenshotTarget(A)},Jo=async(A=!1)=>{const e=Do();return await e.captureScreenshot(A)},Yo=A=>{Do().enableScreenshot(A)},$o=()=>Do().getScreenshotState(),Zo=A=>{Do().updateScreenshotOptions(A)},zo=A=>{Do().triggerScreenshotConfig(A)};var jo={init:Lo,getInstance:Do,getInitResult:Vo,generateInitResult:No,showIcon:Mo,hideIcon:ko,setIconPosition:Ko,setIconCoordinates:To,setIconStyle:Ro,onIconClick:Po,getConnectionStatus:Oo,showNotification:Go,clearNotification:Wo,setScreenshotTarget:Xo,captureScreenshot:Jo,enableScreenshot:Yo,getScreenshotState:$o,updateScreenshotOptions:Zo,triggerScreenshotConfig:zo,destroy:_o};A.CustomerSDK=class{constructor(){this.iconManager=null,this.screenshotManager=null,this.debug=!1,this.deviceId=null,this.initResult=null,this.config=null,this.screenshotCallback=null,this.initCallback=null}async init(A,t,n){try{this.config=A,this.screenshotCallback=t||null,this.initCallback=n||null,this.debug=A.debug??!1;const r=await this.getRawDeviceId();this.debug&&console.log("Raw Device ID:",r);const o=A.referrer||document.referrer||document.location.href;this.deviceId=Io.MD5(r+o).toString(),this.debug&&(console.log("MD5 Device ID (for frontend):",this.deviceId),console.log("Referrer used:",o));const i={deviceId:this.deviceId,referrer:o,agent:A.agent,timestamp:Date.now()},s=A.target||void 0,a=A.iconPosition||void 0;if(this.iconManager=new e(a,this.debug,s,{sideAttach:A.sideAttach,sideHideRatio:A.sideHideRatio,magnetic:A.magnetic,magneticDirection:A.magneticDirection,margin:A.margin,autoAttachDelay:A.autoAttachDelay}),await this.iconManager.show(),n?.onIconClick&&this.iconManager.onClick(n.onIconClick),A.screenshot){const e="string"==typeof s?document.querySelector(s):s||document.body,n=t?.sendData;this.debug&&(console.log("[CustomerSDK] 初始化截图管理器:"),console.log(" screenshotCallback:",t?"存在":"null/undefined",t),console.log(" screenshotCallback?.sendData:",t?.sendData?"存在":"null/undefined",typeof t?.sendData,t?.sendData),console.log(" sendToExternal:",n?"存在":"undefined",typeof n,n),console.log(" 即将传递给 ScreenshotManager 的参数:",{targetElement:e?"存在":"null",screenshot:A.screenshot?"存在":"null",sendToExternal:n?"存在":"undefined"})),this.screenshotManager=new dt(e,A.screenshot,n),t?.onConfig&&this.setupScreenshotConfigListener(t.onConfig)}return this.initResult=i,this.debug&&console.log("CustomerSDK initialized successfully (icon + screenshot only)"),i}catch(A){throw console.error("Failed to initialize CustomerSDK:",A),A}}setupScreenshotConfigListener(A){const e=e=>{try{if(!e.data||"checkScreenshot"!==e.data.type)return;this.debug&&console.log("[CustomerSDK] Received screenshot config message:",e.data),e.data.data&&"string"==typeof e.data.data&&A(e.data.data)}catch(A){this.debug&&console.error("[CustomerSDK] Error handling screenshot config message:",A)}};window.addEventListener("message",e),this._screenshotConfigHandler=e}triggerScreenshotConfig(A){this.screenshotManager?this.screenshotManager.handleScreenshotConfig(A):this.debug&&console.warn("[CustomerSDK] ScreenshotManager not initialized")}hideIcon(){this.iconManager?.hide()}showIcon(){this.iconManager?.show()}onIconClick(A){this.iconManager?.onClick(A)}getScreenshotManager(){return this.screenshotManager}getIconManager(){return this.iconManager}getDeviceId(){return this.deviceId}getInitResult(){return this.initResult}async updateToken(A,e,t){if(!this.config)throw new Error("SDK not initialized. Call init() first.");this.debug&&console.log("Updating token:",A?"Token provided":"Token removed");const n={...this.config,token:A&&""!==A.trim()?A:void 0};return this.destroy(),await this.init(n,e||this.screenshotCallback||void 0,t||this.initCallback||void 0)}async getRawDeviceId(){this.debug&&console.log("🔍 Starting to get device fingerprint...");try{this.debug&&console.log("📦 Loading FingerprintJS...");const A=await Gn.load();this.debug&&console.log("🎯 Getting device fingerprint...");const e=await A.get();return this.debug&&(console.log("✅ FingerprintJS result:",e),console.log("🆔 Device ID obtained:",e.visitorId)),e.visitorId}catch(A){this.debug&&console.warn("❌ Failed to get device fingerprint, using fallback:",A);const e="device_"+Date.now()+"_"+Math.random().toString(36).substr(2,9);return this.debug&&console.log("🆔 Fallback Device ID:",e),e}}showNotification(A=1,e={}){this.iconManager?(this.iconManager.showNotification({badgeCount:"string"==typeof A?0:A,badgeText:"string"==typeof A?A:"",pulse:e.pulse||!1}),e.autoHide&&e.autoHide>0&&setTimeout(()=>{this.iconManager?.clearNotification()},e.autoHide)):this.debug&&console.warn("SDK not initialized")}clearNotification(){this.iconManager?.clearNotification()}destroy(){this.iconManager?.hide(),this.screenshotManager?.destroy(),this._screenshotConfigHandler&&(window.removeEventListener("message",this._screenshotConfigHandler),this._screenshotConfigHandler=null),this.iconManager=null,this.screenshotManager=null,this.initResult=null,this.deviceId=null,this.debug&&console.log("CustomerSDK destroyed")}},A.CustomerServiceSDK=xo,A.captureScreenshot=Jo,A.clearNotification=Wo,A.default=jo,A.destroy=_o,A.enableScreenshot=Yo,A.generateInitResult=No,A.getConnectionStatus=Oo,A.getInitResult=Vo,A.getInstance=Do,A.getScreenshotState=$o,A.hideIcon=ko,A.init=Lo,A.onIconClick=Po,A.setIconCoordinates=To,A.setIconPosition=Ko,A.setIconStyle=Ro,A.setScreenshotTarget=Xo,A.showIcon=Mo,A.showNotification=Go,A.triggerScreenshotConfig=zo,A.updateScreenshotOptions=Zo,Object.defineProperty(A,"__esModule",{value:!0})});
|
|
38
|
+
function(){var A=e,t=A.lib,n=t.WordArray,r=t.Hasher,o=A.algo,i=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),c=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),l=n.create([0,1518500249,1859775393,2400959708,2840853838]),u=n.create([1352829926,1548603684,1836072691,2053994217,0]),h=o.RIPEMD160=r.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(A,e){for(var t=0;t<16;t++){var n=e+t,r=A[n];A[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o,h,m,C,Q,y,U,F,b,v,E,H=this._hash.words,I=l.words,x=u.words,S=i.words,L=s.words,D=a.words,M=c.words;for(y=o=H[0],U=h=H[1],F=m=H[2],b=C=H[3],v=Q=H[4],t=0;t<80;t+=1)E=o+A[e+S[t]]|0,E+=t<16?g(h,m,C)+I[0]:t<32?d(h,m,C)+I[1]:t<48?B(h,m,C)+I[2]:t<64?f(h,m,C)+I[3]:w(h,m,C)+I[4],E=(E=p(E|=0,D[t]))+Q|0,o=Q,Q=C,C=p(m,10),m=h,h=E,E=y+A[e+L[t]]|0,E+=t<16?w(U,F,b)+x[0]:t<32?f(U,F,b)+x[1]:t<48?B(U,F,b)+x[2]:t<64?d(U,F,b)+x[3]:g(U,F,b)+x[4],E=(E=p(E|=0,M[t]))+v|0,y=v,v=b,b=p(F,10),F=U,U=E;E=H[1]+m+b|0,H[1]=H[2]+C+v|0,H[2]=H[3]+Q+y|0,H[3]=H[4]+o+U|0,H[4]=H[0]+h+F|0,H[0]=E},_doFinalize:function(){var A=this._data,e=A.words,t=8*this._nDataBytes,n=8*A.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(t<<8|t>>>24)|4278255360&(t<<24|t>>>8),A.sigBytes=4*(e.length+1),this._process();for(var r=this._hash,o=r.words,i=0;i<5;i++){var s=o[i];o[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return r},clone:function(){var A=r.clone.call(this);return A._hash=this._hash.clone(),A}});function g(A,e,t){return A^e^t}function d(A,e,t){return A&e|~A&t}function B(A,e,t){return(A|~e)^t}function f(A,e,t){return A&t|e&~t}function w(A,e,t){return A^(e|~t)}function p(A,e){return A<<e|A>>>32-e}A.RIPEMD160=r._createHelper(h),A.HmacRIPEMD160=r._createHmacHelper(h)}(),e.RIPEMD160)}(xr)),Dr(),Mr||(Mr=1,function(A){var e,t,n,r,o,i,s,a,c;A.exports=(c=Yn(),pr(),Dr(),n=(t=(e=c).lib).Base,r=t.WordArray,i=(o=e.algo).SHA256,s=o.HMAC,a=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:i,iterations:25e4}),init:function(A){this.cfg=this.cfg.extend(A)},compute:function(A,e){for(var t=this.cfg,n=s.create(t.hasher,A),o=r.create(),i=r.create([1]),a=o.words,c=i.words,l=t.keySize,u=t.iterations;a.length<l;){var h=n.update(e).finalize(i);n.reset();for(var g=h.words,d=g.length,B=h,f=1;f<u;f++){B=n.finalize(B),n.reset();for(var w=B.words,p=0;p<d;p++)g[p]^=w[p]}o.concat(h),c[0]++}return o.sigBytes=4*l,o}}),e.PBKDF2=function(A,e,t){return a.create(t).compute(A,e)},c.PBKDF2)}(kr)),Rr(),Vr(),Wr(),Jr(),Zr(),qr(),Ao||(Ao=1,function(A){var e,t;A.exports=(t=Yn(),Vr(),t.mode.ECB=((e=t.lib.BlockCipherMode.extend()).Encryptor=e.extend({processBlock:function(A,e){this._cipher.encryptBlock(A,e)}}),e.Decryptor=e.extend({processBlock:function(A,e){this._cipher.decryptBlock(A,e)}}),e),t.mode.ECB)}(eo)),to||(to=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.AnsiX923={pad:function(A,e){var t=A.sigBytes,n=4*e,r=n-t%n,o=t+r-1;A.clamp(),A.words[o>>>2]|=r<<24-o%4*8,A.sigBytes+=r},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Ansix923)}(no)),ro||(ro=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.Iso10126={pad:function(A,t){var n=4*t,r=n-A.sigBytes%n;A.concat(e.lib.WordArray.random(r-1)).concat(e.lib.WordArray.create([r<<24],1))},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Iso10126)}(oo)),io||(io=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.Iso97971={pad:function(A,t){A.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(A,t)},unpad:function(A){e.pad.ZeroPadding.unpad(A),A.sigBytes--}},e.pad.Iso97971)}(so)),ao||(ao=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.ZeroPadding={pad:function(A,e){var t=4*e;A.clamp(),A.sigBytes+=t-(A.sigBytes%t||t)},unpad:function(A){var e=A.words,t=A.sigBytes-1;for(t=A.sigBytes-1;t>=0;t--)if(e[t>>>2]>>>24-t%4*8&255){A.sigBytes=t+1;break}}},e.pad.ZeroPadding)}(co)),lo||(lo=1,function(A){var e;A.exports=(e=Yn(),Vr(),e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding)}(uo)),ho||(ho=1,function(A){var e,t,n,r;A.exports=(r=Yn(),Vr(),t=(e=r).lib.CipherParams,n=e.enc.Hex,e.format.Hex={stringify:function(A){return A.ciphertext.toString(n)},parse:function(A){var e=n.parse(A);return t.create({ciphertext:e})}},r.format.Hex)}(go)),Bo||(Bo=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.BlockCipher,n=A.algo,r=[],o=[],i=[],s=[],a=[],c=[],l=[],u=[],h=[],g=[];!function(){for(var A=[],e=0;e<256;e++)A[e]=e<128?e<<1:e<<1^283;var t=0,n=0;for(e=0;e<256;e++){var d=n^n<<1^n<<2^n<<3^n<<4;d=d>>>8^255&d^99,r[t]=d,o[d]=t;var B=A[t],f=A[B],w=A[f],p=257*A[d]^16843008*d;i[t]=p<<24|p>>>8,s[t]=p<<16|p>>>16,a[t]=p<<8|p>>>24,c[t]=p,p=16843009*w^65537*f^257*B^16843008*t,l[d]=p<<24|p>>>8,u[d]=p<<16|p>>>16,h[d]=p<<8|p>>>24,g[d]=p,t?(t=B^A[A[A[w^B]]],n^=A[A[n]]):t=n=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],B=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var A=this._keyPriorReset=this._key,e=A.words,t=A.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i<n;i++)i<t?o[i]=e[i]:(c=o[i-1],i%t?t>6&&i%t==4&&(c=r[c>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c]):(c=r[(c=c<<8|c>>>24)>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c],c^=d[i/t|0]<<24),o[i]=o[i-t]^c);for(var s=this._invKeySchedule=[],a=0;a<n;a++){if(i=n-a,a%4)var c=o[i];else c=o[i-4];s[a]=a<4||i<=4?c:l[r[c>>>24]]^u[r[c>>>16&255]]^h[r[c>>>8&255]]^g[r[255&c]]}}},encryptBlock:function(A,e){this._doCryptBlock(A,e,this._keySchedule,i,s,a,c,r)},decryptBlock:function(A,e){var t=A[e+1];A[e+1]=A[e+3],A[e+3]=t,this._doCryptBlock(A,e,this._invKeySchedule,l,u,h,g,o),t=A[e+1],A[e+1]=A[e+3],A[e+3]=t},_doCryptBlock:function(A,e,t,n,r,o,i,s){for(var a=this._nRounds,c=A[e]^t[0],l=A[e+1]^t[1],u=A[e+2]^t[2],h=A[e+3]^t[3],g=4,d=1;d<a;d++){var B=n[c>>>24]^r[l>>>16&255]^o[u>>>8&255]^i[255&h]^t[g++],f=n[l>>>24]^r[u>>>16&255]^o[h>>>8&255]^i[255&c]^t[g++],w=n[u>>>24]^r[h>>>16&255]^o[c>>>8&255]^i[255&l]^t[g++],p=n[h>>>24]^r[c>>>16&255]^o[l>>>8&255]^i[255&u]^t[g++];c=B,l=f,u=w,h=p}B=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&h])^t[g++],f=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^t[g++],w=(s[u>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^t[g++],p=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^t[g++],A[e]=B,A[e+1]=f,A[e+2]=w,A[e+3]=p},keySize:8});A.AES=t._createHelper(B)}(),e.AES)}(fo)),mo(),Co||(Co=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=n.RC4=t.extend({_doReset:function(){for(var A=this._key,e=A.words,t=A.sigBytes,n=this._S=[],r=0;r<256;r++)n[r]=r;r=0;for(var o=0;r<256;r++){var i=r%t,s=e[i>>>2]>>>24-i%4*8&255;o=(o+n[r]+s)%256;var a=n[r];n[r]=n[o],n[o]=a}this._i=this._j=0},_doProcessBlock:function(A,e){A[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var A=this._S,e=this._i,t=this._j,n=0,r=0;r<4;r++){t=(t+A[e=(e+1)%256])%256;var o=A[e];A[e]=A[t],A[t]=o,n|=A[(A[e]+A[t])%256]<<24-8*r}return this._i=e,this._j=t,n}A.RC4=t._createHelper(r);var i=n.RC4Drop=r.extend({cfg:r.cfg.extend({drop:192}),_doReset:function(){r._doReset.call(this);for(var A=this.cfg.drop;A>0;A--)o.call(this)}});A.RC4Drop=t._createHelper(i)}(),e.RC4)}(Qo)),yo||(yo=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.Rabbit=t.extend({_doReset:function(){for(var A=this._key.words,e=this.cfg.iv,t=0;t<4;t++)A[t]=16711935&(A[t]<<8|A[t]>>>24)|4278255360&(A[t]<<24|A[t]>>>8);var n=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],r=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];for(this._b=0,t=0;t<4;t++)a.call(this);for(t=0;t<8;t++)r[t]^=n[t+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,h=l<<16|65535&c;for(r[0]^=c,r[1]^=u,r[2]^=l,r[3]^=h,r[4]^=c,r[5]^=u,r[6]^=l,r[7]^=h,t=0;t<4;t++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.Rabbit=t._createHelper(s)}(),e.Rabbit)}(Uo)),Fo||(Fo=1,function(A){var e;A.exports=(e=Yn(),ir(),hr(),Rr(),Vr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.RabbitLegacy=t.extend({_doReset:function(){var A=this._key.words,e=this.cfg.iv,t=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],n=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];this._b=0;for(var r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)n[r]^=t[r+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,h=l<<16|65535&c;for(n[0]^=c,n[1]^=u,n[2]^=l,n[3]^=h,n[4]^=c,n[5]^=u,n[6]^=l,n[7]^=h,r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.RabbitLegacy=t._createHelper(s)}(),e.RabbitLegacy)}(bo)),Ho(),e)}(Wn);var Io=Wn.exports;class xo{constructor(){this.iconManager=null,this.screenshotManager=null,this.config=null,this.isInitialized=!1,this.isInitializing=!1,this.initResult=null,this.debug=!1,this.lastIconConfig=null}async init(A,t,n=!1){if(this.isInitializing)throw new Error("SDK is already initializing. Please wait for the current initialization to complete.");if(this.isInitialized&&!n){if(this.debug&&console.warn("CustomerSDK already initialized, returning cached result. Use forceReinit=true to reinitialize."),this.initResult)return this.initResult;throw new Error("SDK already initialized but cannot retrieve initialization info")}this.isInitializing=!0,this.isInitialized&&n&&(this.debug&&console.log("Force reinitializing SDK..."),this.screenshotManager?.destroy(),this.screenshotManager=null,this.isInitialized=!1),this.config=A,this.debug=A.debug??!1;try{const n=await this.getDeviceId();this.debug&&console.log("Raw Device ID:",n);const r=this.getReferrer(A),o=Io.MD5(n+r).toString();this.debug&&(console.log("Raw Device ID:",n),console.log("MD5 Device ID (for frontend):",o),console.log("Referrer used:",r));const i={deviceId:o,referrer:r,agent:A.agent,timestamp:Date.now()},s=A.iconPosition??this.lastIconConfig?.position,a=A.target??this.lastIconConfig?.target;if(this.isIconConfigChanged(s,a)?(this.iconManager&&(this.iconManager.hide(),this.iconManager=null,this.debug&&console.log("Icon config changed, recreating icon manager")),this.iconManager=new e(s,this.debug,a,{sideAttach:A.sideAttach??!0,sideHideRatio:A.sideHideRatio??.5,magnetic:A.magnetic??!0,magneticDirection:A.magneticDirection??"x",margin:A.margin??10,autoAttachDelay:A.autoAttachDelay??3e3}),await this.iconManager.show(),this.lastIconConfig={position:s,target:a}):(this.iconManager?(await this.iconManager.show(),this.debug&&console.log("Icon config unchanged, keeping existing icon manager")):(this.iconManager=new e(s,this.debug,a,{sideAttach:A.sideAttach??!0,sideHideRatio:A.sideHideRatio??.5,magnetic:A.magnetic??!0,magneticDirection:A.magneticDirection??"x",margin:A.margin??10,autoAttachDelay:A.autoAttachDelay??3e3}),await this.iconManager.show()),this.lastIconConfig={position:s,target:a}),this.iconManager.onClick(()=>{this.clearNotification()}),A.screenshot){const e=document.body,n={...A.screenshot,debug:this.debug},r=t&&"sendData"in t?t.sendData:void 0;this.debug&&(console.log("[CustomerServiceSDK] 初始化截图管理器:"),console.log(" options:",t?"存在":"null/undefined",t),console.log(" sendData:",r?"存在":"undefined",typeof r)),this.screenshotManager=new dt(e,n,r),this.screenshotManager.enable(!0),this.debug&&console.log("CustomerSDK screenshot manager initialized and enabled")}return this.isInitialized=!0,this.initResult=i,this.debug&&console.log("CustomerSDK initialized successfully (icon + screenshot only)"),i}catch(A){console.error("Failed to initialize CustomerSDK:",A);try{this.iconManager&&(this.iconManager.hide(),this.iconManager=null),this.screenshotManager&&(this.screenshotManager.destroy(),this.screenshotManager=null),this.isInitialized=!1,this.initResult=null}catch(A){console.error("Error during cleanup after initialization failure:",A)}throw A}finally{this.isInitializing=!1}}showIcon(){this.iconManager?.show()}hideIcon(){this.iconManager?.hide()}setIconPosition(A){this.iconManager?.setPosition(A)}setIconCoordinates(A){this.iconManager?.setIconPosition(A)}setIconStyle(A){this.iconManager?.setStyle(A)}onIconClick(A){this.iconManager?.onClick(A)}getConnectionStatus(){return this.isInitialized}showNotification(A=1,e={}){this.iconManager?(this.iconManager.showNotification({badgeCount:"string"==typeof A?0:A,badgeText:"string"==typeof A?A:"",pulse:e.pulse||!1}),e.autoHide&&e.autoHide>0&&setTimeout(()=>{this.iconManager?.clearNotification()},e.autoHide)):this.debug&&console.warn("SDK not initialized")}clearNotification(){this.iconManager?.clearNotification()}setScreenshotTarget(A){this.screenshotManager?.setTargetElement(A)}async captureScreenshot(A=!1){return this.screenshotManager?await this.screenshotManager.captureOnce(A):(this.debug&&console.warn("截图功能未启用"),!1)}enableScreenshot(A){this.screenshotManager?(this.screenshotManager.enable(A),this.debug&&console.log("📸 截图功能已"+(A?"启用":"禁用"))):this.debug&&console.warn("截图管理器未初始化")}getScreenshotState(){return this.screenshotManager?.getState()||null}updateScreenshotOptions(A){this.screenshotManager?(this.screenshotManager.updateOptions(A),this.debug&&console.log("📸 截图配置已更新:",A)):this.debug&&console.warn("截图管理器未初始化,无法更新配置")}triggerScreenshotConfig(A){this.screenshotManager?(this.screenshotManager.handleScreenshotConfig(A),this.debug&&console.log("[CustomerServiceSDK] Screenshot config triggered:",A)):this.debug&&console.warn("[CustomerServiceSDK] ScreenshotManager not initialized")}destroy(){this.iconManager?.hide(),this.screenshotManager?.destroy(),this.iconManager=null,this.screenshotManager=null,this.config=null,this.initResult=null,this.lastIconConfig=null,this.isInitialized=!1,this.debug&&console.log("CustomerSDK destroyed")}getInitResult(){return this.initResult}async generateInitResult(A){const e=await this.getDeviceId(),t=this.config?.referrer||this.getReferrer(this.config||{}),n=Io.MD5(e+t).toString(),r=A||this.config?.agent;return this.debug&&console.log("Generated InitResult:",{deviceId:n,referrer:t,agent:r,timestamp:Date.now()}),{deviceId:n,referrer:t,agent:r,timestamp:Date.now()}}async getDeviceId(){this.debug&&console.log("🔍 Starting to get device fingerprint...");try{this.debug&&console.log("📦 Loading FingerprintJS...");const A=await Gn.load();this.debug&&console.log("🎯 Getting device fingerprint...");const e=await A.get();return this.debug&&(console.log("✅ FingerprintJS result:",e),console.log("🆔 Device ID obtained:",e.visitorId)),e.visitorId}catch(A){this.debug&&console.warn("❌ Failed to get device fingerprint, using fallback:",A);const e="device_"+Date.now()+"_"+Math.random().toString(36).substr(2,9);return this.debug&&console.log("🆔 Fallback Device ID:",e),e}}isIconConfigChanged(A,e){if(!this.lastIconConfig)return!0;const t=JSON.stringify(this.lastIconConfig.position)!==JSON.stringify(A),n=this.lastIconConfig.target;let r=!1;return n!==e&&(r="string"==typeof n&&"string"==typeof e?n!==e:(n instanceof HTMLElement&&HTMLElement,!0)),t||r}getReferrer(A){return A.referrer||document.referrer||document.location.href}}let So=null;const Lo=async(A,e,t=!1)=>(So||(So=new xo),await So.init(A,e,t)),Do=()=>{if(!So)throw new Error("SDK not initialized. Call init() first.");return So},Mo=()=>{Do().showIcon()},ko=()=>{Do().hideIcon()},Ko=A=>{Do().setIconPosition(A)},To=A=>{Do().setIconCoordinates(A)},Ro=A=>{Do().setIconStyle(A)},Po=A=>{Do().onIconClick(A)},Oo=()=>Do().getConnectionStatus(),Vo=()=>Do().getInitResult(),No=async A=>{const e=Do();return await e.generateInitResult(A)},Go=(A=1,e={})=>{Do().showNotification(A,e)},Wo=()=>{Do().clearNotification()},_o=()=>{Do().destroy(),So=null},Xo=A=>{Do().setScreenshotTarget(A)},Jo=async(A=!1)=>{const e=Do();return await e.captureScreenshot(A)},Yo=A=>{Do().enableScreenshot(A)},$o=()=>Do().getScreenshotState(),Zo=A=>{Do().updateScreenshotOptions(A)},zo=A=>{Do().triggerScreenshotConfig(A)};var jo={init:Lo,getInstance:Do,getInitResult:Vo,generateInitResult:No,showIcon:Mo,hideIcon:ko,setIconPosition:Ko,setIconCoordinates:To,setIconStyle:Ro,onIconClick:Po,getConnectionStatus:Oo,showNotification:Go,clearNotification:Wo,setScreenshotTarget:Xo,captureScreenshot:Jo,enableScreenshot:Yo,getScreenshotState:$o,updateScreenshotOptions:Zo,triggerScreenshotConfig:zo,destroy:_o};A.CustomerSDK=class{constructor(){this.iconManager=null,this.screenshotManager=null,this.debug=!1,this.deviceId=null,this.initResult=null,this.config=null,this.screenshotCallback=null,this.initCallback=null}async init(A,t,n){try{this.config=A,this.screenshotCallback=t||null,this.initCallback=n||null,this.debug=A.debug??!1;const r=await this.getRawDeviceId();this.debug&&console.log("Raw Device ID:",r);const o=A.referrer||document.referrer||document.location.href;this.deviceId=Io.MD5(r+o).toString(),this.debug&&(console.log("MD5 Device ID (for frontend):",this.deviceId),console.log("Referrer used:",o));const i={deviceId:this.deviceId,referrer:o,agent:A.agent,timestamp:Date.now()},s=A.target||void 0,a=A.iconPosition||void 0;if(this.iconManager=new e(a,this.debug,s,{sideAttach:A.sideAttach,sideHideRatio:A.sideHideRatio,magnetic:A.magnetic,magneticDirection:A.magneticDirection,margin:A.margin,autoAttachDelay:A.autoAttachDelay}),await this.iconManager.show(),n?.onIconClick&&this.iconManager.onClick(n.onIconClick),A.screenshot){const e="string"==typeof s?document.querySelector(s):s||document.body,n=t?.sendData;this.debug&&(console.log("[CustomerSDK] 初始化截图管理器:"),console.log(" screenshotCallback:",t?"存在":"null/undefined",t),console.log(" screenshotCallback?.sendData:",t?.sendData?"存在":"null/undefined",typeof t?.sendData,t?.sendData),console.log(" sendToExternal:",n?"存在":"undefined",typeof n,n),console.log(" 即将传递给 ScreenshotManager 的参数:",{targetElement:e?"存在":"null",screenshot:A.screenshot?"存在":"null",sendToExternal:n?"存在":"undefined"})),this.screenshotManager=new dt(e,A.screenshot,n),t?.onConfig&&this.setupScreenshotConfigListener(t.onConfig)}return this.initResult=i,this.debug&&console.log("CustomerSDK initialized successfully (icon + screenshot only)"),i}catch(A){throw console.error("Failed to initialize CustomerSDK:",A),A}}setupScreenshotConfigListener(A){const e=e=>{try{if(!e.data||"checkScreenshot"!==e.data.type)return;this.debug&&console.log("[CustomerSDK] Received screenshot config message:",e.data),e.data.data&&"string"==typeof e.data.data&&A(e.data.data)}catch(A){this.debug&&console.error("[CustomerSDK] Error handling screenshot config message:",A)}};window.addEventListener("message",e),this._screenshotConfigHandler=e}triggerScreenshotConfig(A){this.screenshotManager?this.screenshotManager.handleScreenshotConfig(A):this.debug&&console.warn("[CustomerSDK] ScreenshotManager not initialized")}hideIcon(){this.iconManager?.hide()}showIcon(){this.iconManager?.show()}onIconClick(A){this.iconManager?.onClick(A)}getScreenshotManager(){return this.screenshotManager}getIconManager(){return this.iconManager}getDeviceId(){return this.deviceId}getInitResult(){return this.initResult}async updateToken(A,e,t){if(!this.config)throw new Error("SDK not initialized. Call init() first.");this.debug&&console.log("Updating token:",A?"Token provided":"Token removed");const n={...this.config,token:A&&""!==A.trim()?A:void 0};return this.destroy(),await this.init(n,e||this.screenshotCallback||void 0,t||this.initCallback||void 0)}async getRawDeviceId(){this.debug&&console.log("🔍 Starting to get device fingerprint...");try{this.debug&&console.log("📦 Loading FingerprintJS...");const A=await Gn.load();this.debug&&console.log("🎯 Getting device fingerprint...");const e=await A.get();return this.debug&&(console.log("✅ FingerprintJS result:",e),console.log("🆔 Device ID obtained:",e.visitorId)),e.visitorId}catch(A){this.debug&&console.warn("❌ Failed to get device fingerprint, using fallback:",A);const e="device_"+Date.now()+"_"+Math.random().toString(36).substr(2,9);return this.debug&&console.log("🆔 Fallback Device ID:",e),e}}showNotification(A=1,e={}){this.iconManager?(this.iconManager.showNotification({badgeCount:"string"==typeof A?0:A,badgeText:"string"==typeof A?A:"",pulse:e.pulse||!1}),e.autoHide&&e.autoHide>0&&setTimeout(()=>{this.iconManager?.clearNotification()},e.autoHide)):this.debug&&console.warn("SDK not initialized")}clearNotification(){this.iconManager?.clearNotification()}destroy(){this.iconManager?.hide(),this.screenshotManager?.destroy(),this._screenshotConfigHandler&&(window.removeEventListener("message",this._screenshotConfigHandler),this._screenshotConfigHandler=null),this.iconManager=null,this.screenshotManager=null,this.initResult=null,this.deviceId=null,this.debug&&console.log("CustomerSDK destroyed")}},A.CustomerServiceSDK=xo,A.captureScreenshot=Jo,A.clearNotification=Wo,A.default=jo,A.destroy=_o,A.enableScreenshot=Yo,A.generateInitResult=No,A.getConnectionStatus=Oo,A.getInitResult=Vo,A.getInstance=Do,A.getScreenshotState=$o,A.hideIcon=ko,A.init=Lo,A.onIconClick=Po,A.setIconCoordinates=To,A.setIconPosition=Ko,A.setIconStyle=Ro,A.setScreenshotTarget=Xo,A.showIcon=Mo,A.showNotification=Go,A.triggerScreenshotConfig=zo,A.updateScreenshotOptions=Zo,Object.defineProperty(A,"__esModule",{value:!0})});
|
package/dist/index.d.ts
CHANGED
|
@@ -16,11 +16,11 @@ export declare class CustomerServiceSDK {
|
|
|
16
16
|
/**
|
|
17
17
|
* 初始化 SDK
|
|
18
18
|
* @param config SDK配置
|
|
19
|
-
* @param options UI
|
|
19
|
+
* @param options UI选项 或 截图回调(可选)
|
|
20
20
|
* @param forceReinit 是否强制重新初始化(用于更新token等配置)
|
|
21
21
|
* @returns 返回初始化信息(包含设备ID等)
|
|
22
22
|
*/
|
|
23
|
-
init(config: SDKConfig,
|
|
23
|
+
init(config: SDKConfig, options?: ChatWindowOptions | import('./core/CustomerSDK').ScreenshotMessageCallback, forceReinit?: boolean): Promise<InitResult>;
|
|
24
24
|
/**
|
|
25
25
|
* 显示/隐藏悬浮图标
|
|
26
26
|
*/
|
|
@@ -129,11 +129,11 @@ export declare class CustomerServiceSDK {
|
|
|
129
129
|
/**
|
|
130
130
|
* 初始化 Customer SDK
|
|
131
131
|
* @param config SDK配置
|
|
132
|
-
* @param options UI
|
|
132
|
+
* @param options UI选项 或 截图回调(可选)
|
|
133
133
|
* @param forceReinit 是否强制重新初始化(用于更新token等配置)
|
|
134
134
|
* @returns 返回初始化信息(包含设备ID等)
|
|
135
135
|
*/
|
|
136
|
-
export declare const init: (config: SDKConfig, options?: ChatWindowOptions, forceReinit?: boolean) => Promise<InitResult>;
|
|
136
|
+
export declare const init: (config: SDKConfig, options?: ChatWindowOptions | import("./core/CustomerSDK").ScreenshotMessageCallback, forceReinit?: boolean) => Promise<InitResult>;
|
|
137
137
|
/**
|
|
138
138
|
* 获取全局SDK实例
|
|
139
139
|
*/
|
|
@@ -201,7 +201,7 @@ export declare const updateScreenshotOptions: (options: Partial<ScreenshotOption
|
|
|
201
201
|
*/
|
|
202
202
|
export declare const triggerScreenshotConfig: (configJson: string) => void;
|
|
203
203
|
declare const _default: {
|
|
204
|
-
init: (config: SDKConfig, options?: ChatWindowOptions, forceReinit?: boolean) => Promise<InitResult>;
|
|
204
|
+
init: (config: SDKConfig, options?: ChatWindowOptions | import("./core/CustomerSDK").ScreenshotMessageCallback, forceReinit?: boolean) => Promise<InitResult>;
|
|
205
205
|
getInstance: () => CustomerServiceSDK;
|
|
206
206
|
getInitResult: () => InitResult | null;
|
|
207
207
|
generateInitResult: (agent?: string) => Promise<InitResult>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIjH;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CA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AI;0CAS9B,MAAM,KAAG,IAAI;mBAtCtC,IAAI;;AA6C/B,wBAqBC;AAGD,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,CAAA;AAGvG,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA"}
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 使用 Interact.js 的 IconManager 示例实现
|
|
3
|
-
*
|
|
4
|
-
* 安装:pnpm add interactjs
|
|
5
|
-
*
|
|
6
|
-
* 这个文件展示了如何使用 Interact.js 替代自定义拖动实现
|
|
7
|
-
* 可以将这个实现替换到 IconManager.ts 中
|
|
8
|
-
*/
|
|
9
|
-
export declare class IconManagerWithInteract {
|
|
10
|
-
private iconElement;
|
|
11
|
-
private interactable;
|
|
12
|
-
private target;
|
|
13
|
-
private debug;
|
|
14
|
-
constructor(target?: HTMLElement | string, debug?: boolean);
|
|
15
|
-
show(): Promise<void>;
|
|
16
|
-
private setupInteractDrag;
|
|
17
|
-
/**
|
|
18
|
-
* 获取拖动约束
|
|
19
|
-
*/
|
|
20
|
-
private getRestriction;
|
|
21
|
-
/**
|
|
22
|
-
* 获取目标元素
|
|
23
|
-
*/
|
|
24
|
-
private getTargetElement;
|
|
25
|
-
/**
|
|
26
|
-
* 处理点击事件
|
|
27
|
-
*/
|
|
28
|
-
private handleClick;
|
|
29
|
-
/**
|
|
30
|
-
* 清理 Interact.js
|
|
31
|
-
*/
|
|
32
|
-
private cleanupInteract;
|
|
33
|
-
hide(): void;
|
|
34
|
-
destroy(): void;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=IconManager.interact.example.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IconManager.interact.example.d.ts","sourceRoot":"","sources":["../../src/core/IconManager.interact.example.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,KAAK,CAAiB;gBAElB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE,KAAK,GAAE,OAAe;IAK3D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB3B,OAAO,CAAC,iBAAiB;IAgGzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAiBtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB,IAAI,IAAI,IAAI;IAUZ,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
interface IframeOptions {
|
|
2
|
-
src?: string;
|
|
3
|
-
mode?: 'auto' | 'fullscreen' | 'popup';
|
|
4
|
-
width?: number;
|
|
5
|
-
height?: number;
|
|
6
|
-
draggable?: boolean;
|
|
7
|
-
resizable?: boolean;
|
|
8
|
-
allowClose?: boolean;
|
|
9
|
-
target?: HTMLElement | string;
|
|
10
|
-
onMessage?: (messageType: string, data: any) => void;
|
|
11
|
-
onClose?: () => void;
|
|
12
|
-
debug?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare class IframeManager {
|
|
15
|
-
private config;
|
|
16
|
-
private iframeElement;
|
|
17
|
-
private containerElement;
|
|
18
|
-
private isOpen;
|
|
19
|
-
private isCreated;
|
|
20
|
-
private debug;
|
|
21
|
-
private targetElement;
|
|
22
|
-
private messageHandler;
|
|
23
|
-
constructor(config?: IframeOptions);
|
|
24
|
-
/**
|
|
25
|
-
* 初始化iframe(隐藏状态)
|
|
26
|
-
* 预创建iframe并连接到SSE,但不显示
|
|
27
|
-
*/
|
|
28
|
-
init(): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* 显示iframe聊天窗口
|
|
31
|
-
*/
|
|
32
|
-
show(): void;
|
|
33
|
-
/**
|
|
34
|
-
* 打开iframe聊天窗口(保持兼容性)
|
|
35
|
-
*/
|
|
36
|
-
open(): void;
|
|
37
|
-
/**
|
|
38
|
-
* 隐藏iframe聊天窗口(类似v-show)
|
|
39
|
-
*/
|
|
40
|
-
hide(): void;
|
|
41
|
-
/**
|
|
42
|
-
* 关闭iframe聊天窗口(完全销毁,保持兼容性)
|
|
43
|
-
*/
|
|
44
|
-
close(): void;
|
|
45
|
-
/**
|
|
46
|
-
* 完全销毁iframe(需要时才调用)
|
|
47
|
-
*/
|
|
48
|
-
destroy(): void;
|
|
49
|
-
/**
|
|
50
|
-
* 检查是否已打开
|
|
51
|
-
*/
|
|
52
|
-
isIframeOpen(): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* 向iframe发送消息
|
|
55
|
-
*/
|
|
56
|
-
sendToIframe(data: any): void;
|
|
57
|
-
/**
|
|
58
|
-
* 清理页面上孤立的容器元素(防止重复创建)
|
|
59
|
-
*/
|
|
60
|
-
private cleanupOrphanedElements;
|
|
61
|
-
/**
|
|
62
|
-
* 创建iframe(默认隐藏状态,用于SSE连接)
|
|
63
|
-
*/
|
|
64
|
-
private createIframe;
|
|
65
|
-
/**
|
|
66
|
-
* 向iframe注入移动端优化样式(隐藏滚动条)
|
|
67
|
-
*/
|
|
68
|
-
private injectMobileStyles;
|
|
69
|
-
/**
|
|
70
|
-
* 控制页面滚动(移动端全屏模式使用)
|
|
71
|
-
*/
|
|
72
|
-
private preventBodyScroll;
|
|
73
|
-
/**
|
|
74
|
-
* 检测设备类型
|
|
75
|
-
*/
|
|
76
|
-
private isMobileDevice;
|
|
77
|
-
/**
|
|
78
|
-
* 获取当前显示模式
|
|
79
|
-
* PC 模式使用弹窗,移动端使用全屏
|
|
80
|
-
*/
|
|
81
|
-
private getActualMode;
|
|
82
|
-
/**
|
|
83
|
-
* 设置消息监听
|
|
84
|
-
*/
|
|
85
|
-
private setupMessageListener;
|
|
86
|
-
/**
|
|
87
|
-
* 处理来自iframe的消息
|
|
88
|
-
*/
|
|
89
|
-
private handleIframeMessage;
|
|
90
|
-
/**
|
|
91
|
-
* 向调用 SDK 的地方(Vue 页面)广播消息
|
|
92
|
-
* 通过 window.dispatchEvent 触发事件,让 Vue 页面中的 window.addEventListener('message') 可以收到
|
|
93
|
-
*
|
|
94
|
-
* 重要说明:
|
|
95
|
-
* 1. window.dispatchEvent 创建的事件会在同一窗口内触发所有监听器,无论 origin 是什么,Vue 页面都能收到
|
|
96
|
-
* 2. MessageEvent 的 origin 属性不能是 '*',必须是有效的 origin 字符串(如 'http://localhost:5173')
|
|
97
|
-
* 3. 我们使用 window.location.origin 来标识消息来源(当前页面的 origin)
|
|
98
|
-
* 4. 如果 Vue 页面需要检查 origin,应该检查 window.location.origin 而不是 '*'
|
|
99
|
-
*/
|
|
100
|
-
private broadcastMessageToPage;
|
|
101
|
-
/**
|
|
102
|
-
* 调整iframe大小(PC模式支持)
|
|
103
|
-
*/
|
|
104
|
-
private resizeIframe;
|
|
105
|
-
/**
|
|
106
|
-
* 获取目标元素(支持字符串选择器或 HTMLElement)
|
|
107
|
-
*/
|
|
108
|
-
private getTargetElement;
|
|
109
|
-
}
|
|
110
|
-
export {};
|
|
111
|
-
//# sourceMappingURL=IframeManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IframeManager.d.ts","sourceRoot":"","sources":["../../src/core/IframeManager.ts"],"names":[],"mappings":"AACA,UAAU,aAAa;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAA;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IAC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OAAO,CAAC,mBAAmB;IAyG3B;;;;;;;;;OASG;IACH,OAAO,CAAC,sBAAsB;IA+B9B;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CA0BzB"}
|
package/dist/core/SimpleSDK.d.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { IconManager } from './IconManager';
|
|
2
|
-
import { ScreenshotManager, ScreenshotOptions } from './ScreenshotManager';
|
|
3
|
-
/**
|
|
4
|
-
* 简化的 SDK 配置(不包含 iframe)
|
|
5
|
-
*/
|
|
6
|
-
export interface CustomerSimpleSDKConfig {
|
|
7
|
-
debug?: boolean;
|
|
8
|
-
screenshot?: ScreenshotOptions;
|
|
9
|
-
iconPosition?: {
|
|
10
|
-
x?: number | string;
|
|
11
|
-
y?: number | string;
|
|
12
|
-
};
|
|
13
|
-
iconTarget?: HTMLElement | string;
|
|
14
|
-
sideAttach?: boolean;
|
|
15
|
-
sideHideRatio?: number;
|
|
16
|
-
magnetic?: boolean;
|
|
17
|
-
magneticDirection?: 'x' | 'y' | 'both';
|
|
18
|
-
margin?: number;
|
|
19
|
-
autoAttachDelay?: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* 截图消息回调接口
|
|
23
|
-
*/
|
|
24
|
-
export interface ScreenshotMessageCallback {
|
|
25
|
-
/**
|
|
26
|
-
* 接收来自外部的截图配置消息
|
|
27
|
-
* @param config 二进制配置(BinaryConfig 的 JSON 字符串)
|
|
28
|
-
*/
|
|
29
|
-
onConfig?: (config: string) => void;
|
|
30
|
-
/**
|
|
31
|
-
* 发送截图数据到外部
|
|
32
|
-
* @param data 截图数据(BinaryMessage 格式)
|
|
33
|
-
*/
|
|
34
|
-
sendData?: (data: any) => void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 简化的 SDK(只包含图标和截图功能)
|
|
38
|
-
* 不包含 iframe 管理,适用于弹窗组件场景
|
|
39
|
-
*/
|
|
40
|
-
export declare class CustomerSimpleSDK {
|
|
41
|
-
private iconManager;
|
|
42
|
-
private screenshotManager;
|
|
43
|
-
private debug;
|
|
44
|
-
constructor();
|
|
45
|
-
/**
|
|
46
|
-
* 初始化 SDK
|
|
47
|
-
*/
|
|
48
|
-
init(config: CustomerSimpleSDKConfig, screenshotCallback?: ScreenshotMessageCallback): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* 设置截图配置监听器(可选,用于兼容 postMessage 场景)
|
|
51
|
-
* 对于弹窗组件场景,建议直接使用 triggerScreenshotConfig 方法
|
|
52
|
-
*/
|
|
53
|
-
private setupScreenshotConfigListener;
|
|
54
|
-
/**
|
|
55
|
-
* 触发截图配置(用于弹窗组件场景)
|
|
56
|
-
* 当弹窗组件需要启用截图功能时,调用此方法传入配置
|
|
57
|
-
* @param configJson 截图配置的 JSON 字符串(BinaryConfig 格式)
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* // 从后端或弹窗组件获取配置
|
|
62
|
-
* const config = {
|
|
63
|
-
* agent: 'xxx',
|
|
64
|
-
* sign: 'xxx',
|
|
65
|
-
* type: 1,
|
|
66
|
-
* topic: 'xxx',
|
|
67
|
-
* routingKey: 'xxx',
|
|
68
|
-
* ttl: Date.now() + 3600000,
|
|
69
|
-
* duration: 5000
|
|
70
|
-
* }
|
|
71
|
-
* sdk.triggerScreenshotConfig(JSON.stringify(config))
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
triggerScreenshotConfig(configJson: string): void;
|
|
75
|
-
/**
|
|
76
|
-
* 隐藏图标
|
|
77
|
-
*/
|
|
78
|
-
hideIcon(): void;
|
|
79
|
-
/**
|
|
80
|
-
* 显示图标
|
|
81
|
-
*/
|
|
82
|
-
showIcon(): void;
|
|
83
|
-
/**
|
|
84
|
-
* 设置图标点击回调
|
|
85
|
-
*/
|
|
86
|
-
onIconClick(callback: () => void): void;
|
|
87
|
-
/**
|
|
88
|
-
* 显示消息通知
|
|
89
|
-
*/
|
|
90
|
-
showNotification(badgeCount?: number | string, options?: {
|
|
91
|
-
pulse?: boolean;
|
|
92
|
-
autoHide?: number;
|
|
93
|
-
}): void;
|
|
94
|
-
/**
|
|
95
|
-
* 清除消息通知
|
|
96
|
-
*/
|
|
97
|
-
clearNotification(): void;
|
|
98
|
-
/**
|
|
99
|
-
* 获取截图管理器实例(用于高级操作)
|
|
100
|
-
*/
|
|
101
|
-
getScreenshotManager(): ScreenshotManager | null;
|
|
102
|
-
/**
|
|
103
|
-
* 获取图标管理器实例(用于高级操作)
|
|
104
|
-
*/
|
|
105
|
-
getIconManager(): IconManager | null;
|
|
106
|
-
/**
|
|
107
|
-
* 销毁 SDK
|
|
108
|
-
*/
|
|
109
|
-
destroy(): void;
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=SimpleSDK.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleSDK.d.ts","sourceRoot":"","sources":["../../src/core/SimpleSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE1E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,iBAAiB,CAAA;IAE9B,YAAY,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC3D,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IACjC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iBAAiB,CAAC,EAAE,GAAG,GAAG,GAAG,GAA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@@
|
|
|
1
|
-
/**
|
|
2
|
-
* 简化版 SDK 导出(只包含图标和截图功能)
|
|
3
|
-
* 适用于需要自行管理 iframe 或弹窗组件的项目
|
|
4
|
-
*/
|
|
5
|
-
export { CustomerSimpleSDK } from './core/SimpleSDK';
|
|
6
|
-
export type { CustomerSimpleSDKConfig, ScreenshotMessageCallback } from './core/SimpleSDK';
|
|
7
|
-
export { CustomerSimpleSDK as SimpleSDK } from './core/SimpleSDK';
|
|
8
|
-
export type { CustomerSimpleSDKConfig as SimpleSDKConfig } from './core/SimpleSDK';
|
|
9
|
-
export { IconManager } from './core/IconManager';
|
|
10
|
-
export { ScreenshotManager } from './core/ScreenshotManager';
|
|
11
|
-
export type { ScreenshotOptions } from './core/ScreenshotManager';
|
|
12
|
-
export type { BinaryConfig } from './core/ScreenshotManager';
|
|
13
|
-
export type { IconPosition } from './types';
|
|
14
|
-
//# sourceMappingURL=simple.d.ts.map
|
package/dist/simple.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple.d.ts","sourceRoot":"","sources":["../src/simple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,YAAY,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAG1F,OAAO,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,uBAAuB,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAG5D,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA"}
|