@onairos/react-native 3.7.2 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +116 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +109 -1
- package/lib/module/components/EmailInput.js +23 -1
- package/lib/module/components/GoogleButton.js +49 -1
- package/lib/module/components/HeadingGroup.js +36 -1
- package/lib/module/components/LLMDataInputModal.js +656 -7
- package/lib/module/components/ModalHeader.js +92 -1
- package/lib/module/components/ModalSheet.js +39 -1
- package/lib/module/components/Onairos.js +373 -1
- package/lib/module/components/OnairosButton.js +305 -1
- package/lib/module/components/OnairosSignInButton.js +121 -1
- package/lib/module/components/Overlay.js +456 -1
- package/lib/module/components/PersonaImage.js +129 -1
- package/lib/module/components/PersonaLoadingScreen.js +310 -1
- package/lib/module/components/PersonalizationConsentScreen.js +460 -1
- package/lib/module/components/PinCreationScreen.js +396 -1
- package/lib/module/components/PinInput.js +456 -1
- package/lib/module/components/PlatformConnectorsStep.js +1302 -6
- package/lib/module/components/PlatformList.js +129 -1
- package/lib/module/components/PlatformToggle.js +173 -1
- package/lib/module/components/PrimaryButton.js +172 -1
- package/lib/module/components/SignInMatchAnimation.js +189 -1
- package/lib/module/components/SignInStep.js +338 -1
- package/lib/module/components/UniversalOnboarding.js +2770 -1
- package/lib/module/components/VerificationStep.js +168 -1
- package/lib/module/components/WelcomeScreen.js +453 -1
- package/lib/module/components/icons/Basicproficon.js +30 -1
- package/lib/module/components/icons/Basicprofile.js +14 -1
- package/lib/module/components/icons/Checkbox.js +14 -1
- package/lib/module/components/icons/Checkmark.js +20 -1
- package/lib/module/components/icons/Contentanalysis.js +14 -1
- package/lib/module/components/icons/Contenticon.js +32 -1
- package/lib/module/components/icons/EnochE.js +34 -1
- package/lib/module/components/icons/Personalityicon.js +23 -1
- package/lib/module/components/icons/Personalityprofile.js +14 -1
- package/lib/module/components/icons/Personalitytraits.js +14 -1
- package/lib/module/components/icons/Userpreferences.js +14 -1
- package/lib/module/components/icons/index.js +13 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
- package/lib/module/components/onboarding/PinInput.js +274 -1
- package/lib/module/components/onboarding/PlatformConnector.js +240 -1
- package/lib/module/config/PLATFORM_APIS.md +849 -0
- package/lib/module/config/api.js +47 -1
- package/lib/module/constants/index.js +114 -1
- package/lib/module/context/AuthContext.js +335 -1
- package/lib/module/hooks/useConnectedAccounts.js +106 -1
- package/lib/module/hooks/useConnections.js +95 -1
- package/lib/module/hooks/useCredentials.js +171 -6
- package/lib/module/hooks/useUserConnections.js +140 -1
- package/lib/module/index.js +172 -1
- package/lib/module/services/apiClient.js +295 -1
- package/lib/module/services/biometricPinService.js +169 -1
- package/lib/module/services/chatGPTConversationExtractor.js +149 -1
- package/lib/module/services/chatGPTConversationService.js +268 -1
- package/lib/module/services/claudeConversationExtractor.js +97 -1
- package/lib/module/services/claudeConversationService.js +151 -1
- package/lib/module/services/connectedAccountsService.js +293 -1
- package/lib/module/services/googleAuthService.js +241 -1
- package/lib/module/services/hingeDataExtractor.js +99 -1
- package/lib/module/services/hingeDataService.js +143 -1
- package/lib/module/services/imageCompressionService.js +250 -1
- package/lib/module/services/instagramDataExtractor.js +120 -1
- package/lib/module/services/instagramDataService.js +156 -1
- package/lib/module/services/jwtStorageService.js +257 -1
- package/lib/module/services/linkedinDOMExtractor.js +234 -1
- package/lib/module/services/linkedinProfileService.js +210 -1
- package/lib/module/services/linkedinScrapingService.js +219 -1
- package/lib/module/services/llmDataStorage.js +277 -1
- package/lib/module/services/mobileTrainingService.js +173 -1
- package/lib/module/services/netflixDataExtractor.js +114 -1
- package/lib/module/services/netflixDataService.js +191 -1
- package/lib/module/services/pinEncryptionService.js +74 -6
- package/lib/module/services/pinStorageUtils.js +93 -1
- package/lib/module/services/platformAuthService.js +1461 -1
- package/lib/module/services/sephoraDataExtractor.js +134 -1
- package/lib/module/services/sephoraDataService.js +193 -1
- package/lib/module/services/spotifyDataExtractor.js +142 -1
- package/lib/module/services/spotifyDataService.js +234 -1
- package/lib/module/services/storageService.js +383 -1
- package/lib/module/services/telegramDataExtractor.js +109 -1
- package/lib/module/services/telegramDataService.js +493 -1
- package/lib/module/services/trainingApiHelpers.js +67 -1
- package/lib/module/services/userConnectionsService.js +329 -1
- package/lib/module/services/youtubeMigrationService.js +405 -1
- package/lib/module/theme/index.js +245 -1
- package/lib/module/types.js +10 -1
- package/lib/module/utils/Portal.js +90 -1
- package/lib/module/utils/api.js +118 -1
- package/lib/module/utils/assetRegistry.js +200 -34
- package/lib/module/utils/auth.js +100 -1
- package/lib/module/utils/connectorTests.js +600 -27
- package/lib/module/utils/crypto.js +54 -1
- package/lib/module/utils/debugHelper.js +54 -1
- package/lib/module/utils/encryption.js +67 -1
- package/lib/module/utils/eventUtils.js +270 -1
- package/lib/module/utils/haptics.js +59 -8
- package/lib/module/utils/imagePreloader.js +3 -1
- package/lib/module/utils/networkDiagnostics.js +217 -1
- package/lib/module/utils/onairosApi.js +333 -1
- package/lib/module/utils/programmaticFlow.js +111 -1
- package/lib/module/utils/retryHelper.js +211 -1
- package/lib/module/utils/secureStorage.js +330 -6
- package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
- package/lib/module/utils/webviewScripts/claude.js +370 -1
- package/lib/module/utils/webviewScripts/hinge.js +405 -1
- package/lib/module/utils/webviewScripts/index.js +434 -1
- package/lib/module/utils/webviewScripts/instagram.js +448 -1
- package/lib/module/utils/webviewScripts/linkedin.js +874 -1
- package/lib/module/utils/webviewScripts/netflix.js +376 -1
- package/lib/module/utils/webviewScripts/sephora.js +510 -1
- package/lib/module/utils/webviewScripts/spotify.js +413 -1
- package/lib/module/utils/webviewScripts/telegram.js +672 -1
- package/package.json +2 -2
|
@@ -1 +1,54 @@
|
|
|
1
|
-
import{RSA}from'react-native-rsa-native';
|
|
1
|
+
import { RSA } from 'react-native-rsa-native';
|
|
2
|
+
import { sha256 as cryptoSha256 } from 'react-native-crypto-js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Encrypt data using RSA
|
|
6
|
+
* @param {string} publicKey - The RSA public key
|
|
7
|
+
* @param {string} data - The data to encrypt
|
|
8
|
+
* @returns {Promise<string>} - The encrypted data
|
|
9
|
+
*/
|
|
10
|
+
export const rsaEncrypt = async (publicKey, data) => {
|
|
11
|
+
try {
|
|
12
|
+
// Clean the public key format
|
|
13
|
+
const cleanedKey = publicKey.replace(/\\n/g, '').replace(/^\s+|\s+$/g, '').replace('-----BEGIN PUBLIC KEY-----', '').replace('-----END PUBLIC KEY-----', '').trim();
|
|
14
|
+
|
|
15
|
+
// Format the key properly for the library
|
|
16
|
+
const formattedKey = `-----BEGIN PUBLIC KEY-----\n${cleanedKey}\n-----END PUBLIC KEY-----`;
|
|
17
|
+
|
|
18
|
+
// Encrypt the data
|
|
19
|
+
const encrypted = await RSA.encrypt(data, formattedKey);
|
|
20
|
+
return encrypted;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('RSA encryption failed:', error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Hash data using SHA-256
|
|
29
|
+
* @param {string} data - The data to hash
|
|
30
|
+
* @returns {string} - The hashed data
|
|
31
|
+
*/
|
|
32
|
+
export const sha256 = data => {
|
|
33
|
+
return cryptoSha256(data).toString();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Convert a base64 string to a buffer
|
|
38
|
+
* @param {string} base64String - The base64 string to convert
|
|
39
|
+
* @returns {ArrayBuffer} - The converted buffer
|
|
40
|
+
*/
|
|
41
|
+
export const base64ToBuffer = base64String => {
|
|
42
|
+
try {
|
|
43
|
+
const binaryString = Buffer.from(base64String, 'base64').toString('binary');
|
|
44
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
45
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
46
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
47
|
+
}
|
|
48
|
+
return bytes.buffer;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Error converting base64 to buffer:', error);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Debug utility functions for Onairos React Native SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Determine if we're in dev mode
|
|
6
|
+
const __DEV__ = process.env.NODE_ENV !== 'production';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Log debug message to console when in development mode
|
|
10
|
+
* @param label Label for the debug message
|
|
11
|
+
* @param data Data to log
|
|
12
|
+
*/
|
|
13
|
+
export const logDebug = (label, data) => {
|
|
14
|
+
if (__DEV__) {
|
|
15
|
+
console.log(`[Onairos Debug] ${label}:`, data || '');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Log error message to console
|
|
21
|
+
* @param label Label for the error message
|
|
22
|
+
* @param error Error object or message
|
|
23
|
+
*/
|
|
24
|
+
export const logError = (label, error) => {
|
|
25
|
+
if (__DEV__) {
|
|
26
|
+
console.error(`[Onairos Error] ${label}:`, error);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Check if debug mode is enabled
|
|
32
|
+
* @param debug Debug flag passed to component
|
|
33
|
+
* @returns Whether debug mode is enabled
|
|
34
|
+
*/
|
|
35
|
+
export const isDebugMode = debug => {
|
|
36
|
+
return debug === true || __DEV__;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Format and log API request details
|
|
41
|
+
* @param method HTTP method
|
|
42
|
+
* @param url API URL
|
|
43
|
+
* @param data Request data
|
|
44
|
+
*/
|
|
45
|
+
export const logApiRequest = (method, url, data) => {
|
|
46
|
+
if (__DEV__) {
|
|
47
|
+
logDebug('API Request', {
|
|
48
|
+
method,
|
|
49
|
+
url,
|
|
50
|
+
data: data || {}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=debugHelper.js.map
|
|
@@ -1 +1,67 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { onairosApi } from '../api';
|
|
2
|
+
/**
|
|
3
|
+
* Encrypt a model key using RSA with a public key
|
|
4
|
+
* @param publicKey The public key to encrypt with
|
|
5
|
+
* @param modelKey The model key to encrypt
|
|
6
|
+
* @returns The encrypted model key
|
|
7
|
+
*/
|
|
8
|
+
export const encryptModelKey = (publicKey, modelKey) => {
|
|
9
|
+
try {
|
|
10
|
+
console.log('Encrypting model key');
|
|
11
|
+
if (!publicKey || !modelKey) {
|
|
12
|
+
throw new Error('Public key or model key is missing');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// In a production environment, this would use RSA encryption
|
|
16
|
+
// For now, we'll use a mock implementation
|
|
17
|
+
// return RSA.encrypt(modelKey, publicKey);
|
|
18
|
+
|
|
19
|
+
// Return a fake encrypted value
|
|
20
|
+
return `encrypted_${modelKey}_${Date.now()}`;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Error encrypting model key:', error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get the server's public key
|
|
29
|
+
* @returns The server's public key
|
|
30
|
+
*/
|
|
31
|
+
export const getServerPublicKey = async () => {
|
|
32
|
+
try {
|
|
33
|
+
var _response$data, _response$data2;
|
|
34
|
+
// Use the API without generics to prevent TypeScript errors
|
|
35
|
+
const response = await onairosApi.get('public/getPublicKey');
|
|
36
|
+
|
|
37
|
+
// Check for the public key in the response data
|
|
38
|
+
if (response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && (_response$data = _response$data.data) !== null && _response$data !== void 0 && _response$data.publicKey) {
|
|
39
|
+
return response.data.data.publicKey;
|
|
40
|
+
} else if (response !== null && response !== void 0 && (_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.publicKey) {
|
|
41
|
+
return response.data.publicKey;
|
|
42
|
+
} else {
|
|
43
|
+
throw new Error('No public key found in response');
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error getting server public key:', error);
|
|
47
|
+
// For testing, return a mock public key
|
|
48
|
+
return 'mock_public_key_for_testing';
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Hash a string using SHA-256
|
|
54
|
+
* @param input The string to hash
|
|
55
|
+
* @returns The hashed string
|
|
56
|
+
*/
|
|
57
|
+
export const hashString = async input => {
|
|
58
|
+
try {
|
|
59
|
+
// In a production environment, this would use a proper hashing function
|
|
60
|
+
// For now, we'll return a mock hash
|
|
61
|
+
return `hash_${input.replace(/\s+/g, '_')}_${Date.now()}`;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Error hashing string:', error);
|
|
64
|
+
return `fallback_hash_${Date.now()}`;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=encryption.js.map
|
|
@@ -1 +1,270 @@
|
|
|
1
|
-
function _0xab99(){const _0x2e01ec=['PqGHR','charAt','floor','random','en-US','long','numeric','hbkDq','ZKxuo','trim','sjCqN','toUpperCase','replace','split','filter','length','XhGRR','osJun','KMsRz','fWatz','slice','map','substring','getFullYear','revVD','uhoDn','OZIxr','KLxCA','AojWu','taoLk','toLocaleDateString','rVQFG','xrRTl','VFkRU','Event\x20code\x20is\x20required','Event\x20code\x20must\x20be\x20at\x20least\x203\x20characters','eCjoX','EPiHq','hVosP','tRYuU','dblQw','jKdwb','OislG','Iejuu','test','nQiFo','evKuI','YuDTz','RxWrh','kfolg','GSXhc','ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','cHalO','JsTCa','VnFce','HsOhG','getDate','TnZCn','uREzN','wYVgb','kcJkp','Event\x20code\x20must\x20be\x2010\x20characters\x20or\x20less','EuXgm','qsvEG','qPzam','setHours','Past','Upcoming','bitrT','UEBGt','Today','SeKve','lIBbx','getTime','ceil','xkCBB','ujGvG','tHIBq','sort','OwCwe','jsScI','XaQmM','cWvxK','isActive','eventDate','zRERP','QczOC','nRVpw','CxkhU','LmgEq','DCZoP','UKXhe','GSiNR','WLKkh','toLowerCase','includes','description','code','TFckA','location','hJXxQ','organizer','tags','qyXHX','ZjfsG','reduce','attendeeCount','GwoYN','round','rRUZj'];_0xab99=function(){return _0x2e01ec;};return _0xab99();}export const generateEventCode=(_0xefc064=0x6)=>{const _0x6ae6b2={'PqGHR':function(_0x4cb138,_0x19e8ec){return _0x4cb138<_0x19e8ec;},'wYpvT':function(_0x504caa,_0x40f4f0){return _0x504caa*_0x40f4f0;}},_0x5432c0='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';let _0x1aba03='';for(let _0x165f63=0x0;_0x6ae6b2[_0x5188(0x0)](_0x165f63,_0xefc064);_0x165f63++){_0x1aba03+=_0x5432c0[_0x5188(0x1)](Math[_0x5188(0x2)](_0x6ae6b2['wYpvT'](Math[_0x5188(0x3)](),_0x5432c0['length'])));}return _0x1aba03;};export const generateSmartEventCode=_0x42dc97=>{const _0x33f9d9={'sjCqN':function(_0x50d3dc){return _0x50d3dc();},'rVQFG':_0x5188(0x4),'xrRTl':_0x5188(0x5),'VFkRU':_0x5188(0x6),'XhGRR':function(_0x450172){return _0x450172();},'osJun':function(_0xd12bdd,_0x41522b){return _0xd12bdd===_0x41522b;},'KMsRz':'AxqHz','fWatz':_0x5188(0x7),'revVD':function(_0x57d27e,_0x48aef9){return _0x57d27e<_0x48aef9;},'OZIxr':'uhoDn','MvmPC':function(_0x16893c,_0x42ef9d){return _0x16893c-_0x42ef9d;},'KLxCA':function(_0x426621,_0x19d228){return _0x426621>_0x19d228;},'AojWu':function(_0x42b574,_0xa4e1df){return _0x42b574===_0xa4e1df;},'taoLk':_0x5188(0x8)};if(!_0x42dc97[_0x5188(0x9)]())return _0x33f9d9[_0x5188(0xa)](generateEventCode);const _0x438dc6=_0x42dc97['trim']()[_0x5188(0xb)]()[_0x5188(0xc)](/[^A-Z0-9\s]/g,'')[_0x5188(0xd)](/\s+/)[_0x5188(0xe)](_0x57cdf8=>_0x57cdf8[_0x5188(0xf)]>0x0);if(_0x438dc6[_0x5188(0xf)]===0x0)return _0x33f9d9[_0x5188(0x10)](generateEventCode);let _0x52e061='';if(_0x438dc6[_0x5188(0xf)]>=0x2){if(_0x33f9d9[_0x5188(0x11)](_0x33f9d9[_0x5188(0x12)],_0x33f9d9[_0x5188(0x13)]))return _0x3a46da();else{const _0xf621f7=_0x438dc6[_0x5188(0x14)](0x0,0x3);_0x52e061=_0xf621f7[_0x5188(0x15)](_0x353eec=>_0x353eec[_0x5188(0x16)](0x0,0x2))['join']('');}}else _0x52e061=_0x438dc6[0x0][_0x5188(0x16)](0x0,0x4);const _0x46211a=new Date()[_0x5188(0x17)]()['toString']()[_0x5188(0x14)](-0x2);_0x52e061+=_0x46211a;if(_0x33f9d9[_0x5188(0x18)](_0x52e061['length'],0x4)){if(_0x5188(0x19)===_0x33f9d9[_0x5188(0x1a)])_0x52e061+=generateEventCode(_0x33f9d9['MvmPC'](0x4,_0x52e061['length']));else return _0x33f9d9[_0x5188(0xa)](_0x40764a);}else{if(_0x33f9d9[_0x5188(0x1b)](_0x52e061[_0x5188(0xf)],0x8)){if(_0x33f9d9[_0x5188(0x1c)](_0x33f9d9['taoLk'],_0x33f9d9[_0x5188(0x1d)]))_0x52e061=_0x52e061['substring'](0x0,0x8);else{const _0x35e80e=new _0x504722(_0x352655);return _0x35e80e[_0x5188(0x1e)](_0x33f9d9[_0x5188(0x1f)],{'weekday':_0x33f9d9[_0x5188(0x20)],'year':_0x5188(0x6),'month':_0x33f9d9[_0x5188(0x20)],'day':_0x33f9d9[_0x5188(0x21)]});}}}return _0x52e061;};export const validateEventCode=_0x31a3c5=>{const _0x21a797={'hVosP':_0x5188(0x22),'dblQw':_0x5188(0x23),'tRYuU':function(_0x1f3dc7,_0x9f881d){return _0x1f3dc7<_0x9f881d;},'jKdwb':function(_0x1e8cd2,_0x189f12){return _0x1e8cd2===_0x189f12;},'OislG':_0x5188(0x24),'Iejuu':'Event\x20code\x20must\x20be\x2010\x20characters\x20or\x20less','nQiFo':function(_0x4e427f,_0x15f4f4){return _0x4e427f!==_0x15f4f4;},'YuDTz':_0x5188(0x25),'VGEhD':'Event\x20code\x20must\x20contain\x20only\x20letters\x20and\x20numbers'};if(!_0x31a3c5||!_0x31a3c5['trim']())return{'isValid':![],'error':_0x21a797[_0x5188(0x26)]};const _0x45c64b=_0x31a3c5[_0x5188(0x9)]()[_0x5188(0xb)]();if(_0x21a797[_0x5188(0x27)](_0x45c64b[_0x5188(0xf)],0x3))return{'isValid':![],'error':_0x21a797[_0x5188(0x28)]};if(_0x45c64b[_0x5188(0xf)]>0xa)return _0x21a797[_0x5188(0x29)](_0x21a797[_0x5188(0x2a)],_0x5188(0x24))?{'isValid':![],'error':_0x21a797[_0x5188(0x2b)]}:{'isValid':![],'error':_0x21a797[_0x5188(0x26)]};if(!/^[A-Z0-9]+$/[_0x5188(0x2c)](_0x45c64b))return _0x21a797[_0x5188(0x2d)](_0x5188(0x2e),_0x21a797[_0x5188(0x2f)])?{'isValid':![],'error':_0x21a797['VGEhD']}:{'isValid':![],'error':_0x21a797[_0x5188(0x28)]};return{'isValid':!![]};};export const formatEventDate=_0x3e4438=>{const _0x283daf={'RxWrh':_0x5188(0x4),'kfolg':'long','GSXhc':_0x5188(0x6)};try{const _0x40b444=new Date(_0x3e4438);return _0x40b444[_0x5188(0x1e)](_0x283daf[_0x5188(0x30)],{'weekday':_0x283daf[_0x5188(0x31)],'year':_0x283daf[_0x5188(0x32)],'month':_0x5188(0x5),'day':_0x283daf[_0x5188(0x32)]});}catch(_0x5bcc27){return _0x3e4438;}};export const isEventToday=_0x9b2985=>{const _0x22f681={'wYVgb':_0x5188(0x33),'iUKAE':function(_0x230b1c,_0x56797f){return _0x230b1c<_0x56797f;},'kcJkp':function(_0x201fb2,_0xfc40e8){return _0x201fb2*_0xfc40e8;},'VnFce':'JsTCa','HsOhG':function(_0x28cd0b,_0x55c5c1){return _0x28cd0b===_0x55c5c1;},'TnZCn':function(_0x5df828,_0x2fa923){return _0x5df828===_0x2fa923;},'uREzN':_0x5188(0x34)};try{if(_0x5188(0x35)===_0x22f681[_0x5188(0x36)]){const _0x2d3c64=new Date(),_0xf345ba=new Date(_0x9b2985);return _0x2d3c64[_0x5188(0x17)]()===_0xf345ba[_0x5188(0x17)]()&&_0x22f681[_0x5188(0x37)](_0x2d3c64['getMonth'](),_0xf345ba['getMonth']())&&_0x22f681['TnZCn'](_0x2d3c64[_0x5188(0x38)](),_0xf345ba[_0x5188(0x38)]());}else return 0x0;}catch(_0x53ea1a){if(_0x22f681[_0x5188(0x39)](_0x22f681['uREzN'],_0x22f681[_0x5188(0x3a)]))return![];else{const _0x190445=_0x22f681[_0x5188(0x3b)];let _0x49c34b='';for(let _0x8b664a=0x0;_0x22f681['iUKAE'](_0x8b664a,_0x1b17af);_0x8b664a++){_0x49c34b+=_0x190445[_0x5188(0x1)](_0x25de85[_0x5188(0x2)](_0x22f681[_0x5188(0x3c)](_0x40037f['random'](),_0x190445[_0x5188(0xf)])));}return _0x49c34b;}}};function _0x5188(_0x518821,_0x20082d){_0x518821=_0x518821-0x0;const _0x106296=_0xab99();let _0x2efa96=_0x106296[_0x518821];return _0x2efa96;}export const isEventPast=_0x232686=>{const _0x4bcff9={'qPzam':_0x5188(0x3d),'EuXgm':function(_0x904bad,_0x5129af){return _0x904bad===_0x5129af;},'IBKDK':'FobjL','qsvEG':'ZxyrV'};try{if(_0x4bcff9[_0x5188(0x3e)](_0x4bcff9['IBKDK'],_0x4bcff9[_0x5188(0x3f)]))return{'isValid':![],'error':_0x4bcff9[_0x5188(0x40)]};else{const _0x2315c9=new Date(),_0x2f77b4=new Date(_0x232686);return _0x2315c9[_0x5188(0x41)](0x0,0x0,0x0,0x0),_0x2f77b4[_0x5188(0x41)](0x0,0x0,0x0,0x0),_0x2f77b4<_0x2315c9;}}catch(_0x4d5b0f){return![];}};export const getEventStatus=(_0x7c6cbe,_0x4fd455)=>{const _0x35ed22={'TEvqF':'Inactive','vyCqJ':function(_0x5439c8,_0x3bfdb9){return _0x5439c8(_0x3bfdb9);},'bitrT':_0x5188(0x42),'UEBGt':function(_0x37c037,_0x589659){return _0x37c037(_0x589659);},'SeKve':_0x5188(0x43)};if(!_0x4fd455)return _0x35ed22['TEvqF'];if(_0x35ed22['vyCqJ'](isEventPast,_0x7c6cbe))return _0x35ed22[_0x5188(0x44)];if(_0x35ed22[_0x5188(0x45)](isEventToday,_0x7c6cbe))return _0x5188(0x46);return _0x35ed22[_0x5188(0x47)];};export const getDaysUntilEvent=_0x24cae=>{const _0x569826={'lIBbx':function(_0x55cb59,_0x3eb4b7){return _0x55cb59-_0x3eb4b7;},'xkCBB':function(_0x18c13e,_0x470e8b){return _0x18c13e/_0x470e8b;},'ujGvG':function(_0x44c43a,_0x34d794){return _0x44c43a*_0x34d794;}};try{const _0xfa7bd5=new Date(),_0x299cb8=new Date(_0x24cae);_0xfa7bd5[_0x5188(0x41)](0x0,0x0,0x0,0x0),_0x299cb8['setHours'](0x0,0x0,0x0,0x0);const _0x1516f3=_0x569826[_0x5188(0x48)](_0x299cb8[_0x5188(0x49)](),_0xfa7bd5[_0x5188(0x49)]()),_0x39a7da=Math[_0x5188(0x4a)](_0x569826[_0x5188(0x4b)](_0x1516f3,_0x569826[_0x5188(0x4c)](0x3e8*0x3c,0x3c)*0x18));return _0x39a7da;}catch(_0x62907b){return 0x0;}};export const sortEventsByDate=_0x28dcf0=>{const _0x22ca94={'FMpez':function(_0x108869,_0x442f41){return _0x108869<_0x442f41;},'PNhyw':function(_0x4124f3,_0x3574d9){return _0x4124f3===_0x3574d9;},'OwCwe':_0x5188(0x4d),'jsScI':'fMzWx','Nesab':function(_0x17098f,_0x2a51a4){return _0x17098f<_0x2a51a4;},'zRERP':function(_0x201274,_0x11a372){return _0x201274<_0x11a372;},'fyRTU':function(_0x103b1f,_0x2ae1d3){return _0x103b1f&&_0x2ae1d3;},'QczOC':function(_0x5c91c7,_0x332202){return _0x5c91c7&&_0x332202;},'OYehN':function(_0x3ba550,_0x34c0a3){return _0x3ba550-_0x34c0a3;},'nRVpw':function(_0x7987de,_0x4add66){return _0x7987de!==_0x4add66;},'kMXOT':'mMaIE','LmgEq':function(_0x4a4d76,_0x18fb02){return _0x4a4d76-_0x18fb02;}};return _0x28dcf0[_0x5188(0x4e)]((_0x94f9f4,_0x568379)=>{const _0x219ade={'XaQmM':function(_0xdde3ca,_0x18e6e4){return _0xdde3ca===_0x18e6e4;},'cWvxK':function(_0x5b1976,_0x50a76a){return _0x5b1976===_0x50a76a;}};if(_0x22ca94['PNhyw'](_0x22ca94[_0x5188(0x4f)],_0x22ca94[_0x5188(0x50)]))try{const _0x13d62d=new _0x9204cb(),_0x3eefa6=new _0x48017f(_0x1f4fe0);return _0x219ade[_0x5188(0x51)](_0x13d62d[_0x5188(0x17)](),_0x3eefa6[_0x5188(0x17)]())&&_0x219ade[_0x5188(0x52)](_0x13d62d['getMonth'](),_0x3eefa6['getMonth']())&&_0x219ade[_0x5188(0x52)](_0x13d62d[_0x5188(0x38)](),_0x3eefa6[_0x5188(0x38)]());}catch(_0x442c88){return![];}else{if(_0x94f9f4[_0x5188(0x53)]&&!_0x568379[_0x5188(0x53)])return-0x1;if(!_0x94f9f4['isActive']&&_0x568379[_0x5188(0x53)])return 0x1;const _0x54dc88=new Date(_0x94f9f4[_0x5188(0x54)]),_0x1cbe9d=new Date(_0x568379[_0x5188(0x54)]),_0x11cb60=new Date(),_0x36fb04=_0x22ca94['Nesab'](_0x54dc88,_0x11cb60),_0x5da64c=_0x22ca94[_0x5188(0x55)](_0x1cbe9d,_0x11cb60);if(_0x22ca94['fyRTU'](_0x36fb04,!_0x5da64c))return 0x1;if(_0x22ca94[_0x5188(0x56)](!_0x36fb04,_0x5da64c))return-0x1;if(_0x22ca94[_0x5188(0x56)](_0x36fb04,_0x5da64c))return _0x22ca94['OYehN'](_0x1cbe9d[_0x5188(0x49)](),_0x54dc88[_0x5188(0x49)]());else{if(_0x22ca94[_0x5188(0x57)](_0x5188(0x58),_0x22ca94['kMXOT']))return _0x22ca94[_0x5188(0x59)](_0x54dc88[_0x5188(0x49)](),_0x1cbe9d['getTime']());else try{const _0x4d9711=new _0x2f9150(),_0x4b759f=new _0x2d9d26(_0x27b9a4);return _0x4d9711[_0x5188(0x41)](0x0,0x0,0x0,0x0),_0x4b759f[_0x5188(0x41)](0x0,0x0,0x0,0x0),_0x22ca94['FMpez'](_0x4b759f,_0x4d9711);}catch(_0x5ef0d3){return![];}}}});};export const filterEventsBySearch=(_0x34c482,_0x19adcf)=>{const _0x4ead88={'AsOMC':'Inactive','GSiNR':function(_0xfe91d8,_0x103d54){return _0xfe91d8(_0x103d54);},'WLKkh':_0x5188(0x43),'TFckA':function(_0x289cf9,_0x20616d){return _0x289cf9===_0x20616d;},'hJXxQ':function(_0x869b2c,_0x652029){return _0x869b2c===_0x652029;},'qyXHX':function(_0x51f411,_0x3ddcaf){return _0x51f411===_0x3ddcaf;},'DCZoP':function(_0x15837a,_0x166394){return _0x15837a!==_0x166394;},'LrLZo':'hZuNZ'};if(!_0x19adcf['trim']()){if(_0x4ead88[_0x5188(0x5a)](_0x5188(0x5b),_0x4ead88['LrLZo']))return _0x34c482;else{if(!_0x202f57)return _0x4ead88['AsOMC'];if(_0x4ead88[_0x5188(0x5c)](_0x3e9742,_0x363698))return _0x5188(0x42);if(_0x1fa913(_0x1a72e2))return _0x5188(0x46);return _0x4ead88[_0x5188(0x5d)];}}const _0x552ad1=_0x19adcf['toLowerCase']()[_0x5188(0x9)]();return _0x34c482['filter'](_0x4e7c7a=>{var _0x4fc5f5,_0x51b10e,_0x550751;return _0x4e7c7a['title'][_0x5188(0x5e)]()[_0x5188(0x5f)](_0x552ad1)||_0x4e7c7a[_0x5188(0x60)][_0x5188(0x5e)]()[_0x5188(0x5f)](_0x552ad1)||_0x4e7c7a[_0x5188(0x61)][_0x5188(0x5e)]()[_0x5188(0x5f)](_0x552ad1)||(_0x4ead88[_0x5188(0x62)](_0x4fc5f5=_0x4e7c7a[_0x5188(0x63)],null)||_0x4ead88[_0x5188(0x62)](_0x4fc5f5,void 0x0)?void 0x0:_0x4fc5f5['toLowerCase']()[_0x5188(0x5f)](_0x552ad1))||(_0x4ead88[_0x5188(0x64)](_0x51b10e=_0x4e7c7a[_0x5188(0x65)],null)||_0x51b10e===void 0x0?void 0x0:_0x51b10e['toLowerCase']()['includes'](_0x552ad1))||((_0x550751=_0x4e7c7a[_0x5188(0x66)])===null||_0x4ead88[_0x5188(0x67)](_0x550751,void 0x0)?void 0x0:_0x550751['some'](_0x139876=>_0x139876[_0x5188(0x5e)]()[_0x5188(0x5f)](_0x552ad1)));});};export const getUniqueEventTags=_0xbbec9f=>{const _0x32abec=_0xbbec9f['flatMap'](_0x35dfc6=>_0x35dfc6[_0x5188(0x66)]||[]);return Array['from'](new Set(_0x32abec))[_0x5188(0x4e)]();};export const calculateEventStats=_0x487d9b=>{const _0x4204ab={'ZjfsG':function(_0x3b74c2,_0x4884b2){return _0x3b74c2-_0x4884b2;},'GwoYN':function(_0x138bba,_0x20fad6){return _0x138bba>_0x20fad6;},'hODrH':function(_0x1cd469,_0x1f750f){return _0x1cd469*_0x1f750f;},'rRUZj':function(_0x128ab4,_0x45cfcb){return _0x128ab4/_0x45cfcb;}},_0x5f255d=_0x487d9b[_0x5188(0xf)],_0x57166e=_0x487d9b[_0x5188(0xe)](_0x515cec=>_0x515cec['isActive'])[_0x5188(0xf)],_0x574c31=_0x4204ab[_0x5188(0x68)](_0x5f255d,_0x57166e),_0x26e3e4=_0x487d9b[_0x5188(0x69)]((_0x5358f9,_0x5565a9)=>_0x5358f9+_0x5565a9[_0x5188(0x6a)],0x0),_0x209f41=_0x487d9b[_0x5188(0x69)]((_0x3793dc,_0x1b6219)=>_0x3793dc+_0x1b6219['maxAttendees'],0x0),_0x4efe29=_0x487d9b[_0x5188(0xe)](_0x419f64=>_0x419f64[_0x5188(0x53)]&&!isEventPast(_0x419f64[_0x5188(0x54)]))['length'],_0x383eb=_0x487d9b[_0x5188(0xe)](_0x35fd22=>isEventPast(_0x35fd22[_0x5188(0x54)]))[_0x5188(0xf)],_0x1beb48=_0x487d9b['filter'](_0x489adf=>_0x489adf['isActive']&&isEventToday(_0x489adf[_0x5188(0x54)]))['length'];return{'total':_0x5f255d,'active':_0x57166e,'inactive':_0x574c31,'upcoming':_0x4efe29,'past':_0x383eb,'today':_0x1beb48,'totalAttendees':_0x26e3e4,'totalCapacity':_0x209f41,'averageAttendance':_0x4204ab[_0x5188(0x6b)](_0x209f41,0x0)?Math[_0x5188(0x6c)](_0x4204ab['hODrH'](_0x4204ab[_0x5188(0x6d)](_0x26e3e4,_0x209f41),0x64)):0x0};};
|
|
1
|
+
/**
|
|
2
|
+
* Event utility functions for event management
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate a random alphanumeric event code
|
|
7
|
+
* @param length - Length of the code (default: 6)
|
|
8
|
+
* @returns Random event code
|
|
9
|
+
*/
|
|
10
|
+
export const generateEventCode = (length = 6) => {
|
|
11
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
12
|
+
let result = '';
|
|
13
|
+
for (let i = 0; i < length; i++) {
|
|
14
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generate a smart event code based on the event title
|
|
21
|
+
* @param title - Event title
|
|
22
|
+
* @returns Smart event code
|
|
23
|
+
*/
|
|
24
|
+
export const generateSmartEventCode = title => {
|
|
25
|
+
if (!title.trim()) {
|
|
26
|
+
return generateEventCode();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Clean the title and split into words
|
|
30
|
+
const words = title.trim().toUpperCase().replace(/[^A-Z0-9\s]/g, '') // Remove special characters
|
|
31
|
+
.split(/\s+/).filter(word => word.length > 0);
|
|
32
|
+
if (words.length === 0) {
|
|
33
|
+
return generateEventCode();
|
|
34
|
+
}
|
|
35
|
+
let code = '';
|
|
36
|
+
|
|
37
|
+
// Strategy 1: Take first 2 letters of each word (up to 3 words)
|
|
38
|
+
if (words.length >= 2) {
|
|
39
|
+
const significantWords = words.slice(0, 3);
|
|
40
|
+
code = significantWords.map(word => word.substring(0, 2)).join('');
|
|
41
|
+
} else {
|
|
42
|
+
// Strategy 2: Single word - take first 4 letters
|
|
43
|
+
code = words[0].substring(0, 4);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Add current year's last 2 digits
|
|
47
|
+
const currentYear = new Date().getFullYear().toString().slice(-2);
|
|
48
|
+
code += currentYear;
|
|
49
|
+
|
|
50
|
+
// Ensure minimum length of 4 and maximum of 8
|
|
51
|
+
if (code.length < 4) {
|
|
52
|
+
code += generateEventCode(4 - code.length);
|
|
53
|
+
} else if (code.length > 8) {
|
|
54
|
+
code = code.substring(0, 8);
|
|
55
|
+
}
|
|
56
|
+
return code;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Validate event code format
|
|
61
|
+
* @param code - Event code to validate
|
|
62
|
+
* @returns Object with validation result and error message
|
|
63
|
+
*/
|
|
64
|
+
export const validateEventCode = code => {
|
|
65
|
+
if (!code || !code.trim()) {
|
|
66
|
+
return {
|
|
67
|
+
isValid: false,
|
|
68
|
+
error: 'Event code is required'
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const trimmedCode = code.trim().toUpperCase();
|
|
72
|
+
if (trimmedCode.length < 3) {
|
|
73
|
+
return {
|
|
74
|
+
isValid: false,
|
|
75
|
+
error: 'Event code must be at least 3 characters'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (trimmedCode.length > 10) {
|
|
79
|
+
return {
|
|
80
|
+
isValid: false,
|
|
81
|
+
error: 'Event code must be 10 characters or less'
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (!/^[A-Z0-9]+$/.test(trimmedCode)) {
|
|
85
|
+
return {
|
|
86
|
+
isValid: false,
|
|
87
|
+
error: 'Event code must contain only letters and numbers'
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
isValid: true
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Format event date for display
|
|
97
|
+
* @param dateString - Date string in YYYY-MM-DD format
|
|
98
|
+
* @returns Formatted date string
|
|
99
|
+
*/
|
|
100
|
+
export const formatEventDate = dateString => {
|
|
101
|
+
try {
|
|
102
|
+
const date = new Date(dateString);
|
|
103
|
+
return date.toLocaleDateString('en-US', {
|
|
104
|
+
weekday: 'long',
|
|
105
|
+
year: 'numeric',
|
|
106
|
+
month: 'long',
|
|
107
|
+
day: 'numeric'
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
return dateString;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Check if an event is happening today
|
|
116
|
+
* @param eventDate - Event date string
|
|
117
|
+
* @returns True if event is today
|
|
118
|
+
*/
|
|
119
|
+
export const isEventToday = eventDate => {
|
|
120
|
+
try {
|
|
121
|
+
const today = new Date();
|
|
122
|
+
const event = new Date(eventDate);
|
|
123
|
+
return today.getFullYear() === event.getFullYear() && today.getMonth() === event.getMonth() && today.getDate() === event.getDate();
|
|
124
|
+
} catch (error) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Check if an event is in the past
|
|
131
|
+
* @param eventDate - Event date string
|
|
132
|
+
* @returns True if event is in the past
|
|
133
|
+
*/
|
|
134
|
+
export const isEventPast = eventDate => {
|
|
135
|
+
try {
|
|
136
|
+
const today = new Date();
|
|
137
|
+
const event = new Date(eventDate);
|
|
138
|
+
|
|
139
|
+
// Set time to start of day for accurate comparison
|
|
140
|
+
today.setHours(0, 0, 0, 0);
|
|
141
|
+
event.setHours(0, 0, 0, 0);
|
|
142
|
+
return event < today;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Get event status based on date and active status
|
|
150
|
+
* @param eventDate - Event date string
|
|
151
|
+
* @param isActive - Whether event is active
|
|
152
|
+
* @returns Event status string
|
|
153
|
+
*/
|
|
154
|
+
export const getEventStatus = (eventDate, isActive) => {
|
|
155
|
+
if (!isActive) {
|
|
156
|
+
return 'Inactive';
|
|
157
|
+
}
|
|
158
|
+
if (isEventPast(eventDate)) {
|
|
159
|
+
return 'Past';
|
|
160
|
+
}
|
|
161
|
+
if (isEventToday(eventDate)) {
|
|
162
|
+
return 'Today';
|
|
163
|
+
}
|
|
164
|
+
return 'Upcoming';
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Calculate days until event
|
|
169
|
+
* @param eventDate - Event date string
|
|
170
|
+
* @returns Number of days until event (negative if past)
|
|
171
|
+
*/
|
|
172
|
+
export const getDaysUntilEvent = eventDate => {
|
|
173
|
+
try {
|
|
174
|
+
const today = new Date();
|
|
175
|
+
const event = new Date(eventDate);
|
|
176
|
+
|
|
177
|
+
// Set time to start of day for accurate comparison
|
|
178
|
+
today.setHours(0, 0, 0, 0);
|
|
179
|
+
event.setHours(0, 0, 0, 0);
|
|
180
|
+
const diffTime = event.getTime() - today.getTime();
|
|
181
|
+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
182
|
+
return diffDays;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Sort events by date (upcoming first, then past events)
|
|
190
|
+
* @param events - Array of events
|
|
191
|
+
* @returns Sorted array of events
|
|
192
|
+
*/
|
|
193
|
+
export const sortEventsByDate = events => {
|
|
194
|
+
return events.sort((a, b) => {
|
|
195
|
+
// Active events first
|
|
196
|
+
if (a.isActive && !b.isActive) return -1;
|
|
197
|
+
if (!a.isActive && b.isActive) return 1;
|
|
198
|
+
|
|
199
|
+
// Then sort by date
|
|
200
|
+
const dateA = new Date(a.eventDate);
|
|
201
|
+
const dateB = new Date(b.eventDate);
|
|
202
|
+
|
|
203
|
+
// Upcoming events first (ascending), then past events (descending)
|
|
204
|
+
const today = new Date();
|
|
205
|
+
const aIsPast = dateA < today;
|
|
206
|
+
const bIsPast = dateB < today;
|
|
207
|
+
if (aIsPast && !bIsPast) return 1;
|
|
208
|
+
if (!aIsPast && bIsPast) return -1;
|
|
209
|
+
if (aIsPast && bIsPast) {
|
|
210
|
+
return dateB.getTime() - dateA.getTime(); // Past events: most recent first
|
|
211
|
+
} else {
|
|
212
|
+
return dateA.getTime() - dateB.getTime(); // Upcoming events: soonest first
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Filter events by search query
|
|
219
|
+
* @param events - Array of events
|
|
220
|
+
* @param query - Search query
|
|
221
|
+
* @returns Filtered array of events
|
|
222
|
+
*/
|
|
223
|
+
export const filterEventsBySearch = (events, query) => {
|
|
224
|
+
if (!query.trim()) {
|
|
225
|
+
return events;
|
|
226
|
+
}
|
|
227
|
+
const searchTerm = query.toLowerCase().trim();
|
|
228
|
+
return events.filter(event => {
|
|
229
|
+
var _event$location, _event$organizer, _event$tags;
|
|
230
|
+
return event.title.toLowerCase().includes(searchTerm) || event.description.toLowerCase().includes(searchTerm) || event.code.toLowerCase().includes(searchTerm) || ((_event$location = event.location) === null || _event$location === void 0 ? void 0 : _event$location.toLowerCase().includes(searchTerm)) || ((_event$organizer = event.organizer) === null || _event$organizer === void 0 ? void 0 : _event$organizer.toLowerCase().includes(searchTerm)) || ((_event$tags = event.tags) === null || _event$tags === void 0 ? void 0 : _event$tags.some(tag => tag.toLowerCase().includes(searchTerm)));
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get unique tags from events
|
|
236
|
+
* @param events - Array of events
|
|
237
|
+
* @returns Array of unique tags
|
|
238
|
+
*/
|
|
239
|
+
export const getUniqueEventTags = events => {
|
|
240
|
+
const allTags = events.flatMap(event => event.tags || []);
|
|
241
|
+
return Array.from(new Set(allTags)).sort();
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Calculate event statistics
|
|
246
|
+
* @param events - Array of events
|
|
247
|
+
* @returns Event statistics object
|
|
248
|
+
*/
|
|
249
|
+
export const calculateEventStats = events => {
|
|
250
|
+
const total = events.length;
|
|
251
|
+
const active = events.filter(e => e.isActive).length;
|
|
252
|
+
const inactive = total - active;
|
|
253
|
+
const totalAttendees = events.reduce((sum, e) => sum + e.attendeeCount, 0);
|
|
254
|
+
const totalCapacity = events.reduce((sum, e) => sum + e.maxAttendees, 0);
|
|
255
|
+
const upcoming = events.filter(e => e.isActive && !isEventPast(e.eventDate)).length;
|
|
256
|
+
const past = events.filter(e => isEventPast(e.eventDate)).length;
|
|
257
|
+
const today = events.filter(e => e.isActive && isEventToday(e.eventDate)).length;
|
|
258
|
+
return {
|
|
259
|
+
total,
|
|
260
|
+
active,
|
|
261
|
+
inactive,
|
|
262
|
+
upcoming,
|
|
263
|
+
past,
|
|
264
|
+
today,
|
|
265
|
+
totalAttendees,
|
|
266
|
+
totalCapacity,
|
|
267
|
+
averageAttendance: totalCapacity > 0 ? Math.round(totalAttendees / totalCapacity * 100) : 0
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
//# sourceMappingURL=eventUtils.js.map
|
|
@@ -1,8 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
];
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
export let HapticType = /*#__PURE__*/function (HapticType) {
|
|
3
|
+
HapticType["LIGHT"] = "light";
|
|
4
|
+
HapticType["MEDIUM"] = "medium";
|
|
5
|
+
HapticType["HEAVY"] = "heavy";
|
|
6
|
+
HapticType["SUCCESS"] = "success";
|
|
7
|
+
HapticType["WARNING"] = "warning";
|
|
8
|
+
HapticType["ERROR"] = "error";
|
|
9
|
+
HapticType["BUTTON_PRESS"] = "light"; // Alias for button presses
|
|
10
|
+
return HapticType;
|
|
11
|
+
}({});
|
|
12
|
+
export const triggerHaptic = (type = HapticType.LIGHT) => {
|
|
13
|
+
if (Platform.OS === 'ios') {
|
|
14
|
+
try {
|
|
15
|
+
// Try to use react-native-haptic-feedback if available
|
|
16
|
+
const ReactNativeHapticFeedback = require('react-native-haptic-feedback');
|
|
17
|
+
const options = {
|
|
18
|
+
enableVibrateFallback: true,
|
|
19
|
+
ignoreAndroidSystemSettings: false
|
|
20
|
+
};
|
|
21
|
+
switch (type) {
|
|
22
|
+
case HapticType.LIGHT:
|
|
23
|
+
ReactNativeHapticFeedback.trigger('impactLight', options);
|
|
24
|
+
break;
|
|
25
|
+
case HapticType.MEDIUM:
|
|
26
|
+
ReactNativeHapticFeedback.trigger('impactMedium', options);
|
|
27
|
+
break;
|
|
28
|
+
case HapticType.HEAVY:
|
|
29
|
+
ReactNativeHapticFeedback.trigger('impactHeavy', options);
|
|
30
|
+
break;
|
|
31
|
+
case HapticType.SUCCESS:
|
|
32
|
+
ReactNativeHapticFeedback.trigger('notificationSuccess', options);
|
|
33
|
+
break;
|
|
34
|
+
case HapticType.WARNING:
|
|
35
|
+
ReactNativeHapticFeedback.trigger('notificationWarning', options);
|
|
36
|
+
break;
|
|
37
|
+
case HapticType.ERROR:
|
|
38
|
+
ReactNativeHapticFeedback.trigger('notificationError', options);
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
ReactNativeHapticFeedback.trigger('impactLight', options);
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// Fallback to basic vibration if haptic feedback is not available
|
|
45
|
+
console.warn('Haptic feedback not available:', error);
|
|
46
|
+
}
|
|
47
|
+
} else if (Platform.OS === 'android') {
|
|
48
|
+
// Android fallback - basic vibration
|
|
49
|
+
try {
|
|
50
|
+
const {
|
|
51
|
+
Vibration
|
|
52
|
+
} = require('react-native');
|
|
53
|
+
Vibration.vibrate(50);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.warn('Vibration not available:', error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=haptics.js.map
|