@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.
Files changed (237) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/components/BodyText.js +27 -9
  3. package/lib/commonjs/components/BrandMark.js +111 -10
  4. package/lib/commonjs/components/CodeInput.js +116 -9
  5. package/lib/commonjs/components/EmailInput.js +30 -8
  6. package/lib/commonjs/components/GoogleButton.js +56 -9
  7. package/lib/commonjs/components/HeadingGroup.js +43 -9
  8. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  9. package/lib/commonjs/components/ModalHeader.js +99 -9
  10. package/lib/commonjs/components/ModalSheet.js +47 -9
  11. package/lib/commonjs/components/Onairos.js +380 -14
  12. package/lib/commonjs/components/OnairosButton.js +313 -13
  13. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  14. package/lib/commonjs/components/Overlay.js +465 -13
  15. package/lib/commonjs/components/PersonaImage.js +137 -10
  16. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  17. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  18. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  19. package/lib/commonjs/components/PinInput.js +464 -9
  20. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  21. package/lib/commonjs/components/PlatformList.js +137 -10
  22. package/lib/commonjs/components/PlatformToggle.js +180 -9
  23. package/lib/commonjs/components/PrimaryButton.js +180 -10
  24. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  25. package/lib/commonjs/components/SignInStep.js +345 -12
  26. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  27. package/lib/commonjs/components/VerificationStep.js +176 -11
  28. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  29. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  30. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  31. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  32. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  33. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  34. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  35. package/lib/commonjs/components/icons/EnochE.js +41 -8
  36. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  37. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  38. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  39. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  40. package/lib/commonjs/components/icons/index.js +84 -17
  41. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  42. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  43. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  44. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  45. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  46. package/lib/commonjs/config/api.js +56 -7
  47. package/lib/commonjs/constants/index.js +120 -7
  48. package/lib/commonjs/context/AuthContext.js +345 -10
  49. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  50. package/lib/commonjs/hooks/useConnections.js +102 -8
  51. package/lib/commonjs/hooks/useCredentials.js +178 -10
  52. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  53. package/lib/commonjs/index.js +439 -34
  54. package/lib/commonjs/services/apiClient.js +298 -8
  55. package/lib/commonjs/services/biometricPinService.js +180 -8
  56. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  57. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  58. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  59. package/lib/commonjs/services/claudeConversationService.js +158 -9
  60. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  61. package/lib/commonjs/services/googleAuthService.js +252 -11
  62. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  63. package/lib/commonjs/services/hingeDataService.js +150 -9
  64. package/lib/commonjs/services/imageCompressionService.js +260 -7
  65. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  66. package/lib/commonjs/services/instagramDataService.js +163 -9
  67. package/lib/commonjs/services/jwtStorageService.js +276 -7
  68. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  69. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  70. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  71. package/lib/commonjs/services/llmDataStorage.js +294 -8
  72. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  73. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  74. package/lib/commonjs/services/netflixDataService.js +198 -9
  75. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  76. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  77. package/lib/commonjs/services/platformAuthService.js +1484 -12
  78. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  79. package/lib/commonjs/services/sephoraDataService.js +200 -9
  80. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  81. package/lib/commonjs/services/spotifyDataService.js +241 -9
  82. package/lib/commonjs/services/storageService.js +404 -8
  83. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  84. package/lib/commonjs/services/telegramDataService.js +499 -9
  85. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  86. package/lib/commonjs/services/userConnectionsService.js +340 -10
  87. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  88. package/lib/commonjs/theme/index.js +250 -7
  89. package/lib/commonjs/types/ambient.d.js +2 -1
  90. package/lib/commonjs/types/declarations.d.js +2 -1
  91. package/lib/commonjs/types/index.js +6 -1
  92. package/lib/commonjs/types/node-fix.d.js +2 -1
  93. package/lib/commonjs/types/node-override.d.js +2 -1
  94. package/lib/commonjs/types/opacity.d.js +2 -1
  95. package/lib/commonjs/types.js +14 -1
  96. package/lib/commonjs/utils/Portal.js +98 -8
  97. package/lib/commonjs/utils/api.js +130 -9
  98. package/lib/commonjs/utils/assetRegistry.js +210 -35
  99. package/lib/commonjs/utils/auth.js +112 -9
  100. package/lib/commonjs/utils/connectorTests.js +613 -29
  101. package/lib/commonjs/utils/crypto.js +62 -8
  102. package/lib/commonjs/utils/debugHelper.js +64 -1
  103. package/lib/commonjs/utils/encryption.js +76 -7
  104. package/lib/commonjs/utils/eventUtils.js +288 -1
  105. package/lib/commonjs/utils/haptics.js +66 -9
  106. package/lib/commonjs/utils/imagePreloader.js +6 -1
  107. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  108. package/lib/commonjs/utils/onairosApi.js +350 -9
  109. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  110. package/lib/commonjs/utils/retryHelper.js +220 -1
  111. package/lib/commonjs/utils/secureStorage.js +349 -10
  112. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  113. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  114. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  115. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  116. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  117. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  118. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  119. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  120. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  121. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  122. package/lib/module/api/index.js +211 -1
  123. package/lib/module/components/BodyText.js +20 -1
  124. package/lib/module/components/BrandMark.js +104 -1
  125. package/lib/module/components/CodeInput.js +109 -1
  126. package/lib/module/components/EmailInput.js +23 -1
  127. package/lib/module/components/GoogleButton.js +49 -1
  128. package/lib/module/components/HeadingGroup.js +36 -1
  129. package/lib/module/components/LLMDataInputModal.js +656 -7
  130. package/lib/module/components/ModalHeader.js +92 -1
  131. package/lib/module/components/ModalSheet.js +39 -1
  132. package/lib/module/components/Onairos.js +373 -1
  133. package/lib/module/components/OnairosButton.js +305 -1
  134. package/lib/module/components/OnairosSignInButton.js +121 -1
  135. package/lib/module/components/Overlay.js +456 -1
  136. package/lib/module/components/PersonaImage.js +129 -1
  137. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  138. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  139. package/lib/module/components/PinCreationScreen.js +396 -1
  140. package/lib/module/components/PinInput.js +456 -1
  141. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  142. package/lib/module/components/PlatformList.js +129 -1
  143. package/lib/module/components/PlatformToggle.js +173 -1
  144. package/lib/module/components/PrimaryButton.js +172 -1
  145. package/lib/module/components/SignInMatchAnimation.js +189 -1
  146. package/lib/module/components/SignInStep.js +338 -1
  147. package/lib/module/components/UniversalOnboarding.js +2770 -1
  148. package/lib/module/components/VerificationStep.js +168 -1
  149. package/lib/module/components/WelcomeScreen.js +453 -1
  150. package/lib/module/components/icons/Basicproficon.js +30 -1
  151. package/lib/module/components/icons/Basicprofile.js +14 -1
  152. package/lib/module/components/icons/Checkbox.js +14 -1
  153. package/lib/module/components/icons/Checkmark.js +20 -1
  154. package/lib/module/components/icons/Contentanalysis.js +14 -1
  155. package/lib/module/components/icons/Contenticon.js +32 -1
  156. package/lib/module/components/icons/EnochE.js +34 -1
  157. package/lib/module/components/icons/Personalityicon.js +23 -1
  158. package/lib/module/components/icons/Personalityprofile.js +14 -1
  159. package/lib/module/components/icons/Personalitytraits.js +14 -1
  160. package/lib/module/components/icons/Userpreferences.js +14 -1
  161. package/lib/module/components/icons/index.js +13 -1
  162. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  163. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  164. package/lib/module/components/onboarding/PinInput.js +274 -1
  165. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  166. package/lib/module/config/PLATFORM_APIS.md +849 -0
  167. package/lib/module/config/api.js +47 -1
  168. package/lib/module/constants/index.js +114 -1
  169. package/lib/module/context/AuthContext.js +335 -1
  170. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  171. package/lib/module/hooks/useConnections.js +95 -1
  172. package/lib/module/hooks/useCredentials.js +171 -6
  173. package/lib/module/hooks/useUserConnections.js +140 -1
  174. package/lib/module/index.js +172 -1
  175. package/lib/module/services/apiClient.js +295 -1
  176. package/lib/module/services/biometricPinService.js +169 -1
  177. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  178. package/lib/module/services/chatGPTConversationService.js +268 -1
  179. package/lib/module/services/claudeConversationExtractor.js +97 -1
  180. package/lib/module/services/claudeConversationService.js +151 -1
  181. package/lib/module/services/connectedAccountsService.js +293 -1
  182. package/lib/module/services/googleAuthService.js +241 -1
  183. package/lib/module/services/hingeDataExtractor.js +99 -1
  184. package/lib/module/services/hingeDataService.js +143 -1
  185. package/lib/module/services/imageCompressionService.js +250 -1
  186. package/lib/module/services/instagramDataExtractor.js +120 -1
  187. package/lib/module/services/instagramDataService.js +156 -1
  188. package/lib/module/services/jwtStorageService.js +257 -1
  189. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  190. package/lib/module/services/linkedinProfileService.js +210 -1
  191. package/lib/module/services/linkedinScrapingService.js +219 -1
  192. package/lib/module/services/llmDataStorage.js +277 -1
  193. package/lib/module/services/mobileTrainingService.js +173 -1
  194. package/lib/module/services/netflixDataExtractor.js +114 -1
  195. package/lib/module/services/netflixDataService.js +191 -1
  196. package/lib/module/services/pinEncryptionService.js +74 -6
  197. package/lib/module/services/pinStorageUtils.js +93 -1
  198. package/lib/module/services/platformAuthService.js +1461 -1
  199. package/lib/module/services/sephoraDataExtractor.js +134 -1
  200. package/lib/module/services/sephoraDataService.js +193 -1
  201. package/lib/module/services/spotifyDataExtractor.js +142 -1
  202. package/lib/module/services/spotifyDataService.js +234 -1
  203. package/lib/module/services/storageService.js +383 -1
  204. package/lib/module/services/telegramDataExtractor.js +109 -1
  205. package/lib/module/services/telegramDataService.js +493 -1
  206. package/lib/module/services/trainingApiHelpers.js +67 -1
  207. package/lib/module/services/userConnectionsService.js +329 -1
  208. package/lib/module/services/youtubeMigrationService.js +405 -1
  209. package/lib/module/theme/index.js +245 -1
  210. package/lib/module/types.js +10 -1
  211. package/lib/module/utils/Portal.js +90 -1
  212. package/lib/module/utils/api.js +118 -1
  213. package/lib/module/utils/assetRegistry.js +200 -34
  214. package/lib/module/utils/auth.js +100 -1
  215. package/lib/module/utils/connectorTests.js +600 -27
  216. package/lib/module/utils/crypto.js +54 -1
  217. package/lib/module/utils/debugHelper.js +54 -1
  218. package/lib/module/utils/encryption.js +67 -1
  219. package/lib/module/utils/eventUtils.js +270 -1
  220. package/lib/module/utils/haptics.js +59 -8
  221. package/lib/module/utils/imagePreloader.js +3 -1
  222. package/lib/module/utils/networkDiagnostics.js +217 -1
  223. package/lib/module/utils/onairosApi.js +333 -1
  224. package/lib/module/utils/programmaticFlow.js +111 -1
  225. package/lib/module/utils/retryHelper.js +211 -1
  226. package/lib/module/utils/secureStorage.js +330 -6
  227. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  228. package/lib/module/utils/webviewScripts/claude.js +370 -1
  229. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  230. package/lib/module/utils/webviewScripts/index.js +434 -1
  231. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  232. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  233. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  234. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  235. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  236. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  237. package/package.json +2 -2
