lucia-sdk 0.9.2 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +10 -6
- package/dist/umd/{lucia-sdk-0.9.2.min.js → lucia-sdk-0.9.6.min.js} +1 -1
- package/dist/umd/lucia-sdk-latest.min.js +1 -1
- package/package.json +10 -6
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var o=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),a="0.9.2",s=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new o(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return n(this,arguments,void 0,function(e,t,n){var i,o,a=this;return void 0===n&&(n=!0),r(this,function(r){switch(r.label){case 0:return this.store.config?(i="/api/sdk/init"===e)||this.initComplete?i?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(r,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=r.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return r.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t=this;return r(this,function(i){switch(i.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,i.label=1;case 1:return i.trys.push([1,,3,4]),e=function(){return n(t,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=r.sent(),t.resolve(n),[3,4];case 3:return i=r.sent(),t.reject(i),[3,4];case 4:return[4,e()];case 5:return r.sent(),[2]}})})},[4,e()];case 2:return i.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,i){return n(this,arguments,void 0,function(e,n,i){var o,s,u,c,l;return void 0===i&&(i=!0),r(this,function(r){switch(r.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),s=n&&"object"==typeof n&&!Array.isArray(n)?n:{payload:n},u=JSON.stringify(t(t({},s),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return[2,r.sent()];case 4:return l=r.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),u={isInitialized:!1,config:null,session:null},c=function(){function e(){}return e.dispatch=function(n){Object.keys(n).forEach(function(r){if(Object.keys(e.store).includes(r)){var o=n[r];e.store[r]="object"==typeof o?Array.isArray(o)?i([],o,!0):t({},o):o}})},e.store=u,e}(),l=function(e){this.store=c.store,this.dispatch=c.dispatch,this.dispatch({config:e}),this.httpClient=new s(this.store),this.logger=new o(this.store)},d=['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]"],h=[/\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],f=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=i(i([],d,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&h.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),p=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],g=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:p,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=f,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||p;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==p?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||p).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),v=new o(c.store);function m(){return n(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),v.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function y(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),v.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function b(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var k=new o(c.store);function C(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return r.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=r.sent(),k.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return i=r.sent(),k.log("error","Error detecting Solana wallet:",i),[2,null];case 8:return[2]}})})}function T(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,C()];case 1:return(e=r.sent())?(null===(i=window.phantom)||void 0===i?void 0:i.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return W?[2,W]:(e={cores:P(function(){return navigator.hardwareConcurrency}),memory:P(function(){return navigator.deviceMemory}),cpuClass:P(function(){return navigator.cpuClass}),touch:O(),devicePixelRatio:P(function(){return window.devicePixelRatio})},t={width:P(function(){return window.screen.width}),height:P(function(){return window.screen.height}),colorDepth:P(function(){return window.screen.colorDepth}),availHeight:P(function(){return window.screen.availHeight}),availWidth:P(function(){return window.screen.availWidth}),orientation:{type:P(function(){return window.screen.orientation.type}),angle:P(function(){return window.screen.orientation.angle})}},s={language:P(function(){return navigator.language}),encoding:P(function(){return TextDecoder.encoding}),timezone:P(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:P(function(){return navigator.plugins.length}),pluginNames:P(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:j()},[4,D()]);case 1:return s.uniqueHash=r.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,i={navPer:P(function(){return navigator.permissions.webglVersion}),renderedPer:P(function(){return navigator.permissions.RENDERER}),geoPer:P(function(){return navigator.permissions.geolocation})},o={localStorage:P(function(){return!!window.localStorage}),indexedDB:P(function(){return!!window.indexedDB}),openDB:P(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:i,storage:o},[2,a]}})})}function A(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all([C(),m(),y(),T(),b()])];case 1:return e=r.sent(),t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&x(a),walletName:i,solWalletName:o}]}})})}function I(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function P(e,t){try{return e()}catch(e){return t}}function x(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function E(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return i=r.sent(),[2,Array.from(new Uint8Array(i)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function D(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,i=120,e.width=n,e.height=i,e.style.width="".concat(n,"px"),e.style.height="".concat(i,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,i),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,i).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,E(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}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 M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const _=[];for(let e=0;e<256;++e)_.push((e+256).toString(16).slice(1));let L;const R=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function N(e,t,n){if(K.randomUUID&&!e)return K.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!L){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(R)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(_[e[t+0]]+_[e[t+1]]+_[e[t+2]]+_[e[t+3]]+"-"+_[e[t+4]]+_[e[t+5]]+"-"+_[e[t+6]]+_[e[t+7]]+"-"+_[e[t+8]]+_[e[t+9]]+"-"+_[e[t+10]]+_[e[t+11]]+_[e[t+12]]+_[e[t+13]]+_[e[t+14]]+_[e[t+15]]).toLowerCase()}(r)}var q="luci_session",B=new o(c.store);function V(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return B.log("error","Error retrieving session data:",e),null}}function z(){var e={id:N(),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(e)),e}function Q(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var F=function(i){function o(){var e=null!==i&&i.apply(this,arguments)||this;return e.clickTracker=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,i),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return(e=V())||(e=z()),[4,S()];case 1:return t=r.sent(),n=new URL(window.location.href),i=n.searchParams.get("lucia"),[4,A()];case 2:return o=r.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:i,utm:I()},!1)];case 3:return(s=r.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new g(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:i},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return r.sent(),[2]}})})},o.prototype.pageView=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=Q(),n=V(),i={page:e,user:{name:H()},session:n},t&&(i.lid=t),[4,this.httpClient.post("/api/sdk/page",i)];case 1:return r.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={tag:e,amount:t,event:i,user:{name:H()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return r.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),o={button:e,user:{name:H()},session:i},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return r.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={walletAddress:e,chainId:t,walletName:i,user:{name:H()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return r.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return n(this,arguments,void 0,function(e,n){var i,o,a;return void 0===n&&(n={}),r(this,function(r){switch(r.label){case 0:return[4,S()];case 1:return i=r.sent(),o=I(),a=V(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:t({timestamp:(new Date).toISOString(),browserData:i,utmParams:o},n)})];case 2:return r.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(l),G=null,Z=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},J=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),G=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},X={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(G)return G;if(window.__luciaInitPromise)return G=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=n(void 0,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,(t=new F(e)).init()];case 1:return n.sent(),[2,t]}})});return G=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Z()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackConversion(e,t,i)]}})})},buttonClick:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().sendWalletInfo(e,t,i)]}})})},trackUserAcquisition:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(void 0,i([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:a};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),n=null==e?void 0:e.getAttribute("data-api-key");if(n){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(t(t(t({apiKey:n},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}export{J as __resetInstance,X as default,x as filterObject,j as getApplePayAvailable,S as getBrowserData,D as getCanvasFingerprint,U as getColorGamut,M as getContrastPreference,I as getUtmParams,A as getWalletData,O as isTouchEnabled,P as safeAccess};
|
|
1
|
+
var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var o=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),a="0.9.6",s=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new o(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return n(this,arguments,void 0,function(e,t,n){var i,o,a=this;return void 0===n&&(n=!0),r(this,function(r){switch(r.label){case 0:return this.store.config?(i="/api/sdk/init"===e)||this.initComplete?i?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(r,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=r.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return r.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t=this;return r(this,function(i){switch(i.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,i.label=1;case 1:return i.trys.push([1,,3,4]),e=function(){return n(t,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=r.sent(),t.resolve(n),[3,4];case 3:return i=r.sent(),t.reject(i),[3,4];case 4:return[4,e()];case 5:return r.sent(),[2]}})})},[4,e()];case 2:return i.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,i){return n(this,arguments,void 0,function(e,n,i){var o,s,u,c,l;return void 0===i&&(i=!0),r(this,function(r){switch(r.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),s=n&&"object"==typeof n&&!Array.isArray(n)?n:{payload:n},u=JSON.stringify(t(t({},s),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return[2,r.sent()];case 4:return l=r.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),u={isInitialized:!1,config:null,session:null},c=function(){function e(){}return e.dispatch=function(n){Object.keys(n).forEach(function(r){if(Object.keys(e.store).includes(r)){var o=n[r];e.store[r]="object"==typeof o?Array.isArray(o)?i([],o,!0):t({},o):o}})},e.store=u,e}(),l=function(e){this.store=c.store,this.dispatch=c.dispatch,this.dispatch({config:e}),this.httpClient=new s(this.store),this.logger=new o(this.store)},d=['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]"],h=[/\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],f=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=i(i([],d,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&h.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),p=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],g=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:p,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=f,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||p;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==p?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||p).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),v=new o(c.store);function m(){return n(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),v.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function y(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),v.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function b(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var k=new o(c.store);function C(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return r.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=r.sent(),k.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return i=r.sent(),k.log("error","Error detecting Solana wallet:",i),[2,null];case 8:return[2]}})})}function T(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,C()];case 1:return(e=r.sent())?(null===(i=window.phantom)||void 0===i?void 0:i.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return W?[2,W]:(e={cores:P(function(){return navigator.hardwareConcurrency}),memory:P(function(){return navigator.deviceMemory}),cpuClass:P(function(){return navigator.cpuClass}),touch:O(),devicePixelRatio:P(function(){return window.devicePixelRatio})},t={width:P(function(){return window.screen.width}),height:P(function(){return window.screen.height}),colorDepth:P(function(){return window.screen.colorDepth}),availHeight:P(function(){return window.screen.availHeight}),availWidth:P(function(){return window.screen.availWidth}),orientation:{type:P(function(){return window.screen.orientation.type}),angle:P(function(){return window.screen.orientation.angle})}},s={language:P(function(){return navigator.language}),encoding:P(function(){return TextDecoder.encoding}),timezone:P(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:P(function(){return navigator.plugins.length}),pluginNames:P(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:j()},[4,D()]);case 1:return s.uniqueHash=r.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,i={navPer:P(function(){return navigator.permissions.webglVersion}),renderedPer:P(function(){return navigator.permissions.RENDERER}),geoPer:P(function(){return navigator.permissions.geolocation})},o={localStorage:P(function(){return!!window.localStorage}),indexedDB:P(function(){return!!window.indexedDB}),openDB:P(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:i,storage:o},[2,a]}})})}function A(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all([C(),m(),y(),T(),b()])];case 1:return e=r.sent(),t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&x(a),walletName:i,solWalletName:o}]}})})}function I(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function P(e,t){try{return e()}catch(e){return t}}function x(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function E(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return i=r.sent(),[2,Array.from(new Uint8Array(i)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function D(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,i=120,e.width=n,e.height=i,e.style.width="".concat(n,"px"),e.style.height="".concat(i,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,i),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,i).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,E(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}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 M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const _=[];for(let e=0;e<256;++e)_.push((e+256).toString(16).slice(1));let L;const R=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function N(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!L){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(R)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(_[e[t+0]]+_[e[t+1]]+_[e[t+2]]+_[e[t+3]]+"-"+_[e[t+4]]+_[e[t+5]]+"-"+_[e[t+6]]+_[e[t+7]]+"-"+_[e[t+8]]+_[e[t+9]]+"-"+_[e[t+10]]+_[e[t+11]]+_[e[t+12]]+_[e[t+13]]+_[e[t+14]]+_[e[t+15]]).toLowerCase()}(r)}var q="luci_session",B=new o(c.store);function V(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return B.log("error","Error retrieving session data:",e),null}}function z(){var e,t={id:K.randomUUID&&!e?K.randomUUID():N(e),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(t)),t}function Q(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var F=function(i){function o(){var e=null!==i&&i.apply(this,arguments)||this;return e.clickTracker=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,i),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return(e=V())||(e=z()),[4,S()];case 1:return t=r.sent(),n=new URL(window.location.href),i=n.searchParams.get("lucia"),[4,A()];case 2:return o=r.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:i,utm:I()},!1)];case 3:return(s=r.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new g(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:i},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return r.sent(),[2]}})})},o.prototype.pageView=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=Q(),n=V(),i={page:e,user:{name:H()},session:n},t&&(i.lid=t),[4,this.httpClient.post("/api/sdk/page",i)];case 1:return r.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={tag:e,amount:t,event:i,user:{name:H()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return r.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),o={button:e,user:{name:H()},session:i},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return r.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={walletAddress:e,chainId:t,walletName:i,user:{name:H()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return r.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return n(this,arguments,void 0,function(e,n){var i,o,a;return void 0===n&&(n={}),r(this,function(r){switch(r.label){case 0:return[4,S()];case 1:return i=r.sent(),o=I(),a=V(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:t({timestamp:(new Date).toISOString(),browserData:i,utmParams:o},n)})];case 2:return r.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(l),G=null,Z=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},J=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),G=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},X={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(G)return G;if(window.__luciaInitPromise)return G=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=n(void 0,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,(t=new F(e)).init()];case 1:return n.sent(),[2,t]}})});return G=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Z()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackConversion(e,t,i)]}})})},buttonClick:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().sendWalletInfo(e,t,i)]}})})},trackUserAcquisition:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(void 0,i([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:a};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),n=null==e?void 0:e.getAttribute("data-api-key");if(n){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(t(t(t({apiKey:n},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}export{J as __resetInstance,X as default,x as filterObject,j as getApplePayAvailable,S as getBrowserData,D as getCanvasFingerprint,U as getColorGamut,M as getContrastPreference,I as getUtmParams,A as getWalletData,O as isTouchEnabled,P as safeAccess};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../node_modules/uuid/dist/
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../node_modules/uuid/dist/stringify.js","../node_modules/uuid/dist/rng.js","../node_modules/uuid/dist/native.js","../node_modules/uuid/dist/v4.js"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction _v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n return _v4(options, buf, offset);\n}\nexport default v4;\n"],"names":["byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","_v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify"],"mappings":"yhrBACA,MAAMA,EAAY,GAClB,IAAK,IAAIC,EAAI,EAAGA,EAAI,MAAOA,EACvBD,EAAUE,MAAMD,EAAI,KAAOE,SAAS,IAAIC,MAAM,ICHlD,IAAIC,EACJ,MAAMC,EAAQ,IAAIC,WAAW,ICA7B,IAAAC,EAAe,CAAEC,WADoB,oBAAXC,QAA0BA,OAAOD,YAAcC,OAAOD,WAAWE,KAAKD,SCGhG,SAASE,EAAIC,EAASC,EAAKC,GAEvB,MAAMC,GADNH,EAAUA,GAAW,CAAA,GACAI,QAAUJ,EAAQK,SFH5B,WACX,IAAKb,EAAiB,CAClB,GAAsB,oBAAXK,SAA2BA,OAAOL,gBACzC,MAAM,IAAIc,MAAM,4GAEpBd,EAAkBK,OAAOL,gBAAgBM,KAAKD,OAClD,CACA,OAAOL,EAAgBC,EAC3B,CELsDY,GAClD,GAAIF,EAAKI,OAAS,GACd,MAAM,IAAID,MAAM,qCAcpB,OAZAH,EAAK,GAAgB,GAAVA,EAAK,GAAa,GAC7BA,EAAK,GAAgB,GAAVA,EAAK,GAAa,IHL1B,SAAyBK,EAAKN,EAAS,GAC1C,OAAQf,EAAUqB,EAAIN,EAAS,IAC3Bf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,MAAMO,aACrC,CGLWC,CAAgBP,EAC3B,6MACYH,QACJL,EAAOC,aAAuBI,EACvBL,EAAOC,aAEXG,EAAIC","x_google_ignoreList":[0,1,2,3]}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var o=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),a="0.9.2",s=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new o(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return n(this,arguments,void 0,function(e,t,n){var i,o,a=this;return void 0===n&&(n=!0),r(this,function(r){switch(r.label){case 0:return this.store.config?(i="/api/sdk/init"===e)||this.initComplete?i?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(r,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=r.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return r.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t=this;return r(this,function(i){switch(i.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,i.label=1;case 1:return i.trys.push([1,,3,4]),e=function(){return n(t,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=r.sent(),t.resolve(n),[3,4];case 3:return i=r.sent(),t.reject(i),[3,4];case 4:return[4,e()];case 5:return r.sent(),[2]}})})},[4,e()];case 2:return i.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,i){return n(this,arguments,void 0,function(e,n,i){var o,s,u,c,l;return void 0===i&&(i=!0),r(this,function(r){switch(r.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),s=n&&"object"==typeof n&&!Array.isArray(n)?n:{payload:n},u=JSON.stringify(t(t({},s),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return[2,r.sent()];case 4:return l=r.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),u={isInitialized:!1,config:null,session:null},c=function(){function e(){}return e.dispatch=function(n){Object.keys(n).forEach(function(r){if(Object.keys(e.store).includes(r)){var o=n[r];e.store[r]="object"==typeof o?Array.isArray(o)?i([],o,!0):t({},o):o}})},e.store=u,e}(),l=function(e){this.store=c.store,this.dispatch=c.dispatch,this.dispatch({config:e}),this.httpClient=new s(this.store),this.logger=new o(this.store)},d=['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]"],h=[/\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],f=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=i(i([],d,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&h.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),p=["button","a[href]",'[role="button"]'],g=["[data-lucia-ignore]",'[data-lucia-track="false"]'],w=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:p,ignore:null!==(a=t.ignore)&&void 0!==a?a:g},this.trackingCallback=n,this.logger=r,this.privacyGuard=f,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||p;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==p?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||p).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),v=new o(c.store);function m(){return n(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),v.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function y(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),v.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function b(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var k=new o(c.store);function C(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return r.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=r.sent(),k.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return i=r.sent(),k.log("error","Error detecting Solana wallet:",i),[2,null];case 8:return[2]}})})}function T(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,C()];case 1:return(e=r.sent())?(null===(i=window.phantom)||void 0===i?void 0:i.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function A(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return D?[2,D]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:O(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,W()]);case 1:return s.uniqueHash=r.sent(),s.colorGamut=M(),s.contrastPreference=j(),n=s,i={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},D=a={device:e,screen:t,browser:n,permissions:i,storage:o},[2,a]}})})}function S(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all([C(),m(),y(),T(),b()])];case 1:return e=r.sent(),t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&P(a),walletName:i,solWalletName:o}]}})})}function I(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function P(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function E(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return i=r.sent(),[2,Array.from(new Uint8Array(i)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var D=null;function W(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,i=120,e.width=n,e.height=i,e.style.width="".concat(n,"px"),e.style.height="".concat(i,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,i),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,i).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,E(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function O(){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 j(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 M(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const U=[];for(let e=0;e<256;++e)U.push((e+256).toString(16).slice(1));let L;const R=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function N(e,t,n){if(K.randomUUID&&!e)return K.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!L){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(R)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(U[e[t+0]]+U[e[t+1]]+U[e[t+2]]+U[e[t+3]]+"-"+U[e[t+4]]+U[e[t+5]]+"-"+U[e[t+6]]+U[e[t+7]]+"-"+U[e[t+8]]+U[e[t+9]]+"-"+U[e[t+10]]+U[e[t+11]]+U[e[t+12]]+U[e[t+13]]+U[e[t+14]]+U[e[t+15]]).toLowerCase()}(r)}var B="luci_session",q=new o(c.store);function V(){try{var e=sessionStorage.getItem(B);return e?JSON.parse(e):null}catch(e){return q.log("error","Error retrieving session data:",e),null}}function z(){var e={id:N(),timestamp:Date.now()};return sessionStorage.setItem(B,JSON.stringify(e)),e}function Q(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function F(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var H=function(i){function o(){var e=null!==i&&i.apply(this,arguments)||this;return e.clickTracker=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,i),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return(e=V())||(e=z()),[4,A()];case 1:return t=r.sent(),n=new URL(window.location.href),i=n.searchParams.get("lucia"),[4,S()];case 2:return o=r.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:F()},data:t,walletData:o,session:a,redirectHash:i,utm:I()},!1)];case 3:return(s=r.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(B,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new w(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:i},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return r.sent(),[2]}})})},o.prototype.pageView=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=Q(),n=V(),i={page:e,user:{name:F()},session:n},t&&(i.lid=t),[4,this.httpClient.post("/api/sdk/page",i)];case 1:return r.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={tag:e,amount:t,event:i,user:{name:F()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return r.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),o={button:e,user:{name:F()},session:i},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return r.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={walletAddress:e,chainId:t,walletName:i,user:{name:F()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return r.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return n(this,arguments,void 0,function(e,n){var i,o,a;return void 0===n&&(n={}),r(this,function(r){switch(r.label){case 0:return[4,A()];case 1:return i=r.sent(),o=I(),a=V(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:t({timestamp:(new Date).toISOString(),browserData:i,utmParams:o},n)})];case 2:return r.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(l),G=null,Z=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},J={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(G)return G;if(window.__luciaInitPromise)return G=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=n(void 0,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,(t=new H(e)).init()];case 1:return n.sent(),[2,t]}})});return G=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Z()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackConversion(e,t,i)]}})})},buttonClick:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().sendWalletInfo(e,t,i)]}})})},trackUserAcquisition:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(void 0,i([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:a};if("undefined"!=typeof window){window.LuciaSDK=J;var X=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),n=null==e?void 0:e.getAttribute("data-api-key");if(n){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");J.init(t(t(t({apiKey:n},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",X):X()}exports.__resetInstance=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),G=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},exports.default=J,exports.filterObject=P,exports.getApplePayAvailable=_,exports.getBrowserData=A,exports.getCanvasFingerprint=W,exports.getColorGamut=M,exports.getContrastPreference=j,exports.getUtmParams=I,exports.getWalletData=S,exports.isTouchEnabled=O,exports.safeAccess=x;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var o=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),a="0.9.6",s=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new o(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return n(this,arguments,void 0,function(e,t,n){var i,o,a=this;return void 0===n&&(n=!0),r(this,function(r){switch(r.label){case 0:return this.store.config?(i="/api/sdk/init"===e)||this.initComplete?i?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(r,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=r.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return r.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t=this;return r(this,function(i){switch(i.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,i.label=1;case 1:return i.trys.push([1,,3,4]),e=function(){return n(t,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=r.sent(),t.resolve(n),[3,4];case 3:return i=r.sent(),t.reject(i),[3,4];case 4:return[4,e()];case 5:return r.sent(),[2]}})})},[4,e()];case 2:return i.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,i){return n(this,arguments,void 0,function(e,n,i){var o,s,u,c,l;return void 0===i&&(i=!0),r(this,function(r){switch(r.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),s=n&&"object"==typeof n&&!Array.isArray(n)?n:{payload:n},u=JSON.stringify(t(t({},s),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return[2,r.sent()];case 4:return l=r.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),u={isInitialized:!1,config:null,session:null},c=function(){function e(){}return e.dispatch=function(n){Object.keys(n).forEach(function(r){if(Object.keys(e.store).includes(r)){var o=n[r];e.store[r]="object"==typeof o?Array.isArray(o)?i([],o,!0):t({},o):o}})},e.store=u,e}(),l=function(e){this.store=c.store,this.dispatch=c.dispatch,this.dispatch({config:e}),this.httpClient=new s(this.store),this.logger=new o(this.store)},d=['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]"],h=[/\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],f=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=i(i([],d,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&h.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),p=["button","a[href]",'[role="button"]'],g=["[data-lucia-ignore]",'[data-lucia-track="false"]'],w=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:p,ignore:null!==(a=t.ignore)&&void 0!==a?a:g},this.trackingCallback=n,this.logger=r,this.privacyGuard=f,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||p;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==p?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||p).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),v=new o(c.store);function m(){return n(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),v.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function y(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),v.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function b(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var k=new o(c.store);function C(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return r.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=r.sent(),k.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return i=r.sent(),k.log("error","Error detecting Solana wallet:",i),[2,null];case 8:return[2]}})})}function T(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,C()];case 1:return(e=r.sent())?(null===(i=window.phantom)||void 0===i?void 0:i.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function A(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return D?[2,D]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:O(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,W()]);case 1:return s.uniqueHash=r.sent(),s.colorGamut=M(),s.contrastPreference=j(),n=s,i={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},D=a={device:e,screen:t,browser:n,permissions:i,storage:o},[2,a]}})})}function S(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all([C(),m(),y(),T(),b()])];case 1:return e=r.sent(),t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&P(a),walletName:i,solWalletName:o}]}})})}function I(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function P(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function E(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return i=r.sent(),[2,Array.from(new Uint8Array(i)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var D=null;function W(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,i=120,e.width=n,e.height=i,e.style.width="".concat(n,"px"),e.style.height="".concat(i,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,i),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,i).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,E(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function O(){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 j(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 M(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const U=[];for(let e=0;e<256;++e)U.push((e+256).toString(16).slice(1));let L;const R=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function N(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!L){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(R)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(U[e[t+0]]+U[e[t+1]]+U[e[t+2]]+U[e[t+3]]+"-"+U[e[t+4]]+U[e[t+5]]+"-"+U[e[t+6]]+U[e[t+7]]+"-"+U[e[t+8]]+U[e[t+9]]+"-"+U[e[t+10]]+U[e[t+11]]+U[e[t+12]]+U[e[t+13]]+U[e[t+14]]+U[e[t+15]]).toLowerCase()}(r)}var B="luci_session",q=new o(c.store);function V(){try{var e=sessionStorage.getItem(B);return e?JSON.parse(e):null}catch(e){return q.log("error","Error retrieving session data:",e),null}}function z(){var e,t={id:K.randomUUID&&!e?K.randomUUID():N(e),timestamp:Date.now()};return sessionStorage.setItem(B,JSON.stringify(t)),t}function Q(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function F(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var H=function(i){function o(){var e=null!==i&&i.apply(this,arguments)||this;return e.clickTracker=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,i),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return(e=V())||(e=z()),[4,A()];case 1:return t=r.sent(),n=new URL(window.location.href),i=n.searchParams.get("lucia"),[4,S()];case 2:return o=r.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:F()},data:t,walletData:o,session:a,redirectHash:i,utm:I()},!1)];case 3:return(s=r.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(B,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new w(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:i},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return r.sent(),[2]}})})},o.prototype.pageView=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=Q(),n=V(),i={page:e,user:{name:F()},session:n},t&&(i.lid=t),[4,this.httpClient.post("/api/sdk/page",i)];case 1:return r.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={tag:e,amount:t,event:i,user:{name:F()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return r.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),o={button:e,user:{name:F()},session:i},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return r.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={walletAddress:e,chainId:t,walletName:i,user:{name:F()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return r.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return n(this,arguments,void 0,function(e,n){var i,o,a;return void 0===n&&(n={}),r(this,function(r){switch(r.label){case 0:return[4,A()];case 1:return i=r.sent(),o=I(),a=V(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:t({timestamp:(new Date).toISOString(),browserData:i,utmParams:o},n)})];case 2:return r.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(l),G=null,Z=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},J={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(G)return G;if(window.__luciaInitPromise)return G=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=n(void 0,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,(t=new H(e)).init()];case 1:return n.sent(),[2,t]}})});return G=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Z()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackConversion(e,t,i)]}})})},buttonClick:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().sendWalletInfo(e,t,i)]}})})},trackUserAcquisition:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(void 0,i([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:a};if("undefined"!=typeof window){window.LuciaSDK=J;var X=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),n=null==e?void 0:e.getAttribute("data-api-key");if(n){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");J.init(t(t(t({apiKey:n},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",X):X()}exports.__resetInstance=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),G=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},exports.default=J,exports.filterObject=P,exports.getApplePayAvailable=_,exports.getBrowserData=A,exports.getCanvasFingerprint=W,exports.getColorGamut=M,exports.getContrastPreference=j,exports.getUtmParams=I,exports.getWalletData=S,exports.isTouchEnabled=O,exports.safeAccess=x;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../node_modules/uuid/dist/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../node_modules/uuid/dist/stringify.js","../node_modules/uuid/dist/rng.js","../node_modules/uuid/dist/native.js","../node_modules/uuid/dist/v4.js"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction _v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n return _v4(options, buf, offset);\n}\nexport default v4;\n"],"names":["byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","_v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify"],"mappings":"6lrBACA,MAAMA,EAAY,GAClB,IAAK,IAAIC,EAAI,EAAGA,EAAI,MAAOA,EACvBD,EAAUE,MAAMD,EAAI,KAAOE,SAAS,IAAIC,MAAM,ICHlD,IAAIC,EACJ,MAAMC,EAAQ,IAAIC,WAAW,ICA7B,IAAAC,EAAe,CAAEC,WADoB,oBAAXC,QAA0BA,OAAOD,YAAcC,OAAOD,WAAWE,KAAKD,SCGhG,SAASE,EAAIC,EAASC,EAAKC,GAEvB,MAAMC,GADNH,EAAUA,GAAW,CAAA,GACAI,QAAUJ,EAAQK,SFH5B,WACX,IAAKb,EAAiB,CAClB,GAAsB,oBAAXK,SAA2BA,OAAOL,gBACzC,MAAM,IAAIc,MAAM,4GAEpBd,EAAkBK,OAAOL,gBAAgBM,KAAKD,OAClD,CACA,OAAOL,EAAgBC,EAC3B,CELsDY,GAClD,GAAIF,EAAKI,OAAS,GACd,MAAM,IAAID,MAAM,qCAcpB,OAZAH,EAAK,GAAgB,GAAVA,EAAK,GAAa,GAC7BA,EAAK,GAAgB,GAAVA,EAAK,GAAa,IHL1B,SAAyBK,EAAKN,EAAS,GAC1C,OAAQf,EAAUqB,EAAIN,EAAS,IAC3Bf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,MAAMO,aACrC,CGLWC,CAAgBP,EAC3B,6MACYH,QACJL,EAAOC,aAAuBI,EACvBL,EAAOC,aAEXG,EAAIC","x_google_ignoreList":[0,1,2,3]}
|
package/dist/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lucia-sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"description": "Lucia JavaScript Library",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/ondecentral/Lucia-Browser-SDK.git"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"main": "dist/index.js",
|
|
8
12
|
"module": "dist/index.es.js",
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
"package:publish": "yarn package:build && npm publish --access public",
|
|
24
28
|
"tsc": "tsc --pretty --noEmit",
|
|
25
29
|
"prepare": "yarn package:build",
|
|
26
|
-
"
|
|
30
|
+
"postinstall": "husky || true",
|
|
27
31
|
"validate": "npm-run-all --parallel lint tsc",
|
|
28
32
|
"commitlint": "commitlint",
|
|
29
33
|
"lint": "eslint .",
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
"@rollup/plugin-replace": "^6.0.3",
|
|
40
44
|
"@rollup/plugin-terser": "^0.4.4",
|
|
41
45
|
"@testing-library/jest-dom": "^6.9.1",
|
|
42
|
-
"@types/jest": "^
|
|
46
|
+
"@types/jest": "^30.0.0",
|
|
43
47
|
"@types/uuid": "^10.0.0",
|
|
44
48
|
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
45
49
|
"@typescript-eslint/parser": "^8.50.1",
|
|
@@ -53,8 +57,8 @@
|
|
|
53
57
|
"eslint-plugin-unicorn": "^62.0.0",
|
|
54
58
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
55
59
|
"husky": "^9.1.7",
|
|
56
|
-
"jest": "^
|
|
57
|
-
"jest-environment-jsdom": "^
|
|
60
|
+
"jest": "^30.2.0",
|
|
61
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
58
62
|
"lint-staged": "^16.2.7",
|
|
59
63
|
"npm-run-all": "^4.1.5",
|
|
60
64
|
"prettier": "^3.7.4",
|
|
@@ -65,7 +69,7 @@
|
|
|
65
69
|
"typescript": "^5.9.3"
|
|
66
70
|
},
|
|
67
71
|
"dependencies": {
|
|
68
|
-
"uuid": "^
|
|
72
|
+
"uuid": "^13.0.0"
|
|
69
73
|
},
|
|
70
74
|
"resolutions": {
|
|
71
75
|
"conventional-changelog-conventionalcommits": "^9.1.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";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),s="0.9.2",u=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new a(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return r(this,arguments,void 0,function(e,t,n){var r,o,a=this;return void 0===n&&(n=!0),i(this,function(i){switch(i.label){case 0:return this.store.config?(r="/api/sdk/init"===e)||this.initComplete?r?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(i,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:i,reject:o,isInit:r}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=i.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return i.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return r(this,void 0,void 0,function(){var e,t=this;return i(this,function(n){switch(n.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),e=function(){return r(t,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=i.sent(),t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[4,e()];case 5:return i.sent(),[2]}})})},[4,e()];case 2:return n.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,t){return r(this,arguments,void 0,function(e,t,r){var o,a,u,c,l;return void 0===r&&(r=!0),i(this,function(i){switch(i.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(r&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),a=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},u=JSON.stringify(n(n({},a),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s},body:JSON.stringify(t)})];case 2:return[4,i.sent().json()];case 3:return[2,i.sent()];case 4:return l=i.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),c={isInitialized:!1,config:null,session:null},l=function(){function e(){}return e.dispatch=function(t){Object.keys(t).forEach(function(r){if(Object.keys(e.store).includes(r)){var i=t[r];e.store[r]="object"==typeof i?Array.isArray(i)?o([],i,!0):n({},i):i}})},e.store=c,e}(),d=function(e){this.store=l.store,this.dispatch=l.dispatch,this.dispatch({config:e}),this.httpClient=new u(this.store),this.logger=new a(this.store)},h=['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]"],f=[/\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],p=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=o(o([],h,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&f.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),g=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],v=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:g,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=p,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||g;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==g?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),m=new a(l.store);function y(){return r(this,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),m.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function b(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),m.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function k(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var C=new a(l.store);function T(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return i.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=i.sent(),C.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return r=i.sent(),C.log("error","Error detecting Solana wallet:",r),[2,null];case 8:return[2]}})})}function A(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,T()];case 1:return(e=i.sent())?(null===(r=window.phantom)||void 0===r?void 0:r.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return W?[2,W]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:j(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,O()]);case 1:return s.uniqueHash=i.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,r={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:r,storage:o},[2,a]}})})}function I(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all([T(),y(),b(),A(),k()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&E(a),walletName:r,solWalletName:o}]}})})}function P(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function E(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function D(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return r=i.sent(),[2,Array.from(new Uint8Array(r)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function O(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,r=120,e.width=n,e.height=r,e.style.width="".concat(n,"px"),e.style.height="".concat(r,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,r),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,r).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,D(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function j(){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 M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const L=[];for(let e=0;e<256;++e)L.push((e+256).toString(16).slice(1));let R;const K=new Uint8Array(16);var N={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function B(e,t,n){if(N.randomUUID&&!e)return N.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!R){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(K)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(L[e[t+0]]+L[e[t+1]]+L[e[t+2]]+L[e[t+3]]+"-"+L[e[t+4]]+L[e[t+5]]+"-"+L[e[t+6]]+L[e[t+7]]+"-"+L[e[t+8]]+L[e[t+9]]+"-"+L[e[t+10]]+L[e[t+11]]+L[e[t+12]]+L[e[t+13]]+L[e[t+14]]+L[e[t+15]]).toLowerCase()}(r)}var q="luci_session",V=new a(l.store);function z(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return V.log("error","Error retrieving session data:",e),null}}function Q(){var e={id:B(),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(e)),e}function F(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var G=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.clickTracker=null,t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,e),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return(e=z())||(e=Q()),[4,S()];case 1:return t=i.sent(),n=new URL(window.location.href),r=n.searchParams.get("lucia"),[4,I()];case 2:return o=i.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:r,utm:P()},!1)];case 3:return(s=i.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new v(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:r},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return i.sent(),[2]}})})},o.prototype.pageView=function(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=F(),n=z(),r={page:e,user:{name:H()},session:n},t&&(r.lid=t),[4,this.httpClient.post("/api/sdk/page",r)];case 1:return i.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={tag:e,amount:t,event:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return i.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),o={button:e,user:{name:H()},session:r},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return i.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={walletAddress:e,chainId:t,walletName:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return i.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return r(this,arguments,void 0,function(e,t){var r,o,a;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return[4,S()];case 1:return r=i.sent(),o=P(),a=z(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:n({timestamp:(new Date).toISOString(),browserData:r,utmParams:o},t)})];case 2:return i.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(d),Z=null,J=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},X={init:function(e){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;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=r(void 0,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,(t=new G(e)).init()];case 1:return n.sent(),[2,t]}})});return Z=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return r(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,J()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().trackConversion(e,t,n)]}})})},buttonClick:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().sendWalletInfo(e,t,n)]}})})},trackUserAcquisition:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return r(void 0,o([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:s};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(t){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(n(n(n({apiKey:t},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}e.__resetInstance=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),Z=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},e.default=X,e.filterObject=E,e.getApplePayAvailable=_,e.getBrowserData=S,e.getCanvasFingerprint=O,e.getColorGamut=U,e.getContrastPreference=M,e.getUtmParams=P,e.getWalletData=I,e.isTouchEnabled=j,e.safeAccess=x,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";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),s="0.9.6",u=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new a(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return r(this,arguments,void 0,function(e,t,n){var r,o,a=this;return void 0===n&&(n=!0),i(this,function(i){switch(i.label){case 0:return this.store.config?(r="/api/sdk/init"===e)||this.initComplete?r?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(i,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:i,reject:o,isInit:r}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=i.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return i.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return r(this,void 0,void 0,function(){var e,t=this;return i(this,function(n){switch(n.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),e=function(){return r(t,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=i.sent(),t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[4,e()];case 5:return i.sent(),[2]}})})},[4,e()];case 2:return n.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,t){return r(this,arguments,void 0,function(e,t,r){var o,a,u,c,l;return void 0===r&&(r=!0),i(this,function(i){switch(i.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(r&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),a=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},u=JSON.stringify(n(n({},a),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s},body:JSON.stringify(t)})];case 2:return[4,i.sent().json()];case 3:return[2,i.sent()];case 4:return l=i.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),c={isInitialized:!1,config:null,session:null},l=function(){function e(){}return e.dispatch=function(t){Object.keys(t).forEach(function(r){if(Object.keys(e.store).includes(r)){var i=t[r];e.store[r]="object"==typeof i?Array.isArray(i)?o([],i,!0):n({},i):i}})},e.store=c,e}(),d=function(e){this.store=l.store,this.dispatch=l.dispatch,this.dispatch({config:e}),this.httpClient=new u(this.store),this.logger=new a(this.store)},h=['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]"],f=[/\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],p=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=o(o([],h,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&f.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),g=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],v=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:g,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=p,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||g;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==g?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),m=new a(l.store);function y(){return r(this,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),m.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function b(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),m.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function k(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var C=new a(l.store);function T(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return i.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=i.sent(),C.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return r=i.sent(),C.log("error","Error detecting Solana wallet:",r),[2,null];case 8:return[2]}})})}function A(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,T()];case 1:return(e=i.sent())?(null===(r=window.phantom)||void 0===r?void 0:r.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return W?[2,W]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:j(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,O()]);case 1:return s.uniqueHash=i.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,r={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:r,storage:o},[2,a]}})})}function I(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all([T(),y(),b(),A(),k()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&E(a),walletName:r,solWalletName:o}]}})})}function P(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function E(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function D(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return r=i.sent(),[2,Array.from(new Uint8Array(r)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function O(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,r=120,e.width=n,e.height=r,e.style.width="".concat(n,"px"),e.style.height="".concat(r,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,r),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,r).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,D(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function j(){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 M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const L=[];for(let e=0;e<256;++e)L.push((e+256).toString(16).slice(1));let R;const K=new Uint8Array(16);var N={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function B(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!R){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(K)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(L[e[t+0]]+L[e[t+1]]+L[e[t+2]]+L[e[t+3]]+"-"+L[e[t+4]]+L[e[t+5]]+"-"+L[e[t+6]]+L[e[t+7]]+"-"+L[e[t+8]]+L[e[t+9]]+"-"+L[e[t+10]]+L[e[t+11]]+L[e[t+12]]+L[e[t+13]]+L[e[t+14]]+L[e[t+15]]).toLowerCase()}(r)}var q="luci_session",V=new a(l.store);function z(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return V.log("error","Error retrieving session data:",e),null}}function Q(){var e,t={id:N.randomUUID&&!e?N.randomUUID():B(e),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(t)),t}function F(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var G=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.clickTracker=null,t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,e),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return(e=z())||(e=Q()),[4,S()];case 1:return t=i.sent(),n=new URL(window.location.href),r=n.searchParams.get("lucia"),[4,I()];case 2:return o=i.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:r,utm:P()},!1)];case 3:return(s=i.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new v(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:r},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return i.sent(),[2]}})})},o.prototype.pageView=function(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=F(),n=z(),r={page:e,user:{name:H()},session:n},t&&(r.lid=t),[4,this.httpClient.post("/api/sdk/page",r)];case 1:return i.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={tag:e,amount:t,event:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return i.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),o={button:e,user:{name:H()},session:r},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return i.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={walletAddress:e,chainId:t,walletName:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return i.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return r(this,arguments,void 0,function(e,t){var r,o,a;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return[4,S()];case 1:return r=i.sent(),o=P(),a=z(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:n({timestamp:(new Date).toISOString(),browserData:r,utmParams:o},t)})];case 2:return i.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(d),Z=null,J=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},X={init:function(e){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;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=r(void 0,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,(t=new G(e)).init()];case 1:return n.sent(),[2,t]}})});return Z=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return r(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,J()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().trackConversion(e,t,n)]}})})},buttonClick:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().sendWalletInfo(e,t,n)]}})})},trackUserAcquisition:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return r(void 0,o([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:s};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(t){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(n(n(n({apiKey:t},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}e.__resetInstance=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),Z=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},e.default=X,e.filterObject=E,e.getApplePayAvailable=_,e.getBrowserData=S,e.getCanvasFingerprint=O,e.getColorGamut=U,e.getContrastPreference=M,e.getUtmParams=P,e.getWalletData=I,e.isTouchEnabled=j,e.safeAccess=x,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";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),s="0.9.2",u=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new a(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return r(this,arguments,void 0,function(e,t,n){var r,o,a=this;return void 0===n&&(n=!0),i(this,function(i){switch(i.label){case 0:return this.store.config?(r="/api/sdk/init"===e)||this.initComplete?r?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(i,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:i,reject:o,isInit:r}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=i.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return i.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return r(this,void 0,void 0,function(){var e,t=this;return i(this,function(n){switch(n.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),e=function(){return r(t,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=i.sent(),t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[4,e()];case 5:return i.sent(),[2]}})})},[4,e()];case 2:return n.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,t){return r(this,arguments,void 0,function(e,t,r){var o,a,u,c,l;return void 0===r&&(r=!0),i(this,function(i){switch(i.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(r&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),a=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},u=JSON.stringify(n(n({},a),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s},body:JSON.stringify(t)})];case 2:return[4,i.sent().json()];case 3:return[2,i.sent()];case 4:return l=i.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),c={isInitialized:!1,config:null,session:null},l=function(){function e(){}return e.dispatch=function(t){Object.keys(t).forEach(function(r){if(Object.keys(e.store).includes(r)){var i=t[r];e.store[r]="object"==typeof i?Array.isArray(i)?o([],i,!0):n({},i):i}})},e.store=c,e}(),d=function(e){this.store=l.store,this.dispatch=l.dispatch,this.dispatch({config:e}),this.httpClient=new u(this.store),this.logger=new a(this.store)},h=['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]"],f=[/\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],p=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=o(o([],h,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&f.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),g=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],v=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:g,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=p,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||g;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==g?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),m=new a(l.store);function y(){return r(this,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),m.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function b(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),m.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function k(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var C=new a(l.store);function T(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return i.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=i.sent(),C.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return r=i.sent(),C.log("error","Error detecting Solana wallet:",r),[2,null];case 8:return[2]}})})}function A(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,T()];case 1:return(e=i.sent())?(null===(r=window.phantom)||void 0===r?void 0:r.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return W?[2,W]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:j(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,O()]);case 1:return s.uniqueHash=i.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,r={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:r,storage:o},[2,a]}})})}function I(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all([T(),y(),b(),A(),k()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&E(a),walletName:r,solWalletName:o}]}})})}function P(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function E(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function D(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return r=i.sent(),[2,Array.from(new Uint8Array(r)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function O(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,r=120,e.width=n,e.height=r,e.style.width="".concat(n,"px"),e.style.height="".concat(r,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,r),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,r).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,D(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function j(){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 M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const L=[];for(let e=0;e<256;++e)L.push((e+256).toString(16).slice(1));let R;const K=new Uint8Array(16);var N={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function B(e,t,n){if(N.randomUUID&&!e)return N.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!R){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(K)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(L[e[t+0]]+L[e[t+1]]+L[e[t+2]]+L[e[t+3]]+"-"+L[e[t+4]]+L[e[t+5]]+"-"+L[e[t+6]]+L[e[t+7]]+"-"+L[e[t+8]]+L[e[t+9]]+"-"+L[e[t+10]]+L[e[t+11]]+L[e[t+12]]+L[e[t+13]]+L[e[t+14]]+L[e[t+15]]).toLowerCase()}(r)}var q="luci_session",V=new a(l.store);function z(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return V.log("error","Error retrieving session data:",e),null}}function Q(){var e={id:B(),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(e)),e}function F(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var G=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.clickTracker=null,t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,e),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return(e=z())||(e=Q()),[4,S()];case 1:return t=i.sent(),n=new URL(window.location.href),r=n.searchParams.get("lucia"),[4,I()];case 2:return o=i.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:r,utm:P()},!1)];case 3:return(s=i.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new v(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:r},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return i.sent(),[2]}})})},o.prototype.pageView=function(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=F(),n=z(),r={page:e,user:{name:H()},session:n},t&&(r.lid=t),[4,this.httpClient.post("/api/sdk/page",r)];case 1:return i.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={tag:e,amount:t,event:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return i.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),o={button:e,user:{name:H()},session:r},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return i.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={walletAddress:e,chainId:t,walletName:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return i.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return r(this,arguments,void 0,function(e,t){var r,o,a;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return[4,S()];case 1:return r=i.sent(),o=P(),a=z(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:n({timestamp:(new Date).toISOString(),browserData:r,utmParams:o},t)})];case 2:return i.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(d),Z=null,J=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},X={init:function(e){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;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=r(void 0,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,(t=new G(e)).init()];case 1:return n.sent(),[2,t]}})});return Z=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return r(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,J()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().trackConversion(e,t,n)]}})})},buttonClick:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().sendWalletInfo(e,t,n)]}})})},trackUserAcquisition:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return r(void 0,o([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:s};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(t){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(n(n(n({apiKey:t},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}e.__resetInstance=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),Z=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},e.default=X,e.filterObject=E,e.getApplePayAvailable=_,e.getBrowserData=S,e.getCanvasFingerprint=O,e.getColorGamut=U,e.getContrastPreference=M,e.getUtmParams=P,e.getWalletData=I,e.isTouchEnabled=j,e.safeAccess=x,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";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),s="0.9.6",u=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new a(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;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"},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return r(this,arguments,void 0,function(e,t,n){var r,o,a=this;return void 0===n&&(n=!0),i(this,function(i){switch(i.label){case 0:return this.store.config?(r="/api/sdk/init"===e)||this.initComplete?r?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(i,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:i,reject:o,isInit:r}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=i.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return i.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return r(this,void 0,void 0,function(){var e,t=this;return i(this,function(n){switch(n.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),e=function(){return r(t,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=i.sent(),t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[4,e()];case 5:return i.sent(),[2]}})})},[4,e()];case 2:return n.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,t){return r(this,arguments,void 0,function(e,t,r){var o,a,u,c,l;return void 0===r&&(r=!0),i(this,function(i){switch(i.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(r&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),a=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},u=JSON.stringify(n(n({},a),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s},body:JSON.stringify(t)})];case 2:return[4,i.sent().json()];case 3:return[2,i.sent()];case 4:return l=i.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),c={isInitialized:!1,config:null,session:null},l=function(){function e(){}return e.dispatch=function(t){Object.keys(t).forEach(function(r){if(Object.keys(e.store).includes(r)){var i=t[r];e.store[r]="object"==typeof i?Array.isArray(i)?o([],i,!0):n({},i):i}})},e.store=c,e}(),d=function(e){this.store=l.store,this.dispatch=l.dispatch,this.dispatch({config:e}),this.httpClient=new u(this.store),this.logger=new a(this.store)},h=['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]"],f=[/\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],p=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=o(o([],h,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&f.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),g=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],v=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:g,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=p,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){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"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||g;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==g?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var 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)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var 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:".concat(this.sanitizeText(s).substring(0,50));var u=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:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),m=new a(l.store);function y(){return r(this,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),m.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function b(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),m.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function k(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){return window.ethereum?(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:""},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";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var C=new a(l.store);function T(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return i.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=i.sent(),C.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return r=i.sent(),C.log("error","Error detecting Solana wallet:",r),[2,null];case 8:return[2]}})})}function A(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,T()];case 1:return(e=i.sent())?(null===(r=window.phantom)||void 0===r?void 0:r.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return W?[2,W]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:j(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,O()]);case 1:return s.uniqueHash=i.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,r={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:r,storage:o},[2,a]}})})}function I(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all([T(),y(),b(),A(),k()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&E(a),walletName:r,solWalletName:o}]}})})}function P(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function E(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function D(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return r=i.sent(),[2,Array.from(new Uint8Array(r)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function O(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,r=120,e.width=n,e.height=r,e.style.width="".concat(n,"px"),e.style.height="".concat(r,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,r),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,r).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,D(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function j(){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 M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(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 U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const L=[];for(let e=0;e<256;++e)L.push((e+256).toString(16).slice(1));let R;const K=new Uint8Array(16);var N={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function B(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!R){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(K)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(L[e[t+0]]+L[e[t+1]]+L[e[t+2]]+L[e[t+3]]+"-"+L[e[t+4]]+L[e[t+5]]+"-"+L[e[t+6]]+L[e[t+7]]+"-"+L[e[t+8]]+L[e[t+9]]+"-"+L[e[t+10]]+L[e[t+11]]+L[e[t+12]]+L[e[t+13]]+L[e[t+14]]+L[e[t+15]]).toLowerCase()}(r)}var q="luci_session",V=new a(l.store);function z(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return V.log("error","Error retrieving session data:",e),null}}function Q(){var e,t={id:N.randomUUID&&!e?N.randomUUID():B(e),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(t)),t}function F(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var G=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.clickTracker=null,t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,e),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return(e=z())||(e=Q()),[4,S()];case 1:return t=i.sent(),n=new URL(window.location.href),r=n.searchParams.get("lucia"),[4,I()];case 2:return o=i.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:r,utm:P()},!1)];case 3:return(s=i.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new v(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:r},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return i.sent(),[2]}})})},o.prototype.pageView=function(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=F(),n=z(),r={page:e,user:{name:H()},session:n},t&&(r.lid=t),[4,this.httpClient.post("/api/sdk/page",r)];case 1:return i.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={tag:e,amount:t,event:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return i.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),o={button:e,user:{name:H()},session:r},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return i.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={walletAddress:e,chainId:t,walletName:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return i.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return r(this,arguments,void 0,function(e,t){var r,o,a;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return[4,S()];case 1:return r=i.sent(),o=P(),a=z(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:n({timestamp:(new Date).toISOString(),browserData:r,utmParams:o},t)})];case 2:return i.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){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))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(d),Z=null,J=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},X={init:function(e){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;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=r(void 0,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,(t=new G(e)).init()];case 1:return n.sent(),[2,t]}})});return Z=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return r(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,J()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().trackConversion(e,t,n)]}})})},buttonClick:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().sendWalletInfo(e,t,n)]}})})},trackUserAcquisition:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return r(void 0,o([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){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:s};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(t){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(n(n(n({apiKey:t},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}e.__resetInstance=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),Z=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},e.default=X,e.filterObject=E,e.getApplePayAvailable=_,e.getBrowserData=S,e.getCanvasFingerprint=O,e.getColorGamut=U,e.getContrastPreference=M,e.getUtmParams=P,e.getWalletData=I,e.isTouchEnabled=j,e.safeAccess=x,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lucia-sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"description": "Lucia JavaScript Library",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/ondecentral/Lucia-Browser-SDK.git"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"main": "dist/index.js",
|
|
8
12
|
"module": "dist/index.es.js",
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
"package:publish": "yarn package:build && npm publish --access public",
|
|
24
28
|
"tsc": "tsc --pretty --noEmit",
|
|
25
29
|
"prepare": "yarn package:build",
|
|
26
|
-
"
|
|
30
|
+
"postinstall": "husky || true",
|
|
27
31
|
"validate": "npm-run-all --parallel lint tsc",
|
|
28
32
|
"commitlint": "commitlint",
|
|
29
33
|
"lint": "eslint .",
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
"@rollup/plugin-replace": "^6.0.3",
|
|
40
44
|
"@rollup/plugin-terser": "^0.4.4",
|
|
41
45
|
"@testing-library/jest-dom": "^6.9.1",
|
|
42
|
-
"@types/jest": "^
|
|
46
|
+
"@types/jest": "^30.0.0",
|
|
43
47
|
"@types/uuid": "^10.0.0",
|
|
44
48
|
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
45
49
|
"@typescript-eslint/parser": "^8.50.1",
|
|
@@ -53,8 +57,8 @@
|
|
|
53
57
|
"eslint-plugin-unicorn": "^62.0.0",
|
|
54
58
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
55
59
|
"husky": "^9.1.7",
|
|
56
|
-
"jest": "^
|
|
57
|
-
"jest-environment-jsdom": "^
|
|
60
|
+
"jest": "^30.2.0",
|
|
61
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
58
62
|
"lint-staged": "^16.2.7",
|
|
59
63
|
"npm-run-all": "^4.1.5",
|
|
60
64
|
"prettier": "^3.7.4",
|
|
@@ -65,7 +69,7 @@
|
|
|
65
69
|
"typescript": "^5.9.3"
|
|
66
70
|
},
|
|
67
71
|
"dependencies": {
|
|
68
|
-
"uuid": "^
|
|
72
|
+
"uuid": "^13.0.0"
|
|
69
73
|
},
|
|
70
74
|
"resolutions": {
|
|
71
75
|
"conventional-changelog-conventionalcommits": "^9.1.0"
|