@moneybar.online/moneybar 4.2.4 → 5.0.0

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.esm.js CHANGED
@@ -1,3202 +1,2 @@
1
- import { createClient } from '@supabase/supabase-js';
2
-
3
- /**
4
- * MoneyBar - The navbar of monetization
5
- *
6
- * Fix the 3 money-blocking stages that stop revenue:
7
- * 1. Forced sign-ins before value → Value-first trials
8
- * 2. Silent drop-offs → Exit feedback capture
9
- * 3. Broken payment flows → Seamless Google Auth + payments
10
- *
11
- * Features:
12
- * - Server-side usage tracking (incognito-proof)
13
- * - Google OAuth authentication
14
- * - Payment integration with DodoPayments
15
- * - User feedback collection
16
- * - Automatic UI management (paywall, auth, status)
17
- * - User context for personalization
18
- *
19
- * @example Simple Usage (Recommended):
20
- * ```javascript
21
- * import { MoneyBar } from '@moneybar.online/moneybar';
22
- *
23
- * const moneyBar = new MoneyBar({
24
- * appId: 'my-pdf-app',
25
- * freeAttemptLimit: 3,
26
- * supabase: { url: 'https://xyz.supabase.co', anonKey: 'anon_key' },
27
- * payment: { productId: 'prod_xyz' }
28
- * });
29
- *
30
- * // Single button - handles all monetization automatically
31
- * moneyBar.attachToButton('#action-btn', (userContext) => {
32
- * // Your action logic here - with user context for personalization
33
- * if (userContext.isPremium) {
34
- * generatePremiumPDF();
35
- * } else {
36
- * generateBasicPDF();
37
- * }
38
- * });
39
- * ```
40
- *
41
- * @example Multiple Buttons:
42
- * ```javascript
43
- * moneyBar.attachToButtons({
44
- * buttons: [
45
- * {
46
- * selector: '#free-btn',
47
- * downloadCallback: (ctx) => downloadFreeTemplate(ctx),
48
- * isPremium: false
49
- * },
50
- * {
51
- * selector: '#premium-btn',
52
- * downloadCallback: (ctx) => downloadPremiumTemplate(ctx),
53
- * isPremium: true
54
- * }
55
- * ]
56
- * });
57
- * ```
58
- */
59
- class MoneyBar {
60
- mergeConfigs(config) {
61
- // Try to get config from window.APP_CONFIG
62
- const windowConfig = typeof window !== 'undefined' ? window.APP_CONFIG : null;
63
- if (!config && !windowConfig) {
64
- throw new Error('MoneyBar: No configuration provided. Either pass config to constructor or set window.APP_CONFIG');
65
- }
66
- // If no constructor config provided, use window config entirely
67
- if (!config) {
68
- return windowConfig;
69
- }
70
- // If no window config, use constructor config entirely
71
- if (!windowConfig) {
72
- return config;
73
- }
74
- // Merge configs: constructor config takes precedence over window config
75
- return {
76
- ...windowConfig,
77
- ...config
78
- };
79
- }
80
- constructor(config) {
81
- this.currentUser = null;
82
- this.userFingerprint = null;
83
- this.eventListeners = new Map();
84
- this.supabaseConnectionFailed = false;
85
- this.paymentConnectionFailed = false;
86
- this.securityKeyFailed = false; // Track security key validation failures
87
- this.isLoadingStatus = false; // Track if we're currently loading status from backend
88
- this.cachedStatus = null;
89
- this.statusCacheTime = 0;
90
- this.STATUS_CACHE_DURATION = 5000; // 5 seconds cache
91
- this.initializationPromise = null;
92
- this.cachedPremiumStatus = null;
93
- this.premiumStatusCacheTime = 0;
94
- // Auto-load from window.APP_CONFIG if no config provided, or merge configs
95
- this.config = this.mergeConfigs(config);
96
- if (this.config.options?.debug) ;
97
- this.validateConfig();
98
- this.initializeSupabase();
99
- this.initializePayment();
100
- this.initializeFingerprint();
101
- this.setupAuthListener();
102
- this.checkPaymentStatus();
103
- }
104
- /**
105
- * Main method to handle download attempts
106
- * Call this from your download button's click handler
107
- */
108
- async handleDownload() {
109
- try {
110
- // Security check: if security key validation failed
111
- if (this.securityKeyFailed) {
112
- this.showError('Invalid Security Key', 'Your security key is invalid, expired, or not found. Please check your MoneyBar configuration and ensure you have a valid security_key.');
113
- return;
114
- }
115
- // Security check: if Supabase connection failed, disable downloads to prevent localStorage bypass
116
- if (this.supabaseConnectionFailed) {
117
- this.config.callbacks?.onError?.(new Error('Server connection required for download verification. Please check your configuration.'));
118
- return;
119
- }
120
- // Security check: if payment configuration is invalid, disable downloads
121
- if (this.config.payment && this.paymentConnectionFailed) {
122
- this.config.callbacks?.onError?.(new Error('Payment configuration error. Please contact support.'));
123
- return;
124
- }
125
- // Check if user is premium first (if authenticated)
126
- if (this.currentUser) {
127
- const isPremium = await this.checkPremiumStatus(this.currentUser.email);
128
- if (isPremium) {
129
- this.config.callbacks?.onPremiumDownload();
130
- return;
131
- }
132
- }
133
- // Check usage limits (works for both authenticated and anonymous users)
134
- const status = await this.getDownloadStatus();
135
- if (status.currentCount >= status.limit) {
136
- // Limit reached - show paywall/limit message
137
- this.config.callbacks?.onLimitReached(status.currentCount, status.limit);
138
- return;
139
- }
140
- // Increment counter and proceed with action
141
- await this.incrementDownloadCount();
142
- this.config.callbacks?.onDownloadAllowed();
143
- // Invalidate cache since count changed
144
- this.cachedStatus = null;
145
- // Check if limit reached after increment
146
- const newStatus = await this.getDownloadStatus();
147
- this.emit('countChanged', { count: newStatus.currentCount, limit: newStatus.limit });
148
- if (newStatus.currentCount >= newStatus.limit) {
149
- // Show paywall for next time
150
- setTimeout(() => {
151
- this.config.callbacks?.onLimitReached(newStatus.currentCount, newStatus.limit);
152
- }, 100);
153
- }
154
- }
155
- catch (error) {
156
- this.handleError(error);
157
- }
158
- }
159
- /**
160
- * Get current download status for the user
161
- */
162
- async getDownloadStatus(forceRefresh = false) {
163
- // console.log(`🔍 [INIT] getDownloadStatus called (forceRefresh: ${forceRefresh}) at ${new Date().toISOString()}`);
164
- // Check if we can use cached status
165
- const cacheAge = this.cachedStatus ? Date.now() - this.statusCacheTime : -1;
166
- const canUseCache = !forceRefresh && this.cachedStatus && cacheAge < this.STATUS_CACHE_DURATION;
167
- if (canUseCache) {
168
- // console.log(`🔍 [INIT] Using cached status (age: ${cacheAge}ms)`);
169
- return this.cachedStatus;
170
- }
171
- // If there's already an initialization in progress and it's not forced refresh, wait for it
172
- if (!forceRefresh && this.initializationPromise) {
173
- // console.log(`🔍 [INIT] Waiting for existing initialization promise`);
174
- return await this.initializationPromise;
175
- }
176
- // console.log(`🔍 [INIT] Starting new status fetch (cache age: ${cacheAge}ms)`);
177
- // Create the initialization promise
178
- this.initializationPromise = this.fetchFreshStatus(forceRefresh);
179
- try {
180
- const result = await this.initializationPromise;
181
- // console.log(`🔍 [INIT] Status fetch completed successfully`);
182
- return result;
183
- }
184
- finally {
185
- // Clear the promise after completion
186
- this.initializationPromise = null;
187
- }
188
- }
189
- async fetchFreshStatus(forceRefresh) {
190
- try {
191
- let count = 0;
192
- let isPremium = false;
193
- // Only call API if we really need fresh data
194
- if (forceRefresh || !this.cachedStatus) {
195
- // Get download count only if we don't have it cached
196
- count = await this.getDownloadCount();
197
- // CRITICAL: Check if security key validation failed
198
- // Don't proceed with normal status if there's a security error
199
- if (this.securityKeyFailed) {
200
- // Return a minimal error status
201
- return {
202
- currentCount: 0,
203
- limit: this.config.freeAttemptLimit,
204
- isPremium: false,
205
- isAuthenticated: false,
206
- remaining: 0
207
- };
208
- }
209
- }
210
- else {
211
- // Use cached count if available to avoid unnecessary API call
212
- count = this.cachedStatus.currentCount;
213
- }
214
- // Check premium status only for authenticated users, and only when needed
215
- if (this.currentUser) {
216
- const premiumCacheValid = this.cachedPremiumStatus !== null && (Date.now() - this.premiumStatusCacheTime) < this.STATUS_CACHE_DURATION;
217
- if (forceRefresh || !premiumCacheValid) {
218
- isPremium = await this.checkPremiumStatus(this.currentUser.email);
219
- // Update cache
220
- this.cachedPremiumStatus = isPremium;
221
- this.premiumStatusCacheTime = Date.now();
222
- }
223
- else {
224
- // Use cached premium status to avoid unnecessary API call
225
- isPremium = this.cachedPremiumStatus; // We know it's not null because premiumCacheValid is true
226
- console.log(`🔍 [CACHE] Using cached premium status from getDownloadStatus: ${isPremium}`);
227
- }
228
- }
229
- else {
230
- // Unauthenticated users cannot be premium
231
- isPremium = false;
232
- }
233
- const status = {
234
- currentCount: count,
235
- limit: this.config.freeAttemptLimit,
236
- isPremium,
237
- isAuthenticated: !!this.currentUser,
238
- remaining: Math.max(0, this.config.freeAttemptLimit - count)
239
- };
240
- // Cache the status
241
- this.cachedStatus = status;
242
- this.statusCacheTime = Date.now();
243
- return status;
244
- }
245
- catch (error) {
246
- this.handleError(error);
247
- // Return safe defaults on error
248
- const errorStatus = {
249
- currentCount: 0,
250
- limit: this.config.freeAttemptLimit,
251
- isPremium: false,
252
- isAuthenticated: false,
253
- remaining: this.config.freeAttemptLimit
254
- };
255
- // Cache error status for short time to avoid repeated failures
256
- this.cachedStatus = errorStatus;
257
- this.statusCacheTime = Date.now();
258
- return errorStatus;
259
- }
260
- }
261
- /**
262
- * Creates a UserContext object with current user information
263
- */
264
- async getUserContext() {
265
- const status = await this.getDownloadStatus();
266
- return {
267
- isPremium: status.isPremium,
268
- isAuthenticated: status.isAuthenticated,
269
- email: this.currentUser?.email,
270
- name: this.currentUser?.user_metadata?.full_name || this.currentUser?.user_metadata?.name,
271
- currentCount: status.currentCount,
272
- remaining: status.remaining,
273
- limit: status.limit,
274
- user: this.currentUser
275
- };
276
- }
277
- /**
278
- * Manually trigger Google sign-in
279
- */
280
- async signIn() {
281
- try {
282
- const { error } = await this.supabase.auth.signInWithOAuth({
283
- provider: 'google',
284
- options: {
285
- redirectTo: `${window.location.origin}${window.location.pathname}`
286
- }
287
- });
288
- if (error)
289
- throw error;
290
- }
291
- catch (error) {
292
- this.handleError(error);
293
- }
294
- }
295
- /**
296
- * Sign out current user
297
- */
298
- async signOut() {
299
- try {
300
- await this.supabase.auth.signOut();
301
- this.currentUser = null;
302
- this.emit('authChanged', { user: null, isPremium: false });
303
- }
304
- catch (error) {
305
- this.handleError(error);
306
- }
307
- }
308
- /**
309
- * Create payment for premium upgrade
310
- */
311
- async createPayment() {
312
- if (!this.currentUser) {
313
- throw new Error('User must be signed in to create payment');
314
- }
315
- if (!this.config.payment) {
316
- throw new Error('Payment configuration not provided');
317
- }
318
- const payment = this.config.payment?.find(p => p.provider === 'dodo');
319
- if (!payment) {
320
- throw new Error('No dodo payment provider configured');
321
- }
322
- const requestBody = {
323
- email: this.currentUser.email,
324
- product_id: payment.productId,
325
- mode: payment.mode || 'test',
326
- app_id: this.config.appId,
327
- return_url: `${window.location.origin}${window.location.pathname}?payment=success`
328
- };
329
- console.log(`🔥 [PAYMENT API] createPayment called for provider: ${payment.provider}, email: ${this.currentUser.email} | Time: ${new Date().toISOString()}`);
330
- try {
331
- // Route to appropriate payment API based on provider
332
- let response;
333
- if (payment.provider === 'dodo') {
334
- response = await fetch(`${this.config.supabase.url}/functions/v1/create-payment`, {
335
- method: 'POST',
336
- headers: {
337
- 'Content-Type': 'application/json',
338
- 'Authorization': `Bearer ${this.config.supabase.anonKey}`
339
- },
340
- body: JSON.stringify(requestBody)
341
- });
342
- }
343
- else {
344
- throw new Error(`Payment provider '${payment.provider}' is not yet supported`);
345
- }
346
- console.log(`🔥 [PAYMENT API] createPayment response for ${payment.provider}: ${response.status}`);
347
- if (this.config.options?.debug) {
348
- //console.log('🔍 DEBUG: createPayment response status:', response.status);
349
- }
350
- if (!response.ok) {
351
- const errorText = await response.text();
352
- if (this.config.options?.debug) {
353
- console.error('🔍 DEBUG: createPayment error response:', errorText);
354
- }
355
- let errorData;
356
- try {
357
- errorData = JSON.parse(errorText);
358
- }
359
- catch {
360
- errorData = { error: errorText };
361
- }
362
- // Check if this is a product ID error (invalid config)
363
- if (errorText.includes('404') || errorText.includes('could not be found')) {
364
- this.paymentConnectionFailed = true;
365
- if (this.config.options?.debug) {
366
- console.warn('Invalid payment product ID detected, disabling downloads');
367
- }
368
- // Update UI to show disabled state
369
- this.updateStatusDisplays();
370
- }
371
- throw new Error(errorData.error || 'Payment creation failed');
372
- }
373
- const result = await response.json();
374
- if (this.config.options?.debug) {
375
- //console.log('🔍 DEBUG: createPayment success response:', result);
376
- }
377
- return result;
378
- }
379
- catch (error) {
380
- this.handleError(error);
381
- return null;
382
- }
383
- }
384
- /**
385
- * Simplified API: Attach download limiting to a single button
386
- * Handles all UI logic automatically (paywall, auth, payment flow)
387
- */
388
- attachToButton(selector, downloadCallback) {
389
- //console.log('🎨 [THEME DEBUG] attachToButton called');
390
- //console.log('🎨 [THEME DEBUG] Full config:', JSON.stringify(this.config, null, 2));
391
- const button = document.querySelector(selector);
392
- if (!button) {
393
- throw new Error(`Button not found: ${selector}`);
394
- }
395
- // Store original button text (for potential future use)
396
- // const originalText = button.textContent || 'Download';
397
- // Create and inject UI elements
398
- this.injectBaseStyles();
399
- this.createTitleBar(); // Always create title bar first
400
- this.createPaywallModal();
401
- this.createSuccessModal();
402
- this.createAuthUI();
403
- this.createStatusDisplay();
404
- // Set up button click handler
405
- // Mark button as attached by LeadFast
406
- button.setAttribute('data-leadfast-attached', 'true');
407
- button.onclick = async (e) => {
408
- e.preventDefault();
409
- await this.handleButtonClick(downloadCallback);
410
- };
411
- // Update UI based on auth state
412
- this.setupUIUpdates();
413
- }
414
- /**
415
- * Simplified API: Attach download limiting to multiple buttons
416
- * Each button can have different download callbacks and premium status
417
- */
418
- attachToButtons(config) {
419
- this.injectBaseStyles();
420
- this.createTitleBar(); // Always create title bar first
421
- this.createPaywallModal();
422
- this.createSuccessModal();
423
- this.createAuthUI();
424
- config.buttons.forEach(buttonConfig => {
425
- const button = document.querySelector(buttonConfig.selector);
426
- if (!button) {
427
- console.warn(`Button not found: ${buttonConfig.selector}`);
428
- return;
429
- }
430
- // Store original text for potential future use
431
- // const originalText = button.textContent || 'Download';
432
- // Set up click handler - all buttons use the same logic now
433
- // Mark button as attached by LeadFast
434
- button.setAttribute('data-leadfast-attached', 'true');
435
- button.onclick = async (e) => {
436
- e.preventDefault();
437
- await this.handleButtonClick(buttonConfig.downloadCallback);
438
- };
439
- this.setupUIUpdates();
440
- });
441
- // Add global status display
442
- this.createGlobalStatusDisplay();
443
- }
444
- async handleButtonClick(downloadCallback) {
445
- // Prevent rapid clicks/race conditions
446
- const button = document.querySelector('[data-leadfast-attached="true"]');
447
- if (button && button.disabled) {
448
- console.log('⚠️ Button click ignored - operation already in progress');
449
- return;
450
- }
451
- if (button) {
452
- button.disabled = true;
453
- button.style.opacity = '0.6';
454
- }
455
- try {
456
- await this.handleButtonClickInternal(downloadCallback);
457
- }
458
- finally {
459
- // Re-enable button
460
- if (button) {
461
- button.disabled = false;
462
- button.style.opacity = '1';
463
- }
464
- }
465
- }
466
- async handleButtonClickInternal(downloadCallback) {
467
- // const clickTime = Date.now();
468
- // console.log(`🕐 [TIMING] Button click started at: ${new Date(clickTime).toISOString()}`);
469
- // Security check: if Supabase connection failed, disable downloads to prevent localStorage bypass
470
- if (this.supabaseConnectionFailed) {
471
- // console.log(`🕐 [TIMING] Connection failed check: ${Date.now() - clickTime}ms`);
472
- this.showConnectionError();
473
- return;
474
- }
475
- // Security check: if payment configuration is invalid, disable downloads
476
- if (this.config.payment && this.paymentConnectionFailed) {
477
- // console.log(`🕐 [TIMING] Payment config failed check: ${Date.now() - clickTime}ms`);
478
- this.showPaymentConfigError();
479
- return;
480
- }
481
- // Check cache status
482
- const cacheValid = this.cachedStatus && (Date.now() - this.statusCacheTime) < this.STATUS_CACHE_DURATION;
483
- // console.log(`🕐 [CACHE] Cache valid: ${cacheValid}, age: ${this.cachedStatus ? Date.now() - this.statusCacheTime : 'no cache'}ms`);
484
- // console.log(`🕐 [CACHE] Cached status:`, this.cachedStatus);
485
- // const statusStartTime = Date.now();
486
- // Use cached status if available (since it's already displayed in title bar)
487
- const status = cacheValid
488
- ? this.cachedStatus
489
- : await this.getDownloadStatus();
490
- // console.log(`🕐 [TIMING] Status check completed: ${Date.now() - statusStartTime}ms (total: ${Date.now() - clickTime}ms)`);
491
- // console.log(`🕐 [STATUS] Final status:`, status);
492
- // Check if user is premium first (quick check from cached status)
493
- if (status.isPremium) {
494
- // console.log(`🕐 [TIMING] Premium user - callback executed: ${Date.now() - clickTime}ms`);
495
- // Get user context for premium users too
496
- const userContext = await this.getUserContext();
497
- // Check if callback expects user context parameter
498
- if (downloadCallback.length > 0) {
499
- // Callback expects user context parameter
500
- downloadCallback(userContext);
501
- }
502
- else {
503
- // Legacy callback with no parameters
504
- downloadCallback();
505
- }
506
- return;
507
- }
508
- // Quick limit check from cached status - show paywall immediately if needed
509
- if (status.currentCount >= status.limit) {
510
- // console.log(`🕐 [TIMING] Limit reached (${status.currentCount}/${status.limit}) - showing paywall: ${Date.now() - clickTime}ms`);
511
- // Limit reached - show paywall instantly (no additional API calls)
512
- // const paywallStartTime = Date.now();
513
- this.showPaywallInstant(status);
514
- // console.log(`🕐 [TIMING] Paywall shown: ${Date.now() - paywallStartTime}ms (total: ${Date.now() - clickTime}ms)`);
515
- return;
516
- }
517
- // console.log(`🕐 [TIMING] Limit not reached (${status.currentCount}/${status.limit}) - proceeding with action`);
518
- // Allow action and increment counter
519
- // const incrementStartTime = Date.now();
520
- // Execute user's function first - only increment count if it succeeds
521
- try {
522
- // Check if callback expects user context parameter
523
- if (downloadCallback.length > 0) {
524
- // Get user context BEFORE increment for callback
525
- const userContext = await this.getUserContext();
526
- // For non-premium users, simulate the increment so user context matches UI
527
- if (!userContext.isPremium) {
528
- userContext.currentCount += 1;
529
- userContext.remaining = Math.max(0, userContext.limit - userContext.currentCount);
530
- }
531
- // Callback expects user context parameter
532
- downloadCallback(userContext);
533
- }
534
- else {
535
- // Legacy callback with no parameters
536
- downloadCallback();
537
- }
538
- // Double-check limit before increment (race condition protection)
539
- const freshStatus = await this.getDownloadStatus(true); // Force refresh
540
- if (freshStatus.currentCount >= freshStatus.limit) {
541
- console.warn(`⚠️ Limit reached during execution (${freshStatus.currentCount}/${freshStatus.limit}) - canceling increment`);
542
- // User reached limit while their function was executing
543
- alert('⚠️ You reached the limit while this action was processing. No attempt was counted.');
544
- return;
545
- }
546
- // Only increment count after successful execution - with limit check
547
- const newCount = await this.incrementDownloadCount();
548
- // Double-check: if server returned count exceeding limit, something went wrong
549
- if (newCount > this.config.freeAttemptLimit) {
550
- console.error(`⚠️ Server returned count (${newCount}) exceeding limit (${this.config.freeAttemptLimit})`);
551
- // Don't update UI with invalid state
552
- return;
553
- }
554
- // console.log(`🕐 [TIMING] Count incremented: ${Date.now() - incrementStartTime}ms`);
555
- // Show success message only if explicitly enabled in config
556
- if (this.config.successMessage?.enabled === true) {
557
- const title = this.config.successMessage?.title || 'Action Completed!';
558
- const message = this.config.successMessage?.message || 'Your action completed successfully!';
559
- this.showSuccess(title, message);
560
- }
561
- }
562
- catch (error) {
563
- console.error('User function failed:', error);
564
- // Don't increment count on error - user shouldn't lose an attempt
565
- alert('Action failed. Please check the console for details. No attempt was counted.');
566
- return; // Exit early, don't update UI
567
- }
568
- // Update UI with fresh status (invalidate cache since count changed)
569
- // console.log(`🕐 [CACHE] Invalidating cache due to count change (was: ${this.cachedStatus ? 'cached' : 'null'})`);
570
- this.cachedStatus = null;
571
- this.updateStatusDisplays();
572
- // console.log(`🕐 [TIMING] Button click completed: ${Date.now() - clickTime}ms`);
573
- }
574
- injectBaseStyles() {
575
- //console.log('🎨 [THEME DEBUG] injectBaseStyles called');
576
- if (document.getElementById('lead-fast-styles')) {
577
- //console.log('🎨 [THEME DEBUG] Styles already injected, skipping');
578
- return;
579
- }
580
- // Inject DaisyUI CDN if theme is specified
581
- if (this.config.theme?.name) {
582
- //console.log('🎨 [THEME DEBUG] Theme specified, calling injectDaisyUI');
583
- this.injectDaisyUI();
584
- }
585
- const styles = document.createElement('style');
586
- styles.id = 'lead-fast-styles';
587
- const primaryColor = this.config.theme?.primaryColor || '#3182ce';
588
- styles.textContent = `
589
- /* User Profile Card - Top Right */
590
- .lead-fast-profile {
591
- position: fixed;
592
- top: 20px;
593
- left: 50%;
594
- transform: translateX(-50%);
595
- z-index: 1000;
596
- font-family: system-ui, -apple-system, sans-serif;
597
- width: 90%;
598
- max-width: 1200px;
599
- }
600
-
601
- .lead-fast-title-bar {
602
- background: rgba(250, 247, 245, 0.9) !important;
603
- border: 1px solid rgba(231, 226, 223, 0.6) !important;
604
- color: #291334 !important;
605
- border-radius: 16px;
606
- padding: 12px 24px;
607
- box-shadow: 0 8px 32px rgb(0 0 0 / 0.1), 0 2px 8px rgb(0 0 0 / 0.05);
608
- backdrop-filter: blur(20px);
609
- display: flex;
610
- align-items: center;
611
- justify-content: space-between;
612
- min-height: 60px;
613
- font-family: system-ui, -apple-system, sans-serif;
614
- }
615
-
616
- /* Theme variations for floating title bar */
617
- [data-theme="bumblebee"] .lead-fast-title-bar {
618
- background: rgba(255, 248, 220, 0.9) !important;
619
- border-color: rgba(254, 215, 170, 0.6) !important;
620
- color: #1c1917 !important;
621
- }
622
-
623
- [data-theme="garden"] .lead-fast-title-bar {
624
- background: rgba(240, 253, 244, 0.9) !important;
625
- border-color: rgba(134, 239, 172, 0.6) !important;
626
- color: #14532d !important;
627
- }
628
-
629
- [data-theme="emerald"] .lead-fast-title-bar {
630
- background: rgba(236, 253, 245, 0.9) !important;
631
- border-color: rgba(167, 243, 208, 0.6) !important;
632
- color: #065f46 !important;
633
- }
634
-
635
- [data-theme="corporate"] .lead-fast-title-bar {
636
- background: rgba(248, 250, 252, 0.9) !important;
637
- border-color: rgba(226, 232, 240, 0.6) !important;
638
- color: #1e293b !important;
639
- }
640
-
641
- [data-theme="dark"] .lead-fast-title-bar {
642
- background: rgba(31, 41, 55, 0.9) !important;
643
- border-color: rgba(55, 65, 81, 0.6) !important;
644
- color: #f9fafb !important;
645
- }
646
-
647
- [data-theme="cyberpunk"] .lead-fast-title-bar {
648
- background: rgba(0, 20, 36, 0.9) !important;
649
- border-color: rgba(7, 89, 133, 0.6) !important;
650
- color: #0ea5e9 !important;
651
- box-shadow: 0 8px 32px rgba(14, 165, 233, 0.2), 0 2px 8px rgba(14, 165, 233, 0.1);
652
- }
653
-
654
- [data-theme="valentine"] .lead-fast-title-bar {
655
- background: rgba(233, 30, 122, 0.15) !important;
656
- border-color: rgba(233, 30, 122, 0.6) !important;
657
- color: #831843 !important;
658
- }
659
-
660
- [data-theme="synthwave"] .lead-fast-title-bar {
661
- background: rgba(32, 20, 64, 0.9) !important;
662
- border-color: rgba(186, 85, 211, 0.6) !important;
663
- color: #ff00ff !important;
664
- box-shadow: 0 8px 32px rgba(255, 0, 255, 0.2), 0 2px 8px rgba(255, 0, 255, 0.1);
665
- }
666
-
667
- [data-theme="dracula"] .lead-fast-title-bar {
668
- background: rgba(40, 42, 54, 0.9) !important;
669
- border-color: rgba(98, 114, 164, 0.6) !important;
670
- color: #f8f8f2 !important;
671
- }
672
-
673
- [data-theme="halloween"] .lead-fast-title-bar {
674
- background: rgba(26, 26, 26, 0.9) !important;
675
- border-color: rgba(255, 165, 0, 0.6) !important;
676
- color: #ff6600 !important;
677
- }
678
-
679
- [data-theme="forest"] .lead-fast-title-bar {
680
- background: rgba(23, 46, 23, 0.9) !important;
681
- border-color: rgba(34, 197, 94, 0.6) !important;
682
- color: #22c55e !important;
683
- }
684
-
685
- [data-theme="luxury"] .lead-fast-title-bar {
686
- background: rgba(9, 9, 11, 0.9) !important;
687
- border-color: rgba(212, 175, 55, 0.6) !important;
688
- color: #d4af37 !important;
689
- }
690
-
691
- [data-theme="night"] .lead-fast-title-bar {
692
- background: rgba(15, 23, 42, 0.9) !important;
693
- border-color: rgba(30, 58, 138, 0.6) !important;
694
- color: #60a5fa !important;
695
- }
696
-
697
- [data-theme="light"] .lead-fast-title-bar {
698
- background: rgba(255, 255, 255, 0.9) !important;
699
- border-color: rgba(229, 231, 235, 0.6) !important;
700
- color: #1f2937 !important;
701
- }
702
-
703
- [data-theme="cupcake"] .lead-fast-title-bar {
704
- background: rgba(250, 235, 215, 0.9) !important;
705
- border-color: rgba(219, 185, 156, 0.6) !important;
706
- color: #8b4513 !important;
707
- }
708
-
709
- [data-theme="retro"] .lead-fast-title-bar {
710
- background: rgba(212, 165, 116, 0.9) !important;
711
- border-color: rgba(185, 144, 102, 0.6) !important;
712
- color: #5d4037 !important;
713
- }
714
-
715
- [data-theme="aqua"] .lead-fast-title-bar {
716
- background: rgba(240, 253, 250, 0.9) !important;
717
- border-color: rgba(125, 211, 252, 0.6) !important;
718
- color: #155e75 !important;
719
- }
720
-
721
- [data-theme="lofi"] .lead-fast-title-bar {
722
- background: rgba(248, 248, 248, 0.9) !important;
723
- border-color: rgba(68, 68, 68, 0.6) !important;
724
- color: #1a1a1a !important;
725
- }
726
-
727
- [data-theme="pastel"] .lead-fast-title-bar {
728
- background: rgba(254, 251, 255, 0.9) !important;
729
- border-color: rgba(209, 196, 233, 0.6) !important;
730
- color: #7c3aed !important;
731
- }
732
-
733
- [data-theme="fantasy"] .lead-fast-title-bar {
734
- background: rgba(255, 247, 237, 0.9) !important;
735
- border-color: rgba(249, 168, 212, 0.6) !important;
736
- color: #be185d !important;
737
- }
738
-
739
- [data-theme="wireframe"] .lead-fast-title-bar {
740
- background: rgba(223, 223, 223, 0.9) !important;
741
- border-color: rgba(0, 0, 0, 0.3) !important;
742
- color: #000000 !important;
743
- }
744
-
745
- [data-theme="black"] .lead-fast-title-bar {
746
- background: rgba(0, 0, 0, 0.9) !important;
747
- border-color: rgba(55, 55, 55, 0.6) !important;
748
- color: #ffffff !important;
749
- }
750
-
751
- [data-theme="cmyk"] .lead-fast-title-bar {
752
- background: rgba(0, 255, 255, 0.9) !important;
753
- border-color: rgba(255, 0, 255, 0.6) !important;
754
- color: #000000 !important;
755
- }
756
-
757
- [data-theme="autumn"] .lead-fast-title-bar {
758
- background: rgba(139, 69, 19, 0.9) !important;
759
- border-color: rgba(255, 140, 0, 0.6) !important;
760
- color: #ff8c00 !important;
761
- }
762
-
763
- [data-theme="business"] .lead-fast-title-bar {
764
- background: rgba(29, 78, 216, 0.9) !important;
765
- border-color: rgba(59, 130, 246, 0.6) !important;
766
- color: #3b82f6 !important;
767
- }
768
-
769
- [data-theme="acid"] .lead-fast-title-bar {
770
- background: rgba(255, 255, 0, 0.9) !important;
771
- border-color: rgba(255, 0, 255, 0.6) !important;
772
- color: #000000 !important;
773
- }
774
-
775
- [data-theme="lemonade"] .lead-fast-title-bar {
776
- background: rgba(255, 255, 224, 0.9) !important;
777
- border-color: rgba(34, 197, 94, 0.6) !important;
778
- color: #15803d !important;
779
- }
780
-
781
- [data-theme="coffee"] .lead-fast-title-bar {
782
- background: rgba(101, 67, 33, 0.9) !important;
783
- border-color: rgba(160, 82, 45, 0.6) !important;
784
- color: #d2b48c !important;
785
- }
786
-
787
- [data-theme="winter"] .lead-fast-title-bar {
788
- background: rgba(248, 250, 252, 0.9) !important;
789
- border-color: rgba(59, 130, 246, 0.6) !important;
790
- color: #1e40af !important;
791
- }
792
-
793
- .lead-fast-title-section {
794
- display: flex;
795
- align-items: center;
796
- gap: 16px;
797
- }
798
-
799
- .lead-fast-logo {
800
- font-size: 20px;
801
- font-weight: 700;
802
- display: flex;
803
- align-items: center;
804
- gap: 8px;
805
- color: inherit;
806
- text-decoration: none;
807
- }
808
-
809
- .lead-fast-logo img {
810
- width: 32px;
811
- height: 32px;
812
- border-radius: 6px;
813
- }
814
-
815
- .lead-fast-nav {
816
- display: flex;
817
- align-items: center;
818
- gap: 32px;
819
- margin-left: 24px;
820
- }
821
-
822
- .lead-fast-nav-link {
823
- color: inherit;
824
- text-decoration: none;
825
- font-weight: 500;
826
- font-size: 14px;
827
- opacity: 0.8;
828
- transition: all 0.2s;
829
- }
830
-
831
- .lead-fast-nav-link:hover {
832
- opacity: 1;
833
- text-decoration: none;
834
- }
835
-
836
- .lead-fast-user-section {
837
- display: flex;
838
- align-items: center;
839
- gap: 12px;
840
- }
841
-
842
- .lead-fast-avatar {
843
- width: 36px;
844
- height: 36px;
845
- border-radius: 50%;
846
- background: linear-gradient(135deg, ${primaryColor}, #4f46e5);
847
- display: flex;
848
- align-items: center;
849
- justify-content: center;
850
- color: white;
851
- font-weight: 600;
852
- font-size: 14px;
853
- }
854
-
855
- .lead-fast-user-info {
856
- display: flex;
857
- flex-direction: column;
858
- align-items: flex-start;
859
- gap: 2px;
860
- }
861
-
862
- .lead-fast-user-email {
863
- color: inherit !important;
864
- font-size: 13px;
865
- font-weight: 500;
866
- line-height: 1;
867
- }
868
-
869
- .lead-fast-user-status {
870
- display: flex;
871
- align-items: center;
872
- gap: 6px;
873
- }
874
-
875
- .lead-fast-badge {
876
- padding: 2px 6px;
877
- border-radius: 12px;
878
- font-size: 10px;
879
- font-weight: 600;
880
- text-transform: uppercase;
881
- letter-spacing: 0.025em;
882
- line-height: 1;
883
- }
884
-
885
- .lead-fast-badge.premium {
886
- background: #10b981 !important;
887
- color: #ffffff !important;
888
- }
889
-
890
- .lead-fast-badge.free {
891
- background: #65c3c8 !important;
892
- color: #291334 !important;
893
- }
894
-
895
- [data-theme="dark"] .lead-fast-badge.premium {
896
- background: #059669 !important;
897
- color: #ffffff !important;
898
- }
899
-
900
- [data-theme="dark"] .lead-fast-badge.free {
901
- background: #374151 !important;
902
- color: #f9fafb !important;
903
- }
904
-
905
- .lead-fast-count {
906
- font-size: 10px;
907
- color: inherit !important;
908
- opacity: 0.7;
909
- line-height: 1;
910
- }
911
-
912
- .lead-fast-signout {
913
- background: rgba(0, 0, 0, 0.1) !important;
914
- border: none;
915
- color: inherit !important;
916
- cursor: pointer;
917
- padding: 6px 12px;
918
- border-radius: 8px;
919
- transition: all 0.2s;
920
- font-size: 11px;
921
- font-weight: 500;
922
- margin-left: 8px;
923
- }
924
-
925
- [data-theme="dark"] .lead-fast-signout {
926
- background: rgba(255, 255, 255, 0.1) !important;
927
- }
928
-
929
- [data-theme="cyberpunk"] .lead-fast-signout {
930
- background: rgba(14, 165, 233, 0.2) !important;
931
- }
932
-
933
- .lead-fast-signout:hover {
934
- background: rgba(0, 0, 0, 0.2) !important;
935
- transform: translateY(-1px);
936
- }
937
-
938
- [data-theme="dark"] .lead-fast-signout:hover {
939
- background: rgba(255, 255, 255, 0.2) !important;
940
- }
941
-
942
- [data-theme="cyberpunk"] .lead-fast-signout:hover {
943
- background: rgba(14, 165, 233, 0.3) !important;
944
- }
945
-
946
- .lead-fast-branding {
947
- position: absolute;
948
- bottom: -20px;
949
- left: 24px;
950
- font-size: 9px;
951
- color: inherit !important;
952
- opacity: 0.4;
953
- font-weight: 500;
954
- letter-spacing: 0.05em;
955
- text-transform: lowercase;
956
- background: rgba(255, 255, 255, 0.8);
957
- padding: 2px 6px;
958
- border-radius: 4px;
959
- backdrop-filter: blur(8px);
960
- }
961
-
962
- [data-theme="dark"] .lead-fast-branding {
963
- background: rgba(0, 0, 0, 0.6);
964
- }
965
-
966
- [data-theme="cyberpunk"] .lead-fast-branding {
967
- background: rgba(0, 20, 36, 0.8);
968
- }
969
-
970
- /* Modal Theming */
971
- .download-limiter-modal {
972
- display: none;
973
- position: fixed;
974
- top: 0;
975
- left: 0;
976
- width: 100%;
977
- height: 100%;
978
- background: rgba(0,0,0,0.5);
979
- z-index: 9999;
980
- align-items: center;
981
- justify-content: center;
982
- }
983
- .download-limiter-modal.show { display: flex; }
984
-
985
- .download-limiter-content {
986
- background: #faf7f5 !important;
987
- color: #291334 !important;
988
- padding: 2rem;
989
- border-radius: 12px;
990
- max-width: 400px;
991
- text-align: center;
992
- box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
993
- border: 1px solid #e7e2df !important;
994
- font-family: system-ui, -apple-system, sans-serif;
995
- }
996
-
997
- [data-theme="dark"] .download-limiter-content {
998
- background: #1f2937 !important;
999
- color: #f9fafb !important;
1000
- border-color: #374151 !important;
1001
- }
1002
-
1003
- [data-theme="cyberpunk"] .download-limiter-content {
1004
- background: #001424 !important;
1005
- color: #0ea5e9 !important;
1006
- border-color: #075985 !important;
1007
- }
1008
-
1009
- [data-theme="valentine"] .download-limiter-content {
1010
- background: rgba(233, 30, 122, 0.05) !important;
1011
- color: #831843 !important;
1012
- border-color: #e91e7a !important;
1013
- }
1014
-
1015
- [data-theme="bumblebee"] .download-limiter-content {
1016
- background: rgba(255, 248, 220, 0.95) !important;
1017
- color: #1c1917 !important;
1018
- border-color: rgba(254, 215, 170, 0.8) !important;
1019
- }
1020
-
1021
- [data-theme="garden"] .download-limiter-content {
1022
- background: rgba(240, 253, 244, 0.95) !important;
1023
- color: #14532d !important;
1024
- border-color: rgba(134, 239, 172, 0.8) !important;
1025
- }
1026
-
1027
- [data-theme="emerald"] .download-limiter-content {
1028
- background: rgba(236, 253, 245, 0.95) !important;
1029
- color: #065f46 !important;
1030
- border-color: rgba(167, 243, 208, 0.8) !important;
1031
- }
1032
-
1033
- [data-theme="corporate"] .download-limiter-content {
1034
- background: rgba(248, 250, 252, 0.95) !important;
1035
- color: #1e293b !important;
1036
- border-color: rgba(226, 232, 240, 0.8) !important;
1037
- }
1038
-
1039
- [data-theme="forest"] .download-limiter-content {
1040
- background: rgba(23, 46, 23, 0.95) !important;
1041
- color: #22c55e !important;
1042
- border-color: rgba(34, 197, 94, 0.8) !important;
1043
- }
1044
-
1045
- [data-theme="halloween"] .download-limiter-content {
1046
- background: rgba(26, 26, 26, 0.95) !important;
1047
- color: #ff6500 !important;
1048
- border-color: rgba(255, 165, 0, 0.3) !important;
1049
- }
1050
-
1051
- [data-theme="synthwave"] .download-limiter-content {
1052
- background: rgba(32, 20, 64, 0.95) !important;
1053
- color: #ba55d3 !important;
1054
- border-color: rgba(186, 85, 211, 0.3) !important;
1055
- }
1056
-
1057
- [data-theme="dracula"] .download-limiter-content {
1058
- background: rgba(40, 42, 54, 0.95) !important;
1059
- color: #f8f8f2 !important;
1060
- border-color: rgba(98, 114, 164, 0.3) !important;
1061
- }
1062
-
1063
- [data-theme="luxury"] .download-limiter-content {
1064
- background: rgba(9, 9, 11, 0.95) !important;
1065
- color: #d4af37 !important;
1066
- border-color: rgba(212, 175, 55, 0.3) !important;
1067
- }
1068
-
1069
- [data-theme="night"] .download-limiter-content {
1070
- background: rgba(15, 23, 42, 0.95) !important;
1071
- color: #1e40af !important;
1072
- border-color: rgba(30, 58, 138, 0.3) !important;
1073
- }
1074
-
1075
- [data-theme="light"] .download-limiter-content {
1076
- background: rgba(255, 255, 255, 0.95) !important;
1077
- color: #1f2937 !important;
1078
- border-color: rgba(229, 231, 235, 0.8) !important;
1079
- }
1080
-
1081
- [data-theme="cupcake"] .download-limiter-content {
1082
- background: rgba(250, 235, 215, 0.95) !important;
1083
- color: #8b4513 !important;
1084
- border-color: rgba(219, 185, 156, 0.8) !important;
1085
- }
1086
-
1087
- [data-theme="retro"] .download-limiter-content {
1088
- background: rgba(212, 165, 116, 0.95) !important;
1089
- color: #5d4037 !important;
1090
- border-color: rgba(185, 144, 102, 0.8) !important;
1091
- }
1092
-
1093
- [data-theme="aqua"] .download-limiter-content {
1094
- background: rgba(240, 253, 250, 0.95) !important;
1095
- color: #155e75 !important;
1096
- border-color: rgba(125, 211, 252, 0.8) !important;
1097
- }
1098
-
1099
- [data-theme="lofi"] .download-limiter-content {
1100
- background: rgba(248, 248, 248, 0.95) !important;
1101
- color: #1a1a1a !important;
1102
- border-color: rgba(68, 68, 68, 0.8) !important;
1103
- }
1104
-
1105
- [data-theme="pastel"] .download-limiter-content {
1106
- background: rgba(254, 251, 255, 0.95) !important;
1107
- color: #7c3aed !important;
1108
- border-color: rgba(209, 196, 233, 0.8) !important;
1109
- }
1110
-
1111
- [data-theme="fantasy"] .download-limiter-content {
1112
- background: rgba(255, 247, 237, 0.95) !important;
1113
- color: #be185d !important;
1114
- border-color: rgba(249, 168, 212, 0.8) !important;
1115
- }
1116
-
1117
- [data-theme="wireframe"] .download-limiter-content {
1118
- background: rgba(255, 255, 255, 0.95) !important;
1119
- color: #000000 !important;
1120
- border-color: rgba(0, 0, 0, 0.3) !important;
1121
- }
1122
-
1123
- [data-theme="black"] .download-limiter-content {
1124
- background: rgba(0, 0, 0, 0.95) !important;
1125
- color: #ffffff !important;
1126
- border-color: rgba(55, 55, 55, 0.8) !important;
1127
- }
1128
-
1129
- [data-theme="cmyk"] .download-limiter-content {
1130
- background: rgba(0, 255, 255, 0.95) !important;
1131
- color: #000000 !important;
1132
- border-color: rgba(255, 0, 255, 0.8) !important;
1133
- }
1134
-
1135
- [data-theme="autumn"] .download-limiter-content {
1136
- background: rgba(139, 69, 19, 0.95) !important;
1137
- color: #ff8c00 !important;
1138
- border-color: rgba(255, 140, 0, 0.8) !important;
1139
- }
1140
-
1141
- [data-theme="business"] .download-limiter-content {
1142
- background: rgba(29, 78, 216, 0.95) !important;
1143
- color: #3b82f6 !important;
1144
- border-color: rgba(59, 130, 246, 0.8) !important;
1145
- }
1146
-
1147
- [data-theme="acid"] .download-limiter-content {
1148
- background: rgba(255, 255, 0, 0.95) !important;
1149
- color: #000000 !important;
1150
- border-color: rgba(255, 0, 255, 0.8) !important;
1151
- }
1152
-
1153
- [data-theme="lemonade"] .download-limiter-content {
1154
- background: rgba(255, 255, 224, 0.95) !important;
1155
- color: #15803d !important;
1156
- border-color: rgba(34, 197, 94, 0.8) !important;
1157
- }
1158
-
1159
- [data-theme="coffee"] .download-limiter-content {
1160
- background: rgba(101, 67, 33, 0.95) !important;
1161
- color: #d2b48c !important;
1162
- border-color: rgba(160, 82, 45, 0.8) !important;
1163
- }
1164
-
1165
- [data-theme="winter"] .download-limiter-content {
1166
- background: rgba(248, 250, 252, 0.95) !important;
1167
- color: #1e40af !important;
1168
- border-color: rgba(59, 130, 246, 0.8) !important;
1169
- }
1170
-
1171
- .download-limiter-content h2 {
1172
- color: inherit !important;
1173
- margin: 0 0 1rem 0;
1174
- font-size: 1.5rem;
1175
- font-weight: 600;
1176
- }
1177
- .download-limiter-content p {
1178
- color: inherit !important;
1179
- margin: 0 0 1.5rem 0;
1180
- line-height: 1.6;
1181
- }
1182
- .download-limiter-signin-btn {
1183
- display: inline-flex;
1184
- align-items: center;
1185
- gap: 8px;
1186
- background: #65c3c8 !important;
1187
- color: #291334 !important;
1188
- border: none;
1189
- padding: 12px 20px;
1190
- border-radius: 8px;
1191
- font-size: 14px;
1192
- font-weight: 500;
1193
- cursor: pointer;
1194
- text-decoration: none;
1195
- transition: all 0.2s;
1196
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
1197
- }
1198
-
1199
- [data-theme="dark"] .download-limiter-signin-btn {
1200
- background: #3b82f6 !important;
1201
- color: #ffffff !important;
1202
- }
1203
-
1204
- [data-theme="cyberpunk"] .download-limiter-signin-btn {
1205
- background: #f59e0b !important;
1206
- color: #000000 !important;
1207
- }
1208
-
1209
- [data-theme="valentine"] .download-limiter-signin-btn {
1210
- background: #e91e7a !important;
1211
- color: #ffffff !important;
1212
- }
1213
-
1214
- [data-theme="bumblebee"] .download-limiter-signin-btn {
1215
- background: #fbbf24 !important;
1216
- color: #1c1917 !important;
1217
- }
1218
-
1219
- [data-theme="garden"] .download-limiter-signin-btn {
1220
- background: #22c55e !important;
1221
- color: #ffffff !important;
1222
- }
1223
-
1224
- [data-theme="emerald"] .download-limiter-signin-btn {
1225
- background: #10b981 !important;
1226
- color: #ffffff !important;
1227
- }
1228
-
1229
- [data-theme="corporate"] .download-limiter-signin-btn {
1230
- background: #3b82f6 !important;
1231
- color: #ffffff !important;
1232
- }
1233
-
1234
- [data-theme="forest"] .download-limiter-signin-btn {
1235
- background: #22c55e !important;
1236
- color: #1a1a1a !important;
1237
- }
1238
-
1239
- [data-theme="halloween"] .download-limiter-signin-btn {
1240
- background: #ff6500 !important;
1241
- color: #1a1a1a !important;
1242
- }
1243
-
1244
- [data-theme="synthwave"] .download-limiter-signin-btn {
1245
- background: #ba55d3 !important;
1246
- color: #201040 !important;
1247
- }
1248
-
1249
- [data-theme="dracula"] .download-limiter-signin-btn {
1250
- background: #8be9fd !important;
1251
- color: #282a36 !important;
1252
- }
1253
-
1254
- [data-theme="luxury"] .download-limiter-signin-btn {
1255
- background: #d4af37 !important;
1256
- color: #09090b !important;
1257
- }
1258
-
1259
- [data-theme="night"] .download-limiter-signin-btn {
1260
- background: #1e40af !important;
1261
- color: #ffffff !important;
1262
- }
1263
-
1264
- [data-theme="light"] .download-limiter-signin-btn {
1265
- background: #3b82f6 !important;
1266
- color: #ffffff !important;
1267
- }
1268
-
1269
- [data-theme="cupcake"] .download-limiter-signin-btn {
1270
- background: #8b4513 !important;
1271
- color: #ffffff !important;
1272
- }
1273
-
1274
- [data-theme="retro"] .download-limiter-signin-btn {
1275
- background: #d4a574 !important;
1276
- color: #ffffff !important;
1277
- }
1278
-
1279
- [data-theme="aqua"] .download-limiter-signin-btn {
1280
- background: #0891b2 !important;
1281
- color: #ffffff !important;
1282
- }
1283
-
1284
- [data-theme="lofi"] .download-limiter-signin-btn {
1285
- background: #1a1a1a !important;
1286
- color: #ffffff !important;
1287
- }
1288
-
1289
- [data-theme="pastel"] .download-limiter-signin-btn {
1290
- background: #7c3aed !important;
1291
- color: #ffffff !important;
1292
- }
1293
-
1294
- [data-theme="fantasy"] .download-limiter-signin-btn {
1295
- background: #be185d !important;
1296
- color: #ffffff !important;
1297
- }
1298
-
1299
- [data-theme="wireframe"] .download-limiter-signin-btn {
1300
- background: #dfdfdf !important;
1301
- color: #000000 !important;
1302
- border: 1px solid #000000 !important;
1303
- }
1304
-
1305
- [data-theme="black"] .download-limiter-signin-btn {
1306
- background: #ffffff !important;
1307
- color: #000000 !important;
1308
- }
1309
-
1310
- [data-theme="cmyk"] .download-limiter-signin-btn {
1311
- background: #ff00ff !important;
1312
- color: #000000 !important;
1313
- }
1314
-
1315
- [data-theme="autumn"] .download-limiter-signin-btn {
1316
- background: #ff8c00 !important;
1317
- color: #ffffff !important;
1318
- }
1319
-
1320
- [data-theme="business"] .download-limiter-signin-btn {
1321
- background: #3b82f6 !important;
1322
- color: #ffffff !important;
1323
- }
1324
-
1325
- [data-theme="acid"] .download-limiter-signin-btn {
1326
- background: #ff00ff !important;
1327
- color: #000000 !important;
1328
- }
1329
-
1330
- [data-theme="lemonade"] .download-limiter-signin-btn {
1331
- background: #22c55e !important;
1332
- color: #ffffff !important;
1333
- }
1334
-
1335
- [data-theme="coffee"] .download-limiter-signin-btn {
1336
- background: #a0522d !important;
1337
- color: #ffffff !important;
1338
- }
1339
-
1340
- [data-theme="winter"] .download-limiter-signin-btn {
1341
- background: #3b82f6 !important;
1342
- color: #ffffff !important;
1343
- }
1344
-
1345
- .download-limiter-signin-btn:hover {
1346
- opacity: 0.9;
1347
- transform: translateY(-1px);
1348
- box-shadow: 0 4px 8px rgba(0,0,0,0.15);
1349
- }
1350
-
1351
- /* Upgrade Button Styles for All Themes */
1352
- [data-theme="dark"] .upgrade-btn {
1353
- background: #3b82f6 !important;
1354
- color: #ffffff !important;
1355
- }
1356
-
1357
- [data-theme="cyberpunk"] .upgrade-btn {
1358
- background: #ff073a !important;
1359
- color: #ffffff !important;
1360
- }
1361
-
1362
- [data-theme="valentine"] .upgrade-btn {
1363
- background: #e91e7a !important;
1364
- color: #ffffff !important;
1365
- }
1366
-
1367
- [data-theme="bumblebee"] .upgrade-btn {
1368
- background: #f59e0b !important;
1369
- color: #ffffff !important;
1370
- }
1371
-
1372
- [data-theme="garden"] .upgrade-btn {
1373
- background: #10b981 !important;
1374
- color: #ffffff !important;
1375
- }
1376
-
1377
- [data-theme="emerald"] .upgrade-btn {
1378
- background: #10b981 !important;
1379
- color: #ffffff !important;
1380
- }
1381
-
1382
- [data-theme="corporate"] .upgrade-btn {
1383
- background: #3b82f6 !important;
1384
- color: #ffffff !important;
1385
- }
1386
-
1387
- [data-theme="forest"] .upgrade-btn {
1388
- background: #10b981 !important;
1389
- color: #ffffff !important;
1390
- }
1391
-
1392
- [data-theme="halloween"] .upgrade-btn {
1393
- background: #ff7b00 !important;
1394
- color: #000000 !important;
1395
- }
1396
-
1397
- [data-theme="synthwave"] .upgrade-btn {
1398
- background: #e879f9 !important;
1399
- color: #ffffff !important;
1400
- }
1401
-
1402
- [data-theme="dracula"] .upgrade-btn {
1403
- background: #bd93f9 !important;
1404
- color: #ffffff !important;
1405
- }
1406
-
1407
- [data-theme="luxury"] .upgrade-btn {
1408
- background: #d4af37 !important;
1409
- color: #000000 !important;
1410
- }
1411
-
1412
- [data-theme="night"] .upgrade-btn {
1413
- background: #38bdf8 !important;
1414
- color: #ffffff !important;
1415
- }
1416
-
1417
- [data-theme="light"] .upgrade-btn {
1418
- background: #3b82f6 !important;
1419
- color: #ffffff !important;
1420
- }
1421
-
1422
- [data-theme="cupcake"] .upgrade-btn {
1423
- background: #f472b6 !important;
1424
- color: #ffffff !important;
1425
- }
1426
-
1427
- [data-theme="retro"] .upgrade-btn {
1428
- background: #d4a574 !important;
1429
- color: #ffffff !important;
1430
- }
1431
-
1432
- [data-theme="aqua"] .upgrade-btn {
1433
- background: #06b6d4 !important;
1434
- color: #ffffff !important;
1435
- }
1436
-
1437
- [data-theme="lofi"] .upgrade-btn {
1438
- background: #a3a3a3 !important;
1439
- color: #000000 !important;
1440
- }
1441
-
1442
- [data-theme="pastel"] .upgrade-btn {
1443
- background: #a78bfa !important;
1444
- color: #ffffff !important;
1445
- }
1446
-
1447
- [data-theme="fantasy"] .upgrade-btn {
1448
- background: #f472b6 !important;
1449
- color: #ffffff !important;
1450
- }
1451
-
1452
- [data-theme="wireframe"] .upgrade-btn {
1453
- background: #dfdfdf !important;
1454
- color: #000000 !important;
1455
- border: 1px solid #000000 !important;
1456
- }
1457
-
1458
- [data-theme="black"] .upgrade-btn {
1459
- background: #ffffff !important;
1460
- color: #000000 !important;
1461
- }
1462
-
1463
- [data-theme="cmyk"] .upgrade-btn {
1464
- background: #0891b2 !important;
1465
- color: #ffffff !important;
1466
- }
1467
-
1468
- [data-theme="autumn"] .upgrade-btn {
1469
- background: #d97706 !important;
1470
- color: #ffffff !important;
1471
- }
1472
-
1473
- [data-theme="business"] .upgrade-btn {
1474
- background: #3b82f6 !important;
1475
- color: #ffffff !important;
1476
- }
1477
-
1478
- [data-theme="acid"] .upgrade-btn {
1479
- background: #84cc16 !important;
1480
- color: #000000 !important;
1481
- }
1482
-
1483
- [data-theme="lemonade"] .upgrade-btn {
1484
- background: #22c55e !important;
1485
- color: #ffffff !important;
1486
- }
1487
-
1488
- [data-theme="coffee"] .upgrade-btn {
1489
- background: #a0522d !important;
1490
- color: #ffffff !important;
1491
- }
1492
-
1493
- [data-theme="winter"] .upgrade-btn {
1494
- background: #3b82f6 !important;
1495
- color: #ffffff !important;
1496
- }
1497
-
1498
- /* Cancel Button Styles for All Themes */
1499
- [data-theme="dark"] .cancel-btn {
1500
- background: #4b5563 !important;
1501
- color: #ffffff !important;
1502
- }
1503
-
1504
- [data-theme="cyberpunk"] .cancel-btn {
1505
- background: #7e22ce !important;
1506
- color: #ffffff !important;
1507
- }
1508
-
1509
- [data-theme="valentine"] .cancel-btn {
1510
- background: #c11560 !important;
1511
- color: #ffffff !important;
1512
- }
1513
-
1514
- [data-theme="bumblebee"] .cancel-btn {
1515
- background: #d97706 !important;
1516
- color: #ffffff !important;
1517
- }
1518
-
1519
- [data-theme="garden"] .cancel-btn {
1520
- background: #059669 !important;
1521
- color: #ffffff !important;
1522
- }
1523
-
1524
- [data-theme="emerald"] .cancel-btn {
1525
- background: #059669 !important;
1526
- color: #ffffff !important;
1527
- }
1528
-
1529
- [data-theme="corporate"] .cancel-btn {
1530
- background: #6b7280 !important;
1531
- color: #ffffff !important;
1532
- }
1533
-
1534
- [data-theme="forest"] .cancel-btn {
1535
- background: #059669 !important;
1536
- color: #ffffff !important;
1537
- }
1538
-
1539
- [data-theme="halloween"] .cancel-btn {
1540
- background: #7c3aed !important;
1541
- color: #ffffff !important;
1542
- }
1543
-
1544
- [data-theme="synthwave"] .cancel-btn {
1545
- background: #7e22ce !important;
1546
- color: #ffffff !important;
1547
- }
1548
-
1549
- [data-theme="dracula"] .cancel-btn {
1550
- background: #6272a4 !important;
1551
- color: #ffffff !important;
1552
- }
1553
-
1554
- [data-theme="luxury"] .cancel-btn {
1555
- background: #8b5cf6 !important;
1556
- color: #ffffff !important;
1557
- }
1558
-
1559
- [data-theme="night"] .cancel-btn {
1560
- background: #0284c7 !important;
1561
- color: #ffffff !important;
1562
- }
1563
-
1564
- [data-theme="light"] .cancel-btn {
1565
- background: #6b7280 !important;
1566
- color: #ffffff !important;
1567
- }
1568
-
1569
- [data-theme="cupcake"] .cancel-btn {
1570
- background: #ec4899 !important;
1571
- color: #ffffff !important;
1572
- }
1573
-
1574
- [data-theme="retro"] .cancel-btn {
1575
- background: #b8925c !important;
1576
- color: #ffffff !important;
1577
- }
1578
-
1579
- [data-theme="aqua"] .cancel-btn {
1580
- background: #0891b2 !important;
1581
- color: #ffffff !important;
1582
- }
1583
-
1584
- [data-theme="lofi"] .cancel-btn {
1585
- background: #6b7280 !important;
1586
- color: #ffffff !important;
1587
- }
1588
-
1589
- [data-theme="pastel"] .cancel-btn {
1590
- background: #8b5cf6 !important;
1591
- color: #ffffff !important;
1592
- }
1593
-
1594
- [data-theme="fantasy"] .cancel-btn {
1595
- background: #ec4899 !important;
1596
- color: #ffffff !important;
1597
- }
1598
-
1599
- [data-theme="wireframe"] .cancel-btn {
1600
- background: #f5f5f5 !important;
1601
- color: #000000 !important;
1602
- border: 1px solid #000000 !important;
1603
- }
1604
-
1605
- [data-theme="black"] .cancel-btn {
1606
- background: #6b7280 !important;
1607
- color: #ffffff !important;
1608
- }
1609
-
1610
- [data-theme="cmyk"] .cancel-btn {
1611
- background: #0369a1 !important;
1612
- color: #ffffff !important;
1613
- }
1614
-
1615
- [data-theme="autumn"] .cancel-btn {
1616
- background: #c2410c !important;
1617
- color: #ffffff !important;
1618
- }
1619
-
1620
- [data-theme="business"] .cancel-btn {
1621
- background: #6b7280 !important;
1622
- color: #ffffff !important;
1623
- }
1624
-
1625
- [data-theme="acid"] .cancel-btn {
1626
- background: #65a30d !important;
1627
- color: #ffffff !important;
1628
- }
1629
-
1630
- [data-theme="lemonade"] .cancel-btn {
1631
- background: #16a34a !important;
1632
- color: #ffffff !important;
1633
- }
1634
-
1635
- [data-theme="coffee"] .cancel-btn {
1636
- background: #8b4513 !important;
1637
- color: #ffffff !important;
1638
- }
1639
-
1640
- [data-theme="winter"] .cancel-btn {
1641
- background: #1e40af !important;
1642
- color: #ffffff !important;
1643
- }
1644
-
1645
- /* Success Button Styles for All Themes */
1646
- [data-theme="dark"] .success-btn {
1647
- background: #10b981 !important;
1648
- color: #ffffff !important;
1649
- }
1650
-
1651
- [data-theme="cyberpunk"] .success-btn {
1652
- background: #00ff41 !important;
1653
- color: #000000 !important;
1654
- }
1655
-
1656
- [data-theme="valentine"] .success-btn {
1657
- background: #e91e7a !important;
1658
- color: #ffffff !important;
1659
- }
1660
-
1661
- [data-theme="bumblebee"] .success-btn {
1662
- background: #f59e0b !important;
1663
- color: #ffffff !important;
1664
- }
1665
-
1666
- [data-theme="garden"] .success-btn {
1667
- background: #10b981 !important;
1668
- color: #ffffff !important;
1669
- }
1670
-
1671
- [data-theme="emerald"] .success-btn {
1672
- background: #10b981 !important;
1673
- color: #ffffff !important;
1674
- }
1675
-
1676
- [data-theme="corporate"] .success-btn {
1677
- background: #10b981 !important;
1678
- color: #ffffff !important;
1679
- }
1680
-
1681
- [data-theme="forest"] .success-btn {
1682
- background: #10b981 !important;
1683
- color: #ffffff !important;
1684
- }
1685
-
1686
- [data-theme="halloween"] .success-btn {
1687
- background: #ff7b00 !important;
1688
- color: #000000 !important;
1689
- }
1690
-
1691
- [data-theme="synthwave"] .success-btn {
1692
- background: #00ff41 !important;
1693
- color: #000000 !important;
1694
- }
1695
-
1696
- [data-theme="dracula"] .success-btn {
1697
- background: #50fa7b !important;
1698
- color: #000000 !important;
1699
- }
1700
-
1701
- [data-theme="luxury"] .success-btn {
1702
- background: #d4af37 !important;
1703
- color: #000000 !important;
1704
- }
1705
-
1706
- [data-theme="night"] .success-btn {
1707
- background: #22d3ee !important;
1708
- color: #ffffff !important;
1709
- }
1710
-
1711
- [data-theme="light"] .success-btn {
1712
- background: #10b981 !important;
1713
- color: #ffffff !important;
1714
- }
1715
-
1716
- [data-theme="cupcake"] .success-btn {
1717
- background: #f472b6 !important;
1718
- color: #ffffff !important;
1719
- }
1720
-
1721
- [data-theme="retro"] .success-btn {
1722
- background: #d4a574 !important;
1723
- color: #ffffff !important;
1724
- }
1725
-
1726
- [data-theme="aqua"] .success-btn {
1727
- background: #06b6d4 !important;
1728
- color: #ffffff !important;
1729
- }
1730
-
1731
- [data-theme="lofi"] .success-btn {
1732
- background: #10b981 !important;
1733
- color: #ffffff !important;
1734
- }
1735
-
1736
- [data-theme="pastel"] .success-btn {
1737
- background: #34d399 !important;
1738
- color: #ffffff !important;
1739
- }
1740
-
1741
- [data-theme="fantasy"] .success-btn {
1742
- background: #f472b6 !important;
1743
- color: #ffffff !important;
1744
- }
1745
-
1746
- [data-theme="wireframe"] .success-btn {
1747
- background: #dfdfdf !important;
1748
- color: #000000 !important;
1749
- border: 1px solid #000000 !important;
1750
- }
1751
-
1752
- [data-theme="black"] .success-btn {
1753
- background: #10b981 !important;
1754
- color: #ffffff !important;
1755
- }
1756
-
1757
- [data-theme="cmyk"] .success-btn {
1758
- background: #06b6d4 !important;
1759
- color: #ffffff !important;
1760
- }
1761
-
1762
- [data-theme="autumn"] .success-btn {
1763
- background: #d97706 !important;
1764
- color: #ffffff !important;
1765
- }
1766
-
1767
- [data-theme="business"] .success-btn {
1768
- background: #10b981 !important;
1769
- color: #ffffff !important;
1770
- }
1771
-
1772
- [data-theme="acid"] .success-btn {
1773
- background: #84cc16 !important;
1774
- color: #000000 !important;
1775
- }
1776
-
1777
- [data-theme="lemonade"] .success-btn {
1778
- background: #22c55e !important;
1779
- color: #ffffff !important;
1780
- }
1781
-
1782
- [data-theme="coffee"] .success-btn {
1783
- background: #a0522d !important;
1784
- color: #ffffff !important;
1785
- }
1786
-
1787
- [data-theme="winter"] .success-btn {
1788
- background: #3b82f6 !important;
1789
- color: #ffffff !important;
1790
- }
1791
- .download-limiter-signout-btn {
1792
- background: #dc3545;
1793
- color: white;
1794
- border: none;
1795
- padding: 6px 12px;
1796
- border-radius: 4px;
1797
- font-size: 12px;
1798
- cursor: pointer;
1799
- margin-left: 8px;
1800
- }
1801
- .download-limiter-premium-badge {
1802
- background: linear-gradient(45deg, #f39c12, #e74c3c);
1803
- color: white;
1804
- padding: 2px 6px;
1805
- border-radius: 3px;
1806
- font-size: 10px;
1807
- margin-left: 8px;
1808
- font-weight: bold;
1809
- }
1810
- .download-limiter-btn-premium {
1811
- opacity: 0.7;
1812
- }
1813
- .download-limiter-success-modal {
1814
- display: none;
1815
- position: fixed;
1816
- top: 0;
1817
- left: 0;
1818
- width: 100%;
1819
- height: 100%;
1820
- background: rgba(0,0,0,0.5);
1821
- z-index: 10000;
1822
- align-items: center;
1823
- justify-content: center;
1824
- }
1825
- .download-limiter-success-modal.show { display: flex; }
1826
- .download-limiter-success-content {
1827
- background: white;
1828
- padding: 2rem;
1829
- border-radius: 8px;
1830
- max-width: 400px;
1831
- text-align: center;
1832
- box-shadow: 0 4px 20px rgba(0,0,0,0.15);
1833
- border-left: 4px solid #38a169;
1834
- }
1835
-
1836
- /* Single upgrade flow styles */
1837
- .single-upgrade-container {
1838
- margin: 20px 0;
1839
- text-align: center;
1840
- }
1841
-
1842
- .single-upgrade-content .upgrade-btn {
1843
- background: linear-gradient(135deg, #059669, #0d9488) !important;
1844
- color: white !important;
1845
- border: none !important;
1846
- padding: 16px 32px !important;
1847
- border-radius: 12px !important;
1848
- font-size: 18px !important;
1849
- font-weight: 600 !important;
1850
- cursor: pointer !important;
1851
- transition: all 0.3s ease !important;
1852
- box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3) !important;
1853
- margin-bottom: 16px !important;
1854
- min-width: 200px !important;
1855
- }
1856
-
1857
- .single-upgrade-content .upgrade-btn:hover {
1858
- background: linear-gradient(135deg, #047857, #0f766e) !important;
1859
- transform: translateY(-2px) !important;
1860
- box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4) !important;
1861
- }
1862
-
1863
- .single-upgrade-content .upgrade-description {
1864
- font-size: 14px !important;
1865
- color: #6b7280 !important;
1866
- margin: 12px 0 0 0 !important;
1867
- line-height: 1.5 !important;
1868
- max-width: 300px !important;
1869
- margin-left: auto !important;
1870
- margin-right: auto !important;
1871
- }
1872
-
1873
- /* Anonymous user usage count styles */
1874
- .lead-fast-anonymous-status {
1875
- display: flex;
1876
- align-items: center;
1877
- gap: 12px;
1878
- }
1879
-
1880
- .lead-fast-anonymous-status .lead-fast-count {
1881
- background: rgba(59, 130, 246, 0.1);
1882
- color: #1d4ed8;
1883
- padding: 6px 12px;
1884
- border-radius: 8px;
1885
- font-size: 14px;
1886
- font-weight: 500;
1887
- border: 1px solid rgba(59, 130, 246, 0.2);
1888
- }
1889
-
1890
- /* Loading state styles */
1891
- .lead-fast-loading-status {
1892
- display: flex;
1893
- align-items: center;
1894
- gap: 10px;
1895
- }
1896
-
1897
- .lead-fast-spinner {
1898
- width: 20px;
1899
- height: 20px;
1900
- color: #3b82f6;
1901
- }
1902
-
1903
- .lead-fast-loading-text {
1904
- font-size: 14px;
1905
- color: #6b7280;
1906
- font-weight: 500;
1907
- }
1908
-
1909
- /* Success button theming */
1910
- .download-limiter-btn.success-btn {
1911
- background: #059669 !important;
1912
- color: white !important;
1913
- border: none !important;
1914
- padding: 12px 24px !important;
1915
- border-radius: 8px !important;
1916
- cursor: pointer !important;
1917
- margin-top: 20px !important;
1918
- font-size: 16px !important;
1919
- font-weight: 500 !important;
1920
- transition: all 0.2s ease !important;
1921
- }
1922
-
1923
- .download-limiter-btn.success-btn:hover {
1924
- background: #047857 !important;
1925
- transform: translateY(-1px) !important;
1926
- }
1927
-
1928
- /* Theme-specific success button colors */
1929
- [data-theme="cyberpunk"] .download-limiter-btn.success-btn {
1930
- background: #0ea5e9 !important;
1931
- box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3) !important;
1932
- }
1933
-
1934
- [data-theme="cyberpunk"] .download-limiter-btn.success-btn:hover {
1935
- background: #0284c7 !important;
1936
- }
1937
-
1938
- [data-theme="valentine"] .download-limiter-btn.success-btn {
1939
- background: #be185d !important;
1940
- }
1941
-
1942
- [data-theme="valentine"] .download-limiter-btn.success-btn:hover {
1943
- background: #9d174d !important;
1944
- }
1945
-
1946
- [data-theme="bumblebee"] .download-limiter-btn.success-btn {
1947
- background: #f59e0b !important;
1948
- }
1949
-
1950
- [data-theme="bumblebee"] .download-limiter-btn.success-btn:hover {
1951
- background: #d97706 !important;
1952
- }
1953
-
1954
- [data-theme="garden"] .download-limiter-btn.success-btn {
1955
- background: #16a34a !important;
1956
- }
1957
-
1958
- [data-theme="garden"] .download-limiter-btn.success-btn:hover {
1959
- background: #15803d !important;
1960
- }
1961
-
1962
- /* Google Sign-in button theming */
1963
- .download-limiter-btn.google-signin-btn {
1964
- background: #4285f4 !important;
1965
- color: white !important;
1966
- border: none !important;
1967
- padding: 12px 24px !important;
1968
- border-radius: 8px !important;
1969
- cursor: pointer !important;
1970
- margin-right: 10px !important;
1971
- display: inline-flex !important;
1972
- align-items: center !important;
1973
- gap: 8px !important;
1974
- font-size: 14px !important;
1975
- font-weight: 500 !important;
1976
- transition: all 0.2s ease !important;
1977
- }
1978
-
1979
- .download-limiter-btn.google-signin-btn:hover {
1980
- background: #3367d6 !important;
1981
- transform: translateY(-1px) !important;
1982
- }
1983
-
1984
- /* Upgrade button theming */
1985
- .download-limiter-btn.upgrade-btn {
1986
- background: #059669 !important;
1987
- color: white !important;
1988
- border: none !important;
1989
- padding: 12px 24px !important;
1990
- border-radius: 8px !important;
1991
- cursor: pointer !important;
1992
- margin-right: 10px !important;
1993
- font-size: 16px !important;
1994
- font-weight: 500 !important;
1995
- transition: all 0.2s ease !important;
1996
- }
1997
-
1998
- .download-limiter-btn.upgrade-btn:hover {
1999
- background: #047857 !important;
2000
- transform: translateY(-1px) !important;
2001
- }
2002
-
2003
- /* Theme-specific button colors */
2004
- [data-theme="cyberpunk"] .download-limiter-btn.upgrade-btn {
2005
- background: #0ea5e9 !important;
2006
- box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3) !important;
2007
- }
2008
-
2009
- [data-theme="valentine"] .download-limiter-btn.upgrade-btn {
2010
- background: #be185d !important;
2011
- }
2012
-
2013
- [data-theme="bumblebee"] .download-limiter-btn.upgrade-btn {
2014
- background: #f59e0b !important;
2015
- }
2016
-
2017
- [data-theme="garden"] .download-limiter-btn.upgrade-btn {
2018
- background: #16a34a !important;
2019
- }
2020
-
2021
- /* Cancel button container and styling - positioned at very bottom */
2022
- .download-limiter-cancel-container {
2023
- margin-top: 30px !important;
2024
- padding-top: 20px !important;
2025
- border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
2026
- text-align: center !important;
2027
- position: relative !important;
2028
- bottom: 0 !important;
2029
- }
2030
-
2031
- .download-limiter-btn.cancel-btn {
2032
- background: transparent !important;
2033
- color: #6b7280 !important;
2034
- border: none !important;
2035
- padding: 8px 16px !important;
2036
- border-radius: 6px !important;
2037
- cursor: pointer !important;
2038
- font-size: 13px !important;
2039
- font-weight: 400 !important;
2040
- transition: all 0.2s ease !important;
2041
- text-decoration: underline !important;
2042
- margin: 0 auto !important;
2043
- display: block !important;
2044
- }
2045
-
2046
- .download-limiter-btn.cancel-btn:hover {
2047
- color: #374151 !important;
2048
- background: rgba(107, 114, 128, 0.1) !important;
2049
- text-decoration: none !important;
2050
- }
2051
-
2052
- /* Theme-specific cancel button border */
2053
- [data-theme="dark"] .download-limiter-cancel-container {
2054
- border-top-color: rgba(255, 255, 255, 0.1) !important;
2055
- }
2056
-
2057
- [data-theme="dark"] .download-limiter-btn.cancel-btn {
2058
- color: #9ca3af !important;
2059
- }
2060
-
2061
- [data-theme="dark"] .download-limiter-btn.cancel-btn:hover {
2062
- color: #d1d5db !important;
2063
- background: rgba(156, 163, 175, 0.1) !important;
2064
- }
2065
-
2066
- [data-theme="cyberpunk"] .download-limiter-cancel-container {
2067
- border-top-color: rgba(14, 165, 233, 0.2) !important;
2068
- }
2069
-
2070
- [data-theme="cyberpunk"] .download-limiter-btn.cancel-btn {
2071
- color: #0ea5e9 !important;
2072
- }
2073
-
2074
- [data-theme="cyberpunk"] .download-limiter-btn.cancel-btn:hover {
2075
- color: #38bdf8 !important;
2076
- background: rgba(14, 165, 233, 0.1) !important;
2077
- }
2078
- `;
2079
- document.head.appendChild(styles);
2080
- }
2081
- injectDaisyUI() {
2082
- //console.log('🎨 [THEME DEBUG] injectDaisyUI called');
2083
- //console.log('🎨 [THEME DEBUG] Theme config:', this.config.theme);
2084
- // Check if DaisyUI is already loaded
2085
- const existingLink = document.querySelector('link[href*="daisyui"]');
2086
- if (existingLink) {
2087
- //console.log('🎨 [THEME DEBUG] DaisyUI already exists:', existingLink);
2088
- // Apply theme if DaisyUI already exists
2089
- if (this.config.theme?.name) {
2090
- const themeName = this.config.theme.name.toLowerCase();
2091
- //console.log('🎨 [THEME DEBUG] Setting existing theme:', themeName);
2092
- document.documentElement.setAttribute('data-theme', themeName);
2093
- //console.log('🎨 [THEME DEBUG] Current data-theme attribute:', document.documentElement.getAttribute('data-theme'));
2094
- }
2095
- return;
2096
- }
2097
- //console.log('🎨 [THEME DEBUG] No existing DaisyUI found, injecting...');
2098
- // Note: Tailwind CSS is not needed as we use custom CSS for all styling
2099
- // Apply theme directly using our custom CSS - no external dependencies needed
2100
- if (this.config.theme?.name) {
2101
- const themeName = this.config.theme.name.toLowerCase();
2102
- document.documentElement.setAttribute('data-theme', themeName);
2103
- // Update status displays immediately since no CSS loading is needed
2104
- this.updateStatusDisplays();
2105
- }
2106
- }
2107
- createPaywallModal() {
2108
- if (document.getElementById('download-limiter-paywall'))
2109
- return;
2110
- const modal = document.createElement('div');
2111
- modal.id = 'download-limiter-paywall';
2112
- modal.className = 'download-limiter-modal';
2113
- modal.innerHTML = `
2114
- <div class="download-limiter-content">
2115
- <h3 id="download-limiter-paywall-title">Usage Limit Reached</h3>
2116
- <p id="download-limiter-paywall-subtitle">You've used all your free attempts. Upgrade to premium for unlimited usage!</p>
2117
-
2118
- <!-- Auth Section (shows when not signed in) -->
2119
- <div id="download-limiter-auth-section" style="margin: 20px 0;">
2120
- <p>Sign in to continue or upgrade to premium</p>
2121
- <button id="download-limiter-signin-btn" class="download-limiter-btn google-signin-btn">
2122
- <svg width="18" height="18" viewBox="0 0 18 18" fill="none">
2123
- <path d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a8.8 8.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18z" fill="white"/>
2124
- <path d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2.04a4.8 4.8 0 0 1-2.7.75 4.8 4.8 0 0 1-4.52-3.4H1.83v2.07A8 8 0 0 0 8.98 17z" fill="white"/>
2125
- <path d="M4.46 10.37a4.8 4.8 0 0 1-.25-1.37c0-.48.09-.94.25-1.37V5.56H1.83a8 8 0 0 0 0 6.88l2.63-2.07z" fill="white"/>
2126
- <path d="M8.98 3.77c1.32 0 2.5.45 3.44 1.35l2.58-2.58C13.94.64 11.66 0 8.98 0A8 8 0 0 0 1.83 5.56l2.63 2.07c.61-1.8 2.26-3.86 4.52-3.86z" fill="white"/>
2127
- </svg>
2128
- Sign in with Google
2129
- </button>
2130
- </div>
2131
-
2132
- <!-- Payment Section (shows when signed in) -->
2133
- <div id="download-limiter-payment-section" style="margin: 20px 0; display: none;">
2134
- <button id="download-limiter-upgrade-btn" class="download-limiter-btn upgrade-btn">
2135
- Upgrade to Premium
2136
- </button>
2137
- </div>
2138
-
2139
- <div class="download-limiter-cancel-container">
2140
- <button id="download-limiter-close-btn" class="download-limiter-btn cancel-btn">
2141
- Cancel
2142
- </button>
2143
- </div>
2144
- </div>
2145
- `;
2146
- document.body.appendChild(modal);
2147
- // Set up event handlers
2148
- modal.querySelector('#download-limiter-signin-btn').addEventListener('click', async () => {
2149
- await this.signIn();
2150
- });
2151
- modal.querySelector('#download-limiter-upgrade-btn').addEventListener('click', async () => {
2152
- const payment = await this.createPayment();
2153
- if (payment?.checkout_url) {
2154
- window.location.href = payment.checkout_url;
2155
- }
2156
- });
2157
- modal.querySelector('#download-limiter-close-btn').addEventListener('click', () => {
2158
- if (this.config.options?.debug) {
2159
- console.log('🔍 DEBUG: Cancel button clicked');
2160
- console.log('🔍 DEBUG: this.config.feedback:', this.config.feedback);
2161
- console.log('🔍 DEBUG: this.config.email:', this.config.email);
2162
- console.log('🔍 DEBUG: Feedback config exists:', !!(this.config.feedback || this.config.email));
2163
- }
2164
- // Show feedback form if feedback config exists, otherwise just close
2165
- if (this.config.feedback || this.config.email) {
2166
- if (this.config.options?.debug) {
2167
- console.log('🔍 DEBUG: Showing feedback form');
2168
- }
2169
- this.showFeedbackForm();
2170
- }
2171
- else {
2172
- if (this.config.options?.debug) {
2173
- console.log('🔍 DEBUG: No email config, just closing modal');
2174
- }
2175
- modal.classList.remove('show');
2176
- }
2177
- });
2178
- // Removed click-outside-to-close behavior to encourage users to use the Cancel button
2179
- // which triggers the feedback form. This improves feedback collection.
2180
- }
2181
- createSuccessModal() {
2182
- if (document.getElementById('download-limiter-success'))
2183
- return;
2184
- const modal = document.createElement('div');
2185
- modal.id = 'download-limiter-success';
2186
- modal.className = 'download-limiter-modal'; // Use same modal class as paywall
2187
- modal.innerHTML = `
2188
- <div class="download-limiter-content"> <!-- Use same content class as paywall for theming -->
2189
- <h3 id="download-limiter-success-title">Action Started!</h3>
2190
- <p id="download-limiter-success-message">Your action completed successfully!</p>
2191
- <button id="download-limiter-success-close" class="download-limiter-btn success-btn">
2192
- OK
2193
- </button>
2194
- </div>
2195
- `;
2196
- document.body.appendChild(modal);
2197
- // Set up event handlers
2198
- modal.querySelector('#download-limiter-success-close').addEventListener('click', () => {
2199
- modal.classList.remove('show');
2200
- });
2201
- modal.addEventListener('click', (e) => {
2202
- if (e.target === modal) {
2203
- modal.classList.remove('show');
2204
- }
2205
- });
2206
- }
2207
- showFeedbackForm() {
2208
- // const feedbackStartTime = Date.now();
2209
- // console.log(`🕐 [FEEDBACK] showFeedbackForm called: ${new Date(feedbackStartTime).toISOString()}`);
2210
- // Hide paywall first
2211
- // const paywallHideStart = Date.now();
2212
- const paywall = document.getElementById('download-limiter-paywall');
2213
- if (paywall) {
2214
- paywall.classList.remove('show');
2215
- // console.log(`🕐 [FEEDBACK] Paywall hidden: ${Date.now() - paywallHideStart}ms`);
2216
- }
2217
- // Create or show feedback modal
2218
- // const createFeedbackStart = Date.now();
2219
- this.createFeedbackModal();
2220
- // console.log(`🕐 [FEEDBACK] createFeedbackModal completed: ${Date.now() - createFeedbackStart}ms`);
2221
- const modal = document.getElementById('download-limiter-feedback');
2222
- if (modal) {
2223
- modal.classList.add('show');
2224
- // console.log(`🕐 [FEEDBACK] Feedback modal shown: ${Date.now() - feedbackStartTime}ms total`);
2225
- }
2226
- }
2227
- createFeedbackModal() {
2228
- if (document.getElementById('download-limiter-feedback')) {
2229
- if (this.config.options?.debug) {
2230
- console.log('🔍 DEBUG: Feedback modal already exists');
2231
- }
2232
- return;
2233
- }
2234
- // Get feedback configuration or fallback to legacy email config
2235
- const feedbackConfig = this.config.feedback || (this.config.email ? {
2236
- form: {
2237
- title: 'Quick Feedback',
2238
- description: 'Why didn\'t you upgrade?',
2239
- option1: 'Not useful for my needs',
2240
- option2: 'Didn\'t find what I was looking for',
2241
- option3: 'Just trying it out'
2242
- },
2243
- email: this.config.email
2244
- } : null);
2245
- if (this.config.options?.debug) {
2246
- console.log('🔍 DEBUG: Feedback config:', feedbackConfig);
2247
- console.log('🔍 DEBUG: this.config.feedback:', this.config.feedback);
2248
- console.log('🔍 DEBUG: this.config.email:', this.config.email);
2249
- }
2250
- if (!feedbackConfig) {
2251
- if (this.config.options?.debug) {
2252
- console.log('🔍 DEBUG: No feedback config found, not creating modal');
2253
- }
2254
- return;
2255
- }
2256
- const modal = document.createElement('div');
2257
- modal.id = 'download-limiter-feedback';
2258
- modal.className = 'download-limiter-modal';
2259
- modal.innerHTML = `
2260
- <div class="download-limiter-content">
2261
- <h3>${feedbackConfig.form.title}</h3>
2262
- <p style="margin-bottom: 20px;">${feedbackConfig.form.description}</p>
2263
-
2264
- <form id="feedback-form" style="text-align: left;">
2265
- <div style="margin-bottom: 15px;">
2266
- <label style="display: block; margin-bottom: 8px;">
2267
- <input type="radio" name="reason" value="option1" style="margin-right: 8px;">
2268
- ${feedbackConfig.form.option1}
2269
- </label>
2270
- <label style="display: block; margin-bottom: 8px;">
2271
- <input type="radio" name="reason" value="option2" style="margin-right: 8px;">
2272
- ${feedbackConfig.form.option2}
2273
- </label>
2274
- <label style="display: block; margin-bottom: 8px;">
2275
- <input type="radio" name="reason" value="option3" style="margin-right: 8px;">
2276
- ${feedbackConfig.form.option3}
2277
- </label>
2278
- </div>
2279
-
2280
- <div style="margin-bottom: 15px;">
2281
- <label for="feedback-details" style="display: block; margin-bottom: 5px;">Tell us more:</label>
2282
- <textarea
2283
- id="feedback-details"
2284
- name="details"
2285
- rows="3"
2286
- style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"
2287
- placeholder="Your feedback helps us improve..." maxlength="200"></textarea>
2288
- </div>
2289
-
2290
- <div style="margin-bottom: 20px;">
2291
- <label for="feedback-email" style="display: block; margin-bottom: 5px;">
2292
- Email (optional):
2293
- </label>
2294
- <input
2295
- type="email"
2296
- id="feedback-email"
2297
- name="email"
2298
- style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"
2299
- placeholder="your@email.com">
2300
- <small style="color: #666; display: block; margin-top: 4px;">
2301
- Only if you want us to reach out about what you mentioned above. We don't follow up unless you want us to
2302
- </small>
2303
- </div>
2304
-
2305
-
2306
- <div style="text-align: center;">
2307
- <button type="submit" class="download-limiter-btn success-btn" style="margin-right: 10px;">
2308
- Submit Feedback
2309
- </button>
2310
- <button type="button" id="feedback-skip-btn" class="download-limiter-btn cancel-btn">
2311
- Skip
2312
- </button>
2313
- </div>
2314
- </form>
2315
- </div>
2316
- `;
2317
- document.body.appendChild(modal);
2318
- if (this.config.options?.debug) {
2319
- console.log('🔍 DEBUG: Feedback modal created and added to DOM');
2320
- }
2321
- // Set up event listeners
2322
- const form = modal.querySelector('#feedback-form');
2323
- form.addEventListener('submit', (e) => {
2324
- e.preventDefault();
2325
- this.submitFeedback(form);
2326
- });
2327
- modal.querySelector('#feedback-skip-btn').addEventListener('click', () => {
2328
- modal.classList.remove('show');
2329
- });
2330
- modal.addEventListener('click', (e) => {
2331
- if (e.target === modal) {
2332
- modal.classList.remove('show');
2333
- }
2334
- });
2335
- }
2336
- async submitFeedback(form) {
2337
- const formData = new FormData(form);
2338
- const reason = formData.get('reason');
2339
- const details = formData.get('details');
2340
- const email = formData.get('email');
2341
- if (!reason) {
2342
- alert('Please select a reason');
2343
- return;
2344
- }
2345
- const feedbackData = {
2346
- reason,
2347
- details,
2348
- email: email || undefined,
2349
- timestamp: new Date().toISOString(),
2350
- userAgent: navigator.userAgent,
2351
- appId: this.config.appId
2352
- };
2353
- try {
2354
- await this.sendFeedbackEmail(feedbackData);
2355
- // Close feedback modal
2356
- const modal = document.getElementById('download-limiter-feedback');
2357
- if (modal) {
2358
- modal.classList.remove('show');
2359
- }
2360
- // Show thank you message
2361
- alert('Thank you for your feedback!');
2362
- }
2363
- catch (error) {
2364
- console.error('Failed to send feedback:', error);
2365
- alert('Failed to send feedback. Please try again.');
2366
- }
2367
- }
2368
- async sendFeedbackEmail(feedbackData) {
2369
- // Get email config - handle both new array format and legacy format
2370
- let emailConfig;
2371
- if (this.config.feedback?.email) {
2372
- // New array format - use first provider (typically resend)
2373
- if (Array.isArray(this.config.feedback.email)) {
2374
- emailConfig = this.config.feedback.email[0];
2375
- }
2376
- else {
2377
- // Legacy format fallback
2378
- emailConfig = this.config.feedback.email;
2379
- }
2380
- }
2381
- else if (this.config.email) {
2382
- // Deprecated legacy email config
2383
- emailConfig = {
2384
- provider: 'resend',
2385
- apiKey: this.config.email.resendApiKey,
2386
- fromEmail: this.config.email.fromEmail
2387
- };
2388
- }
2389
- if (!emailConfig) {
2390
- throw new Error('Email configuration not available');
2391
- }
2392
- const emailBody = `
2393
- New Feedback from ${this.config.appId}
2394
-
2395
- Reason: ${feedbackData.reason}
2396
- Details: ${feedbackData.details}
2397
- User Email: ${feedbackData.email || 'Not provided'}
2398
- Timestamp: ${feedbackData.timestamp}
2399
- User Agent: ${feedbackData.userAgent}
2400
- `.trim();
2401
- // Handle different email providers
2402
- let response;
2403
- if (emailConfig.provider === 'resend' || !emailConfig.provider) {
2404
- response = await fetch('https://api.resend.com/emails', {
2405
- method: 'POST',
2406
- headers: {
2407
- 'Content-Type': 'application/json',
2408
- 'Authorization': `Bearer ${emailConfig.apiKey || emailConfig.resendApiKey}`
2409
- },
2410
- body: JSON.stringify({
2411
- from: emailConfig.fromEmail,
2412
- to: [emailConfig.fromEmail], // Send feedback to yourself
2413
- subject: `Feedback from ${this.config.appId}`,
2414
- text: emailBody
2415
- })
2416
- });
2417
- }
2418
- else {
2419
- throw new Error(`Unsupported email provider: ${emailConfig.provider}`);
2420
- }
2421
- if (!response.ok) {
2422
- throw new Error(`Email API error: ${response.status}`);
2423
- }
2424
- }
2425
- createAuthUI() {
2426
- if (document.getElementById('lead-fast-profile'))
2427
- return;
2428
- const profileContainer = document.createElement('div');
2429
- profileContainer.id = 'lead-fast-profile';
2430
- profileContainer.className = 'lead-fast-profile';
2431
- document.body.appendChild(profileContainer);
2432
- }
2433
- createStatusDisplay() {
2434
- if (document.getElementById('download-limiter-status'))
2435
- return;
2436
- const statusDiv = document.createElement('div');
2437
- statusDiv.id = 'download-limiter-status';
2438
- statusDiv.className = 'download-limiter-status';
2439
- document.body.appendChild(statusDiv);
2440
- }
2441
- createGlobalStatusDisplay() {
2442
- this.createStatusDisplay();
2443
- }
2444
- showPaywallInstant(status) {
2445
- // const showStartTime = Date.now();
2446
- // console.log(`🕐 [MODAL] showPaywallInstant started: ${new Date(showStartTime).toISOString()}`);
2447
- // Ensure modal exists before trying to show it
2448
- // const createStartTime = Date.now();
2449
- this.createPaywallModal();
2450
- // console.log(`🕐 [MODAL] createPaywallModal completed: ${Date.now() - createStartTime}ms`);
2451
- const modal = document.getElementById('download-limiter-paywall');
2452
- if (modal) {
2453
- // console.log(`🕐 [MODAL] Modal found in DOM: ${Date.now() - showStartTime}ms`);
2454
- // Update paywall title with exact count (no API call needed)
2455
- const titleEl = modal.querySelector('#download-limiter-paywall-title');
2456
- if (titleEl) {
2457
- titleEl.textContent = `You've used ${status.limit} free attempts`;
2458
- // console.log(`🕐 [MODAL] Title updated: ${Date.now() - showStartTime}ms`);
2459
- }
2460
- // Show appropriate section based on auth state
2461
- const authSection = modal.querySelector('#download-limiter-auth-section');
2462
- const paymentSection = modal.querySelector('#download-limiter-payment-section');
2463
- if (!this.currentUser) {
2464
- // console.log(`🕐 [MODAL] Setting up anonymous user flow: ${Date.now() - showStartTime}ms`);
2465
- // Anonymous user - show single upgrade flow
2466
- const subtitleEl = modal.querySelector('#download-limiter-paywall-subtitle');
2467
- if (subtitleEl) {
2468
- subtitleEl.textContent = 'Sign in to continue. If you\'re already premium, you\'ll get unlimited access. New users can upgrade after signing in.';
2469
- }
2470
- // Hide separate auth/payment sections and show single upgrade button
2471
- authSection.style.display = 'none';
2472
- paymentSection.style.display = 'none';
2473
- // Show single upgrade button
2474
- // const upgradeStartTime = Date.now();
2475
- this.showSingleUpgradeFlow(modal);
2476
- // console.log(`🕐 [MODAL] Single upgrade flow setup: ${Date.now() - upgradeStartTime}ms`);
2477
- }
2478
- else {
2479
- // console.log(`🕐 [MODAL] Setting up signed-in user flow: ${Date.now() - showStartTime}ms`);
2480
- // Existing flow for signed-in users - direct to payment
2481
- authSection.style.display = 'none';
2482
- paymentSection.style.display = 'block';
2483
- }
2484
- modal.classList.add('show');
2485
- // console.log(`🕐 [MODAL] Modal shown (classList.add('show')): ${Date.now() - showStartTime}ms`);
2486
- }
2487
- }
2488
- async showPaywall() {
2489
- // Get current status if not cached
2490
- const status = await this.getDownloadStatus();
2491
- this.showPaywallInstant(status);
2492
- }
2493
- showSingleUpgradeFlow(modal) {
2494
- // Create single upgrade button that handles both login and payment
2495
- let upgradeContainer = modal.querySelector('.single-upgrade-container');
2496
- if (!upgradeContainer) {
2497
- upgradeContainer = document.createElement('div');
2498
- upgradeContainer.className = 'single-upgrade-container';
2499
- upgradeContainer.innerHTML = `
2500
- <div class="single-upgrade-content">
2501
- <button class="download-limiter-btn upgrade-btn" id="single-upgrade-btn">
2502
- Continue with Google
2503
- </button>
2504
- <!--<p class="upgrade-description">
2505
- Sign in to restore access. Premium members get unlimited usage immediately.
2506
- </p>-->
2507
- </div>
2508
- `;
2509
- // Insert before the cancel container to keep cancel at the bottom
2510
- const cancelContainer = modal.querySelector('.download-limiter-cancel-container');
2511
- if (cancelContainer) {
2512
- modal.querySelector('.download-limiter-content')?.insertBefore(upgradeContainer, cancelContainer);
2513
- }
2514
- else {
2515
- modal.querySelector('.download-limiter-content')?.appendChild(upgradeContainer);
2516
- }
2517
- }
2518
- upgradeContainer.style.display = 'block';
2519
- // Add click handler for single upgrade flow
2520
- const upgradeBtn = modal.querySelector('#single-upgrade-btn');
2521
- if (upgradeBtn) {
2522
- upgradeBtn.replaceWith(upgradeBtn.cloneNode(true)); // Remove existing listeners
2523
- const newUpgradeBtn = modal.querySelector('#single-upgrade-btn');
2524
- newUpgradeBtn?.addEventListener('click', async () => {
2525
- try {
2526
- // Step 1: Sign in with Google
2527
- const { error } = await this.supabase.auth.signInWithOAuth({
2528
- provider: 'google',
2529
- options: {
2530
- redirectTo: `${window.location.origin}${window.location.pathname}?upgrade=true`
2531
- }
2532
- });
2533
- if (error) {
2534
- console.error('Sign in error:', error);
2535
- this.showError('Sign In Failed', 'Failed to sign in with Google. Please try again.');
2536
- }
2537
- // OAuth will redirect, so no further action needed here
2538
- }
2539
- catch (error) {
2540
- console.error('Upgrade flow error:', error);
2541
- this.showError('Upgrade Failed', 'Failed to start upgrade process. Please try again.');
2542
- }
2543
- });
2544
- }
2545
- }
2546
- showSuccess(title, message) {
2547
- const modal = document.getElementById('download-limiter-success');
2548
- if (modal) {
2549
- const titleEl = modal.querySelector('#download-limiter-success-title');
2550
- const messageEl = modal.querySelector('#download-limiter-success-message');
2551
- if (titleEl)
2552
- titleEl.textContent = title;
2553
- if (messageEl)
2554
- messageEl.textContent = message;
2555
- modal.classList.add('show');
2556
- // No auto-hide - let user dismiss manually
2557
- }
2558
- }
2559
- showError(title, message) {
2560
- // Create a clean error toast instead of alert
2561
- const toast = document.createElement('div');
2562
- toast.style.cssText = `
2563
- position: fixed;
2564
- top: 20px;
2565
- right: 20px;
2566
- background: #fee2e2;
2567
- border: 1px solid #fecaca;
2568
- color: #dc2626;
2569
- padding: 12px 16px;
2570
- border-radius: 8px;
2571
- font-size: 14px;
2572
- font-weight: 500;
2573
- line-height: 1.4;
2574
- max-width: 300px;
2575
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
2576
- z-index: 10000;
2577
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
2578
- `;
2579
- toast.innerHTML = `
2580
- <div style="font-weight: 600; margin-bottom: 4px;">${title}</div>
2581
- <div style="font-size: 13px; opacity: 0.9;">${message}</div>
2582
- `;
2583
- document.body.appendChild(toast);
2584
- // Auto-remove after 5 seconds
2585
- setTimeout(() => {
2586
- if (toast.parentNode) {
2587
- toast.parentNode.removeChild(toast);
2588
- }
2589
- }, 5000);
2590
- // Click to dismiss
2591
- toast.addEventListener('click', () => {
2592
- if (toast.parentNode) {
2593
- toast.parentNode.removeChild(toast);
2594
- }
2595
- });
2596
- }
2597
- showConnectionError() {
2598
- this.showError('Connection Error', 'Server connection required for download verification. Please check your configuration and try again.');
2599
- }
2600
- showPaymentConfigError() {
2601
- this.showError('Payment Configuration Error', 'Payment system is not properly configured. Please contact support.');
2602
- }
2603
- disableDownloadButtons(errorType) {
2604
- // Find all buttons that were attached by the library
2605
- const buttons = document.querySelectorAll('[data-leadfast-attached]');
2606
- const errorMessages = {
2607
- connection: 'Download disabled: Server connection required',
2608
- payment: 'Download disabled: Payment configuration error',
2609
- security_key: 'Download disabled: Invalid or missing security key'
2610
- };
2611
- const statusMessages = {
2612
- connection: '⚠️ Connection Error - Downloads Disabled',
2613
- payment: '⚠️ Payment Config Error - Downloads Disabled',
2614
- security_key: '🔐 Invalid Security Key - Please Update Configuration'
2615
- };
2616
- buttons.forEach(button => {
2617
- const btnElement = button;
2618
- btnElement.disabled = true;
2619
- btnElement.style.opacity = '0.5';
2620
- btnElement.style.cursor = 'not-allowed';
2621
- btnElement.title = errorMessages[errorType];
2622
- });
2623
- // Update user section to show error
2624
- const userSection = document.querySelector('.lead-fast-user-section');
2625
- if (userSection) {
2626
- userSection.innerHTML = `
2627
- <div style="
2628
- color: #ef4444;
2629
- padding: 6px 8px;
2630
- font-size: 12px;
2631
- font-weight: 500;
2632
- line-height: 1.2;
2633
- border-radius: 4px;
2634
- background: rgba(239, 68, 68, 0.05);
2635
- border: 1px solid rgba(239, 68, 68, 0.2);
2636
- max-width: 200px;
2637
- text-align: center;
2638
- ">
2639
- ${statusMessages[errorType]}
2640
- </div>
2641
- `;
2642
- }
2643
- }
2644
- async updateStatusDisplays() {
2645
- //console.log('🎨 [THEME DEBUG] updateStatusDisplays called');
2646
- // Check for security key error first (most specific)
2647
- if (this.securityKeyFailed) {
2648
- this.disableDownloadButtons('security_key');
2649
- return;
2650
- }
2651
- // If connection failed, disable all download buttons
2652
- if (this.supabaseConnectionFailed) {
2653
- this.disableDownloadButtons('connection');
2654
- return;
2655
- }
2656
- // If payment configuration is invalid, disable all download buttons
2657
- if (this.config.payment && this.paymentConnectionFailed) {
2658
- this.disableDownloadButtons('payment');
2659
- return;
2660
- }
2661
- // Show loading state
2662
- this.isLoadingStatus = true;
2663
- this.updateUserSection(null); // Show loading UI
2664
- const status = await this.getDownloadStatus();
2665
- // Clear loading state
2666
- this.isLoadingStatus = false;
2667
- // CRITICAL: Check again AFTER API call - flag may have been set during getDownloadStatus
2668
- if (this.securityKeyFailed) {
2669
- this.disableDownloadButtons('security_key');
2670
- return;
2671
- }
2672
- if (this.supabaseConnectionFailed) {
2673
- this.disableDownloadButtons('connection');
2674
- return;
2675
- }
2676
- this.updateUserSection(status);
2677
- }
2678
- createTitleBar() {
2679
- //console.log('🎨 [THEME DEBUG] Creating title bar');
2680
- // Create the profile div if it doesn't exist
2681
- let profileDiv = document.getElementById('lead-fast-profile');
2682
- if (!profileDiv) {
2683
- profileDiv = document.createElement('div');
2684
- profileDiv.id = 'lead-fast-profile';
2685
- profileDiv.className = 'lead-fast-profile';
2686
- document.body.appendChild(profileDiv);
2687
- }
2688
- // Get title bar configuration
2689
- const titleConfig = this.config.titleBar || {};
2690
- const title = titleConfig.title || 'My App';
2691
- const titleImage = titleConfig.titleImage;
2692
- const links = titleConfig.links || [];
2693
- // Always create title bar with logo and navigation
2694
- profileDiv.innerHTML = `
2695
- <div class="lead-fast-title-bar">
2696
- <div class="lead-fast-title-section">
2697
- <a href="#" class="lead-fast-logo">
2698
- ${titleImage ? `<img src="${titleImage}" alt="${title}">` : ''}
2699
- <span>${title}</span>
2700
- </a>
2701
- <nav class="lead-fast-nav">
2702
- ${links.map(link => `
2703
- <a href="${link.url}" class="lead-fast-nav-link" ${link.target ? `target="${link.target}"` : ''}>
2704
- ${link.text}
2705
- </a>
2706
- `).join('')}
2707
- </nav>
2708
- </div>
2709
-
2710
- <div class="lead-fast-user-section" id="lead-fast-user-section">
2711
- <!-- User section will be populated when logged in -->
2712
- </div>
2713
-
2714
- <!-- <a href="https://www.moneyfast.bar" target="_blank" class="lead-fast-branding" style="text-decoration: none; color: inherit;">moneyfast.bar</a>-->
2715
- </div>
2716
- `;
2717
- }
2718
- updateUserSection(status) {
2719
- //console.log('🎨 [THEME DEBUG] updateUserSection called');
2720
- //console.log('🎨 [THEME DEBUG] Current data-theme:', document.documentElement.getAttribute('data-theme'));
2721
- const userSection = document.getElementById('lead-fast-user-section');
2722
- if (!userSection) {
2723
- //console.log('🎨 [THEME DEBUG] User section not found!');
2724
- return;
2725
- }
2726
- // Show loading state if status is null
2727
- if (status === null || this.isLoadingStatus) {
2728
- userSection.innerHTML = `
2729
- <div class="lead-fast-loading-status">
2730
- <svg class="lead-fast-spinner" viewBox="0 0 24 24">
2731
- <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="3" fill="none" stroke-dasharray="31.4 31.4" stroke-linecap="round">
2732
- <animateTransform attributeName="transform" type="rotate" from="0 12 12" to="360 12 12" dur="1s" repeatCount="indefinite"/>
2733
- </circle>
2734
- </svg>
2735
- <span class="lead-fast-loading-text">Loading...</span>
2736
- </div>
2737
- `;
2738
- return;
2739
- }
2740
- if (this.currentUser) {
2741
- // User is signed in - show user info
2742
- const userInitial = this.currentUser.email.charAt(0).toUpperCase();
2743
- const userEmail = this.currentUser.email;
2744
- const badgeClass = status.isPremium ? 'premium' : 'free';
2745
- const badgeText = status.isPremium ? 'Premium' : 'Free';
2746
- const countText = status.isPremium ? 'Unlimited' : `${status.currentCount}/${status.limit}`;
2747
- //console.log('🎨 [THEME DEBUG] Populating user section');
2748
- userSection.innerHTML = `
2749
- <div class="lead-fast-avatar">${userInitial}</div>
2750
- <div class="lead-fast-user-info">
2751
- <div class="lead-fast-user-email">${userEmail}</div>
2752
- <div class="lead-fast-user-status">
2753
- <span class="lead-fast-badge ${badgeClass}">${badgeText}</span>
2754
- <span class="lead-fast-count">${countText}</span>
2755
- </div>
2756
- </div>
2757
- <button class="lead-fast-signout">signout</button>
2758
- `;
2759
- // Debug CSS variables after updating user section
2760
- const titleBar = document.querySelector('.lead-fast-title-bar');
2761
- if (titleBar) {
2762
- getComputedStyle(titleBar);
2763
- //console.log('🎨 [THEME DEBUG] Title bar background color:', computedStyle.backgroundColor);
2764
- //console.log('🎨 [THEME DEBUG] Title bar border color:', computedStyle.borderColor);
2765
- }
2766
- // Add sign out functionality
2767
- const signoutBtn = userSection.querySelector('.lead-fast-signout');
2768
- if (signoutBtn) {
2769
- signoutBtn.addEventListener('click', () => {
2770
- this.signOut();
2771
- });
2772
- }
2773
- }
2774
- else {
2775
- // Anonymous user - show usage count
2776
- //console.log('🎨 [THEME DEBUG] Showing anonymous user usage count');
2777
- const countText = `Attempts: ${status.currentCount}/${status.limit}`;
2778
- userSection.innerHTML = `
2779
- <div class="lead-fast-anonymous-status">
2780
- <span class="lead-fast-count">${countText}</span>
2781
- </div>
2782
- `;
2783
- }
2784
- }
2785
- setupUIUpdates() {
2786
- // Update UI on auth changes
2787
- this.on('authChanged', async () => {
2788
- // Invalidate cache when auth state changes
2789
- // console.log(`🕐 [CACHE] Invalidating cache due to auth change (was: ${this.cachedStatus ? 'cached' : 'null'})`);
2790
- this.cachedStatus = null;
2791
- this.updateStatusDisplays();
2792
- // Update paywall display if it's currently shown
2793
- const modal = document.getElementById('download-limiter-paywall');
2794
- if (modal && modal.classList.contains('show')) {
2795
- this.updatePaywallDisplay();
2796
- // Auto-redirect to payment after sign-in from paywall (if not already premium)
2797
- if (this.currentUser && this.config.payment) {
2798
- setTimeout(async () => {
2799
- const isPremium = await this.checkPremiumStatus(this.currentUser.email);
2800
- if (!isPremium) {
2801
- // User is not premium, redirect to payment
2802
- const payment = await this.createPayment();
2803
- if (payment?.checkout_url) {
2804
- window.location.href = payment.checkout_url;
2805
- }
2806
- }
2807
- else {
2808
- // User is already premium, just close paywall and stay on page
2809
- modal.classList.remove('show');
2810
- }
2811
- }, 1000); // Small delay to let UI update
2812
- }
2813
- }
2814
- });
2815
- // Update UI on count changes
2816
- this.on('countChanged', () => {
2817
- this.updateStatusDisplays();
2818
- });
2819
- // Initial update
2820
- this.updateStatusDisplays();
2821
- }
2822
- updatePaywallDisplay() {
2823
- const modal = document.getElementById('download-limiter-paywall');
2824
- if (!modal)
2825
- return;
2826
- const authSection = modal.querySelector('#download-limiter-auth-section');
2827
- const paymentSection = modal.querySelector('#download-limiter-payment-section');
2828
- if (!this.currentUser) {
2829
- // Not signed in - show auth section
2830
- authSection.style.display = 'block';
2831
- paymentSection.style.display = 'none';
2832
- }
2833
- else {
2834
- // Signed in - show payment section
2835
- authSection.style.display = 'none';
2836
- paymentSection.style.display = 'block';
2837
- }
2838
- }
2839
- /**
2840
- * Event listener management
2841
- */
2842
- on(event, listener) {
2843
- if (!this.eventListeners.has(event)) {
2844
- this.eventListeners.set(event, []);
2845
- }
2846
- this.eventListeners.get(event).push(listener);
2847
- }
2848
- off(event, listener) {
2849
- const listeners = this.eventListeners.get(event);
2850
- if (listeners) {
2851
- const index = listeners.indexOf(listener);
2852
- if (index > -1) {
2853
- listeners.splice(index, 1);
2854
- }
2855
- }
2856
- }
2857
- emit(event, data) {
2858
- const listeners = this.eventListeners.get(event);
2859
- if (listeners) {
2860
- listeners.forEach(listener => {
2861
- try {
2862
- listener(data);
2863
- }
2864
- catch (error) {
2865
- console.error(`Error in ${event} listener:`, error);
2866
- }
2867
- });
2868
- }
2869
- }
2870
- validateConfig() {
2871
- if (!this.config.appId)
2872
- throw new Error('appId is required');
2873
- if (!this.config.supabase?.url)
2874
- throw new Error('supabase.url is required');
2875
- if (!this.config.supabase?.anonKey)
2876
- throw new Error('supabase.anonKey is required');
2877
- if (typeof this.config.freeAttemptLimit !== 'number' || this.config.freeAttemptLimit < 0) {
2878
- throw new Error('freeAttemptLimit must be a non-negative number');
2879
- }
2880
- }
2881
- async initializeSupabase() {
2882
- try {
2883
- this.supabase = createClient(this.config.supabase.url, this.config.supabase.anonKey);
2884
- // Skip connection test - we'll detect connection issues during actual API calls
2885
- this.supabaseConnectionFailed = false;
2886
- }
2887
- catch (error) {
2888
- console.error('Failed to initialize Supabase:', error);
2889
- this.supabaseConnectionFailed = true;
2890
- }
2891
- }
2892
- async initializePayment() {
2893
- // Skip if no payment configuration
2894
- if (!this.config.payment) {
2895
- return;
2896
- }
2897
- // Validate product ID format
2898
- const payment = this.config.payment?.find(p => p.provider === 'dodo');
2899
- if (!payment) {
2900
- this.paymentConnectionFailed = true;
2901
- if (this.config.options?.debug) {
2902
- console.warn('No dodo payment provider configured');
2903
- }
2904
- return;
2905
- }
2906
- const productId = payment.productId;
2907
- if (!productId || !productId.startsWith('pdt_') || productId.length < 10) {
2908
- this.paymentConnectionFailed = true;
2909
- if (this.config.options?.debug) {
2910
- console.warn('Invalid payment product ID format:', productId);
2911
- }
2912
- return;
2913
- }
2914
- // For now, skip payment gateway connectivity test
2915
- // Only validate product ID format (which we already did above)
2916
- // In production, you can add actual DodoPayments API test here
2917
- this.paymentConnectionFailed = false;
2918
- }
2919
- async initializeFingerprint() {
2920
- try {
2921
- this.userFingerprint = await this.generateFingerprint();
2922
- }
2923
- catch (error) {
2924
- this.userFingerprint = crypto.randomUUID ? crypto.randomUUID() : String(Date.now());
2925
- if (this.config.options?.debug) {
2926
- console.warn('Fingerprint generation failed, using fallback:', error);
2927
- }
2928
- }
2929
- }
2930
- async generateFingerprint() {
2931
- const ua = navigator.userAgent || '';
2932
- const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || '';
2933
- const screenSize = `${screen.width}x${screen.height}`;
2934
- const lang = navigator.language || '';
2935
- const raw = `${ua}||${tz}||${screenSize}||${lang}`;
2936
- const buf = new TextEncoder().encode(raw);
2937
- const hashBuffer = await crypto.subtle.digest('SHA-256', buf);
2938
- const hashArray = Array.from(new Uint8Array(hashBuffer));
2939
- return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
2940
- }
2941
- async setupAuthListener() {
2942
- this.supabase.auth.onAuthStateChange(async (event, session) => {
2943
- const previousUser = this.currentUser;
2944
- this.currentUser = session?.user || null;
2945
- let isPremium = false;
2946
- if (this.currentUser) {
2947
- // Only check premium status if user changed or cache is expired
2948
- const userChanged = !previousUser || previousUser.email !== this.currentUser.email;
2949
- const cacheExpired = !this.cachedPremiumStatus || (Date.now() - this.premiumStatusCacheTime) > this.STATUS_CACHE_DURATION;
2950
- if (userChanged || cacheExpired) {
2951
- isPremium = await this.checkPremiumStatus(this.currentUser.email);
2952
- // Cache the result
2953
- this.cachedPremiumStatus = isPremium;
2954
- this.premiumStatusCacheTime = Date.now();
2955
- }
2956
- else {
2957
- // Use cached result
2958
- isPremium = this.cachedPremiumStatus; // We know it's not null because cacheExpired is false
2959
- console.log(`🔍 [CACHE] Using cached premium status from auth listener: ${isPremium}`);
2960
- }
2961
- }
2962
- else {
2963
- // Clear cache when user logs out
2964
- this.cachedPremiumStatus = null;
2965
- this.premiumStatusCacheTime = 0;
2966
- }
2967
- // Check if user just signed in for upgrade flow
2968
- const urlParams = new URLSearchParams(window.location.search);
2969
- const isUpgradeFlow = urlParams.get('upgrade') === 'true';
2970
- if (event === 'SIGNED_IN' && !previousUser && this.currentUser && this.config.payment) {
2971
- // Check if this is an upgrade flow (from anonymous trial)
2972
- if (isUpgradeFlow) {
2973
- if (!isPremium) {
2974
- // User signed in for upgrade - redirect to payment immediately
2975
- const payment = await this.createPayment();
2976
- if (payment?.checkout_url) {
2977
- // Clean URL before redirect
2978
- window.history.replaceState({}, document.title, window.location.pathname);
2979
- window.location.href = payment.checkout_url;
2980
- }
2981
- }
2982
- else {
2983
- // User is already premium, just clean URL and close modal
2984
- window.history.replaceState({}, document.title, window.location.pathname);
2985
- const modal = document.getElementById('download-limiter-paywall');
2986
- if (modal) {
2987
- modal.classList.remove('show');
2988
- }
2989
- }
2990
- }
2991
- }
2992
- this.emit('authChanged', { user: this.currentUser, isPremium });
2993
- });
2994
- // Get initial auth state
2995
- const { data: { user } } = await this.supabase.auth.getUser();
2996
- this.currentUser = user;
2997
- }
2998
- async getDownloadCount() {
2999
- if (!this.userFingerprint)
3000
- return 0;
3001
- try {
3002
- const response = await fetch(`${this.config.supabase.url}/functions/v1/check-download-limit`, {
3003
- method: 'POST',
3004
- headers: {
3005
- 'Content-Type': 'application/json',
3006
- 'Authorization': `Bearer ${this.config.supabase.anonKey}`
3007
- },
3008
- body: JSON.stringify({
3009
- fingerprint: this.userFingerprint,
3010
- security_key: this.config.security_key,
3011
- action: 'check'
3012
- })
3013
- });
3014
- if (response.ok) {
3015
- const data = await response.json();
3016
- this.supabaseConnectionFailed = false; // Connection successful
3017
- return data.current_count || 0;
3018
- }
3019
- else {
3020
- // Handle auth errors (401/403) as connection failures
3021
- if (response.status === 401 || response.status === 403) {
3022
- // Try to get the actual error message from response
3023
- try {
3024
- const errorData = await response.json();
3025
- const errorMsg = errorData.error || errorData.message || 'Authentication failed';
3026
- // Check if it's a security key validation error
3027
- if (errorMsg.toLowerCase().includes('security key')) {
3028
- console.error(`❌ Security Key Validation Failed [check-download-limit]: ${errorMsg}`);
3029
- console.error(`💡 Backend Function: check-download-limit`);
3030
- console.error(`💡 Please check your security_key in the MoneyBar configuration`);
3031
- this.securityKeyFailed = true; // Set security key error flag
3032
- this.supabaseConnectionFailed = true; // Also mark connection as failed to disable downloads
3033
- }
3034
- else {
3035
- console.warn(`Supabase authentication failed [check-download-limit]: ${response.status} - ${errorMsg}`);
3036
- this.supabaseConnectionFailed = true;
3037
- }
3038
- }
3039
- catch (e) {
3040
- console.warn(`Supabase authentication failed: ${response.status} - Unable to parse error`);
3041
- this.supabaseConnectionFailed = true;
3042
- }
3043
- }
3044
- }
3045
- }
3046
- catch (error) {
3047
- this.supabaseConnectionFailed = true; // Mark connection as failed
3048
- if (this.config.options?.debug) {
3049
- console.warn('Failed to get server usage count, connection failed:', error);
3050
- }
3051
- }
3052
- // Security: Do not fallback to localStorage when server connection fails
3053
- // This prevents users from bypassing limits by manipulating localStorage
3054
- return 0;
3055
- }
3056
- async incrementDownloadCount() {
3057
- if (!this.userFingerprint) {
3058
- // if (this.config.options?.debug) {
3059
- // console.warn('🔍 DEBUG: No userFingerprint available for incrementDownloadCount');
3060
- // }
3061
- return 0;
3062
- }
3063
- const requestBody = {
3064
- fingerprint: this.userFingerprint,
3065
- security_key: this.config.security_key,
3066
- action: 'increment'
3067
- };
3068
- try {
3069
- const response = await fetch(`${this.config.supabase.url}/functions/v1/check-download-limit`, {
3070
- method: 'POST',
3071
- headers: {
3072
- 'Content-Type': 'application/json',
3073
- 'Authorization': `Bearer ${this.config.supabase.anonKey}`
3074
- },
3075
- body: JSON.stringify(requestBody)
3076
- });
3077
- if (this.config.options?.debug) {
3078
- //console.log('🔍 DEBUG: Response status:', response.status);
3079
- if (!response.ok) {
3080
- const errorText = await response.text();
3081
- console.error('🔍 DEBUG: Error response:', errorText);
3082
- }
3083
- }
3084
- if (response.ok) {
3085
- const data = await response.json();
3086
- this.supabaseConnectionFailed = false; // Connection successful
3087
- return data.new_count || 0;
3088
- }
3089
- else {
3090
- // Handle auth errors (401/403) as connection failures
3091
- if (response.status === 401 || response.status === 403) {
3092
- // Try to get the actual error message from response
3093
- try {
3094
- const errorData = await response.json();
3095
- const errorMsg = errorData.error || errorData.message || 'Authentication failed';
3096
- // Check if it's a security key validation error
3097
- if (errorMsg.toLowerCase().includes('security key')) {
3098
- console.error(`❌ Security Key Validation Failed [check-download-limit]: ${errorMsg}`);
3099
- console.error(`💡 Backend Function: check-download-limit`);
3100
- console.error(`💡 Please check your security_key in the MoneyBar configuration`);
3101
- this.securityKeyFailed = true; // Set security key error flag
3102
- this.supabaseConnectionFailed = true; // Also mark connection as failed to disable downloads
3103
- }
3104
- else {
3105
- console.warn(`Supabase authentication failed [check-download-limit]: ${response.status} - ${errorMsg}`);
3106
- this.supabaseConnectionFailed = true;
3107
- }
3108
- }
3109
- catch (e) {
3110
- console.warn(`Supabase authentication failed: ${response.status} - Unable to parse error`);
3111
- this.supabaseConnectionFailed = true;
3112
- }
3113
- }
3114
- }
3115
- }
3116
- catch (error) {
3117
- this.supabaseConnectionFailed = true; // Mark connection as failed
3118
- if (this.config.options?.debug) {
3119
- console.warn('Failed to increment server count, connection failed:', error);
3120
- }
3121
- }
3122
- // Security: Do not fallback to localStorage when server connection fails
3123
- // This prevents users from bypassing limits by manipulating localStorage
3124
- return 0;
3125
- }
3126
- async checkPremiumStatus(email) {
3127
- try {
3128
- const response = await fetch(`${this.config.supabase.url}/functions/v1/check-payment-status`, {
3129
- method: 'POST',
3130
- headers: {
3131
- 'Content-Type': 'application/json',
3132
- 'Authorization': `Bearer ${this.config.supabase.anonKey}`
3133
- },
3134
- body: JSON.stringify({
3135
- email,
3136
- app_id: this.config.appId
3137
- })
3138
- });
3139
- if (response.ok) {
3140
- const data = await response.json();
3141
- return data.status === 'completed';
3142
- }
3143
- }
3144
- catch (error) {
3145
- if (this.config.options?.debug) {
3146
- console.warn('Failed to check premium status:', error);
3147
- }
3148
- }
3149
- return false;
3150
- }
3151
- getLocalDownloadCount() {
3152
- const key = `download_count_${this.config.appId}`;
3153
- const val = parseInt(localStorage.getItem(key) || '0', 10);
3154
- return isNaN(val) ? 0 : val;
3155
- }
3156
- incrementLocalDownloadCount() {
3157
- const key = `download_count_${this.config.appId}`;
3158
- const next = this.getLocalDownloadCount() + 1;
3159
- localStorage.setItem(key, String(next));
3160
- return next;
3161
- }
3162
- handleError(error) {
3163
- if (this.config.options?.debug) {
3164
- console.error('Lead Fast Error:', error);
3165
- }
3166
- if (this.config.callbacks?.onError) {
3167
- this.config.callbacks.onError(error);
3168
- }
3169
- else {
3170
- // Default error handling
3171
- console.error('Lead Fast:', error.message);
3172
- }
3173
- this.emit('error', error);
3174
- }
3175
- async checkPaymentStatus() {
3176
- // Check if user returned from payment
3177
- const urlParams = new URLSearchParams(window.location.search);
3178
- if (urlParams.get('payment') === 'success') {
3179
- // Wait for auth to be ready
3180
- setTimeout(async () => {
3181
- if (this.currentUser) {
3182
- const isPremium = await this.checkPremiumStatus(this.currentUser.email);
3183
- if (isPremium) {
3184
- this.showSuccess('Payment Successful!', 'Welcome to premium! You now have unlimited usage.');
3185
- }
3186
- else {
3187
- this.showSuccess('Processing Payment', 'Payment is being processed. Please refresh in a few moments.');
3188
- }
3189
- }
3190
- else {
3191
- this.showSuccess('Processing Payment', 'Please wait while we verify your payment...');
3192
- }
3193
- // Clean up URL
3194
- const cleanUrl = window.location.href.split('?')[0];
3195
- window.history.replaceState({}, document.title, cleanUrl);
3196
- }, 2000);
3197
- }
3198
- }
3199
- }
3200
-
3201
- export { MoneyBar };
1
+ import{createClient as n}from"@supabase/supabase-js";class t{mergeConfigs(n){const t="undefined"!=typeof window?window.APP_CONFIG:null;if(!n&&!t)throw new Error("MoneyBar: No configuration provided. Either pass config to constructor or set window.APP_CONFIG");return n?t?{...t,...n}:n:t}constructor(n){this.currentUser=null,this.userFingerprint=null,this.eventListeners=new Map,this.supabaseConnectionFailed=!1,this.paymentConnectionFailed=!1,this.securityKeyFailed=!1,this.isLoadingStatus=!1,this.cachedStatus=null,this.statusCacheTime=0,this.STATUS_CACHE_DURATION=5e3,this.initializationPromise=null,this.cachedPremiumStatus=null,this.premiumStatusCacheTime=0,this.config=this.mergeConfigs(n),this.config.options,this.validateConfig(),this.initializeSupabase(),this.initializePayment(),this.initializeFingerprint(),this.setupAuthListener(),this.checkPaymentStatus()}async handleDownload(){try{if(this.securityKeyFailed)return void this.showError("Invalid Security Key","Your security key is invalid, expired, or not found. Please check your MoneyBar configuration and ensure you have a valid security_key.");if(this.supabaseConnectionFailed)return void this.config.callbacks?.onError?.(new Error("Server connection required for download verification. Please check your configuration."));if(this.config.payment&&this.paymentConnectionFailed)return void this.config.callbacks?.onError?.(new Error("Payment configuration error. Please contact support."));if(this.currentUser){if(await this.checkPremiumStatus(this.currentUser.email))return void this.config.callbacks?.onPremiumDownload()}const n=await this.getDownloadStatus();if(n.currentCount>=n.limit)return void this.config.callbacks?.onLimitReached(n.currentCount,n.limit);await this.incrementDownloadCount(),this.config.callbacks?.onDownloadAllowed(),this.cachedStatus=null;const t=await this.getDownloadStatus();this.emit("countChanged",{count:t.currentCount,limit:t.limit}),t.currentCount>=t.limit&&setTimeout(()=>{this.config.callbacks?.onLimitReached(t.currentCount,t.limit)},100)}catch(n){this.handleError(n)}}async getDownloadStatus(n=!1){const t=this.cachedStatus?Date.now()-this.statusCacheTime:-1;if(!n&&this.cachedStatus&&t<this.STATUS_CACHE_DURATION)return this.cachedStatus;if(!n&&this.initializationPromise)return await this.initializationPromise;this.initializationPromise=this.fetchFreshStatus(n);try{return await this.initializationPromise}finally{this.initializationPromise=null}}async fetchFreshStatus(n){try{let t=0,e=!1;if(n||!this.cachedStatus){if(t=await this.getDownloadCount(),this.securityKeyFailed)return{currentCount:0,limit:this.config.freeAttemptLimit,isPremium:!1,isAuthenticated:!1,remaining:0}}else t=this.cachedStatus.currentCount;if(this.currentUser){const t=null!==this.cachedPremiumStatus&&Date.now()-this.premiumStatusCacheTime<this.STATUS_CACHE_DURATION;n||!t?(e=await this.checkPremiumStatus(this.currentUser.email),this.cachedPremiumStatus=e,this.premiumStatusCacheTime=Date.now()):(e=this.cachedPremiumStatus,console.log(`🔍 [CACHE] Using cached premium status from getDownloadStatus: ${e}`))}else e=!1;const a={currentCount:t,limit:this.config.freeAttemptLimit,isPremium:e,isAuthenticated:!!this.currentUser,remaining:Math.max(0,this.config.freeAttemptLimit-t)};return this.cachedStatus=a,this.statusCacheTime=Date.now(),a}catch(n){this.handleError(n);const t={currentCount:0,limit:this.config.freeAttemptLimit,isPremium:!1,isAuthenticated:!1,remaining:this.config.freeAttemptLimit};return this.cachedStatus=t,this.statusCacheTime=Date.now(),t}}async getUserContext(){const n=await this.getDownloadStatus();return{isPremium:n.isPremium,isAuthenticated:n.isAuthenticated,email:this.currentUser?.email,name:this.currentUser?.user_metadata?.full_name||this.currentUser?.user_metadata?.name,currentCount:n.currentCount,remaining:n.remaining,limit:n.limit,user:this.currentUser}}async signIn(){try{const{error:n}=await this.supabase.auth.signInWithOAuth({provider:"google",options:{redirectTo:`${window.location.origin}${window.location.pathname}`}});if(n)throw n}catch(n){this.handleError(n)}}async signOut(){try{await this.supabase.auth.signOut(),this.currentUser=null,this.emit("authChanged",{user:null,isPremium:!1})}catch(n){this.handleError(n)}}async createPayment(){if(!this.currentUser)throw new Error("User must be signed in to create payment");if(!this.config.payment)throw new Error("Payment configuration not provided");const n=this.config.payment?.find(n=>"dodo"===n.provider);if(!n)throw new Error("No dodo payment provider configured");const t={email:this.currentUser.email,product_id:n.productId,mode:n.mode||"test",app_id:this.config.appId,return_url:`${window.location.origin}${window.location.pathname}?payment=success`};console.log(`🔥 [PAYMENT API] createPayment called for provider: ${n.provider}, email: ${this.currentUser.email} | Time: ${(new Date).toISOString()}`);try{let e;if("dodo"!==n.provider)throw new Error(`Payment provider '${n.provider}' is not yet supported`);if(e=await fetch(`${this.config.supabase.url}/functions/v1/create-payment`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.supabase.anonKey}`},body:JSON.stringify(t)}),console.log(`🔥 [PAYMENT API] createPayment response for ${n.provider}: ${e.status}`),this.config.options,!e.ok){const n=await e.text();let t;this.config.options?.debug&&console.error("🔍 DEBUG: createPayment error response:",n);try{t=JSON.parse(n)}catch{t={error:n}}throw(n.includes("404")||n.includes("could not be found"))&&(this.paymentConnectionFailed=!0,this.config.options?.debug&&console.warn("Invalid payment product ID detected, disabling downloads"),this.updateStatusDisplays()),new Error(t.error||"Payment creation failed")}const a=await e.json();return this.config.options,a}catch(n){return this.handleError(n),null}}attachToButton(n,t){const e=document.querySelector(n);if(!e)throw new Error(`Button not found: ${n}`);this.injectBaseStyles(),this.createTitleBar(),this.createPaywallModal(),this.createSuccessModal(),this.createAuthUI(),this.createStatusDisplay(),e.setAttribute("data-leadfast-attached","true"),e.onclick=async n=>{n.preventDefault(),await this.handleButtonClick(t)},this.setupUIUpdates()}attachToButtons(n){this.injectBaseStyles(),this.createTitleBar(),this.createPaywallModal(),this.createSuccessModal(),this.createAuthUI(),n.buttons.forEach(n=>{const t=document.querySelector(n.selector);t?(t.setAttribute("data-leadfast-attached","true"),t.onclick=async t=>{t.preventDefault(),await this.handleButtonClick(n.downloadCallback)},this.setupUIUpdates()):console.warn(`Button not found: ${n.selector}`)}),this.createGlobalStatusDisplay()}async handleButtonClick(n){const t=document.querySelector('[data-leadfast-attached="true"]');if(t&&t.disabled)console.log("⚠️ Button click ignored - operation already in progress");else{t&&(t.disabled=!0,t.style.opacity="0.6");try{await this.handleButtonClickInternal(n)}finally{t&&(t.disabled=!1,t.style.opacity="1")}}}async handleButtonClickInternal(n){if(this.supabaseConnectionFailed)return void this.showConnectionError();if(this.config.payment&&this.paymentConnectionFailed)return void this.showPaymentConfigError();const t=this.cachedStatus&&Date.now()-this.statusCacheTime<this.STATUS_CACHE_DURATION?this.cachedStatus:await this.getDownloadStatus();if(t.isPremium){const t=await this.getUserContext();return void(n.length>0?n(t):n())}if(t.currentCount>=t.limit)this.showPaywallInstant(t);else{try{if(n.length>0){const t=await this.getUserContext();t.isPremium||(t.currentCount+=1,t.remaining=Math.max(0,t.limit-t.currentCount)),n(t)}else n();const t=await this.getDownloadStatus(!0);if(t.currentCount>=t.limit)return console.warn(`⚠️ Limit reached during execution (${t.currentCount}/${t.limit}) - canceling increment`),void alert("⚠️ You reached the limit while this action was processing. No attempt was counted.");const e=await this.incrementDownloadCount();if(e>this.config.freeAttemptLimit)return void console.error(`⚠️ Server returned count (${e}) exceeding limit (${this.config.freeAttemptLimit})`);if(!0===this.config.successMessage?.enabled){const n=this.config.successMessage?.title||"Action Completed!",t=this.config.successMessage?.message||"Your action completed successfully!";this.showSuccess(n,t)}}catch(n){return console.error("User function failed:",n),void alert("Action failed. Please check the console for details. No attempt was counted.")}this.cachedStatus=null,this.updateStatusDisplays()}}injectBaseStyles(){if(document.getElementById("lead-fast-styles"))return;this.config.theme?.name&&this.injectDaisyUI();const n=document.createElement("style");n.id="lead-fast-styles";const t=this.config.theme?.primaryColor||"#3182ce";n.textContent=`\n /* User Profile Card - Top Right */\n .lead-fast-profile {\n position: fixed;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n z-index: 1000;\n font-family: system-ui, -apple-system, sans-serif;\n width: 90%;\n max-width: 1200px;\n }\n\n .lead-fast-title-bar {\n background: rgba(250, 247, 245, 0.9) !important;\n border: 1px solid rgba(231, 226, 223, 0.6) !important;\n color: #291334 !important;\n border-radius: 16px;\n padding: 12px 24px;\n box-shadow: 0 8px 32px rgb(0 0 0 / 0.1), 0 2px 8px rgb(0 0 0 / 0.05);\n backdrop-filter: blur(20px);\n display: flex;\n align-items: center;\n justify-content: space-between;\n min-height: 60px;\n font-family: system-ui, -apple-system, sans-serif;\n }\n\n /* Theme variations for floating title bar */\n [data-theme="bumblebee"] .lead-fast-title-bar {\n background: rgba(255, 248, 220, 0.9) !important;\n border-color: rgba(254, 215, 170, 0.6) !important;\n color: #1c1917 !important;\n }\n\n [data-theme="garden"] .lead-fast-title-bar {\n background: rgba(240, 253, 244, 0.9) !important;\n border-color: rgba(134, 239, 172, 0.6) !important;\n color: #14532d !important;\n }\n\n [data-theme="emerald"] .lead-fast-title-bar {\n background: rgba(236, 253, 245, 0.9) !important;\n border-color: rgba(167, 243, 208, 0.6) !important;\n color: #065f46 !important;\n }\n\n [data-theme="corporate"] .lead-fast-title-bar {\n background: rgba(248, 250, 252, 0.9) !important;\n border-color: rgba(226, 232, 240, 0.6) !important;\n color: #1e293b !important;\n }\n\n [data-theme="dark"] .lead-fast-title-bar {\n background: rgba(31, 41, 55, 0.9) !important;\n border-color: rgba(55, 65, 81, 0.6) !important;\n color: #f9fafb !important;\n }\n\n [data-theme="cyberpunk"] .lead-fast-title-bar {\n background: rgba(0, 20, 36, 0.9) !important;\n border-color: rgba(7, 89, 133, 0.6) !important;\n color: #0ea5e9 !important;\n box-shadow: 0 8px 32px rgba(14, 165, 233, 0.2), 0 2px 8px rgba(14, 165, 233, 0.1);\n }\n\n [data-theme="valentine"] .lead-fast-title-bar {\n background: rgba(233, 30, 122, 0.15) !important;\n border-color: rgba(233, 30, 122, 0.6) !important;\n color: #831843 !important;\n }\n\n [data-theme="synthwave"] .lead-fast-title-bar {\n background: rgba(32, 20, 64, 0.9) !important;\n border-color: rgba(186, 85, 211, 0.6) !important;\n color: #ff00ff !important;\n box-shadow: 0 8px 32px rgba(255, 0, 255, 0.2), 0 2px 8px rgba(255, 0, 255, 0.1);\n }\n\n [data-theme="dracula"] .lead-fast-title-bar {\n background: rgba(40, 42, 54, 0.9) !important;\n border-color: rgba(98, 114, 164, 0.6) !important;\n color: #f8f8f2 !important;\n }\n\n [data-theme="halloween"] .lead-fast-title-bar {\n background: rgba(26, 26, 26, 0.9) !important;\n border-color: rgba(255, 165, 0, 0.6) !important;\n color: #ff6600 !important;\n }\n\n [data-theme="forest"] .lead-fast-title-bar {\n background: rgba(23, 46, 23, 0.9) !important;\n border-color: rgba(34, 197, 94, 0.6) !important;\n color: #22c55e !important;\n }\n\n [data-theme="luxury"] .lead-fast-title-bar {\n background: rgba(9, 9, 11, 0.9) !important;\n border-color: rgba(212, 175, 55, 0.6) !important;\n color: #d4af37 !important;\n }\n\n [data-theme="night"] .lead-fast-title-bar {\n background: rgba(15, 23, 42, 0.9) !important;\n border-color: rgba(30, 58, 138, 0.6) !important;\n color: #60a5fa !important;\n }\n\n [data-theme="light"] .lead-fast-title-bar {\n background: rgba(255, 255, 255, 0.9) !important;\n border-color: rgba(229, 231, 235, 0.6) !important;\n color: #1f2937 !important;\n }\n\n [data-theme="cupcake"] .lead-fast-title-bar {\n background: rgba(250, 235, 215, 0.9) !important;\n border-color: rgba(219, 185, 156, 0.6) !important;\n color: #8b4513 !important;\n }\n\n [data-theme="retro"] .lead-fast-title-bar {\n background: rgba(212, 165, 116, 0.9) !important;\n border-color: rgba(185, 144, 102, 0.6) !important;\n color: #5d4037 !important;\n }\n\n [data-theme="aqua"] .lead-fast-title-bar {\n background: rgba(240, 253, 250, 0.9) !important;\n border-color: rgba(125, 211, 252, 0.6) !important;\n color: #155e75 !important;\n }\n\n [data-theme="lofi"] .lead-fast-title-bar {\n background: rgba(248, 248, 248, 0.9) !important;\n border-color: rgba(68, 68, 68, 0.6) !important;\n color: #1a1a1a !important;\n }\n\n [data-theme="pastel"] .lead-fast-title-bar {\n background: rgba(254, 251, 255, 0.9) !important;\n border-color: rgba(209, 196, 233, 0.6) !important;\n color: #7c3aed !important;\n }\n\n [data-theme="fantasy"] .lead-fast-title-bar {\n background: rgba(255, 247, 237, 0.9) !important;\n border-color: rgba(249, 168, 212, 0.6) !important;\n color: #be185d !important;\n }\n\n [data-theme="wireframe"] .lead-fast-title-bar {\n background: rgba(223, 223, 223, 0.9) !important;\n border-color: rgba(0, 0, 0, 0.3) !important;\n color: #000000 !important;\n }\n\n [data-theme="black"] .lead-fast-title-bar {\n background: rgba(0, 0, 0, 0.9) !important;\n border-color: rgba(55, 55, 55, 0.6) !important;\n color: #ffffff !important;\n }\n\n [data-theme="cmyk"] .lead-fast-title-bar {\n background: rgba(0, 255, 255, 0.9) !important;\n border-color: rgba(255, 0, 255, 0.6) !important;\n color: #000000 !important;\n }\n\n [data-theme="autumn"] .lead-fast-title-bar {\n background: rgba(139, 69, 19, 0.9) !important;\n border-color: rgba(255, 140, 0, 0.6) !important;\n color: #ff8c00 !important;\n }\n\n [data-theme="business"] .lead-fast-title-bar {\n background: rgba(29, 78, 216, 0.9) !important;\n border-color: rgba(59, 130, 246, 0.6) !important;\n color: #3b82f6 !important;\n }\n\n [data-theme="acid"] .lead-fast-title-bar {\n background: rgba(255, 255, 0, 0.9) !important;\n border-color: rgba(255, 0, 255, 0.6) !important;\n color: #000000 !important;\n }\n\n [data-theme="lemonade"] .lead-fast-title-bar {\n background: rgba(255, 255, 224, 0.9) !important;\n border-color: rgba(34, 197, 94, 0.6) !important;\n color: #15803d !important;\n }\n\n [data-theme="coffee"] .lead-fast-title-bar {\n background: rgba(101, 67, 33, 0.9) !important;\n border-color: rgba(160, 82, 45, 0.6) !important;\n color: #d2b48c !important;\n }\n\n [data-theme="winter"] .lead-fast-title-bar {\n background: rgba(248, 250, 252, 0.9) !important;\n border-color: rgba(59, 130, 246, 0.6) !important;\n color: #1e40af !important;\n }\n\n .lead-fast-title-section {\n display: flex;\n align-items: center;\n gap: 16px;\n }\n\n .lead-fast-logo {\n font-size: 20px;\n font-weight: 700;\n display: flex;\n align-items: center;\n gap: 8px;\n color: inherit;\n text-decoration: none;\n }\n\n .lead-fast-logo img {\n width: 32px;\n height: 32px;\n border-radius: 6px;\n }\n\n .lead-fast-nav {\n display: flex;\n align-items: center;\n gap: 32px;\n margin-left: 24px;\n }\n\n .lead-fast-nav-link {\n color: inherit;\n text-decoration: none;\n font-weight: 500;\n font-size: 14px;\n opacity: 0.8;\n transition: all 0.2s;\n }\n\n .lead-fast-nav-link:hover {\n opacity: 1;\n text-decoration: none;\n }\n\n .lead-fast-user-section {\n display: flex;\n align-items: center;\n gap: 12px;\n }\n\n .lead-fast-avatar {\n width: 36px;\n height: 36px;\n border-radius: 50%;\n background: linear-gradient(135deg, ${t}, #4f46e5);\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n font-weight: 600;\n font-size: 14px;\n }\n\n .lead-fast-user-info {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 2px;\n }\n\n .lead-fast-user-email {\n color: inherit !important;\n font-size: 13px;\n font-weight: 500;\n line-height: 1;\n }\n\n .lead-fast-user-status {\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n .lead-fast-badge {\n padding: 2px 6px;\n border-radius: 12px;\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.025em;\n line-height: 1;\n }\n\n .lead-fast-badge.premium {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n .lead-fast-badge.free {\n background: #65c3c8 !important;\n color: #291334 !important;\n }\n\n [data-theme="dark"] .lead-fast-badge.premium {\n background: #059669 !important;\n color: #ffffff !important;\n }\n\n [data-theme="dark"] .lead-fast-badge.free {\n background: #374151 !important;\n color: #f9fafb !important;\n }\n\n .lead-fast-count {\n font-size: 10px;\n color: inherit !important;\n opacity: 0.7;\n line-height: 1;\n }\n\n .lead-fast-signout {\n background: rgba(0, 0, 0, 0.1) !important;\n border: none;\n color: inherit !important;\n cursor: pointer;\n padding: 6px 12px;\n border-radius: 8px;\n transition: all 0.2s;\n font-size: 11px;\n font-weight: 500;\n margin-left: 8px;\n }\n\n [data-theme="dark"] .lead-fast-signout {\n background: rgba(255, 255, 255, 0.1) !important;\n }\n\n [data-theme="cyberpunk"] .lead-fast-signout {\n background: rgba(14, 165, 233, 0.2) !important;\n }\n\n .lead-fast-signout:hover {\n background: rgba(0, 0, 0, 0.2) !important;\n transform: translateY(-1px);\n }\n\n [data-theme="dark"] .lead-fast-signout:hover {\n background: rgba(255, 255, 255, 0.2) !important;\n }\n\n [data-theme="cyberpunk"] .lead-fast-signout:hover {\n background: rgba(14, 165, 233, 0.3) !important;\n }\n\n .lead-fast-branding {\n position: absolute;\n bottom: -20px;\n left: 24px;\n font-size: 9px;\n color: inherit !important;\n opacity: 0.4;\n font-weight: 500;\n letter-spacing: 0.05em;\n text-transform: lowercase;\n background: rgba(255, 255, 255, 0.8);\n padding: 2px 6px;\n border-radius: 4px;\n backdrop-filter: blur(8px);\n }\n\n [data-theme="dark"] .lead-fast-branding {\n background: rgba(0, 0, 0, 0.6);\n }\n\n [data-theme="cyberpunk"] .lead-fast-branding {\n background: rgba(0, 20, 36, 0.8);\n }\n\n /* Modal Theming */\n .download-limiter-modal {\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0,0,0,0.5);\n z-index: 9999;\n align-items: center;\n justify-content: center;\n }\n .download-limiter-modal.show { display: flex; }\n\n .download-limiter-content {\n background: #faf7f5 !important;\n color: #291334 !important;\n padding: 2rem;\n border-radius: 12px;\n max-width: 400px;\n text-align: center;\n box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n border: 1px solid #e7e2df !important;\n font-family: system-ui, -apple-system, sans-serif;\n }\n\n [data-theme="dark"] .download-limiter-content {\n background: #1f2937 !important;\n color: #f9fafb !important;\n border-color: #374151 !important;\n }\n\n [data-theme="cyberpunk"] .download-limiter-content {\n background: #001424 !important;\n color: #0ea5e9 !important;\n border-color: #075985 !important;\n }\n\n [data-theme="valentine"] .download-limiter-content {\n background: rgba(233, 30, 122, 0.05) !important;\n color: #831843 !important;\n border-color: #e91e7a !important;\n }\n\n [data-theme="bumblebee"] .download-limiter-content {\n background: rgba(255, 248, 220, 0.95) !important;\n color: #1c1917 !important;\n border-color: rgba(254, 215, 170, 0.8) !important;\n }\n\n [data-theme="garden"] .download-limiter-content {\n background: rgba(240, 253, 244, 0.95) !important;\n color: #14532d !important;\n border-color: rgba(134, 239, 172, 0.8) !important;\n }\n\n [data-theme="emerald"] .download-limiter-content {\n background: rgba(236, 253, 245, 0.95) !important;\n color: #065f46 !important;\n border-color: rgba(167, 243, 208, 0.8) !important;\n }\n\n [data-theme="corporate"] .download-limiter-content {\n background: rgba(248, 250, 252, 0.95) !important;\n color: #1e293b !important;\n border-color: rgba(226, 232, 240, 0.8) !important;\n }\n\n [data-theme="forest"] .download-limiter-content {\n background: rgba(23, 46, 23, 0.95) !important;\n color: #22c55e !important;\n border-color: rgba(34, 197, 94, 0.8) !important;\n }\n\n [data-theme="halloween"] .download-limiter-content {\n background: rgba(26, 26, 26, 0.95) !important;\n color: #ff6500 !important;\n border-color: rgba(255, 165, 0, 0.3) !important;\n }\n\n [data-theme="synthwave"] .download-limiter-content {\n background: rgba(32, 20, 64, 0.95) !important;\n color: #ba55d3 !important;\n border-color: rgba(186, 85, 211, 0.3) !important;\n }\n\n [data-theme="dracula"] .download-limiter-content {\n background: rgba(40, 42, 54, 0.95) !important;\n color: #f8f8f2 !important;\n border-color: rgba(98, 114, 164, 0.3) !important;\n }\n\n [data-theme="luxury"] .download-limiter-content {\n background: rgba(9, 9, 11, 0.95) !important;\n color: #d4af37 !important;\n border-color: rgba(212, 175, 55, 0.3) !important;\n }\n\n [data-theme="night"] .download-limiter-content {\n background: rgba(15, 23, 42, 0.95) !important;\n color: #1e40af !important;\n border-color: rgba(30, 58, 138, 0.3) !important;\n }\n\n [data-theme="light"] .download-limiter-content {\n background: rgba(255, 255, 255, 0.95) !important;\n color: #1f2937 !important;\n border-color: rgba(229, 231, 235, 0.8) !important;\n }\n\n [data-theme="cupcake"] .download-limiter-content {\n background: rgba(250, 235, 215, 0.95) !important;\n color: #8b4513 !important;\n border-color: rgba(219, 185, 156, 0.8) !important;\n }\n\n [data-theme="retro"] .download-limiter-content {\n background: rgba(212, 165, 116, 0.95) !important;\n color: #5d4037 !important;\n border-color: rgba(185, 144, 102, 0.8) !important;\n }\n\n [data-theme="aqua"] .download-limiter-content {\n background: rgba(240, 253, 250, 0.95) !important;\n color: #155e75 !important;\n border-color: rgba(125, 211, 252, 0.8) !important;\n }\n\n [data-theme="lofi"] .download-limiter-content {\n background: rgba(248, 248, 248, 0.95) !important;\n color: #1a1a1a !important;\n border-color: rgba(68, 68, 68, 0.8) !important;\n }\n\n [data-theme="pastel"] .download-limiter-content {\n background: rgba(254, 251, 255, 0.95) !important;\n color: #7c3aed !important;\n border-color: rgba(209, 196, 233, 0.8) !important;\n }\n\n [data-theme="fantasy"] .download-limiter-content {\n background: rgba(255, 247, 237, 0.95) !important;\n color: #be185d !important;\n border-color: rgba(249, 168, 212, 0.8) !important;\n }\n\n [data-theme="wireframe"] .download-limiter-content {\n background: rgba(255, 255, 255, 0.95) !important;\n color: #000000 !important;\n border-color: rgba(0, 0, 0, 0.3) !important;\n }\n\n [data-theme="black"] .download-limiter-content {\n background: rgba(0, 0, 0, 0.95) !important;\n color: #ffffff !important;\n border-color: rgba(55, 55, 55, 0.8) !important;\n }\n\n [data-theme="cmyk"] .download-limiter-content {\n background: rgba(0, 255, 255, 0.95) !important;\n color: #000000 !important;\n border-color: rgba(255, 0, 255, 0.8) !important;\n }\n\n [data-theme="autumn"] .download-limiter-content {\n background: rgba(139, 69, 19, 0.95) !important;\n color: #ff8c00 !important;\n border-color: rgba(255, 140, 0, 0.8) !important;\n }\n\n [data-theme="business"] .download-limiter-content {\n background: rgba(29, 78, 216, 0.95) !important;\n color: #3b82f6 !important;\n border-color: rgba(59, 130, 246, 0.8) !important;\n }\n\n [data-theme="acid"] .download-limiter-content {\n background: rgba(255, 255, 0, 0.95) !important;\n color: #000000 !important;\n border-color: rgba(255, 0, 255, 0.8) !important;\n }\n\n [data-theme="lemonade"] .download-limiter-content {\n background: rgba(255, 255, 224, 0.95) !important;\n color: #15803d !important;\n border-color: rgba(34, 197, 94, 0.8) !important;\n }\n\n [data-theme="coffee"] .download-limiter-content {\n background: rgba(101, 67, 33, 0.95) !important;\n color: #d2b48c !important;\n border-color: rgba(160, 82, 45, 0.8) !important;\n }\n\n [data-theme="winter"] .download-limiter-content {\n background: rgba(248, 250, 252, 0.95) !important;\n color: #1e40af !important;\n border-color: rgba(59, 130, 246, 0.8) !important;\n }\n\n .download-limiter-content h2 {\n color: inherit !important;\n margin: 0 0 1rem 0;\n font-size: 1.5rem;\n font-weight: 600;\n }\n .download-limiter-content p {\n color: inherit !important;\n margin: 0 0 1.5rem 0;\n line-height: 1.6;\n }\n .download-limiter-signin-btn {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n background: #65c3c8 !important;\n color: #291334 !important;\n border: none;\n padding: 12px 20px;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n text-decoration: none;\n transition: all 0.2s;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n }\n\n [data-theme="dark"] .download-limiter-signin-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cyberpunk"] .download-limiter-signin-btn {\n background: #f59e0b !important;\n color: #000000 !important;\n }\n\n [data-theme="valentine"] .download-limiter-signin-btn {\n background: #e91e7a !important;\n color: #ffffff !important;\n }\n\n [data-theme="bumblebee"] .download-limiter-signin-btn {\n background: #fbbf24 !important;\n color: #1c1917 !important;\n }\n\n [data-theme="garden"] .download-limiter-signin-btn {\n background: #22c55e !important;\n color: #ffffff !important;\n }\n\n [data-theme="emerald"] .download-limiter-signin-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="corporate"] .download-limiter-signin-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="forest"] .download-limiter-signin-btn {\n background: #22c55e !important;\n color: #1a1a1a !important;\n }\n\n [data-theme="halloween"] .download-limiter-signin-btn {\n background: #ff6500 !important;\n color: #1a1a1a !important;\n }\n\n [data-theme="synthwave"] .download-limiter-signin-btn {\n background: #ba55d3 !important;\n color: #201040 !important;\n }\n\n [data-theme="dracula"] .download-limiter-signin-btn {\n background: #8be9fd !important;\n color: #282a36 !important;\n }\n\n [data-theme="luxury"] .download-limiter-signin-btn {\n background: #d4af37 !important;\n color: #09090b !important;\n }\n\n [data-theme="night"] .download-limiter-signin-btn {\n background: #1e40af !important;\n color: #ffffff !important;\n }\n\n [data-theme="light"] .download-limiter-signin-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cupcake"] .download-limiter-signin-btn {\n background: #8b4513 !important;\n color: #ffffff !important;\n }\n\n [data-theme="retro"] .download-limiter-signin-btn {\n background: #d4a574 !important;\n color: #ffffff !important;\n }\n\n [data-theme="aqua"] .download-limiter-signin-btn {\n background: #0891b2 !important;\n color: #ffffff !important;\n }\n\n [data-theme="lofi"] .download-limiter-signin-btn {\n background: #1a1a1a !important;\n color: #ffffff !important;\n }\n\n [data-theme="pastel"] .download-limiter-signin-btn {\n background: #7c3aed !important;\n color: #ffffff !important;\n }\n\n [data-theme="fantasy"] .download-limiter-signin-btn {\n background: #be185d !important;\n color: #ffffff !important;\n }\n\n [data-theme="wireframe"] .download-limiter-signin-btn {\n background: #dfdfdf !important;\n color: #000000 !important;\n border: 1px solid #000000 !important;\n }\n\n [data-theme="black"] .download-limiter-signin-btn {\n background: #ffffff !important;\n color: #000000 !important;\n }\n\n [data-theme="cmyk"] .download-limiter-signin-btn {\n background: #ff00ff !important;\n color: #000000 !important;\n }\n\n [data-theme="autumn"] .download-limiter-signin-btn {\n background: #ff8c00 !important;\n color: #ffffff !important;\n }\n\n [data-theme="business"] .download-limiter-signin-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="acid"] .download-limiter-signin-btn {\n background: #ff00ff !important;\n color: #000000 !important;\n }\n\n [data-theme="lemonade"] .download-limiter-signin-btn {\n background: #22c55e !important;\n color: #ffffff !important;\n }\n\n [data-theme="coffee"] .download-limiter-signin-btn {\n background: #a0522d !important;\n color: #ffffff !important;\n }\n\n [data-theme="winter"] .download-limiter-signin-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n .download-limiter-signin-btn:hover {\n opacity: 0.9;\n transform: translateY(-1px);\n box-shadow: 0 4px 8px rgba(0,0,0,0.15);\n }\n\n /* Upgrade Button Styles for All Themes */\n [data-theme="dark"] .upgrade-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cyberpunk"] .upgrade-btn {\n background: #ff073a !important;\n color: #ffffff !important;\n }\n\n [data-theme="valentine"] .upgrade-btn {\n background: #e91e7a !important;\n color: #ffffff !important;\n }\n\n [data-theme="bumblebee"] .upgrade-btn {\n background: #f59e0b !important;\n color: #ffffff !important;\n }\n\n [data-theme="garden"] .upgrade-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="emerald"] .upgrade-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="corporate"] .upgrade-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="forest"] .upgrade-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="halloween"] .upgrade-btn {\n background: #ff7b00 !important;\n color: #000000 !important;\n }\n\n [data-theme="synthwave"] .upgrade-btn {\n background: #e879f9 !important;\n color: #ffffff !important;\n }\n\n [data-theme="dracula"] .upgrade-btn {\n background: #bd93f9 !important;\n color: #ffffff !important;\n }\n\n [data-theme="luxury"] .upgrade-btn {\n background: #d4af37 !important;\n color: #000000 !important;\n }\n\n [data-theme="night"] .upgrade-btn {\n background: #38bdf8 !important;\n color: #ffffff !important;\n }\n\n [data-theme="light"] .upgrade-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cupcake"] .upgrade-btn {\n background: #f472b6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="retro"] .upgrade-btn {\n background: #d4a574 !important;\n color: #ffffff !important;\n }\n\n [data-theme="aqua"] .upgrade-btn {\n background: #06b6d4 !important;\n color: #ffffff !important;\n }\n\n [data-theme="lofi"] .upgrade-btn {\n background: #a3a3a3 !important;\n color: #000000 !important;\n }\n\n [data-theme="pastel"] .upgrade-btn {\n background: #a78bfa !important;\n color: #ffffff !important;\n }\n\n [data-theme="fantasy"] .upgrade-btn {\n background: #f472b6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="wireframe"] .upgrade-btn {\n background: #dfdfdf !important;\n color: #000000 !important;\n border: 1px solid #000000 !important;\n }\n\n [data-theme="black"] .upgrade-btn {\n background: #ffffff !important;\n color: #000000 !important;\n }\n\n [data-theme="cmyk"] .upgrade-btn {\n background: #0891b2 !important;\n color: #ffffff !important;\n }\n\n [data-theme="autumn"] .upgrade-btn {\n background: #d97706 !important;\n color: #ffffff !important;\n }\n\n [data-theme="business"] .upgrade-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="acid"] .upgrade-btn {\n background: #84cc16 !important;\n color: #000000 !important;\n }\n\n [data-theme="lemonade"] .upgrade-btn {\n background: #22c55e !important;\n color: #ffffff !important;\n }\n\n [data-theme="coffee"] .upgrade-btn {\n background: #a0522d !important;\n color: #ffffff !important;\n }\n\n [data-theme="winter"] .upgrade-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n\n /* Cancel Button Styles for All Themes */\n [data-theme="dark"] .cancel-btn {\n background: #4b5563 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cyberpunk"] .cancel-btn {\n background: #7e22ce !important;\n color: #ffffff !important;\n }\n\n [data-theme="valentine"] .cancel-btn {\n background: #c11560 !important;\n color: #ffffff !important;\n }\n\n [data-theme="bumblebee"] .cancel-btn {\n background: #d97706 !important;\n color: #ffffff !important;\n }\n\n [data-theme="garden"] .cancel-btn {\n background: #059669 !important;\n color: #ffffff !important;\n }\n\n [data-theme="emerald"] .cancel-btn {\n background: #059669 !important;\n color: #ffffff !important;\n }\n\n [data-theme="corporate"] .cancel-btn {\n background: #6b7280 !important;\n color: #ffffff !important;\n }\n\n [data-theme="forest"] .cancel-btn {\n background: #059669 !important;\n color: #ffffff !important;\n }\n\n [data-theme="halloween"] .cancel-btn {\n background: #7c3aed !important;\n color: #ffffff !important;\n }\n\n [data-theme="synthwave"] .cancel-btn {\n background: #7e22ce !important;\n color: #ffffff !important;\n }\n\n [data-theme="dracula"] .cancel-btn {\n background: #6272a4 !important;\n color: #ffffff !important;\n }\n\n [data-theme="luxury"] .cancel-btn {\n background: #8b5cf6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="night"] .cancel-btn {\n background: #0284c7 !important;\n color: #ffffff !important;\n }\n\n [data-theme="light"] .cancel-btn {\n background: #6b7280 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cupcake"] .cancel-btn {\n background: #ec4899 !important;\n color: #ffffff !important;\n }\n\n [data-theme="retro"] .cancel-btn {\n background: #b8925c !important;\n color: #ffffff !important;\n }\n\n [data-theme="aqua"] .cancel-btn {\n background: #0891b2 !important;\n color: #ffffff !important;\n }\n\n [data-theme="lofi"] .cancel-btn {\n background: #6b7280 !important;\n color: #ffffff !important;\n }\n\n [data-theme="pastel"] .cancel-btn {\n background: #8b5cf6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="fantasy"] .cancel-btn {\n background: #ec4899 !important;\n color: #ffffff !important;\n }\n\n [data-theme="wireframe"] .cancel-btn {\n background: #f5f5f5 !important;\n color: #000000 !important;\n border: 1px solid #000000 !important;\n }\n\n [data-theme="black"] .cancel-btn {\n background: #6b7280 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cmyk"] .cancel-btn {\n background: #0369a1 !important;\n color: #ffffff !important;\n }\n\n [data-theme="autumn"] .cancel-btn {\n background: #c2410c !important;\n color: #ffffff !important;\n }\n\n [data-theme="business"] .cancel-btn {\n background: #6b7280 !important;\n color: #ffffff !important;\n }\n\n [data-theme="acid"] .cancel-btn {\n background: #65a30d !important;\n color: #ffffff !important;\n }\n\n [data-theme="lemonade"] .cancel-btn {\n background: #16a34a !important;\n color: #ffffff !important;\n }\n\n [data-theme="coffee"] .cancel-btn {\n background: #8b4513 !important;\n color: #ffffff !important;\n }\n\n [data-theme="winter"] .cancel-btn {\n background: #1e40af !important;\n color: #ffffff !important;\n }\n\n /* Success Button Styles for All Themes */\n [data-theme="dark"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cyberpunk"] .success-btn {\n background: #00ff41 !important;\n color: #000000 !important;\n }\n\n [data-theme="valentine"] .success-btn {\n background: #e91e7a !important;\n color: #ffffff !important;\n }\n\n [data-theme="bumblebee"] .success-btn {\n background: #f59e0b !important;\n color: #ffffff !important;\n }\n\n [data-theme="garden"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="emerald"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="corporate"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="forest"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="halloween"] .success-btn {\n background: #ff7b00 !important;\n color: #000000 !important;\n }\n\n [data-theme="synthwave"] .success-btn {\n background: #00ff41 !important;\n color: #000000 !important;\n }\n\n [data-theme="dracula"] .success-btn {\n background: #50fa7b !important;\n color: #000000 !important;\n }\n\n [data-theme="luxury"] .success-btn {\n background: #d4af37 !important;\n color: #000000 !important;\n }\n\n [data-theme="night"] .success-btn {\n background: #22d3ee !important;\n color: #ffffff !important;\n }\n\n [data-theme="light"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cupcake"] .success-btn {\n background: #f472b6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="retro"] .success-btn {\n background: #d4a574 !important;\n color: #ffffff !important;\n }\n\n [data-theme="aqua"] .success-btn {\n background: #06b6d4 !important;\n color: #ffffff !important;\n }\n\n [data-theme="lofi"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="pastel"] .success-btn {\n background: #34d399 !important;\n color: #ffffff !important;\n }\n\n [data-theme="fantasy"] .success-btn {\n background: #f472b6 !important;\n color: #ffffff !important;\n }\n\n [data-theme="wireframe"] .success-btn {\n background: #dfdfdf !important;\n color: #000000 !important;\n border: 1px solid #000000 !important;\n }\n\n [data-theme="black"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="cmyk"] .success-btn {\n background: #06b6d4 !important;\n color: #ffffff !important;\n }\n\n [data-theme="autumn"] .success-btn {\n background: #d97706 !important;\n color: #ffffff !important;\n }\n\n [data-theme="business"] .success-btn {\n background: #10b981 !important;\n color: #ffffff !important;\n }\n\n [data-theme="acid"] .success-btn {\n background: #84cc16 !important;\n color: #000000 !important;\n }\n\n [data-theme="lemonade"] .success-btn {\n background: #22c55e !important;\n color: #ffffff !important;\n }\n\n [data-theme="coffee"] .success-btn {\n background: #a0522d !important;\n color: #ffffff !important;\n }\n\n [data-theme="winter"] .success-btn {\n background: #3b82f6 !important;\n color: #ffffff !important;\n }\n .download-limiter-signout-btn {\n background: #dc3545;\n color: white;\n border: none;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px;\n cursor: pointer;\n margin-left: 8px;\n }\n .download-limiter-premium-badge {\n background: linear-gradient(45deg, #f39c12, #e74c3c);\n color: white;\n padding: 2px 6px;\n border-radius: 3px;\n font-size: 10px;\n margin-left: 8px;\n font-weight: bold;\n }\n .download-limiter-btn-premium {\n opacity: 0.7;\n }\n .download-limiter-success-modal {\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0,0,0,0.5);\n z-index: 10000;\n align-items: center;\n justify-content: center;\n }\n .download-limiter-success-modal.show { display: flex; }\n .download-limiter-success-content {\n background: white;\n padding: 2rem;\n border-radius: 8px;\n max-width: 400px;\n text-align: center;\n box-shadow: 0 4px 20px rgba(0,0,0,0.15);\n border-left: 4px solid #38a169;\n }\n\n /* Single upgrade flow styles */\n .single-upgrade-container {\n margin: 20px 0;\n text-align: center;\n }\n\n .single-upgrade-content .upgrade-btn {\n background: linear-gradient(135deg, #059669, #0d9488) !important;\n color: white !important;\n border: none !important;\n padding: 16px 32px !important;\n border-radius: 12px !important;\n font-size: 18px !important;\n font-weight: 600 !important;\n cursor: pointer !important;\n transition: all 0.3s ease !important;\n box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3) !important;\n margin-bottom: 16px !important;\n min-width: 200px !important;\n }\n\n .single-upgrade-content .upgrade-btn:hover {\n background: linear-gradient(135deg, #047857, #0f766e) !important;\n transform: translateY(-2px) !important;\n box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4) !important;\n }\n\n .single-upgrade-content .upgrade-description {\n font-size: 14px !important;\n color: #6b7280 !important;\n margin: 12px 0 0 0 !important;\n line-height: 1.5 !important;\n max-width: 300px !important;\n margin-left: auto !important;\n margin-right: auto !important;\n }\n\n /* Anonymous user usage count styles */\n .lead-fast-anonymous-status {\n display: flex;\n align-items: center;\n gap: 12px;\n }\n\n .lead-fast-anonymous-status .lead-fast-count {\n background: rgba(59, 130, 246, 0.1);\n color: #1d4ed8;\n padding: 6px 12px;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n border: 1px solid rgba(59, 130, 246, 0.2);\n }\n\n /* Loading state styles */\n .lead-fast-loading-status {\n display: flex;\n align-items: center;\n gap: 10px;\n }\n\n .lead-fast-spinner {\n width: 20px;\n height: 20px;\n color: #3b82f6;\n }\n\n .lead-fast-loading-text {\n font-size: 14px;\n color: #6b7280;\n font-weight: 500;\n }\n\n /* Success button theming */\n .download-limiter-btn.success-btn {\n background: #059669 !important;\n color: white !important;\n border: none !important;\n padding: 12px 24px !important;\n border-radius: 8px !important;\n cursor: pointer !important;\n margin-top: 20px !important;\n font-size: 16px !important;\n font-weight: 500 !important;\n transition: all 0.2s ease !important;\n }\n\n .download-limiter-btn.success-btn:hover {\n background: #047857 !important;\n transform: translateY(-1px) !important;\n }\n\n /* Theme-specific success button colors */\n [data-theme="cyberpunk"] .download-limiter-btn.success-btn {\n background: #0ea5e9 !important;\n box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3) !important;\n }\n\n [data-theme="cyberpunk"] .download-limiter-btn.success-btn:hover {\n background: #0284c7 !important;\n }\n\n [data-theme="valentine"] .download-limiter-btn.success-btn {\n background: #be185d !important;\n }\n\n [data-theme="valentine"] .download-limiter-btn.success-btn:hover {\n background: #9d174d !important;\n }\n\n [data-theme="bumblebee"] .download-limiter-btn.success-btn {\n background: #f59e0b !important;\n }\n\n [data-theme="bumblebee"] .download-limiter-btn.success-btn:hover {\n background: #d97706 !important;\n }\n\n [data-theme="garden"] .download-limiter-btn.success-btn {\n background: #16a34a !important;\n }\n\n [data-theme="garden"] .download-limiter-btn.success-btn:hover {\n background: #15803d !important;\n }\n\n /* Google Sign-in button theming */\n .download-limiter-btn.google-signin-btn {\n background: #4285f4 !important;\n color: white !important;\n border: none !important;\n padding: 12px 24px !important;\n border-radius: 8px !important;\n cursor: pointer !important;\n margin-right: 10px !important;\n display: inline-flex !important;\n align-items: center !important;\n gap: 8px !important;\n font-size: 14px !important;\n font-weight: 500 !important;\n transition: all 0.2s ease !important;\n }\n\n .download-limiter-btn.google-signin-btn:hover {\n background: #3367d6 !important;\n transform: translateY(-1px) !important;\n }\n\n /* Upgrade button theming */\n .download-limiter-btn.upgrade-btn {\n background: #059669 !important;\n color: white !important;\n border: none !important;\n padding: 12px 24px !important;\n border-radius: 8px !important;\n cursor: pointer !important;\n margin-right: 10px !important;\n font-size: 16px !important;\n font-weight: 500 !important;\n transition: all 0.2s ease !important;\n }\n\n .download-limiter-btn.upgrade-btn:hover {\n background: #047857 !important;\n transform: translateY(-1px) !important;\n }\n\n /* Theme-specific button colors */\n [data-theme="cyberpunk"] .download-limiter-btn.upgrade-btn {\n background: #0ea5e9 !important;\n box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3) !important;\n }\n\n [data-theme="valentine"] .download-limiter-btn.upgrade-btn {\n background: #be185d !important;\n }\n\n [data-theme="bumblebee"] .download-limiter-btn.upgrade-btn {\n background: #f59e0b !important;\n }\n\n [data-theme="garden"] .download-limiter-btn.upgrade-btn {\n background: #16a34a !important;\n }\n\n /* Cancel button container and styling - positioned at very bottom */\n .download-limiter-cancel-container {\n margin-top: 30px !important;\n padding-top: 20px !important;\n border-top: 1px solid rgba(0, 0, 0, 0.1) !important;\n text-align: center !important;\n position: relative !important;\n bottom: 0 !important;\n }\n\n .download-limiter-btn.cancel-btn {\n background: transparent !important;\n color: #6b7280 !important;\n border: none !important;\n padding: 8px 16px !important;\n border-radius: 6px !important;\n cursor: pointer !important;\n font-size: 13px !important;\n font-weight: 400 !important;\n transition: all 0.2s ease !important;\n text-decoration: underline !important;\n margin: 0 auto !important;\n display: block !important;\n }\n\n .download-limiter-btn.cancel-btn:hover {\n color: #374151 !important;\n background: rgba(107, 114, 128, 0.1) !important;\n text-decoration: none !important;\n }\n\n /* Theme-specific cancel button border */\n [data-theme="dark"] .download-limiter-cancel-container {\n border-top-color: rgba(255, 255, 255, 0.1) !important;\n }\n\n [data-theme="dark"] .download-limiter-btn.cancel-btn {\n color: #9ca3af !important;\n }\n\n [data-theme="dark"] .download-limiter-btn.cancel-btn:hover {\n color: #d1d5db !important;\n background: rgba(156, 163, 175, 0.1) !important;\n }\n\n [data-theme="cyberpunk"] .download-limiter-cancel-container {\n border-top-color: rgba(14, 165, 233, 0.2) !important;\n }\n\n [data-theme="cyberpunk"] .download-limiter-btn.cancel-btn {\n color: #0ea5e9 !important;\n }\n\n [data-theme="cyberpunk"] .download-limiter-btn.cancel-btn:hover {\n color: #38bdf8 !important;\n background: rgba(14, 165, 233, 0.1) !important;\n }\n `,document.head.appendChild(n)}injectDaisyUI(){if(document.querySelector('link[href*="daisyui"]')){if(this.config.theme?.name){const n=this.config.theme.name.toLowerCase();document.documentElement.setAttribute("data-theme",n)}}else if(this.config.theme?.name){const n=this.config.theme.name.toLowerCase();document.documentElement.setAttribute("data-theme",n),this.updateStatusDisplays()}}createPaywallModal(){if(document.getElementById("download-limiter-paywall"))return;const n=document.createElement("div");n.id="download-limiter-paywall",n.className="download-limiter-modal",n.innerHTML='\n <div class="download-limiter-content">\n <h3 id="download-limiter-paywall-title">Usage Limit Reached</h3>\n <p id="download-limiter-paywall-subtitle">You\'ve used all your free attempts. Upgrade to premium for unlimited usage!</p>\n\n \x3c!-- Auth Section (shows when not signed in) --\x3e\n <div id="download-limiter-auth-section" style="margin: 20px 0;">\n <p>Sign in to continue or upgrade to premium</p>\n <button id="download-limiter-signin-btn" class="download-limiter-btn google-signin-btn">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none">\n <path d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a8.8 8.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18z" fill="white"/>\n <path d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2.04a4.8 4.8 0 0 1-2.7.75 4.8 4.8 0 0 1-4.52-3.4H1.83v2.07A8 8 0 0 0 8.98 17z" fill="white"/>\n <path d="M4.46 10.37a4.8 4.8 0 0 1-.25-1.37c0-.48.09-.94.25-1.37V5.56H1.83a8 8 0 0 0 0 6.88l2.63-2.07z" fill="white"/>\n <path d="M8.98 3.77c1.32 0 2.5.45 3.44 1.35l2.58-2.58C13.94.64 11.66 0 8.98 0A8 8 0 0 0 1.83 5.56l2.63 2.07c.61-1.8 2.26-3.86 4.52-3.86z" fill="white"/>\n </svg>\n Sign in with Google\n </button>\n </div>\n\n \x3c!-- Payment Section (shows when signed in) --\x3e\n <div id="download-limiter-payment-section" style="margin: 20px 0; display: none;">\n <button id="download-limiter-upgrade-btn" class="download-limiter-btn upgrade-btn">\n Upgrade to Premium\n </button>\n </div>\n\n <div class="download-limiter-cancel-container">\n <button id="download-limiter-close-btn" class="download-limiter-btn cancel-btn">\n Cancel\n </button>\n </div>\n </div>\n ',document.body.appendChild(n),n.querySelector("#download-limiter-signin-btn").addEventListener("click",async()=>{await this.signIn()}),n.querySelector("#download-limiter-upgrade-btn").addEventListener("click",async()=>{const n=await this.createPayment();n?.checkout_url&&(window.location.href=n.checkout_url)}),n.querySelector("#download-limiter-close-btn").addEventListener("click",()=>{this.config.options?.debug&&(console.log("🔍 DEBUG: Cancel button clicked"),console.log("🔍 DEBUG: this.config.feedback:",this.config.feedback),console.log("🔍 DEBUG: this.config.email:",this.config.email),console.log("🔍 DEBUG: Feedback config exists:",!(!this.config.feedback&&!this.config.email))),this.config.feedback||this.config.email?(this.config.options?.debug&&console.log("🔍 DEBUG: Showing feedback form"),this.showFeedbackForm()):(this.config.options?.debug&&console.log("🔍 DEBUG: No email config, just closing modal"),n.classList.remove("show"))})}createSuccessModal(){if(document.getElementById("download-limiter-success"))return;const n=document.createElement("div");n.id="download-limiter-success",n.className="download-limiter-modal",n.innerHTML='\n <div class="download-limiter-content"> \x3c!-- Use same content class as paywall for theming --\x3e\n <h3 id="download-limiter-success-title">Action Started!</h3>\n <p id="download-limiter-success-message">Your action completed successfully!</p>\n <button id="download-limiter-success-close" class="download-limiter-btn success-btn">\n OK\n </button>\n </div>\n ',document.body.appendChild(n),n.querySelector("#download-limiter-success-close").addEventListener("click",()=>{n.classList.remove("show")}),n.addEventListener("click",t=>{t.target===n&&n.classList.remove("show")})}showFeedbackForm(){const n=document.getElementById("download-limiter-paywall");n&&n.classList.remove("show"),this.createFeedbackModal();const t=document.getElementById("download-limiter-feedback");t&&t.classList.add("show")}createFeedbackModal(){if(document.getElementById("download-limiter-feedback"))return void(this.config.options?.debug&&console.log("🔍 DEBUG: Feedback modal already exists"));const n=this.config.feedback||(this.config.email?{form:{title:"Quick Feedback",description:"Why didn't you upgrade?",option1:"Not useful for my needs",option2:"Didn't find what I was looking for",option3:"Just trying it out"},email:this.config.email}:null);if(this.config.options?.debug&&(console.log("🔍 DEBUG: Feedback config:",n),console.log("🔍 DEBUG: this.config.feedback:",this.config.feedback),console.log("🔍 DEBUG: this.config.email:",this.config.email)),!n)return void(this.config.options?.debug&&console.log("🔍 DEBUG: No feedback config found, not creating modal"));const t=document.createElement("div");t.id="download-limiter-feedback",t.className="download-limiter-modal",t.innerHTML=`\n <div class="download-limiter-content">\n <h3>${n.form.title}</h3>\n <p style="margin-bottom: 20px;">${n.form.description}</p>\n\n <form id="feedback-form" style="text-align: left;">\n <div style="margin-bottom: 15px;">\n <label style="display: block; margin-bottom: 8px;">\n <input type="radio" name="reason" value="option1" style="margin-right: 8px;">\n ${n.form.option1}\n </label>\n <label style="display: block; margin-bottom: 8px;">\n <input type="radio" name="reason" value="option2" style="margin-right: 8px;">\n ${n.form.option2}\n </label>\n <label style="display: block; margin-bottom: 8px;">\n <input type="radio" name="reason" value="option3" style="margin-right: 8px;">\n ${n.form.option3}\n </label>\n </div>\n\n <div style="margin-bottom: 15px;">\n <label for="feedback-details" style="display: block; margin-bottom: 5px;">Tell us more:</label>\n <textarea\n id="feedback-details"\n name="details"\n rows="3"\n style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"\n placeholder="Your feedback helps us improve..." maxlength="200"></textarea>\n </div>\n\n <div style="margin-bottom: 20px;">\n <label for="feedback-email" style="display: block; margin-bottom: 5px;">\n Email (optional):\n </label>\n <input\n type="email"\n id="feedback-email"\n name="email"\n style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"\n placeholder="your@email.com">\n <small style="color: #666; display: block; margin-top: 4px;">\n Only if you want us to reach out about what you mentioned above. We don't follow up unless you want us to\n </small>\n </div>\n\n \n <div style="text-align: center;">\n <button type="submit" class="download-limiter-btn success-btn" style="margin-right: 10px;">\n Submit Feedback\n </button>\n <button type="button" id="feedback-skip-btn" class="download-limiter-btn cancel-btn">\n Skip\n </button>\n </div>\n </form>\n </div>\n `,document.body.appendChild(t),this.config.options?.debug&&console.log("🔍 DEBUG: Feedback modal created and added to DOM");const e=t.querySelector("#feedback-form");e.addEventListener("submit",n=>{n.preventDefault(),this.submitFeedback(e)}),t.querySelector("#feedback-skip-btn").addEventListener("click",()=>{t.classList.remove("show")}),t.addEventListener("click",n=>{n.target===t&&t.classList.remove("show")})}async submitFeedback(n){const t=new FormData(n),e=t.get("reason"),a=t.get("details"),o=t.get("email");if(!e)return void alert("Please select a reason");const r={reason:e,details:a,email:o||void 0,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,appId:this.config.appId};try{await this.sendFeedbackEmail(r);const n=document.getElementById("download-limiter-feedback");n&&n.classList.remove("show"),alert("Thank you for your feedback!")}catch(n){console.error("Failed to send feedback:",n),alert("Failed to send feedback. Please try again.")}}async sendFeedbackEmail(n){let t;if(this.config.feedback?.email?t=Array.isArray(this.config.feedback.email)?this.config.feedback.email[0]:this.config.feedback.email:this.config.email&&(t={provider:"resend",apiKey:this.config.email.resendApiKey,fromEmail:this.config.email.fromEmail}),!t)throw new Error("Email configuration not available");const e=`\nNew Feedback from ${this.config.appId}\n\nReason: ${n.reason}\nDetails: ${n.details}\nUser Email: ${n.email||"Not provided"}\nTimestamp: ${n.timestamp}\nUser Agent: ${n.userAgent}\n `.trim();let a;if("resend"!==t.provider&&t.provider)throw new Error(`Unsupported email provider: ${t.provider}`);if(a=await fetch("https://api.resend.com/emails",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.apiKey||t.resendApiKey}`},body:JSON.stringify({from:t.fromEmail,to:[t.fromEmail],subject:`Feedback from ${this.config.appId}`,text:e})}),!a.ok)throw new Error(`Email API error: ${a.status}`)}createAuthUI(){if(document.getElementById("lead-fast-profile"))return;const n=document.createElement("div");n.id="lead-fast-profile",n.className="lead-fast-profile",document.body.appendChild(n)}createStatusDisplay(){if(document.getElementById("download-limiter-status"))return;const n=document.createElement("div");n.id="download-limiter-status",n.className="download-limiter-status",document.body.appendChild(n)}createGlobalStatusDisplay(){this.createStatusDisplay()}showPaywallInstant(n){this.createPaywallModal();const t=document.getElementById("download-limiter-paywall");if(t){const e=t.querySelector("#download-limiter-paywall-title");e&&(e.textContent=`You've used ${n.limit} free attempts`);const a=t.querySelector("#download-limiter-auth-section"),o=t.querySelector("#download-limiter-payment-section");if(this.currentUser)a.style.display="none",o.style.display="block";else{const n=t.querySelector("#download-limiter-paywall-subtitle");n&&(n.textContent="Sign in to continue. If you're already premium, you'll get unlimited access. New users can upgrade after signing in."),a.style.display="none",o.style.display="none",this.showSingleUpgradeFlow(t)}t.classList.add("show")}}async showPaywall(){const n=await this.getDownloadStatus();this.showPaywallInstant(n)}showSingleUpgradeFlow(n){let t=n.querySelector(".single-upgrade-container");if(!t){t=document.createElement("div"),t.className="single-upgrade-container",t.innerHTML='\n <div class="single-upgrade-content">\n <button class="download-limiter-btn upgrade-btn" id="single-upgrade-btn">\n Continue with Google\n </button>\n \x3c!--<p class="upgrade-description">\n Sign in to restore access. Premium members get unlimited usage immediately.\n </p>--\x3e\n </div>\n ';const e=n.querySelector(".download-limiter-cancel-container");e?n.querySelector(".download-limiter-content")?.insertBefore(t,e):n.querySelector(".download-limiter-content")?.appendChild(t)}t.style.display="block";const e=n.querySelector("#single-upgrade-btn");if(e){e.replaceWith(e.cloneNode(!0));const t=n.querySelector("#single-upgrade-btn");t?.addEventListener("click",async()=>{try{const{error:n}=await this.supabase.auth.signInWithOAuth({provider:"google",options:{redirectTo:`${window.location.origin}${window.location.pathname}?upgrade=true`}});n&&(console.error("Sign in error:",n),this.showError("Sign In Failed","Failed to sign in with Google. Please try again."))}catch(n){console.error("Upgrade flow error:",n),this.showError("Upgrade Failed","Failed to start upgrade process. Please try again.")}})}}showSuccess(n,t){const e=document.getElementById("download-limiter-success");if(e){const a=e.querySelector("#download-limiter-success-title"),o=e.querySelector("#download-limiter-success-message");a&&(a.textContent=n),o&&(o.textContent=t),e.classList.add("show")}}showError(n,t){const e=document.createElement("div");e.style.cssText="\n position: fixed;\n top: 20px;\n right: 20px;\n background: #fee2e2;\n border: 1px solid #fecaca;\n color: #dc2626;\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n line-height: 1.4;\n max-width: 300px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n ",e.innerHTML=`\n <div style="font-weight: 600; margin-bottom: 4px;">${n}</div>\n <div style="font-size: 13px; opacity: 0.9;">${t}</div>\n `,document.body.appendChild(e),setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},5e3),e.addEventListener("click",()=>{e.parentNode&&e.parentNode.removeChild(e)})}showConnectionError(){this.showError("Connection Error","Server connection required for download verification. Please check your configuration and try again.")}showPaymentConfigError(){this.showError("Payment Configuration Error","Payment system is not properly configured. Please contact support.")}disableDownloadButtons(n){const t=document.querySelectorAll("[data-leadfast-attached]"),e={connection:"Download disabled: Server connection required",payment:"Download disabled: Payment configuration error",security_key:"Download disabled: Invalid or missing security key"},a={connection:"⚠️ Connection Error - Downloads Disabled",payment:"⚠️ Payment Config Error - Downloads Disabled",security_key:"🔐 Invalid Security Key - Please Update Configuration"};t.forEach(t=>{const a=t;a.disabled=!0,a.style.opacity="0.5",a.style.cursor="not-allowed",a.title=e[n]});const o=document.querySelector(".lead-fast-user-section");o&&(o.innerHTML=`\n <div style="\n color: #ef4444;\n padding: 6px 8px;\n font-size: 12px;\n font-weight: 500;\n line-height: 1.2;\n border-radius: 4px;\n background: rgba(239, 68, 68, 0.05);\n border: 1px solid rgba(239, 68, 68, 0.2);\n max-width: 200px;\n text-align: center;\n ">\n ${a[n]}\n </div>\n `)}async updateStatusDisplays(){if(this.securityKeyFailed)return void this.disableDownloadButtons("security_key");if(this.supabaseConnectionFailed)return void this.disableDownloadButtons("connection");if(this.config.payment&&this.paymentConnectionFailed)return void this.disableDownloadButtons("payment");this.isLoadingStatus=!0,this.updateUserSection(null);const n=await this.getDownloadStatus();this.isLoadingStatus=!1,this.securityKeyFailed?this.disableDownloadButtons("security_key"):this.supabaseConnectionFailed?this.disableDownloadButtons("connection"):this.updateUserSection(n)}createTitleBar(){let n=document.getElementById("lead-fast-profile");n||(n=document.createElement("div"),n.id="lead-fast-profile",n.className="lead-fast-profile",document.body.appendChild(n));const t=this.config.titleBar||{},e=t.title||"My App",a=t.titleImage,o=t.links||[];n.innerHTML=`\n <div class="lead-fast-title-bar">\n <div class="lead-fast-title-section">\n <a href="#" class="lead-fast-logo">\n ${a?`<img src="${a}" alt="${e}">`:""}\n <span>${e}</span>\n </a>\n <nav class="lead-fast-nav">\n ${o.map(n=>`\n <a href="${n.url}" class="lead-fast-nav-link" ${n.target?`target="${n.target}"`:""}>\n ${n.text}\n </a>\n `).join("")}\n </nav>\n </div>\n\n <div class="lead-fast-user-section" id="lead-fast-user-section">\n \x3c!-- User section will be populated when logged in --\x3e\n </div>\n\n \x3c!-- <a href="https://www.moneyfast.bar" target="_blank" class="lead-fast-branding" style="text-decoration: none; color: inherit;">moneyfast.bar</a>--\x3e\n </div>\n `}updateUserSection(n){const t=document.getElementById("lead-fast-user-section");if(t)if(null===n||this.isLoadingStatus)t.innerHTML='\n <div class="lead-fast-loading-status">\n <svg class="lead-fast-spinner" viewBox="0 0 24 24">\n <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="3" fill="none" stroke-dasharray="31.4 31.4" stroke-linecap="round">\n <animateTransform attributeName="transform" type="rotate" from="0 12 12" to="360 12 12" dur="1s" repeatCount="indefinite"/>\n </circle>\n </svg>\n <span class="lead-fast-loading-text">Loading...</span>\n </div>\n ';else if(this.currentUser){const e=this.currentUser.email.charAt(0).toUpperCase(),a=this.currentUser.email,o=n.isPremium?"premium":"free",r=n.isPremium?"Premium":"Free",i=n.isPremium?"Unlimited":`${n.currentCount}/${n.limit}`;t.innerHTML=`\n <div class="lead-fast-avatar">${e}</div>\n <div class="lead-fast-user-info">\n <div class="lead-fast-user-email">${a}</div>\n <div class="lead-fast-user-status">\n <span class="lead-fast-badge ${o}">${r}</span>\n <span class="lead-fast-count">${i}</span>\n </div>\n </div>\n <button class="lead-fast-signout">signout</button>\n `;const s=document.querySelector(".lead-fast-title-bar");s&&getComputedStyle(s);const d=t.querySelector(".lead-fast-signout");d&&d.addEventListener("click",()=>{this.signOut()})}else{const e=`Attempts: ${n.currentCount}/${n.limit}`;t.innerHTML=`\n <div class="lead-fast-anonymous-status">\n <span class="lead-fast-count">${e}</span>\n </div>\n `}}setupUIUpdates(){this.on("authChanged",async()=>{this.cachedStatus=null,this.updateStatusDisplays();const n=document.getElementById("download-limiter-paywall");n&&n.classList.contains("show")&&(this.updatePaywallDisplay(),this.currentUser&&this.config.payment&&setTimeout(async()=>{if(await this.checkPremiumStatus(this.currentUser.email))n.classList.remove("show");else{const n=await this.createPayment();n?.checkout_url&&(window.location.href=n.checkout_url)}},1e3))}),this.on("countChanged",()=>{this.updateStatusDisplays()}),this.updateStatusDisplays()}updatePaywallDisplay(){const n=document.getElementById("download-limiter-paywall");if(!n)return;const t=n.querySelector("#download-limiter-auth-section"),e=n.querySelector("#download-limiter-payment-section");this.currentUser?(t.style.display="none",e.style.display="block"):(t.style.display="block",e.style.display="none")}on(n,t){this.eventListeners.has(n)||this.eventListeners.set(n,[]),this.eventListeners.get(n).push(t)}off(n,t){const e=this.eventListeners.get(n);if(e){const n=e.indexOf(t);n>-1&&e.splice(n,1)}}emit(n,t){const e=this.eventListeners.get(n);e&&e.forEach(e=>{try{e(t)}catch(t){console.error(`Error in ${n} listener:`,t)}})}validateConfig(){if(!this.config.appId)throw new Error("appId is required");if(!this.config.supabase?.url)throw new Error("supabase.url is required");if(!this.config.supabase?.anonKey)throw new Error("supabase.anonKey is required");if("number"!=typeof this.config.freeAttemptLimit||this.config.freeAttemptLimit<0)throw new Error("freeAttemptLimit must be a non-negative number")}async initializeSupabase(){try{this.supabase=n(this.config.supabase.url,this.config.supabase.anonKey),this.supabaseConnectionFailed=!1}catch(n){console.error("Failed to initialize Supabase:",n),this.supabaseConnectionFailed=!0}}async initializePayment(){if(!this.config.payment)return;const n=this.config.payment?.find(n=>"dodo"===n.provider);if(!n)return this.paymentConnectionFailed=!0,void(this.config.options?.debug&&console.warn("No dodo payment provider configured"));const t=n.productId;if(!t||!t.startsWith("pdt_")||t.length<10)return this.paymentConnectionFailed=!0,void(this.config.options?.debug&&console.warn("Invalid payment product ID format:",t));this.paymentConnectionFailed=!1}async initializeFingerprint(){try{this.userFingerprint=await this.generateFingerprint()}catch(n){this.userFingerprint=crypto.randomUUID?crypto.randomUUID():String(Date.now()),this.config.options?.debug&&console.warn("Fingerprint generation failed, using fallback:",n)}}async generateFingerprint(){const n=`${navigator.userAgent||""}||${Intl.DateTimeFormat().resolvedOptions().timeZone||""}||${`${screen.width}x${screen.height}`}||${navigator.language||""}`,t=(new TextEncoder).encode(n),e=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}async setupAuthListener(){this.supabase.auth.onAuthStateChange(async(n,t)=>{const e=this.currentUser;this.currentUser=t?.user||null;let a=!1;if(this.currentUser){const n=!e||e.email!==this.currentUser.email,t=!this.cachedPremiumStatus||Date.now()-this.premiumStatusCacheTime>this.STATUS_CACHE_DURATION;n||t?(a=await this.checkPremiumStatus(this.currentUser.email),this.cachedPremiumStatus=a,this.premiumStatusCacheTime=Date.now()):(a=this.cachedPremiumStatus,console.log(`🔍 [CACHE] Using cached premium status from auth listener: ${a}`))}else this.cachedPremiumStatus=null,this.premiumStatusCacheTime=0;const o="true"===new URLSearchParams(window.location.search).get("upgrade");if("SIGNED_IN"===n&&!e&&this.currentUser&&this.config.payment&&o)if(a){window.history.replaceState({},document.title,window.location.pathname);const n=document.getElementById("download-limiter-paywall");n&&n.classList.remove("show")}else{const n=await this.createPayment();n?.checkout_url&&(window.history.replaceState({},document.title,window.location.pathname),window.location.href=n.checkout_url)}this.emit("authChanged",{user:this.currentUser,isPremium:a})});const{data:{user:n}}=await this.supabase.auth.getUser();this.currentUser=n}async getDownloadCount(){if(!this.userFingerprint)return 0;try{const n=await fetch(`${this.config.supabase.url}/functions/v1/check-download-limit`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.supabase.anonKey}`},body:JSON.stringify({fingerprint:this.userFingerprint,security_key:this.config.security_key,action:"check"})});if(n.ok){const t=await n.json();return this.supabaseConnectionFailed=!1,t.current_count||0}if(401===n.status||403===n.status)try{const t=await n.json(),e=t.error||t.message||"Authentication failed";e.toLowerCase().includes("security key")?(console.error(`❌ Security Key Validation Failed [check-download-limit]: ${e}`),console.error("💡 Backend Function: check-download-limit"),console.error("💡 Please check your security_key in the MoneyBar configuration"),this.securityKeyFailed=!0,this.supabaseConnectionFailed=!0):(console.warn(`Supabase authentication failed [check-download-limit]: ${n.status} - ${e}`),this.supabaseConnectionFailed=!0)}catch(t){console.warn(`Supabase authentication failed: ${n.status} - Unable to parse error`),this.supabaseConnectionFailed=!0}}catch(n){this.supabaseConnectionFailed=!0,this.config.options?.debug&&console.warn("Failed to get server usage count, connection failed:",n)}return 0}async incrementDownloadCount(){if(!this.userFingerprint)return 0;const n={fingerprint:this.userFingerprint,security_key:this.config.security_key,action:"increment"};try{const t=await fetch(`${this.config.supabase.url}/functions/v1/check-download-limit`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.supabase.anonKey}`},body:JSON.stringify(n)});if(this.config.options?.debug&&!t.ok){const n=await t.text();console.error("🔍 DEBUG: Error response:",n)}if(t.ok){const n=await t.json();return this.supabaseConnectionFailed=!1,n.new_count||0}if(401===t.status||403===t.status)try{const n=await t.json(),e=n.error||n.message||"Authentication failed";e.toLowerCase().includes("security key")?(console.error(`❌ Security Key Validation Failed [check-download-limit]: ${e}`),console.error("💡 Backend Function: check-download-limit"),console.error("💡 Please check your security_key in the MoneyBar configuration"),this.securityKeyFailed=!0,this.supabaseConnectionFailed=!0):(console.warn(`Supabase authentication failed [check-download-limit]: ${t.status} - ${e}`),this.supabaseConnectionFailed=!0)}catch(n){console.warn(`Supabase authentication failed: ${t.status} - Unable to parse error`),this.supabaseConnectionFailed=!0}}catch(n){this.supabaseConnectionFailed=!0,this.config.options?.debug&&console.warn("Failed to increment server count, connection failed:",n)}return 0}async checkPremiumStatus(n){try{const t=await fetch(`${this.config.supabase.url}/functions/v1/check-payment-status`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.supabase.anonKey}`},body:JSON.stringify({email:n,app_id:this.config.appId})});if(t.ok){return"completed"===(await t.json()).status}}catch(n){this.config.options?.debug&&console.warn("Failed to check premium status:",n)}return!1}getLocalDownloadCount(){const n=`download_count_${this.config.appId}`,t=parseInt(localStorage.getItem(n)||"0",10);return isNaN(t)?0:t}incrementLocalDownloadCount(){const n=`download_count_${this.config.appId}`,t=this.getLocalDownloadCount()+1;return localStorage.setItem(n,String(t)),t}handleError(n){this.config.options?.debug&&console.error("Lead Fast Error:",n),this.config.callbacks?.onError?this.config.callbacks.onError(n):console.error("Lead Fast:",n.message),this.emit("error",n)}async checkPaymentStatus(){"success"===new URLSearchParams(window.location.search).get("payment")&&setTimeout(async()=>{if(this.currentUser){await this.checkPremiumStatus(this.currentUser.email)?this.showSuccess("Payment Successful!","Welcome to premium! You now have unlimited usage."):this.showSuccess("Processing Payment","Payment is being processed. Please refresh in a few moments.")}else this.showSuccess("Processing Payment","Please wait while we verify your payment...");const n=window.location.href.split("?")[0];window.history.replaceState({},document.title,n)},2e3)}}export{t as MoneyBar};
3202
2
  //# sourceMappingURL=index.esm.js.map