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