@sensorswave/js-sdk 0.3.0 → 0.3.2

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/README.md ADDED
@@ -0,0 +1,374 @@
1
+ # SensorsWave JS SDK
2
+
3
+ [SensorsWave](http://sensorswave.com/) JS SDK is a web analytics tracking library.
4
+ If you're new to SensorWave, check out our product and create an account at [sensorswave.com](http://sensorswave.com/).
5
+
6
+ ## SDK Usage
7
+
8
+ ### 1. Install via npm
9
+
10
+ ```bash
11
+ npm install @sensorswave/js-sdk
12
+ ```
13
+
14
+ ### 2. Import as ES Module
15
+
16
+ ```javascript
17
+ import SensorsWave from '@sensorswave/js-sdk';
18
+ SensorsWave.init('your-api-token', {
19
+ debug: false,
20
+ apiHost: 'https://your-api-host.com',
21
+ autoCapture: true
22
+ });
23
+ ```
24
+
25
+ ### 3. Import via Script Tag
26
+
27
+ ```html
28
+ <script src="/path/to/index.js"></script>
29
+ <script>
30
+ SensorsWave.init('your-api-token', {
31
+ debug: false,
32
+ apiHost: 'https://your-api-host.com',
33
+ autoCapture: true
34
+ });
35
+ </script>
36
+ ```
37
+
38
+ ### 4. Send Custom Events
39
+
40
+ ```javascript
41
+ SensorsWave.trackEvent('button_click', {
42
+ buttonName: 'submit',
43
+ page: 'home'
44
+ });
45
+ ```
46
+
47
+ ## Configuration Options
48
+
49
+ | Option | Type | Default | Description |
50
+ |--------|------|---------|-------------|
51
+ | debug | boolean | false | Whether to enable debug mode for logging |
52
+ | apiHost | string | '' | API host address for sending events |
53
+ | autoCapture | boolean | true | Whether to automatically capture page events (page view, page load, page leave) |
54
+ | enableClickTrack | boolean | false | Whether to enable automatic click tracking on all elements |
55
+ | isSinglePageApp | boolean | false | Whether the application is a Single Page Application (enables automatic route change tracking) |
56
+ | crossSubdomainCookie | boolean | true | Whether to share cookies across subdomains |
57
+ | enableAB | boolean | false | Whether to enable A/B testing feature |
58
+ | abRefreshInterval | number | 600000 (10 minutes) | The interval in milliseconds for refreshing A/B test configuration |
59
+ | batchSend | boolean | true | Whether to use batch sending (sends events in batches up to 10 events every 5 seconds) |
60
+
61
+ ## API Methods
62
+
63
+ ### Event Tracking
64
+
65
+ #### trackEvent
66
+
67
+ Manually track a custom event with properties.
68
+
69
+ **Parameters:**
70
+ - `eventName` (string, required): The name of the event to track
71
+ - `properties` (Object, optional): Additional properties to include with the event
72
+
73
+ **Example:**
74
+ ```javascript
75
+ SensorsWave.trackEvent('button_click', {
76
+ buttonName: 'submit',
77
+ page: 'home',
78
+ category: 'user_action'
79
+ });
80
+ ```
81
+
82
+ #### track
83
+
84
+ Track an event with full control over the event structure. This is an advanced method that allows you to specify all event fields manually.
85
+
86
+ **Parameters:**
87
+ - `event` (AdvanceEvent, required): Complete event object with the following structure:
88
+ - `event` (string, required): Event name
89
+ - `properties` (Record<string, any>, optional): Event properties
90
+ - `time` (number, required): Timestamp in milliseconds
91
+ - `anon_id` (string, optional): Anonymous user ID
92
+ - `login_id` (string, optional): Logged-in user ID
93
+ - `trace_id` (string, required): Trace ID for request tracking
94
+ - `user_properties` (Record<string, any>, optional): User properties
95
+ - `subject_properties` (Record<string, any>, optional): Subject properties
96
+
97
+ **Example:**
98
+ ```javascript
99
+ SensorsWave.track({
100
+ event: 'purchase_completed',
101
+ properties: {
102
+ product_id: '12345',
103
+ amount: 99.99,
104
+ currency: 'USD'
105
+ },
106
+ time: Date.now(),
107
+ trace_id: 'unique-trace-id-12345',
108
+ anon_id: 'anonymous-user-id',
109
+ login_id: 'user@example.com',
110
+ user_properties: {
111
+ plan: 'premium',
112
+ signup_date: '2024-01-01'
113
+ }
114
+ });
115
+ ```
116
+
117
+ ### User Profile
118
+
119
+ #### profileSet
120
+
121
+ Set user properties. If a property already exists, it will be overwritten.
122
+
123
+ **Parameters:**
124
+ - `properties` (Object, required): User properties to set
125
+
126
+ **Example:**
127
+ ```javascript
128
+ SensorsWave.profileSet({
129
+ name: 'John Doe',
130
+ email: 'john@example.com',
131
+ age: 30,
132
+ plan: 'premium'
133
+ });
134
+ ```
135
+
136
+ #### profileSetOnce
137
+
138
+ Set user properties only if they don't already exist. Existing properties will not be overwritten.
139
+
140
+ **Parameters:**
141
+ - `properties` (Object, required): User properties to set once
142
+
143
+ **Example:**
144
+ ```javascript
145
+ SensorsWave.profileSetOnce({
146
+ signup_date: '2024-01-15',
147
+ initial_referrer: 'google',
148
+ initial_campaign: 'spring_sale'
149
+ });
150
+ ```
151
+
152
+ #### profileIncrement
153
+
154
+ Increment numeric user properties by a specified amount. Only supports numeric properties.
155
+
156
+ **Parameters:**
157
+ - `properties` (Object, required): Properties to increment with numeric values
158
+
159
+ **Example:**
160
+ ```javascript
161
+ // Increment single property
162
+ SensorsWave.profileIncrement({
163
+ login_count: 1
164
+ });
165
+
166
+ // Increment multiple properties
167
+ SensorsWave.profileIncrement({
168
+ login_count: 1,
169
+ points_earned: 100,
170
+ purchases_count: 1
171
+ });
172
+ ```
173
+
174
+ #### profileAppend
175
+
176
+ Append new values to list-type user properties without deduplication.
177
+
178
+ **Parameters:**
179
+ - `properties` (Object, required): Properties with array values to append
180
+
181
+ **Example:**
182
+ ```javascript
183
+ SensorsWave.profileAppend({
184
+ categories_viewed: ['electronics', 'mobile_phones'],
185
+ tags: ['new_customer', 'q1_2024']
186
+ });
187
+ ```
188
+
189
+ #### profileUnion
190
+
191
+ Append new values to list-type user properties with deduplication (avoids duplicate values).
192
+
193
+ **Parameters:**
194
+ - `properties` (Object, required): Properties with array values to append with deduplication
195
+
196
+ **Example:**
197
+ ```javascript
198
+ SensorsWave.profileUnion({
199
+ interests: ['technology', 'gaming'],
200
+ newsletter_subscriptions: ['tech_news']
201
+ });
202
+ ```
203
+
204
+ #### profileUnset
205
+
206
+ Set specific user properties to null (effectively removing them).
207
+
208
+ **Parameters:**
209
+ - `propertyNames` (string | string[], required): Property name(s) to unset
210
+
211
+ **Example:**
212
+ ```javascript
213
+ // Unset single property
214
+ SensorsWave.profileUnset('temporary_campaign');
215
+
216
+ // Unset multiple properties
217
+ SensorsWave.profileUnset(['old_plan', 'expired_flag', 'temp_id']);
218
+ ```
219
+
220
+ #### profileDelete
221
+
222
+ Delete all user profile data for the current user. This operation cannot be undone.
223
+
224
+ **Example:**
225
+ ```javascript
226
+ SensorsWave.profileDelete();
227
+ ```
228
+
229
+ ### User Identification
230
+
231
+ #### identify
232
+
233
+ Set the login ID for the current user and send a binding event to associate anonymous behavior with the identified user.
234
+
235
+ **Parameters:**
236
+ - `loginId` (string | number, required): Unique identifier for the user (e.g., email, user ID, username)
237
+
238
+ **Example:**
239
+ ```javascript
240
+ SensorsWave.identify('user@example.com');
241
+ ```
242
+
243
+ #### setLoginId
244
+
245
+ Set the login ID for the current user without sending a binding event. Use this if you want to identify the user but don't need to track the association event.
246
+
247
+ **Parameters:**
248
+ - `loginId` (string | number, required): Unique identifier for the user
249
+
250
+ **Example:**
251
+ ```javascript
252
+ SensorsWave.setLoginId('user@example.com');
253
+ ```
254
+
255
+ ### Common Properties
256
+
257
+ #### registerCommonProperties
258
+
259
+ Register static or dynamic common properties that will be included with all events. This is useful for including global context like app version, environment, or user-specific data.
260
+
261
+ **Parameters:**
262
+ - `properties` (Record<string, string | Function>, required): Properties to register
263
+ - Static properties: string values
264
+ - Dynamic properties: functions that return values (evaluated for each event)
265
+
266
+ **Example:**
267
+ ```javascript
268
+ SensorsWave.registerCommonProperties({
269
+ // Static property
270
+ app_version: '1.0.0',
271
+ environment: 'production',
272
+
273
+ // Dynamic property (evaluated for each event)
274
+ current_time: () => new Date().toISOString(),
275
+ user_session_id: () => getSessionId(),
276
+
277
+ // You can also include user-specific data
278
+ user_tier: () => getUserTier()
279
+ });
280
+ ```
281
+
282
+ #### clearCommonProperties
283
+
284
+ Remove specific registered common properties.
285
+
286
+ **Parameters:**
287
+ - `propertyNames` (string[], required): Array of property names to remove
288
+
289
+ **Example:**
290
+ ```javascript
291
+ SensorsWave.clearCommonProperties(['app_version', 'user_session_id']);
292
+ ```
293
+
294
+ ### A/B Testing
295
+
296
+ #### checkFeatureGate
297
+
298
+ Check if a feature gate (feature flag) is enabled for the current user. Returns a promise that resolves to a boolean.
299
+
300
+ **Parameters:**
301
+ - `key` (string, required): The feature gate key to check
302
+
303
+ **Returns:** Promise<boolean>
304
+
305
+ **Example:**
306
+ ```javascript
307
+ // Check if a feature is enabled
308
+ SensorsWave.checkFeatureGate('new_checkout_flow')
309
+ .then(isEnabled => {
310
+ if (isEnabled) {
311
+ // Show new feature
312
+ showNewCheckout();
313
+ } else {
314
+ // Show old feature
315
+ showOldCheckout();
316
+ }
317
+ });
318
+
319
+ // Using async/await
320
+ async function initFeature() {
321
+ const isEnabled = await SensorsWave.checkFeatureGate('advanced_search');
322
+ if (isEnabled) {
323
+ enableAdvancedSearch();
324
+ }
325
+ }
326
+ ```
327
+
328
+ #### getExperiment
329
+
330
+ Get experiment variant data for the current user. Returns a promise that resolves to the experiment configuration.
331
+
332
+ **Parameters:**
333
+ - `key` (string, required): The experiment key to retrieve
334
+
335
+ **Returns:** Promise<Object>
336
+
337
+ The returned object contains:
338
+ - Record<string, any>: Variant configuration values
339
+
340
+ **Example:**
341
+ ```javascript
342
+ // Get experiment configuration
343
+ SensorsWave.getExperiment('homepage_layout')
344
+ .then(experiment => {
345
+ if (experiment) {
346
+ // Apply experiment configuration
347
+ applyLayout(experiment.layout_type);
348
+ }
349
+ });
350
+
351
+ // Using async/await
352
+ async function initExperiment() {
353
+ const experiment = await SensorsWave.getExperiment('pricing_display');
354
+ if (experiment) {
355
+ const { price_format, discount_type } = experiment;
356
+ updatePricingDisplay(price_format, discount_type);
357
+ }
358
+ }
359
+ ```
360
+
361
+ ## Supported Event Types
362
+
363
+ The SDK automatically captures the following event types when `autoCapture` is enabled:
364
+
365
+ - **PageView**: Triggered when a user views a page
366
+ - **PageLoad**: Triggered when a page finishes loading
367
+ - **PageLeave**: Triggered when a user is about to leave a page
368
+ - **WebClick**: Triggered on element clicks (only when `enableClickTrack` is true)
369
+
370
+ Custom events can be tracked using the `trackEvent()` or `track()` methods.
371
+
372
+ ## License
373
+
374
+ Apache-2.0
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";class e{constructor(){this.listeners={}}on(e,t,n=!1){if(e&&t){if(!s(t))throw new Error("listener must be a function");this.listeners[e]=this.listeners[e]||[],this.listeners[e].push({listener:t,once:n})}}off(e,t){const n=this.listeners[e];if(!n?.length)return;"number"==typeof t&&n.splice(t,1);const i=n.findIndex(e=>e.listener===t);-1!==i&&n.splice(i,1)}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((n,i)=>{n.listener.call(this,...t),n.listener.once&&this.off(e,i)})}once(e,t){this.on(e,t,!0)}removeAllListeners(e){e?this.listeners[e]=[]:this.listeners={}}}const t={get:function(e){const t=e+"=",n=document.cookie.split(";");for(let i=0,s=n.length;i<s;i++){let e=n[i];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(t))return h(e.substring(t.length,e.length))}return null},set:function({name:e,value:t,expires:n,samesite:i,secure:s,domain:r}){let o="",a="",l="",c="";if(0!==(n=null==n||void 0===n?365:n)){const e=new Date;"s"===String(n).slice(-1)?e.setTime(e.getTime()+1e3*Number(String(n).slice(0,-1))):e.setTime(e.getTime()+24*n*60*60*1e3),o="; expires="+e.toUTCString()}function u(e){return e?e.replace(/\r\n/g,""):""}i&&(l="; SameSite="+i),s&&(a="; secure");const h=u(e),d=u(t),g=u(r);g&&(c="; domain="+g),h&&d&&(document.cookie=h+"="+encodeURIComponent(d)+o+"; path=/"+c+l+a)},remove:function(e){this.set({name:e,value:"",expires:-1})},isSupport:function({samesite:e,secure:t}={}){if(!navigator.cookieEnabled)return!1;const n="sol_cookie_support_test";return this.set({name:n,value:"1",samesite:e,secure:t}),"1"===this.get(n)&&(this.remove(n),!0)}},n=Object.prototype.toString;function i(e){return"[object Object]"===n.call(e)}function s(e){const t=n.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function r(e){return"[object Array]"==n.call(e)}function o(e){return"[object String]"==n.call(e)}function a(e){return void 0===e}const l=Object.prototype.hasOwnProperty;function c(e){if(i(e)){for(let t in e)if(l.call(e,t))return!1;return!0}return!1}function u(e){return!(!e||1!==e.nodeType)}function h(e){let t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t}function d(e){try{return JSON.parse(e)}catch(t){return""}}const g=function(){let e=Date.now();return function(t){return Math.ceil((e=(9301*e+49297)%233280,e/233280*t))}}();function p(){if("function"==typeof Uint32Array){let e;if("undefined"!=typeof crypto&&(e=crypto),e&&i(e)&&e.getRandomValues)return e.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}return g(1e19)/1e19}const f=function(){function e(){let e=Date.now(),t=0;for(;e==Date.now();)t++;return e.toString(16)+t.toString(16)}return function(){let t=String(screen.height*screen.width);t=t&&/\d{5,}/.test(t)?t.toString():String(31242*p()).replace(".","").slice(0,8);return e()+"-"+p().toString(16).replace(".","")+"-"+function(){const e=navigator.userAgent;let t,n=[],i=0;function s(e,t){let i=0;for(let s=0;s<t.length;s++)i|=n[s]<<8*s;return e^i}for(let r=0;r<e.length;r++)t=e.charCodeAt(r),n.unshift(255&t),n.length>=4&&(i=s(i,n),n=[]);return n.length>0&&(i=s(i,n)),i.toString(16)}()+"-"+t+"-"+e()||(String(p())+String(p())+String(p())).slice(2,15)}}();function m(e,t){t&&"string"==typeof t||(t="");let n=null;try{n=new URL(e).hostname}catch(i){}return n||t}function E(e){let t=[];try{t=atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})}catch(n){t=[]}try{return decodeURIComponent(t.join(""))}catch(n){return t.join("")}}function I(e){let t="";try{t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}))}catch(n){t=e}return t}const S={get:function(e){return window.localStorage.getItem(e)},parse:function(e){let t;try{t=JSON.parse(S.get(e))||null}catch(n){console.warn(n)}return t},set:function(e,t){try{window.localStorage.setItem(e,t)}catch(n){console.warn(n)}},remove:function(e){window.localStorage.removeItem(e)},isSupport:function(){let e=!0;try{const t="__local_store_support__",n="testIsSupportStorage";S.set(t,n),S.get(t)!==n&&(e=!1),S.remove(t)}catch(t){e=!1}return e}};function w(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}const O={},A="0.3.0",_="init-ready",R="spa-switch",v="ff-ready",b="$PageLeave";var N=(e=>(e[e.FEATURE_GATE=1]="FEATURE_GATE",e[e.FEATURE_CONFIG=2]="FEATURE_CONFIG",e[e.EXPERIMENT=3]="EXPERIMENT",e))(N||{});const T=6e5,y={crossSubdomain:!1,requests:[],_sessionState:{},_abData:[],_trace_id:"",commonProps:{},_state:{anon_id:"",login_id:"",identities:{}},getIdentityCookieID(){return this._state.identities?.$identity_cookie_id||""},getCommonProps:function(){return this.commonProps||{}},setCommonProps:function(e){this.commonProps=e},getAnonId(){return this.getIdentityCookieID()||this._state.anon_id||f()},getLoginId(){return this._state.login_id},getTraceId(){return this._trace_id||f()},set:function(e,t){this._state[e]=t,this.save()},getCookieName:function(){return"sol2025jssdkcross"},getABLSName:function(){return"sol2025jssdkablatest"},save:function(){let e=JSON.parse(JSON.stringify(this._state));e.identities&&(e.identities=I(JSON.stringify(e.identities)));const n=JSON.stringify(e);t.set({name:this.getCookieName(),value:n,expires:365})},init:function(e){let n,s;this.crossSubdomain=e,t.isSupport()&&(n=t.get(this.getCookieName()),s=d(n)),y._state={...s||{}},y._state.identities&&(y._state.identities=d(E(y._state.identities))),y._state.identities&&i(y._state.identities)&&!c(y._state.identities)||(y._state.identities={$identity_cookie_id:f()}),y.save()},setLoginId(e){"number"==typeof e&&(e=String(e)),void 0!==e&&e&&(y.set("login_id",e),y.save())},saveABData(e){if(!e||c(e))return;this._abData=e;let t=JSON.parse(JSON.stringify(this._abData));t=I(JSON.stringify(t));try{localStorage.setItem(this.getABLSName(),JSON.stringify({time:Date.now(),data:t,anon_id:this.getAnonId(),login_id:this.getLoginId()}))}catch(n){console.warn("Failed to save abdata to localStorage",n)}},getABData(){try{let e=localStorage.getItem(this.getABLSName());if(e){const{time:t,data:n,login_id:i,anon_id:s}=d(e)||{};if(t&&n&&Date.now()-t<T&&s===this.getAnonId()&&(!i||i===this.getLoginId()))return d(E(n));localStorage.removeItem(this.getABLSName())}}catch(e){console.warn("Failed to load abdata from localStorage",e),this._abData=[]}return this._abData||[]}};function P(e){var t;if(e.data)return{contentType:"application/json",body:(t=e.data,JSON.stringify(t,(e,t)=>"bigint"==typeof t?t.toString():t,undefined))}}const C=[];function L(e){const t={...e};t.timeout=t.timeout||6e4;const n=t.transport??"fetch",i=C.find(e=>e.transport===n)?.method??C[0]?.method;if(!i)throw new Error("No available transport method for HTTP request");i(t)}function B(e){return o(e=e||document.referrer)&&(e=h(e=e.trim()))||""}function F(e){const t=m(e=e||B());if(!t)return"";const n={baidu:[/^.*\.baidu\.com$/],bing:[/^.*\.bing\.com$/],google:[/^www\.google\.com$/,/^www\.google\.com\.[a-z]{2}$/,/^www\.google\.[a-z]{2}$/],sm:[/^m\.sm\.cn$/],so:[/^.+\.so\.com$/],sogou:[/^.*\.sogou\.com$/],yahoo:[/^.*\.yahoo\.com$/],duckduckgo:[/^.*\.duckduckgo\.com$/]};for(let i of Object.keys(n)){let e=n[i];for(let n=0,s=e.length;n<s;n++)if(e[n].test(t))return i}return"Unknown Search Engine"}function M(e,t){return-1!==e.indexOf(t)}"function"==typeof fetch&&C.push({transport:"fetch",method:function(e){if("undefined"==typeof fetch)return void console.error("fetch API is not available");const t=P(e),n=new Headers;e.headers&&Object.keys(e.headers).forEach(t=>{n.append(t,e.headers[t])}),t?.contentType&&n.append("Content-Type",t.contentType),fetch(e.url,{method:e.method||"GET",headers:n,body:t?.body}).then(t=>t.text().then(n=>{const i={statusCode:t.status,text:n};if(200===t.status)try{i.json=JSON.parse(n)}catch(s){console.error("Failed to parse response:",s)}e.callback?.(i)})).catch(t=>{console.error("Request failed:",t),e.callback?.({statusCode:0,text:String(t)})})}}),"undefined"!=typeof XMLHttpRequest&&C.push({transport:"XHR",method:function(e){if("undefined"==typeof XMLHttpRequest)return void console.error("XMLHttpRequest is not available");const t=new XMLHttpRequest;t.open(e.method||"GET",e.url,!0);const n=P(e);e.headers&&Object.keys(e.headers).forEach(n=>{t.setRequestHeader(n,e.headers[n])}),n?.contentType&&t.setRequestHeader("Content-Type",n.contentType),t.timeout=e.timeout||6e4,t.withCredentials=!0,t.onreadystatechange=()=>{if(4===t.readyState){const i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(n){console.error("Failed to parse JSON response:",n)}e.callback?.(i)}},t.send(n?.body)}});const D={FACEBOOK:"Facebook",MOBILE:"Mobile",IOS:"iOS",ANDROID:"Android",TABLET:"Tablet",ANDROID_TABLET:"Android Tablet",IPAD:"iPad",APPLE:"Apple",APPLE_WATCH:"Apple Watch",SAFARI:"Safari",BLACKBERRY:"BlackBerry",SAMSUNG_BROWSER:"SamsungBrowser",SAMSUNG_INTERNET:"Samsung Internet",CHROME:"Chrome",CHROME_OS:"Chrome OS",CHROME_IOS:"Chrome iOS",INTERNET_EXPLORER:"Internet Explorer",INTERNET_EXPLORER_MOBILE:"Internet Explorer Mobile",OPERA:"Opera",OPERA_MINI:"Opera Mini",EDGE:"Edge",MICROSOFT_EDGE:"Microsoft Edge",FIREFOX:"Firefox",FIREFOX_IOS:"Firefox iOS",NINTENDO:"Nintendo",PLAYSTATION:"PlayStation",XBOX:"Xbox",ANDROID_MOBILE:"Android Mobile",MOBILE_SAFARI:"Mobile Safari",WINDOWS:"Windows",WINDOWS_PHONE:"Windows Phone",NOKIA:"Nokia",OUYA:"Ouya",GENERIC_MOBILE:"Generic mobile",GENERIC_TABLET:"Generic tablet",KONQUEROR:"Konqueror",UC_BROWSER:"UC Browser",HUAWEI:"Huawei",XIAOMI:"Xiaomi",OPPO:"OPPO",VIVO:"vivo"},x="(\\d+(\\.\\d+)?)",k=new RegExp("Version/"+x),H=new RegExp(D.XBOX,"i"),$=new RegExp(D.PLAYSTATION+" \\w+","i"),X=new RegExp(D.NINTENDO+" \\w+","i"),U=new RegExp(D.BLACKBERRY+"|PlayBook|BB10","i"),q=new RegExp("(HUAWEI|honor|HONOR)","i"),W=new RegExp("(Xiaomi|Redmi)","i"),G=new RegExp("(OPPO|realme)","i"),j=new RegExp("(vivo|IQOO)","i"),Y={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function z(e,t){return t=t||"",M(e," OPR/")&&M(e,"Mini")?D.OPERA_MINI:M(e," OPR/")?D.OPERA:U.test(e)?D.BLACKBERRY:M(e,"IE"+D.MOBILE)||M(e,"WPDesktop")?D.INTERNET_EXPLORER_MOBILE:M(e,D.SAMSUNG_BROWSER)?D.SAMSUNG_INTERNET:M(e,D.EDGE)||M(e,"Edg/")?D.MICROSOFT_EDGE:M(e,"FBIOS")?D.FACEBOOK+" "+D.MOBILE:M(e,"UCWEB")||M(e,"UCBrowser")?D.UC_BROWSER:M(e,"CriOS")?D.CHROME_IOS:M(e,"CrMo")||M(e,D.CHROME)?D.CHROME:M(e,D.ANDROID)&&M(e,D.SAFARI)?D.ANDROID_MOBILE:M(e,"FxiOS")?D.FIREFOX_IOS:M(e.toLowerCase(),D.KONQUEROR.toLowerCase())?D.KONQUEROR:function(e,t){return t&&M(t,D.APPLE)||M(n=e,D.SAFARI)&&!M(n,D.CHROME)&&!M(n,D.ANDROID);var n}(e,t)?M(e,D.MOBILE)?D.MOBILE_SAFARI:D.SAFARI:M(e,D.FIREFOX)?D.FIREFOX:M(e,"MSIE")||M(e,"Trident/")?D.INTERNET_EXPLORER:M(e,"Gecko")?D.FIREFOX:""}const K={[D.INTERNET_EXPLORER_MOBILE]:[new RegExp("rv:"+x)],[D.MICROSOFT_EDGE]:[new RegExp(D.EDGE+"?\\/"+x)],[D.CHROME]:[new RegExp("("+D.CHROME+"|CrMo)\\/"+x)],[D.CHROME_IOS]:[new RegExp("CriOS\\/"+x)],[D.UC_BROWSER]:[new RegExp("(UCBrowser|UCWEB)\\/"+x)],[D.SAFARI]:[k],[D.MOBILE_SAFARI]:[k],[D.OPERA]:[new RegExp("("+D.OPERA+"|OPR)\\/"+x)],[D.FIREFOX]:[new RegExp(D.FIREFOX+"\\/"+x)],[D.FIREFOX_IOS]:[new RegExp("FxiOS\\/"+x)],[D.KONQUEROR]:[new RegExp("Konqueror[:/]?"+x,"i")],[D.BLACKBERRY]:[new RegExp(D.BLACKBERRY+" "+x),k],[D.ANDROID_MOBILE]:[new RegExp("android\\s"+x,"i")],[D.SAMSUNG_INTERNET]:[new RegExp(D.SAMSUNG_BROWSER+"\\/"+x)],[D.INTERNET_EXPLORER]:[new RegExp("(rv:|MSIE )"+x)],Mozilla:[new RegExp("rv:"+x)]};function J(e,t){const n=z(e,t),i=K[n];if(a(i))return null;for(let s=0;s<i.length;s++){const t=i[s],n=e.match(t);if(n)return parseFloat(n[n.length-2])}return null}const Z=[[new RegExp(D.XBOX+"; "+D.XBOX+" (.*?)[);]","i"),e=>[D.XBOX,e&&e[1]||""]],[new RegExp(D.NINTENDO,"i"),[D.NINTENDO,""]],[new RegExp(D.PLAYSTATION,"i"),[D.PLAYSTATION,""]],[U,[D.BLACKBERRY,""]],[new RegExp(D.WINDOWS,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[D.WINDOWS_PHONE,""];if(new RegExp(D.MOBILE).test(t)&&!/IEMobile\b/.test(t))return[D.WINDOWS+" "+D.MOBILE,""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){const e=n[1];let i=Y[e]||"";return/arm/i.test(t)&&(i="RT"),[D.WINDOWS,i]}return[D.WINDOWS,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[D.IOS,t.join(".")]}return[D.IOS,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=a(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+D.ANDROID+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+D.ANDROID+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[D.ANDROID,t.join(".")]}return[D.ANDROID,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[D.CHROME_OS,""]],[/Linux|debian/i,["Linux",""]]];function Q(){const e=window.innerHeight||document.documentElement.clientHeight||document.body&&document.body.clientHeight||0,t=window.innerWidth||document.documentElement.clientWidth||document.body&&document.body.clientWidth||0,n=navigator.userAgent,i=function(e){for(let t=0;t<Z.length;t++){const[n,i]=Z[t],s=n.exec(e),r=s&&("function"==typeof i?i(s,e):i);if(r)return r}return["",""]}(n)||["",""];return{$browser:z(n),$browser_version:J(n),$url:location?.href.substring(0,1e3),$host:location?.host,$viewport_height:e,$viewport_width:t,$lib:"webjs",$lib_version:A,$search_engine:F(),$referrer:B(),$referrer_domain:m(r=r||B()),$model:(s=n,(X.test(s)?D.NINTENDO:$.test(s)?D.PLAYSTATION:H.test(s)?D.XBOX:new RegExp(D.OUYA,"i").test(s)?D.OUYA:new RegExp("("+D.WINDOWS_PHONE+"|WPDesktop)","i").test(s)?D.WINDOWS_PHONE:/iPad/.test(s)?D.IPAD:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?D.APPLE_WATCH:U.test(s)?D.BLACKBERRY:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(D.NOKIA,"i").test(s)?D.NOKIA:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":q.test(s)?D.HUAWEI:W.test(s)?D.XIAOMI:G.test(s)?D.OPPO:j.test(s)?D.VIVO:/(Android|ZTE)/i.test(s)?!new RegExp(D.MOBILE).test(s)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)?/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?D.ANDROID:D.ANDROID_TABLET:D.ANDROID:new RegExp("(pda|"+D.MOBILE+")","i").test(s)?D.GENERIC_MOBILE:new RegExp(D.TABLET,"i").test(s)&&!new RegExp(D.TABLET+" pc","i").test(s)?D.GENERIC_TABLET:"")||""),$os:i?.[0]||"",$os_version:i?.[1]||"",$pathname:location?.pathname,$screen_height:Number(screen.height)||0,$screen_width:Number(screen.width)||0};var s,r}const V=new class{constructor(){this.STORAGE_KEY="sol_unsent_events",this.MAX_QUEUE_SIZE=100,this.MAX_RETRY_COUNT=3,this.MAX_AGE_MS=6048e5,this.queue=[],this.loadFromStorage(),this.cleanupExpiredItems()}loadFromStorage(){try{const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.queue=d(e)||[])}catch(e){console.warn("Failed to load queue from localStorage:",e),this.queue=[]}}cleanupExpiredItems(){const e=Date.now(),t=this.queue.filter(t=>e-t.timestamp<this.MAX_AGE_MS&&t.retryCount<t.maxRetries);t.length!==this.queue.length&&(this.queue=t,this.saveToStorage())}saveToStorage(){try{this.cleanupExpiredItems(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE)),localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.queue))}catch(e){console.warn("Failed to save queue to localStorage:",e)}}enqueue(e,t,n,i=this.MAX_RETRY_COUNT){try{const s={id:f(),url:e,data:t,headers:n,timestamp:Date.now(),retryCount:0,maxRetries:i};return this.queue.push(s),this.saveToStorage(),s.id}catch(s){return console.warn("Failed to enqueue request:",s),""}}dequeue(e){try{this.queue=this.queue.filter(t=>t.id!==e),this.saveToStorage()}catch(t){console.warn("Failed to dequeue request:",t)}}getAll(){try{return this.cleanupExpiredItems(),[...this.queue]}catch(e){return console.warn("Failed to get queue items:",e),[]}}incrementRetryCount(e){const t=this.queue.find(t=>t.id===e);return!!t&&(t.retryCount++,t.retryCount>=t.maxRetries?(this.dequeue(e),!1):(this.saveToStorage(),!0))}clear(){this.queue=[];try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn("Failed to clear queue from localStorage:",e)}}getItemById(e){return this.queue.find(t=>t.id===e)}};class ee{constructor(e={}){this.flushTimer=null,this.isFlushing=!1,this.pendingFlush=!1,this.config={maxBatchSize:e.maxBatchSize||10,flushInterval:e.flushInterval||5e3},this.startFlushTimer()}add(){V.getAll().length>=this.config.maxBatchSize&&this.triggerFlush()}triggerFlush(){this.isFlushing?this.pendingFlush=!0:(this.isFlushing=!0,this.flush())}flush(){const e=V.getAll();if(0===e.length)return this.isFlushing=!1,void(this.pendingFlush&&(this.pendingFlush=!1,this.triggerFlush()));const t=[],n=[];e.forEach(e=>{Array.isArray(e.data)?t.push(...e.data):t.push(e.data),n.push(e.id)});const i=t.slice(0,this.config.maxBatchSize),s=e[0],r=s.url,o=s.headers;O.instance.config.debug&&console.log(JSON.stringify(i,null,2)),L({url:r,method:"POST",data:i,headers:o,callback:e=>{200!==e.statusCode?console.error("Failed to send batch events:",e):n.forEach(e=>{V.dequeue(e)}),this.isFlushing=!1;const t=V.getAll();(this.pendingFlush||t.length>=this.config.maxBatchSize)&&(this.pendingFlush=!1,this.triggerFlush())}})}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush()}}let te=null,ne=null;function ie(e,t,n){return L({url:e,method:"POST",data:t.data,headers:t.headers,callback:e=>{if(200!==e.statusCode){if(n)if(V.incrementRetryCount(n)){const e=V.getItemById(n);if(e){const t=Math.min(1e3*Math.pow(2,e.retryCount),3e4);setTimeout(()=>{ie(e.url,{data:e.data,headers:e.headers},e.id)},t)}}else console.warn("Max retries reached for request:",n)}else n&&V.dequeue(n),t.callback&&t.callback(e.json)}})}function se(e){return`${e.apiHost}/in/track`}function re(e){return`${e.apiHost}/api/abol/evalall`}function oe(e){return{"Content-Type":"application/json",ProjectToken:e.apiToken}}function ae(e,t,n){O.instance.config.debug&&console.log(JSON.stringify(t.data,null,2));const i=V.enqueue(e,t.data,t.headers);return ie(e,{...t,callback:void 0},i)}function le(e,t,n=!0){const i={time:Date.now(),trace_id:y.getTraceId(),event:e.event,properties:{...n?Q():{},...y.getCommonProps(),...e.properties}},s=y.getLoginId(),r=y.getAnonId();s&&(i.login_id=s),r&&(i.anon_id=r);const o=se(t),a=oe(t),l=S.isSupport()?(ne||(te||(te=new ee({maxBatchSize:10,flushInterval:5e3})),ne=te),ne):null;!1!==t.batchSend&&l?(V.enqueue(o,[i],a),l.add()):ae(o,{data:[i],headers:a})}function ce({userProps:e,opts:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={time:Date.now(),trace_id:y.getTraceId(),event:"$UserSet",login_id:n,anon_id:i,user_properties:e};return ae(se(t),{data:[s],headers:oe(t)})}function ue(e){return`$ab_${e.id}`}function he(e){const t=e.typ;return t===N.FEATURE_GATE&&"fail"!==e.vid?{[ue(e)]:e.vid}:t===N.EXPERIMENT?{[ue(e)]:e.vid}:{}}function de({isHit:e,data:t,opts:n}){if(!t||c(t))return;let i={};i=e?{$set:{...he(t)}}:{$unset:{[ue(t)]:null}};const s=y.getLoginId(),r=y.getAnonId();if(!s||!r)return;const o={time:Date.now(),trace_id:y.getTraceId(),event:"$ABImpress",login_id:s,anon_id:r,properties:{...Q(),...y.getCommonProps()},user_properties:{...i}};return ae(se(n),{data:[o],headers:oe(n)})}class ge{constructor({plugins:e,emitter:t,config:n}){this.plugins=[],this.pluginInsMap={},this.emitter=t,this.config=n,this.registerBuiltInPlugins(e),this.created(),this.emitter.on(_,()=>{this.init()})}registerBuiltInPlugins(e){for(let t=0,n=e.length;t<n;t++)this.registerPlugin(e[t])}registerPlugin(e){this.plugins.push(e)}getPlugins(){return this.plugins}getPlugin(e){return this.pluginInsMap[e]}created(){for(let e=0,t=this.plugins.length;e<t;e++){const t=this.plugins[e];if(!t.NAME)throw new Error('Plugin should be defined with "NAME"');const n=new t({emitter:this.emitter,config:this.config});this.pluginInsMap[t.NAME]=n}}init(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.init&&t.init()}}destroy(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.destroy&&"function"==typeof t.destroy&&t.destroy()}this.pluginInsMap={},this.plugins=[]}}const pe=class{constructor({emitter:e,config:t}){this.boundSend=null,this.hashEvent=null,this.emitter=e,this.config=t}init(){const e=this.config;this.boundSend=()=>{le({event:"$PageView",properties:{$title:document.title}},e)},e.isSinglePageApp?(this.hashEvent="pushState"in window.history?"popstate":"hashchange",window.addEventListener(this.hashEvent,this.boundSend)):this.boundSend()}destroy(){this.hashEvent&&this.boundSend&&(window.removeEventListener(this.hashEvent,this.boundSend),this.hashEvent=null,this.boundSend=null)}};pe.NAME="pageview";let fe=pe;const me=class{constructor({emitter:e,config:t}){this.startTime=Date.now(),this.pageShowStatus=!0,this.pageHiddenStatus=!1,this.timer=null,this.currentPageUrl=document.referrer,this.url=location.href,this.title=document.title||"",this.heartbeatIntervalTime=5e3,this.heartbeatIntervalTimer=null,this.pageId=null,this.storageName="solwebjssdkpageleave",this.maxDuration=432e3,this.eventListeners=[],this.emitter=e,this.config=t}init(){this.pageId=Number(String(p()).slice(2,5)+String(p()).slice(2,4)+String(Date.now()).slice(-4)),this.addEventListener(),!0===document.hidden?this.pageShowStatus=!1:this.addHeartBeatInterval()}log(e){console.log(e)}refreshPageEndTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this.pageHiddenStatus=!1},5e3)}hiddenStatusHandler(){this.timer&&clearTimeout(this.timer),this.timer=null,this.pageHiddenStatus=!1}pageStartHandler(){this.startTime=Date.now(),1==!document.hidden?this.pageShowStatus=!0:this.pageShowStatus=!1,this.url=location.href,this.title=document.title}pageEndHandler(){if(!0===this.pageHiddenStatus)return;const e=this.getPageLeaveProperties();!1===this.pageShowStatus&&delete e.event_duration,this.pageShowStatus=!1,this.pageHiddenStatus=!0,le({event:b,properties:e},this.config),this.refreshPageEndTimer(),this.delHeartBeatData()}addEventListener(){this.addPageStartListener(),this.addPageSwitchListener(),this.addSinglePageListener(),this.addPageEndListener()}addPageStartListener(){if("onpageshow"in window){const e=()=>{this.pageStartHandler(),this.hiddenStatusHandler()};window.addEventListener("pageshow",e),this.eventListeners.push({target:window,event:"pageshow",handler:e})}}addSinglePageListener(){this.config.isSinglePageApp&&this.emitter.on(R,e=>{e!==location.href&&(this.url=e,this.pageEndHandler(),this.stopHeartBeatInterval(),this.currentPageUrl=this.url,this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval())})}addPageEndListener(){["pagehide","beforeunload","unload"].forEach(e=>{if(`on${e}`in window){const t=()=>{this.pageEndHandler(),this.stopHeartBeatInterval()};window.addEventListener(e,t),this.eventListeners.push({target:window,event:e,handler:t})}})}addPageSwitchListener(){const e=()=>{"visible"===document.visibilityState?(this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval()):(this.url=location.href,this.title=document.title,this.pageEndHandler(),this.stopHeartBeatInterval())};document.addEventListener("visibilitychange",e),this.eventListeners.push({target:document,event:"visibilitychange",handler:e})}addHeartBeatInterval(){S.isSupport()&&this.startHeartBeatInterval()}startHeartBeatInterval(){this.heartbeatIntervalTimer&&this.stopHeartBeatInterval(),this.heartbeatIntervalTimer=setInterval(()=>{this.saveHeartBeatData()},this.heartbeatIntervalTime),this.saveHeartBeatData("is_first_heartbeat"),this.reissueHeartBeatData()}stopHeartBeatInterval(){this.heartbeatIntervalTimer&&clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null}saveHeartBeatData(e){const t=this.getPageLeaveProperties();t.$time=Date.now(),"is_first_heartbeat"===e&&(t.event_duration=3);const n={type:"track",event:b,properties:t};n.heartbeat_interval_time=this.heartbeatIntervalTime,S.isSupport()&&S.set(`${this.storageName}-${this.pageId}`,JSON.stringify(n))}delHeartBeatData(e){S.isSupport()&&S.remove(e||`${this.storageName}-${this.pageId}`)}reissueHeartBeatData(){for(let e=window.localStorage.length-1;e>=0;e--){const t=window.localStorage.key(e);if(t&&t!==`${this.storageName}-${this.pageId}`&&0===t.indexOf(`${this.storageName}-`)){const e=S.parse(t);i(e)&&Date.now()-e.time>e.heartbeat_interval_time+5e3&&(delete e.heartbeat_interval_time,e._flush_time=(new Date).getTime(),le({event:b,properties:e?.properties},this.config),this.delHeartBeatData(t))}}}getPageLeaveProperties(){let e=(Date.now()-this.startTime)/1e3;(isNaN(e)||e<0||e>this.maxDuration)&&(e=0),e=Number(e.toFixed(3));const t=document.documentElement&&document.documentElement.scrollTop||window.pageYOffset||document.body&&document.body.scrollTop||0,n=Math.round(t)||0,i={$title:this.title,$viewport_position:n};return 0!==e&&(i.event_duration=e),i}destroy(){this.eventListeners.forEach(({target:e,event:t,handler:n})=>{e.removeEventListener(t,n)}),this.eventListeners=[],this.timer&&(clearTimeout(this.timer),this.timer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};me.NAME="pageleave";let Ee=me;const Ie=class{constructor({emitter:e,config:t}){this.eventSended=!1,this.emitter=e,this.config=t}init(){const e=()=>{let t=0;const n=window.performance,i={$title:document.title};if(n){t=function(){let e=0;if("function"==typeof performance.getEntriesByType){const t=performance.getEntriesByType("navigation");t.length>0&&(e=t[0].domContentLoadedEventEnd||0)}return e}();const e=function(){if(performance.getEntries&&"function"==typeof performance.getEntries){const e=performance.getEntries();let t=0;for(const n of e)"transferSize"in n&&(t+=n.transferSize);if("number"==typeof t&&t>=0&&t<10737418240)return Number((t/1024).toFixed(3))}}();e&&(i.$page_resource_size=e)}else console.warn("Performance API is not supported.");t>0&&!Number.isFinite(t)&&(i.event_duration=Number((t/1e3).toFixed(3))),this.eventSended||(this.eventSended=!0,le({event:"$PageLoad",properties:i},this.config)),window.removeEventListener("load",e)};"complete"===document.readyState?e():window.addEventListener&&window.addEventListener("load",e)}};Ie.NAME="pageload";let Se=Ie;function we(e,t){if(!u(e))return!1;const n=o(e.tagName)?e.tagName.toLowerCase():"unknown",i={};i.$element_type=n,i.$element_name=e.getAttribute("name"),i.$element_id=e.getAttribute("id"),i.$element_class_name=o(e.className)?e.className:null,i.$element_target_url=e.getAttribute("href"),i.$element_content=function(e,t){return o(t)&&"input"===t.toLowerCase()?("button"===(n=e).type||"submit"===n.type)&&n.value||"":function(e,t){let n="",i="";return e.textContent?n=w(e.textContent):e.innerText&&(n=w(e.innerText)),n&&(n=n.replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)),i=n||"","input"!==t&&"INPUT"!==t||(i=e.value||""),i}(e,t);var n}(e,n),i.$element_selector=Oe(e),i.$element_path=function(e){let t=[];for(;e.parentNode&&u(e);){if(!o(e.tagName))return"unknown";if(e.id&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.id)){t.unshift(e.tagName.toLowerCase()+"#"+e.id);break}if(e===document.body){t.unshift("body");break}t.unshift(e.tagName.toLowerCase()),e=e.parentNode}return t.join(" > ")}(e),i.$url_path=location.pathname,i.$title=document.title;const s=function(e,t){const n=t.pageX||t.clientX+Ae().scrollLeft||t.offsetX+_e(e).targetEleX,i=t.pageY||t.clientY+Ae().scrollTop||t.offsetY+_e(e).targetEleY;return{$page_x:Re(n),$page_y:Re(i)}}(e,t);return i.$page_x=s.$page_x,i.$page_y=s.$page_y,i}function Oe(e,t=[]){if(!(e&&e.parentNode&&e.parentNode.children&&o(e.tagName)))return"unknown";t=Array.isArray(t)?t:[];const n=e.nodeName.toLowerCase();return e&&"body"!==n&&1==e.nodeType?(t.unshift(function(e){if(!e||!u(e)||!o(e.tagName))return"";let t=e.parentNode&&9==e.parentNode.nodeType?-1:function(e){if(!e.parentNode)return-1;let t=0;const n=e.tagName,i=e.parentNode.children;for(let s=0,r=i.length;s<r;s++)if(i[s].tagName===n){if(e===i[s])return t;t++}return-1}(e);return e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?"#"+e.getAttribute("id"):e.tagName.toLowerCase()+(~t?":nth-of-type("+(t+1)+")":"")}(e)),e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?t.join(" > "):Oe(e.parentNode,t)):(t.unshift("body"),t.join(" > "))}function Ae(){return{scrollLeft:document.body.scrollLeft||document.documentElement.scrollLeft||0,scrollTop:document.body.scrollTop||document.documentElement.scrollTop||0}}function _e(e){if(document.documentElement.getBoundingClientRect){const t=e.getBoundingClientRect();return{targetEleX:t.left+Ae().scrollLeft||0,targetEleY:t.top+Ae().scrollTop||0}}return{targetEleX:0,targetEleY:0}}function Re(e){return Number(Number(e).toFixed(3))}const ve=class{constructor({emitter:e,config:t}){this.isInitialized=!1,this.boundHandleClick=null,this.emitter=e,this.config=t}init(){this.isInitialized||(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,!0),this.isInitialized=!0)}handleClick(e){const t=e.target;if(!t)return;if(!["A","INPUT","BUTTON","TEXTAREA"].includes(t.tagName))return;if("true"===t.getAttribute("sol-disable"))return;le({event:"$WebClick",properties:we(t,e)||{}},this.config)}destroy(){this.boundHandleClick&&(document.removeEventListener("click",this.boundHandleClick,!0),this.boundHandleClick=null),this.isInitialized=!1}};ve.NAME="webclick";let be=ve;const Ne=class{constructor({emitter:e,config:t}){this.updateInterval=null,this.fetchingPromise=null,this.emitter=e,this.config=t}init(){const e=this.config;e.enableAB&&(this.fastFetch().then(()=>{this.emitter.emit(v)}),e.abRefreshInterval<3e4&&(e.abRefreshInterval=3e4),this.updateInterval=setInterval(()=>{this.fetchNewData().catch(console.warn)},e.abRefreshInterval))}async fastFetch(){const e=y.getABData();return e&&e.length?(this.emitter.emit(v),Promise.resolve(e)):this.fetchNewData()}async fetchNewData(){return this.fetchingPromise||(this.fetchingPromise=new Promise(e=>{!function({opts:e,cb:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={user:{login_id:n,anon_id:i,props:{...Q(),...y.getCommonProps()}},sdk:"webjs",sdk_version:A};L({url:re(e),method:"POST",data:s,headers:oe(e),callback:e=>{200!==e.statusCode?console.error("Failed to fetch feature flags"):t&&t(e.json)}})}({opts:this.config,cb:t=>{y.saveABData(t.data?.results||[]),e(t),this.fetchingPromise=null}})})),this.fetchingPromise}async getFeatureGate(e){return await this.fastFetch().catch(console.warn),y.getABData().find(t=>t.typ===N.FEATURE_GATE&&t.key==e)}async checkFeatureGate(e){const t=await this.getFeatureGate(e);return!!t&&("fail"===t.vid?(de({isHit:!1,data:t,opts:this.config}),!1):(de({isHit:!0,data:t,opts:this.config}),!0))}async getExperiment(e){await this.fastFetch().catch(console.warn);const t=y.getABData().find(t=>t.typ===N.EXPERIMENT&&t.key===e);return t?t?.vid?(de({isHit:!0,data:t,opts:this.config}),t?.value||{}):(de({isHit:!1,data:t,opts:this.config}),{}):{}}destroy(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null),this.fetchingPromise=null}};Ne.NAME="abtest";let Te=Ne;const ye=[],Pe={debug:!1,apiToken:"",apiHost:"",autoCapture:!0,isSinglePageApp:!1,crossSubdomainCookie:!0,enableAB:!1,abRefreshInterval:T,enableClickTrack:!1,batchSend:!0},Ce=new class{constructor(){this.__loaded=!1,this.config={},this.eventEmitter=new e,this.pluginCore={},this.commonProps={},this.spaCleanup=null,O.instance=this}init(e,t={}){t.apiToken=e,this.mergeConfig(t),this.eventEmitter.emit("init-param",this.config);const n=this.config;return y.init(n.crossSubdomainCookie),this.__loaded=!0,window._solFailedRequestsInitialized||(window._solFailedRequestsInitialized=!0,function(){const e=V.getAll();0!==e.length&&e.forEach(e=>{ie(e.url,{data:e.data,headers:e.headers},e.id)})}()),n.autoCapture&&this.autoTrack(),n.enableAB&&ye.push(Te),n.enableClickTrack&&ye.push(be),this.pluginCore=new ge({plugins:ye,emitter:this.eventEmitter,config:n}),this.spaCleanup=function(e){let t=location.href;const n=window.history.pushState,i=window.history.replaceState,r=function(){e(t),t=location.href};return s(window.history.pushState)&&(window.history.pushState=function(...i){n.apply(window.history,i),e(t),t=location.href}),s(window.history.replaceState)&&(window.history.replaceState=function(...n){i.apply(window.history,n),e(t),t=location.href}),window.addEventListener("popstate",r),function(){s(window.history.pushState)&&(window.history.pushState=n),s(window.history.replaceState)&&(window.history.replaceState=i),window.removeEventListener("popstate",r)}}(e=>{this.eventEmitter.emit(R,e)}),this.eventEmitter.emit(_),this}mergeConfig(e){this.config={...Pe,...e}}track(e){!function(e,t){const n={...e};n.time||(n.time=Date.now()),n.login_id||(n.login_id=y.getLoginId()),n.anon_id||(n.anon_id=y.getAnonId()),n.properties={...Q(),...y.getCommonProps(),...n.properties},ae(se(t),{data:[n],headers:oe(t)})}(e,this.config)}trackEvent(e,t){le({event:e,properties:{...t,...this.commonProps}},this.config)}autoTrack(){ye.push(fe,Se,Ee)}profileSet(e){ce({userProps:{$set:e},opts:this.config})}profileSetOnce(e){ce({userProps:{$set_once:e},opts:this.config})}profileIncrement(e){ce({userProps:{$increment:e},opts:this.config})}profileAppend(e){ce({userProps:{$append:e},opts:this.config})}profileUnion(e){ce({userProps:{$union:e},opts:this.config})}profileUnset(e){const t={};r(e)?e.forEach(function(e){t[e]=null}):t[e]=null,ce({userProps:{$unset:t},opts:this.config})}profileDelete(){ce({userProps:{$delete:!0},opts:this.config})}registerCommonProperties(e){if(!i(e))return console.warn("Commmon Properties must be an object!");this.commonProps=e,y.setCommonProps(this.commonProps)}clearCommonProperties(e){if(!r(e))return console.warn("Commmon Properties to be cleared must be an array!");e.forEach(e=>{delete this.commonProps[e]}),y.setCommonProps(this.commonProps)}identify(e){y.setLoginId(e),function(e){const t=y.getLoginId(),n=y.getAnonId();if(!t||!n)return;const i={time:Date.now(),trace_id:y.getTraceId(),event:"$Identify",login_id:t,anon_id:n};ae(se(e),{data:[i],headers:oe(e)})}(this.config)}setLoginId(e){y.setLoginId(e)}getAnonId(){return y.getAnonId()}getLoginId(){return y.getLoginId()}checkFeatureGate(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.checkFeatureGate(e):Promise.reject("AB is disabled")}getExperiment(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.getExperiment(e):Promise.reject("AB is disabled")}destroy(){ne&&(ne.destroy(),ne=null),this.spaCleanup&&"function"==typeof this.spaCleanup&&(this.spaCleanup(),this.spaCleanup=null),this.pluginCore&&"function"==typeof this.pluginCore.destroy&&this.pluginCore.destroy(),this.eventEmitter&&this.eventEmitter.removeAllListeners(),O.instance===this&&(O.instance=null)}};module.exports=Ce;
1
+ "use strict";class e{constructor(){this.listeners={}}on(e,t,n=!1){if(e&&t){if(!s(t))throw new Error("listener must be a function");this.listeners[e]=this.listeners[e]||[],this.listeners[e].push({listener:t,once:n})}}off(e,t){const n=this.listeners[e];if(!n?.length)return;"number"==typeof t&&n.splice(t,1);const i=n.findIndex(e=>e.listener===t);-1!==i&&n.splice(i,1)}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((n,i)=>{n.listener.call(this,...t),n.listener.once&&this.off(e,i)})}once(e,t){this.on(e,t,!0)}removeAllListeners(e){e?this.listeners[e]=[]:this.listeners={}}}const t={get:function(e){const t=e+"=",n=document.cookie.split(";");for(let i=0,s=n.length;i<s;i++){let e=n[i];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(t))return h(e.substring(t.length,e.length))}return null},set:function({name:e,value:t,expires:n,samesite:i,secure:s,domain:r}){let o="",a="",l="",c="";if(0!==(n=null==n||void 0===n?365:n)){const e=new Date;"s"===String(n).slice(-1)?e.setTime(e.getTime()+1e3*Number(String(n).slice(0,-1))):e.setTime(e.getTime()+24*n*60*60*1e3),o="; expires="+e.toUTCString()}function u(e){return e?e.replace(/\r\n/g,""):""}i&&(l="; SameSite="+i),s&&(a="; secure");const h=u(e),d=u(t),g=u(r);g&&(c="; domain="+g),h&&d&&(document.cookie=h+"="+encodeURIComponent(d)+o+"; path=/"+c+l+a)},remove:function(e){this.set({name:e,value:"",expires:-1})},isSupport:function({samesite:e,secure:t}={}){if(!navigator.cookieEnabled)return!1;const n="sol_cookie_support_test";return this.set({name:n,value:"1",samesite:e,secure:t}),"1"===this.get(n)&&(this.remove(n),!0)}},n=Object.prototype.toString;function i(e){return"[object Object]"===n.call(e)}function s(e){const t=n.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function r(e){return"[object Array]"==n.call(e)}function o(e){return"[object String]"==n.call(e)}function a(e){return void 0===e}const l=Object.prototype.hasOwnProperty;function c(e){if(i(e)){for(let t in e)if(l.call(e,t))return!1;return!0}return!1}function u(e){return!(!e||1!==e.nodeType)}function h(e){let t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t}function d(e){try{return JSON.parse(e)}catch(t){return""}}const g=function(){let e=Date.now();return function(t){return Math.ceil((e=(9301*e+49297)%233280,e/233280*t))}}();function p(){if("function"==typeof Uint32Array){let e;if("undefined"!=typeof crypto&&(e=crypto),e&&i(e)&&e.getRandomValues)return e.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}return g(1e19)/1e19}const f=function(){function e(){let e=Date.now(),t=0;for(;e==Date.now();)t++;return e.toString(16)+t.toString(16)}return function(){let t=String(screen.height*screen.width);t=t&&/\d{5,}/.test(t)?t.toString():String(31242*p()).replace(".","").slice(0,8);return e()+"-"+p().toString(16).replace(".","")+"-"+function(){const e=navigator.userAgent;let t,n=[],i=0;function s(e,t){let i=0;for(let s=0;s<t.length;s++)i|=n[s]<<8*s;return e^i}for(let r=0;r<e.length;r++)t=e.charCodeAt(r),n.unshift(255&t),n.length>=4&&(i=s(i,n),n=[]);return n.length>0&&(i=s(i,n)),i.toString(16)}()+"-"+t+"-"+e()||(String(p())+String(p())+String(p())).slice(2,15)}}();function m(e,t){t&&"string"==typeof t||(t="");let n=null;try{n=new URL(e).hostname}catch(i){}return n||t}function E(e){let t=[];try{t=atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})}catch(n){t=[]}try{return decodeURIComponent(t.join(""))}catch(n){return t.join("")}}function I(e){let t="";try{t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}))}catch(n){t=e}return t}const S={get:function(e){return window.localStorage.getItem(e)},parse:function(e){let t;try{t=JSON.parse(S.get(e))||null}catch(n){console.warn(n)}return t},set:function(e,t){try{window.localStorage.setItem(e,t)}catch(n){console.warn(n)}},remove:function(e){window.localStorage.removeItem(e)},isSupport:function(){let e=!0;try{const t="__local_store_support__",n="testIsSupportStorage";S.set(t,n),S.get(t)!==n&&(e=!1),S.remove(t)}catch(t){e=!1}return e}};function w(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}const O={},A="0.3.2",_="init-ready",R="spa-switch",v="ff-ready",b="$PageLeave";var N=(e=>(e[e.FEATURE_GATE=1]="FEATURE_GATE",e[e.FEATURE_CONFIG=2]="FEATURE_CONFIG",e[e.EXPERIMENT=3]="EXPERIMENT",e))(N||{});const T=6e5,y={crossSubdomain:!1,requests:[],_sessionState:{},_abData:[],_trace_id:"",commonProps:{},_state:{anon_id:"",login_id:"",identities:{}},getIdentityCookieID(){return this._state.identities?.$identity_cookie_id||""},getCommonProps:function(){return this.commonProps||{}},setCommonProps:function(e){this.commonProps=e},getAnonId(){return this.getIdentityCookieID()||this._state.anon_id||f()},getLoginId(){return this._state.login_id},getTraceId(){return this._trace_id||f()},set:function(e,t){this._state[e]=t,this.save()},getCookieName:function(){return"sol2025jssdkcross"},getABLSName:function(){return"sol2025jssdkablatest"},save:function(){let e=JSON.parse(JSON.stringify(this._state));e.identities&&(e.identities=I(JSON.stringify(e.identities)));const n=JSON.stringify(e);t.set({name:this.getCookieName(),value:n,expires:365})},init:function(e){let n,s;this.crossSubdomain=e,t.isSupport()&&(n=t.get(this.getCookieName()),s=d(n)),y._state={...s||{}},y._state.identities&&(y._state.identities=d(E(y._state.identities))),y._state.identities&&i(y._state.identities)&&!c(y._state.identities)||(y._state.identities={$identity_cookie_id:f()}),y.save()},setLoginId(e){"number"==typeof e&&(e=String(e)),void 0!==e&&e&&(y.set("login_id",e),y.save())},saveABData(e){if(!e||c(e))return;this._abData=e;let t=JSON.parse(JSON.stringify(this._abData));t=I(JSON.stringify(t));try{localStorage.setItem(this.getABLSName(),JSON.stringify({time:Date.now(),data:t,anon_id:this.getAnonId(),login_id:this.getLoginId()}))}catch(n){console.warn("Failed to save abdata to localStorage",n)}},getABData(){try{let e=localStorage.getItem(this.getABLSName());if(e){const{time:t,data:n,login_id:i,anon_id:s}=d(e)||{};if(t&&n&&Date.now()-t<T&&s===this.getAnonId()&&(!i||i===this.getLoginId()))return d(E(n));localStorage.removeItem(this.getABLSName())}}catch(e){console.warn("Failed to load abdata from localStorage",e),this._abData=[]}return this._abData||[]}};function P(e){var t;if(e.data)return{contentType:"application/json",body:(t=e.data,JSON.stringify(t,(e,t)=>"bigint"==typeof t?t.toString():t,undefined))}}const C=[];function L(e){const t={...e};t.timeout=t.timeout||6e4;const n=t.transport??"fetch",i=C.find(e=>e.transport===n)?.method??C[0]?.method;if(!i)throw new Error("No available transport method for HTTP request");i(t)}function B(e){return o(e=e||document.referrer)&&(e=h(e=e.trim()))||""}function F(e){const t=m(e=e||B());if(!t)return"";const n={baidu:[/^.*\.baidu\.com$/],bing:[/^.*\.bing\.com$/],google:[/^www\.google\.com$/,/^www\.google\.com\.[a-z]{2}$/,/^www\.google\.[a-z]{2}$/],sm:[/^m\.sm\.cn$/],so:[/^.+\.so\.com$/],sogou:[/^.*\.sogou\.com$/],yahoo:[/^.*\.yahoo\.com$/],duckduckgo:[/^.*\.duckduckgo\.com$/]};for(let i of Object.keys(n)){let e=n[i];for(let n=0,s=e.length;n<s;n++)if(e[n].test(t))return i}return"Unknown Search Engine"}function M(e,t){return-1!==e.indexOf(t)}"function"==typeof fetch&&C.push({transport:"fetch",method:function(e){if("undefined"==typeof fetch)return void console.error("fetch API is not available");const t=P(e),n=new Headers;e.headers&&Object.keys(e.headers).forEach(t=>{n.append(t,e.headers[t])}),t?.contentType&&n.append("Content-Type",t.contentType),fetch(e.url,{method:e.method||"GET",headers:n,body:t?.body}).then(t=>t.text().then(n=>{const i={statusCode:t.status,text:n};if(200===t.status)try{i.json=JSON.parse(n)}catch(s){console.error("Failed to parse response:",s)}e.callback?.(i)})).catch(t=>{console.error("Request failed:",t),e.callback?.({statusCode:0,text:String(t)})})}}),"undefined"!=typeof XMLHttpRequest&&C.push({transport:"XHR",method:function(e){if("undefined"==typeof XMLHttpRequest)return void console.error("XMLHttpRequest is not available");const t=new XMLHttpRequest;t.open(e.method||"GET",e.url,!0);const n=P(e);e.headers&&Object.keys(e.headers).forEach(n=>{t.setRequestHeader(n,e.headers[n])}),n?.contentType&&t.setRequestHeader("Content-Type",n.contentType),t.timeout=e.timeout||6e4,t.withCredentials=!0,t.onreadystatechange=()=>{if(4===t.readyState){const i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(n){console.error("Failed to parse JSON response:",n)}e.callback?.(i)}},t.send(n?.body)}});const D={FACEBOOK:"Facebook",MOBILE:"Mobile",IOS:"iOS",ANDROID:"Android",TABLET:"Tablet",ANDROID_TABLET:"Android Tablet",IPAD:"iPad",APPLE:"Apple",APPLE_WATCH:"Apple Watch",SAFARI:"Safari",BLACKBERRY:"BlackBerry",SAMSUNG_BROWSER:"SamsungBrowser",SAMSUNG_INTERNET:"Samsung Internet",CHROME:"Chrome",CHROME_OS:"Chrome OS",CHROME_IOS:"Chrome iOS",INTERNET_EXPLORER:"Internet Explorer",INTERNET_EXPLORER_MOBILE:"Internet Explorer Mobile",OPERA:"Opera",OPERA_MINI:"Opera Mini",EDGE:"Edge",MICROSOFT_EDGE:"Microsoft Edge",FIREFOX:"Firefox",FIREFOX_IOS:"Firefox iOS",NINTENDO:"Nintendo",PLAYSTATION:"PlayStation",XBOX:"Xbox",ANDROID_MOBILE:"Android Mobile",MOBILE_SAFARI:"Mobile Safari",WINDOWS:"Windows",WINDOWS_PHONE:"Windows Phone",NOKIA:"Nokia",OUYA:"Ouya",GENERIC_MOBILE:"Generic mobile",GENERIC_TABLET:"Generic tablet",KONQUEROR:"Konqueror",UC_BROWSER:"UC Browser",HUAWEI:"Huawei",XIAOMI:"Xiaomi",OPPO:"OPPO",VIVO:"vivo"},x="(\\d+(\\.\\d+)?)",k=new RegExp("Version/"+x),H=new RegExp(D.XBOX,"i"),$=new RegExp(D.PLAYSTATION+" \\w+","i"),X=new RegExp(D.NINTENDO+" \\w+","i"),U=new RegExp(D.BLACKBERRY+"|PlayBook|BB10","i"),q=new RegExp("(HUAWEI|honor|HONOR)","i"),W=new RegExp("(Xiaomi|Redmi)","i"),G=new RegExp("(OPPO|realme)","i"),j=new RegExp("(vivo|IQOO)","i"),Y={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function z(e,t){return t=t||"",M(e," OPR/")&&M(e,"Mini")?D.OPERA_MINI:M(e," OPR/")?D.OPERA:U.test(e)?D.BLACKBERRY:M(e,"IE"+D.MOBILE)||M(e,"WPDesktop")?D.INTERNET_EXPLORER_MOBILE:M(e,D.SAMSUNG_BROWSER)?D.SAMSUNG_INTERNET:M(e,D.EDGE)||M(e,"Edg/")?D.MICROSOFT_EDGE:M(e,"FBIOS")?D.FACEBOOK+" "+D.MOBILE:M(e,"UCWEB")||M(e,"UCBrowser")?D.UC_BROWSER:M(e,"CriOS")?D.CHROME_IOS:M(e,"CrMo")||M(e,D.CHROME)?D.CHROME:M(e,D.ANDROID)&&M(e,D.SAFARI)?D.ANDROID_MOBILE:M(e,"FxiOS")?D.FIREFOX_IOS:M(e.toLowerCase(),D.KONQUEROR.toLowerCase())?D.KONQUEROR:function(e,t){return t&&M(t,D.APPLE)||M(n=e,D.SAFARI)&&!M(n,D.CHROME)&&!M(n,D.ANDROID);var n}(e,t)?M(e,D.MOBILE)?D.MOBILE_SAFARI:D.SAFARI:M(e,D.FIREFOX)?D.FIREFOX:M(e,"MSIE")||M(e,"Trident/")?D.INTERNET_EXPLORER:M(e,"Gecko")?D.FIREFOX:""}const K={[D.INTERNET_EXPLORER_MOBILE]:[new RegExp("rv:"+x)],[D.MICROSOFT_EDGE]:[new RegExp(D.EDGE+"?\\/"+x)],[D.CHROME]:[new RegExp("("+D.CHROME+"|CrMo)\\/"+x)],[D.CHROME_IOS]:[new RegExp("CriOS\\/"+x)],[D.UC_BROWSER]:[new RegExp("(UCBrowser|UCWEB)\\/"+x)],[D.SAFARI]:[k],[D.MOBILE_SAFARI]:[k],[D.OPERA]:[new RegExp("("+D.OPERA+"|OPR)\\/"+x)],[D.FIREFOX]:[new RegExp(D.FIREFOX+"\\/"+x)],[D.FIREFOX_IOS]:[new RegExp("FxiOS\\/"+x)],[D.KONQUEROR]:[new RegExp("Konqueror[:/]?"+x,"i")],[D.BLACKBERRY]:[new RegExp(D.BLACKBERRY+" "+x),k],[D.ANDROID_MOBILE]:[new RegExp("android\\s"+x,"i")],[D.SAMSUNG_INTERNET]:[new RegExp(D.SAMSUNG_BROWSER+"\\/"+x)],[D.INTERNET_EXPLORER]:[new RegExp("(rv:|MSIE )"+x)],Mozilla:[new RegExp("rv:"+x)]};function J(e,t){const n=z(e,t),i=K[n];if(a(i))return null;for(let s=0;s<i.length;s++){const t=i[s],n=e.match(t);if(n)return parseFloat(n[n.length-2])}return null}const Z=[[new RegExp(D.XBOX+"; "+D.XBOX+" (.*?)[);]","i"),e=>[D.XBOX,e&&e[1]||""]],[new RegExp(D.NINTENDO,"i"),[D.NINTENDO,""]],[new RegExp(D.PLAYSTATION,"i"),[D.PLAYSTATION,""]],[U,[D.BLACKBERRY,""]],[new RegExp(D.WINDOWS,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[D.WINDOWS_PHONE,""];if(new RegExp(D.MOBILE).test(t)&&!/IEMobile\b/.test(t))return[D.WINDOWS+" "+D.MOBILE,""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){const e=n[1];let i=Y[e]||"";return/arm/i.test(t)&&(i="RT"),[D.WINDOWS,i]}return[D.WINDOWS,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[D.IOS,t.join(".")]}return[D.IOS,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=a(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+D.ANDROID+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+D.ANDROID+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[D.ANDROID,t.join(".")]}return[D.ANDROID,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[D.CHROME_OS,""]],[/Linux|debian/i,["Linux",""]]];function Q(){const e=window.innerHeight||document.documentElement.clientHeight||document.body&&document.body.clientHeight||0,t=window.innerWidth||document.documentElement.clientWidth||document.body&&document.body.clientWidth||0,n=navigator.userAgent,i=function(e){for(let t=0;t<Z.length;t++){const[n,i]=Z[t],s=n.exec(e),r=s&&("function"==typeof i?i(s,e):i);if(r)return r}return["",""]}(n)||["",""];return{$browser:z(n),$browser_version:J(n),$url:location?.href.substring(0,1e3),$host:location?.host,$viewport_height:e,$viewport_width:t,$lib:"webjs",$lib_version:A,$search_engine:F(),$referrer:B(),$referrer_domain:m(r=r||B()),$model:(s=n,(X.test(s)?D.NINTENDO:$.test(s)?D.PLAYSTATION:H.test(s)?D.XBOX:new RegExp(D.OUYA,"i").test(s)?D.OUYA:new RegExp("("+D.WINDOWS_PHONE+"|WPDesktop)","i").test(s)?D.WINDOWS_PHONE:/iPad/.test(s)?D.IPAD:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?D.APPLE_WATCH:U.test(s)?D.BLACKBERRY:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(D.NOKIA,"i").test(s)?D.NOKIA:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":q.test(s)?D.HUAWEI:W.test(s)?D.XIAOMI:G.test(s)?D.OPPO:j.test(s)?D.VIVO:/(Android|ZTE)/i.test(s)?!new RegExp(D.MOBILE).test(s)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)?/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?D.ANDROID:D.ANDROID_TABLET:D.ANDROID:new RegExp("(pda|"+D.MOBILE+")","i").test(s)?D.GENERIC_MOBILE:new RegExp(D.TABLET,"i").test(s)&&!new RegExp(D.TABLET+" pc","i").test(s)?D.GENERIC_TABLET:"")||""),$os:i?.[0]||"",$os_version:i?.[1]||"",$pathname:location?.pathname,$screen_height:Number(screen.height)||0,$screen_width:Number(screen.width)||0};var s,r}const V=new class{constructor(){this.STORAGE_KEY="sol_unsent_events",this.MAX_QUEUE_SIZE=100,this.MAX_RETRY_COUNT=3,this.MAX_AGE_MS=6048e5,this.queue=[],this.loadFromStorage(),this.cleanupExpiredItems()}loadFromStorage(){try{const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.queue=d(e)||[])}catch(e){console.warn("Failed to load queue from localStorage:",e),this.queue=[]}}cleanupExpiredItems(){const e=Date.now(),t=this.queue.filter(t=>e-t.timestamp<this.MAX_AGE_MS&&t.retryCount<t.maxRetries);t.length!==this.queue.length&&(this.queue=t,this.saveToStorage())}saveToStorage(){try{this.cleanupExpiredItems(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE)),localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.queue))}catch(e){console.warn("Failed to save queue to localStorage:",e)}}enqueue(e,t,n,i=this.MAX_RETRY_COUNT){try{const s={id:f(),url:e,data:t,headers:n,timestamp:Date.now(),retryCount:0,maxRetries:i};return this.queue.push(s),this.saveToStorage(),s.id}catch(s){return console.warn("Failed to enqueue request:",s),""}}dequeue(e){try{this.queue=this.queue.filter(t=>t.id!==e),this.saveToStorage()}catch(t){console.warn("Failed to dequeue request:",t)}}getAll(){try{return this.cleanupExpiredItems(),[...this.queue]}catch(e){return console.warn("Failed to get queue items:",e),[]}}incrementRetryCount(e){const t=this.queue.find(t=>t.id===e);return!!t&&(t.retryCount++,t.retryCount>=t.maxRetries?(this.dequeue(e),!1):(this.saveToStorage(),!0))}clear(){this.queue=[];try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn("Failed to clear queue from localStorage:",e)}}getItemById(e){return this.queue.find(t=>t.id===e)}};class ee{constructor(e={}){this.flushTimer=null,this.isFlushing=!1,this.pendingFlush=!1,this.config={maxBatchSize:e.maxBatchSize||10,flushInterval:e.flushInterval||5e3},this.startFlushTimer()}add(){V.getAll().length>=this.config.maxBatchSize&&this.triggerFlush()}triggerFlush(){this.isFlushing?this.pendingFlush=!0:(this.isFlushing=!0,this.flush())}flush(){const e=V.getAll();if(0===e.length)return this.isFlushing=!1,void(this.pendingFlush&&(this.pendingFlush=!1,this.triggerFlush()));const t=[],n=[];e.forEach(e=>{Array.isArray(e.data)?t.push(...e.data):t.push(e.data),n.push(e.id)});const i=t.slice(0,this.config.maxBatchSize),s=e[0],r=s.url,o=s.headers;O.instance.config.debug&&console.log(JSON.stringify(i,null,2)),L({url:r,method:"POST",data:i,headers:o,callback:e=>{200!==e.statusCode?console.error("Failed to send batch events:",e):n.forEach(e=>{V.dequeue(e)}),this.isFlushing=!1;const t=V.getAll();(this.pendingFlush||t.length>=this.config.maxBatchSize)&&(this.pendingFlush=!1,this.triggerFlush())}})}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush()}}let te=null,ne=null;function ie(e,t,n){return L({url:e,method:"POST",data:t.data,headers:t.headers,callback:e=>{if(200!==e.statusCode){if(n)if(V.incrementRetryCount(n)){const e=V.getItemById(n);if(e){const t=Math.min(1e3*Math.pow(2,e.retryCount),3e4);setTimeout(()=>{ie(e.url,{data:e.data,headers:e.headers},e.id)},t)}}else console.warn("Max retries reached for request:",n)}else n&&V.dequeue(n),t.callback&&t.callback(e.json)}})}function se(e){return`${e.apiHost}/in/track`}function re(e){return`${e.apiHost}/api/abol/evalall`}function oe(e){return{"Content-Type":"application/json",ProjectToken:e.apiToken}}function ae(e,t,n){O.instance.config.debug&&console.log(JSON.stringify(t.data,null,2));const i=V.enqueue(e,t.data,t.headers);return ie(e,{...t,callback:void 0},i)}function le(e,t,n=!0){const i={time:Date.now(),trace_id:y.getTraceId(),event:e.event,properties:{...n?Q():{},...y.getCommonProps(),...e.properties}},s=y.getLoginId(),r=y.getAnonId();s&&(i.login_id=s),r&&(i.anon_id=r);const o=se(t),a=oe(t),l=S.isSupport()?(ne||(te||(te=new ee({maxBatchSize:10,flushInterval:5e3})),ne=te),ne):null;!1!==t.batchSend&&l?(V.enqueue(o,[i],a),l.add()):ae(o,{data:[i],headers:a})}function ce({userProps:e,opts:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={time:Date.now(),trace_id:y.getTraceId(),event:"$UserSet",login_id:n,anon_id:i,user_properties:e};return ae(se(t),{data:[s],headers:oe(t)})}function ue(e){return`$ab_${e.id}`}function he(e){const t=e.typ;return t===N.FEATURE_GATE&&"fail"!==e.vid?{[ue(e)]:e.vid}:t===N.EXPERIMENT?{[ue(e)]:e.vid}:{}}function de({isHit:e,data:t,opts:n}){if(!t||c(t)||t.disable_impress)return;let i={};i=e?{$set:{...he(t)}}:{$unset:{[ue(t)]:null}};const s=y.getLoginId(),r=y.getAnonId();if(!s||!r)return;const o={time:Date.now(),trace_id:y.getTraceId(),event:"$ABImpress",login_id:s,anon_id:r,properties:{...Q(),...y.getCommonProps()},user_properties:{...i}};return ae(se(n),{data:[o],headers:oe(n)})}class ge{constructor({plugins:e,emitter:t,config:n}){this.plugins=[],this.pluginInsMap={},this.emitter=t,this.config=n,this.registerBuiltInPlugins(e),this.created(),this.emitter.on(_,()=>{this.init()})}registerBuiltInPlugins(e){for(let t=0,n=e.length;t<n;t++)this.registerPlugin(e[t])}registerPlugin(e){this.plugins.push(e)}getPlugins(){return this.plugins}getPlugin(e){return this.pluginInsMap[e]}created(){for(let e=0,t=this.plugins.length;e<t;e++){const t=this.plugins[e];if(!t.NAME)throw new Error('Plugin should be defined with "NAME"');const n=new t({emitter:this.emitter,config:this.config});this.pluginInsMap[t.NAME]=n}}init(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.init&&t.init()}}destroy(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.destroy&&"function"==typeof t.destroy&&t.destroy()}this.pluginInsMap={},this.plugins=[]}}const pe=class{constructor({emitter:e,config:t}){this.boundSend=null,this.hashEvent=null,this.emitter=e,this.config=t}init(){const e=this.config;this.boundSend=()=>{le({event:"$PageView",properties:{$title:document.title}},e)},e.isSinglePageApp?(this.hashEvent="pushState"in window.history?"popstate":"hashchange",window.addEventListener(this.hashEvent,this.boundSend)):this.boundSend()}destroy(){this.hashEvent&&this.boundSend&&(window.removeEventListener(this.hashEvent,this.boundSend),this.hashEvent=null,this.boundSend=null)}};pe.NAME="pageview";let fe=pe;const me=class{constructor({emitter:e,config:t}){this.startTime=Date.now(),this.pageShowStatus=!0,this.pageHiddenStatus=!1,this.timer=null,this.currentPageUrl=document.referrer,this.url=location.href,this.title=document.title||"",this.heartbeatIntervalTime=5e3,this.heartbeatIntervalTimer=null,this.pageId=null,this.storageName="solwebjssdkpageleave",this.maxDuration=432e3,this.eventListeners=[],this.emitter=e,this.config=t}init(){this.pageId=Number(String(p()).slice(2,5)+String(p()).slice(2,4)+String(Date.now()).slice(-4)),this.addEventListener(),!0===document.hidden?this.pageShowStatus=!1:this.addHeartBeatInterval()}log(e){console.log(e)}refreshPageEndTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this.pageHiddenStatus=!1},5e3)}hiddenStatusHandler(){this.timer&&clearTimeout(this.timer),this.timer=null,this.pageHiddenStatus=!1}pageStartHandler(){this.startTime=Date.now(),1==!document.hidden?this.pageShowStatus=!0:this.pageShowStatus=!1,this.url=location.href,this.title=document.title}pageEndHandler(){if(!0===this.pageHiddenStatus)return;const e=this.getPageLeaveProperties();!1===this.pageShowStatus&&delete e.event_duration,this.pageShowStatus=!1,this.pageHiddenStatus=!0,le({event:b,properties:e},this.config),this.refreshPageEndTimer(),this.delHeartBeatData()}addEventListener(){this.addPageStartListener(),this.addPageSwitchListener(),this.addSinglePageListener(),this.addPageEndListener()}addPageStartListener(){if("onpageshow"in window){const e=()=>{this.pageStartHandler(),this.hiddenStatusHandler()};window.addEventListener("pageshow",e),this.eventListeners.push({target:window,event:"pageshow",handler:e})}}addSinglePageListener(){this.config.isSinglePageApp&&this.emitter.on(R,e=>{e!==location.href&&(this.url=e,this.pageEndHandler(),this.stopHeartBeatInterval(),this.currentPageUrl=this.url,this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval())})}addPageEndListener(){["pagehide","beforeunload","unload"].forEach(e=>{if(`on${e}`in window){const t=()=>{this.pageEndHandler(),this.stopHeartBeatInterval()};window.addEventListener(e,t),this.eventListeners.push({target:window,event:e,handler:t})}})}addPageSwitchListener(){const e=()=>{"visible"===document.visibilityState?(this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval()):(this.url=location.href,this.title=document.title,this.pageEndHandler(),this.stopHeartBeatInterval())};document.addEventListener("visibilitychange",e),this.eventListeners.push({target:document,event:"visibilitychange",handler:e})}addHeartBeatInterval(){S.isSupport()&&this.startHeartBeatInterval()}startHeartBeatInterval(){this.heartbeatIntervalTimer&&this.stopHeartBeatInterval(),this.heartbeatIntervalTimer=setInterval(()=>{this.saveHeartBeatData()},this.heartbeatIntervalTime),this.saveHeartBeatData("is_first_heartbeat"),this.reissueHeartBeatData()}stopHeartBeatInterval(){this.heartbeatIntervalTimer&&clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null}saveHeartBeatData(e){const t=this.getPageLeaveProperties();t.$time=Date.now(),"is_first_heartbeat"===e&&(t.event_duration=3);const n={type:"track",event:b,properties:t};n.heartbeat_interval_time=this.heartbeatIntervalTime,S.isSupport()&&S.set(`${this.storageName}-${this.pageId}`,JSON.stringify(n))}delHeartBeatData(e){S.isSupport()&&S.remove(e||`${this.storageName}-${this.pageId}`)}reissueHeartBeatData(){for(let e=window.localStorage.length-1;e>=0;e--){const t=window.localStorage.key(e);if(t&&t!==`${this.storageName}-${this.pageId}`&&0===t.indexOf(`${this.storageName}-`)){const e=S.parse(t);i(e)&&Date.now()-e.time>e.heartbeat_interval_time+5e3&&(delete e.heartbeat_interval_time,e._flush_time=(new Date).getTime(),le({event:b,properties:e?.properties},this.config),this.delHeartBeatData(t))}}}getPageLeaveProperties(){let e=(Date.now()-this.startTime)/1e3;(isNaN(e)||e<0||e>this.maxDuration)&&(e=0),e=Number(e.toFixed(3));const t=document.documentElement&&document.documentElement.scrollTop||window.pageYOffset||document.body&&document.body.scrollTop||0,n=Math.round(t)||0,i={$title:this.title,$viewport_position:n};return 0!==e&&(i.event_duration=e),i}destroy(){this.eventListeners.forEach(({target:e,event:t,handler:n})=>{e.removeEventListener(t,n)}),this.eventListeners=[],this.timer&&(clearTimeout(this.timer),this.timer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};me.NAME="pageleave";let Ee=me;const Ie=class{constructor({emitter:e,config:t}){this.eventSended=!1,this.emitter=e,this.config=t}init(){const e=()=>{let t=0;const n=window.performance,i={$title:document.title};if(n){t=function(){let e=0;if("function"==typeof performance.getEntriesByType){const t=performance.getEntriesByType("navigation");t.length>0&&(e=t[0].domContentLoadedEventEnd||0)}return e}();const e=function(){if(performance.getEntries&&"function"==typeof performance.getEntries){const e=performance.getEntries();let t=0;for(const n of e)"transferSize"in n&&(t+=n.transferSize);if("number"==typeof t&&t>=0&&t<10737418240)return Number((t/1024).toFixed(3))}}();e&&(i.$page_resource_size=e)}else console.warn("Performance API is not supported.");t>0&&!Number.isFinite(t)&&(i.event_duration=Number((t/1e3).toFixed(3))),this.eventSended||(this.eventSended=!0,le({event:"$PageLoad",properties:i},this.config)),window.removeEventListener("load",e)};"complete"===document.readyState?e():window.addEventListener&&window.addEventListener("load",e)}};Ie.NAME="pageload";let Se=Ie;function we(e,t){if(!u(e))return!1;const n=o(e.tagName)?e.tagName.toLowerCase():"unknown",i={};i.$element_type=n,i.$element_name=e.getAttribute("name"),i.$element_id=e.getAttribute("id"),i.$element_class_name=o(e.className)?e.className:null,i.$element_target_url=e.getAttribute("href"),i.$element_content=function(e,t){return o(t)&&"input"===t.toLowerCase()?("button"===(n=e).type||"submit"===n.type)&&n.value||"":function(e,t){let n="",i="";return e.textContent?n=w(e.textContent):e.innerText&&(n=w(e.innerText)),n&&(n=n.replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)),i=n||"","input"!==t&&"INPUT"!==t||(i=e.value||""),i}(e,t);var n}(e,n),i.$element_selector=Oe(e),i.$element_path=function(e){let t=[];for(;e.parentNode&&u(e);){if(!o(e.tagName))return"unknown";if(e.id&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.id)){t.unshift(e.tagName.toLowerCase()+"#"+e.id);break}if(e===document.body){t.unshift("body");break}t.unshift(e.tagName.toLowerCase()),e=e.parentNode}return t.join(" > ")}(e),i.$url_path=location.pathname,i.$title=document.title;const s=function(e,t){const n=t.pageX||t.clientX+Ae().scrollLeft||t.offsetX+_e(e).targetEleX,i=t.pageY||t.clientY+Ae().scrollTop||t.offsetY+_e(e).targetEleY;return{$page_x:Re(n),$page_y:Re(i)}}(e,t);return i.$page_x=s.$page_x,i.$page_y=s.$page_y,i}function Oe(e,t=[]){if(!(e&&e.parentNode&&e.parentNode.children&&o(e.tagName)))return"unknown";t=Array.isArray(t)?t:[];const n=e.nodeName.toLowerCase();return e&&"body"!==n&&1==e.nodeType?(t.unshift(function(e){if(!e||!u(e)||!o(e.tagName))return"";let t=e.parentNode&&9==e.parentNode.nodeType?-1:function(e){if(!e.parentNode)return-1;let t=0;const n=e.tagName,i=e.parentNode.children;for(let s=0,r=i.length;s<r;s++)if(i[s].tagName===n){if(e===i[s])return t;t++}return-1}(e);return e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?"#"+e.getAttribute("id"):e.tagName.toLowerCase()+(~t?":nth-of-type("+(t+1)+")":"")}(e)),e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?t.join(" > "):Oe(e.parentNode,t)):(t.unshift("body"),t.join(" > "))}function Ae(){return{scrollLeft:document.body.scrollLeft||document.documentElement.scrollLeft||0,scrollTop:document.body.scrollTop||document.documentElement.scrollTop||0}}function _e(e){if(document.documentElement.getBoundingClientRect){const t=e.getBoundingClientRect();return{targetEleX:t.left+Ae().scrollLeft||0,targetEleY:t.top+Ae().scrollTop||0}}return{targetEleX:0,targetEleY:0}}function Re(e){return Number(Number(e).toFixed(3))}const ve=class{constructor({emitter:e,config:t}){this.isInitialized=!1,this.boundHandleClick=null,this.emitter=e,this.config=t}init(){this.isInitialized||(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,!0),this.isInitialized=!0)}handleClick(e){const t=e.target;if(!t)return;if(!["A","INPUT","BUTTON","TEXTAREA"].includes(t.tagName))return;if("true"===t.getAttribute("sol-disable"))return;le({event:"$WebClick",properties:we(t,e)||{}},this.config)}destroy(){this.boundHandleClick&&(document.removeEventListener("click",this.boundHandleClick,!0),this.boundHandleClick=null),this.isInitialized=!1}};ve.NAME="webclick";let be=ve;const Ne=class{constructor({emitter:e,config:t}){this.updateInterval=null,this.fetchingPromise=null,this.emitter=e,this.config=t}init(){const e=this.config;e.enableAB&&(this.fastFetch().then(()=>{this.emitter.emit(v)}),e.abRefreshInterval<3e4&&(e.abRefreshInterval=3e4),this.updateInterval=setInterval(()=>{this.fetchNewData().catch(console.warn)},e.abRefreshInterval))}async fastFetch(){const e=y.getABData();return e&&e.length?(this.emitter.emit(v),Promise.resolve(e)):this.fetchNewData()}async fetchNewData(){return this.fetchingPromise||(this.fetchingPromise=new Promise(e=>{!function({opts:e,cb:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={user:{login_id:n,anon_id:i,props:{...Q(),...y.getCommonProps()}},sdk:"webjs",sdk_version:A};L({url:re(e),method:"POST",data:s,headers:oe(e),callback:e=>{200!==e.statusCode?console.error("Failed to fetch feature flags"):t&&t(e.json)}})}({opts:this.config,cb:t=>{y.saveABData(t.data?.results||[]),e(t),this.fetchingPromise=null}})})),this.fetchingPromise}async getFeatureGate(e){return await this.fastFetch().catch(console.warn),y.getABData().find(t=>t.typ===N.FEATURE_GATE&&t.key==e)}async checkFeatureGate(e){const t=await this.getFeatureGate(e);return!!t&&("fail"===t.vid?(de({isHit:!1,data:t,opts:this.config}),!1):(de({isHit:!0,data:t,opts:this.config}),!0))}async getExperiment(e){await this.fastFetch().catch(console.warn);const t=y.getABData().find(t=>t.typ===N.EXPERIMENT&&t.key===e);return t?t?.vid?(de({isHit:!0,data:t,opts:this.config}),t?.value||{}):(de({isHit:!1,data:t,opts:this.config}),{}):{}}destroy(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null),this.fetchingPromise=null}};Ne.NAME="abtest";let Te=Ne;const ye=[],Pe={debug:!1,apiToken:"",apiHost:"",autoCapture:!0,isSinglePageApp:!1,crossSubdomainCookie:!0,enableAB:!1,abRefreshInterval:T,enableClickTrack:!1,batchSend:!0},Ce=new class{constructor(){this.__loaded=!1,this.config={},this.eventEmitter=new e,this.pluginCore={},this.commonProps={},this.spaCleanup=null,O.instance=this}init(e,t={}){t.apiToken=e,this.mergeConfig(t),this.eventEmitter.emit("init-param",this.config);const n=this.config;return y.init(n.crossSubdomainCookie),this.__loaded=!0,window._solFailedRequestsInitialized||(window._solFailedRequestsInitialized=!0,function(){const e=V.getAll();0!==e.length&&e.forEach(e=>{ie(e.url,{data:e.data,headers:e.headers},e.id)})}()),n.autoCapture&&this.autoTrack(),n.enableAB&&ye.push(Te),n.enableClickTrack&&ye.push(be),this.pluginCore=new ge({plugins:ye,emitter:this.eventEmitter,config:n}),this.spaCleanup=function(e){let t=location.href;const n=window.history.pushState,i=window.history.replaceState,r=function(){e(t),t=location.href};return s(window.history.pushState)&&(window.history.pushState=function(...i){n.apply(window.history,i),e(t),t=location.href}),s(window.history.replaceState)&&(window.history.replaceState=function(...n){i.apply(window.history,n),e(t),t=location.href}),window.addEventListener("popstate",r),function(){s(window.history.pushState)&&(window.history.pushState=n),s(window.history.replaceState)&&(window.history.replaceState=i),window.removeEventListener("popstate",r)}}(e=>{this.eventEmitter.emit(R,e)}),this.eventEmitter.emit(_),this}mergeConfig(e){this.config={...Pe,...e}}track(e){!function(e,t){const n={...e};n.time||(n.time=Date.now()),n.login_id||(n.login_id=y.getLoginId()),n.anon_id||(n.anon_id=y.getAnonId()),n.properties={...Q(),...y.getCommonProps(),...n.properties},ae(se(t),{data:[n],headers:oe(t)})}(e,this.config)}trackEvent(e,t){le({event:e,properties:{...t,...this.commonProps}},this.config)}autoTrack(){ye.push(fe,Se,Ee)}profileSet(e){ce({userProps:{$set:e},opts:this.config})}profileSetOnce(e){ce({userProps:{$set_once:e},opts:this.config})}profileIncrement(e){ce({userProps:{$increment:e},opts:this.config})}profileAppend(e){ce({userProps:{$append:e},opts:this.config})}profileUnion(e){ce({userProps:{$union:e},opts:this.config})}profileUnset(e){const t={};r(e)?e.forEach(function(e){t[e]=null}):t[e]=null,ce({userProps:{$unset:t},opts:this.config})}profileDelete(){ce({userProps:{$delete:!0},opts:this.config})}registerCommonProperties(e){if(!i(e))return console.warn("Commmon Properties must be an object!");this.commonProps=e,y.setCommonProps(this.commonProps)}clearCommonProperties(e){if(!r(e))return console.warn("Commmon Properties to be cleared must be an array!");e.forEach(e=>{delete this.commonProps[e]}),y.setCommonProps(this.commonProps)}identify(e){y.setLoginId(e),function(e){const t=y.getLoginId(),n=y.getAnonId();if(!t||!n)return;const i={time:Date.now(),trace_id:y.getTraceId(),event:"$Identify",login_id:t,anon_id:n};ae(se(e),{data:[i],headers:oe(e)})}(this.config)}setLoginId(e){y.setLoginId(e)}getAnonId(){return y.getAnonId()}getLoginId(){return y.getLoginId()}checkFeatureGate(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.checkFeatureGate(e):Promise.reject("AB is disabled")}getExperiment(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.getExperiment(e):Promise.reject("AB is disabled")}destroy(){ne&&(ne.destroy(),ne=null),this.spaCleanup&&"function"==typeof this.spaCleanup&&(this.spaCleanup(),this.spaCleanup=null),this.pluginCore&&"function"==typeof this.pluginCore.destroy&&this.pluginCore.destroy(),this.eventEmitter&&this.eventEmitter.removeAllListeners(),O.instance===this&&(O.instance=null)}};module.exports=Ce;
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- class e{constructor(){this.listeners={}}on(e,t,n=!1){if(e&&t){if(!s(t))throw new Error("listener must be a function");this.listeners[e]=this.listeners[e]||[],this.listeners[e].push({listener:t,once:n})}}off(e,t){const n=this.listeners[e];if(!n?.length)return;"number"==typeof t&&n.splice(t,1);const i=n.findIndex(e=>e.listener===t);-1!==i&&n.splice(i,1)}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((n,i)=>{n.listener.call(this,...t),n.listener.once&&this.off(e,i)})}once(e,t){this.on(e,t,!0)}removeAllListeners(e){e?this.listeners[e]=[]:this.listeners={}}}const t={get:function(e){const t=e+"=",n=document.cookie.split(";");for(let i=0,s=n.length;i<s;i++){let e=n[i];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(t))return h(e.substring(t.length,e.length))}return null},set:function({name:e,value:t,expires:n,samesite:i,secure:s,domain:r}){let o="",a="",l="",c="";if(0!==(n=null==n||void 0===n?365:n)){const e=/* @__PURE__ */new Date;"s"===String(n).slice(-1)?e.setTime(e.getTime()+1e3*Number(String(n).slice(0,-1))):e.setTime(e.getTime()+24*n*60*60*1e3),o="; expires="+e.toUTCString()}function u(e){return e?e.replace(/\r\n/g,""):""}i&&(l="; SameSite="+i),s&&(a="; secure");const h=u(e),d=u(t),g=u(r);g&&(c="; domain="+g),h&&d&&(document.cookie=h+"="+encodeURIComponent(d)+o+"; path=/"+c+l+a)},remove:function(e){this.set({name:e,value:"",expires:-1})},isSupport:function({samesite:e,secure:t}={}){if(!navigator.cookieEnabled)return!1;const n="sol_cookie_support_test";return this.set({name:n,value:"1",samesite:e,secure:t}),"1"===this.get(n)&&(this.remove(n),!0)}},n=Object.prototype.toString;function i(e){return"[object Object]"===n.call(e)}function s(e){const t=n.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function r(e){return"[object Array]"==n.call(e)}function o(e){return"[object String]"==n.call(e)}function a(e){return void 0===e}const l=Object.prototype.hasOwnProperty;function c(e){if(i(e)){for(let t in e)if(l.call(e,t))return!1;return!0}return!1}function u(e){return!(!e||1!==e.nodeType)}function h(e){let t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t}function d(e){try{return JSON.parse(e)}catch(t){return""}}const g=function(){let e=Date.now();return function(t){return Math.ceil((e=(9301*e+49297)%233280,e/233280*t))}}();function p(){if("function"==typeof Uint32Array){let e;if("undefined"!=typeof crypto&&(e=crypto),e&&i(e)&&e.getRandomValues)return e.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}return g(1e19)/1e19}const f=/* @__PURE__ */function(){function e(){let e=Date.now(),t=0;for(;e==Date.now();)t++;return e.toString(16)+t.toString(16)}return function(){let t=String(screen.height*screen.width);t=t&&/\d{5,}/.test(t)?t.toString():String(31242*p()).replace(".","").slice(0,8);return e()+"-"+p().toString(16).replace(".","")+"-"+function(){const e=navigator.userAgent;let t,n=[],i=0;function s(e,t){let i=0;for(let s=0;s<t.length;s++)i|=n[s]<<8*s;return e^i}for(let r=0;r<e.length;r++)t=e.charCodeAt(r),n.unshift(255&t),n.length>=4&&(i=s(i,n),n=[]);return n.length>0&&(i=s(i,n)),i.toString(16)}()+"-"+t+"-"+e()||(String(p())+String(p())+String(p())).slice(2,15)}}();function m(e,t){t&&"string"==typeof t||(t="");let n=null;try{n=new URL(e).hostname}catch(i){}return n||t}function E(e){let t=[];try{t=atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})}catch(n){t=[]}try{return decodeURIComponent(t.join(""))}catch(n){return t.join("")}}function I(e){let t="";try{t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}))}catch(n){t=e}return t}const S={get:function(e){return window.localStorage.getItem(e)},parse:function(e){let t;try{t=JSON.parse(S.get(e))||null}catch(n){console.warn(n)}return t},set:function(e,t){try{window.localStorage.setItem(e,t)}catch(n){console.warn(n)}},remove:function(e){window.localStorage.removeItem(e)},isSupport:function(){let e=!0;try{const t="__local_store_support__",n="testIsSupportStorage";S.set(t,n),S.get(t)!==n&&(e=!1),S.remove(t)}catch(t){e=!1}return e}};function w(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}const O={},A="0.3.0",_="init-ready",R="spa-switch",v="ff-ready",b="$PageLeave";var N=/* @__PURE__ */(e=>(e[e.FEATURE_GATE=1]="FEATURE_GATE",e[e.FEATURE_CONFIG=2]="FEATURE_CONFIG",e[e.EXPERIMENT=3]="EXPERIMENT",e))(N||{});const T=6e5,y={crossSubdomain:!1,requests:[],_sessionState:{},_abData:[],_trace_id:"",commonProps:{},_state:{anon_id:"",login_id:"",identities:{}},getIdentityCookieID(){return this._state.identities?.$identity_cookie_id||""},getCommonProps:function(){return this.commonProps||{}},setCommonProps:function(e){this.commonProps=e},getAnonId(){return this.getIdentityCookieID()||this._state.anon_id||f()},getLoginId(){return this._state.login_id},getTraceId(){return this._trace_id||f()},set:function(e,t){this._state[e]=t,this.save()},getCookieName:function(){return"sol2025jssdkcross"},getABLSName:function(){return"sol2025jssdkablatest"},save:function(){let e=JSON.parse(JSON.stringify(this._state));e.identities&&(e.identities=I(JSON.stringify(e.identities)));const n=JSON.stringify(e);t.set({name:this.getCookieName(),value:n,expires:365})},init:function(e){let n,s;this.crossSubdomain=e,t.isSupport()&&(n=t.get(this.getCookieName()),s=d(n)),y._state={...s||{}},y._state.identities&&(y._state.identities=d(E(y._state.identities))),y._state.identities&&i(y._state.identities)&&!c(y._state.identities)||(y._state.identities={$identity_cookie_id:f()}),y.save()},setLoginId(e){"number"==typeof e&&(e=String(e)),void 0!==e&&e&&(y.set("login_id",e),y.save())},saveABData(e){if(!e||c(e))return;this._abData=e;let t=JSON.parse(JSON.stringify(this._abData));t=I(JSON.stringify(t));try{localStorage.setItem(this.getABLSName(),JSON.stringify({time:Date.now(),data:t,anon_id:this.getAnonId(),login_id:this.getLoginId()}))}catch(n){console.warn("Failed to save abdata to localStorage",n)}},getABData(){try{let e=localStorage.getItem(this.getABLSName());if(e){const{time:t,data:n,login_id:i,anon_id:s}=d(e)||{};if(t&&n&&Date.now()-t<T&&s===this.getAnonId()&&(!i||i===this.getLoginId()))return d(E(n));localStorage.removeItem(this.getABLSName())}}catch(e){console.warn("Failed to load abdata from localStorage",e),this._abData=[]}return this._abData||[]}};function P(e){var t;if(e.data)return{contentType:"application/json",body:(t=e.data,JSON.stringify(t,(e,t)=>"bigint"==typeof t?t.toString():t,undefined))}}const C=[];function L(e){const t={...e};t.timeout=t.timeout||6e4;const n=t.transport??"fetch",i=C.find(e=>e.transport===n)?.method??C[0]?.method;if(!i)throw new Error("No available transport method for HTTP request");i(t)}function B(e){return o(e=e||document.referrer)&&(e=h(e=e.trim()))||""}function F(e){const t=m(e=e||B());if(!t)return"";const n={baidu:[/^.*\.baidu\.com$/],bing:[/^.*\.bing\.com$/],google:[/^www\.google\.com$/,/^www\.google\.com\.[a-z]{2}$/,/^www\.google\.[a-z]{2}$/],sm:[/^m\.sm\.cn$/],so:[/^.+\.so\.com$/],sogou:[/^.*\.sogou\.com$/],yahoo:[/^.*\.yahoo\.com$/],duckduckgo:[/^.*\.duckduckgo\.com$/]};for(let i of Object.keys(n)){let e=n[i];for(let n=0,s=e.length;n<s;n++)if(e[n].test(t))return i}return"Unknown Search Engine"}function M(e,t){return-1!==e.indexOf(t)}"function"==typeof fetch&&C.push({transport:"fetch",method:function(e){if("undefined"==typeof fetch)return void console.error("fetch API is not available");const t=P(e),n=new Headers;e.headers&&Object.keys(e.headers).forEach(t=>{n.append(t,e.headers[t])}),t?.contentType&&n.append("Content-Type",t.contentType),fetch(e.url,{method:e.method||"GET",headers:n,body:t?.body}).then(t=>t.text().then(n=>{const i={statusCode:t.status,text:n};if(200===t.status)try{i.json=JSON.parse(n)}catch(s){console.error("Failed to parse response:",s)}e.callback?.(i)})).catch(t=>{console.error("Request failed:",t),e.callback?.({statusCode:0,text:String(t)})})}}),"undefined"!=typeof XMLHttpRequest&&C.push({transport:"XHR",method:function(e){if("undefined"==typeof XMLHttpRequest)return void console.error("XMLHttpRequest is not available");const t=new XMLHttpRequest;t.open(e.method||"GET",e.url,!0);const n=P(e);e.headers&&Object.keys(e.headers).forEach(n=>{t.setRequestHeader(n,e.headers[n])}),n?.contentType&&t.setRequestHeader("Content-Type",n.contentType),t.timeout=e.timeout||6e4,t.withCredentials=!0,t.onreadystatechange=()=>{if(4===t.readyState){const i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(n){console.error("Failed to parse JSON response:",n)}e.callback?.(i)}},t.send(n?.body)}});const D={FACEBOOK:"Facebook",MOBILE:"Mobile",IOS:"iOS",ANDROID:"Android",TABLET:"Tablet",ANDROID_TABLET:"Android Tablet",IPAD:"iPad",APPLE:"Apple",APPLE_WATCH:"Apple Watch",SAFARI:"Safari",BLACKBERRY:"BlackBerry",SAMSUNG_BROWSER:"SamsungBrowser",SAMSUNG_INTERNET:"Samsung Internet",CHROME:"Chrome",CHROME_OS:"Chrome OS",CHROME_IOS:"Chrome iOS",INTERNET_EXPLORER:"Internet Explorer",INTERNET_EXPLORER_MOBILE:"Internet Explorer Mobile",OPERA:"Opera",OPERA_MINI:"Opera Mini",EDGE:"Edge",MICROSOFT_EDGE:"Microsoft Edge",FIREFOX:"Firefox",FIREFOX_IOS:"Firefox iOS",NINTENDO:"Nintendo",PLAYSTATION:"PlayStation",XBOX:"Xbox",ANDROID_MOBILE:"Android Mobile",MOBILE_SAFARI:"Mobile Safari",WINDOWS:"Windows",WINDOWS_PHONE:"Windows Phone",NOKIA:"Nokia",OUYA:"Ouya",GENERIC_MOBILE:"Generic mobile",GENERIC_TABLET:"Generic tablet",KONQUEROR:"Konqueror",UC_BROWSER:"UC Browser",HUAWEI:"Huawei",XIAOMI:"Xiaomi",OPPO:"OPPO",VIVO:"vivo"},x="(\\d+(\\.\\d+)?)",k=new RegExp("Version/"+x),H=new RegExp(D.XBOX,"i"),$=new RegExp(D.PLAYSTATION+" \\w+","i"),X=new RegExp(D.NINTENDO+" \\w+","i"),U=new RegExp(D.BLACKBERRY+"|PlayBook|BB10","i"),q=new RegExp("(HUAWEI|honor|HONOR)","i"),W=new RegExp("(Xiaomi|Redmi)","i"),G=new RegExp("(OPPO|realme)","i"),j=new RegExp("(vivo|IQOO)","i"),Y={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function z(e,t){return t=t||"",M(e," OPR/")&&M(e,"Mini")?D.OPERA_MINI:M(e," OPR/")?D.OPERA:U.test(e)?D.BLACKBERRY:M(e,"IE"+D.MOBILE)||M(e,"WPDesktop")?D.INTERNET_EXPLORER_MOBILE:M(e,D.SAMSUNG_BROWSER)?D.SAMSUNG_INTERNET:M(e,D.EDGE)||M(e,"Edg/")?D.MICROSOFT_EDGE:M(e,"FBIOS")?D.FACEBOOK+" "+D.MOBILE:M(e,"UCWEB")||M(e,"UCBrowser")?D.UC_BROWSER:M(e,"CriOS")?D.CHROME_IOS:M(e,"CrMo")||M(e,D.CHROME)?D.CHROME:M(e,D.ANDROID)&&M(e,D.SAFARI)?D.ANDROID_MOBILE:M(e,"FxiOS")?D.FIREFOX_IOS:M(e.toLowerCase(),D.KONQUEROR.toLowerCase())?D.KONQUEROR:function(e,t){return t&&M(t,D.APPLE)||M(n=e,D.SAFARI)&&!M(n,D.CHROME)&&!M(n,D.ANDROID);var n}(e,t)?M(e,D.MOBILE)?D.MOBILE_SAFARI:D.SAFARI:M(e,D.FIREFOX)?D.FIREFOX:M(e,"MSIE")||M(e,"Trident/")?D.INTERNET_EXPLORER:M(e,"Gecko")?D.FIREFOX:""}const K={[D.INTERNET_EXPLORER_MOBILE]:[new RegExp("rv:"+x)],[D.MICROSOFT_EDGE]:[new RegExp(D.EDGE+"?\\/"+x)],[D.CHROME]:[new RegExp("("+D.CHROME+"|CrMo)\\/"+x)],[D.CHROME_IOS]:[new RegExp("CriOS\\/"+x)],[D.UC_BROWSER]:[new RegExp("(UCBrowser|UCWEB)\\/"+x)],[D.SAFARI]:[k],[D.MOBILE_SAFARI]:[k],[D.OPERA]:[new RegExp("("+D.OPERA+"|OPR)\\/"+x)],[D.FIREFOX]:[new RegExp(D.FIREFOX+"\\/"+x)],[D.FIREFOX_IOS]:[new RegExp("FxiOS\\/"+x)],[D.KONQUEROR]:[new RegExp("Konqueror[:/]?"+x,"i")],[D.BLACKBERRY]:[new RegExp(D.BLACKBERRY+" "+x),k],[D.ANDROID_MOBILE]:[new RegExp("android\\s"+x,"i")],[D.SAMSUNG_INTERNET]:[new RegExp(D.SAMSUNG_BROWSER+"\\/"+x)],[D.INTERNET_EXPLORER]:[new RegExp("(rv:|MSIE )"+x)],Mozilla:[new RegExp("rv:"+x)]};function J(e,t){const n=z(e,t),i=K[n];if(a(i))return null;for(let s=0;s<i.length;s++){const t=i[s],n=e.match(t);if(n)return parseFloat(n[n.length-2])}return null}const Z=[[new RegExp(D.XBOX+"; "+D.XBOX+" (.*?)[);]","i"),e=>[D.XBOX,e&&e[1]||""]],[new RegExp(D.NINTENDO,"i"),[D.NINTENDO,""]],[new RegExp(D.PLAYSTATION,"i"),[D.PLAYSTATION,""]],[U,[D.BLACKBERRY,""]],[new RegExp(D.WINDOWS,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[D.WINDOWS_PHONE,""];if(new RegExp(D.MOBILE).test(t)&&!/IEMobile\b/.test(t))return[D.WINDOWS+" "+D.MOBILE,""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){const e=n[1];let i=Y[e]||"";return/arm/i.test(t)&&(i="RT"),[D.WINDOWS,i]}return[D.WINDOWS,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[D.IOS,t.join(".")]}return[D.IOS,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=a(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+D.ANDROID+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+D.ANDROID+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[D.ANDROID,t.join(".")]}return[D.ANDROID,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[D.CHROME_OS,""]],[/Linux|debian/i,["Linux",""]]];function Q(){const e=window.innerHeight||document.documentElement.clientHeight||document.body&&document.body.clientHeight||0,t=window.innerWidth||document.documentElement.clientWidth||document.body&&document.body.clientWidth||0,n=navigator.userAgent,i=function(e){for(let t=0;t<Z.length;t++){const[n,i]=Z[t],s=n.exec(e),r=s&&("function"==typeof i?i(s,e):i);if(r)return r}return["",""]}(n)||["",""];return{$browser:z(n),$browser_version:J(n),$url:location?.href.substring(0,1e3),$host:location?.host,$viewport_height:e,$viewport_width:t,$lib:"webjs",$lib_version:A,$search_engine:F(),$referrer:B(),$referrer_domain:m(r=r||B()),$model:(s=n,(X.test(s)?D.NINTENDO:$.test(s)?D.PLAYSTATION:H.test(s)?D.XBOX:new RegExp(D.OUYA,"i").test(s)?D.OUYA:new RegExp("("+D.WINDOWS_PHONE+"|WPDesktop)","i").test(s)?D.WINDOWS_PHONE:/iPad/.test(s)?D.IPAD:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?D.APPLE_WATCH:U.test(s)?D.BLACKBERRY:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(D.NOKIA,"i").test(s)?D.NOKIA:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":q.test(s)?D.HUAWEI:W.test(s)?D.XIAOMI:G.test(s)?D.OPPO:j.test(s)?D.VIVO:/(Android|ZTE)/i.test(s)?!new RegExp(D.MOBILE).test(s)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)?/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?D.ANDROID:D.ANDROID_TABLET:D.ANDROID:new RegExp("(pda|"+D.MOBILE+")","i").test(s)?D.GENERIC_MOBILE:new RegExp(D.TABLET,"i").test(s)&&!new RegExp(D.TABLET+" pc","i").test(s)?D.GENERIC_TABLET:"")||""),$os:i?.[0]||"",$os_version:i?.[1]||"",$pathname:location?.pathname,$screen_height:Number(screen.height)||0,$screen_width:Number(screen.width)||0};var s,r}const V=new class{constructor(){this.STORAGE_KEY="sol_unsent_events",this.MAX_QUEUE_SIZE=100,this.MAX_RETRY_COUNT=3,this.MAX_AGE_MS=6048e5,this.queue=[],this.loadFromStorage(),this.cleanupExpiredItems()}loadFromStorage(){try{const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.queue=d(e)||[])}catch(e){console.warn("Failed to load queue from localStorage:",e),this.queue=[]}}cleanupExpiredItems(){const e=Date.now(),t=this.queue.filter(t=>e-t.timestamp<this.MAX_AGE_MS&&t.retryCount<t.maxRetries);t.length!==this.queue.length&&(this.queue=t,this.saveToStorage())}saveToStorage(){try{this.cleanupExpiredItems(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE)),localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.queue))}catch(e){console.warn("Failed to save queue to localStorage:",e)}}enqueue(e,t,n,i=this.MAX_RETRY_COUNT){try{const s={id:f(),url:e,data:t,headers:n,timestamp:Date.now(),retryCount:0,maxRetries:i};return this.queue.push(s),this.saveToStorage(),s.id}catch(s){return console.warn("Failed to enqueue request:",s),""}}dequeue(e){try{this.queue=this.queue.filter(t=>t.id!==e),this.saveToStorage()}catch(t){console.warn("Failed to dequeue request:",t)}}getAll(){try{return this.cleanupExpiredItems(),[...this.queue]}catch(e){return console.warn("Failed to get queue items:",e),[]}}incrementRetryCount(e){const t=this.queue.find(t=>t.id===e);return!!t&&(t.retryCount++,t.retryCount>=t.maxRetries?(this.dequeue(e),!1):(this.saveToStorage(),!0))}clear(){this.queue=[];try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn("Failed to clear queue from localStorage:",e)}}getItemById(e){return this.queue.find(t=>t.id===e)}};class ee{constructor(e={}){this.flushTimer=null,this.isFlushing=!1,this.pendingFlush=!1,this.config={maxBatchSize:e.maxBatchSize||10,flushInterval:e.flushInterval||5e3},this.startFlushTimer()}add(){V.getAll().length>=this.config.maxBatchSize&&this.triggerFlush()}triggerFlush(){this.isFlushing?this.pendingFlush=!0:(this.isFlushing=!0,this.flush())}flush(){const e=V.getAll();if(0===e.length)return this.isFlushing=!1,void(this.pendingFlush&&(this.pendingFlush=!1,this.triggerFlush()));const t=[],n=[];e.forEach(e=>{Array.isArray(e.data)?t.push(...e.data):t.push(e.data),n.push(e.id)});const i=t.slice(0,this.config.maxBatchSize),s=e[0],r=s.url,o=s.headers;O.instance.config.debug&&console.log(JSON.stringify(i,null,2)),L({url:r,method:"POST",data:i,headers:o,callback:e=>{200!==e.statusCode?console.error("Failed to send batch events:",e):n.forEach(e=>{V.dequeue(e)}),this.isFlushing=!1;const t=V.getAll();(this.pendingFlush||t.length>=this.config.maxBatchSize)&&(this.pendingFlush=!1,this.triggerFlush())}})}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush()}}let te=null,ne=null;function ie(e,t,n){return L({url:e,method:"POST",data:t.data,headers:t.headers,callback:e=>{if(200!==e.statusCode){if(n)if(V.incrementRetryCount(n)){const e=V.getItemById(n);if(e){const t=Math.min(1e3*Math.pow(2,e.retryCount),3e4);setTimeout(()=>{ie(e.url,{data:e.data,headers:e.headers},e.id)},t)}}else console.warn("Max retries reached for request:",n)}else n&&V.dequeue(n),t.callback&&t.callback(e.json)}})}function se(e){return`${e.apiHost}/in/track`}function re(e){return`${e.apiHost}/api/abol/evalall`}function oe(e){return{"Content-Type":"application/json",ProjectToken:e.apiToken}}function ae(e,t,n){O.instance.config.debug&&console.log(JSON.stringify(t.data,null,2));const i=V.enqueue(e,t.data,t.headers);return ie(e,{...t,callback:void 0},i)}function le(e,t,n=!0){const i={time:Date.now(),trace_id:y.getTraceId(),event:e.event,properties:{...n?Q():{},...y.getCommonProps(),...e.properties}},s=y.getLoginId(),r=y.getAnonId();s&&(i.login_id=s),r&&(i.anon_id=r);const o=se(t),a=oe(t),l=S.isSupport()?(ne||(te||(te=new ee({maxBatchSize:10,flushInterval:5e3})),ne=te),ne):null;!1!==t.batchSend&&l?(V.enqueue(o,[i],a),l.add()):ae(o,{data:[i],headers:a})}function ce({userProps:e,opts:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={time:Date.now(),trace_id:y.getTraceId(),event:"$UserSet",login_id:n,anon_id:i,user_properties:e};return ae(se(t),{data:[s],headers:oe(t)})}function ue(e){return`$ab_${e.id}`}function he(e){const t=e.typ;return t===N.FEATURE_GATE&&"fail"!==e.vid?{[ue(e)]:e.vid}:t===N.EXPERIMENT?{[ue(e)]:e.vid}:{}}function de({isHit:e,data:t,opts:n}){if(!t||c(t))return;let i={};i=e?{$set:{...he(t)}}:{$unset:{[ue(t)]:null}};const s=y.getLoginId(),r=y.getAnonId();if(!s||!r)return;const o={time:Date.now(),trace_id:y.getTraceId(),event:"$ABImpress",login_id:s,anon_id:r,properties:{...Q(),...y.getCommonProps()},user_properties:{...i}};return ae(se(n),{data:[o],headers:oe(n)})}class ge{constructor({plugins:e,emitter:t,config:n}){this.plugins=[],this.pluginInsMap={},this.emitter=t,this.config=n,this.registerBuiltInPlugins(e),this.created(),this.emitter.on(_,()=>{this.init()})}registerBuiltInPlugins(e){for(let t=0,n=e.length;t<n;t++)this.registerPlugin(e[t])}registerPlugin(e){this.plugins.push(e)}getPlugins(){return this.plugins}getPlugin(e){return this.pluginInsMap[e]}created(){for(let e=0,t=this.plugins.length;e<t;e++){const t=this.plugins[e];if(!t.NAME)throw new Error('Plugin should be defined with "NAME"');const n=new t({emitter:this.emitter,config:this.config});this.pluginInsMap[t.NAME]=n}}init(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.init&&t.init()}}destroy(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.destroy&&"function"==typeof t.destroy&&t.destroy()}this.pluginInsMap={},this.plugins=[]}}const pe=class{constructor({emitter:e,config:t}){this.boundSend=null,this.hashEvent=null,this.emitter=e,this.config=t}init(){const e=this.config;this.boundSend=()=>{le({event:"$PageView",properties:{$title:document.title}},e)},e.isSinglePageApp?(this.hashEvent="pushState"in window.history?"popstate":"hashchange",window.addEventListener(this.hashEvent,this.boundSend)):this.boundSend()}destroy(){this.hashEvent&&this.boundSend&&(window.removeEventListener(this.hashEvent,this.boundSend),this.hashEvent=null,this.boundSend=null)}};pe.NAME="pageview";let fe=pe;const me=class{constructor({emitter:e,config:t}){this.startTime=Date.now(),this.pageShowStatus=!0,this.pageHiddenStatus=!1,this.timer=null,this.currentPageUrl=document.referrer,this.url=location.href,this.title=document.title||"",this.heartbeatIntervalTime=5e3,this.heartbeatIntervalTimer=null,this.pageId=null,this.storageName="solwebjssdkpageleave",this.maxDuration=432e3,this.eventListeners=[],this.emitter=e,this.config=t}init(){this.pageId=Number(String(p()).slice(2,5)+String(p()).slice(2,4)+String(Date.now()).slice(-4)),this.addEventListener(),!0===document.hidden?this.pageShowStatus=!1:this.addHeartBeatInterval()}log(e){console.log(e)}refreshPageEndTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this.pageHiddenStatus=!1},5e3)}hiddenStatusHandler(){this.timer&&clearTimeout(this.timer),this.timer=null,this.pageHiddenStatus=!1}pageStartHandler(){this.startTime=Date.now(),1==!document.hidden?this.pageShowStatus=!0:this.pageShowStatus=!1,this.url=location.href,this.title=document.title}pageEndHandler(){if(!0===this.pageHiddenStatus)return;const e=this.getPageLeaveProperties();!1===this.pageShowStatus&&delete e.event_duration,this.pageShowStatus=!1,this.pageHiddenStatus=!0,le({event:b,properties:e},this.config),this.refreshPageEndTimer(),this.delHeartBeatData()}addEventListener(){this.addPageStartListener(),this.addPageSwitchListener(),this.addSinglePageListener(),this.addPageEndListener()}addPageStartListener(){if("onpageshow"in window){const e=()=>{this.pageStartHandler(),this.hiddenStatusHandler()};window.addEventListener("pageshow",e),this.eventListeners.push({target:window,event:"pageshow",handler:e})}}addSinglePageListener(){this.config.isSinglePageApp&&this.emitter.on(R,e=>{e!==location.href&&(this.url=e,this.pageEndHandler(),this.stopHeartBeatInterval(),this.currentPageUrl=this.url,this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval())})}addPageEndListener(){["pagehide","beforeunload","unload"].forEach(e=>{if(`on${e}`in window){const t=()=>{this.pageEndHandler(),this.stopHeartBeatInterval()};window.addEventListener(e,t),this.eventListeners.push({target:window,event:e,handler:t})}})}addPageSwitchListener(){const e=()=>{"visible"===document.visibilityState?(this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval()):(this.url=location.href,this.title=document.title,this.pageEndHandler(),this.stopHeartBeatInterval())};document.addEventListener("visibilitychange",e),this.eventListeners.push({target:document,event:"visibilitychange",handler:e})}addHeartBeatInterval(){S.isSupport()&&this.startHeartBeatInterval()}startHeartBeatInterval(){this.heartbeatIntervalTimer&&this.stopHeartBeatInterval(),this.heartbeatIntervalTimer=setInterval(()=>{this.saveHeartBeatData()},this.heartbeatIntervalTime),this.saveHeartBeatData("is_first_heartbeat"),this.reissueHeartBeatData()}stopHeartBeatInterval(){this.heartbeatIntervalTimer&&clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null}saveHeartBeatData(e){const t=this.getPageLeaveProperties();t.$time=Date.now(),"is_first_heartbeat"===e&&(t.event_duration=3);const n={type:"track",event:b,properties:t};n.heartbeat_interval_time=this.heartbeatIntervalTime,S.isSupport()&&S.set(`${this.storageName}-${this.pageId}`,JSON.stringify(n))}delHeartBeatData(e){S.isSupport()&&S.remove(e||`${this.storageName}-${this.pageId}`)}reissueHeartBeatData(){for(let e=window.localStorage.length-1;e>=0;e--){const t=window.localStorage.key(e);if(t&&t!==`${this.storageName}-${this.pageId}`&&0===t.indexOf(`${this.storageName}-`)){const e=S.parse(t);i(e)&&Date.now()-e.time>e.heartbeat_interval_time+5e3&&(delete e.heartbeat_interval_time,e._flush_time=/* @__PURE__ */(new Date).getTime(),le({event:b,properties:e?.properties},this.config),this.delHeartBeatData(t))}}}getPageLeaveProperties(){let e=(Date.now()-this.startTime)/1e3;(isNaN(e)||e<0||e>this.maxDuration)&&(e=0),e=Number(e.toFixed(3));const t=document.documentElement&&document.documentElement.scrollTop||window.pageYOffset||document.body&&document.body.scrollTop||0,n=Math.round(t)||0,i={$title:this.title,$viewport_position:n};return 0!==e&&(i.event_duration=e),i}destroy(){this.eventListeners.forEach(({target:e,event:t,handler:n})=>{e.removeEventListener(t,n)}),this.eventListeners=[],this.timer&&(clearTimeout(this.timer),this.timer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};me.NAME="pageleave";let Ee=me;const Ie=class{constructor({emitter:e,config:t}){this.eventSended=!1,this.emitter=e,this.config=t}init(){const e=()=>{let t=0;const n=window.performance,i={$title:document.title};if(n){t=function(){let e=0;if("function"==typeof performance.getEntriesByType){const t=performance.getEntriesByType("navigation");t.length>0&&(e=t[0].domContentLoadedEventEnd||0)}return e}();const e=function(){if(performance.getEntries&&"function"==typeof performance.getEntries){const e=performance.getEntries();let t=0;for(const n of e)"transferSize"in n&&(t+=n.transferSize);if("number"==typeof t&&t>=0&&t<10737418240)return Number((t/1024).toFixed(3))}}();e&&(i.$page_resource_size=e)}else console.warn("Performance API is not supported.");t>0&&!Number.isFinite(t)&&(i.event_duration=Number((t/1e3).toFixed(3))),this.eventSended||(this.eventSended=!0,le({event:"$PageLoad",properties:i},this.config)),window.removeEventListener("load",e)};"complete"===document.readyState?e():window.addEventListener&&window.addEventListener("load",e)}};Ie.NAME="pageload";let Se=Ie;function we(e,t){if(!u(e))return!1;const n=o(e.tagName)?e.tagName.toLowerCase():"unknown",i={};i.$element_type=n,i.$element_name=e.getAttribute("name"),i.$element_id=e.getAttribute("id"),i.$element_class_name=o(e.className)?e.className:null,i.$element_target_url=e.getAttribute("href"),i.$element_content=function(e,t){return o(t)&&"input"===t.toLowerCase()?("button"===(n=e).type||"submit"===n.type)&&n.value||"":function(e,t){let n="",i="";return e.textContent?n=w(e.textContent):e.innerText&&(n=w(e.innerText)),n&&(n=n.replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)),i=n||"","input"!==t&&"INPUT"!==t||(i=e.value||""),i}(e,t);var n}(e,n),i.$element_selector=Oe(e),i.$element_path=function(e){let t=[];for(;e.parentNode&&u(e);){if(!o(e.tagName))return"unknown";if(e.id&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.id)){t.unshift(e.tagName.toLowerCase()+"#"+e.id);break}if(e===document.body){t.unshift("body");break}t.unshift(e.tagName.toLowerCase()),e=e.parentNode}return t.join(" > ")}(e),i.$url_path=location.pathname,i.$title=document.title;const s=function(e,t){const n=t.pageX||t.clientX+Ae().scrollLeft||t.offsetX+_e(e).targetEleX,i=t.pageY||t.clientY+Ae().scrollTop||t.offsetY+_e(e).targetEleY;return{$page_x:Re(n),$page_y:Re(i)}}(e,t);return i.$page_x=s.$page_x,i.$page_y=s.$page_y,i}function Oe(e,t=[]){if(!(e&&e.parentNode&&e.parentNode.children&&o(e.tagName)))return"unknown";t=Array.isArray(t)?t:[];const n=e.nodeName.toLowerCase();return e&&"body"!==n&&1==e.nodeType?(t.unshift(function(e){if(!e||!u(e)||!o(e.tagName))return"";let t=e.parentNode&&9==e.parentNode.nodeType?-1:function(e){if(!e.parentNode)return-1;let t=0;const n=e.tagName,i=e.parentNode.children;for(let s=0,r=i.length;s<r;s++)if(i[s].tagName===n){if(e===i[s])return t;t++}return-1}(e);return e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?"#"+e.getAttribute("id"):e.tagName.toLowerCase()+(~t?":nth-of-type("+(t+1)+")":"")}(e)),e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?t.join(" > "):Oe(e.parentNode,t)):(t.unshift("body"),t.join(" > "))}function Ae(){return{scrollLeft:document.body.scrollLeft||document.documentElement.scrollLeft||0,scrollTop:document.body.scrollTop||document.documentElement.scrollTop||0}}function _e(e){if(document.documentElement.getBoundingClientRect){const t=e.getBoundingClientRect();return{targetEleX:t.left+Ae().scrollLeft||0,targetEleY:t.top+Ae().scrollTop||0}}return{targetEleX:0,targetEleY:0}}function Re(e){return Number(Number(e).toFixed(3))}const ve=class{constructor({emitter:e,config:t}){this.isInitialized=!1,this.boundHandleClick=null,this.emitter=e,this.config=t}init(){this.isInitialized||(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,!0),this.isInitialized=!0)}handleClick(e){const t=e.target;if(!t)return;if(!["A","INPUT","BUTTON","TEXTAREA"].includes(t.tagName))return;if("true"===t.getAttribute("sol-disable"))return;le({event:"$WebClick",properties:we(t,e)||{}},this.config)}destroy(){this.boundHandleClick&&(document.removeEventListener("click",this.boundHandleClick,!0),this.boundHandleClick=null),this.isInitialized=!1}};ve.NAME="webclick";let be=ve;const Ne=class{constructor({emitter:e,config:t}){this.updateInterval=null,this.fetchingPromise=null,this.emitter=e,this.config=t}init(){const e=this.config;e.enableAB&&(this.fastFetch().then(()=>{this.emitter.emit(v)}),e.abRefreshInterval<3e4&&(e.abRefreshInterval=3e4),this.updateInterval=setInterval(()=>{this.fetchNewData().catch(console.warn)},e.abRefreshInterval))}async fastFetch(){const e=y.getABData();return e&&e.length?(this.emitter.emit(v),Promise.resolve(e)):this.fetchNewData()}async fetchNewData(){return this.fetchingPromise||(this.fetchingPromise=new Promise(e=>{!function({opts:e,cb:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={user:{login_id:n,anon_id:i,props:{...Q(),...y.getCommonProps()}},sdk:"webjs",sdk_version:A};L({url:re(e),method:"POST",data:s,headers:oe(e),callback:e=>{200!==e.statusCode?console.error("Failed to fetch feature flags"):t&&t(e.json)}})}({opts:this.config,cb:t=>{y.saveABData(t.data?.results||[]),e(t),this.fetchingPromise=null}})})),this.fetchingPromise}async getFeatureGate(e){return await this.fastFetch().catch(console.warn),y.getABData().find(t=>t.typ===N.FEATURE_GATE&&t.key==e)}async checkFeatureGate(e){const t=await this.getFeatureGate(e);return!!t&&("fail"===t.vid?(de({isHit:!1,data:t,opts:this.config}),!1):(de({isHit:!0,data:t,opts:this.config}),!0))}async getExperiment(e){await this.fastFetch().catch(console.warn);const t=y.getABData().find(t=>t.typ===N.EXPERIMENT&&t.key===e);return t?t?.vid?(de({isHit:!0,data:t,opts:this.config}),t?.value||{}):(de({isHit:!1,data:t,opts:this.config}),{}):{}}destroy(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null),this.fetchingPromise=null}};Ne.NAME="abtest";let Te=Ne;const ye=[],Pe={debug:!1,apiToken:"",apiHost:"",autoCapture:!0,isSinglePageApp:!1,crossSubdomainCookie:!0,enableAB:!1,abRefreshInterval:T,enableClickTrack:!1,batchSend:!0},Ce=new class{constructor(){this.__loaded=!1,this.config={},this.eventEmitter=new e,this.pluginCore={},this.commonProps={},this.spaCleanup=null,O.instance=this}init(e,t={}){t.apiToken=e,this.mergeConfig(t),this.eventEmitter.emit("init-param",this.config);const n=this.config;return y.init(n.crossSubdomainCookie),this.__loaded=!0,window._solFailedRequestsInitialized||(window._solFailedRequestsInitialized=!0,function(){const e=V.getAll();0!==e.length&&e.forEach(e=>{ie(e.url,{data:e.data,headers:e.headers},e.id)})}()),n.autoCapture&&this.autoTrack(),n.enableAB&&ye.push(Te),n.enableClickTrack&&ye.push(be),this.pluginCore=new ge({plugins:ye,emitter:this.eventEmitter,config:n}),this.spaCleanup=function(e){let t=location.href;const n=window.history.pushState,i=window.history.replaceState,r=function(){e(t),t=location.href};return s(window.history.pushState)&&(window.history.pushState=function(...i){n.apply(window.history,i),e(t),t=location.href}),s(window.history.replaceState)&&(window.history.replaceState=function(...n){i.apply(window.history,n),e(t),t=location.href}),window.addEventListener("popstate",r),function(){s(window.history.pushState)&&(window.history.pushState=n),s(window.history.replaceState)&&(window.history.replaceState=i),window.removeEventListener("popstate",r)}}(e=>{this.eventEmitter.emit(R,e)}),this.eventEmitter.emit(_),this}mergeConfig(e){this.config={...Pe,...e}}track(e){!function(e,t){const n={...e};n.time||(n.time=Date.now()),n.login_id||(n.login_id=y.getLoginId()),n.anon_id||(n.anon_id=y.getAnonId()),n.properties={...Q(),...y.getCommonProps(),...n.properties},ae(se(t),{data:[n],headers:oe(t)})}(e,this.config)}trackEvent(e,t){le({event:e,properties:{...t,...this.commonProps}},this.config)}autoTrack(){ye.push(fe,Se,Ee)}profileSet(e){ce({userProps:{$set:e},opts:this.config})}profileSetOnce(e){ce({userProps:{$set_once:e},opts:this.config})}profileIncrement(e){ce({userProps:{$increment:e},opts:this.config})}profileAppend(e){ce({userProps:{$append:e},opts:this.config})}profileUnion(e){ce({userProps:{$union:e},opts:this.config})}profileUnset(e){const t={};r(e)?e.forEach(function(e){t[e]=null}):t[e]=null,ce({userProps:{$unset:t},opts:this.config})}profileDelete(){ce({userProps:{$delete:!0},opts:this.config})}registerCommonProperties(e){if(!i(e))return console.warn("Commmon Properties must be an object!");this.commonProps=e,y.setCommonProps(this.commonProps)}clearCommonProperties(e){if(!r(e))return console.warn("Commmon Properties to be cleared must be an array!");e.forEach(e=>{delete this.commonProps[e]}),y.setCommonProps(this.commonProps)}identify(e){y.setLoginId(e),function(e){const t=y.getLoginId(),n=y.getAnonId();if(!t||!n)return;const i={time:Date.now(),trace_id:y.getTraceId(),event:"$Identify",login_id:t,anon_id:n};ae(se(e),{data:[i],headers:oe(e)})}(this.config)}setLoginId(e){y.setLoginId(e)}getAnonId(){return y.getAnonId()}getLoginId(){return y.getLoginId()}checkFeatureGate(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.checkFeatureGate(e):Promise.reject("AB is disabled")}getExperiment(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.getExperiment(e):Promise.reject("AB is disabled")}destroy(){ne&&(ne.destroy(),ne=null),this.spaCleanup&&"function"==typeof this.spaCleanup&&(this.spaCleanup(),this.spaCleanup=null),this.pluginCore&&"function"==typeof this.pluginCore.destroy&&this.pluginCore.destroy(),this.eventEmitter&&this.eventEmitter.removeAllListeners(),O.instance===this&&(O.instance=null)}};export{Ce as default};
1
+ class e{constructor(){this.listeners={}}on(e,t,n=!1){if(e&&t){if(!s(t))throw new Error("listener must be a function");this.listeners[e]=this.listeners[e]||[],this.listeners[e].push({listener:t,once:n})}}off(e,t){const n=this.listeners[e];if(!n?.length)return;"number"==typeof t&&n.splice(t,1);const i=n.findIndex(e=>e.listener===t);-1!==i&&n.splice(i,1)}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((n,i)=>{n.listener.call(this,...t),n.listener.once&&this.off(e,i)})}once(e,t){this.on(e,t,!0)}removeAllListeners(e){e?this.listeners[e]=[]:this.listeners={}}}const t={get:function(e){const t=e+"=",n=document.cookie.split(";");for(let i=0,s=n.length;i<s;i++){let e=n[i];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(t))return h(e.substring(t.length,e.length))}return null},set:function({name:e,value:t,expires:n,samesite:i,secure:s,domain:r}){let o="",a="",l="",c="";if(0!==(n=null==n||void 0===n?365:n)){const e=/* @__PURE__ */new Date;"s"===String(n).slice(-1)?e.setTime(e.getTime()+1e3*Number(String(n).slice(0,-1))):e.setTime(e.getTime()+24*n*60*60*1e3),o="; expires="+e.toUTCString()}function u(e){return e?e.replace(/\r\n/g,""):""}i&&(l="; SameSite="+i),s&&(a="; secure");const h=u(e),d=u(t),g=u(r);g&&(c="; domain="+g),h&&d&&(document.cookie=h+"="+encodeURIComponent(d)+o+"; path=/"+c+l+a)},remove:function(e){this.set({name:e,value:"",expires:-1})},isSupport:function({samesite:e,secure:t}={}){if(!navigator.cookieEnabled)return!1;const n="sol_cookie_support_test";return this.set({name:n,value:"1",samesite:e,secure:t}),"1"===this.get(n)&&(this.remove(n),!0)}},n=Object.prototype.toString;function i(e){return"[object Object]"===n.call(e)}function s(e){const t=n.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function r(e){return"[object Array]"==n.call(e)}function o(e){return"[object String]"==n.call(e)}function a(e){return void 0===e}const l=Object.prototype.hasOwnProperty;function c(e){if(i(e)){for(let t in e)if(l.call(e,t))return!1;return!0}return!1}function u(e){return!(!e||1!==e.nodeType)}function h(e){let t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t}function d(e){try{return JSON.parse(e)}catch(t){return""}}const g=function(){let e=Date.now();return function(t){return Math.ceil((e=(9301*e+49297)%233280,e/233280*t))}}();function p(){if("function"==typeof Uint32Array){let e;if("undefined"!=typeof crypto&&(e=crypto),e&&i(e)&&e.getRandomValues)return e.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}return g(1e19)/1e19}const f=/* @__PURE__ */function(){function e(){let e=Date.now(),t=0;for(;e==Date.now();)t++;return e.toString(16)+t.toString(16)}return function(){let t=String(screen.height*screen.width);t=t&&/\d{5,}/.test(t)?t.toString():String(31242*p()).replace(".","").slice(0,8);return e()+"-"+p().toString(16).replace(".","")+"-"+function(){const e=navigator.userAgent;let t,n=[],i=0;function s(e,t){let i=0;for(let s=0;s<t.length;s++)i|=n[s]<<8*s;return e^i}for(let r=0;r<e.length;r++)t=e.charCodeAt(r),n.unshift(255&t),n.length>=4&&(i=s(i,n),n=[]);return n.length>0&&(i=s(i,n)),i.toString(16)}()+"-"+t+"-"+e()||(String(p())+String(p())+String(p())).slice(2,15)}}();function m(e,t){t&&"string"==typeof t||(t="");let n=null;try{n=new URL(e).hostname}catch(i){}return n||t}function E(e){let t=[];try{t=atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})}catch(n){t=[]}try{return decodeURIComponent(t.join(""))}catch(n){return t.join("")}}function I(e){let t="";try{t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}))}catch(n){t=e}return t}const S={get:function(e){return window.localStorage.getItem(e)},parse:function(e){let t;try{t=JSON.parse(S.get(e))||null}catch(n){console.warn(n)}return t},set:function(e,t){try{window.localStorage.setItem(e,t)}catch(n){console.warn(n)}},remove:function(e){window.localStorage.removeItem(e)},isSupport:function(){let e=!0;try{const t="__local_store_support__",n="testIsSupportStorage";S.set(t,n),S.get(t)!==n&&(e=!1),S.remove(t)}catch(t){e=!1}return e}};function w(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}const O={},A="0.3.2",_="init-ready",R="spa-switch",v="ff-ready",b="$PageLeave";var N=/* @__PURE__ */(e=>(e[e.FEATURE_GATE=1]="FEATURE_GATE",e[e.FEATURE_CONFIG=2]="FEATURE_CONFIG",e[e.EXPERIMENT=3]="EXPERIMENT",e))(N||{});const T=6e5,y={crossSubdomain:!1,requests:[],_sessionState:{},_abData:[],_trace_id:"",commonProps:{},_state:{anon_id:"",login_id:"",identities:{}},getIdentityCookieID(){return this._state.identities?.$identity_cookie_id||""},getCommonProps:function(){return this.commonProps||{}},setCommonProps:function(e){this.commonProps=e},getAnonId(){return this.getIdentityCookieID()||this._state.anon_id||f()},getLoginId(){return this._state.login_id},getTraceId(){return this._trace_id||f()},set:function(e,t){this._state[e]=t,this.save()},getCookieName:function(){return"sol2025jssdkcross"},getABLSName:function(){return"sol2025jssdkablatest"},save:function(){let e=JSON.parse(JSON.stringify(this._state));e.identities&&(e.identities=I(JSON.stringify(e.identities)));const n=JSON.stringify(e);t.set({name:this.getCookieName(),value:n,expires:365})},init:function(e){let n,s;this.crossSubdomain=e,t.isSupport()&&(n=t.get(this.getCookieName()),s=d(n)),y._state={...s||{}},y._state.identities&&(y._state.identities=d(E(y._state.identities))),y._state.identities&&i(y._state.identities)&&!c(y._state.identities)||(y._state.identities={$identity_cookie_id:f()}),y.save()},setLoginId(e){"number"==typeof e&&(e=String(e)),void 0!==e&&e&&(y.set("login_id",e),y.save())},saveABData(e){if(!e||c(e))return;this._abData=e;let t=JSON.parse(JSON.stringify(this._abData));t=I(JSON.stringify(t));try{localStorage.setItem(this.getABLSName(),JSON.stringify({time:Date.now(),data:t,anon_id:this.getAnonId(),login_id:this.getLoginId()}))}catch(n){console.warn("Failed to save abdata to localStorage",n)}},getABData(){try{let e=localStorage.getItem(this.getABLSName());if(e){const{time:t,data:n,login_id:i,anon_id:s}=d(e)||{};if(t&&n&&Date.now()-t<T&&s===this.getAnonId()&&(!i||i===this.getLoginId()))return d(E(n));localStorage.removeItem(this.getABLSName())}}catch(e){console.warn("Failed to load abdata from localStorage",e),this._abData=[]}return this._abData||[]}};function P(e){var t;if(e.data)return{contentType:"application/json",body:(t=e.data,JSON.stringify(t,(e,t)=>"bigint"==typeof t?t.toString():t,undefined))}}const C=[];function L(e){const t={...e};t.timeout=t.timeout||6e4;const n=t.transport??"fetch",i=C.find(e=>e.transport===n)?.method??C[0]?.method;if(!i)throw new Error("No available transport method for HTTP request");i(t)}function B(e){return o(e=e||document.referrer)&&(e=h(e=e.trim()))||""}function F(e){const t=m(e=e||B());if(!t)return"";const n={baidu:[/^.*\.baidu\.com$/],bing:[/^.*\.bing\.com$/],google:[/^www\.google\.com$/,/^www\.google\.com\.[a-z]{2}$/,/^www\.google\.[a-z]{2}$/],sm:[/^m\.sm\.cn$/],so:[/^.+\.so\.com$/],sogou:[/^.*\.sogou\.com$/],yahoo:[/^.*\.yahoo\.com$/],duckduckgo:[/^.*\.duckduckgo\.com$/]};for(let i of Object.keys(n)){let e=n[i];for(let n=0,s=e.length;n<s;n++)if(e[n].test(t))return i}return"Unknown Search Engine"}function M(e,t){return-1!==e.indexOf(t)}"function"==typeof fetch&&C.push({transport:"fetch",method:function(e){if("undefined"==typeof fetch)return void console.error("fetch API is not available");const t=P(e),n=new Headers;e.headers&&Object.keys(e.headers).forEach(t=>{n.append(t,e.headers[t])}),t?.contentType&&n.append("Content-Type",t.contentType),fetch(e.url,{method:e.method||"GET",headers:n,body:t?.body}).then(t=>t.text().then(n=>{const i={statusCode:t.status,text:n};if(200===t.status)try{i.json=JSON.parse(n)}catch(s){console.error("Failed to parse response:",s)}e.callback?.(i)})).catch(t=>{console.error("Request failed:",t),e.callback?.({statusCode:0,text:String(t)})})}}),"undefined"!=typeof XMLHttpRequest&&C.push({transport:"XHR",method:function(e){if("undefined"==typeof XMLHttpRequest)return void console.error("XMLHttpRequest is not available");const t=new XMLHttpRequest;t.open(e.method||"GET",e.url,!0);const n=P(e);e.headers&&Object.keys(e.headers).forEach(n=>{t.setRequestHeader(n,e.headers[n])}),n?.contentType&&t.setRequestHeader("Content-Type",n.contentType),t.timeout=e.timeout||6e4,t.withCredentials=!0,t.onreadystatechange=()=>{if(4===t.readyState){const i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(n){console.error("Failed to parse JSON response:",n)}e.callback?.(i)}},t.send(n?.body)}});const D={FACEBOOK:"Facebook",MOBILE:"Mobile",IOS:"iOS",ANDROID:"Android",TABLET:"Tablet",ANDROID_TABLET:"Android Tablet",IPAD:"iPad",APPLE:"Apple",APPLE_WATCH:"Apple Watch",SAFARI:"Safari",BLACKBERRY:"BlackBerry",SAMSUNG_BROWSER:"SamsungBrowser",SAMSUNG_INTERNET:"Samsung Internet",CHROME:"Chrome",CHROME_OS:"Chrome OS",CHROME_IOS:"Chrome iOS",INTERNET_EXPLORER:"Internet Explorer",INTERNET_EXPLORER_MOBILE:"Internet Explorer Mobile",OPERA:"Opera",OPERA_MINI:"Opera Mini",EDGE:"Edge",MICROSOFT_EDGE:"Microsoft Edge",FIREFOX:"Firefox",FIREFOX_IOS:"Firefox iOS",NINTENDO:"Nintendo",PLAYSTATION:"PlayStation",XBOX:"Xbox",ANDROID_MOBILE:"Android Mobile",MOBILE_SAFARI:"Mobile Safari",WINDOWS:"Windows",WINDOWS_PHONE:"Windows Phone",NOKIA:"Nokia",OUYA:"Ouya",GENERIC_MOBILE:"Generic mobile",GENERIC_TABLET:"Generic tablet",KONQUEROR:"Konqueror",UC_BROWSER:"UC Browser",HUAWEI:"Huawei",XIAOMI:"Xiaomi",OPPO:"OPPO",VIVO:"vivo"},x="(\\d+(\\.\\d+)?)",k=new RegExp("Version/"+x),H=new RegExp(D.XBOX,"i"),$=new RegExp(D.PLAYSTATION+" \\w+","i"),X=new RegExp(D.NINTENDO+" \\w+","i"),U=new RegExp(D.BLACKBERRY+"|PlayBook|BB10","i"),q=new RegExp("(HUAWEI|honor|HONOR)","i"),W=new RegExp("(Xiaomi|Redmi)","i"),G=new RegExp("(OPPO|realme)","i"),j=new RegExp("(vivo|IQOO)","i"),Y={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function z(e,t){return t=t||"",M(e," OPR/")&&M(e,"Mini")?D.OPERA_MINI:M(e," OPR/")?D.OPERA:U.test(e)?D.BLACKBERRY:M(e,"IE"+D.MOBILE)||M(e,"WPDesktop")?D.INTERNET_EXPLORER_MOBILE:M(e,D.SAMSUNG_BROWSER)?D.SAMSUNG_INTERNET:M(e,D.EDGE)||M(e,"Edg/")?D.MICROSOFT_EDGE:M(e,"FBIOS")?D.FACEBOOK+" "+D.MOBILE:M(e,"UCWEB")||M(e,"UCBrowser")?D.UC_BROWSER:M(e,"CriOS")?D.CHROME_IOS:M(e,"CrMo")||M(e,D.CHROME)?D.CHROME:M(e,D.ANDROID)&&M(e,D.SAFARI)?D.ANDROID_MOBILE:M(e,"FxiOS")?D.FIREFOX_IOS:M(e.toLowerCase(),D.KONQUEROR.toLowerCase())?D.KONQUEROR:function(e,t){return t&&M(t,D.APPLE)||M(n=e,D.SAFARI)&&!M(n,D.CHROME)&&!M(n,D.ANDROID);var n}(e,t)?M(e,D.MOBILE)?D.MOBILE_SAFARI:D.SAFARI:M(e,D.FIREFOX)?D.FIREFOX:M(e,"MSIE")||M(e,"Trident/")?D.INTERNET_EXPLORER:M(e,"Gecko")?D.FIREFOX:""}const K={[D.INTERNET_EXPLORER_MOBILE]:[new RegExp("rv:"+x)],[D.MICROSOFT_EDGE]:[new RegExp(D.EDGE+"?\\/"+x)],[D.CHROME]:[new RegExp("("+D.CHROME+"|CrMo)\\/"+x)],[D.CHROME_IOS]:[new RegExp("CriOS\\/"+x)],[D.UC_BROWSER]:[new RegExp("(UCBrowser|UCWEB)\\/"+x)],[D.SAFARI]:[k],[D.MOBILE_SAFARI]:[k],[D.OPERA]:[new RegExp("("+D.OPERA+"|OPR)\\/"+x)],[D.FIREFOX]:[new RegExp(D.FIREFOX+"\\/"+x)],[D.FIREFOX_IOS]:[new RegExp("FxiOS\\/"+x)],[D.KONQUEROR]:[new RegExp("Konqueror[:/]?"+x,"i")],[D.BLACKBERRY]:[new RegExp(D.BLACKBERRY+" "+x),k],[D.ANDROID_MOBILE]:[new RegExp("android\\s"+x,"i")],[D.SAMSUNG_INTERNET]:[new RegExp(D.SAMSUNG_BROWSER+"\\/"+x)],[D.INTERNET_EXPLORER]:[new RegExp("(rv:|MSIE )"+x)],Mozilla:[new RegExp("rv:"+x)]};function J(e,t){const n=z(e,t),i=K[n];if(a(i))return null;for(let s=0;s<i.length;s++){const t=i[s],n=e.match(t);if(n)return parseFloat(n[n.length-2])}return null}const Z=[[new RegExp(D.XBOX+"; "+D.XBOX+" (.*?)[);]","i"),e=>[D.XBOX,e&&e[1]||""]],[new RegExp(D.NINTENDO,"i"),[D.NINTENDO,""]],[new RegExp(D.PLAYSTATION,"i"),[D.PLAYSTATION,""]],[U,[D.BLACKBERRY,""]],[new RegExp(D.WINDOWS,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[D.WINDOWS_PHONE,""];if(new RegExp(D.MOBILE).test(t)&&!/IEMobile\b/.test(t))return[D.WINDOWS+" "+D.MOBILE,""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){const e=n[1];let i=Y[e]||"";return/arm/i.test(t)&&(i="RT"),[D.WINDOWS,i]}return[D.WINDOWS,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[D.IOS,t.join(".")]}return[D.IOS,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=a(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+D.ANDROID+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+D.ANDROID+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[D.ANDROID,t.join(".")]}return[D.ANDROID,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[D.CHROME_OS,""]],[/Linux|debian/i,["Linux",""]]];function Q(){const e=window.innerHeight||document.documentElement.clientHeight||document.body&&document.body.clientHeight||0,t=window.innerWidth||document.documentElement.clientWidth||document.body&&document.body.clientWidth||0,n=navigator.userAgent,i=function(e){for(let t=0;t<Z.length;t++){const[n,i]=Z[t],s=n.exec(e),r=s&&("function"==typeof i?i(s,e):i);if(r)return r}return["",""]}(n)||["",""];return{$browser:z(n),$browser_version:J(n),$url:location?.href.substring(0,1e3),$host:location?.host,$viewport_height:e,$viewport_width:t,$lib:"webjs",$lib_version:A,$search_engine:F(),$referrer:B(),$referrer_domain:m(r=r||B()),$model:(s=n,(X.test(s)?D.NINTENDO:$.test(s)?D.PLAYSTATION:H.test(s)?D.XBOX:new RegExp(D.OUYA,"i").test(s)?D.OUYA:new RegExp("("+D.WINDOWS_PHONE+"|WPDesktop)","i").test(s)?D.WINDOWS_PHONE:/iPad/.test(s)?D.IPAD:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?D.APPLE_WATCH:U.test(s)?D.BLACKBERRY:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(D.NOKIA,"i").test(s)?D.NOKIA:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":q.test(s)?D.HUAWEI:W.test(s)?D.XIAOMI:G.test(s)?D.OPPO:j.test(s)?D.VIVO:/(Android|ZTE)/i.test(s)?!new RegExp(D.MOBILE).test(s)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)?/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?D.ANDROID:D.ANDROID_TABLET:D.ANDROID:new RegExp("(pda|"+D.MOBILE+")","i").test(s)?D.GENERIC_MOBILE:new RegExp(D.TABLET,"i").test(s)&&!new RegExp(D.TABLET+" pc","i").test(s)?D.GENERIC_TABLET:"")||""),$os:i?.[0]||"",$os_version:i?.[1]||"",$pathname:location?.pathname,$screen_height:Number(screen.height)||0,$screen_width:Number(screen.width)||0};var s,r}const V=new class{constructor(){this.STORAGE_KEY="sol_unsent_events",this.MAX_QUEUE_SIZE=100,this.MAX_RETRY_COUNT=3,this.MAX_AGE_MS=6048e5,this.queue=[],this.loadFromStorage(),this.cleanupExpiredItems()}loadFromStorage(){try{const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.queue=d(e)||[])}catch(e){console.warn("Failed to load queue from localStorage:",e),this.queue=[]}}cleanupExpiredItems(){const e=Date.now(),t=this.queue.filter(t=>e-t.timestamp<this.MAX_AGE_MS&&t.retryCount<t.maxRetries);t.length!==this.queue.length&&(this.queue=t,this.saveToStorage())}saveToStorage(){try{this.cleanupExpiredItems(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE)),localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.queue))}catch(e){console.warn("Failed to save queue to localStorage:",e)}}enqueue(e,t,n,i=this.MAX_RETRY_COUNT){try{const s={id:f(),url:e,data:t,headers:n,timestamp:Date.now(),retryCount:0,maxRetries:i};return this.queue.push(s),this.saveToStorage(),s.id}catch(s){return console.warn("Failed to enqueue request:",s),""}}dequeue(e){try{this.queue=this.queue.filter(t=>t.id!==e),this.saveToStorage()}catch(t){console.warn("Failed to dequeue request:",t)}}getAll(){try{return this.cleanupExpiredItems(),[...this.queue]}catch(e){return console.warn("Failed to get queue items:",e),[]}}incrementRetryCount(e){const t=this.queue.find(t=>t.id===e);return!!t&&(t.retryCount++,t.retryCount>=t.maxRetries?(this.dequeue(e),!1):(this.saveToStorage(),!0))}clear(){this.queue=[];try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn("Failed to clear queue from localStorage:",e)}}getItemById(e){return this.queue.find(t=>t.id===e)}};class ee{constructor(e={}){this.flushTimer=null,this.isFlushing=!1,this.pendingFlush=!1,this.config={maxBatchSize:e.maxBatchSize||10,flushInterval:e.flushInterval||5e3},this.startFlushTimer()}add(){V.getAll().length>=this.config.maxBatchSize&&this.triggerFlush()}triggerFlush(){this.isFlushing?this.pendingFlush=!0:(this.isFlushing=!0,this.flush())}flush(){const e=V.getAll();if(0===e.length)return this.isFlushing=!1,void(this.pendingFlush&&(this.pendingFlush=!1,this.triggerFlush()));const t=[],n=[];e.forEach(e=>{Array.isArray(e.data)?t.push(...e.data):t.push(e.data),n.push(e.id)});const i=t.slice(0,this.config.maxBatchSize),s=e[0],r=s.url,o=s.headers;O.instance.config.debug&&console.log(JSON.stringify(i,null,2)),L({url:r,method:"POST",data:i,headers:o,callback:e=>{200!==e.statusCode?console.error("Failed to send batch events:",e):n.forEach(e=>{V.dequeue(e)}),this.isFlushing=!1;const t=V.getAll();(this.pendingFlush||t.length>=this.config.maxBatchSize)&&(this.pendingFlush=!1,this.triggerFlush())}})}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush()}}let te=null,ne=null;function ie(e,t,n){return L({url:e,method:"POST",data:t.data,headers:t.headers,callback:e=>{if(200!==e.statusCode){if(n)if(V.incrementRetryCount(n)){const e=V.getItemById(n);if(e){const t=Math.min(1e3*Math.pow(2,e.retryCount),3e4);setTimeout(()=>{ie(e.url,{data:e.data,headers:e.headers},e.id)},t)}}else console.warn("Max retries reached for request:",n)}else n&&V.dequeue(n),t.callback&&t.callback(e.json)}})}function se(e){return`${e.apiHost}/in/track`}function re(e){return`${e.apiHost}/api/abol/evalall`}function oe(e){return{"Content-Type":"application/json",ProjectToken:e.apiToken}}function ae(e,t,n){O.instance.config.debug&&console.log(JSON.stringify(t.data,null,2));const i=V.enqueue(e,t.data,t.headers);return ie(e,{...t,callback:void 0},i)}function le(e,t,n=!0){const i={time:Date.now(),trace_id:y.getTraceId(),event:e.event,properties:{...n?Q():{},...y.getCommonProps(),...e.properties}},s=y.getLoginId(),r=y.getAnonId();s&&(i.login_id=s),r&&(i.anon_id=r);const o=se(t),a=oe(t),l=S.isSupport()?(ne||(te||(te=new ee({maxBatchSize:10,flushInterval:5e3})),ne=te),ne):null;!1!==t.batchSend&&l?(V.enqueue(o,[i],a),l.add()):ae(o,{data:[i],headers:a})}function ce({userProps:e,opts:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={time:Date.now(),trace_id:y.getTraceId(),event:"$UserSet",login_id:n,anon_id:i,user_properties:e};return ae(se(t),{data:[s],headers:oe(t)})}function ue(e){return`$ab_${e.id}`}function he(e){const t=e.typ;return t===N.FEATURE_GATE&&"fail"!==e.vid?{[ue(e)]:e.vid}:t===N.EXPERIMENT?{[ue(e)]:e.vid}:{}}function de({isHit:e,data:t,opts:n}){if(!t||c(t)||t.disable_impress)return;let i={};i=e?{$set:{...he(t)}}:{$unset:{[ue(t)]:null}};const s=y.getLoginId(),r=y.getAnonId();if(!s||!r)return;const o={time:Date.now(),trace_id:y.getTraceId(),event:"$ABImpress",login_id:s,anon_id:r,properties:{...Q(),...y.getCommonProps()},user_properties:{...i}};return ae(se(n),{data:[o],headers:oe(n)})}class ge{constructor({plugins:e,emitter:t,config:n}){this.plugins=[],this.pluginInsMap={},this.emitter=t,this.config=n,this.registerBuiltInPlugins(e),this.created(),this.emitter.on(_,()=>{this.init()})}registerBuiltInPlugins(e){for(let t=0,n=e.length;t<n;t++)this.registerPlugin(e[t])}registerPlugin(e){this.plugins.push(e)}getPlugins(){return this.plugins}getPlugin(e){return this.pluginInsMap[e]}created(){for(let e=0,t=this.plugins.length;e<t;e++){const t=this.plugins[e];if(!t.NAME)throw new Error('Plugin should be defined with "NAME"');const n=new t({emitter:this.emitter,config:this.config});this.pluginInsMap[t.NAME]=n}}init(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.init&&t.init()}}destroy(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.destroy&&"function"==typeof t.destroy&&t.destroy()}this.pluginInsMap={},this.plugins=[]}}const pe=class{constructor({emitter:e,config:t}){this.boundSend=null,this.hashEvent=null,this.emitter=e,this.config=t}init(){const e=this.config;this.boundSend=()=>{le({event:"$PageView",properties:{$title:document.title}},e)},e.isSinglePageApp?(this.hashEvent="pushState"in window.history?"popstate":"hashchange",window.addEventListener(this.hashEvent,this.boundSend)):this.boundSend()}destroy(){this.hashEvent&&this.boundSend&&(window.removeEventListener(this.hashEvent,this.boundSend),this.hashEvent=null,this.boundSend=null)}};pe.NAME="pageview";let fe=pe;const me=class{constructor({emitter:e,config:t}){this.startTime=Date.now(),this.pageShowStatus=!0,this.pageHiddenStatus=!1,this.timer=null,this.currentPageUrl=document.referrer,this.url=location.href,this.title=document.title||"",this.heartbeatIntervalTime=5e3,this.heartbeatIntervalTimer=null,this.pageId=null,this.storageName="solwebjssdkpageleave",this.maxDuration=432e3,this.eventListeners=[],this.emitter=e,this.config=t}init(){this.pageId=Number(String(p()).slice(2,5)+String(p()).slice(2,4)+String(Date.now()).slice(-4)),this.addEventListener(),!0===document.hidden?this.pageShowStatus=!1:this.addHeartBeatInterval()}log(e){console.log(e)}refreshPageEndTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this.pageHiddenStatus=!1},5e3)}hiddenStatusHandler(){this.timer&&clearTimeout(this.timer),this.timer=null,this.pageHiddenStatus=!1}pageStartHandler(){this.startTime=Date.now(),1==!document.hidden?this.pageShowStatus=!0:this.pageShowStatus=!1,this.url=location.href,this.title=document.title}pageEndHandler(){if(!0===this.pageHiddenStatus)return;const e=this.getPageLeaveProperties();!1===this.pageShowStatus&&delete e.event_duration,this.pageShowStatus=!1,this.pageHiddenStatus=!0,le({event:b,properties:e},this.config),this.refreshPageEndTimer(),this.delHeartBeatData()}addEventListener(){this.addPageStartListener(),this.addPageSwitchListener(),this.addSinglePageListener(),this.addPageEndListener()}addPageStartListener(){if("onpageshow"in window){const e=()=>{this.pageStartHandler(),this.hiddenStatusHandler()};window.addEventListener("pageshow",e),this.eventListeners.push({target:window,event:"pageshow",handler:e})}}addSinglePageListener(){this.config.isSinglePageApp&&this.emitter.on(R,e=>{e!==location.href&&(this.url=e,this.pageEndHandler(),this.stopHeartBeatInterval(),this.currentPageUrl=this.url,this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval())})}addPageEndListener(){["pagehide","beforeunload","unload"].forEach(e=>{if(`on${e}`in window){const t=()=>{this.pageEndHandler(),this.stopHeartBeatInterval()};window.addEventListener(e,t),this.eventListeners.push({target:window,event:e,handler:t})}})}addPageSwitchListener(){const e=()=>{"visible"===document.visibilityState?(this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval()):(this.url=location.href,this.title=document.title,this.pageEndHandler(),this.stopHeartBeatInterval())};document.addEventListener("visibilitychange",e),this.eventListeners.push({target:document,event:"visibilitychange",handler:e})}addHeartBeatInterval(){S.isSupport()&&this.startHeartBeatInterval()}startHeartBeatInterval(){this.heartbeatIntervalTimer&&this.stopHeartBeatInterval(),this.heartbeatIntervalTimer=setInterval(()=>{this.saveHeartBeatData()},this.heartbeatIntervalTime),this.saveHeartBeatData("is_first_heartbeat"),this.reissueHeartBeatData()}stopHeartBeatInterval(){this.heartbeatIntervalTimer&&clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null}saveHeartBeatData(e){const t=this.getPageLeaveProperties();t.$time=Date.now(),"is_first_heartbeat"===e&&(t.event_duration=3);const n={type:"track",event:b,properties:t};n.heartbeat_interval_time=this.heartbeatIntervalTime,S.isSupport()&&S.set(`${this.storageName}-${this.pageId}`,JSON.stringify(n))}delHeartBeatData(e){S.isSupport()&&S.remove(e||`${this.storageName}-${this.pageId}`)}reissueHeartBeatData(){for(let e=window.localStorage.length-1;e>=0;e--){const t=window.localStorage.key(e);if(t&&t!==`${this.storageName}-${this.pageId}`&&0===t.indexOf(`${this.storageName}-`)){const e=S.parse(t);i(e)&&Date.now()-e.time>e.heartbeat_interval_time+5e3&&(delete e.heartbeat_interval_time,e._flush_time=/* @__PURE__ */(new Date).getTime(),le({event:b,properties:e?.properties},this.config),this.delHeartBeatData(t))}}}getPageLeaveProperties(){let e=(Date.now()-this.startTime)/1e3;(isNaN(e)||e<0||e>this.maxDuration)&&(e=0),e=Number(e.toFixed(3));const t=document.documentElement&&document.documentElement.scrollTop||window.pageYOffset||document.body&&document.body.scrollTop||0,n=Math.round(t)||0,i={$title:this.title,$viewport_position:n};return 0!==e&&(i.event_duration=e),i}destroy(){this.eventListeners.forEach(({target:e,event:t,handler:n})=>{e.removeEventListener(t,n)}),this.eventListeners=[],this.timer&&(clearTimeout(this.timer),this.timer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};me.NAME="pageleave";let Ee=me;const Ie=class{constructor({emitter:e,config:t}){this.eventSended=!1,this.emitter=e,this.config=t}init(){const e=()=>{let t=0;const n=window.performance,i={$title:document.title};if(n){t=function(){let e=0;if("function"==typeof performance.getEntriesByType){const t=performance.getEntriesByType("navigation");t.length>0&&(e=t[0].domContentLoadedEventEnd||0)}return e}();const e=function(){if(performance.getEntries&&"function"==typeof performance.getEntries){const e=performance.getEntries();let t=0;for(const n of e)"transferSize"in n&&(t+=n.transferSize);if("number"==typeof t&&t>=0&&t<10737418240)return Number((t/1024).toFixed(3))}}();e&&(i.$page_resource_size=e)}else console.warn("Performance API is not supported.");t>0&&!Number.isFinite(t)&&(i.event_duration=Number((t/1e3).toFixed(3))),this.eventSended||(this.eventSended=!0,le({event:"$PageLoad",properties:i},this.config)),window.removeEventListener("load",e)};"complete"===document.readyState?e():window.addEventListener&&window.addEventListener("load",e)}};Ie.NAME="pageload";let Se=Ie;function we(e,t){if(!u(e))return!1;const n=o(e.tagName)?e.tagName.toLowerCase():"unknown",i={};i.$element_type=n,i.$element_name=e.getAttribute("name"),i.$element_id=e.getAttribute("id"),i.$element_class_name=o(e.className)?e.className:null,i.$element_target_url=e.getAttribute("href"),i.$element_content=function(e,t){return o(t)&&"input"===t.toLowerCase()?("button"===(n=e).type||"submit"===n.type)&&n.value||"":function(e,t){let n="",i="";return e.textContent?n=w(e.textContent):e.innerText&&(n=w(e.innerText)),n&&(n=n.replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)),i=n||"","input"!==t&&"INPUT"!==t||(i=e.value||""),i}(e,t);var n}(e,n),i.$element_selector=Oe(e),i.$element_path=function(e){let t=[];for(;e.parentNode&&u(e);){if(!o(e.tagName))return"unknown";if(e.id&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.id)){t.unshift(e.tagName.toLowerCase()+"#"+e.id);break}if(e===document.body){t.unshift("body");break}t.unshift(e.tagName.toLowerCase()),e=e.parentNode}return t.join(" > ")}(e),i.$url_path=location.pathname,i.$title=document.title;const s=function(e,t){const n=t.pageX||t.clientX+Ae().scrollLeft||t.offsetX+_e(e).targetEleX,i=t.pageY||t.clientY+Ae().scrollTop||t.offsetY+_e(e).targetEleY;return{$page_x:Re(n),$page_y:Re(i)}}(e,t);return i.$page_x=s.$page_x,i.$page_y=s.$page_y,i}function Oe(e,t=[]){if(!(e&&e.parentNode&&e.parentNode.children&&o(e.tagName)))return"unknown";t=Array.isArray(t)?t:[];const n=e.nodeName.toLowerCase();return e&&"body"!==n&&1==e.nodeType?(t.unshift(function(e){if(!e||!u(e)||!o(e.tagName))return"";let t=e.parentNode&&9==e.parentNode.nodeType?-1:function(e){if(!e.parentNode)return-1;let t=0;const n=e.tagName,i=e.parentNode.children;for(let s=0,r=i.length;s<r;s++)if(i[s].tagName===n){if(e===i[s])return t;t++}return-1}(e);return e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?"#"+e.getAttribute("id"):e.tagName.toLowerCase()+(~t?":nth-of-type("+(t+1)+")":"")}(e)),e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?t.join(" > "):Oe(e.parentNode,t)):(t.unshift("body"),t.join(" > "))}function Ae(){return{scrollLeft:document.body.scrollLeft||document.documentElement.scrollLeft||0,scrollTop:document.body.scrollTop||document.documentElement.scrollTop||0}}function _e(e){if(document.documentElement.getBoundingClientRect){const t=e.getBoundingClientRect();return{targetEleX:t.left+Ae().scrollLeft||0,targetEleY:t.top+Ae().scrollTop||0}}return{targetEleX:0,targetEleY:0}}function Re(e){return Number(Number(e).toFixed(3))}const ve=class{constructor({emitter:e,config:t}){this.isInitialized=!1,this.boundHandleClick=null,this.emitter=e,this.config=t}init(){this.isInitialized||(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,!0),this.isInitialized=!0)}handleClick(e){const t=e.target;if(!t)return;if(!["A","INPUT","BUTTON","TEXTAREA"].includes(t.tagName))return;if("true"===t.getAttribute("sol-disable"))return;le({event:"$WebClick",properties:we(t,e)||{}},this.config)}destroy(){this.boundHandleClick&&(document.removeEventListener("click",this.boundHandleClick,!0),this.boundHandleClick=null),this.isInitialized=!1}};ve.NAME="webclick";let be=ve;const Ne=class{constructor({emitter:e,config:t}){this.updateInterval=null,this.fetchingPromise=null,this.emitter=e,this.config=t}init(){const e=this.config;e.enableAB&&(this.fastFetch().then(()=>{this.emitter.emit(v)}),e.abRefreshInterval<3e4&&(e.abRefreshInterval=3e4),this.updateInterval=setInterval(()=>{this.fetchNewData().catch(console.warn)},e.abRefreshInterval))}async fastFetch(){const e=y.getABData();return e&&e.length?(this.emitter.emit(v),Promise.resolve(e)):this.fetchNewData()}async fetchNewData(){return this.fetchingPromise||(this.fetchingPromise=new Promise(e=>{!function({opts:e,cb:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={user:{login_id:n,anon_id:i,props:{...Q(),...y.getCommonProps()}},sdk:"webjs",sdk_version:A};L({url:re(e),method:"POST",data:s,headers:oe(e),callback:e=>{200!==e.statusCode?console.error("Failed to fetch feature flags"):t&&t(e.json)}})}({opts:this.config,cb:t=>{y.saveABData(t.data?.results||[]),e(t),this.fetchingPromise=null}})})),this.fetchingPromise}async getFeatureGate(e){return await this.fastFetch().catch(console.warn),y.getABData().find(t=>t.typ===N.FEATURE_GATE&&t.key==e)}async checkFeatureGate(e){const t=await this.getFeatureGate(e);return!!t&&("fail"===t.vid?(de({isHit:!1,data:t,opts:this.config}),!1):(de({isHit:!0,data:t,opts:this.config}),!0))}async getExperiment(e){await this.fastFetch().catch(console.warn);const t=y.getABData().find(t=>t.typ===N.EXPERIMENT&&t.key===e);return t?t?.vid?(de({isHit:!0,data:t,opts:this.config}),t?.value||{}):(de({isHit:!1,data:t,opts:this.config}),{}):{}}destroy(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null),this.fetchingPromise=null}};Ne.NAME="abtest";let Te=Ne;const ye=[],Pe={debug:!1,apiToken:"",apiHost:"",autoCapture:!0,isSinglePageApp:!1,crossSubdomainCookie:!0,enableAB:!1,abRefreshInterval:T,enableClickTrack:!1,batchSend:!0},Ce=new class{constructor(){this.__loaded=!1,this.config={},this.eventEmitter=new e,this.pluginCore={},this.commonProps={},this.spaCleanup=null,O.instance=this}init(e,t={}){t.apiToken=e,this.mergeConfig(t),this.eventEmitter.emit("init-param",this.config);const n=this.config;return y.init(n.crossSubdomainCookie),this.__loaded=!0,window._solFailedRequestsInitialized||(window._solFailedRequestsInitialized=!0,function(){const e=V.getAll();0!==e.length&&e.forEach(e=>{ie(e.url,{data:e.data,headers:e.headers},e.id)})}()),n.autoCapture&&this.autoTrack(),n.enableAB&&ye.push(Te),n.enableClickTrack&&ye.push(be),this.pluginCore=new ge({plugins:ye,emitter:this.eventEmitter,config:n}),this.spaCleanup=function(e){let t=location.href;const n=window.history.pushState,i=window.history.replaceState,r=function(){e(t),t=location.href};return s(window.history.pushState)&&(window.history.pushState=function(...i){n.apply(window.history,i),e(t),t=location.href}),s(window.history.replaceState)&&(window.history.replaceState=function(...n){i.apply(window.history,n),e(t),t=location.href}),window.addEventListener("popstate",r),function(){s(window.history.pushState)&&(window.history.pushState=n),s(window.history.replaceState)&&(window.history.replaceState=i),window.removeEventListener("popstate",r)}}(e=>{this.eventEmitter.emit(R,e)}),this.eventEmitter.emit(_),this}mergeConfig(e){this.config={...Pe,...e}}track(e){!function(e,t){const n={...e};n.time||(n.time=Date.now()),n.login_id||(n.login_id=y.getLoginId()),n.anon_id||(n.anon_id=y.getAnonId()),n.properties={...Q(),...y.getCommonProps(),...n.properties},ae(se(t),{data:[n],headers:oe(t)})}(e,this.config)}trackEvent(e,t){le({event:e,properties:{...t,...this.commonProps}},this.config)}autoTrack(){ye.push(fe,Se,Ee)}profileSet(e){ce({userProps:{$set:e},opts:this.config})}profileSetOnce(e){ce({userProps:{$set_once:e},opts:this.config})}profileIncrement(e){ce({userProps:{$increment:e},opts:this.config})}profileAppend(e){ce({userProps:{$append:e},opts:this.config})}profileUnion(e){ce({userProps:{$union:e},opts:this.config})}profileUnset(e){const t={};r(e)?e.forEach(function(e){t[e]=null}):t[e]=null,ce({userProps:{$unset:t},opts:this.config})}profileDelete(){ce({userProps:{$delete:!0},opts:this.config})}registerCommonProperties(e){if(!i(e))return console.warn("Commmon Properties must be an object!");this.commonProps=e,y.setCommonProps(this.commonProps)}clearCommonProperties(e){if(!r(e))return console.warn("Commmon Properties to be cleared must be an array!");e.forEach(e=>{delete this.commonProps[e]}),y.setCommonProps(this.commonProps)}identify(e){y.setLoginId(e),function(e){const t=y.getLoginId(),n=y.getAnonId();if(!t||!n)return;const i={time:Date.now(),trace_id:y.getTraceId(),event:"$Identify",login_id:t,anon_id:n};ae(se(e),{data:[i],headers:oe(e)})}(this.config)}setLoginId(e){y.setLoginId(e)}getAnonId(){return y.getAnonId()}getLoginId(){return y.getLoginId()}checkFeatureGate(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.checkFeatureGate(e):Promise.reject("AB is disabled")}getExperiment(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.getExperiment(e):Promise.reject("AB is disabled")}destroy(){ne&&(ne.destroy(),ne=null),this.spaCleanup&&"function"==typeof this.spaCleanup&&(this.spaCleanup(),this.spaCleanup=null),this.pluginCore&&"function"==typeof this.pluginCore.destroy&&this.pluginCore.destroy(),this.eventEmitter&&this.eventEmitter.removeAllListeners(),O.instance===this&&(O.instance=null)}};export{Ce as default};
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SensorsWave=t()}(this,function(){"use strict";class e{constructor(){this.listeners={}}on(e,t,n=!1){if(e&&t){if(!s(t))throw new Error("listener must be a function");this.listeners[e]=this.listeners[e]||[],this.listeners[e].push({listener:t,once:n})}}off(e,t){const n=this.listeners[e];if(!n?.length)return;"number"==typeof t&&n.splice(t,1);const i=n.findIndex(e=>e.listener===t);-1!==i&&n.splice(i,1)}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((n,i)=>{n.listener.call(this,...t),n.listener.once&&this.off(e,i)})}once(e,t){this.on(e,t,!0)}removeAllListeners(e){e?this.listeners[e]=[]:this.listeners={}}}const t={get:function(e){const t=e+"=",n=document.cookie.split(";");for(let i=0,s=n.length;i<s;i++){let e=n[i];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(t))return h(e.substring(t.length,e.length))}return null},set:function({name:e,value:t,expires:n,samesite:i,secure:s,domain:r}){let o="",a="",l="",c="";if(0!==(n=null==n||void 0===n?365:n)){const e=new Date;"s"===String(n).slice(-1)?e.setTime(e.getTime()+1e3*Number(String(n).slice(0,-1))):e.setTime(e.getTime()+24*n*60*60*1e3),o="; expires="+e.toUTCString()}function u(e){return e?e.replace(/\r\n/g,""):""}i&&(l="; SameSite="+i),s&&(a="; secure");const h=u(e),d=u(t),g=u(r);g&&(c="; domain="+g),h&&d&&(document.cookie=h+"="+encodeURIComponent(d)+o+"; path=/"+c+l+a)},remove:function(e){this.set({name:e,value:"",expires:-1})},isSupport:function({samesite:e,secure:t}={}){if(!navigator.cookieEnabled)return!1;const n="sol_cookie_support_test";return this.set({name:n,value:"1",samesite:e,secure:t}),"1"===this.get(n)&&(this.remove(n),!0)}},n=Object.prototype.toString;function i(e){return"[object Object]"===n.call(e)}function s(e){const t=n.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function r(e){return"[object Array]"==n.call(e)}function o(e){return"[object String]"==n.call(e)}function a(e){return void 0===e}const l=Object.prototype.hasOwnProperty;function c(e){if(i(e)){for(let t in e)if(l.call(e,t))return!1;return!0}return!1}function u(e){return!(!e||1!==e.nodeType)}function h(e){let t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t}function d(e){try{return JSON.parse(e)}catch(t){return""}}const g=function(){let e=Date.now();return function(t){return Math.ceil((e=(9301*e+49297)%233280,e/233280*t))}}();function p(){if("function"==typeof Uint32Array){let e;if("undefined"!=typeof crypto&&(e=crypto),e&&i(e)&&e.getRandomValues)return e.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}return g(1e19)/1e19}const f=function(){function e(){let e=Date.now(),t=0;for(;e==Date.now();)t++;return e.toString(16)+t.toString(16)}return function(){let t=String(screen.height*screen.width);t=t&&/\d{5,}/.test(t)?t.toString():String(31242*p()).replace(".","").slice(0,8);return e()+"-"+p().toString(16).replace(".","")+"-"+function(){const e=navigator.userAgent;let t,n=[],i=0;function s(e,t){let i=0;for(let s=0;s<t.length;s++)i|=n[s]<<8*s;return e^i}for(let r=0;r<e.length;r++)t=e.charCodeAt(r),n.unshift(255&t),n.length>=4&&(i=s(i,n),n=[]);return n.length>0&&(i=s(i,n)),i.toString(16)}()+"-"+t+"-"+e()||(String(p())+String(p())+String(p())).slice(2,15)}}();function m(e,t){t&&"string"==typeof t||(t="");let n=null;try{n=new URL(e).hostname}catch(i){}return n||t}function E(e){let t=[];try{t=atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})}catch(n){t=[]}try{return decodeURIComponent(t.join(""))}catch(n){return t.join("")}}function I(e){let t="";try{t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}))}catch(n){t=e}return t}const S={get:function(e){return window.localStorage.getItem(e)},parse:function(e){let t;try{t=JSON.parse(S.get(e))||null}catch(n){console.warn(n)}return t},set:function(e,t){try{window.localStorage.setItem(e,t)}catch(n){console.warn(n)}},remove:function(e){window.localStorage.removeItem(e)},isSupport:function(){let e=!0;try{const t="__local_store_support__",n="testIsSupportStorage";S.set(t,n),S.get(t)!==n&&(e=!1),S.remove(t)}catch(t){e=!1}return e}};function w(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}const O={},A="0.3.0",_="init-ready",v="spa-switch",R="ff-ready",b="$PageLeave";var N=(e=>(e[e.FEATURE_GATE=1]="FEATURE_GATE",e[e.FEATURE_CONFIG=2]="FEATURE_CONFIG",e[e.EXPERIMENT=3]="EXPERIMENT",e))(N||{});const T=6e5,y={crossSubdomain:!1,requests:[],_sessionState:{},_abData:[],_trace_id:"",commonProps:{},_state:{anon_id:"",login_id:"",identities:{}},getIdentityCookieID(){return this._state.identities?.$identity_cookie_id||""},getCommonProps:function(){return this.commonProps||{}},setCommonProps:function(e){this.commonProps=e},getAnonId(){return this.getIdentityCookieID()||this._state.anon_id||f()},getLoginId(){return this._state.login_id},getTraceId(){return this._trace_id||f()},set:function(e,t){this._state[e]=t,this.save()},getCookieName:function(){return"sol2025jssdkcross"},getABLSName:function(){return"sol2025jssdkablatest"},save:function(){let e=JSON.parse(JSON.stringify(this._state));e.identities&&(e.identities=I(JSON.stringify(e.identities)));const n=JSON.stringify(e);t.set({name:this.getCookieName(),value:n,expires:365})},init:function(e){let n,s;this.crossSubdomain=e,t.isSupport()&&(n=t.get(this.getCookieName()),s=d(n)),y._state={...s||{}},y._state.identities&&(y._state.identities=d(E(y._state.identities))),y._state.identities&&i(y._state.identities)&&!c(y._state.identities)||(y._state.identities={$identity_cookie_id:f()}),y.save()},setLoginId(e){"number"==typeof e&&(e=String(e)),void 0!==e&&e&&(y.set("login_id",e),y.save())},saveABData(e){if(!e||c(e))return;this._abData=e;let t=JSON.parse(JSON.stringify(this._abData));t=I(JSON.stringify(t));try{localStorage.setItem(this.getABLSName(),JSON.stringify({time:Date.now(),data:t,anon_id:this.getAnonId(),login_id:this.getLoginId()}))}catch(n){console.warn("Failed to save abdata to localStorage",n)}},getABData(){try{let e=localStorage.getItem(this.getABLSName());if(e){const{time:t,data:n,login_id:i,anon_id:s}=d(e)||{};if(t&&n&&Date.now()-t<T&&s===this.getAnonId()&&(!i||i===this.getLoginId()))return d(E(n));localStorage.removeItem(this.getABLSName())}}catch(e){console.warn("Failed to load abdata from localStorage",e),this._abData=[]}return this._abData||[]}};function P(e){var t;if(e.data)return{contentType:"application/json",body:(t=e.data,JSON.stringify(t,(e,t)=>"bigint"==typeof t?t.toString():t,undefined))}}const C=[];function L(e){const t={...e};t.timeout=t.timeout||6e4;const n=t.transport??"fetch",i=C.find(e=>e.transport===n)?.method??C[0]?.method;if(!i)throw new Error("No available transport method for HTTP request");i(t)}function B(e){return o(e=e||document.referrer)&&(e=h(e=e.trim()))||""}function F(e){const t=m(e=e||B());if(!t)return"";const n={baidu:[/^.*\.baidu\.com$/],bing:[/^.*\.bing\.com$/],google:[/^www\.google\.com$/,/^www\.google\.com\.[a-z]{2}$/,/^www\.google\.[a-z]{2}$/],sm:[/^m\.sm\.cn$/],so:[/^.+\.so\.com$/],sogou:[/^.*\.sogou\.com$/],yahoo:[/^.*\.yahoo\.com$/],duckduckgo:[/^.*\.duckduckgo\.com$/]};for(let i of Object.keys(n)){let e=n[i];for(let n=0,s=e.length;n<s;n++)if(e[n].test(t))return i}return"Unknown Search Engine"}function M(e,t){return-1!==e.indexOf(t)}"function"==typeof fetch&&C.push({transport:"fetch",method:function(e){if("undefined"==typeof fetch)return void console.error("fetch API is not available");const t=P(e),n=new Headers;e.headers&&Object.keys(e.headers).forEach(t=>{n.append(t,e.headers[t])}),t?.contentType&&n.append("Content-Type",t.contentType),fetch(e.url,{method:e.method||"GET",headers:n,body:t?.body}).then(t=>t.text().then(n=>{const i={statusCode:t.status,text:n};if(200===t.status)try{i.json=JSON.parse(n)}catch(s){console.error("Failed to parse response:",s)}e.callback?.(i)})).catch(t=>{console.error("Request failed:",t),e.callback?.({statusCode:0,text:String(t)})})}}),"undefined"!=typeof XMLHttpRequest&&C.push({transport:"XHR",method:function(e){if("undefined"==typeof XMLHttpRequest)return void console.error("XMLHttpRequest is not available");const t=new XMLHttpRequest;t.open(e.method||"GET",e.url,!0);const n=P(e);e.headers&&Object.keys(e.headers).forEach(n=>{t.setRequestHeader(n,e.headers[n])}),n?.contentType&&t.setRequestHeader("Content-Type",n.contentType),t.timeout=e.timeout||6e4,t.withCredentials=!0,t.onreadystatechange=()=>{if(4===t.readyState){const i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(n){console.error("Failed to parse JSON response:",n)}e.callback?.(i)}},t.send(n?.body)}});const x={FACEBOOK:"Facebook",MOBILE:"Mobile",IOS:"iOS",ANDROID:"Android",TABLET:"Tablet",ANDROID_TABLET:"Android Tablet",IPAD:"iPad",APPLE:"Apple",APPLE_WATCH:"Apple Watch",SAFARI:"Safari",BLACKBERRY:"BlackBerry",SAMSUNG_BROWSER:"SamsungBrowser",SAMSUNG_INTERNET:"Samsung Internet",CHROME:"Chrome",CHROME_OS:"Chrome OS",CHROME_IOS:"Chrome iOS",INTERNET_EXPLORER:"Internet Explorer",INTERNET_EXPLORER_MOBILE:"Internet Explorer Mobile",OPERA:"Opera",OPERA_MINI:"Opera Mini",EDGE:"Edge",MICROSOFT_EDGE:"Microsoft Edge",FIREFOX:"Firefox",FIREFOX_IOS:"Firefox iOS",NINTENDO:"Nintendo",PLAYSTATION:"PlayStation",XBOX:"Xbox",ANDROID_MOBILE:"Android Mobile",MOBILE_SAFARI:"Mobile Safari",WINDOWS:"Windows",WINDOWS_PHONE:"Windows Phone",NOKIA:"Nokia",OUYA:"Ouya",GENERIC_MOBILE:"Generic mobile",GENERIC_TABLET:"Generic tablet",KONQUEROR:"Konqueror",UC_BROWSER:"UC Browser",HUAWEI:"Huawei",XIAOMI:"Xiaomi",OPPO:"OPPO",VIVO:"vivo"},D="(\\d+(\\.\\d+)?)",k=new RegExp("Version/"+D),H=new RegExp(x.XBOX,"i"),$=new RegExp(x.PLAYSTATION+" \\w+","i"),X=new RegExp(x.NINTENDO+" \\w+","i"),U=new RegExp(x.BLACKBERRY+"|PlayBook|BB10","i"),q=new RegExp("(HUAWEI|honor|HONOR)","i"),W=new RegExp("(Xiaomi|Redmi)","i"),G=new RegExp("(OPPO|realme)","i"),j=new RegExp("(vivo|IQOO)","i"),Y={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function z(e,t){return t=t||"",M(e," OPR/")&&M(e,"Mini")?x.OPERA_MINI:M(e," OPR/")?x.OPERA:U.test(e)?x.BLACKBERRY:M(e,"IE"+x.MOBILE)||M(e,"WPDesktop")?x.INTERNET_EXPLORER_MOBILE:M(e,x.SAMSUNG_BROWSER)?x.SAMSUNG_INTERNET:M(e,x.EDGE)||M(e,"Edg/")?x.MICROSOFT_EDGE:M(e,"FBIOS")?x.FACEBOOK+" "+x.MOBILE:M(e,"UCWEB")||M(e,"UCBrowser")?x.UC_BROWSER:M(e,"CriOS")?x.CHROME_IOS:M(e,"CrMo")||M(e,x.CHROME)?x.CHROME:M(e,x.ANDROID)&&M(e,x.SAFARI)?x.ANDROID_MOBILE:M(e,"FxiOS")?x.FIREFOX_IOS:M(e.toLowerCase(),x.KONQUEROR.toLowerCase())?x.KONQUEROR:function(e,t){return t&&M(t,x.APPLE)||M(n=e,x.SAFARI)&&!M(n,x.CHROME)&&!M(n,x.ANDROID);var n}(e,t)?M(e,x.MOBILE)?x.MOBILE_SAFARI:x.SAFARI:M(e,x.FIREFOX)?x.FIREFOX:M(e,"MSIE")||M(e,"Trident/")?x.INTERNET_EXPLORER:M(e,"Gecko")?x.FIREFOX:""}const K={[x.INTERNET_EXPLORER_MOBILE]:[new RegExp("rv:"+D)],[x.MICROSOFT_EDGE]:[new RegExp(x.EDGE+"?\\/"+D)],[x.CHROME]:[new RegExp("("+x.CHROME+"|CrMo)\\/"+D)],[x.CHROME_IOS]:[new RegExp("CriOS\\/"+D)],[x.UC_BROWSER]:[new RegExp("(UCBrowser|UCWEB)\\/"+D)],[x.SAFARI]:[k],[x.MOBILE_SAFARI]:[k],[x.OPERA]:[new RegExp("("+x.OPERA+"|OPR)\\/"+D)],[x.FIREFOX]:[new RegExp(x.FIREFOX+"\\/"+D)],[x.FIREFOX_IOS]:[new RegExp("FxiOS\\/"+D)],[x.KONQUEROR]:[new RegExp("Konqueror[:/]?"+D,"i")],[x.BLACKBERRY]:[new RegExp(x.BLACKBERRY+" "+D),k],[x.ANDROID_MOBILE]:[new RegExp("android\\s"+D,"i")],[x.SAMSUNG_INTERNET]:[new RegExp(x.SAMSUNG_BROWSER+"\\/"+D)],[x.INTERNET_EXPLORER]:[new RegExp("(rv:|MSIE )"+D)],Mozilla:[new RegExp("rv:"+D)]};function J(e,t){const n=z(e,t),i=K[n];if(a(i))return null;for(let s=0;s<i.length;s++){const t=i[s],n=e.match(t);if(n)return parseFloat(n[n.length-2])}return null}const Z=[[new RegExp(x.XBOX+"; "+x.XBOX+" (.*?)[);]","i"),e=>[x.XBOX,e&&e[1]||""]],[new RegExp(x.NINTENDO,"i"),[x.NINTENDO,""]],[new RegExp(x.PLAYSTATION,"i"),[x.PLAYSTATION,""]],[U,[x.BLACKBERRY,""]],[new RegExp(x.WINDOWS,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[x.WINDOWS_PHONE,""];if(new RegExp(x.MOBILE).test(t)&&!/IEMobile\b/.test(t))return[x.WINDOWS+" "+x.MOBILE,""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){const e=n[1];let i=Y[e]||"";return/arm/i.test(t)&&(i="RT"),[x.WINDOWS,i]}return[x.WINDOWS,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[x.IOS,t.join(".")]}return[x.IOS,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=a(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+x.ANDROID+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+x.ANDROID+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[x.ANDROID,t.join(".")]}return[x.ANDROID,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[x.CHROME_OS,""]],[/Linux|debian/i,["Linux",""]]];function Q(){const e=window.innerHeight||document.documentElement.clientHeight||document.body&&document.body.clientHeight||0,t=window.innerWidth||document.documentElement.clientWidth||document.body&&document.body.clientWidth||0,n=navigator.userAgent,i=function(e){for(let t=0;t<Z.length;t++){const[n,i]=Z[t],s=n.exec(e),r=s&&("function"==typeof i?i(s,e):i);if(r)return r}return["",""]}(n)||["",""];return{$browser:z(n),$browser_version:J(n),$url:location?.href.substring(0,1e3),$host:location?.host,$viewport_height:e,$viewport_width:t,$lib:"webjs",$lib_version:A,$search_engine:F(),$referrer:B(),$referrer_domain:m(r=r||B()),$model:(s=n,(X.test(s)?x.NINTENDO:$.test(s)?x.PLAYSTATION:H.test(s)?x.XBOX:new RegExp(x.OUYA,"i").test(s)?x.OUYA:new RegExp("("+x.WINDOWS_PHONE+"|WPDesktop)","i").test(s)?x.WINDOWS_PHONE:/iPad/.test(s)?x.IPAD:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?x.APPLE_WATCH:U.test(s)?x.BLACKBERRY:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(x.NOKIA,"i").test(s)?x.NOKIA:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":q.test(s)?x.HUAWEI:W.test(s)?x.XIAOMI:G.test(s)?x.OPPO:j.test(s)?x.VIVO:/(Android|ZTE)/i.test(s)?!new RegExp(x.MOBILE).test(s)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)?/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?x.ANDROID:x.ANDROID_TABLET:x.ANDROID:new RegExp("(pda|"+x.MOBILE+")","i").test(s)?x.GENERIC_MOBILE:new RegExp(x.TABLET,"i").test(s)&&!new RegExp(x.TABLET+" pc","i").test(s)?x.GENERIC_TABLET:"")||""),$os:i?.[0]||"",$os_version:i?.[1]||"",$pathname:location?.pathname,$screen_height:Number(screen.height)||0,$screen_width:Number(screen.width)||0};var s,r}const V=new class{constructor(){this.STORAGE_KEY="sol_unsent_events",this.MAX_QUEUE_SIZE=100,this.MAX_RETRY_COUNT=3,this.MAX_AGE_MS=6048e5,this.queue=[],this.loadFromStorage(),this.cleanupExpiredItems()}loadFromStorage(){try{const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.queue=d(e)||[])}catch(e){console.warn("Failed to load queue from localStorage:",e),this.queue=[]}}cleanupExpiredItems(){const e=Date.now(),t=this.queue.filter(t=>e-t.timestamp<this.MAX_AGE_MS&&t.retryCount<t.maxRetries);t.length!==this.queue.length&&(this.queue=t,this.saveToStorage())}saveToStorage(){try{this.cleanupExpiredItems(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE)),localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.queue))}catch(e){console.warn("Failed to save queue to localStorage:",e)}}enqueue(e,t,n,i=this.MAX_RETRY_COUNT){try{const s={id:f(),url:e,data:t,headers:n,timestamp:Date.now(),retryCount:0,maxRetries:i};return this.queue.push(s),this.saveToStorage(),s.id}catch(s){return console.warn("Failed to enqueue request:",s),""}}dequeue(e){try{this.queue=this.queue.filter(t=>t.id!==e),this.saveToStorage()}catch(t){console.warn("Failed to dequeue request:",t)}}getAll(){try{return this.cleanupExpiredItems(),[...this.queue]}catch(e){return console.warn("Failed to get queue items:",e),[]}}incrementRetryCount(e){const t=this.queue.find(t=>t.id===e);return!!t&&(t.retryCount++,t.retryCount>=t.maxRetries?(this.dequeue(e),!1):(this.saveToStorage(),!0))}clear(){this.queue=[];try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn("Failed to clear queue from localStorage:",e)}}getItemById(e){return this.queue.find(t=>t.id===e)}};class ee{constructor(e={}){this.flushTimer=null,this.isFlushing=!1,this.pendingFlush=!1,this.config={maxBatchSize:e.maxBatchSize||10,flushInterval:e.flushInterval||5e3},this.startFlushTimer()}add(){V.getAll().length>=this.config.maxBatchSize&&this.triggerFlush()}triggerFlush(){this.isFlushing?this.pendingFlush=!0:(this.isFlushing=!0,this.flush())}flush(){const e=V.getAll();if(0===e.length)return this.isFlushing=!1,void(this.pendingFlush&&(this.pendingFlush=!1,this.triggerFlush()));const t=[],n=[];e.forEach(e=>{Array.isArray(e.data)?t.push(...e.data):t.push(e.data),n.push(e.id)});const i=t.slice(0,this.config.maxBatchSize),s=e[0],r=s.url,o=s.headers;O.instance.config.debug&&console.log(JSON.stringify(i,null,2)),L({url:r,method:"POST",data:i,headers:o,callback:e=>{200!==e.statusCode?console.error("Failed to send batch events:",e):n.forEach(e=>{V.dequeue(e)}),this.isFlushing=!1;const t=V.getAll();(this.pendingFlush||t.length>=this.config.maxBatchSize)&&(this.pendingFlush=!1,this.triggerFlush())}})}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush()}}let te=null,ne=null;function ie(e,t,n){return L({url:e,method:"POST",data:t.data,headers:t.headers,callback:e=>{if(200!==e.statusCode){if(n)if(V.incrementRetryCount(n)){const e=V.getItemById(n);if(e){const t=Math.min(1e3*Math.pow(2,e.retryCount),3e4);setTimeout(()=>{ie(e.url,{data:e.data,headers:e.headers},e.id)},t)}}else console.warn("Max retries reached for request:",n)}else n&&V.dequeue(n),t.callback&&t.callback(e.json)}})}function se(e){return`${e.apiHost}/in/track`}function re(e){return`${e.apiHost}/api/abol/evalall`}function oe(e){return{"Content-Type":"application/json",ProjectToken:e.apiToken}}function ae(e,t,n){O.instance.config.debug&&console.log(JSON.stringify(t.data,null,2));const i=V.enqueue(e,t.data,t.headers);return ie(e,{...t,callback:void 0},i)}function le(e,t,n=!0){const i={time:Date.now(),trace_id:y.getTraceId(),event:e.event,properties:{...n?Q():{},...y.getCommonProps(),...e.properties}},s=y.getLoginId(),r=y.getAnonId();s&&(i.login_id=s),r&&(i.anon_id=r);const o=se(t),a=oe(t),l=S.isSupport()?(ne||(te||(te=new ee({maxBatchSize:10,flushInterval:5e3})),ne=te),ne):null;!1!==t.batchSend&&l?(V.enqueue(o,[i],a),l.add()):ae(o,{data:[i],headers:a})}function ce({userProps:e,opts:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={time:Date.now(),trace_id:y.getTraceId(),event:"$UserSet",login_id:n,anon_id:i,user_properties:e};return ae(se(t),{data:[s],headers:oe(t)})}function ue(e){return`$ab_${e.id}`}function he(e){const t=e.typ;return t===N.FEATURE_GATE&&"fail"!==e.vid?{[ue(e)]:e.vid}:t===N.EXPERIMENT?{[ue(e)]:e.vid}:{}}function de({isHit:e,data:t,opts:n}){if(!t||c(t))return;let i={};i=e?{$set:{...he(t)}}:{$unset:{[ue(t)]:null}};const s=y.getLoginId(),r=y.getAnonId();if(!s||!r)return;const o={time:Date.now(),trace_id:y.getTraceId(),event:"$ABImpress",login_id:s,anon_id:r,properties:{...Q(),...y.getCommonProps()},user_properties:{...i}};return ae(se(n),{data:[o],headers:oe(n)})}class ge{constructor({plugins:e,emitter:t,config:n}){this.plugins=[],this.pluginInsMap={},this.emitter=t,this.config=n,this.registerBuiltInPlugins(e),this.created(),this.emitter.on(_,()=>{this.init()})}registerBuiltInPlugins(e){for(let t=0,n=e.length;t<n;t++)this.registerPlugin(e[t])}registerPlugin(e){this.plugins.push(e)}getPlugins(){return this.plugins}getPlugin(e){return this.pluginInsMap[e]}created(){for(let e=0,t=this.plugins.length;e<t;e++){const t=this.plugins[e];if(!t.NAME)throw new Error('Plugin should be defined with "NAME"');const n=new t({emitter:this.emitter,config:this.config});this.pluginInsMap[t.NAME]=n}}init(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.init&&t.init()}}destroy(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.destroy&&"function"==typeof t.destroy&&t.destroy()}this.pluginInsMap={},this.plugins=[]}}const pe=class{constructor({emitter:e,config:t}){this.boundSend=null,this.hashEvent=null,this.emitter=e,this.config=t}init(){const e=this.config;this.boundSend=()=>{le({event:"$PageView",properties:{$title:document.title}},e)},e.isSinglePageApp?(this.hashEvent="pushState"in window.history?"popstate":"hashchange",window.addEventListener(this.hashEvent,this.boundSend)):this.boundSend()}destroy(){this.hashEvent&&this.boundSend&&(window.removeEventListener(this.hashEvent,this.boundSend),this.hashEvent=null,this.boundSend=null)}};pe.NAME="pageview";let fe=pe;const me=class{constructor({emitter:e,config:t}){this.startTime=Date.now(),this.pageShowStatus=!0,this.pageHiddenStatus=!1,this.timer=null,this.currentPageUrl=document.referrer,this.url=location.href,this.title=document.title||"",this.heartbeatIntervalTime=5e3,this.heartbeatIntervalTimer=null,this.pageId=null,this.storageName="solwebjssdkpageleave",this.maxDuration=432e3,this.eventListeners=[],this.emitter=e,this.config=t}init(){this.pageId=Number(String(p()).slice(2,5)+String(p()).slice(2,4)+String(Date.now()).slice(-4)),this.addEventListener(),!0===document.hidden?this.pageShowStatus=!1:this.addHeartBeatInterval()}log(e){console.log(e)}refreshPageEndTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this.pageHiddenStatus=!1},5e3)}hiddenStatusHandler(){this.timer&&clearTimeout(this.timer),this.timer=null,this.pageHiddenStatus=!1}pageStartHandler(){this.startTime=Date.now(),1==!document.hidden?this.pageShowStatus=!0:this.pageShowStatus=!1,this.url=location.href,this.title=document.title}pageEndHandler(){if(!0===this.pageHiddenStatus)return;const e=this.getPageLeaveProperties();!1===this.pageShowStatus&&delete e.event_duration,this.pageShowStatus=!1,this.pageHiddenStatus=!0,le({event:b,properties:e},this.config),this.refreshPageEndTimer(),this.delHeartBeatData()}addEventListener(){this.addPageStartListener(),this.addPageSwitchListener(),this.addSinglePageListener(),this.addPageEndListener()}addPageStartListener(){if("onpageshow"in window){const e=()=>{this.pageStartHandler(),this.hiddenStatusHandler()};window.addEventListener("pageshow",e),this.eventListeners.push({target:window,event:"pageshow",handler:e})}}addSinglePageListener(){this.config.isSinglePageApp&&this.emitter.on(v,e=>{e!==location.href&&(this.url=e,this.pageEndHandler(),this.stopHeartBeatInterval(),this.currentPageUrl=this.url,this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval())})}addPageEndListener(){["pagehide","beforeunload","unload"].forEach(e=>{if(`on${e}`in window){const t=()=>{this.pageEndHandler(),this.stopHeartBeatInterval()};window.addEventListener(e,t),this.eventListeners.push({target:window,event:e,handler:t})}})}addPageSwitchListener(){const e=()=>{"visible"===document.visibilityState?(this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval()):(this.url=location.href,this.title=document.title,this.pageEndHandler(),this.stopHeartBeatInterval())};document.addEventListener("visibilitychange",e),this.eventListeners.push({target:document,event:"visibilitychange",handler:e})}addHeartBeatInterval(){S.isSupport()&&this.startHeartBeatInterval()}startHeartBeatInterval(){this.heartbeatIntervalTimer&&this.stopHeartBeatInterval(),this.heartbeatIntervalTimer=setInterval(()=>{this.saveHeartBeatData()},this.heartbeatIntervalTime),this.saveHeartBeatData("is_first_heartbeat"),this.reissueHeartBeatData()}stopHeartBeatInterval(){this.heartbeatIntervalTimer&&clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null}saveHeartBeatData(e){const t=this.getPageLeaveProperties();t.$time=Date.now(),"is_first_heartbeat"===e&&(t.event_duration=3);const n={type:"track",event:b,properties:t};n.heartbeat_interval_time=this.heartbeatIntervalTime,S.isSupport()&&S.set(`${this.storageName}-${this.pageId}`,JSON.stringify(n))}delHeartBeatData(e){S.isSupport()&&S.remove(e||`${this.storageName}-${this.pageId}`)}reissueHeartBeatData(){for(let e=window.localStorage.length-1;e>=0;e--){const t=window.localStorage.key(e);if(t&&t!==`${this.storageName}-${this.pageId}`&&0===t.indexOf(`${this.storageName}-`)){const e=S.parse(t);i(e)&&Date.now()-e.time>e.heartbeat_interval_time+5e3&&(delete e.heartbeat_interval_time,e._flush_time=(new Date).getTime(),le({event:b,properties:e?.properties},this.config),this.delHeartBeatData(t))}}}getPageLeaveProperties(){let e=(Date.now()-this.startTime)/1e3;(isNaN(e)||e<0||e>this.maxDuration)&&(e=0),e=Number(e.toFixed(3));const t=document.documentElement&&document.documentElement.scrollTop||window.pageYOffset||document.body&&document.body.scrollTop||0,n=Math.round(t)||0,i={$title:this.title,$viewport_position:n};return 0!==e&&(i.event_duration=e),i}destroy(){this.eventListeners.forEach(({target:e,event:t,handler:n})=>{e.removeEventListener(t,n)}),this.eventListeners=[],this.timer&&(clearTimeout(this.timer),this.timer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};me.NAME="pageleave";let Ee=me;const Ie=class{constructor({emitter:e,config:t}){this.eventSended=!1,this.emitter=e,this.config=t}init(){const e=()=>{let t=0;const n=window.performance,i={$title:document.title};if(n){t=function(){let e=0;if("function"==typeof performance.getEntriesByType){const t=performance.getEntriesByType("navigation");t.length>0&&(e=t[0].domContentLoadedEventEnd||0)}return e}();const e=function(){if(performance.getEntries&&"function"==typeof performance.getEntries){const e=performance.getEntries();let t=0;for(const n of e)"transferSize"in n&&(t+=n.transferSize);if("number"==typeof t&&t>=0&&t<10737418240)return Number((t/1024).toFixed(3))}}();e&&(i.$page_resource_size=e)}else console.warn("Performance API is not supported.");t>0&&!Number.isFinite(t)&&(i.event_duration=Number((t/1e3).toFixed(3))),this.eventSended||(this.eventSended=!0,le({event:"$PageLoad",properties:i},this.config)),window.removeEventListener("load",e)};"complete"===document.readyState?e():window.addEventListener&&window.addEventListener("load",e)}};Ie.NAME="pageload";let Se=Ie;function we(e,t){if(!u(e))return!1;const n=o(e.tagName)?e.tagName.toLowerCase():"unknown",i={};i.$element_type=n,i.$element_name=e.getAttribute("name"),i.$element_id=e.getAttribute("id"),i.$element_class_name=o(e.className)?e.className:null,i.$element_target_url=e.getAttribute("href"),i.$element_content=function(e,t){return o(t)&&"input"===t.toLowerCase()?("button"===(n=e).type||"submit"===n.type)&&n.value||"":function(e,t){let n="",i="";return e.textContent?n=w(e.textContent):e.innerText&&(n=w(e.innerText)),n&&(n=n.replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)),i=n||"","input"!==t&&"INPUT"!==t||(i=e.value||""),i}(e,t);var n}(e,n),i.$element_selector=Oe(e),i.$element_path=function(e){let t=[];for(;e.parentNode&&u(e);){if(!o(e.tagName))return"unknown";if(e.id&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.id)){t.unshift(e.tagName.toLowerCase()+"#"+e.id);break}if(e===document.body){t.unshift("body");break}t.unshift(e.tagName.toLowerCase()),e=e.parentNode}return t.join(" > ")}(e),i.$url_path=location.pathname,i.$title=document.title;const s=function(e,t){const n=t.pageX||t.clientX+Ae().scrollLeft||t.offsetX+_e(e).targetEleX,i=t.pageY||t.clientY+Ae().scrollTop||t.offsetY+_e(e).targetEleY;return{$page_x:ve(n),$page_y:ve(i)}}(e,t);return i.$page_x=s.$page_x,i.$page_y=s.$page_y,i}function Oe(e,t=[]){if(!(e&&e.parentNode&&e.parentNode.children&&o(e.tagName)))return"unknown";t=Array.isArray(t)?t:[];const n=e.nodeName.toLowerCase();return e&&"body"!==n&&1==e.nodeType?(t.unshift(function(e){if(!e||!u(e)||!o(e.tagName))return"";let t=e.parentNode&&9==e.parentNode.nodeType?-1:function(e){if(!e.parentNode)return-1;let t=0;const n=e.tagName,i=e.parentNode.children;for(let s=0,r=i.length;s<r;s++)if(i[s].tagName===n){if(e===i[s])return t;t++}return-1}(e);return e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?"#"+e.getAttribute("id"):e.tagName.toLowerCase()+(~t?":nth-of-type("+(t+1)+")":"")}(e)),e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?t.join(" > "):Oe(e.parentNode,t)):(t.unshift("body"),t.join(" > "))}function Ae(){return{scrollLeft:document.body.scrollLeft||document.documentElement.scrollLeft||0,scrollTop:document.body.scrollTop||document.documentElement.scrollTop||0}}function _e(e){if(document.documentElement.getBoundingClientRect){const t=e.getBoundingClientRect();return{targetEleX:t.left+Ae().scrollLeft||0,targetEleY:t.top+Ae().scrollTop||0}}return{targetEleX:0,targetEleY:0}}function ve(e){return Number(Number(e).toFixed(3))}const Re=class{constructor({emitter:e,config:t}){this.isInitialized=!1,this.boundHandleClick=null,this.emitter=e,this.config=t}init(){this.isInitialized||(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,!0),this.isInitialized=!0)}handleClick(e){const t=e.target;if(!t)return;if(!["A","INPUT","BUTTON","TEXTAREA"].includes(t.tagName))return;if("true"===t.getAttribute("sol-disable"))return;le({event:"$WebClick",properties:we(t,e)||{}},this.config)}destroy(){this.boundHandleClick&&(document.removeEventListener("click",this.boundHandleClick,!0),this.boundHandleClick=null),this.isInitialized=!1}};Re.NAME="webclick";let be=Re;const Ne=class{constructor({emitter:e,config:t}){this.updateInterval=null,this.fetchingPromise=null,this.emitter=e,this.config=t}init(){const e=this.config;e.enableAB&&(this.fastFetch().then(()=>{this.emitter.emit(R)}),e.abRefreshInterval<3e4&&(e.abRefreshInterval=3e4),this.updateInterval=setInterval(()=>{this.fetchNewData().catch(console.warn)},e.abRefreshInterval))}async fastFetch(){const e=y.getABData();return e&&e.length?(this.emitter.emit(R),Promise.resolve(e)):this.fetchNewData()}async fetchNewData(){return this.fetchingPromise||(this.fetchingPromise=new Promise(e=>{!function({opts:e,cb:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={user:{login_id:n,anon_id:i,props:{...Q(),...y.getCommonProps()}},sdk:"webjs",sdk_version:A};L({url:re(e),method:"POST",data:s,headers:oe(e),callback:e=>{200!==e.statusCode?console.error("Failed to fetch feature flags"):t&&t(e.json)}})}({opts:this.config,cb:t=>{y.saveABData(t.data?.results||[]),e(t),this.fetchingPromise=null}})})),this.fetchingPromise}async getFeatureGate(e){return await this.fastFetch().catch(console.warn),y.getABData().find(t=>t.typ===N.FEATURE_GATE&&t.key==e)}async checkFeatureGate(e){const t=await this.getFeatureGate(e);return!!t&&("fail"===t.vid?(de({isHit:!1,data:t,opts:this.config}),!1):(de({isHit:!0,data:t,opts:this.config}),!0))}async getExperiment(e){await this.fastFetch().catch(console.warn);const t=y.getABData().find(t=>t.typ===N.EXPERIMENT&&t.key===e);return t?t?.vid?(de({isHit:!0,data:t,opts:this.config}),t?.value||{}):(de({isHit:!1,data:t,opts:this.config}),{}):{}}destroy(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null),this.fetchingPromise=null}};Ne.NAME="abtest";let Te=Ne;const ye=[],Pe={debug:!1,apiToken:"",apiHost:"",autoCapture:!0,isSinglePageApp:!1,crossSubdomainCookie:!0,enableAB:!1,abRefreshInterval:T,enableClickTrack:!1,batchSend:!0};return new class{constructor(){this.__loaded=!1,this.config={},this.eventEmitter=new e,this.pluginCore={},this.commonProps={},this.spaCleanup=null,O.instance=this}init(e,t={}){t.apiToken=e,this.mergeConfig(t),this.eventEmitter.emit("init-param",this.config);const n=this.config;return y.init(n.crossSubdomainCookie),this.__loaded=!0,window._solFailedRequestsInitialized||(window._solFailedRequestsInitialized=!0,function(){const e=V.getAll();0!==e.length&&e.forEach(e=>{ie(e.url,{data:e.data,headers:e.headers},e.id)})}()),n.autoCapture&&this.autoTrack(),n.enableAB&&ye.push(Te),n.enableClickTrack&&ye.push(be),this.pluginCore=new ge({plugins:ye,emitter:this.eventEmitter,config:n}),this.spaCleanup=function(e){let t=location.href;const n=window.history.pushState,i=window.history.replaceState,r=function(){e(t),t=location.href};return s(window.history.pushState)&&(window.history.pushState=function(...i){n.apply(window.history,i),e(t),t=location.href}),s(window.history.replaceState)&&(window.history.replaceState=function(...n){i.apply(window.history,n),e(t),t=location.href}),window.addEventListener("popstate",r),function(){s(window.history.pushState)&&(window.history.pushState=n),s(window.history.replaceState)&&(window.history.replaceState=i),window.removeEventListener("popstate",r)}}(e=>{this.eventEmitter.emit(v,e)}),this.eventEmitter.emit(_),this}mergeConfig(e){this.config={...Pe,...e}}track(e){!function(e,t){const n={...e};n.time||(n.time=Date.now()),n.login_id||(n.login_id=y.getLoginId()),n.anon_id||(n.anon_id=y.getAnonId()),n.properties={...Q(),...y.getCommonProps(),...n.properties},ae(se(t),{data:[n],headers:oe(t)})}(e,this.config)}trackEvent(e,t){le({event:e,properties:{...t,...this.commonProps}},this.config)}autoTrack(){ye.push(fe,Se,Ee)}profileSet(e){ce({userProps:{$set:e},opts:this.config})}profileSetOnce(e){ce({userProps:{$set_once:e},opts:this.config})}profileIncrement(e){ce({userProps:{$increment:e},opts:this.config})}profileAppend(e){ce({userProps:{$append:e},opts:this.config})}profileUnion(e){ce({userProps:{$union:e},opts:this.config})}profileUnset(e){const t={};r(e)?e.forEach(function(e){t[e]=null}):t[e]=null,ce({userProps:{$unset:t},opts:this.config})}profileDelete(){ce({userProps:{$delete:!0},opts:this.config})}registerCommonProperties(e){if(!i(e))return console.warn("Commmon Properties must be an object!");this.commonProps=e,y.setCommonProps(this.commonProps)}clearCommonProperties(e){if(!r(e))return console.warn("Commmon Properties to be cleared must be an array!");e.forEach(e=>{delete this.commonProps[e]}),y.setCommonProps(this.commonProps)}identify(e){y.setLoginId(e),function(e){const t=y.getLoginId(),n=y.getAnonId();if(!t||!n)return;const i={time:Date.now(),trace_id:y.getTraceId(),event:"$Identify",login_id:t,anon_id:n};ae(se(e),{data:[i],headers:oe(e)})}(this.config)}setLoginId(e){y.setLoginId(e)}getAnonId(){return y.getAnonId()}getLoginId(){return y.getLoginId()}checkFeatureGate(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.checkFeatureGate(e):Promise.reject("AB is disabled")}getExperiment(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.getExperiment(e):Promise.reject("AB is disabled")}destroy(){ne&&(ne.destroy(),ne=null),this.spaCleanup&&"function"==typeof this.spaCleanup&&(this.spaCleanup(),this.spaCleanup=null),this.pluginCore&&"function"==typeof this.pluginCore.destroy&&this.pluginCore.destroy(),this.eventEmitter&&this.eventEmitter.removeAllListeners(),O.instance===this&&(O.instance=null)}}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SensorsWave=t()}(this,function(){"use strict";class e{constructor(){this.listeners={}}on(e,t,n=!1){if(e&&t){if(!s(t))throw new Error("listener must be a function");this.listeners[e]=this.listeners[e]||[],this.listeners[e].push({listener:t,once:n})}}off(e,t){const n=this.listeners[e];if(!n?.length)return;"number"==typeof t&&n.splice(t,1);const i=n.findIndex(e=>e.listener===t);-1!==i&&n.splice(i,1)}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((n,i)=>{n.listener.call(this,...t),n.listener.once&&this.off(e,i)})}once(e,t){this.on(e,t,!0)}removeAllListeners(e){e?this.listeners[e]=[]:this.listeners={}}}const t={get:function(e){const t=e+"=",n=document.cookie.split(";");for(let i=0,s=n.length;i<s;i++){let e=n[i];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(t))return h(e.substring(t.length,e.length))}return null},set:function({name:e,value:t,expires:n,samesite:i,secure:s,domain:r}){let o="",a="",l="",c="";if(0!==(n=null==n||void 0===n?365:n)){const e=new Date;"s"===String(n).slice(-1)?e.setTime(e.getTime()+1e3*Number(String(n).slice(0,-1))):e.setTime(e.getTime()+24*n*60*60*1e3),o="; expires="+e.toUTCString()}function u(e){return e?e.replace(/\r\n/g,""):""}i&&(l="; SameSite="+i),s&&(a="; secure");const h=u(e),d=u(t),g=u(r);g&&(c="; domain="+g),h&&d&&(document.cookie=h+"="+encodeURIComponent(d)+o+"; path=/"+c+l+a)},remove:function(e){this.set({name:e,value:"",expires:-1})},isSupport:function({samesite:e,secure:t}={}){if(!navigator.cookieEnabled)return!1;const n="sol_cookie_support_test";return this.set({name:n,value:"1",samesite:e,secure:t}),"1"===this.get(n)&&(this.remove(n),!0)}},n=Object.prototype.toString;function i(e){return"[object Object]"===n.call(e)}function s(e){const t=n.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t}function r(e){return"[object Array]"==n.call(e)}function o(e){return"[object String]"==n.call(e)}function a(e){return void 0===e}const l=Object.prototype.hasOwnProperty;function c(e){if(i(e)){for(let t in e)if(l.call(e,t))return!1;return!0}return!1}function u(e){return!(!e||1!==e.nodeType)}function h(e){let t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t}function d(e){try{return JSON.parse(e)}catch(t){return""}}const g=function(){let e=Date.now();return function(t){return Math.ceil((e=(9301*e+49297)%233280,e/233280*t))}}();function p(){if("function"==typeof Uint32Array){let e;if("undefined"!=typeof crypto&&(e=crypto),e&&i(e)&&e.getRandomValues)return e.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}return g(1e19)/1e19}const f=function(){function e(){let e=Date.now(),t=0;for(;e==Date.now();)t++;return e.toString(16)+t.toString(16)}return function(){let t=String(screen.height*screen.width);t=t&&/\d{5,}/.test(t)?t.toString():String(31242*p()).replace(".","").slice(0,8);return e()+"-"+p().toString(16).replace(".","")+"-"+function(){const e=navigator.userAgent;let t,n=[],i=0;function s(e,t){let i=0;for(let s=0;s<t.length;s++)i|=n[s]<<8*s;return e^i}for(let r=0;r<e.length;r++)t=e.charCodeAt(r),n.unshift(255&t),n.length>=4&&(i=s(i,n),n=[]);return n.length>0&&(i=s(i,n)),i.toString(16)}()+"-"+t+"-"+e()||(String(p())+String(p())+String(p())).slice(2,15)}}();function m(e,t){t&&"string"==typeof t||(t="");let n=null;try{n=new URL(e).hostname}catch(i){}return n||t}function E(e){let t=[];try{t=atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})}catch(n){t=[]}try{return decodeURIComponent(t.join(""))}catch(n){return t.join("")}}function I(e){let t="";try{t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}))}catch(n){t=e}return t}const S={get:function(e){return window.localStorage.getItem(e)},parse:function(e){let t;try{t=JSON.parse(S.get(e))||null}catch(n){console.warn(n)}return t},set:function(e,t){try{window.localStorage.setItem(e,t)}catch(n){console.warn(n)}},remove:function(e){window.localStorage.removeItem(e)},isSupport:function(){let e=!0;try{const t="__local_store_support__",n="testIsSupportStorage";S.set(t,n),S.get(t)!==n&&(e=!1),S.remove(t)}catch(t){e=!1}return e}};function w(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}const O={},A="0.3.2",_="init-ready",v="spa-switch",R="ff-ready",b="$PageLeave";var N=(e=>(e[e.FEATURE_GATE=1]="FEATURE_GATE",e[e.FEATURE_CONFIG=2]="FEATURE_CONFIG",e[e.EXPERIMENT=3]="EXPERIMENT",e))(N||{});const T=6e5,y={crossSubdomain:!1,requests:[],_sessionState:{},_abData:[],_trace_id:"",commonProps:{},_state:{anon_id:"",login_id:"",identities:{}},getIdentityCookieID(){return this._state.identities?.$identity_cookie_id||""},getCommonProps:function(){return this.commonProps||{}},setCommonProps:function(e){this.commonProps=e},getAnonId(){return this.getIdentityCookieID()||this._state.anon_id||f()},getLoginId(){return this._state.login_id},getTraceId(){return this._trace_id||f()},set:function(e,t){this._state[e]=t,this.save()},getCookieName:function(){return"sol2025jssdkcross"},getABLSName:function(){return"sol2025jssdkablatest"},save:function(){let e=JSON.parse(JSON.stringify(this._state));e.identities&&(e.identities=I(JSON.stringify(e.identities)));const n=JSON.stringify(e);t.set({name:this.getCookieName(),value:n,expires:365})},init:function(e){let n,s;this.crossSubdomain=e,t.isSupport()&&(n=t.get(this.getCookieName()),s=d(n)),y._state={...s||{}},y._state.identities&&(y._state.identities=d(E(y._state.identities))),y._state.identities&&i(y._state.identities)&&!c(y._state.identities)||(y._state.identities={$identity_cookie_id:f()}),y.save()},setLoginId(e){"number"==typeof e&&(e=String(e)),void 0!==e&&e&&(y.set("login_id",e),y.save())},saveABData(e){if(!e||c(e))return;this._abData=e;let t=JSON.parse(JSON.stringify(this._abData));t=I(JSON.stringify(t));try{localStorage.setItem(this.getABLSName(),JSON.stringify({time:Date.now(),data:t,anon_id:this.getAnonId(),login_id:this.getLoginId()}))}catch(n){console.warn("Failed to save abdata to localStorage",n)}},getABData(){try{let e=localStorage.getItem(this.getABLSName());if(e){const{time:t,data:n,login_id:i,anon_id:s}=d(e)||{};if(t&&n&&Date.now()-t<T&&s===this.getAnonId()&&(!i||i===this.getLoginId()))return d(E(n));localStorage.removeItem(this.getABLSName())}}catch(e){console.warn("Failed to load abdata from localStorage",e),this._abData=[]}return this._abData||[]}};function P(e){var t;if(e.data)return{contentType:"application/json",body:(t=e.data,JSON.stringify(t,(e,t)=>"bigint"==typeof t?t.toString():t,undefined))}}const C=[];function L(e){const t={...e};t.timeout=t.timeout||6e4;const n=t.transport??"fetch",i=C.find(e=>e.transport===n)?.method??C[0]?.method;if(!i)throw new Error("No available transport method for HTTP request");i(t)}function B(e){return o(e=e||document.referrer)&&(e=h(e=e.trim()))||""}function F(e){const t=m(e=e||B());if(!t)return"";const n={baidu:[/^.*\.baidu\.com$/],bing:[/^.*\.bing\.com$/],google:[/^www\.google\.com$/,/^www\.google\.com\.[a-z]{2}$/,/^www\.google\.[a-z]{2}$/],sm:[/^m\.sm\.cn$/],so:[/^.+\.so\.com$/],sogou:[/^.*\.sogou\.com$/],yahoo:[/^.*\.yahoo\.com$/],duckduckgo:[/^.*\.duckduckgo\.com$/]};for(let i of Object.keys(n)){let e=n[i];for(let n=0,s=e.length;n<s;n++)if(e[n].test(t))return i}return"Unknown Search Engine"}function M(e,t){return-1!==e.indexOf(t)}"function"==typeof fetch&&C.push({transport:"fetch",method:function(e){if("undefined"==typeof fetch)return void console.error("fetch API is not available");const t=P(e),n=new Headers;e.headers&&Object.keys(e.headers).forEach(t=>{n.append(t,e.headers[t])}),t?.contentType&&n.append("Content-Type",t.contentType),fetch(e.url,{method:e.method||"GET",headers:n,body:t?.body}).then(t=>t.text().then(n=>{const i={statusCode:t.status,text:n};if(200===t.status)try{i.json=JSON.parse(n)}catch(s){console.error("Failed to parse response:",s)}e.callback?.(i)})).catch(t=>{console.error("Request failed:",t),e.callback?.({statusCode:0,text:String(t)})})}}),"undefined"!=typeof XMLHttpRequest&&C.push({transport:"XHR",method:function(e){if("undefined"==typeof XMLHttpRequest)return void console.error("XMLHttpRequest is not available");const t=new XMLHttpRequest;t.open(e.method||"GET",e.url,!0);const n=P(e);e.headers&&Object.keys(e.headers).forEach(n=>{t.setRequestHeader(n,e.headers[n])}),n?.contentType&&t.setRequestHeader("Content-Type",n.contentType),t.timeout=e.timeout||6e4,t.withCredentials=!0,t.onreadystatechange=()=>{if(4===t.readyState){const i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(n){console.error("Failed to parse JSON response:",n)}e.callback?.(i)}},t.send(n?.body)}});const x={FACEBOOK:"Facebook",MOBILE:"Mobile",IOS:"iOS",ANDROID:"Android",TABLET:"Tablet",ANDROID_TABLET:"Android Tablet",IPAD:"iPad",APPLE:"Apple",APPLE_WATCH:"Apple Watch",SAFARI:"Safari",BLACKBERRY:"BlackBerry",SAMSUNG_BROWSER:"SamsungBrowser",SAMSUNG_INTERNET:"Samsung Internet",CHROME:"Chrome",CHROME_OS:"Chrome OS",CHROME_IOS:"Chrome iOS",INTERNET_EXPLORER:"Internet Explorer",INTERNET_EXPLORER_MOBILE:"Internet Explorer Mobile",OPERA:"Opera",OPERA_MINI:"Opera Mini",EDGE:"Edge",MICROSOFT_EDGE:"Microsoft Edge",FIREFOX:"Firefox",FIREFOX_IOS:"Firefox iOS",NINTENDO:"Nintendo",PLAYSTATION:"PlayStation",XBOX:"Xbox",ANDROID_MOBILE:"Android Mobile",MOBILE_SAFARI:"Mobile Safari",WINDOWS:"Windows",WINDOWS_PHONE:"Windows Phone",NOKIA:"Nokia",OUYA:"Ouya",GENERIC_MOBILE:"Generic mobile",GENERIC_TABLET:"Generic tablet",KONQUEROR:"Konqueror",UC_BROWSER:"UC Browser",HUAWEI:"Huawei",XIAOMI:"Xiaomi",OPPO:"OPPO",VIVO:"vivo"},D="(\\d+(\\.\\d+)?)",k=new RegExp("Version/"+D),H=new RegExp(x.XBOX,"i"),$=new RegExp(x.PLAYSTATION+" \\w+","i"),X=new RegExp(x.NINTENDO+" \\w+","i"),U=new RegExp(x.BLACKBERRY+"|PlayBook|BB10","i"),q=new RegExp("(HUAWEI|honor|HONOR)","i"),W=new RegExp("(Xiaomi|Redmi)","i"),G=new RegExp("(OPPO|realme)","i"),j=new RegExp("(vivo|IQOO)","i"),Y={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function z(e,t){return t=t||"",M(e," OPR/")&&M(e,"Mini")?x.OPERA_MINI:M(e," OPR/")?x.OPERA:U.test(e)?x.BLACKBERRY:M(e,"IE"+x.MOBILE)||M(e,"WPDesktop")?x.INTERNET_EXPLORER_MOBILE:M(e,x.SAMSUNG_BROWSER)?x.SAMSUNG_INTERNET:M(e,x.EDGE)||M(e,"Edg/")?x.MICROSOFT_EDGE:M(e,"FBIOS")?x.FACEBOOK+" "+x.MOBILE:M(e,"UCWEB")||M(e,"UCBrowser")?x.UC_BROWSER:M(e,"CriOS")?x.CHROME_IOS:M(e,"CrMo")||M(e,x.CHROME)?x.CHROME:M(e,x.ANDROID)&&M(e,x.SAFARI)?x.ANDROID_MOBILE:M(e,"FxiOS")?x.FIREFOX_IOS:M(e.toLowerCase(),x.KONQUEROR.toLowerCase())?x.KONQUEROR:function(e,t){return t&&M(t,x.APPLE)||M(n=e,x.SAFARI)&&!M(n,x.CHROME)&&!M(n,x.ANDROID);var n}(e,t)?M(e,x.MOBILE)?x.MOBILE_SAFARI:x.SAFARI:M(e,x.FIREFOX)?x.FIREFOX:M(e,"MSIE")||M(e,"Trident/")?x.INTERNET_EXPLORER:M(e,"Gecko")?x.FIREFOX:""}const K={[x.INTERNET_EXPLORER_MOBILE]:[new RegExp("rv:"+D)],[x.MICROSOFT_EDGE]:[new RegExp(x.EDGE+"?\\/"+D)],[x.CHROME]:[new RegExp("("+x.CHROME+"|CrMo)\\/"+D)],[x.CHROME_IOS]:[new RegExp("CriOS\\/"+D)],[x.UC_BROWSER]:[new RegExp("(UCBrowser|UCWEB)\\/"+D)],[x.SAFARI]:[k],[x.MOBILE_SAFARI]:[k],[x.OPERA]:[new RegExp("("+x.OPERA+"|OPR)\\/"+D)],[x.FIREFOX]:[new RegExp(x.FIREFOX+"\\/"+D)],[x.FIREFOX_IOS]:[new RegExp("FxiOS\\/"+D)],[x.KONQUEROR]:[new RegExp("Konqueror[:/]?"+D,"i")],[x.BLACKBERRY]:[new RegExp(x.BLACKBERRY+" "+D),k],[x.ANDROID_MOBILE]:[new RegExp("android\\s"+D,"i")],[x.SAMSUNG_INTERNET]:[new RegExp(x.SAMSUNG_BROWSER+"\\/"+D)],[x.INTERNET_EXPLORER]:[new RegExp("(rv:|MSIE )"+D)],Mozilla:[new RegExp("rv:"+D)]};function J(e,t){const n=z(e,t),i=K[n];if(a(i))return null;for(let s=0;s<i.length;s++){const t=i[s],n=e.match(t);if(n)return parseFloat(n[n.length-2])}return null}const Z=[[new RegExp(x.XBOX+"; "+x.XBOX+" (.*?)[);]","i"),e=>[x.XBOX,e&&e[1]||""]],[new RegExp(x.NINTENDO,"i"),[x.NINTENDO,""]],[new RegExp(x.PLAYSTATION,"i"),[x.PLAYSTATION,""]],[U,[x.BLACKBERRY,""]],[new RegExp(x.WINDOWS,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[x.WINDOWS_PHONE,""];if(new RegExp(x.MOBILE).test(t)&&!/IEMobile\b/.test(t))return[x.WINDOWS+" "+x.MOBILE,""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){const e=n[1];let i=Y[e]||"";return/arm/i.test(t)&&(i="RT"),[x.WINDOWS,i]}return[x.WINDOWS,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){const t=[e[3],e[4],e[5]||"0"];return[x.IOS,t.join(".")]}return[x.IOS,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=a(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+x.ANDROID+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+x.ANDROID+")","i"),e=>{if(e&&e[2]){const t=[e[2],e[3],e[4]||"0"];return[x.ANDROID,t.join(".")]}return[x.ANDROID,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];if(e&&e[1]){const n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[x.CHROME_OS,""]],[/Linux|debian/i,["Linux",""]]];function Q(){const e=window.innerHeight||document.documentElement.clientHeight||document.body&&document.body.clientHeight||0,t=window.innerWidth||document.documentElement.clientWidth||document.body&&document.body.clientWidth||0,n=navigator.userAgent,i=function(e){for(let t=0;t<Z.length;t++){const[n,i]=Z[t],s=n.exec(e),r=s&&("function"==typeof i?i(s,e):i);if(r)return r}return["",""]}(n)||["",""];return{$browser:z(n),$browser_version:J(n),$url:location?.href.substring(0,1e3),$host:location?.host,$viewport_height:e,$viewport_width:t,$lib:"webjs",$lib_version:A,$search_engine:F(),$referrer:B(),$referrer_domain:m(r=r||B()),$model:(s=n,(X.test(s)?x.NINTENDO:$.test(s)?x.PLAYSTATION:H.test(s)?x.XBOX:new RegExp(x.OUYA,"i").test(s)?x.OUYA:new RegExp("("+x.WINDOWS_PHONE+"|WPDesktop)","i").test(s)?x.WINDOWS_PHONE:/iPad/.test(s)?x.IPAD:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?x.APPLE_WATCH:U.test(s)?x.BLACKBERRY:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(x.NOKIA,"i").test(s)?x.NOKIA:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":q.test(s)?x.HUAWEI:W.test(s)?x.XIAOMI:G.test(s)?x.OPPO:j.test(s)?x.VIVO:/(Android|ZTE)/i.test(s)?!new RegExp(x.MOBILE).test(s)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)?/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?x.ANDROID:x.ANDROID_TABLET:x.ANDROID:new RegExp("(pda|"+x.MOBILE+")","i").test(s)?x.GENERIC_MOBILE:new RegExp(x.TABLET,"i").test(s)&&!new RegExp(x.TABLET+" pc","i").test(s)?x.GENERIC_TABLET:"")||""),$os:i?.[0]||"",$os_version:i?.[1]||"",$pathname:location?.pathname,$screen_height:Number(screen.height)||0,$screen_width:Number(screen.width)||0};var s,r}const V=new class{constructor(){this.STORAGE_KEY="sol_unsent_events",this.MAX_QUEUE_SIZE=100,this.MAX_RETRY_COUNT=3,this.MAX_AGE_MS=6048e5,this.queue=[],this.loadFromStorage(),this.cleanupExpiredItems()}loadFromStorage(){try{const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.queue=d(e)||[])}catch(e){console.warn("Failed to load queue from localStorage:",e),this.queue=[]}}cleanupExpiredItems(){const e=Date.now(),t=this.queue.filter(t=>e-t.timestamp<this.MAX_AGE_MS&&t.retryCount<t.maxRetries);t.length!==this.queue.length&&(this.queue=t,this.saveToStorage())}saveToStorage(){try{this.cleanupExpiredItems(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE)),localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.queue))}catch(e){console.warn("Failed to save queue to localStorage:",e)}}enqueue(e,t,n,i=this.MAX_RETRY_COUNT){try{const s={id:f(),url:e,data:t,headers:n,timestamp:Date.now(),retryCount:0,maxRetries:i};return this.queue.push(s),this.saveToStorage(),s.id}catch(s){return console.warn("Failed to enqueue request:",s),""}}dequeue(e){try{this.queue=this.queue.filter(t=>t.id!==e),this.saveToStorage()}catch(t){console.warn("Failed to dequeue request:",t)}}getAll(){try{return this.cleanupExpiredItems(),[...this.queue]}catch(e){return console.warn("Failed to get queue items:",e),[]}}incrementRetryCount(e){const t=this.queue.find(t=>t.id===e);return!!t&&(t.retryCount++,t.retryCount>=t.maxRetries?(this.dequeue(e),!1):(this.saveToStorage(),!0))}clear(){this.queue=[];try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn("Failed to clear queue from localStorage:",e)}}getItemById(e){return this.queue.find(t=>t.id===e)}};class ee{constructor(e={}){this.flushTimer=null,this.isFlushing=!1,this.pendingFlush=!1,this.config={maxBatchSize:e.maxBatchSize||10,flushInterval:e.flushInterval||5e3},this.startFlushTimer()}add(){V.getAll().length>=this.config.maxBatchSize&&this.triggerFlush()}triggerFlush(){this.isFlushing?this.pendingFlush=!0:(this.isFlushing=!0,this.flush())}flush(){const e=V.getAll();if(0===e.length)return this.isFlushing=!1,void(this.pendingFlush&&(this.pendingFlush=!1,this.triggerFlush()));const t=[],n=[];e.forEach(e=>{Array.isArray(e.data)?t.push(...e.data):t.push(e.data),n.push(e.id)});const i=t.slice(0,this.config.maxBatchSize),s=e[0],r=s.url,o=s.headers;O.instance.config.debug&&console.log(JSON.stringify(i,null,2)),L({url:r,method:"POST",data:i,headers:o,callback:e=>{200!==e.statusCode?console.error("Failed to send batch events:",e):n.forEach(e=>{V.dequeue(e)}),this.isFlushing=!1;const t=V.getAll();(this.pendingFlush||t.length>=this.config.maxBatchSize)&&(this.pendingFlush=!1,this.triggerFlush())}})}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush()}}let te=null,ne=null;function ie(e,t,n){return L({url:e,method:"POST",data:t.data,headers:t.headers,callback:e=>{if(200!==e.statusCode){if(n)if(V.incrementRetryCount(n)){const e=V.getItemById(n);if(e){const t=Math.min(1e3*Math.pow(2,e.retryCount),3e4);setTimeout(()=>{ie(e.url,{data:e.data,headers:e.headers},e.id)},t)}}else console.warn("Max retries reached for request:",n)}else n&&V.dequeue(n),t.callback&&t.callback(e.json)}})}function se(e){return`${e.apiHost}/in/track`}function re(e){return`${e.apiHost}/api/abol/evalall`}function oe(e){return{"Content-Type":"application/json",ProjectToken:e.apiToken}}function ae(e,t,n){O.instance.config.debug&&console.log(JSON.stringify(t.data,null,2));const i=V.enqueue(e,t.data,t.headers);return ie(e,{...t,callback:void 0},i)}function le(e,t,n=!0){const i={time:Date.now(),trace_id:y.getTraceId(),event:e.event,properties:{...n?Q():{},...y.getCommonProps(),...e.properties}},s=y.getLoginId(),r=y.getAnonId();s&&(i.login_id=s),r&&(i.anon_id=r);const o=se(t),a=oe(t),l=S.isSupport()?(ne||(te||(te=new ee({maxBatchSize:10,flushInterval:5e3})),ne=te),ne):null;!1!==t.batchSend&&l?(V.enqueue(o,[i],a),l.add()):ae(o,{data:[i],headers:a})}function ce({userProps:e,opts:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={time:Date.now(),trace_id:y.getTraceId(),event:"$UserSet",login_id:n,anon_id:i,user_properties:e};return ae(se(t),{data:[s],headers:oe(t)})}function ue(e){return`$ab_${e.id}`}function he(e){const t=e.typ;return t===N.FEATURE_GATE&&"fail"!==e.vid?{[ue(e)]:e.vid}:t===N.EXPERIMENT?{[ue(e)]:e.vid}:{}}function de({isHit:e,data:t,opts:n}){if(!t||c(t)||t.disable_impress)return;let i={};i=e?{$set:{...he(t)}}:{$unset:{[ue(t)]:null}};const s=y.getLoginId(),r=y.getAnonId();if(!s||!r)return;const o={time:Date.now(),trace_id:y.getTraceId(),event:"$ABImpress",login_id:s,anon_id:r,properties:{...Q(),...y.getCommonProps()},user_properties:{...i}};return ae(se(n),{data:[o],headers:oe(n)})}class ge{constructor({plugins:e,emitter:t,config:n}){this.plugins=[],this.pluginInsMap={},this.emitter=t,this.config=n,this.registerBuiltInPlugins(e),this.created(),this.emitter.on(_,()=>{this.init()})}registerBuiltInPlugins(e){for(let t=0,n=e.length;t<n;t++)this.registerPlugin(e[t])}registerPlugin(e){this.plugins.push(e)}getPlugins(){return this.plugins}getPlugin(e){return this.pluginInsMap[e]}created(){for(let e=0,t=this.plugins.length;e<t;e++){const t=this.plugins[e];if(!t.NAME)throw new Error('Plugin should be defined with "NAME"');const n=new t({emitter:this.emitter,config:this.config});this.pluginInsMap[t.NAME]=n}}init(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.init&&t.init()}}destroy(){for(const e of Object.keys(this.pluginInsMap)){const t=this.pluginInsMap[e];t.destroy&&"function"==typeof t.destroy&&t.destroy()}this.pluginInsMap={},this.plugins=[]}}const pe=class{constructor({emitter:e,config:t}){this.boundSend=null,this.hashEvent=null,this.emitter=e,this.config=t}init(){const e=this.config;this.boundSend=()=>{le({event:"$PageView",properties:{$title:document.title}},e)},e.isSinglePageApp?(this.hashEvent="pushState"in window.history?"popstate":"hashchange",window.addEventListener(this.hashEvent,this.boundSend)):this.boundSend()}destroy(){this.hashEvent&&this.boundSend&&(window.removeEventListener(this.hashEvent,this.boundSend),this.hashEvent=null,this.boundSend=null)}};pe.NAME="pageview";let fe=pe;const me=class{constructor({emitter:e,config:t}){this.startTime=Date.now(),this.pageShowStatus=!0,this.pageHiddenStatus=!1,this.timer=null,this.currentPageUrl=document.referrer,this.url=location.href,this.title=document.title||"",this.heartbeatIntervalTime=5e3,this.heartbeatIntervalTimer=null,this.pageId=null,this.storageName="solwebjssdkpageleave",this.maxDuration=432e3,this.eventListeners=[],this.emitter=e,this.config=t}init(){this.pageId=Number(String(p()).slice(2,5)+String(p()).slice(2,4)+String(Date.now()).slice(-4)),this.addEventListener(),!0===document.hidden?this.pageShowStatus=!1:this.addHeartBeatInterval()}log(e){console.log(e)}refreshPageEndTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this.pageHiddenStatus=!1},5e3)}hiddenStatusHandler(){this.timer&&clearTimeout(this.timer),this.timer=null,this.pageHiddenStatus=!1}pageStartHandler(){this.startTime=Date.now(),1==!document.hidden?this.pageShowStatus=!0:this.pageShowStatus=!1,this.url=location.href,this.title=document.title}pageEndHandler(){if(!0===this.pageHiddenStatus)return;const e=this.getPageLeaveProperties();!1===this.pageShowStatus&&delete e.event_duration,this.pageShowStatus=!1,this.pageHiddenStatus=!0,le({event:b,properties:e},this.config),this.refreshPageEndTimer(),this.delHeartBeatData()}addEventListener(){this.addPageStartListener(),this.addPageSwitchListener(),this.addSinglePageListener(),this.addPageEndListener()}addPageStartListener(){if("onpageshow"in window){const e=()=>{this.pageStartHandler(),this.hiddenStatusHandler()};window.addEventListener("pageshow",e),this.eventListeners.push({target:window,event:"pageshow",handler:e})}}addSinglePageListener(){this.config.isSinglePageApp&&this.emitter.on(v,e=>{e!==location.href&&(this.url=e,this.pageEndHandler(),this.stopHeartBeatInterval(),this.currentPageUrl=this.url,this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval())})}addPageEndListener(){["pagehide","beforeunload","unload"].forEach(e=>{if(`on${e}`in window){const t=()=>{this.pageEndHandler(),this.stopHeartBeatInterval()};window.addEventListener(e,t),this.eventListeners.push({target:window,event:e,handler:t})}})}addPageSwitchListener(){const e=()=>{"visible"===document.visibilityState?(this.pageStartHandler(),this.hiddenStatusHandler(),this.addHeartBeatInterval()):(this.url=location.href,this.title=document.title,this.pageEndHandler(),this.stopHeartBeatInterval())};document.addEventListener("visibilitychange",e),this.eventListeners.push({target:document,event:"visibilitychange",handler:e})}addHeartBeatInterval(){S.isSupport()&&this.startHeartBeatInterval()}startHeartBeatInterval(){this.heartbeatIntervalTimer&&this.stopHeartBeatInterval(),this.heartbeatIntervalTimer=setInterval(()=>{this.saveHeartBeatData()},this.heartbeatIntervalTime),this.saveHeartBeatData("is_first_heartbeat"),this.reissueHeartBeatData()}stopHeartBeatInterval(){this.heartbeatIntervalTimer&&clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null}saveHeartBeatData(e){const t=this.getPageLeaveProperties();t.$time=Date.now(),"is_first_heartbeat"===e&&(t.event_duration=3);const n={type:"track",event:b,properties:t};n.heartbeat_interval_time=this.heartbeatIntervalTime,S.isSupport()&&S.set(`${this.storageName}-${this.pageId}`,JSON.stringify(n))}delHeartBeatData(e){S.isSupport()&&S.remove(e||`${this.storageName}-${this.pageId}`)}reissueHeartBeatData(){for(let e=window.localStorage.length-1;e>=0;e--){const t=window.localStorage.key(e);if(t&&t!==`${this.storageName}-${this.pageId}`&&0===t.indexOf(`${this.storageName}-`)){const e=S.parse(t);i(e)&&Date.now()-e.time>e.heartbeat_interval_time+5e3&&(delete e.heartbeat_interval_time,e._flush_time=(new Date).getTime(),le({event:b,properties:e?.properties},this.config),this.delHeartBeatData(t))}}}getPageLeaveProperties(){let e=(Date.now()-this.startTime)/1e3;(isNaN(e)||e<0||e>this.maxDuration)&&(e=0),e=Number(e.toFixed(3));const t=document.documentElement&&document.documentElement.scrollTop||window.pageYOffset||document.body&&document.body.scrollTop||0,n=Math.round(t)||0,i={$title:this.title,$viewport_position:n};return 0!==e&&(i.event_duration=e),i}destroy(){this.eventListeners.forEach(({target:e,event:t,handler:n})=>{e.removeEventListener(t,n)}),this.eventListeners=[],this.timer&&(clearTimeout(this.timer),this.timer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};me.NAME="pageleave";let Ee=me;const Ie=class{constructor({emitter:e,config:t}){this.eventSended=!1,this.emitter=e,this.config=t}init(){const e=()=>{let t=0;const n=window.performance,i={$title:document.title};if(n){t=function(){let e=0;if("function"==typeof performance.getEntriesByType){const t=performance.getEntriesByType("navigation");t.length>0&&(e=t[0].domContentLoadedEventEnd||0)}return e}();const e=function(){if(performance.getEntries&&"function"==typeof performance.getEntries){const e=performance.getEntries();let t=0;for(const n of e)"transferSize"in n&&(t+=n.transferSize);if("number"==typeof t&&t>=0&&t<10737418240)return Number((t/1024).toFixed(3))}}();e&&(i.$page_resource_size=e)}else console.warn("Performance API is not supported.");t>0&&!Number.isFinite(t)&&(i.event_duration=Number((t/1e3).toFixed(3))),this.eventSended||(this.eventSended=!0,le({event:"$PageLoad",properties:i},this.config)),window.removeEventListener("load",e)};"complete"===document.readyState?e():window.addEventListener&&window.addEventListener("load",e)}};Ie.NAME="pageload";let Se=Ie;function we(e,t){if(!u(e))return!1;const n=o(e.tagName)?e.tagName.toLowerCase():"unknown",i={};i.$element_type=n,i.$element_name=e.getAttribute("name"),i.$element_id=e.getAttribute("id"),i.$element_class_name=o(e.className)?e.className:null,i.$element_target_url=e.getAttribute("href"),i.$element_content=function(e,t){return o(t)&&"input"===t.toLowerCase()?("button"===(n=e).type||"submit"===n.type)&&n.value||"":function(e,t){let n="",i="";return e.textContent?n=w(e.textContent):e.innerText&&(n=w(e.innerText)),n&&(n=n.replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)),i=n||"","input"!==t&&"INPUT"!==t||(i=e.value||""),i}(e,t);var n}(e,n),i.$element_selector=Oe(e),i.$element_path=function(e){let t=[];for(;e.parentNode&&u(e);){if(!o(e.tagName))return"unknown";if(e.id&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.id)){t.unshift(e.tagName.toLowerCase()+"#"+e.id);break}if(e===document.body){t.unshift("body");break}t.unshift(e.tagName.toLowerCase()),e=e.parentNode}return t.join(" > ")}(e),i.$url_path=location.pathname,i.$title=document.title;const s=function(e,t){const n=t.pageX||t.clientX+Ae().scrollLeft||t.offsetX+_e(e).targetEleX,i=t.pageY||t.clientY+Ae().scrollTop||t.offsetY+_e(e).targetEleY;return{$page_x:ve(n),$page_y:ve(i)}}(e,t);return i.$page_x=s.$page_x,i.$page_y=s.$page_y,i}function Oe(e,t=[]){if(!(e&&e.parentNode&&e.parentNode.children&&o(e.tagName)))return"unknown";t=Array.isArray(t)?t:[];const n=e.nodeName.toLowerCase();return e&&"body"!==n&&1==e.nodeType?(t.unshift(function(e){if(!e||!u(e)||!o(e.tagName))return"";let t=e.parentNode&&9==e.parentNode.nodeType?-1:function(e){if(!e.parentNode)return-1;let t=0;const n=e.tagName,i=e.parentNode.children;for(let s=0,r=i.length;s<r;s++)if(i[s].tagName===n){if(e===i[s])return t;t++}return-1}(e);return e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?"#"+e.getAttribute("id"):e.tagName.toLowerCase()+(~t?":nth-of-type("+(t+1)+")":"")}(e)),e.getAttribute&&e.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e.getAttribute("id"))?t.join(" > "):Oe(e.parentNode,t)):(t.unshift("body"),t.join(" > "))}function Ae(){return{scrollLeft:document.body.scrollLeft||document.documentElement.scrollLeft||0,scrollTop:document.body.scrollTop||document.documentElement.scrollTop||0}}function _e(e){if(document.documentElement.getBoundingClientRect){const t=e.getBoundingClientRect();return{targetEleX:t.left+Ae().scrollLeft||0,targetEleY:t.top+Ae().scrollTop||0}}return{targetEleX:0,targetEleY:0}}function ve(e){return Number(Number(e).toFixed(3))}const Re=class{constructor({emitter:e,config:t}){this.isInitialized=!1,this.boundHandleClick=null,this.emitter=e,this.config=t}init(){this.isInitialized||(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,!0),this.isInitialized=!0)}handleClick(e){const t=e.target;if(!t)return;if(!["A","INPUT","BUTTON","TEXTAREA"].includes(t.tagName))return;if("true"===t.getAttribute("sol-disable"))return;le({event:"$WebClick",properties:we(t,e)||{}},this.config)}destroy(){this.boundHandleClick&&(document.removeEventListener("click",this.boundHandleClick,!0),this.boundHandleClick=null),this.isInitialized=!1}};Re.NAME="webclick";let be=Re;const Ne=class{constructor({emitter:e,config:t}){this.updateInterval=null,this.fetchingPromise=null,this.emitter=e,this.config=t}init(){const e=this.config;e.enableAB&&(this.fastFetch().then(()=>{this.emitter.emit(R)}),e.abRefreshInterval<3e4&&(e.abRefreshInterval=3e4),this.updateInterval=setInterval(()=>{this.fetchNewData().catch(console.warn)},e.abRefreshInterval))}async fastFetch(){const e=y.getABData();return e&&e.length?(this.emitter.emit(R),Promise.resolve(e)):this.fetchNewData()}async fetchNewData(){return this.fetchingPromise||(this.fetchingPromise=new Promise(e=>{!function({opts:e,cb:t}){const n=y.getLoginId(),i=y.getAnonId();if(!n||!i)return;const s={user:{login_id:n,anon_id:i,props:{...Q(),...y.getCommonProps()}},sdk:"webjs",sdk_version:A};L({url:re(e),method:"POST",data:s,headers:oe(e),callback:e=>{200!==e.statusCode?console.error("Failed to fetch feature flags"):t&&t(e.json)}})}({opts:this.config,cb:t=>{y.saveABData(t.data?.results||[]),e(t),this.fetchingPromise=null}})})),this.fetchingPromise}async getFeatureGate(e){return await this.fastFetch().catch(console.warn),y.getABData().find(t=>t.typ===N.FEATURE_GATE&&t.key==e)}async checkFeatureGate(e){const t=await this.getFeatureGate(e);return!!t&&("fail"===t.vid?(de({isHit:!1,data:t,opts:this.config}),!1):(de({isHit:!0,data:t,opts:this.config}),!0))}async getExperiment(e){await this.fastFetch().catch(console.warn);const t=y.getABData().find(t=>t.typ===N.EXPERIMENT&&t.key===e);return t?t?.vid?(de({isHit:!0,data:t,opts:this.config}),t?.value||{}):(de({isHit:!1,data:t,opts:this.config}),{}):{}}destroy(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null),this.fetchingPromise=null}};Ne.NAME="abtest";let Te=Ne;const ye=[],Pe={debug:!1,apiToken:"",apiHost:"",autoCapture:!0,isSinglePageApp:!1,crossSubdomainCookie:!0,enableAB:!1,abRefreshInterval:T,enableClickTrack:!1,batchSend:!0};return new class{constructor(){this.__loaded=!1,this.config={},this.eventEmitter=new e,this.pluginCore={},this.commonProps={},this.spaCleanup=null,O.instance=this}init(e,t={}){t.apiToken=e,this.mergeConfig(t),this.eventEmitter.emit("init-param",this.config);const n=this.config;return y.init(n.crossSubdomainCookie),this.__loaded=!0,window._solFailedRequestsInitialized||(window._solFailedRequestsInitialized=!0,function(){const e=V.getAll();0!==e.length&&e.forEach(e=>{ie(e.url,{data:e.data,headers:e.headers},e.id)})}()),n.autoCapture&&this.autoTrack(),n.enableAB&&ye.push(Te),n.enableClickTrack&&ye.push(be),this.pluginCore=new ge({plugins:ye,emitter:this.eventEmitter,config:n}),this.spaCleanup=function(e){let t=location.href;const n=window.history.pushState,i=window.history.replaceState,r=function(){e(t),t=location.href};return s(window.history.pushState)&&(window.history.pushState=function(...i){n.apply(window.history,i),e(t),t=location.href}),s(window.history.replaceState)&&(window.history.replaceState=function(...n){i.apply(window.history,n),e(t),t=location.href}),window.addEventListener("popstate",r),function(){s(window.history.pushState)&&(window.history.pushState=n),s(window.history.replaceState)&&(window.history.replaceState=i),window.removeEventListener("popstate",r)}}(e=>{this.eventEmitter.emit(v,e)}),this.eventEmitter.emit(_),this}mergeConfig(e){this.config={...Pe,...e}}track(e){!function(e,t){const n={...e};n.time||(n.time=Date.now()),n.login_id||(n.login_id=y.getLoginId()),n.anon_id||(n.anon_id=y.getAnonId()),n.properties={...Q(),...y.getCommonProps(),...n.properties},ae(se(t),{data:[n],headers:oe(t)})}(e,this.config)}trackEvent(e,t){le({event:e,properties:{...t,...this.commonProps}},this.config)}autoTrack(){ye.push(fe,Se,Ee)}profileSet(e){ce({userProps:{$set:e},opts:this.config})}profileSetOnce(e){ce({userProps:{$set_once:e},opts:this.config})}profileIncrement(e){ce({userProps:{$increment:e},opts:this.config})}profileAppend(e){ce({userProps:{$append:e},opts:this.config})}profileUnion(e){ce({userProps:{$union:e},opts:this.config})}profileUnset(e){const t={};r(e)?e.forEach(function(e){t[e]=null}):t[e]=null,ce({userProps:{$unset:t},opts:this.config})}profileDelete(){ce({userProps:{$delete:!0},opts:this.config})}registerCommonProperties(e){if(!i(e))return console.warn("Commmon Properties must be an object!");this.commonProps=e,y.setCommonProps(this.commonProps)}clearCommonProperties(e){if(!r(e))return console.warn("Commmon Properties to be cleared must be an array!");e.forEach(e=>{delete this.commonProps[e]}),y.setCommonProps(this.commonProps)}identify(e){y.setLoginId(e),function(e){const t=y.getLoginId(),n=y.getAnonId();if(!t||!n)return;const i={time:Date.now(),trace_id:y.getTraceId(),event:"$Identify",login_id:t,anon_id:n};ae(se(e),{data:[i],headers:oe(e)})}(this.config)}setLoginId(e){y.setLoginId(e)}getAnonId(){return y.getAnonId()}getLoginId(){return y.getLoginId()}checkFeatureGate(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.checkFeatureGate(e):Promise.reject("AB is disabled")}getExperiment(e){const t=this.pluginCore.getPlugin(Te.NAME);return this.config.enableAB&&t?t.getExperiment(e):Promise.reject("AB is disabled")}destroy(){ne&&(ne.destroy(),ne=null),this.spaCleanup&&"function"==typeof this.spaCleanup&&(this.spaCleanup(),this.spaCleanup=null),this.pluginCore&&"function"==typeof this.pluginCore.destroy&&this.pluginCore.destroy(),this.eventEmitter&&this.eventEmitter.removeAllListeners(),O.instance===this&&(O.instance=null)}}});
@@ -24,6 +24,7 @@ type ABData = {
24
24
  typ: number;
25
25
  vid?: string;
26
26
  value?: Record<string, any>;
27
+ disable_impress?: boolean;
27
28
  }
28
29
  type SolABRequestData = {
29
30
  user: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@sensorswave/js-sdk",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
5
5
  "description": "Sensors Wave JS SDK for web analytics",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",