@@ -1,7 +1,260 @@
1
- 'use strict';
2
- // Onairos SDK - Asset Registry (auto-generated)
3
- var __ONAIROS_REQ_REGISTRY__ = [
4
- require("@bam.tech/react-native-image-resizer")
5
- ];
6
- function __ONAIROS_REQ_FUNC__(i) { return __ONAIROS_REQ_REGISTRY__[i]; }
7
- function _0xc57e(_0x1ab69f,_0xc57edf){_0x1ab69f=_0x1ab69f-0x0;const _0x17e9d3=_0x1ab6();let _0x485623=_0x17e9d3[_0x1ab69f];return _0x485623;}Object['defineProperty'](exports,_0xc57e(0x0),{'value':!![]}),exports['convertImageToOptimizedBase64']=exports[_0xc57e(0x1)]=exports[_0xc57e(0x2)]=exports[_0xc57e(0x3)]=void 0x0;var _reactNativeImageResizer=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x0));function _0x1ab6(){const _0x45afde=['__esModule','compressProfilePicture','compressImageToTarget','compressForUpload','Error\x20getting\x20file\x20size:','size','xSygl','blALU','YXmSF','blob','onloadend','split','DPSsV','onerror','readAsDataURL','OoiDD','dRMgr','error','Error\x20converting\x20image\x20to\x20base64:','APWAW','📤\x20[COMPRESSION]\x20Final\x20result\x20(best\x20effort):','ffHzk','📊\x20[COMPRESSION]\x20Original\x20size:','✅\x20[COMPRESSION]\x20Image\x20already\x20under\x20target\x20size','GwEeR','Ihosi','contain','hZkxO','vcohB','❌\x20[COMPRESSION]\x20Compression\x20service\x20error:','MPGUi','HDbVH','gZenG','round','RxdgL','BptCd','log','kDFJN','lWLBK','MFQjd','etEch','🎯\x20[COMPRESSION]\x20Success:','BXehq','IIArg',':\x20quality=',',\x20size=','AJgQg','SaJyf','default','createResizedImage','sItMx','yYECZ','LCarY','uri','📊\x20[COMPRESSION]\x20Attempt\x20','\x20result:\x20','\x20KB','toFixed','bjsLn','gUZvA','oeaTR','max','result','gRkOu','TmQBc','❌\x20[COMPRESSION]\x20Resize\x20attempt\x20','\x20failed:','YYFwa','TstUv','ybhyH','CNsrg','fMneX','gzors','tYPRZ','JAOYo','EyigR','LUPNx','KB\x20after\x20','\x20attempts','YcHDb','YYqJw','message','Unknown\x20compression\x20error','JPEG','vPOcf','SqXpY','AXybR','PVhpd','RSCen','success','base64','convertImageToOptimizedBase64'];_0x1ab6=function(){return _0x45afde;};return _0x1ab6();}function _interopRequireDefault(_0x489341){return _0x489341&&_0x489341[_0xc57e(0x0)]?_0x489341:{'default':_0x489341};}const getFileSizeFromUri=async _0x44c4cb=>{const _0x5b2de9={'xSygl':_0xc57e(0x4)};try{const _0x37ccbf=await fetch(_0x44c4cb),_0x4f8116=await _0x37ccbf['blob']();return _0x4f8116[_0xc57e(0x5)];}catch(_0x3097ed){return console['error'](_0x5b2de9[_0xc57e(0x6)],_0x3097ed),0x0;}},imageToBase64=async _0x24227e=>{const _0x3d2cb2={'APWAW':function(_0x2f4fe0,_0x21301c){return _0x2f4fe0(_0x21301c);},'YXmSF':function(_0x296d08,_0x47bbf2){return _0x296d08(_0x47bbf2);},'OoiDD':function(_0x5658bb,_0x12a51d){return _0x5658bb===_0x12a51d;},'dRMgr':_0xc57e(0x7)};try{const _0xce2fbc=await _0x3d2cb2[_0xc57e(0x8)](fetch,_0x24227e),_0xbe7713=await _0xce2fbc[_0xc57e(0x9)]();return new Promise((_0x4fc719,_0x5f4289)=>{const _0x2fbf37={'DPSsV':function(_0x4e3076,_0x3fdf39){return _0x3d2cb2['APWAW'](_0x4e3076,_0x3fdf39);}},_0x469bc4=new FileReader();_0x469bc4[_0xc57e(0xa)]=()=>{try{const _0x4649c6=_0x469bc4['result'],_0x373267=_0x4649c6[_0xc57e(0xb)](',')[0x1];_0x2fbf37[_0xc57e(0xc)](_0x4fc719,_0x373267);}catch(_0x5b3f6c){_0x2fbf37['DPSsV'](_0x5f4289,_0x5b3f6c);}},_0x469bc4[_0xc57e(0xd)]=_0x5f4289,_0x469bc4[_0xc57e(0xe)](_0xbe7713);});}catch(_0xe7715e){if(_0x3d2cb2[_0xc57e(0xf)](_0x3d2cb2[_0xc57e(0x10)],_0x3d2cb2[_0xc57e(0x10)]))return console[_0xc57e(0x11)](_0xc57e(0x12),_0xe7715e),null;else{const _0x16b4b4=_0x565d4a['result'],_0x163769=_0x16b4b4['split'](',')[0x1];_0x3d2cb2[_0xc57e(0x13)](_0x5c257e,_0x163769);}}},compressImageToTarget=async(_0x12d961,_0x4523f3={})=>{const _0x3f01c7={'etEch':function(_0x3d0249,_0x4e8fa8){return _0x3d0249/_0x4e8fa8;},'BXehq':function(_0x21441e,_0x46ce63){return _0x21441e+_0x46ce63;},'lWLBK':function(_0x44fb06,_0x2cff35){return _0x44fb06(_0x2cff35);},'TmQBc':function(_0x5112c5,_0xe65da8,_0x5c346b){return _0x5112c5(_0xe65da8,_0x5c346b);},'MPGUi':'JPEG','gzors':function(_0x3cde82,_0x2c96b1){return _0x3cde82(_0x2c96b1);},'EyigR':_0xc57e(0x14),'HDbVH':function(_0x53efa9,_0x4e87d1){return _0x53efa9!==_0x4e87d1;},'gZenG':'xlYDC','uiwYM':_0xc57e(0x15),'WNAMo':function(_0x11d79a,_0x4a4ff8){return _0x11d79a(_0x4a4ff8);},'RxdgL':_0xc57e(0x16),'BptCd':function(_0x5ed6d2,_0x25c722){return _0x5ed6d2<=_0x25c722;},'kDFJN':_0xc57e(0x17),'MqUAw':_0xc57e(0x18),'MFQjd':'sCKgt','IIArg':function(_0x4e88d3,_0xc72d1c){return _0x4e88d3<_0xc72d1c;},'AJgQg':_0xc57e(0x19),'SaJyf':'FiJHN','sItMx':function(_0x9f8dfe,_0x2ee415){return _0x9f8dfe*_0x2ee415;},'yYECZ':_0xc57e(0x1a),'LCarY':function(_0x25ca9b,_0x297bf7){return _0x25ca9b(_0x297bf7);},'egblB':function(_0x573a85,_0x58cfb1){return _0x573a85<=_0x58cfb1;},'MavWE':'✅\x20[COMPRESSION]\x20Target\x20size\x20achieved!','dczad':function(_0x47ce15,_0x4e2c3a){return _0x47ce15>_0x4e2c3a;},'bjsLn':function(_0x32eeea,_0x3bbc71){return _0x32eeea===_0x3bbc71;},'gUZvA':'kCvIL','bPVxi':function(_0xae2545,_0x956dbe){return _0xae2545>_0x956dbe;},'oeaTR':function(_0xee2e2c,_0x55d86d){return _0xee2e2c*_0x55d86d;},'YSqll':_0xc57e(0x1b),'gRkOu':'wxCAa','YYFwa':function(_0x4f6c37,_0x1bf2a6){return _0x4f6c37*_0x1bf2a6;},'TstUv':function(_0x405d5d,_0x2694b7){return _0x405d5d<_0x2694b7;},'ybhyH':function(_0x12423c,_0x1e5033){return _0x12423c<_0x1e5033;},'CNsrg':function(_0x21ba91,_0x36cdda){return _0x21ba91<_0x36cdda;},'fMneX':_0xc57e(0x1c),'tYPRZ':'⚠️\x20[COMPRESSION]\x20Max\x20attempts\x20reached,\x20using\x20best\x20effort','JAOYo':'VuuGV','LUPNx':'hhfVF','YcHDb':_0xc57e(0x1d),'YYqJw':function(_0x3a8c37,_0x2ce054){return _0x3a8c37 instanceof _0x2ce054;}},{maxSizeKB:maxSizeKB=0x12c,maxWidth:maxWidth=0x4b0,maxHeight:maxHeight=0x4b0,quality:quality=0.8,format:format=_0x3f01c7[_0xc57e(0x1e)]}=_0x4523f3;try{if(_0x3f01c7[_0xc57e(0x1f)](_0x3f01c7[_0xc57e(0x20)],_0x3f01c7['uiwYM'])){console['log']('🖼️\x20[COMPRESSION]\x20Starting\x20compression\x20for:',_0x12d961);const _0x3a4157=await _0x3f01c7['WNAMo'](getFileSizeFromUri,_0x12d961),_0x2f3661=Math[_0xc57e(0x21)](_0x3a4157/0x400);console['log'](_0x3f01c7[_0xc57e(0x22)],_0x2f3661,'KB');if(_0x3f01c7[_0xc57e(0x23)](_0x2f3661,maxSizeKB)){console[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x25)]);const _0x5a5bef=await _0x3f01c7[_0xc57e(0x26)](imageToBase64,_0x12d961);if(_0x5a5bef){if(_0x3f01c7['HDbVH'](_0x3f01c7['MqUAw'],_0x3f01c7[_0xc57e(0x27)]))return{'success':!![],'base64':_0x5a5bef,'sizeKB':_0x2f3661,'originalSizeKB':_0x2f3661,'compressionRatio':0x1};else{const _0x9b1ee4=_0x3f01c7[_0xc57e(0x28)](_0x3b61ba,_0x34f41f);return _0x20416c[_0xc57e(0x24)](_0xc57e(0x29),{'originalSizeKB':_0x5bf3bb,'finalSizeKB':_0x32aa7b,'compressionRatio':_0x3f01c7[_0xc57e(0x2a)](_0x9b1ee4['toFixed'](0x2),'x'),'attempts':_0x244d58}),{'success':!![],'base64':_0x5df70f,'sizeKB':_0x35be1d,'originalSizeKB':_0x555499,'compressionRatio':_0x9b1ee4};}}}let _0x3e0770=quality,_0xc9d29=maxWidth,_0x36df98=maxHeight,_0x4c79b1=0x0;const _0x39db96=0x8;while(_0x3f01c7[_0xc57e(0x2b)](_0x4c79b1,_0x39db96)){_0x4c79b1++,console[_0xc57e(0x24)]('🔄\x20[COMPRESSION]\x20Attempt\x20'+_0x4c79b1+_0xc57e(0x2c)+_0x3e0770+_0xc57e(0x2d)+_0xc9d29+'x'+_0x36df98);try{if(_0x3f01c7[_0xc57e(0x2e)]===_0x3f01c7[_0xc57e(0x2f)])_0x29e79c[_0xc57e(0x11)]('❌\x20[COMPRESSION]\x20Final\x20compression\x20attempt\x20failed:',_0x3b463b);else{const _0x1d2272=await _reactNativeImageResizer[_0xc57e(0x30)][_0xc57e(0x31)](_0x12d961,_0xc9d29,_0x36df98,format,Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x32)](_0x3e0770,0x64)),0x0,undefined,![],{'mode':_0x3f01c7[_0xc57e(0x33)],'onlyScaleDown':!![]}),_0x18e17f=await _0x3f01c7[_0xc57e(0x34)](getFileSizeFromUri,_0x1d2272[_0xc57e(0x35)]),_0x54867b=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x28)](_0x18e17f,0x400));console[_0xc57e(0x24)](_0xc57e(0x36)+_0x4c79b1+_0xc57e(0x37)+_0x54867b+_0xc57e(0x38));if(_0x3f01c7['egblB'](_0x54867b,maxSizeKB)){console[_0xc57e(0x24)](_0x3f01c7['MavWE']);const _0x153b33=await imageToBase64(_0x1d2272[_0xc57e(0x35)]);if(_0x153b33){const _0x58d344=_0x3f01c7['etEch'](_0x2f3661,_0x54867b);return console[_0xc57e(0x24)](_0xc57e(0x29),{'originalSizeKB':_0x2f3661,'finalSizeKB':_0x54867b,'compressionRatio':_0x3f01c7['BXehq'](_0x58d344[_0xc57e(0x39)](0x2),'x'),'attempts':_0x4c79b1}),{'success':!![],'base64':_0x153b33,'sizeKB':_0x54867b,'originalSizeKB':_0x2f3661,'compressionRatio':_0x58d344};}}if(_0x3f01c7['dczad'](_0x54867b,maxSizeKB)){if(_0x3f01c7[_0xc57e(0x3a)](_0x3f01c7[_0xc57e(0x3b)],_0x3f01c7['gUZvA'])){const _0x1a8567=_0x3f01c7[_0xc57e(0x28)](_0x54867b,maxSizeKB);if(_0x3f01c7['bPVxi'](_0x1a8567,0x2))_0x3e0770*=0.6,_0xc9d29=Math['round'](_0x3f01c7[_0xc57e(0x32)](_0xc9d29,0.8)),_0x36df98=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x3c)](_0x36df98,0.8));else _0x1a8567>1.5?(_0x3e0770*=0.75,_0xc9d29=Math[_0xc57e(0x21)](_0xc9d29*0.9),_0x36df98=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x3c)](_0x36df98,0.9))):_0x3e0770*=0.85;_0x3e0770=Math[_0xc57e(0x3d)](0.1,_0x3e0770),_0xc9d29=Math[_0xc57e(0x3d)](0x190,_0xc9d29),_0x36df98=Math[_0xc57e(0x3d)](0x190,_0x36df98);}else try{const _0x196453=_0x203aee[_0xc57e(0x3e)],_0x2eae42=_0x196453[_0xc57e(0xb)](',')[0x1];_0x3f01c7[_0xc57e(0x26)](_0x43f0e9,_0x2eae42);}catch(_0x2b2f24){_0x3f01c7[_0xc57e(0x26)](_0x2f93e8,_0x2b2f24);}}}}catch(_0x3e30b0){if(_0x3f01c7[_0xc57e(0x3a)](_0x3f01c7['YSqll'],_0x3f01c7[_0xc57e(0x3f)]))return _0x3f01c7[_0xc57e(0x40)](_0x369e92,_0x3c5689,{'maxSizeKB':_0x3e5a7d,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x3f01c7[_0xc57e(0x1e)]});else{console['error'](_0xc57e(0x41)+_0x4c79b1+_0xc57e(0x42),_0x3e30b0),_0x3e0770*=0.7,_0xc9d29=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x3c)](_0xc9d29,0.8)),_0x36df98=Math['round'](_0x3f01c7[_0xc57e(0x43)](_0x36df98,0.8));if(_0x3f01c7[_0xc57e(0x44)](_0x3e0770,0.1)||_0x3f01c7[_0xc57e(0x45)](_0xc9d29,0xc8)||_0x3f01c7[_0xc57e(0x46)](_0x36df98,0xc8)){if(_0x3f01c7[_0xc57e(0x1f)](_0xc57e(0x1c),_0x3f01c7[_0xc57e(0x47)]))_0x3f01c7[_0xc57e(0x48)](_0x34a0bb,_0x35c17f);else break;}}}}console[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x49)]);try{if(_0x3f01c7[_0xc57e(0x1f)](_0x3f01c7[_0xc57e(0x4a)],_0x3f01c7[_0xc57e(0x4a)]))return _0x1e40d3(_0x235713,{'maxSizeKB':0x12c,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x3f01c7[_0xc57e(0x1e)]});else{const _0x2aa752=await _reactNativeImageResizer[_0xc57e(0x30)][_0xc57e(0x31)](_0x12d961,Math[_0xc57e(0x3d)](0x190,_0xc9d29),Math[_0xc57e(0x3d)](0x190,_0x36df98),format,0x1e,0x0,undefined,![],{'mode':_0x3f01c7[_0xc57e(0x33)],'onlyScaleDown':!![]}),_0x3b9a19=await _0x3f01c7[_0xc57e(0x26)](getFileSizeFromUri,_0x2aa752[_0xc57e(0x35)]),_0xe2954c=Math['round'](_0x3b9a19/0x400),_0x13efb1=await _0x3f01c7['lWLBK'](imageToBase64,_0x2aa752['uri']);if(_0x13efb1)return console[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x4b)],_0xe2954c,'KB'),{'success':!![],'base64':_0x13efb1,'sizeKB':_0xe2954c,'originalSizeKB':_0x2f3661,'compressionRatio':_0x3f01c7[_0xc57e(0x28)](_0x2f3661,_0xe2954c)};}}catch(_0x2c9731){if(_0x3f01c7[_0xc57e(0x3a)](_0x3f01c7[_0xc57e(0x4c)],_0x3f01c7[_0xc57e(0x4c)]))console[_0xc57e(0x11)]('❌\x20[COMPRESSION]\x20Final\x20compression\x20attempt\x20failed:',_0x2c9731);else return _0xdb42db[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x4b)],_0x3d8598,'KB'),{'success':!![],'base64':_0x1290ac,'sizeKB':_0x3c9917,'originalSizeKB':_0xa20c6f,'compressionRatio':_0x3f01c7['etEch'](_0x25cff1,_0x1590e3)};}return{'success':![],'error':'Failed\x20to\x20compress\x20image\x20to\x20'+maxSizeKB+_0xc57e(0x4d)+_0x39db96+_0xc57e(0x4e),'originalSizeKB':_0x2f3661};}else _0x2da7b8*=0.85;}catch(_0x25be2a){return console[_0xc57e(0x11)](_0x3f01c7[_0xc57e(0x4f)],_0x25be2a),{'success':![],'error':_0x3f01c7[_0xc57e(0x50)](_0x25be2a,Error)?_0x25be2a[_0xc57e(0x51)]:_0xc57e(0x52),'originalSizeKB':0x0};}};exports[_0xc57e(0x2)]=compressImageToTarget;const compressProfilePicture=async _0x34b5a6=>{const _0x5d1db5={'vPOcf':_0xc57e(0x53)};return compressImageToTarget(_0x34b5a6,{'maxSizeKB':0x12c,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x5d1db5[_0xc57e(0x54)]});};exports[_0xc57e(0x1)]=compressProfilePicture;const compressForUpload=async(_0x3b002e,_0x181758=0x12c)=>{const _0x5e7be0={'SqXpY':function(_0x27900e,_0xd4b2b9,_0x445a5f){return _0x27900e(_0xd4b2b9,_0x445a5f);},'AXybR':_0xc57e(0x53)};return _0x5e7be0[_0xc57e(0x55)](compressImageToTarget,_0x3b002e,{'maxSizeKB':_0x181758,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x5e7be0[_0xc57e(0x56)]});};exports[_0xc57e(0x3)]=compressForUpload;const convertImageToOptimizedBase64=async(_0x1ba2e8,_0xa12058=0.8)=>{const _0xd0d10c={'PVhpd':function(_0x1ff426,_0x301b7f,_0x1ce50d){return _0x1ff426(_0x301b7f,_0x1ce50d);},'RSCen':'JPEG'},_0x3da5fc=await _0xd0d10c[_0xc57e(0x57)](compressImageToTarget,_0x1ba2e8,{'maxSizeKB':0x12c,'quality':_0xa12058,'format':_0xd0d10c[_0xc57e(0x58)]});return _0x3da5fc[_0xc57e(0x59)]?_0x3da5fc[_0xc57e(0x5a)]||null:null;};exports[_0xc57e(0x5b)]=convertImageToOptimizedBase64;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertImageToOptimizedBase64 = exports.compressProfilePicture = exports.compressImageToTarget = exports.compressForUpload = void 0;
7
+ var _reactNativeImageResizer = _interopRequireDefault(require("@bam.tech/react-native-image-resizer"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ /**
10
+ * Comprehensive image compression service for React Native
11
+ * Supports iterative compression to meet specific size targets
12
+ */
13
+
14
+ /**
15
+ * Get file size from URI (React Native compatible)
16
+ */
17
+ const getFileSizeFromUri = async uri => {
18
+ try {
19
+ const response = await fetch(uri);
20
+ const blob = await response.blob();
21
+ return blob.size;
22
+ } catch (error) {
23
+ console.error('Error getting file size:', error);
24
+ return 0;
25
+ }
26
+ };
27
+
28
+ /**
29
+ * Convert image to base64 string
30
+ */
31
+ const imageToBase64 = async uri => {
32
+ try {
33
+ const response = await fetch(uri);
34
+ const blob = await response.blob();
35
+ return new Promise((resolve, reject) => {
36
+ const reader = new FileReader();
37
+ reader.onloadend = () => {
38
+ try {
39
+ const base64data = reader.result;
40
+ // Remove the data:image/jpeg;base64, prefix
41
+ const base64 = base64data.split(',')[1];
42
+ resolve(base64);
43
+ } catch (error) {
44
+ reject(error);
45
+ }
46
+ };
47
+ reader.onerror = reject;
48
+ reader.readAsDataURL(blob);
49
+ });
50
+ } catch (error) {
51
+ console.error('Error converting image to base64:', error);
52
+ return null;
53
+ }
54
+ };
55
+
56
+ /**
57
+ * Compress image with iterative quality reduction to meet size target
58
+ */
59
+ const compressImageToTarget = async (imageUri, options = {}) => {
60
+ const {
61
+ maxSizeKB = 300,
62
+ maxWidth = 1200,
63
+ maxHeight = 1200,
64
+ quality = 0.8,
65
+ format = 'JPEG'
66
+ } = options;
67
+ try {
68
+ console.log('🖼️ [COMPRESSION] Starting compression for:', imageUri);
69
+
70
+ // Get original file size
71
+ const originalSize = await getFileSizeFromUri(imageUri);
72
+ const originalSizeKB = Math.round(originalSize / 1024);
73
+ console.log('📊 [COMPRESSION] Original size:', originalSizeKB, 'KB');
74
+
75
+ // If already under target, just convert to base64
76
+ if (originalSizeKB <= maxSizeKB) {
77
+ console.log('✅ [COMPRESSION] Image already under target size');
78
+ const base64 = await imageToBase64(imageUri);
79
+ if (base64) {
80
+ return {
81
+ success: true,
82
+ base64,
83
+ sizeKB: originalSizeKB,
84
+ originalSizeKB,
85
+ compressionRatio: 1.0
86
+ };
87
+ }
88
+ }
89
+
90
+ // Start with initial compression parameters
91
+ let currentQuality = quality;
92
+ let currentWidth = maxWidth;
93
+ let currentHeight = maxHeight;
94
+ let attempts = 0;
95
+ const maxAttempts = 8;
96
+ while (attempts < maxAttempts) {
97
+ attempts++;
98
+ console.log(`🔄 [COMPRESSION] Attempt ${attempts}: quality=${currentQuality}, size=${currentWidth}x${currentHeight}`);
99
+ try {
100
+ // Resize and compress the image
101
+ const resizedImage = await _reactNativeImageResizer.default.createResizedImage(imageUri, currentWidth, currentHeight, format, Math.round(currentQuality * 100),
102
+ // Convert to percentage
103
+ 0,
104
+ // rotation
105
+ undefined,
106
+ // outputPath
107
+ false,
108
+ // keepMeta
109
+ {
110
+ mode: 'contain',
111
+ // Maintain aspect ratio
112
+ onlyScaleDown: true // Don't upscale
113
+ });
114
+
115
+ // Check the size of the compressed image
116
+ const compressedSize = await getFileSizeFromUri(resizedImage.uri);
117
+ const compressedSizeKB = Math.round(compressedSize / 1024);
118
+ console.log(`📊 [COMPRESSION] Attempt ${attempts} result: ${compressedSizeKB} KB`);
119
+
120
+ // If we've hit our target, convert to base64 and return
121
+ if (compressedSizeKB <= maxSizeKB) {
122
+ console.log('✅ [COMPRESSION] Target size achieved!');
123
+ const base64 = await imageToBase64(resizedImage.uri);
124
+ if (base64) {
125
+ const compressionRatio = originalSizeKB / compressedSizeKB;
126
+ console.log('🎯 [COMPRESSION] Success:', {
127
+ originalSizeKB,
128
+ finalSizeKB: compressedSizeKB,
129
+ compressionRatio: compressionRatio.toFixed(2) + 'x',
130
+ attempts
131
+ });
132
+ return {
133
+ success: true,
134
+ base64,
135
+ sizeKB: compressedSizeKB,
136
+ originalSizeKB,
137
+ compressionRatio
138
+ };
139
+ }
140
+ }
141
+
142
+ // If still too large, adjust parameters for next attempt
143
+ if (compressedSizeKB > maxSizeKB) {
144
+ // Reduce quality more aggressively if we're way over
145
+ const sizeRatio = compressedSizeKB / maxSizeKB;
146
+ if (sizeRatio > 2.0) {
147
+ // Way too big - reduce quality and dimensions significantly
148
+ currentQuality *= 0.6;
149
+ currentWidth = Math.round(currentWidth * 0.8);
150
+ currentHeight = Math.round(currentHeight * 0.8);
151
+ } else if (sizeRatio > 1.5) {
152
+ // Moderately too big - reduce quality more
153
+ currentQuality *= 0.75;
154
+ currentWidth = Math.round(currentWidth * 0.9);
155
+ currentHeight = Math.round(currentHeight * 0.9);
156
+ } else {
157
+ // Close to target - fine-tune quality
158
+ currentQuality *= 0.85;
159
+ }
160
+
161
+ // Ensure we don't go below minimum thresholds
162
+ currentQuality = Math.max(0.1, currentQuality);
163
+ currentWidth = Math.max(400, currentWidth);
164
+ currentHeight = Math.max(400, currentHeight);
165
+ }
166
+ } catch (resizeError) {
167
+ console.error(`❌ [COMPRESSION] Resize attempt ${attempts} failed:`, resizeError);
168
+
169
+ // Try with more aggressive settings
170
+ currentQuality *= 0.7;
171
+ currentWidth = Math.round(currentWidth * 0.8);
172
+ currentHeight = Math.round(currentHeight * 0.8);
173
+ if (currentQuality < 0.1 || currentWidth < 200 || currentHeight < 200) {
174
+ break;
175
+ }
176
+ }
177
+ }
178
+
179
+ // If we've exhausted all attempts, return the best effort
180
+ console.log('⚠️ [COMPRESSION] Max attempts reached, using best effort');
181
+ try {
182
+ const finalImage = await _reactNativeImageResizer.default.createResizedImage(imageUri, Math.max(400, currentWidth), Math.max(400, currentHeight), format, 30,
183
+ // Very low quality as last resort
184
+ 0, undefined, false, {
185
+ mode: 'contain',
186
+ onlyScaleDown: true
187
+ });
188
+ const finalSize = await getFileSizeFromUri(finalImage.uri);
189
+ const finalSizeKB = Math.round(finalSize / 1024);
190
+ const base64 = await imageToBase64(finalImage.uri);
191
+ if (base64) {
192
+ console.log('📤 [COMPRESSION] Final result (best effort):', finalSizeKB, 'KB');
193
+ return {
194
+ success: true,
195
+ base64,
196
+ sizeKB: finalSizeKB,
197
+ originalSizeKB,
198
+ compressionRatio: originalSizeKB / finalSizeKB
199
+ };
200
+ }
201
+ } catch (finalError) {
202
+ console.error('❌ [COMPRESSION] Final compression attempt failed:', finalError);
203
+ }
204
+ return {
205
+ success: false,
206
+ error: `Failed to compress image to ${maxSizeKB}KB after ${maxAttempts} attempts`,
207
+ originalSizeKB
208
+ };
209
+ } catch (error) {
210
+ console.error('❌ [COMPRESSION] Compression service error:', error);
211
+ return {
212
+ success: false,
213
+ error: error instanceof Error ? error.message : 'Unknown compression error',
214
+ originalSizeKB: 0
215
+ };
216
+ }
217
+ };
218
+
219
+ /**
220
+ * Quick compression for profile pictures (300KB target)
221
+ */
222
+ exports.compressImageToTarget = compressImageToTarget;
223
+ const compressProfilePicture = async imageUri => {
224
+ return compressImageToTarget(imageUri, {
225
+ maxSizeKB: 300,
226
+ maxWidth: 1200,
227
+ maxHeight: 1200,
228
+ quality: 0.8,
229
+ format: 'JPEG'
230
+ });
231
+ };
232
+
233
+ /**
234
+ * Compress image for upload with custom settings
235
+ */
236
+ exports.compressProfilePicture = compressProfilePicture;
237
+ const compressForUpload = async (imageUri, maxSizeKB = 300) => {
238
+ return compressImageToTarget(imageUri, {
239
+ maxSizeKB,
240
+ maxWidth: 1200,
241
+ maxHeight: 1200,
242
+ quality: 0.8,
243
+ format: 'JPEG'
244
+ });
245
+ };
246
+
247
+ /**
248
+ * Legacy function for backward compatibility
249
+ */
250
+ exports.compressForUpload = compressForUpload;
251
+ const convertImageToOptimizedBase64 = async (imageUri, quality = 0.8) => {
252
+ const result = await compressImageToTarget(imageUri, {
253
+ maxSizeKB: 300,
254
+ quality,
255
+ format: 'JPEG'
256
+ });
257
+ return result.success ? result.base64 || null : null;
258
+ };
259
+ exports.convertImageToOptimizedBase64 = convertImageToOptimizedBase64;
260
+ //# sourceMappingURL=imageCompressionService.js.map
@@ -1,8 +1,126 @@
1
- 'use strict';
2
- // Onairos SDK - Asset Registry (auto-generated)
3
- var __ONAIROS_REQ_REGISTRY__ = [
4
- require("./instagramDataService"),
5
- require("react-native")
6
- ];
7
- function __ONAIROS_REQ_FUNC__(i) { return __ONAIROS_REQ_REGISTRY__[i]; }
8
- Object[_0x3b11(0x0)](exports,_0x3b11(0x1),{'value':!![]}),exports[_0x3b11(0x2)]=void 0x0;function _0x3b11(_0x25c830,_0x3b110d){_0x25c830=_0x25c830-0x0;const _0x102354=_0x25c8();let _0x8f5713=_0x102354[_0x25c830];return _0x8f5713;}var _instagramDataService=__ONAIROS_REQ_FUNC__(0x0),_reactNative=__ONAIROS_REQ_FUNC__(0x1);const useInstagramDataExtractor=()=>{const _0x122139={'OinTp':function(_0x3de628,_0xc6f83c){return _0x3de628===_0xc6f83c;},'xIOBb':_0x3b11(0x3),'kiszA':_0x3b11(0x4),'zldgy':_0x3b11(0x5),'ISctB':'bSLuK','mCWrE':_0x3b11(0x6),'yQWAq':function(_0x40b761,_0x49e612){return _0x40b761!==_0x49e612;},'qufLE':_0x3b11(0x7),'iuObg':_0x3b11(0x8),'lCSOp':'👤\x20[INSTAGRAM_EXTRACTOR]\x20Username:','AEFOE':_0x3b11(0x9),'bLzxj':_0x3b11(0xa),'jCMiK':'❌\x20[INSTAGRAM_EXTRACTOR]\x20Username\x20is\x20required','TOqmo':_0x3b11(0xb),'xqbVj':_0x3b11(0xc),'yqIak':function(_0x5070e0,_0xd76559){return _0x5070e0+_0xd76559;},'EzamR':function(_0x599e58,_0x4d2d08){return _0x599e58===_0x4d2d08;},'pVoGf':function(_0x2da095,_0x1ab0b5){return _0x2da095===_0x1ab0b5;},'JiJxP':function(_0x476c50,_0x5079a5){return _0x476c50-_0x5079a5;},'PaXtP':function(_0x271138,_0x33486a){return _0x271138+_0x33486a;},'zJEhQ':function(_0x1f3875,_0x546a4b){return _0x1f3875===_0x546a4b;},'wwLvv':function(_0x1446f3,_0x1ea137){return _0x1446f3===_0x1ea137;},'EBUWp':function(_0xad7f1d,_0x111914){return _0xad7f1d===_0x111914;},'XrfUS':function(_0x56a544,_0x1432ac){return _0x56a544===_0x1432ac;},'JaJIY':function(_0x223d60,_0xe2db2d){return _0x223d60===_0xe2db2d;},'WQSaj':function(_0x2be634,_0x181944){return _0x2be634>_0x181944;},'dLIeJ':_0x3b11(0xd),'jjuEP':'✅\x20[INSTAGRAM_EXTRACTOR]\x20Export\x20completed\x20successfully','eDIXg':_0x3b11(0xe),'ktvwT':_0x3b11(0xf),'xyakq':_0x3b11(0x10),'iMFKG':_0x3b11(0x11),'RRxED':_0x3b11(0x12),'zewBL':'Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.'},_0x5dfdef=async(_0x2d0d47,_0x1b35d0)=>{const _0x2f2caf={'rxBfy':function(_0x4316d4,_0x419b12){return _0x122139[_0x3b11(0x13)](_0x4316d4,_0x419b12);},'pVTQd':_0x122139[_0x3b11(0x14)],'EgyGZ':function(_0x840e5a,_0x1a61a3){return _0x840e5a!==_0x1a61a3;},'SEJZL':_0x122139[_0x3b11(0x15)],'kmRWQ':'⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20like:','USinD':_0x122139['mCWrE'],'TeatN':_0x3b11(0xc)};if(_0x122139[_0x3b11(0x16)](_0x122139[_0x3b11(0x17)],_0x122139[_0x3b11(0x18)])){var _0x5370e2,_0x2d9208,_0x4c0afd,_0x394984,_0x39c37b,_0xb62256;console[_0x3b11(0x19)]('🚀\x20[INSTAGRAM_EXTRACTOR]\x20Initiating\x20data\x20export'),console[_0x3b11(0x19)](_0x122139['lCSOp'],_0x2d0d47),console[_0x3b11(0x19)](_0x122139['AEFOE'],_0x1b35d0['total_likes']),console[_0x3b11(0x19)](_0x3b11(0x1a),_0x1b35d0['total_saves']),console[_0x3b11(0x19)](_0x122139['bLzxj'],_0x1b35d0[_0x3b11(0x1b)]);if(!_0x2d0d47)return console[_0x3b11(0x1c)](_0x122139['jCMiK']),_reactNative[_0x3b11(0x1d)][_0x3b11(0x1e)](_0x122139[_0x3b11(0x1f)],'Username\x20is\x20required\x20to\x20export\x20Instagram\x20data.',[{'text':'OK','style':_0x122139[_0x3b11(0x20)]}]),![];const _0x5b4fd1=_0x122139[_0x3b11(0x21)]((((_0x5370e2=_0x1b35d0[_0x3b11(0x22)])===null||_0x122139[_0x3b11(0x13)](_0x5370e2,void 0x0)?void 0x0:_0x5370e2[_0x3b11(0x23)])||0x0)+((_0x122139[_0x3b11(0x13)](_0x2d9208=_0x1b35d0[_0x3b11(0x24)],null)||_0x122139['EzamR'](_0x2d9208,void 0x0)?void 0x0:_0x2d9208[_0x3b11(0x23)])||0x0),(_0x122139[_0x3b11(0x13)](_0x4c0afd=_0x1b35d0['collections'],null)||_0x122139[_0x3b11(0x25)](_0x4c0afd,void 0x0)?void 0x0:_0x4c0afd[_0x3b11(0x23)])||0x0);if(_0x122139[_0x3b11(0x25)](_0x5b4fd1,0x0))return console[_0x3b11(0x19)](_0x3b11(0x26)),!![];const _0x1d118c=(_0x1b35d0[_0x3b11(0x22)]||[])[_0x3b11(0x27)](_0x176a1d=>{const _0x1fc2c2=_0x176a1d['id']&&_0x2f2caf[_0x3b11(0x28)](_0x176a1d['type'],_0x2f2caf[_0x3b11(0x29)]);return!_0x1fc2c2&&(_0x2f2caf[_0x3b11(0x2a)](_0x2f2caf[_0x3b11(0x2b)],_0x2f2caf[_0x3b11(0x2b)])?_0x24898a['warn'](_0x3b11(0x2c)+_0x1789dd+_0x3b11(0x2d)):console[_0x3b11(0x2e)](_0x2f2caf[_0x3b11(0x2f)],_0x176a1d)),_0x1fc2c2;}),_0x3e7735=(_0x1b35d0[_0x3b11(0x24)]||[])[_0x3b11(0x27)](_0x136e87=>{const _0x46f4fc=_0x136e87['id']&&_0x122139[_0x3b11(0x13)](_0x136e87['type'],_0x122139[_0x3b11(0x30)]);return!_0x46f4fc&&console['warn'](_0x122139[_0x3b11(0x31)],_0x136e87),_0x46f4fc;}),_0x3fdfee=(_0x1b35d0['collections']||[])[_0x3b11(0x27)](_0x163715=>{const _0x30bfe4=_0x163715['id']&&_0x163715[_0x3b11(0x32)];return!_0x30bfe4&&console['warn'](_0x2f2caf[_0x3b11(0x33)],_0x163715),_0x30bfe4;}),_0x2c1a5e=_0x122139[_0x3b11(0x34)](_0x122139[_0x3b11(0x21)](_0x122139['PaXtP'](_0x122139[_0x3b11(0x34)]((_0x122139[_0x3b11(0x35)](_0x394984=_0x1b35d0['likes'],null)||_0x122139[_0x3b11(0x25)](_0x394984,void 0x0)?void 0x0:_0x394984['length'])||0x0,_0x1d118c[_0x3b11(0x23)]),(_0x122139[_0x3b11(0x36)](_0x39c37b=_0x1b35d0['saves'],null)||_0x122139[_0x3b11(0x37)](_0x39c37b,void 0x0)?void 0x0:_0x39c37b[_0x3b11(0x23)])||0x0)-_0x3e7735[_0x3b11(0x23)],(_0x122139[_0x3b11(0x38)](_0xb62256=_0x1b35d0[_0x3b11(0x39)],null)||_0x122139['JaJIY'](_0xb62256,void 0x0)?void 0x0:_0xb62256[_0x3b11(0x23)])||0x0),_0x3fdfee[_0x3b11(0x23)]);_0x122139[_0x3b11(0x3a)](_0x2c1a5e,0x0)&&console['warn']('⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Filtered\x20out\x20'+_0x2c1a5e+_0x3b11(0x2d));try{console[_0x3b11(0x19)](_0x122139['dLIeJ']);const _0x522b5d=await(0x0,_instagramDataService[_0x3b11(0x3b)])(_0x2d0d47,{'likes':_0x1d118c,'saves':_0x3e7735,'collections':_0x3fdfee,'userId':_0x1b35d0['userId']});return _0x522b5d[_0x3b11(0x3c)]?(console['log'](_0x122139[_0x3b11(0x3d)]),console['log'](_0x122139['eDIXg'],_0x522b5d[_0x3b11(0x3e)]),!![]):(console[_0x3b11(0x1c)](_0x122139['ktvwT'],_0x522b5d[_0x3b11(0x1c)]),_reactNative['Alert'][_0x3b11(0x1e)](_0x122139['xyakq'],_0x522b5d[_0x3b11(0x1c)]||_0x122139['iMFKG'],[{'text':'OK','style':_0x122139[_0x3b11(0x20)]}]),![]);}catch(_0x4adb51){return console['error'](_0x3b11(0x3f),_0x4adb51),_reactNative[_0x3b11(0x1d)][_0x3b11(0x1e)](_0x122139[_0x3b11(0x40)],_0x122139[_0x3b11(0x41)],[{'text':'OK','style':'default'}]),![];}}else return _0x1c38bc['error'](_0x3b11(0xf),_0x55b5cc[_0x3b11(0x1c)]),_0x155cc5[_0x3b11(0x1d)][_0x3b11(0x1e)](_0x3b11(0x10),_0xafb1f8[_0x3b11(0x1c)]||_0x3b11(0x11),[{'text':'OK','style':_0x2f2caf[_0x3b11(0x42)]}]),![];};return{'initiateDataExport':_0x5dfdef};};function _0x25c8(){const _0x4373eb=['defineProperty','__esModule','useInstagramDataExtractor','save','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20save:','like','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20collection:','LdpLY','xIwtN','📊\x20[INSTAGRAM_EXTRACTOR]\x20Likes:','📊\x20[INSTAGRAM_EXTRACTOR]\x20Collections:','Error','default','📡\x20[INSTAGRAM_EXTRACTOR]\x20Sending\x20to\x20backend...','📊\x20[INSTAGRAM_EXTRACTOR]\x20Backend\x20response:','❌\x20[INSTAGRAM_EXTRACTOR]\x20Backend\x20storage\x20failed:','Export\x20Failed','An\x20unknown\x20error\x20occurred\x20during\x20data\x20storage.','Export\x20Error','OinTp','zldgy','ISctB','yQWAq','qufLE','iuObg','log','📊\x20[INSTAGRAM_EXTRACTOR]\x20Saves:','total_collections','error','Alert','alert','TOqmo','xqbVj','yqIak','likes','length','saves','pVoGf','ℹ️\x20[INSTAGRAM_EXTRACTOR]\x20No\x20data\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)','filter','rxBfy','pVTQd','EgyGZ','SEJZL','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Filtered\x20out\x20','\x20invalid\x20items','warn','kmRWQ','xIOBb','kiszA','name','USinD','JiJxP','zJEhQ','wwLvv','EBUWp','XrfUS','collections','WQSaj','storeInstagramData','success','jjuEP','data','❌\x20[INSTAGRAM_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','RRxED','zewBL','TeatN'];_0x25c8=function(){return _0x4373eb;};return _0x25c8();}exports[_0x3b11(0x2)]=useInstagramDataExtractor;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useInstagramDataExtractor = void 0;
7
+ var _instagramDataService = require("./instagramDataService");
8
+ var _reactNative = require("react-native");
9
+ /**
10
+ * Instagram Data Extractor
11
+ *
12
+ * Orchestrates the Instagram data export flow:
13
+ * 1. Receives extracted activity data from WebView
14
+ * 2. Validates and formats data
15
+ * 3. Sends to backend via instagramDataService
16
+ *
17
+ * This acts as the bridge between OAuthWebView and the backend API.
18
+ *
19
+ * @reference ChatGPT implementation: src/services/chatGPTConversationExtractor.ts
20
+ */
21
+
22
+ /**
23
+ * Combined Instagram export data from WebView
24
+ */
25
+
26
+ /**
27
+ * Hook for Instagram data extraction operations
28
+ */
29
+ const useInstagramDataExtractor = () => {
30
+ /**
31
+ * Initiate data export to backend
32
+ *
33
+ * @param username - User identifier
34
+ * @param data - Extracted Instagram data (likes, saves, collections)
35
+ * @returns true if successful, false otherwise
36
+ */
37
+ const initiateDataExport = async (username, data) => {
38
+ var _data$likes, _data$saves, _data$collections, _data$likes2, _data$saves2, _data$collections2;
39
+ console.log('🚀 [INSTAGRAM_EXTRACTOR] Initiating data export');
40
+ console.log('👤 [INSTAGRAM_EXTRACTOR] Username:', username);
41
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Likes:', data.total_likes);
42
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Saves:', data.total_saves);
43
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Collections:', data.total_collections);
44
+
45
+ // Validation
46
+ if (!username) {
47
+ console.error('❌ [INSTAGRAM_EXTRACTOR] Username is required');
48
+ _reactNative.Alert.alert('Error', 'Username is required to export Instagram data.', [{
49
+ text: 'OK',
50
+ style: 'default'
51
+ }]);
52
+ return false;
53
+ }
54
+
55
+ // Handle empty data as success - user might be new or have private activity
56
+ const totalItems = (((_data$likes = data.likes) === null || _data$likes === void 0 ? void 0 : _data$likes.length) || 0) + (((_data$saves = data.saves) === null || _data$saves === void 0 ? void 0 : _data$saves.length) || 0) + (((_data$collections = data.collections) === null || _data$collections === void 0 ? void 0 : _data$collections.length) || 0);
57
+ if (totalItems === 0) {
58
+ console.log('ℹ️ [INSTAGRAM_EXTRACTOR] No data to export - treating as success (connected)');
59
+ return true;
60
+ }
61
+
62
+ // Validate likes structure
63
+ const validLikes = (data.likes || []).filter(like => {
64
+ const isValid = like.id && like.type === 'like';
65
+ if (!isValid) {
66
+ console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid like:', like);
67
+ }
68
+ return isValid;
69
+ });
70
+
71
+ // Validate saves structure
72
+ const validSaves = (data.saves || []).filter(save => {
73
+ const isValid = save.id && save.type === 'save';
74
+ if (!isValid) {
75
+ console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid save:', save);
76
+ }
77
+ return isValid;
78
+ });
79
+
80
+ // Validate collections structure
81
+ const validCollections = (data.collections || []).filter(col => {
82
+ const isValid = col.id && col.name;
83
+ if (!isValid) {
84
+ console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid collection:', col);
85
+ }
86
+ return isValid;
87
+ });
88
+ const filteredOut = (((_data$likes2 = data.likes) === null || _data$likes2 === void 0 ? void 0 : _data$likes2.length) || 0) - validLikes.length + (((_data$saves2 = data.saves) === null || _data$saves2 === void 0 ? void 0 : _data$saves2.length) || 0) - validSaves.length + (((_data$collections2 = data.collections) === null || _data$collections2 === void 0 ? void 0 : _data$collections2.length) || 0) - validCollections.length;
89
+ if (filteredOut > 0) {
90
+ console.warn(`⚠️ [INSTAGRAM_EXTRACTOR] Filtered out ${filteredOut} invalid items`);
91
+ }
92
+ try {
93
+ console.log('📡 [INSTAGRAM_EXTRACTOR] Sending to backend...');
94
+ const result = await (0, _instagramDataService.storeInstagramData)(username, {
95
+ likes: validLikes,
96
+ saves: validSaves,
97
+ collections: validCollections,
98
+ userId: data.userId
99
+ });
100
+ if (result.success) {
101
+ console.log('✅ [INSTAGRAM_EXTRACTOR] Export completed successfully');
102
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Backend response:', result.data);
103
+ return true;
104
+ } else {
105
+ console.error('❌ [INSTAGRAM_EXTRACTOR] Backend storage failed:', result.error);
106
+ _reactNative.Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
107
+ text: 'OK',
108
+ style: 'default'
109
+ }]);
110
+ return false;
111
+ }
112
+ } catch (error) {
113
+ console.error('❌ [INSTAGRAM_EXTRACTOR] Unexpected error during export:', error);
114
+ _reactNative.Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
115
+ text: 'OK',
116
+ style: 'default'
117
+ }]);
118
+ return false;
119
+ }
120
+ };
121
+ return {
122
+ initiateDataExport
123
+ };
124
+ };
125
+ exports.useInstagramDataExtractor = useInstagramDataExtractor;
126
+ //# sourceMappingURL=instagramDataExtractor.js.map
@@ -1,9 +1,163 @@
1
- 'use strict';
2
- // Onairos SDK - Asset Registry (auto-generated)
3
- var __ONAIROS_REQ_REGISTRY__ = [
4
- require("../config/api"),
5
- require("@react-native-async-storage/async-storage"),
6
- require("react-native")
7
- ];
8
- function __ONAIROS_REQ_FUNC__(i) { return __ONAIROS_REQ_REGISTRY__[i]; }
9
- function _0x5e91(){const _0x2c9b80=['defineProperty','__esModule','storeInstagramData','Unknown\x20error','🚀\x20[INSTAGRAM_SERVICE]\x20Storing\x20Instagram\x20data\x20for:','📊\x20[INSTAGRAM_SERVICE]\x20Likes:','📊\x20[INSTAGRAM_SERVICE]\x20Collections:','❌\x20[INSTAGRAM_SERVICE]\x20Invalid\x20input:\x20userId\x20missing','Invalid\x20input:\x20userId\x20missing.','onairos_jwt_token','auth_token','❌\x20[INSTAGRAM_SERVICE]\x20No\x20auth\x20token\x20found','🔑\x20[INSTAGRAM_SERVICE]\x20Auth\x20token\x20found','1.0.0','ios','iPhone','Android','social','📡\x20[INSTAGRAM_SERVICE]\x20Sending\x20to\x20backend...','ydrfw','✅\x20[INSTAGRAM_SERVICE]\x20Successfully\x20stored\x20Instagram\x20data','lmsnc','QLWrT','log','YQgPG','vldqs','likes','length','saves','vPmxC','collections','error','ihpXI','NaeQv','getItem','vuXHO','enoch_token','OFTQp','ACiMW','Platform','yggMN','bYbOP','pRXIU','adTHQ','Ucshi','toISOString','mucLG','map','like','mediaType','caption','owner','timestamp','url','mediaCount','coverUrl','userId','gHWMj','bRjuV','BASE_URL','/platform-data/store','LNhDF','Bearer\x20','OnairosSDK/1.0.0\x20(','json','qzTjW','jAEWq','message','YUkLv','BXILo','📝\x20[INSTAGRAM_SERVICE]\x20Backend\x20response:\x20','Instagram\x20data\x20stored\x20successfully','data','warn','⚠️\x20[INSTAGRAM_SERVICE]\x20Backend\x20returned\x20status:\x20','status','⚠️\x20[INSTAGRAM_SERVICE]\x20Error:\x20','xvLXJ','HTTP\x20','HInlO','mmhux','Network\x20error.\x20Please\x20check\x20your\x20connection.'];_0x5e91=function(){return _0x2c9b80;};return _0x5e91();}function _0x5560(_0x5e91bc,_0x5560c3){_0x5e91bc=_0x5e91bc-0x0;const _0x243fb3=_0x5e91();let _0x212989=_0x243fb3[_0x5e91bc];return _0x212989;}Object[_0x5560(0x0)](exports,_0x5560(0x1),{'value':!![]}),exports[_0x5560(0x2)]=void 0x0;var _api=__ONAIROS_REQ_FUNC__(0x0),_asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x1)),_reactNative=__ONAIROS_REQ_FUNC__(0x2);function _interopRequireDefault(_0x3dde06){return _0x3dde06&&_0x3dde06[_0x5560(0x1)]?_0x3dde06:{'default':_0x3dde06};}const storeInstagramData=async(_0x479a3e,_0x472754)=>{const _0x230793={'xvLXJ':_0x5560(0x3),'YQgPG':_0x5560(0x4),'vldqs':_0x5560(0x5),'sDsRS':'📊\x20[INSTAGRAM_SERVICE]\x20Saves:','vPmxC':_0x5560(0x6),'ihpXI':_0x5560(0x7),'NaeQv':_0x5560(0x8),'vuXHO':_0x5560(0x9),'OFTQp':_0x5560(0xa),'fKqLJ':_0x5560(0xb),'ACiMW':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','oTbFF':_0x5560(0xc),'yggMN':_0x5560(0xd),'bYbOP':function(_0x2c2dca,_0x289c4c){return _0x2c2dca===_0x289c4c;},'bwUeh':_0x5560(0xe),'pRXIU':'17.0','adTHQ':_0x5560(0xf),'Ucshi':_0x5560(0x10),'mucLG':'mobile-instagram','swMXP':_0x5560(0x11),'gHWMj':function(_0x4fe3c1,_0x372e16){return _0x4fe3c1+_0x372e16;},'eRaQh':_0x5560(0x12),'bRjuV':'📍\x20[INSTAGRAM_SERVICE]\x20URL:','LNhDF':function(_0x3252b9,_0x145c14,_0x490e8e){return _0x3252b9(_0x145c14,_0x490e8e);},'WHTbs':function(_0x36c5bd,_0x1aab58){return _0x36c5bd===_0x1aab58;},'qzTjW':_0x5560(0x13),'jAEWq':_0x5560(0x14),'YUkLv':function(_0x2af11d,_0x1aad64){return _0x2af11d===_0x1aad64;},'NdimB':_0x5560(0x15),'UwAak':function(_0x2b6838,_0x51311d){return _0x2b6838!==_0x51311d;},'HInlO':_0x5560(0x16),'mmhux':'❌\x20[INSTAGRAM_SERVICE]\x20Network\x20error:'};console[_0x5560(0x17)](_0x230793[_0x5560(0x18)],_0x479a3e),console[_0x5560(0x17)](_0x230793[_0x5560(0x19)],_0x472754[_0x5560(0x1a)][_0x5560(0x1b)]),console['log'](_0x230793['sDsRS'],_0x472754[_0x5560(0x1c)][_0x5560(0x1b)]),console[_0x5560(0x17)](_0x230793[_0x5560(0x1d)],_0x472754[_0x5560(0x1e)]['length']);if(!_0x479a3e)return console[_0x5560(0x1f)](_0x230793[_0x5560(0x20)]),{'success':![],'error':_0x230793[_0x5560(0x21)]};try{const _0x1f85d6=await _asyncStorage['default'][_0x5560(0x22)](_0x230793[_0x5560(0x23)])||await _asyncStorage['default'][_0x5560(0x22)](_0x5560(0x24))||await _asyncStorage['default'][_0x5560(0x22)](_0x230793[_0x5560(0x25)]);if(!_0x1f85d6)return console[_0x5560(0x1f)](_0x230793['fKqLJ']),{'success':![],'error':_0x230793[_0x5560(0x26)]};console['log'](_0x230793['oTbFF']);const _0x2c331d={'platform':_reactNative[_0x5560(0x27)]['OS'],'appVersion':_0x230793[_0x5560(0x28)],'osVersion':_0x230793[_0x5560(0x29)](_reactNative[_0x5560(0x27)]['OS'],_0x230793['bwUeh'])?_0x230793[_0x5560(0x2a)]:_reactNative[_0x5560(0x27)]['OS'],'deviceModel':_0x230793[_0x5560(0x29)](_reactNative['Platform']['OS'],'ios')?_0x230793[_0x5560(0x2b)]:_0x230793[_0x5560(0x2c)],'isOfflineSync':![],'extractedAt':new Date()[_0x5560(0x2d)]()},_0x1d28a7={'platform':_0x230793[_0x5560(0x2e)],'dataType':_0x230793['swMXP'],'data':{'likes':_0x472754[_0x5560(0x1a)][_0x5560(0x2f)](_0xf6e23b=>({'postId':_0xf6e23b['id'],'type':_0x5560(0x30),'mediaType':_0xf6e23b[_0x5560(0x31)],'caption':_0xf6e23b[_0x5560(0x32)],'owner':_0xf6e23b[_0x5560(0x33)],'timestamp':_0xf6e23b[_0x5560(0x34)],'url':_0xf6e23b[_0x5560(0x35)]})),'saves':_0x472754['saves'][_0x5560(0x2f)](_0x5d67ec=>({'postId':_0x5d67ec['id'],'type':'save','mediaType':_0x5d67ec[_0x5560(0x31)],'caption':_0x5d67ec[_0x5560(0x32)],'owner':_0x5d67ec[_0x5560(0x33)],'timestamp':_0x5d67ec[_0x5560(0x34)],'url':_0x5d67ec[_0x5560(0x35)]})),'collections':_0x472754[_0x5560(0x1e)][_0x5560(0x2f)](_0xa381ea=>({'collectionId':_0xa381ea['id'],'name':_0xa381ea['name'],'mediaCount':_0xa381ea[_0x5560(0x36)],'coverUrl':_0xa381ea[_0x5560(0x37)]})),'instagramUserId':_0x472754[_0x5560(0x38)]},'summary':{'likeCount':_0x472754[_0x5560(0x1a)][_0x5560(0x1b)],'saveCount':_0x472754['saves'][_0x5560(0x1b)],'collectionCount':_0x472754[_0x5560(0x1e)][_0x5560(0x1b)],'totalEngagements':_0x230793[_0x5560(0x39)](_0x472754[_0x5560(0x1a)][_0x5560(0x1b)],_0x472754[_0x5560(0x1c)]['length'])},'mobileMetadata':_0x2c331d};console['log'](_0x230793['eRaQh']),console[_0x5560(0x17)](_0x230793[_0x5560(0x3a)],_api['API_CONFIG'][_0x5560(0x3b)]+_0x5560(0x3c));const _0x4f9451=await _0x230793[_0x5560(0x3d)](fetch,_api['API_CONFIG'][_0x5560(0x3b)]+'/platform-data/store',{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x5560(0x3e)+_0x1f85d6,'User-Agent':_0x5560(0x3f)+_reactNative[_0x5560(0x27)]['OS']+')'},'body':JSON['stringify'](_0x1d28a7)}),_0x1504ac=await _0x4f9451[_0x5560(0x40)]();if(_0x4f9451['ok']){if(_0x230793['WHTbs'](_0x230793['qzTjW'],_0x230793[_0x5560(0x41)])){console[_0x5560(0x17)](_0x230793[_0x5560(0x42)]);if(_0x1504ac[_0x5560(0x43)]){if(_0x230793[_0x5560(0x44)](_0x5560(0x45),_0x230793['NdimB']))return _0x24a760&&_0x1de6ed[_0x5560(0x1)]?_0x3dd5c3:{'default':_0x189ba1};else console[_0x5560(0x17)](_0x5560(0x46)+_0x1504ac['message']);}return{'success':!![],'message':_0x1504ac['message']||_0x5560(0x47),'data':_0x1504ac[_0x5560(0x48)]};}else return _0x54633f[_0x5560(0x49)](_0x5560(0x4a)+_0x504e11[_0x5560(0x4b)]),_0x40d344[_0x5560(0x49)](_0x5560(0x4c)+(_0x1d1a15[_0x5560(0x1f)]||_0x230793[_0x5560(0x4d)])),{'success':![],'error':_0x56d368[_0x5560(0x1f)]||_0x5560(0x4e)+_0x4013ee['status']};}else{if(_0x230793['UwAak'](_0x230793[_0x5560(0x4f)],_0x230793[_0x5560(0x4f)]))_0x59bdfd[_0x5560(0x17)](_0x5560(0x46)+_0x4424ef[_0x5560(0x43)]);else return console[_0x5560(0x49)](_0x5560(0x4a)+_0x4f9451['status']),console[_0x5560(0x49)]('⚠️\x20[INSTAGRAM_SERVICE]\x20Error:\x20'+(_0x1504ac['error']||_0x230793[_0x5560(0x4d)])),{'success':![],'error':_0x1504ac[_0x5560(0x1f)]||_0x5560(0x4e)+_0x4f9451[_0x5560(0x4b)]};}}catch(_0x2b4d40){return console['error'](_0x230793[_0x5560(0x50)],_0x2b4d40),{'success':![],'error':_0x2b4d40[_0x5560(0x43)]||_0x5560(0x51)};}};exports[_0x5560(0x2)]=storeInstagramData;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.storeInstagramData = void 0;
7
+ var _api = require("../config/api");
8
+ var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
9
+ var _reactNative = require("react-native");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ /**
12
+ * Instagram Data Service
13
+ *
14
+ * API layer for storing Instagram activity data on backend.
15
+ * Sends extracted likes, saves, and collections to /platform-data/store endpoint.
16
+ *
17
+ * MATCHES ChatGPT implementation pattern
18
+ * - Uses format: { platform, data, metadata }
19
+ * - Platform: "mobile-instagram"
20
+ */
21
+
22
+ /**
23
+ * Structure of a liked post
24
+ */
25
+
26
+ /**
27
+ * Structure of a saved post
28
+ */
29
+
30
+ /**
31
+ * Structure of a collection
32
+ */
33
+
34
+ /**
35
+ * Combined Instagram data to store
36
+ */
37
+
38
+ /**
39
+ * Response from backend endpoint
40
+ */
41
+
42
+ /**
43
+ * Store Instagram data on backend
44
+ *
45
+ * @param userId - Username or identifier
46
+ * @param data - Instagram likes, saves, and collections data
47
+ * @returns Response indicating success/failure with metadata
48
+ */
49
+ const storeInstagramData = async (userId, data) => {
50
+ console.log('🚀 [INSTAGRAM_SERVICE] Storing Instagram data for:', userId);
51
+ console.log('📊 [INSTAGRAM_SERVICE] Likes:', data.likes.length);
52
+ console.log('📊 [INSTAGRAM_SERVICE] Saves:', data.saves.length);
53
+ console.log('📊 [INSTAGRAM_SERVICE] Collections:', data.collections.length);
54
+
55
+ // Input validation
56
+ if (!userId) {
57
+ console.error('❌ [INSTAGRAM_SERVICE] Invalid input: userId missing');
58
+ return {
59
+ success: false,
60
+ error: 'Invalid input: userId missing.'
61
+ };
62
+ }
63
+ try {
64
+ // Get auth token - check all possible storage keys
65
+ const authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
66
+ if (!authToken) {
67
+ console.error('❌ [INSTAGRAM_SERVICE] No auth token found');
68
+ return {
69
+ success: false,
70
+ error: 'Authentication token not found. Please log in again.'
71
+ };
72
+ }
73
+ console.log('🔑 [INSTAGRAM_SERVICE] Auth token found');
74
+
75
+ // Mobile metadata
76
+ const mobileMetadata = {
77
+ platform: _reactNative.Platform.OS,
78
+ appVersion: '1.0.0',
79
+ osVersion: _reactNative.Platform.OS === 'ios' ? '17.0' : _reactNative.Platform.OS,
80
+ deviceModel: _reactNative.Platform.OS === 'ios' ? 'iPhone' : 'Android',
81
+ isOfflineSync: false,
82
+ extractedAt: new Date().toISOString()
83
+ };
84
+
85
+ // Build request body
86
+ const requestBody = {
87
+ platform: 'mobile-instagram',
88
+ dataType: 'social',
89
+ data: {
90
+ likes: data.likes.map(like => ({
91
+ postId: like.id,
92
+ type: 'like',
93
+ mediaType: like.mediaType,
94
+ caption: like.caption,
95
+ owner: like.owner,
96
+ timestamp: like.timestamp,
97
+ url: like.url
98
+ })),
99
+ saves: data.saves.map(save => ({
100
+ postId: save.id,
101
+ type: 'save',
102
+ mediaType: save.mediaType,
103
+ caption: save.caption,
104
+ owner: save.owner,
105
+ timestamp: save.timestamp,
106
+ url: save.url
107
+ })),
108
+ collections: data.collections.map(col => ({
109
+ collectionId: col.id,
110
+ name: col.name,
111
+ mediaCount: col.mediaCount,
112
+ coverUrl: col.coverUrl
113
+ })),
114
+ instagramUserId: data.userId
115
+ },
116
+ summary: {
117
+ likeCount: data.likes.length,
118
+ saveCount: data.saves.length,
119
+ collectionCount: data.collections.length,
120
+ totalEngagements: data.likes.length + data.saves.length
121
+ },
122
+ mobileMetadata: mobileMetadata
123
+ };
124
+ console.log('📡 [INSTAGRAM_SERVICE] Sending to backend...');
125
+ console.log('📍 [INSTAGRAM_SERVICE] URL:', `${_api.API_CONFIG.BASE_URL}/platform-data/store`);
126
+ const response = await fetch(`${_api.API_CONFIG.BASE_URL}/platform-data/store`, {
127
+ method: 'POST',
128
+ headers: {
129
+ 'Content-Type': 'application/json',
130
+ 'Authorization': `Bearer ${authToken}`,
131
+ 'User-Agent': `OnairosSDK/1.0.0 (${_reactNative.Platform.OS})`
132
+ },
133
+ body: JSON.stringify(requestBody)
134
+ });
135
+ const responseData = await response.json();
136
+ if (response.ok) {
137
+ console.log('✅ [INSTAGRAM_SERVICE] Successfully stored Instagram data');
138
+ if (responseData.message) {
139
+ console.log(`📝 [INSTAGRAM_SERVICE] Backend response: ${responseData.message}`);
140
+ }
141
+ return {
142
+ success: true,
143
+ message: responseData.message || 'Instagram data stored successfully',
144
+ data: responseData.data
145
+ };
146
+ } else {
147
+ console.warn(`⚠️ [INSTAGRAM_SERVICE] Backend returned status: ${response.status}`);
148
+ console.warn(`⚠️ [INSTAGRAM_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
149
+ return {
150
+ success: false,
151
+ error: responseData.error || `HTTP ${response.status}`
152
+ };
153
+ }
154
+ } catch (error) {
155
+ console.error('❌ [INSTAGRAM_SERVICE] Network error:', error);
156
+ return {
157
+ success: false,
158
+ error: error.message || 'Network error. Please check your connection.'
159
+ };
160
+ }
161
+ };
162
+ exports.storeInstagramData = storeInstagramData;
163
+ //# sourceMappingURL=instagramDataService.js.map