lucia-sdk 0.9.13 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/features/web3/eip6963.test.d.ts +1 -0
- package/dist/core/index.d.ts +47 -6
- package/dist/features/fingerprinting/browser-data.d.ts +1 -8
- package/dist/features/fingerprinting/index.d.ts +1 -1
- package/dist/features/web3/eip6963.d.ts +72 -0
- package/dist/features/web3/evm.d.ts +4 -65
- package/dist/features/web3/index.d.ts +6 -3
- package/dist/features/web3/provider-registry.d.ts +26 -0
- package/dist/features/web3/solana.d.ts +4 -53
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json +7 -6
- package/dist/types.d.ts +15 -40
- package/dist/umd/lucia-sdk-0.10.1.min.js +1 -0
- package/dist/umd/lucia-sdk-latest.min.js +1 -1
- package/package.json +7 -6
- package/dist/umd/lucia-sdk-0.9.13.min.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import BaseClass from '../base';
|
|
2
|
-
import { ClickEventMetadata } from '../types';
|
|
2
|
+
import { ClickEventMetadata, WalletInfoOptions } from '../types';
|
|
3
3
|
declare class LuciaSDK extends BaseClass {
|
|
4
|
+
/** Addresses already sent this session — avoids redundant POSTs */
|
|
5
|
+
private sentWallets;
|
|
6
|
+
/** Stored listener references for cleanup */
|
|
7
|
+
private walletListenerCleanups;
|
|
4
8
|
authenticate(): void;
|
|
5
9
|
/**
|
|
6
10
|
* Initializes the SDK with the provided configuration
|
|
@@ -10,6 +14,38 @@ declare class LuciaSDK extends BaseClass {
|
|
|
10
14
|
* Handle automatically tracked click events
|
|
11
15
|
*/
|
|
12
16
|
private handleAutoTrackedClick;
|
|
17
|
+
/**
|
|
18
|
+
* Auto-detect already-connected wallets and send them to the backend.
|
|
19
|
+
* Runs after init so lid and session hash are available.
|
|
20
|
+
* Each chain is independent — one failing must not block the other.
|
|
21
|
+
*
|
|
22
|
+
* EIP-6963 is the PRIMARY path for EVM wallets. The legacy
|
|
23
|
+
* window.ethereum.selectedAddress check is the FALLBACK for wallets
|
|
24
|
+
* that don't support EIP-6963.
|
|
25
|
+
*/
|
|
26
|
+
private autoDetectWallets;
|
|
27
|
+
/**
|
|
28
|
+
* Set up event listeners for wallet connection changes.
|
|
29
|
+
* EVM: per-provider accountsChanged via EIP-6963 (preferred), or
|
|
30
|
+
* window.ethereum accountsChanged as fallback.
|
|
31
|
+
* Solana: connect fires when wallet connects.
|
|
32
|
+
*/
|
|
33
|
+
private setupWalletListeners;
|
|
34
|
+
/**
|
|
35
|
+
* Attach accountsChanged listeners to each EIP-6963 provider that
|
|
36
|
+
* returned accounts. The provider name is known from the EIP-6963 info,
|
|
37
|
+
* so attribution is guaranteed correct.
|
|
38
|
+
*/
|
|
39
|
+
private setupEIP6963AccountListeners;
|
|
40
|
+
/**
|
|
41
|
+
* Handle a late-arriving EIP-6963 provider: check for connected accounts
|
|
42
|
+
* and attach accountsChanged.
|
|
43
|
+
*/
|
|
44
|
+
private handleLateEIP6963Provider;
|
|
45
|
+
/**
|
|
46
|
+
* Attach an accountsChanged listener to a single EIP-6963 provider.
|
|
47
|
+
*/
|
|
48
|
+
private attachEIP6963AccountsChanged;
|
|
13
49
|
/**
|
|
14
50
|
* Sends user information to the server
|
|
15
51
|
* @param userId The user's ID, e.g. email, wallet address, etc.
|
|
@@ -35,12 +71,17 @@ declare class LuciaSDK extends BaseClass {
|
|
|
35
71
|
*/
|
|
36
72
|
buttonClick(button: string, metadata?: ClickEventMetadata): Promise<void>;
|
|
37
73
|
/**
|
|
38
|
-
* Sends wallet information to the server
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
74
|
+
* Sends wallet information to the server. Thin pipe — no validation or classification.
|
|
75
|
+
*
|
|
76
|
+
* Supports both new and old calling patterns:
|
|
77
|
+
* New: sendWalletInfo(address, { provider, connectorType, chainId })
|
|
78
|
+
* Old: sendWalletInfo(address, chainId, walletName)
|
|
79
|
+
*
|
|
80
|
+
* @param walletAddress The wallet address
|
|
81
|
+
* @param optionsOrChainId Options object or legacy chainId
|
|
82
|
+
* @param walletName Legacy wallet name (mapped to provider)
|
|
42
83
|
*/
|
|
43
|
-
sendWalletInfo(walletAddress: string,
|
|
84
|
+
sendWalletInfo(walletAddress: string, optionsOrChainId?: WalletInfoOptions | number | string, walletName?: string): Promise<void>;
|
|
44
85
|
/**
|
|
45
86
|
* Track a user acquisition event when a user signs up or logs in
|
|
46
87
|
* @param userId - Unique identifier for the user
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrowserData
|
|
1
|
+
import { BrowserData } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Collects static browser and hardware data that's unlikely to change during a session.
|
|
4
4
|
* This data can be cached for performance optimization.
|
|
@@ -11,13 +11,6 @@ export declare function getBrowserData(): Promise<BrowserData>;
|
|
|
11
11
|
* Clears the browser data cache (useful for testing)
|
|
12
12
|
*/
|
|
13
13
|
export declare function clearBrowserDataCache(): void;
|
|
14
|
-
/**
|
|
15
|
-
* Collects dynamic wallet information that may change during a session.
|
|
16
|
-
* This data should be fetched each time it's needed for up-to-date values.
|
|
17
|
-
*
|
|
18
|
-
* @returns {Promise<WalletData>} Dynamic wallet data including addresses and provider information.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getWalletData(): Promise<WalletData>;
|
|
21
14
|
/**
|
|
22
15
|
* Extracts tracking parameters from the current URL.
|
|
23
16
|
* Captures UTM parameters, ID-related values, and referrer information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getBrowserData, clearBrowserDataCache,
|
|
1
|
+
export { getBrowserData, clearBrowserDataCache, getUtmParams, safeAccess, filterObject, getCanvasFingerprint, isTouchEnabled, getApplePayAvailable, getContrastPreference, getColorGamut, } from './browser-data';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EIP-6963: Multi Injected Provider Discovery
|
|
3
|
+
*
|
|
4
|
+
* Each EVM wallet announces itself via a browser CustomEvent with its name
|
|
5
|
+
* and a separate provider object. We call eth_accounts on each provider to
|
|
6
|
+
* find which one holds the connected address — guaranteed correct attribution.
|
|
7
|
+
*
|
|
8
|
+
* This is the PRIMARY EVM detection path. The flag-based registry in evm.ts
|
|
9
|
+
* is the FALLBACK for wallets that don't support EIP-6963.
|
|
10
|
+
*/
|
|
11
|
+
export interface EIP6963ProviderInfo {
|
|
12
|
+
uuid: string;
|
|
13
|
+
name: string;
|
|
14
|
+
icon: string;
|
|
15
|
+
rdns: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EIP6963ProviderDetail {
|
|
18
|
+
info: EIP6963ProviderInfo;
|
|
19
|
+
provider: EIP1193Provider;
|
|
20
|
+
}
|
|
21
|
+
export interface EIP6963AnnounceEvent extends CustomEvent {
|
|
22
|
+
detail: EIP6963ProviderDetail;
|
|
23
|
+
}
|
|
24
|
+
export interface EIP6963ConnectedWallet {
|
|
25
|
+
address: string;
|
|
26
|
+
providerName: string;
|
|
27
|
+
providerRdns: string;
|
|
28
|
+
provider: EIP1193Provider;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Start listening for EIP-6963 provider announcements, then request them.
|
|
32
|
+
* Idempotent — calling multiple times is a no-op.
|
|
33
|
+
*/
|
|
34
|
+
export declare function startEIP6963Discovery(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Stop listening for EIP-6963 announcements and clear state.
|
|
37
|
+
* Called from LuciaSDK.destroy() to properly clean up.
|
|
38
|
+
*/
|
|
39
|
+
export declare function stopEIP6963Discovery(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Snapshot of all discovered providers.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getEIP6963Providers(): Map<string, EIP6963ProviderDetail>;
|
|
44
|
+
/**
|
|
45
|
+
* For each discovered provider, call eth_accounts (silent, no popup) and
|
|
46
|
+
* return every connected address with its provider name.
|
|
47
|
+
*
|
|
48
|
+
* Uses Promise.allSettled with a 3-second timeout per provider so one
|
|
49
|
+
* slow/broken extension can't block the others.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getEIP6963ConnectedWallets(): Promise<EIP6963ConnectedWallet[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Given an address, query all discovered EIP-6963 providers to find which one
|
|
54
|
+
* currently holds it. Returns the provider name, or null if no match.
|
|
55
|
+
*
|
|
56
|
+
* Used by the legacy window.ethereum accountsChanged handler to get correct
|
|
57
|
+
* attribution even when the event fires on the global rather than the
|
|
58
|
+
* individual provider object.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveEIP6963ProviderByAddress(address: string): Promise<{
|
|
61
|
+
name: string;
|
|
62
|
+
rdns: string;
|
|
63
|
+
} | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribe to late-arriving provider announcements.
|
|
66
|
+
* Returns a cleanup function to remove the listener.
|
|
67
|
+
*/
|
|
68
|
+
export declare function onEIP6963Announce(callback: (detail: EIP6963ProviderDetail) => void): () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Test helper: clears all module state so tests start clean.
|
|
71
|
+
*/
|
|
72
|
+
export declare function __resetEIP6963(): void;
|
|
@@ -1,69 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @returns boolean indicating if an Ethereum provider exists
|
|
2
|
+
* EVM provider detection — delegates to the provider registry.
|
|
4
3
|
*/
|
|
5
|
-
export declare function checkIfEthereumProviderExists(): boolean;
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @returns
|
|
5
|
+
* Detects the name of the EVM wallet provider from window.ethereum flags.
|
|
6
|
+
* @returns The provider name (e.g. 'MetaMask', 'Rabby') or null if unknown/absent
|
|
9
7
|
*/
|
|
10
|
-
export declare function
|
|
11
|
-
/**
|
|
12
|
-
* Formats an Ethereum address for display by shortening it
|
|
13
|
-
* @param address The full Ethereum address
|
|
14
|
-
* @returns Shortened address in the format "0x1234...5678"
|
|
15
|
-
*/
|
|
16
|
-
export declare function formatEthereumAddress(address: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Sets up listeners for Ethereum account changes
|
|
19
|
-
* @param callback Function to call when accounts change
|
|
20
|
-
*/
|
|
21
|
-
export declare function setupEthereumAccountListeners(callback: (accounts: string[]) => void): void;
|
|
22
|
-
/**
|
|
23
|
-
* Gets the current Ethereum chain ID
|
|
24
|
-
* @returns Promise resolving to the chain ID or null if not available
|
|
25
|
-
*/
|
|
26
|
-
export declare function getEthereumChainId(): Promise<string | null>;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if a wallet is connected and returns the address if it is
|
|
29
|
-
* @returns Promise resolving to the connected address or null
|
|
30
|
-
*/
|
|
31
|
-
export declare function getConnectedWalletAddress(): Promise<string | null>;
|
|
32
|
-
/**
|
|
33
|
-
* Checks if the connected wallet is MetaMask
|
|
34
|
-
* @returns boolean indicating if the connected wallet is MetaMask
|
|
35
|
-
*/
|
|
36
|
-
export declare function isMetaMask(): Promise<boolean>;
|
|
37
|
-
/**
|
|
38
|
-
* Gets the name of the connected wallet
|
|
39
|
-
* @returns Promise resolving to the name of the connected wallet, or null if not available
|
|
40
|
-
*/
|
|
41
|
-
export declare function getWalletName(): Promise<string | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Provider information interface
|
|
44
|
-
*/
|
|
45
|
-
export interface ProviderInfo {
|
|
46
|
-
isMetaMask: boolean;
|
|
47
|
-
isCoinbaseWallet: boolean;
|
|
48
|
-
isWalletConnect: boolean;
|
|
49
|
-
isTrust: boolean;
|
|
50
|
-
isImToken: boolean;
|
|
51
|
-
isBraveWallet: boolean;
|
|
52
|
-
isTokenPocket: boolean;
|
|
53
|
-
isStatus: boolean;
|
|
54
|
-
isTally: boolean;
|
|
55
|
-
isAlphaWallet: boolean;
|
|
56
|
-
isOpera: boolean;
|
|
57
|
-
isCoin98: boolean;
|
|
58
|
-
isMathWallet: boolean;
|
|
59
|
-
isOneInch: boolean;
|
|
60
|
-
isRainbow: boolean;
|
|
61
|
-
isBinanceChainWallet: boolean;
|
|
62
|
-
isFrame: boolean;
|
|
63
|
-
userAgent: string;
|
|
64
|
-
chainId?: string;
|
|
65
|
-
networkVersion?: string;
|
|
66
|
-
name: string;
|
|
67
|
-
isPossiblyGenericInjectedProvider?: boolean;
|
|
68
|
-
}
|
|
69
|
-
export declare function getExtendedProviderInfo(): Promise<ProviderInfo | null>;
|
|
8
|
+
export declare function detectEvmProvider(): string | null;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
1
|
+
export { detectEvmProvider } from './evm';
|
|
2
|
+
export { detectSolanaProvider } from './solana';
|
|
3
|
+
export { EVM_PROVIDERS, SOLANA_PROVIDERS } from './provider-registry';
|
|
4
|
+
export type { ProviderEntry } from './provider-registry';
|
|
5
|
+
export { startEIP6963Discovery, getEIP6963Providers, getEIP6963ConnectedWallets, resolveEIP6963ProviderByAddress, onEIP6963Announce, __resetEIP6963, } from './eip6963';
|
|
6
|
+
export type { EIP6963ProviderInfo, EIP6963ProviderDetail, EIP6963AnnounceEvent, EIP6963ConnectedWallet, } from './eip6963';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet Provider Registry
|
|
3
|
+
*
|
|
4
|
+
* Centralized, ordered list of wallet provider detections.
|
|
5
|
+
* Adding a wallet = adding one entry to the appropriate array.
|
|
6
|
+
*
|
|
7
|
+
* ORDER MATTERS for EVM: wallets that set `isMetaMask: true` for dapp
|
|
8
|
+
* compatibility must appear BEFORE the MetaMask entry. The first match wins.
|
|
9
|
+
*/
|
|
10
|
+
export interface ProviderEntry {
|
|
11
|
+
name: string;
|
|
12
|
+
detect: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* EVM wallet providers, checked against window.ethereum flags.
|
|
16
|
+
*
|
|
17
|
+
* Section 1: Wallets that also set isMetaMask (must come first)
|
|
18
|
+
* Section 2: MetaMask itself
|
|
19
|
+
* Section 3: Wallets that don't set isMetaMask
|
|
20
|
+
* Section 4: Fallback checks (window globals, internal properties)
|
|
21
|
+
*/
|
|
22
|
+
export declare const EVM_PROVIDERS: ProviderEntry[];
|
|
23
|
+
/**
|
|
24
|
+
* Solana wallet providers, checked against window globals.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SOLANA_PROVIDERS: ProviderEntry[];
|
|
@@ -1,57 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Solana provider detection — delegates to the provider registry.
|
|
3
3
|
*/
|
|
4
|
-
interface SolanaProvider {
|
|
5
|
-
isPhantom?: boolean;
|
|
6
|
-
isConnected: boolean;
|
|
7
|
-
publicKey: {
|
|
8
|
-
toString: () => string;
|
|
9
|
-
};
|
|
10
|
-
connect: (options?: {
|
|
11
|
-
onlyIfTrusted?: boolean;
|
|
12
|
-
}) => Promise<{
|
|
13
|
-
publicKey?: {
|
|
14
|
-
toString: () => string;
|
|
15
|
-
};
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
18
|
-
interface SolflareProvider {
|
|
19
|
-
isConnected: boolean;
|
|
20
|
-
publicKey: {
|
|
21
|
-
toString: () => string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
interface WalletAdapter {
|
|
25
|
-
connected: boolean;
|
|
26
|
-
publicKey: {
|
|
27
|
-
toString: () => string;
|
|
28
|
-
};
|
|
29
|
-
name?: string;
|
|
30
|
-
}
|
|
31
|
-
interface PhantomProvider {
|
|
32
|
-
solana?: SolanaProvider;
|
|
33
|
-
}
|
|
34
|
-
declare global {
|
|
35
|
-
interface Window {
|
|
36
|
-
solana?: SolanaProvider;
|
|
37
|
-
solflare?: SolflareProvider;
|
|
38
|
-
phantom?: PhantomProvider;
|
|
39
|
-
walletAdapterNetwork?: {
|
|
40
|
-
adapters: WalletAdapter[];
|
|
41
|
-
};
|
|
42
|
-
SolanaWalletAdapterContext?: {
|
|
43
|
-
current: WalletAdapter;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
4
|
/**
|
|
48
|
-
*
|
|
49
|
-
* @returns
|
|
5
|
+
* Detects the name of the Solana wallet provider from window globals.
|
|
6
|
+
* @returns The provider name (e.g. 'Phantom') or null if unknown/absent
|
|
50
7
|
*/
|
|
51
|
-
export declare function
|
|
52
|
-
/**
|
|
53
|
-
* Get the name of the connected Solana wallet
|
|
54
|
-
* @returns Promise that resolves to the name of the wallet or null if none found
|
|
55
|
-
*/
|
|
56
|
-
export declare function getSolanaWalletName(): Promise<string | null>;
|
|
57
|
-
export {};
|
|
8
|
+
export declare function detectSolanaProvider(): string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SDK } from './types';
|
|
2
|
-
export { getBrowserData,
|
|
2
|
+
export { getBrowserData, getUtmParams, safeAccess, filterObject, getCanvasFingerprint, isTouchEnabled, getApplePayAvailable, getContrastPreference, getColorGamut, } from './features/fingerprinting';
|
|
3
|
+
export { detectEvmProvider, detectSolanaProvider } from './features/web3';
|
|
3
4
|
export declare const __resetInstance: () => void;
|
|
4
5
|
declare const LuciaSDK: SDK;
|
|
5
6
|
export default LuciaSDK;
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const n="0.9.13";class i{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new t(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(t){return e(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const e=yield fetch(`${this.baseURL}${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n}});return yield e.json()}catch(e){this.logger.log("error",e)}return null})}post(t,n){return e(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return e(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const t=()=>e(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const e=this.requestQueue.shift();try{const t=yield this.executePost(e.url,e.data,e.fireAndForget);e.resolve(t)}catch(t){e.reject(t)}yield t()});yield t()}finally{this.isProcessingQueue=!1}}})}executePost(t,i){return e(this,arguments,void 0,function*(e,t,i=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const i=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n},body:JSON.stringify(t)});return yield i.json()}catch(e){this.logger.log("error",e)}return null})}}class r{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(r.store).includes(t)){const n=e[t];r.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}r.store={isInitialized:!1,config:null,session:null};const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));let s;const a=new Uint8Array(16);var l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!s){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");s=crypto.getRandomValues.bind(crypto)}return s(a)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(i)}const u="luci_session",d=new t(r.store);function h(){try{const e=sessionStorage.getItem(u);return e?JSON.parse(e):null}catch(e){return d.log("error","Error retrieving session data:",e),null}}function g(){var e;const t={id:l.randomUUID&&!e?l.randomUUID():c(e),timestamp:Date.now()};return sessionStorage.setItem(u,JSON.stringify(t)),t}function f(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function w(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class m{constructor(e){this.store=r.store,this.dispatch=r.dispatch,this.dispatch({config:e}),this.httpClient=new i(this.store),this.logger=new t(this.store)}}class p{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const y=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},v=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],b=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const k=new class{constructor(e=[]){this.sensitiveSelectors=[...v,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&b.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},C=["button","a[href]",'[role="button"]'],T=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class A extends p{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:C,ignore:null!==(s=t.ignore)&&void 0!==s?s:T},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=k}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||C;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==C){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||C).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const S={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new A(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},I=new t(r.store);function P(){return e(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return I.log("error","Error checking connected wallet:",e),null}})}function E(){return e(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return I.log("error","Error getting wallet name:",e),null}})}function O(){return e(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const x=new t(r.store);function W(){return e(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){x.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return x.log("error","Error detecting Solana wallet:",e),null}})}function j(){return e(this,void 0,void 0,function*(){var e,t,n;const i=yield W();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function D(){return e(this,void 0,void 0,function*(){if(K)return K;const e={device:{cores:U(()=>navigator.hardwareConcurrency),memory:U(()=>navigator.deviceMemory),cpuClass:U(()=>navigator.cpuClass),touch:N(),devicePixelRatio:U(()=>window.devicePixelRatio)},screen:{width:U(()=>window.screen.width),height:U(()=>window.screen.height),colorDepth:U(()=>window.screen.colorDepth),availHeight:U(()=>window.screen.availHeight),availWidth:U(()=>window.screen.availWidth),orientation:{type:U(()=>window.screen.orientation.type),angle:U(()=>window.screen.orientation.angle)}},browser:{language:U(()=>navigator.language),encoding:U(()=>TextDecoder.encoding),timezone:U(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:U(()=>navigator.plugins.length),pluginNames:U(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:_(),uniqueHash:yield $(),colorGamut:B(),contrastPreference:q()},permissions:{navPer:U(()=>navigator.permissions.webglVersion),renderedPer:U(()=>navigator.permissions.RENDERER),geoPer:U(()=>navigator.permissions.geolocation)},storage:{localStorage:U(()=>!!window.localStorage),indexedDB:U(()=>!!window.indexedDB),openDB:U(()=>window.openDatabase)}};return K=e,e})}function R(){return e(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([W(),P(),E(),j(),O()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&L(r),walletName:n,solWalletName:i}})}function M(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function U(e,t){try{return e()}catch(e){return t}}function L(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let K=null;function $(){return e(this,void 0,void 0,function*(){try{const t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;t.width=i,t.height=r,t.style.width=`${i}px`,t.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(t){return e(this,void 0,void 0,function*(){const e=(new TextEncoder).encode(t),n=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function N(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function _(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function q(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function B(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}y.register(S);let z=class extends m{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return e(this,void 0,void 0,function*(){let e=h();e||(e=g());const t=yield D(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield R(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:w()},data:t,walletData:i,session:r,redirectHash:n,utm:M()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(u,JSON.stringify(t))}(o.session)),y.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h();t&&localStorage.setItem("luc_uid",t);const r=Object.assign({user:{name:t,userInfo:n},session:i},e&&{lid:e});yield this.httpClient.post("/api/sdk/user",r)})}pageView(t){return e(this,void 0,void 0,function*(){const e=f(),n=h(),i=Object.assign({page:t,user:{name:w()},session:n},e&&{lid:e});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({tag:t,amount:n,event:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h(),r=Object.assign(Object.assign({button:t,user:{name:w()},session:i},e&&{lid:e}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({walletAddress:t,chainId:n,walletName:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(t){return e(this,arguments,void 0,function*(e,t={}){const n=yield D(),i=M(),r=h();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){y.destroyAll()}},V=null;const Q=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},F=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),V=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,y.reset()},H={init:t=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(V)return V;if(window.__luciaInitPromise)return V=window.__luciaInitPromise,V;if(!(null==t?void 0:t.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=e(void 0,void 0,void 0,function*(){const e=new z(t);return yield e.init(),e});return V=n,window.__luciaInitPromise=n,n},userInfo:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(t,n)}),pageView:t=>e(void 0,void 0,void 0,function*(){return(yield Q()).pageView(t)}),trackConversion:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(t,n,i)}),buttonClick:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(t,n)}),sendWalletInfo:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(t,n,i)}),trackUserAcquisition:(t,...n)=>e(void 0,[t,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:n};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}export{F as __resetInstance,H as default,L as filterObject,_ as getApplePayAvailable,D as getBrowserData,$ as getCanvasFingerprint,B as getColorGamut,q as getContrastPreference,M as getUtmParams,R as getWalletData,N as isTouchEnabled,U as safeAccess};
|
|
1
|
+
function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const n="0.10.1";class i{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new t(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(t){return e(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const e=yield fetch(`${this.baseURL}${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n}});return yield e.json()}catch(e){this.logger.log("error",e)}return null})}post(t,n){return e(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return e(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const t=()=>e(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const e=this.requestQueue.shift();try{const t=yield this.executePost(e.url,e.data,e.fireAndForget);e.resolve(t)}catch(t){e.reject(t)}yield t()});yield t()}finally{this.isProcessingQueue=!1}}})}executePost(t,i){return e(this,arguments,void 0,function*(e,t,i=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const i=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n},body:JSON.stringify(t)});return yield i.json()}catch(e){this.logger.log("error",e)}return null})}}class r{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(r.store).includes(t)){const n=e[t];r.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}r.store={isInitialized:!1,config:null,session:null};const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));let s;const a=new Uint8Array(16);var l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!s){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");s=crypto.getRandomValues.bind(crypto)}return s(a)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(i)}const d="luci_session",u=new t(r.store);function h(){try{const e=sessionStorage.getItem(d);return e?JSON.parse(e):null}catch(e){return u.log("error","Error retrieving session data:",e),null}}function v(){var e;const t={id:l.randomUUID&&!e?l.randomUUID():c(e),timestamp:Date.now()};return sessionStorage.setItem(d,JSON.stringify(t)),t}function g(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function f(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class m{constructor(e){this.store=r.store,this.dispatch=r.dispatch,this.dispatch({config:e}),this.httpClient=new i(this.store),this.logger=new t(this.store)}}class p{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const w=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},y=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],b=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const k=new class{constructor(e=[]){this.sensitiveSelectors=[...y,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&b.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},C=["button","a[href]",'[role="button"]'],T=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class A extends p{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:C,ignore:null!==(s=t.ignore)&&void 0!==s?s:T},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=k}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||C;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==C){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||C).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const I={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new A(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}};function P(){return e(this,void 0,void 0,function*(){if(O)return O;const e={device:{cores:E(()=>navigator.hardwareConcurrency),memory:E(()=>navigator.deviceMemory),cpuClass:E(()=>navigator.cpuClass),touch:j(),devicePixelRatio:E(()=>window.devicePixelRatio)},screen:{width:E(()=>window.screen.width),height:E(()=>window.screen.height),colorDepth:E(()=>window.screen.colorDepth),availHeight:E(()=>window.screen.availHeight),availWidth:E(()=>window.screen.availWidth),orientation:{type:E(()=>window.screen.orientation.type),angle:E(()=>window.screen.orientation.angle)}},browser:{language:E(()=>navigator.language),encoding:E(()=>TextDecoder.encoding),timezone:E(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:E(()=>navigator.plugins.length),pluginNames:E(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:W(),uniqueHash:yield D(),colorGamut:R(),contrastPreference:x()},permissions:{navPer:E(()=>navigator.permissions.webglVersion),renderedPer:E(()=>navigator.permissions.RENDERER),geoPer:E(()=>navigator.permissions.geolocation)},storage:{localStorage:E(()=>!!window.localStorage),indexedDB:E(()=>!!window.indexedDB),openDB:E(()=>window.openDatabase)}};return O=e,e})}function S(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function E(e,t){try{return e()}catch(e){return t}}function L(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let O=null;function D(){return e(this,void 0,void 0,function*(){try{const t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;t.width=i,t.height=r,t.style.width=`${i}px`,t.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(t){return e(this,void 0,void 0,function*(){const e=(new TextEncoder).encode(t),n=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function j(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function W(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function x(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function R(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}const $=new Map;let U=null,M=!1;function K(){return new Map($)}const _=[{name:"Rabby",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRabby)}},{name:"Brave Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBraveWallet)}},{name:"Rainbow",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRainbow)}},{name:"Coinbase Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoinbaseWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCoinbase)}},{name:"Trust Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTrust)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTrustWallet)}},{name:"TokenPocket",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTokenPocket)}},{name:"Zerion",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isZerion)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isPhantom)}},{name:"OKX Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOkxWallet)}},{name:"Bitget Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBitKeep)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isBitgetWallet)}},{name:"SafePal",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isSafePal)}},{name:"Frontier",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrontier)}},{name:"XDEFI",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isXDEFI)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCtrl)}},{name:"Enkrypt",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isEnkrypt)}},{name:"MetaMask",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}},{name:"WalletConnect",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isWalletConnect)}},{name:"imToken",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isImToken)}},{name:"Status",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isStatus)}},{name:"Tally",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTally)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTallyWallet)}},{name:"AlphaWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isAlphaWallet)}},{name:"Opera",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOpera)}},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoin98)}},{name:"MathWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMathWallet)}},{name:"1inch Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOneInchIOSWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isOneInchAndroidWallet)}},{name:"Frame",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrame)}},{name:"Binance Chain Wallet",detect:()=>!!window.BinanceChain},{name:"MetaMask",detect:()=>{var e;return Object.prototype.hasOwnProperty.call(null!==(e=window.ethereum)&&void 0!==e?e:{},"_metamask")}}],N=[{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.phantom)||void 0===e?void 0:e.solana)}},{name:"Solflare",detect:()=>!!window.solflare},{name:"Backpack",detect:()=>!!window.backpack},{name:"Glow",detect:()=>!!window.glow},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isCoin98)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isPhantom)}}];function q(){var e,t;return window.ethereum&&null!==(t=null===(e=_.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}function z(){var e,t;return null!==(t=null===(e=N.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}w.register(I);let B=class extends m{constructor(){super(...arguments),this.sentWallets=new Set,this.walletListenerCleanups=[]}authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return e(this,void 0,void 0,function*(){let e=h();e||(e=v());try{M||(M=!0,U=e=>{var t;const n=e.detail;(null===(t=null==n?void 0:n.info)||void 0===t?void 0:t.rdns)&&(null==n?void 0:n.provider)&&$.set(n.info.rdns,n)},window.addEventListener("eip6963:announceProvider",U),window.dispatchEvent(new Event("eip6963:requestProvider")))}catch(e){}const t=yield P(),n=new URL(window.location.href).searchParams.get("lucia"),i={id:e.id};e.hash&&(i.hash=e.hash);const r=yield this.httpClient.post("/api/sdk/init",{user:{name:f()},data:t,session:i,redirectHash:n,utm:S()},!1);r&&(r.lid&&localStorage.setItem("lid",r.lid),r.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(d,JSON.stringify(t))}(r.session)),w.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger),yield this.autoDetectWallets(),this.setupWalletListeners()})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}autoDetectWallets(){return e(this,void 0,void 0,function*(){var t,n,i;try{const t=yield function(){return e(this,void 0,void 0,function*(){const e=Array.from($.values());if(0===e.length)return[];const t=yield Promise.allSettled(e.map(({info:e,provider:t})=>{const n=t.request({method:"eth_accounts"}).then(n=>{const i=n;return Array.isArray(i)?i.filter(e=>"string"==typeof e&&e.length>0).map(n=>({address:n,providerName:e.name,providerRdns:e.rdns,provider:t})):[]}),i=new Promise((t,n)=>setTimeout(()=>n(new Error(`EIP-6963 timeout: ${e.name}`)),3e3));return Promise.race([n,i])})),n=[];for(const e of t)"fulfilled"===e.status&&n.push(...e.value);return n})}();for(const e of t)yield this.sendWalletInfo(e.address,{provider:e.providerName,providerRdns:e.providerRdns})}catch(e){}if(0===K().size&&(null===(t=window.ethereum)||void 0===t?void 0:t.selectedAddress))try{const e=q();yield this.sendWalletInfo(window.ethereum.selectedAddress,{provider:null!=e?e:void 0})}catch(e){}if((null===(n=window.solana)||void 0===n?void 0:n.isConnected)&&(null===(i=window.solana)||void 0===i?void 0:i.publicKey))try{const e=z();yield this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0})}catch(e){}this.setupEIP6963AccountListeners()})}setupWalletListeners(){var e,t;const n=function(e){const t=t=>{var n;const i=t.detail;(null===(n=null==i?void 0:i.info)||void 0===n?void 0:n.rdns)&&(null==i?void 0:i.provider)&&($.set(i.info.rdns,i),e(i))};return window.addEventListener("eip6963:announceProvider",t),()=>window.removeEventListener("eip6963:announceProvider",t)}(e=>{this.handleLateEIP6963Provider(e)});if(this.walletListenerCleanups.push(n),(null===(e=window.ethereum)||void 0===e?void 0:e.on)&&0===K().size){const e=e=>{const t=e;if(t[0]){const e=t[0],n=q();this.sendWalletInfo(e,{provider:null!=n?n:void 0}).catch(()=>{})}};window.ethereum.on("accountsChanged",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.ethereum)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"accountsChanged",e)})}if(null===(t=window.solana)||void 0===t?void 0:t.on){const e=()=>{var e;if(null===(e=window.solana)||void 0===e?void 0:e.publicKey){const e=z();this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0}).catch(()=>{})}};window.solana.on("connect",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.solana)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"connect",e)})}}setupEIP6963AccountListeners(){const e=K();for(const[,t]of e)this.attachEIP6963AccountsChanged(t)}handleLateEIP6963Provider(e){const{info:t,provider:n}=e;n.request&&n.request({method:"eth_accounts"}).then(e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})}).catch(()=>{}),this.attachEIP6963AccountsChanged(e)}attachEIP6963AccountsChanged(e){const{info:t,provider:n}=e;if(!n.on)return;const i=e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})};n.on("accountsChanged",i),this.walletListenerCleanups.push(()=>{var e;null===(e=n.removeListener)||void 0===e||e.call(n,"accountsChanged",i)})}userInfo(t,n){return e(this,void 0,void 0,function*(){const e=g(),i=h();t&&localStorage.setItem("luc_uid",t);const r=Object.assign({user:{name:t,userInfo:n},session:i},e&&{lid:e});yield this.httpClient.post("/api/sdk/user",r)})}pageView(t){return e(this,void 0,void 0,function*(){const e=g(),n=h(),i=Object.assign({page:t,user:{name:f()},session:n},e&&{lid:e});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(t,n,i){return e(this,void 0,void 0,function*(){const e=g(),r=h(),o=Object.assign({tag:t,amount:n,event:i,user:{name:f()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(t,n){return e(this,void 0,void 0,function*(){const e=g(),i=h(),r=Object.assign(Object.assign({button:t,user:{name:f()},session:i},e&&{lid:e}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(t,n,i){return e(this,void 0,void 0,function*(){var e,r,o;if(!t||"string"!=typeof t)return;const s=t.startsWith("0x")?t.toLowerCase():t;if(this.sentWallets.has(s))return;this.sentWallets.add(s);let a={};n&&"object"==typeof n?a=n:void 0!==n&&(a={chainId:"number"==typeof n?n:void 0,provider:i});const l=g(),c=h(),d=Object.assign(Object.assign(Object.assign(Object.assign({walletAddress:t,provider:null!==(e=a.provider)&&void 0!==e?e:null,providerRdns:null!==(r=a.providerRdns)&&void 0!==r?r:null,connectorType:null!==(o=a.connectorType)&&void 0!==o?o:null},null!=a.chainId&&{chainId:a.chainId}),i&&{walletName:i}),{user:{name:f()},session:c}),l&&{lid:l});try{yield this.httpClient.post("/api/sdk/wallet",d)}catch(e){throw this.sentWallets.delete(s),e}})}trackUserAcquisition(t){return e(this,arguments,void 0,function*(e,t={}){const n=yield P(),i=S(),r=h();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){w.destroyAll(),this.walletListenerCleanups.forEach(e=>e()),this.walletListenerCleanups=[],this.sentWallets.clear(),M&&(U&&(window.removeEventListener("eip6963:announceProvider",U),U=null),$.clear(),M=!1)}},Q=null;const F=()=>{const e=Q||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},H=()=>{const e=Q||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),Q=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,w.reset()},V={init:t=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(Q)return Q;if(window.__luciaInitPromise)return Q=window.__luciaInitPromise,Q;if(!(null==t?void 0:t.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=e(void 0,void 0,void 0,function*(){const e=new B(t);return yield e.init(),e});return Q=n,window.__luciaInitPromise=n,n},userInfo:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).userInfo(t,n)}),pageView:t=>e(void 0,void 0,void 0,function*(){return(yield F()).pageView(t)}),trackConversion:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).trackConversion(t,n,i)}),buttonClick:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).buttonClick(t,n)}),sendWalletInfo:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).sendWalletInfo(t,n,i)}),trackUserAcquisition:(t,...n)=>e(void 0,[t,...n],void 0,function*(e,t={}){return(yield F()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:n};if("undefined"!=typeof window){window.LuciaSDK=V;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");V.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}export{H as __resetInstance,V as default,q as detectEvmProvider,z as detectSolanaProvider,L as filterObject,W as getApplePayAvailable,P as getBrowserData,D as getCanvasFingerprint,R as getColorGamut,x as getContrastPreference,S as getUtmParams,j as isTouchEnabled,E as safeAccess};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}Object.defineProperty(exports,"__esModule",{value:!0}),"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const n="0.9.13";class i{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new t(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(t){return e(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const e=yield fetch(`${this.baseURL}${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n}});return yield e.json()}catch(e){this.logger.log("error",e)}return null})}post(t,n){return e(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return e(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const t=()=>e(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const e=this.requestQueue.shift();try{const t=yield this.executePost(e.url,e.data,e.fireAndForget);e.resolve(t)}catch(t){e.reject(t)}yield t()});yield t()}finally{this.isProcessingQueue=!1}}})}executePost(t,i){return e(this,arguments,void 0,function*(e,t,i=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const i=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n},body:JSON.stringify(t)});return yield i.json()}catch(e){this.logger.log("error",e)}return null})}}class r{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(r.store).includes(t)){const n=e[t];r.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}r.store={isInitialized:!1,config:null,session:null};const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));let s;const a=new Uint8Array(16);var l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!s){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");s=crypto.getRandomValues.bind(crypto)}return s(a)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(i)}const u="luci_session",d=new t(r.store);function h(){try{const e=sessionStorage.getItem(u);return e?JSON.parse(e):null}catch(e){return d.log("error","Error retrieving session data:",e),null}}function g(){var e;const t={id:l.randomUUID&&!e?l.randomUUID():c(e),timestamp:Date.now()};return sessionStorage.setItem(u,JSON.stringify(t)),t}function f(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function w(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class m{constructor(e){this.store=r.store,this.dispatch=r.dispatch,this.dispatch({config:e}),this.httpClient=new i(this.store),this.logger=new t(this.store)}}class p{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const y=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},v=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],b=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const k=new class{constructor(e=[]){this.sensitiveSelectors=[...v,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&b.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},C=["button","a[href]",'[role="button"]'],T=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class A extends p{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:C,ignore:null!==(s=t.ignore)&&void 0!==s?s:T},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=k}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||C;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==C){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||C).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const S={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new A(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},I=new t(r.store);function x(){return e(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return I.log("error","Error checking connected wallet:",e),null}})}function P(){return e(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return I.log("error","Error getting wallet name:",e),null}})}function E(){return e(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const O=new t(r.store);function j(){return e(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){O.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return O.log("error","Error detecting Solana wallet:",e),null}})}function D(){return e(this,void 0,void 0,function*(){var e,t,n;const i=yield j();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function W(){return e(this,void 0,void 0,function*(){if(K)return K;const e={device:{cores:U(()=>navigator.hardwareConcurrency),memory:U(()=>navigator.deviceMemory),cpuClass:U(()=>navigator.cpuClass),touch:_(),devicePixelRatio:U(()=>window.devicePixelRatio)},screen:{width:U(()=>window.screen.width),height:U(()=>window.screen.height),colorDepth:U(()=>window.screen.colorDepth),availHeight:U(()=>window.screen.availHeight),availWidth:U(()=>window.screen.availWidth),orientation:{type:U(()=>window.screen.orientation.type),angle:U(()=>window.screen.orientation.angle)}},browser:{language:U(()=>navigator.language),encoding:U(()=>TextDecoder.encoding),timezone:U(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:U(()=>navigator.plugins.length),pluginNames:U(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:N(),uniqueHash:yield $(),colorGamut:q(),contrastPreference:B()},permissions:{navPer:U(()=>navigator.permissions.webglVersion),renderedPer:U(()=>navigator.permissions.RENDERER),geoPer:U(()=>navigator.permissions.geolocation)},storage:{localStorage:U(()=>!!window.localStorage),indexedDB:U(()=>!!window.indexedDB),openDB:U(()=>window.openDatabase)}};return K=e,e})}function M(){return e(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([j(),x(),P(),D(),E()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&L(r),walletName:n,solWalletName:i}})}function R(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function U(e,t){try{return e()}catch(e){return t}}function L(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let K=null;function $(){return e(this,void 0,void 0,function*(){try{const t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;t.width=i,t.height=r,t.style.width=`${i}px`,t.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(t){return e(this,void 0,void 0,function*(){const e=(new TextEncoder).encode(t),n=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function _(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function N(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function B(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function q(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}y.register(S);let z=class extends m{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return e(this,void 0,void 0,function*(){let e=h();e||(e=g());const t=yield W(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield M(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:w()},data:t,walletData:i,session:r,redirectHash:n,utm:R()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(u,JSON.stringify(t))}(o.session)),y.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h();t&&localStorage.setItem("luc_uid",t);const r=Object.assign({user:{name:t,userInfo:n},session:i},e&&{lid:e});yield this.httpClient.post("/api/sdk/user",r)})}pageView(t){return e(this,void 0,void 0,function*(){const e=f(),n=h(),i=Object.assign({page:t,user:{name:w()},session:n},e&&{lid:e});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({tag:t,amount:n,event:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h(),r=Object.assign(Object.assign({button:t,user:{name:w()},session:i},e&&{lid:e}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({walletAddress:t,chainId:n,walletName:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(t){return e(this,arguments,void 0,function*(e,t={}){const n=yield W(),i=R(),r=h();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){y.destroyAll()}},V=null;const F=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},Q={init:t=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(V)return V;if(window.__luciaInitPromise)return V=window.__luciaInitPromise,V;if(!(null==t?void 0:t.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=e(void 0,void 0,void 0,function*(){const e=new z(t);return yield e.init(),e});return V=n,window.__luciaInitPromise=n,n},userInfo:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).userInfo(t,n)}),pageView:t=>e(void 0,void 0,void 0,function*(){return(yield F()).pageView(t)}),trackConversion:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).trackConversion(t,n,i)}),buttonClick:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).buttonClick(t,n)}),sendWalletInfo:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).sendWalletInfo(t,n,i)}),trackUserAcquisition:(t,...n)=>e(void 0,[t,...n],void 0,function*(e,t={}){return(yield F()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:n};if("undefined"!=typeof window){window.LuciaSDK=Q;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");Q.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}exports.__resetInstance=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),V=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,y.reset()},exports.default=Q,exports.filterObject=L,exports.getApplePayAvailable=N,exports.getBrowserData=W,exports.getCanvasFingerprint=$,exports.getColorGamut=q,exports.getContrastPreference=B,exports.getUtmParams=R,exports.getWalletData=M,exports.isTouchEnabled=_,exports.safeAccess=U;
|
|
1
|
+
"use strict";function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}Object.defineProperty(exports,"__esModule",{value:!0}),"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const n="0.10.1";class i{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new t(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(t){return e(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const e=yield fetch(`${this.baseURL}${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n}});return yield e.json()}catch(e){this.logger.log("error",e)}return null})}post(t,n){return e(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return e(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const t=()=>e(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const e=this.requestQueue.shift();try{const t=yield this.executePost(e.url,e.data,e.fireAndForget);e.resolve(t)}catch(t){e.reject(t)}yield t()});yield t()}finally{this.isProcessingQueue=!1}}})}executePost(t,i){return e(this,arguments,void 0,function*(e,t,i=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const i=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n},body:JSON.stringify(t)});return yield i.json()}catch(e){this.logger.log("error",e)}return null})}}class r{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(r.store).includes(t)){const n=e[t];r.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}r.store={isInitialized:!1,config:null,session:null};const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));let s;const a=new Uint8Array(16);var l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!s){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");s=crypto.getRandomValues.bind(crypto)}return s(a)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(i)}const d="luci_session",u=new t(r.store);function h(){try{const e=sessionStorage.getItem(d);return e?JSON.parse(e):null}catch(e){return u.log("error","Error retrieving session data:",e),null}}function v(){var e;const t={id:l.randomUUID&&!e?l.randomUUID():c(e),timestamp:Date.now()};return sessionStorage.setItem(d,JSON.stringify(t)),t}function g(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function f(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class m{constructor(e){this.store=r.store,this.dispatch=r.dispatch,this.dispatch({config:e}),this.httpClient=new i(this.store),this.logger=new t(this.store)}}class p{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const w=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},y=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],b=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const k=new class{constructor(e=[]){this.sensitiveSelectors=[...y,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&b.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},C=["button","a[href]",'[role="button"]'],T=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class A extends p{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:C,ignore:null!==(s=t.ignore)&&void 0!==s?s:T},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=k}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||C;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==C){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||C).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const P={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new A(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}};function I(){return e(this,void 0,void 0,function*(){if(x)return x;const e={device:{cores:E(()=>navigator.hardwareConcurrency),memory:E(()=>navigator.deviceMemory),cpuClass:E(()=>navigator.cpuClass),touch:O(),devicePixelRatio:E(()=>window.devicePixelRatio)},screen:{width:E(()=>window.screen.width),height:E(()=>window.screen.height),colorDepth:E(()=>window.screen.colorDepth),availHeight:E(()=>window.screen.availHeight),availWidth:E(()=>window.screen.availWidth),orientation:{type:E(()=>window.screen.orientation.type),angle:E(()=>window.screen.orientation.angle)}},browser:{language:E(()=>navigator.language),encoding:E(()=>TextDecoder.encoding),timezone:E(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:E(()=>navigator.plugins.length),pluginNames:E(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:j(),uniqueHash:yield L(),colorGamut:W(),contrastPreference:D()},permissions:{navPer:E(()=>navigator.permissions.webglVersion),renderedPer:E(()=>navigator.permissions.RENDERER),geoPer:E(()=>navigator.permissions.geolocation)},storage:{localStorage:E(()=>!!window.localStorage),indexedDB:E(()=>!!window.indexedDB),openDB:E(()=>window.openDatabase)}};return x=e,e})}function S(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function E(e,t){try{return e()}catch(e){return t}}let x=null;function L(){return e(this,void 0,void 0,function*(){try{const t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;t.width=i,t.height=r,t.style.width=`${i}px`,t.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(t){return e(this,void 0,void 0,function*(){const e=(new TextEncoder).encode(t),n=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function O(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function j(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function D(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function W(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}const R=new Map;let U=null,$=!1;function M(){return new Map(R)}const _=[{name:"Rabby",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRabby)}},{name:"Brave Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBraveWallet)}},{name:"Rainbow",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRainbow)}},{name:"Coinbase Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoinbaseWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCoinbase)}},{name:"Trust Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTrust)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTrustWallet)}},{name:"TokenPocket",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTokenPocket)}},{name:"Zerion",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isZerion)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isPhantom)}},{name:"OKX Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOkxWallet)}},{name:"Bitget Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBitKeep)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isBitgetWallet)}},{name:"SafePal",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isSafePal)}},{name:"Frontier",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrontier)}},{name:"XDEFI",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isXDEFI)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCtrl)}},{name:"Enkrypt",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isEnkrypt)}},{name:"MetaMask",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}},{name:"WalletConnect",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isWalletConnect)}},{name:"imToken",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isImToken)}},{name:"Status",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isStatus)}},{name:"Tally",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTally)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTallyWallet)}},{name:"AlphaWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isAlphaWallet)}},{name:"Opera",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOpera)}},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoin98)}},{name:"MathWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMathWallet)}},{name:"1inch Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOneInchIOSWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isOneInchAndroidWallet)}},{name:"Frame",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrame)}},{name:"Binance Chain Wallet",detect:()=>!!window.BinanceChain},{name:"MetaMask",detect:()=>{var e;return Object.prototype.hasOwnProperty.call(null!==(e=window.ethereum)&&void 0!==e?e:{},"_metamask")}}],K=[{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.phantom)||void 0===e?void 0:e.solana)}},{name:"Solflare",detect:()=>!!window.solflare},{name:"Backpack",detect:()=>!!window.backpack},{name:"Glow",detect:()=>!!window.glow},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isCoin98)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isPhantom)}}];function N(){var e,t;return window.ethereum&&null!==(t=null===(e=_.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}function q(){var e,t;return null!==(t=null===(e=K.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}w.register(P);let B=class extends m{constructor(){super(...arguments),this.sentWallets=new Set,this.walletListenerCleanups=[]}authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return e(this,void 0,void 0,function*(){let e=h();e||(e=v());try{$||($=!0,U=e=>{var t;const n=e.detail;(null===(t=null==n?void 0:n.info)||void 0===t?void 0:t.rdns)&&(null==n?void 0:n.provider)&&R.set(n.info.rdns,n)},window.addEventListener("eip6963:announceProvider",U),window.dispatchEvent(new Event("eip6963:requestProvider")))}catch(e){}const t=yield I(),n=new URL(window.location.href).searchParams.get("lucia"),i={id:e.id};e.hash&&(i.hash=e.hash);const r=yield this.httpClient.post("/api/sdk/init",{user:{name:f()},data:t,session:i,redirectHash:n,utm:S()},!1);r&&(r.lid&&localStorage.setItem("lid",r.lid),r.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(d,JSON.stringify(t))}(r.session)),w.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger),yield this.autoDetectWallets(),this.setupWalletListeners()})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}autoDetectWallets(){return e(this,void 0,void 0,function*(){var t,n,i;try{const t=yield function(){return e(this,void 0,void 0,function*(){const e=Array.from(R.values());if(0===e.length)return[];const t=yield Promise.allSettled(e.map(({info:e,provider:t})=>{const n=t.request({method:"eth_accounts"}).then(n=>{const i=n;return Array.isArray(i)?i.filter(e=>"string"==typeof e&&e.length>0).map(n=>({address:n,providerName:e.name,providerRdns:e.rdns,provider:t})):[]}),i=new Promise((t,n)=>setTimeout(()=>n(new Error(`EIP-6963 timeout: ${e.name}`)),3e3));return Promise.race([n,i])})),n=[];for(const e of t)"fulfilled"===e.status&&n.push(...e.value);return n})}();for(const e of t)yield this.sendWalletInfo(e.address,{provider:e.providerName,providerRdns:e.providerRdns})}catch(e){}if(0===M().size&&(null===(t=window.ethereum)||void 0===t?void 0:t.selectedAddress))try{const e=N();yield this.sendWalletInfo(window.ethereum.selectedAddress,{provider:null!=e?e:void 0})}catch(e){}if((null===(n=window.solana)||void 0===n?void 0:n.isConnected)&&(null===(i=window.solana)||void 0===i?void 0:i.publicKey))try{const e=q();yield this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0})}catch(e){}this.setupEIP6963AccountListeners()})}setupWalletListeners(){var e,t;const n=function(e){const t=t=>{var n;const i=t.detail;(null===(n=null==i?void 0:i.info)||void 0===n?void 0:n.rdns)&&(null==i?void 0:i.provider)&&(R.set(i.info.rdns,i),e(i))};return window.addEventListener("eip6963:announceProvider",t),()=>window.removeEventListener("eip6963:announceProvider",t)}(e=>{this.handleLateEIP6963Provider(e)});if(this.walletListenerCleanups.push(n),(null===(e=window.ethereum)||void 0===e?void 0:e.on)&&0===M().size){const e=e=>{const t=e;if(t[0]){const e=t[0],n=N();this.sendWalletInfo(e,{provider:null!=n?n:void 0}).catch(()=>{})}};window.ethereum.on("accountsChanged",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.ethereum)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"accountsChanged",e)})}if(null===(t=window.solana)||void 0===t?void 0:t.on){const e=()=>{var e;if(null===(e=window.solana)||void 0===e?void 0:e.publicKey){const e=q();this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0}).catch(()=>{})}};window.solana.on("connect",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.solana)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"connect",e)})}}setupEIP6963AccountListeners(){const e=M();for(const[,t]of e)this.attachEIP6963AccountsChanged(t)}handleLateEIP6963Provider(e){const{info:t,provider:n}=e;n.request&&n.request({method:"eth_accounts"}).then(e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})}).catch(()=>{}),this.attachEIP6963AccountsChanged(e)}attachEIP6963AccountsChanged(e){const{info:t,provider:n}=e;if(!n.on)return;const i=e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})};n.on("accountsChanged",i),this.walletListenerCleanups.push(()=>{var e;null===(e=n.removeListener)||void 0===e||e.call(n,"accountsChanged",i)})}userInfo(t,n){return e(this,void 0,void 0,function*(){const e=g(),i=h();t&&localStorage.setItem("luc_uid",t);const r=Object.assign({user:{name:t,userInfo:n},session:i},e&&{lid:e});yield this.httpClient.post("/api/sdk/user",r)})}pageView(t){return e(this,void 0,void 0,function*(){const e=g(),n=h(),i=Object.assign({page:t,user:{name:f()},session:n},e&&{lid:e});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(t,n,i){return e(this,void 0,void 0,function*(){const e=g(),r=h(),o=Object.assign({tag:t,amount:n,event:i,user:{name:f()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(t,n){return e(this,void 0,void 0,function*(){const e=g(),i=h(),r=Object.assign(Object.assign({button:t,user:{name:f()},session:i},e&&{lid:e}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(t,n,i){return e(this,void 0,void 0,function*(){var e,r,o;if(!t||"string"!=typeof t)return;const s=t.startsWith("0x")?t.toLowerCase():t;if(this.sentWallets.has(s))return;this.sentWallets.add(s);let a={};n&&"object"==typeof n?a=n:void 0!==n&&(a={chainId:"number"==typeof n?n:void 0,provider:i});const l=g(),c=h(),d=Object.assign(Object.assign(Object.assign(Object.assign({walletAddress:t,provider:null!==(e=a.provider)&&void 0!==e?e:null,providerRdns:null!==(r=a.providerRdns)&&void 0!==r?r:null,connectorType:null!==(o=a.connectorType)&&void 0!==o?o:null},null!=a.chainId&&{chainId:a.chainId}),i&&{walletName:i}),{user:{name:f()},session:c}),l&&{lid:l});try{yield this.httpClient.post("/api/sdk/wallet",d)}catch(e){throw this.sentWallets.delete(s),e}})}trackUserAcquisition(t){return e(this,arguments,void 0,function*(e,t={}){const n=yield I(),i=S(),r=h();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){w.destroyAll(),this.walletListenerCleanups.forEach(e=>e()),this.walletListenerCleanups=[],this.sentWallets.clear(),$&&(U&&(window.removeEventListener("eip6963:announceProvider",U),U=null),R.clear(),$=!1)}},z=null;const F=()=>{const e=z||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},Q={init:t=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(z)return z;if(window.__luciaInitPromise)return z=window.__luciaInitPromise,z;if(!(null==t?void 0:t.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=e(void 0,void 0,void 0,function*(){const e=new B(t);return yield e.init(),e});return z=n,window.__luciaInitPromise=n,n},userInfo:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).userInfo(t,n)}),pageView:t=>e(void 0,void 0,void 0,function*(){return(yield F()).pageView(t)}),trackConversion:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).trackConversion(t,n,i)}),buttonClick:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).buttonClick(t,n)}),sendWalletInfo:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).sendWalletInfo(t,n,i)}),trackUserAcquisition:(t,...n)=>e(void 0,[t,...n],void 0,function*(e,t={}){return(yield F()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:n};if("undefined"!=typeof window){window.LuciaSDK=Q;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");Q.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}exports.__resetInstance=()=>{const e=z||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),z=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,w.reset()},exports.default=Q,exports.detectEvmProvider=N,exports.detectSolanaProvider=q,exports.filterObject=function(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t},exports.getApplePayAvailable=j,exports.getBrowserData=I,exports.getCanvasFingerprint=L,exports.getColorGamut=W,exports.getContrastPreference=D,exports.getUtmParams=S,exports.isTouchEnabled=O,exports.safeAccess=E;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lucia-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"description": "Lucia JavaScript Library",
|
|
6
6
|
"repository": {
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@commitlint/config-conventional": "^20.2.0",
|
|
40
|
+
"@eslint/js": "^10.0.1",
|
|
40
41
|
"@release-it/conventional-changelog": "^10.0.4",
|
|
41
42
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
42
43
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
43
44
|
"@rollup/plugin-replace": "^6.0.3",
|
|
44
|
-
"@rollup/plugin-terser": "^0.
|
|
45
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
45
46
|
"@testing-library/jest-dom": "^6.9.1",
|
|
46
47
|
"@types/jest": "^30.0.0",
|
|
47
48
|
"@types/uuid": "^11.0.0",
|
|
48
49
|
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
49
50
|
"@typescript-eslint/parser": "^8.50.1",
|
|
50
|
-
"typescript-eslint": "^8.50.1",
|
|
51
51
|
"commitlint": "^20.2.0",
|
|
52
|
-
"eslint": "^
|
|
52
|
+
"eslint": "^10.0.0",
|
|
53
53
|
"eslint-config-prettier": "^10.1.8",
|
|
54
54
|
"eslint-plugin-import": "^2.32.0",
|
|
55
55
|
"eslint-plugin-jest": "^29.11.0",
|
|
56
56
|
"eslint-plugin-promise": "^7.2.1",
|
|
57
|
-
"eslint-plugin-unicorn": "^
|
|
57
|
+
"eslint-plugin-unicorn": "^63.0.0",
|
|
58
58
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
59
59
|
"husky": "^9.1.7",
|
|
60
60
|
"jest": "^30.2.0",
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
"rollup": "^4.54.0",
|
|
67
67
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
68
68
|
"ts-jest": "^29.4.6",
|
|
69
|
-
"typescript": "^5.9.3"
|
|
69
|
+
"typescript": "^5.9.3",
|
|
70
|
+
"typescript-eslint": "^8.50.1"
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"uuid": "^13.0.0"
|
package/dist/types.d.ts
CHANGED
|
@@ -26,13 +26,22 @@ export interface ClickEventMetadata {
|
|
|
26
26
|
href?: string | null;
|
|
27
27
|
meta?: Record<string, string>;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for sendWalletInfo (new interface)
|
|
31
|
+
*/
|
|
32
|
+
export interface WalletInfoOptions {
|
|
33
|
+
provider?: string;
|
|
34
|
+
providerRdns?: string;
|
|
35
|
+
connectorType?: string;
|
|
36
|
+
chainId?: number;
|
|
37
|
+
}
|
|
29
38
|
export interface SDK {
|
|
30
39
|
init: (config: Config) => Promise<LuciaSDKInstance>;
|
|
31
40
|
userInfo: (user: string, userInfo: object) => Promise<void>;
|
|
32
41
|
pageView: (page: string) => Promise<void>;
|
|
33
42
|
trackConversion: (eventTag: string, amount: number, eventDetails: object) => Promise<void>;
|
|
34
43
|
buttonClick: (button: string, metadata?: ClickEventMetadata) => Promise<void>;
|
|
35
|
-
sendWalletInfo: (walletAddress: string,
|
|
44
|
+
sendWalletInfo: (walletAddress: string, optionsOrChainId?: WalletInfoOptions | number | string, walletName?: string) => Promise<void>;
|
|
36
45
|
trackUserAcquisition: (userId: string, acquisitionData?: object) => Promise<void>;
|
|
37
46
|
checkMetaMaskConnection: () => boolean;
|
|
38
47
|
VERSION: string;
|
|
@@ -88,43 +97,6 @@ export interface BrowserData {
|
|
|
88
97
|
openDB?: unknown;
|
|
89
98
|
};
|
|
90
99
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Wallet data object returned by getWalletData()
|
|
93
|
-
*/
|
|
94
|
-
export interface WalletData {
|
|
95
|
-
providerInfo?: Partial<ProviderInfo> | null;
|
|
96
|
-
walletAddress?: string | null;
|
|
97
|
-
solanaAddress?: string | null;
|
|
98
|
-
walletName?: string | null;
|
|
99
|
-
solWalletName?: string | null;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Ethereum provider information
|
|
103
|
-
*/
|
|
104
|
-
export interface ProviderInfo {
|
|
105
|
-
isMetaMask: boolean;
|
|
106
|
-
isCoinbaseWallet: boolean;
|
|
107
|
-
isWalletConnect: boolean;
|
|
108
|
-
isTrust: boolean;
|
|
109
|
-
isImToken: boolean;
|
|
110
|
-
isBraveWallet: boolean;
|
|
111
|
-
isTokenPocket: boolean;
|
|
112
|
-
isStatus: boolean;
|
|
113
|
-
isTally: boolean;
|
|
114
|
-
isAlphaWallet: boolean;
|
|
115
|
-
isOpera: boolean;
|
|
116
|
-
isCoin98: boolean;
|
|
117
|
-
isMathWallet: boolean;
|
|
118
|
-
isOneInch: boolean;
|
|
119
|
-
isRainbow: boolean;
|
|
120
|
-
isBinanceChainWallet: boolean;
|
|
121
|
-
isFrame: boolean;
|
|
122
|
-
userAgent: string;
|
|
123
|
-
chainId?: string;
|
|
124
|
-
networkVersion?: string;
|
|
125
|
-
name: string;
|
|
126
|
-
isPossiblyGenericInjectedProvider?: boolean;
|
|
127
|
-
}
|
|
128
100
|
/**
|
|
129
101
|
* Session data stored in sessionStorage
|
|
130
102
|
*/
|
|
@@ -186,6 +158,9 @@ export interface ClickPayload extends BaseApiPayload {
|
|
|
186
158
|
*/
|
|
187
159
|
export interface WalletPayload extends BaseApiPayload {
|
|
188
160
|
walletAddress: string;
|
|
189
|
-
|
|
190
|
-
|
|
161
|
+
provider?: string | null;
|
|
162
|
+
providerRdns?: string | null;
|
|
163
|
+
connectorType?: string | null;
|
|
164
|
+
chainId?: number;
|
|
165
|
+
walletName?: string;
|
|
191
166
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const i="0.10.1";class r{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new n(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(e){return t(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const t=yield fetch(`${this.baseURL}${e}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i}});return yield t.json()}catch(e){this.logger.log("error",e)}return null})}post(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return t(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const e=()=>t(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const t=this.requestQueue.shift();try{const e=yield this.executePost(t.url,t.data,t.fireAndForget);t.resolve(e)}catch(e){t.reject(e)}yield e()});yield e()}finally{this.isProcessingQueue=!1}}})}executePost(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(n&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const n=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i},body:JSON.stringify(t)});return yield n.json()}catch(e){this.logger.log("error",e)}return null})}}class o{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(o.store).includes(t)){const n=e[t];o.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}o.store={isInitialized:!1,config:null,session:null};const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function d(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}(i)}const u="luci_session",h=new n(o.store);function v(){try{const e=sessionStorage.getItem(u);return e?JSON.parse(e):null}catch(e){return h.log("error","Error retrieving session data:",e),null}}function g(){var e;const t={id:c.randomUUID&&!e?c.randomUUID():d(e),timestamp:Date.now()};return sessionStorage.setItem(u,JSON.stringify(t)),t}function f(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function m(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class p{constructor(e){this.store=o.store,this.dispatch=o.dispatch,this.dispatch({config:e}),this.httpClient=new r(this.store),this.logger=new n(this.store)}}class w{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const y=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},b=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],k=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const C=new class{constructor(e=[]){this.sensitiveSelectors=[...b,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&k.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},T=["button","a[href]",'[role="button"]'],A=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class P extends w{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:T,ignore:null!==(s=t.ignore)&&void 0!==s?s:A},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=C}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||T;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==T){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||A).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const I={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new P(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}};function S(){return t(this,void 0,void 0,function*(){if(O)return O;const e={device:{cores:L(()=>navigator.hardwareConcurrency),memory:L(()=>navigator.deviceMemory),cpuClass:L(()=>navigator.cpuClass),touch:D(),devicePixelRatio:L(()=>window.devicePixelRatio)},screen:{width:L(()=>window.screen.width),height:L(()=>window.screen.height),colorDepth:L(()=>window.screen.colorDepth),availHeight:L(()=>window.screen.availHeight),availWidth:L(()=>window.screen.availWidth),orientation:{type:L(()=>window.screen.orientation.type),angle:L(()=>window.screen.orientation.angle)}},browser:{language:L(()=>navigator.language),encoding:L(()=>TextDecoder.encoding),timezone:L(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:L(()=>navigator.plugins.length),pluginNames:L(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:x(),uniqueHash:yield j(),colorGamut:R(),contrastPreference:W()},permissions:{navPer:L(()=>navigator.permissions.webglVersion),renderedPer:L(()=>navigator.permissions.RENDERER),geoPer:L(()=>navigator.permissions.geolocation)},storage:{localStorage:L(()=>!!window.localStorage),indexedDB:L(()=>!!window.indexedDB),openDB:L(()=>window.openDatabase)}};return O=e,e})}function E(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function L(e,t){try{return e()}catch(e){return t}}let O=null;function j(){return t(this,void 0,void 0,function*(){try{const e=document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;e.width=i,e.height=r,e.style.width=`${i}px`,e.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(e){return t(this,void 0,void 0,function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function D(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function x(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function W(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function R(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}const U=new Map;let $=null,M=!1;function _(){return new Map(U)}const K=[{name:"Rabby",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRabby)}},{name:"Brave Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBraveWallet)}},{name:"Rainbow",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRainbow)}},{name:"Coinbase Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoinbaseWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCoinbase)}},{name:"Trust Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTrust)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTrustWallet)}},{name:"TokenPocket",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTokenPocket)}},{name:"Zerion",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isZerion)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isPhantom)}},{name:"OKX Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOkxWallet)}},{name:"Bitget Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBitKeep)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isBitgetWallet)}},{name:"SafePal",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isSafePal)}},{name:"Frontier",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrontier)}},{name:"XDEFI",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isXDEFI)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCtrl)}},{name:"Enkrypt",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isEnkrypt)}},{name:"MetaMask",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}},{name:"WalletConnect",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isWalletConnect)}},{name:"imToken",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isImToken)}},{name:"Status",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isStatus)}},{name:"Tally",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTally)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTallyWallet)}},{name:"AlphaWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isAlphaWallet)}},{name:"Opera",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOpera)}},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoin98)}},{name:"MathWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMathWallet)}},{name:"1inch Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOneInchIOSWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isOneInchAndroidWallet)}},{name:"Frame",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrame)}},{name:"Binance Chain Wallet",detect:()=>!!window.BinanceChain},{name:"MetaMask",detect:()=>{var e;return Object.prototype.hasOwnProperty.call(null!==(e=window.ethereum)&&void 0!==e?e:{},"_metamask")}}],N=[{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.phantom)||void 0===e?void 0:e.solana)}},{name:"Solflare",detect:()=>!!window.solflare},{name:"Backpack",detect:()=>!!window.backpack},{name:"Glow",detect:()=>!!window.glow},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isCoin98)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isPhantom)}}];function q(){var e,t;return window.ethereum&&null!==(t=null===(e=K.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}function B(){var e,t;return null!==(t=null===(e=N.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}y.register(I);let z=class extends p{constructor(){super(...arguments),this.sentWallets=new Set,this.walletListenerCleanups=[]}authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return t(this,void 0,void 0,function*(){let e=v();e||(e=g());try{M||(M=!0,$=e=>{var t;const n=e.detail;(null===(t=null==n?void 0:n.info)||void 0===t?void 0:t.rdns)&&(null==n?void 0:n.provider)&&U.set(n.info.rdns,n)},window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider")))}catch(e){}const t=yield S(),n=new URL(window.location.href).searchParams.get("lucia"),i={id:e.id};e.hash&&(i.hash=e.hash);const r=yield this.httpClient.post("/api/sdk/init",{user:{name:m()},data:t,session:i,redirectHash:n,utm:E()},!1);r&&(r.lid&&localStorage.setItem("lid",r.lid),r.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(u,JSON.stringify(t))}(r.session)),y.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger),yield this.autoDetectWallets(),this.setupWalletListeners()})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}autoDetectWallets(){return t(this,void 0,void 0,function*(){var e,n,i;try{const e=yield function(){return t(this,void 0,void 0,function*(){const e=Array.from(U.values());if(0===e.length)return[];const t=yield Promise.allSettled(e.map(({info:e,provider:t})=>{const n=t.request({method:"eth_accounts"}).then(n=>{const i=n;return Array.isArray(i)?i.filter(e=>"string"==typeof e&&e.length>0).map(n=>({address:n,providerName:e.name,providerRdns:e.rdns,provider:t})):[]}),i=new Promise((t,n)=>setTimeout(()=>n(new Error(`EIP-6963 timeout: ${e.name}`)),3e3));return Promise.race([n,i])})),n=[];for(const e of t)"fulfilled"===e.status&&n.push(...e.value);return n})}();for(const t of e)yield this.sendWalletInfo(t.address,{provider:t.providerName,providerRdns:t.providerRdns})}catch(e){}if(0===_().size&&(null===(e=window.ethereum)||void 0===e?void 0:e.selectedAddress))try{const e=q();yield this.sendWalletInfo(window.ethereum.selectedAddress,{provider:null!=e?e:void 0})}catch(e){}if((null===(n=window.solana)||void 0===n?void 0:n.isConnected)&&(null===(i=window.solana)||void 0===i?void 0:i.publicKey))try{const e=B();yield this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0})}catch(e){}this.setupEIP6963AccountListeners()})}setupWalletListeners(){var e,t;const n=function(e){const t=t=>{var n;const i=t.detail;(null===(n=null==i?void 0:i.info)||void 0===n?void 0:n.rdns)&&(null==i?void 0:i.provider)&&(U.set(i.info.rdns,i),e(i))};return window.addEventListener("eip6963:announceProvider",t),()=>window.removeEventListener("eip6963:announceProvider",t)}(e=>{this.handleLateEIP6963Provider(e)});if(this.walletListenerCleanups.push(n),(null===(e=window.ethereum)||void 0===e?void 0:e.on)&&0===_().size){const e=e=>{const t=e;if(t[0]){const e=t[0],n=q();this.sendWalletInfo(e,{provider:null!=n?n:void 0}).catch(()=>{})}};window.ethereum.on("accountsChanged",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.ethereum)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"accountsChanged",e)})}if(null===(t=window.solana)||void 0===t?void 0:t.on){const e=()=>{var e;if(null===(e=window.solana)||void 0===e?void 0:e.publicKey){const e=B();this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0}).catch(()=>{})}};window.solana.on("connect",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.solana)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"connect",e)})}}setupEIP6963AccountListeners(){const e=_();for(const[,t]of e)this.attachEIP6963AccountsChanged(t)}handleLateEIP6963Provider(e){const{info:t,provider:n}=e;n.request&&n.request({method:"eth_accounts"}).then(e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})}).catch(()=>{}),this.attachEIP6963AccountsChanged(e)}attachEIP6963AccountsChanged(e){const{info:t,provider:n}=e;if(!n.on)return;const i=e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})};n.on("accountsChanged",i),this.walletListenerCleanups.push(()=>{var e;null===(e=n.removeListener)||void 0===e||e.call(n,"accountsChanged",i)})}userInfo(e,n){return t(this,void 0,void 0,function*(){const t=f(),i=v();e&&localStorage.setItem("luc_uid",e);const r=Object.assign({user:{name:e,userInfo:n},session:i},t&&{lid:t});yield this.httpClient.post("/api/sdk/user",r)})}pageView(e){return t(this,void 0,void 0,function*(){const t=f(),n=v(),i=Object.assign({page:e,user:{name:m()},session:n},t&&{lid:t});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(e,n,i){return t(this,void 0,void 0,function*(){const t=f(),r=v(),o=Object.assign({tag:e,amount:n,event:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(e,n){return t(this,void 0,void 0,function*(){const t=f(),i=v(),r=Object.assign(Object.assign({button:e,user:{name:m()},session:i},t&&{lid:t}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o;if(!e||"string"!=typeof e)return;const s=e.startsWith("0x")?e.toLowerCase():e;if(this.sentWallets.has(s))return;this.sentWallets.add(s);let a={};n&&"object"==typeof n?a=n:void 0!==n&&(a={chainId:"number"==typeof n?n:void 0,provider:i});const l=f(),c=v(),d=Object.assign(Object.assign(Object.assign(Object.assign({walletAddress:e,provider:null!==(t=a.provider)&&void 0!==t?t:null,providerRdns:null!==(r=a.providerRdns)&&void 0!==r?r:null,connectorType:null!==(o=a.connectorType)&&void 0!==o?o:null},null!=a.chainId&&{chainId:a.chainId}),i&&{walletName:i}),{user:{name:m()},session:c}),l&&{lid:l});try{yield this.httpClient.post("/api/sdk/wallet",d)}catch(e){throw this.sentWallets.delete(s),e}})}trackUserAcquisition(e){return t(this,arguments,void 0,function*(e,t={}){const n=yield S(),i=E(),r=v();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){y.destroyAll(),this.walletListenerCleanups.forEach(e=>e()),this.walletListenerCleanups=[],this.sentWallets.clear(),M&&($&&(window.removeEventListener("eip6963:announceProvider",$),$=null),U.clear(),M=!1)}},F=null;const Q=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},H={init:e=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(F)return F;if(window.__luciaInitPromise)return F=window.__luciaInitPromise,F;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=t(void 0,void 0,void 0,function*(){const t=new z(e);return yield t.init(),t});return F=n,window.__luciaInitPromise=n,n},userInfo:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(e,n)}),pageView:e=>t(void 0,void 0,void 0,function*(){return(yield Q()).pageView(e)}),trackConversion:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(e,n,i)}),buttonClick:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(e,n)}),sendWalletInfo:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(e,n,i)}),trackUserAcquisition:(e,...n)=>t(void 0,[e,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:i};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}e.__resetInstance=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),F=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,y.reset()},e.default=H,e.detectEvmProvider=q,e.detectSolanaProvider=B,e.filterObject=function(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t},e.getApplePayAvailable=x,e.getBrowserData=S,e.getCanvasFingerprint=j,e.getColorGamut=R,e.getContrastPreference=W,e.getUtmParams=E,e.isTouchEnabled=D,e.safeAccess=L,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const i="0.9.13";class r{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new n(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(e){return t(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const t=yield fetch(`${this.baseURL}${e}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i}});return yield t.json()}catch(e){this.logger.log("error",e)}return null})}post(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return t(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const e=()=>t(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const t=this.requestQueue.shift();try{const e=yield this.executePost(t.url,t.data,t.fireAndForget);t.resolve(e)}catch(e){t.reject(e)}yield e()});yield e()}finally{this.isProcessingQueue=!1}}})}executePost(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(n&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const n=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i},body:JSON.stringify(t)});return yield n.json()}catch(e){this.logger.log("error",e)}return null})}}class o{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(o.store).includes(t)){const n=e[t];o.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}o.store={isInitialized:!1,config:null,session:null};const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function u(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}(i)}const d="luci_session",h=new n(o.store);function g(){try{const e=sessionStorage.getItem(d);return e?JSON.parse(e):null}catch(e){return h.log("error","Error retrieving session data:",e),null}}function f(){var e;const t={id:c.randomUUID&&!e?c.randomUUID():u(e),timestamp:Date.now()};return sessionStorage.setItem(d,JSON.stringify(t)),t}function w(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function m(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class p{constructor(e){this.store=o.store,this.dispatch=o.dispatch,this.dispatch({config:e}),this.httpClient=new r(this.store),this.logger=new n(this.store)}}class y{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const v=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},b=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],k=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const C=new class{constructor(e=[]){this.sensitiveSelectors=[...b,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&k.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},T=["button","a[href]",'[role="button"]'],A=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class S extends y{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:T,ignore:null!==(s=t.ignore)&&void 0!==s?s:A},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=C}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||T;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==T){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||A).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const I={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new S(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},P=new n(o.store);function E(){return t(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return P.log("error","Error checking connected wallet:",e),null}})}function O(){return t(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return P.log("error","Error getting wallet name:",e),null}})}function x(){return t(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const j=new n(o.store);function D(){return t(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){j.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return j.log("error","Error detecting Solana wallet:",e),null}})}function W(){return t(this,void 0,void 0,function*(){var e,t,n;const i=yield D();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function M(){return t(this,void 0,void 0,function*(){if($)return $;const e={device:{cores:L(()=>navigator.hardwareConcurrency),memory:L(()=>navigator.deviceMemory),cpuClass:L(()=>navigator.cpuClass),touch:N(),devicePixelRatio:L(()=>window.devicePixelRatio)},screen:{width:L(()=>window.screen.width),height:L(()=>window.screen.height),colorDepth:L(()=>window.screen.colorDepth),availHeight:L(()=>window.screen.availHeight),availWidth:L(()=>window.screen.availWidth),orientation:{type:L(()=>window.screen.orientation.type),angle:L(()=>window.screen.orientation.angle)}},browser:{language:L(()=>navigator.language),encoding:L(()=>TextDecoder.encoding),timezone:L(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:L(()=>navigator.plugins.length),pluginNames:L(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:B(),uniqueHash:yield _(),colorGamut:z(),contrastPreference:q()},permissions:{navPer:L(()=>navigator.permissions.webglVersion),renderedPer:L(()=>navigator.permissions.RENDERER),geoPer:L(()=>navigator.permissions.geolocation)},storage:{localStorage:L(()=>!!window.localStorage),indexedDB:L(()=>!!window.indexedDB),openDB:L(()=>window.openDatabase)}};return $=e,e})}function R(){return t(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([D(),E(),O(),W(),x()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&K(r),walletName:n,solWalletName:i}})}function U(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function L(e,t){try{return e()}catch(e){return t}}function K(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let $=null;function _(){return t(this,void 0,void 0,function*(){try{const e=document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;e.width=i,e.height=r,e.style.width=`${i}px`,e.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(e){return t(this,void 0,void 0,function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function N(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function B(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function q(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function z(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}v.register(I);let V=class extends p{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return t(this,void 0,void 0,function*(){let e=g();e||(e=f());const t=yield M(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield R(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:m()},data:t,walletData:i,session:r,redirectHash:n,utm:U()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(d,JSON.stringify(t))}(o.session)),v.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g();e&&localStorage.setItem("luc_uid",e);const r=Object.assign({user:{name:e,userInfo:n},session:i},t&&{lid:t});yield this.httpClient.post("/api/sdk/user",r)})}pageView(e){return t(this,void 0,void 0,function*(){const t=w(),n=g(),i=Object.assign({page:e,user:{name:m()},session:n},t&&{lid:t});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({tag:e,amount:n,event:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g(),r=Object.assign(Object.assign({button:e,user:{name:m()},session:i},t&&{lid:t}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({walletAddress:e,chainId:n,walletName:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(e){return t(this,arguments,void 0,function*(e,t={}){const n=yield M(),i=U(),r=g();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){v.destroyAll()}},F=null;const Q=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},H={init:e=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(F)return F;if(window.__luciaInitPromise)return F=window.__luciaInitPromise,F;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=t(void 0,void 0,void 0,function*(){const t=new V(e);return yield t.init(),t});return F=n,window.__luciaInitPromise=n,n},userInfo:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(e,n)}),pageView:e=>t(void 0,void 0,void 0,function*(){return(yield Q()).pageView(e)}),trackConversion:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(e,n,i)}),buttonClick:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(e,n)}),sendWalletInfo:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(e,n,i)}),trackUserAcquisition:(e,...n)=>t(void 0,[e,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:i};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}e.__resetInstance=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),F=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,v.reset()},e.default=H,e.filterObject=K,e.getApplePayAvailable=B,e.getBrowserData=M,e.getCanvasFingerprint=_,e.getColorGamut=z,e.getContrastPreference=q,e.getUtmParams=U,e.getWalletData=R,e.isTouchEnabled=N,e.safeAccess=L,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const i="0.10.1";class r{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new n(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(e){return t(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const t=yield fetch(`${this.baseURL}${e}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i}});return yield t.json()}catch(e){this.logger.log("error",e)}return null})}post(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return t(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const e=()=>t(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const t=this.requestQueue.shift();try{const e=yield this.executePost(t.url,t.data,t.fireAndForget);t.resolve(e)}catch(e){t.reject(e)}yield e()});yield e()}finally{this.isProcessingQueue=!1}}})}executePost(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(n&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const n=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i},body:JSON.stringify(t)});return yield n.json()}catch(e){this.logger.log("error",e)}return null})}}class o{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(o.store).includes(t)){const n=e[t];o.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}o.store={isInitialized:!1,config:null,session:null};const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function d(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}(i)}const u="luci_session",h=new n(o.store);function v(){try{const e=sessionStorage.getItem(u);return e?JSON.parse(e):null}catch(e){return h.log("error","Error retrieving session data:",e),null}}function g(){var e;const t={id:c.randomUUID&&!e?c.randomUUID():d(e),timestamp:Date.now()};return sessionStorage.setItem(u,JSON.stringify(t)),t}function f(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function m(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class p{constructor(e){this.store=o.store,this.dispatch=o.dispatch,this.dispatch({config:e}),this.httpClient=new r(this.store),this.logger=new n(this.store)}}class w{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const y=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},b=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],k=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const C=new class{constructor(e=[]){this.sensitiveSelectors=[...b,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&k.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},T=["button","a[href]",'[role="button"]'],A=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class P extends w{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:T,ignore:null!==(s=t.ignore)&&void 0!==s?s:A},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=C}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||T;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==T){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||A).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const I={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new P(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}};function S(){return t(this,void 0,void 0,function*(){if(O)return O;const e={device:{cores:L(()=>navigator.hardwareConcurrency),memory:L(()=>navigator.deviceMemory),cpuClass:L(()=>navigator.cpuClass),touch:D(),devicePixelRatio:L(()=>window.devicePixelRatio)},screen:{width:L(()=>window.screen.width),height:L(()=>window.screen.height),colorDepth:L(()=>window.screen.colorDepth),availHeight:L(()=>window.screen.availHeight),availWidth:L(()=>window.screen.availWidth),orientation:{type:L(()=>window.screen.orientation.type),angle:L(()=>window.screen.orientation.angle)}},browser:{language:L(()=>navigator.language),encoding:L(()=>TextDecoder.encoding),timezone:L(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:L(()=>navigator.plugins.length),pluginNames:L(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:x(),uniqueHash:yield j(),colorGamut:R(),contrastPreference:W()},permissions:{navPer:L(()=>navigator.permissions.webglVersion),renderedPer:L(()=>navigator.permissions.RENDERER),geoPer:L(()=>navigator.permissions.geolocation)},storage:{localStorage:L(()=>!!window.localStorage),indexedDB:L(()=>!!window.indexedDB),openDB:L(()=>window.openDatabase)}};return O=e,e})}function E(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function L(e,t){try{return e()}catch(e){return t}}let O=null;function j(){return t(this,void 0,void 0,function*(){try{const e=document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;e.width=i,e.height=r,e.style.width=`${i}px`,e.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(e){return t(this,void 0,void 0,function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function D(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function x(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function W(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function R(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}const U=new Map;let $=null,M=!1;function _(){return new Map(U)}const K=[{name:"Rabby",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRabby)}},{name:"Brave Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBraveWallet)}},{name:"Rainbow",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isRainbow)}},{name:"Coinbase Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoinbaseWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCoinbase)}},{name:"Trust Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTrust)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTrustWallet)}},{name:"TokenPocket",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTokenPocket)}},{name:"Zerion",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isZerion)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isPhantom)}},{name:"OKX Wallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOkxWallet)}},{name:"Bitget Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isBitKeep)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isBitgetWallet)}},{name:"SafePal",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isSafePal)}},{name:"Frontier",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrontier)}},{name:"XDEFI",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isXDEFI)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isCtrl)}},{name:"Enkrypt",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isEnkrypt)}},{name:"MetaMask",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}},{name:"WalletConnect",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isWalletConnect)}},{name:"imToken",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isImToken)}},{name:"Status",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isStatus)}},{name:"Tally",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isTally)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isTallyWallet)}},{name:"AlphaWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isAlphaWallet)}},{name:"Opera",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOpera)}},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isCoin98)}},{name:"MathWallet",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isMathWallet)}},{name:"1inch Wallet",detect:()=>{var e,t;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isOneInchIOSWallet)||!!(null===(t=window.ethereum)||void 0===t?void 0:t.isOneInchAndroidWallet)}},{name:"Frame",detect:()=>{var e;return!!(null===(e=window.ethereum)||void 0===e?void 0:e.isFrame)}},{name:"Binance Chain Wallet",detect:()=>!!window.BinanceChain},{name:"MetaMask",detect:()=>{var e;return Object.prototype.hasOwnProperty.call(null!==(e=window.ethereum)&&void 0!==e?e:{},"_metamask")}}],N=[{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.phantom)||void 0===e?void 0:e.solana)}},{name:"Solflare",detect:()=>!!window.solflare},{name:"Backpack",detect:()=>!!window.backpack},{name:"Glow",detect:()=>!!window.glow},{name:"Coin98",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isCoin98)}},{name:"Phantom",detect:()=>{var e;return!!(null===(e=window.solana)||void 0===e?void 0:e.isPhantom)}}];function q(){var e,t;return window.ethereum&&null!==(t=null===(e=K.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}function B(){var e,t;return null!==(t=null===(e=N.find(e=>e.detect()))||void 0===e?void 0:e.name)&&void 0!==t?t:null}y.register(I);let z=class extends p{constructor(){super(...arguments),this.sentWallets=new Set,this.walletListenerCleanups=[]}authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return t(this,void 0,void 0,function*(){let e=v();e||(e=g());try{M||(M=!0,$=e=>{var t;const n=e.detail;(null===(t=null==n?void 0:n.info)||void 0===t?void 0:t.rdns)&&(null==n?void 0:n.provider)&&U.set(n.info.rdns,n)},window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider")))}catch(e){}const t=yield S(),n=new URL(window.location.href).searchParams.get("lucia"),i={id:e.id};e.hash&&(i.hash=e.hash);const r=yield this.httpClient.post("/api/sdk/init",{user:{name:m()},data:t,session:i,redirectHash:n,utm:E()},!1);r&&(r.lid&&localStorage.setItem("lid",r.lid),r.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(u,JSON.stringify(t))}(r.session)),y.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger),yield this.autoDetectWallets(),this.setupWalletListeners()})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}autoDetectWallets(){return t(this,void 0,void 0,function*(){var e,n,i;try{const e=yield function(){return t(this,void 0,void 0,function*(){const e=Array.from(U.values());if(0===e.length)return[];const t=yield Promise.allSettled(e.map(({info:e,provider:t})=>{const n=t.request({method:"eth_accounts"}).then(n=>{const i=n;return Array.isArray(i)?i.filter(e=>"string"==typeof e&&e.length>0).map(n=>({address:n,providerName:e.name,providerRdns:e.rdns,provider:t})):[]}),i=new Promise((t,n)=>setTimeout(()=>n(new Error(`EIP-6963 timeout: ${e.name}`)),3e3));return Promise.race([n,i])})),n=[];for(const e of t)"fulfilled"===e.status&&n.push(...e.value);return n})}();for(const t of e)yield this.sendWalletInfo(t.address,{provider:t.providerName,providerRdns:t.providerRdns})}catch(e){}if(0===_().size&&(null===(e=window.ethereum)||void 0===e?void 0:e.selectedAddress))try{const e=q();yield this.sendWalletInfo(window.ethereum.selectedAddress,{provider:null!=e?e:void 0})}catch(e){}if((null===(n=window.solana)||void 0===n?void 0:n.isConnected)&&(null===(i=window.solana)||void 0===i?void 0:i.publicKey))try{const e=B();yield this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0})}catch(e){}this.setupEIP6963AccountListeners()})}setupWalletListeners(){var e,t;const n=function(e){const t=t=>{var n;const i=t.detail;(null===(n=null==i?void 0:i.info)||void 0===n?void 0:n.rdns)&&(null==i?void 0:i.provider)&&(U.set(i.info.rdns,i),e(i))};return window.addEventListener("eip6963:announceProvider",t),()=>window.removeEventListener("eip6963:announceProvider",t)}(e=>{this.handleLateEIP6963Provider(e)});if(this.walletListenerCleanups.push(n),(null===(e=window.ethereum)||void 0===e?void 0:e.on)&&0===_().size){const e=e=>{const t=e;if(t[0]){const e=t[0],n=q();this.sendWalletInfo(e,{provider:null!=n?n:void 0}).catch(()=>{})}};window.ethereum.on("accountsChanged",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.ethereum)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"accountsChanged",e)})}if(null===(t=window.solana)||void 0===t?void 0:t.on){const e=()=>{var e;if(null===(e=window.solana)||void 0===e?void 0:e.publicKey){const e=B();this.sendWalletInfo(window.solana.publicKey.toString(),{provider:null!=e?e:void 0}).catch(()=>{})}};window.solana.on("connect",e),this.walletListenerCleanups.push(()=>{var t,n;null===(n=null===(t=window.solana)||void 0===t?void 0:t.removeListener)||void 0===n||n.call(t,"connect",e)})}}setupEIP6963AccountListeners(){const e=_();for(const[,t]of e)this.attachEIP6963AccountsChanged(t)}handleLateEIP6963Provider(e){const{info:t,provider:n}=e;n.request&&n.request({method:"eth_accounts"}).then(e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})}).catch(()=>{}),this.attachEIP6963AccountsChanged(e)}attachEIP6963AccountsChanged(e){const{info:t,provider:n}=e;if(!n.on)return;const i=e=>{const n=e;if(Array.isArray(n))for(const e of n)"string"==typeof e&&e.length>0&&this.sendWalletInfo(e,{provider:t.name,providerRdns:t.rdns}).catch(()=>{})};n.on("accountsChanged",i),this.walletListenerCleanups.push(()=>{var e;null===(e=n.removeListener)||void 0===e||e.call(n,"accountsChanged",i)})}userInfo(e,n){return t(this,void 0,void 0,function*(){const t=f(),i=v();e&&localStorage.setItem("luc_uid",e);const r=Object.assign({user:{name:e,userInfo:n},session:i},t&&{lid:t});yield this.httpClient.post("/api/sdk/user",r)})}pageView(e){return t(this,void 0,void 0,function*(){const t=f(),n=v(),i=Object.assign({page:e,user:{name:m()},session:n},t&&{lid:t});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(e,n,i){return t(this,void 0,void 0,function*(){const t=f(),r=v(),o=Object.assign({tag:e,amount:n,event:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(e,n){return t(this,void 0,void 0,function*(){const t=f(),i=v(),r=Object.assign(Object.assign({button:e,user:{name:m()},session:i},t&&{lid:t}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o;if(!e||"string"!=typeof e)return;const s=e.startsWith("0x")?e.toLowerCase():e;if(this.sentWallets.has(s))return;this.sentWallets.add(s);let a={};n&&"object"==typeof n?a=n:void 0!==n&&(a={chainId:"number"==typeof n?n:void 0,provider:i});const l=f(),c=v(),d=Object.assign(Object.assign(Object.assign(Object.assign({walletAddress:e,provider:null!==(t=a.provider)&&void 0!==t?t:null,providerRdns:null!==(r=a.providerRdns)&&void 0!==r?r:null,connectorType:null!==(o=a.connectorType)&&void 0!==o?o:null},null!=a.chainId&&{chainId:a.chainId}),i&&{walletName:i}),{user:{name:m()},session:c}),l&&{lid:l});try{yield this.httpClient.post("/api/sdk/wallet",d)}catch(e){throw this.sentWallets.delete(s),e}})}trackUserAcquisition(e){return t(this,arguments,void 0,function*(e,t={}){const n=yield S(),i=E(),r=v();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){y.destroyAll(),this.walletListenerCleanups.forEach(e=>e()),this.walletListenerCleanups=[],this.sentWallets.clear(),M&&($&&(window.removeEventListener("eip6963:announceProvider",$),$=null),U.clear(),M=!1)}},F=null;const Q=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},H={init:e=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(F)return F;if(window.__luciaInitPromise)return F=window.__luciaInitPromise,F;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=t(void 0,void 0,void 0,function*(){const t=new z(e);return yield t.init(),t});return F=n,window.__luciaInitPromise=n,n},userInfo:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(e,n)}),pageView:e=>t(void 0,void 0,void 0,function*(){return(yield Q()).pageView(e)}),trackConversion:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(e,n,i)}),buttonClick:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(e,n)}),sendWalletInfo:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(e,n,i)}),trackUserAcquisition:(e,...n)=>t(void 0,[e,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:i};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}e.__resetInstance=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),F=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,y.reset()},e.default=H,e.detectEvmProvider=q,e.detectSolanaProvider=B,e.filterObject=function(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t},e.getApplePayAvailable=x,e.getBrowserData=S,e.getCanvasFingerprint=j,e.getColorGamut=R,e.getContrastPreference=W,e.getUtmParams=E,e.isTouchEnabled=D,e.safeAccess=L,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lucia-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"description": "Lucia JavaScript Library",
|
|
6
6
|
"repository": {
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@commitlint/config-conventional": "^20.2.0",
|
|
40
|
+
"@eslint/js": "^10.0.1",
|
|
40
41
|
"@release-it/conventional-changelog": "^10.0.4",
|
|
41
42
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
42
43
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
43
44
|
"@rollup/plugin-replace": "^6.0.3",
|
|
44
|
-
"@rollup/plugin-terser": "^0.
|
|
45
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
45
46
|
"@testing-library/jest-dom": "^6.9.1",
|
|
46
47
|
"@types/jest": "^30.0.0",
|
|
47
48
|
"@types/uuid": "^11.0.0",
|
|
48
49
|
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
49
50
|
"@typescript-eslint/parser": "^8.50.1",
|
|
50
|
-
"typescript-eslint": "^8.50.1",
|
|
51
51
|
"commitlint": "^20.2.0",
|
|
52
|
-
"eslint": "^
|
|
52
|
+
"eslint": "^10.0.0",
|
|
53
53
|
"eslint-config-prettier": "^10.1.8",
|
|
54
54
|
"eslint-plugin-import": "^2.32.0",
|
|
55
55
|
"eslint-plugin-jest": "^29.11.0",
|
|
56
56
|
"eslint-plugin-promise": "^7.2.1",
|
|
57
|
-
"eslint-plugin-unicorn": "^
|
|
57
|
+
"eslint-plugin-unicorn": "^63.0.0",
|
|
58
58
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
59
59
|
"husky": "^9.1.7",
|
|
60
60
|
"jest": "^30.2.0",
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
"rollup": "^4.54.0",
|
|
67
67
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
68
68
|
"ts-jest": "^29.4.6",
|
|
69
|
-
"typescript": "^5.9.3"
|
|
69
|
+
"typescript": "^5.9.3",
|
|
70
|
+
"typescript-eslint": "^8.50.1"
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"uuid": "^13.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const i="0.9.13";class r{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new n(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(e){return t(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const t=yield fetch(`${this.baseURL}${e}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i}});return yield t.json()}catch(e){this.logger.log("error",e)}return null})}post(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return t(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const e=()=>t(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const t=this.requestQueue.shift();try{const e=yield this.executePost(t.url,t.data,t.fireAndForget);t.resolve(e)}catch(e){t.reject(e)}yield e()});yield e()}finally{this.isProcessingQueue=!1}}})}executePost(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(n&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const n=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i},body:JSON.stringify(t)});return yield n.json()}catch(e){this.logger.log("error",e)}return null})}}class o{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(o.store).includes(t)){const n=e[t];o.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}o.store={isInitialized:!1,config:null,session:null};const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function u(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}(i)}const d="luci_session",h=new n(o.store);function g(){try{const e=sessionStorage.getItem(d);return e?JSON.parse(e):null}catch(e){return h.log("error","Error retrieving session data:",e),null}}function f(){var e;const t={id:c.randomUUID&&!e?c.randomUUID():u(e),timestamp:Date.now()};return sessionStorage.setItem(d,JSON.stringify(t)),t}function w(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function m(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class p{constructor(e){this.store=o.store,this.dispatch=o.dispatch,this.dispatch({config:e}),this.httpClient=new r(this.store),this.logger=new n(this.store)}}class y{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const v=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},b=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],k=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const C=new class{constructor(e=[]){this.sensitiveSelectors=[...b,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&k.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},T=["button","a[href]",'[role="button"]'],A=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class S extends y{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:T,ignore:null!==(s=t.ignore)&&void 0!==s?s:A},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=C}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||T;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==T){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||A).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const I={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new S(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},P=new n(o.store);function E(){return t(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return P.log("error","Error checking connected wallet:",e),null}})}function O(){return t(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return P.log("error","Error getting wallet name:",e),null}})}function x(){return t(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const j=new n(o.store);function D(){return t(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){j.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return j.log("error","Error detecting Solana wallet:",e),null}})}function W(){return t(this,void 0,void 0,function*(){var e,t,n;const i=yield D();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function M(){return t(this,void 0,void 0,function*(){if($)return $;const e={device:{cores:L(()=>navigator.hardwareConcurrency),memory:L(()=>navigator.deviceMemory),cpuClass:L(()=>navigator.cpuClass),touch:N(),devicePixelRatio:L(()=>window.devicePixelRatio)},screen:{width:L(()=>window.screen.width),height:L(()=>window.screen.height),colorDepth:L(()=>window.screen.colorDepth),availHeight:L(()=>window.screen.availHeight),availWidth:L(()=>window.screen.availWidth),orientation:{type:L(()=>window.screen.orientation.type),angle:L(()=>window.screen.orientation.angle)}},browser:{language:L(()=>navigator.language),encoding:L(()=>TextDecoder.encoding),timezone:L(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:L(()=>navigator.plugins.length),pluginNames:L(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:B(),uniqueHash:yield _(),colorGamut:z(),contrastPreference:q()},permissions:{navPer:L(()=>navigator.permissions.webglVersion),renderedPer:L(()=>navigator.permissions.RENDERER),geoPer:L(()=>navigator.permissions.geolocation)},storage:{localStorage:L(()=>!!window.localStorage),indexedDB:L(()=>!!window.indexedDB),openDB:L(()=>window.openDatabase)}};return $=e,e})}function R(){return t(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([D(),E(),O(),W(),x()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&K(r),walletName:n,solWalletName:i}})}function U(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function L(e,t){try{return e()}catch(e){return t}}function K(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let $=null;function _(){return t(this,void 0,void 0,function*(){try{const e=document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;e.width=i,e.height=r,e.style.width=`${i}px`,e.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(e){return t(this,void 0,void 0,function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function N(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function B(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function q(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function z(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}v.register(I);let V=class extends p{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return t(this,void 0,void 0,function*(){let e=g();e||(e=f());const t=yield M(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield R(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:m()},data:t,walletData:i,session:r,redirectHash:n,utm:U()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(d,JSON.stringify(t))}(o.session)),v.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g();e&&localStorage.setItem("luc_uid",e);const r=Object.assign({user:{name:e,userInfo:n},session:i},t&&{lid:t});yield this.httpClient.post("/api/sdk/user",r)})}pageView(e){return t(this,void 0,void 0,function*(){const t=w(),n=g(),i=Object.assign({page:e,user:{name:m()},session:n},t&&{lid:t});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({tag:e,amount:n,event:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g(),r=Object.assign(Object.assign({button:e,user:{name:m()},session:i},t&&{lid:t}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({walletAddress:e,chainId:n,walletName:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(e){return t(this,arguments,void 0,function*(e,t={}){const n=yield M(),i=U(),r=g();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){v.destroyAll()}},F=null;const Q=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},H={init:e=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(F)return F;if(window.__luciaInitPromise)return F=window.__luciaInitPromise,F;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=t(void 0,void 0,void 0,function*(){const t=new V(e);return yield t.init(),t});return F=n,window.__luciaInitPromise=n,n},userInfo:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(e,n)}),pageView:e=>t(void 0,void 0,void 0,function*(){return(yield Q()).pageView(e)}),trackConversion:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(e,n,i)}),buttonClick:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(e,n)}),sendWalletInfo:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(e,n,i)}),trackUserAcquisition:(e,...n)=>t(void 0,[e,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:i};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}e.__resetInstance=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),F=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,v.reset()},e.default=H,e.filterObject=K,e.getApplePayAvailable=B,e.getBrowserData=M,e.getCanvasFingerprint=_,e.getColorGamut=z,e.getContrastPreference=q,e.getUtmParams=U,e.getWalletData=R,e.isTouchEnabled=N,e.safeAccess=L,Object.defineProperty(e,"__esModule",{value:!0})});
|