@glideidentity/web-client-sdk 5.1.2 → 6.0.0-beta.1

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 (203) hide show
  1. package/README.md +337 -526
  2. package/dist/browser/web-client-sdk.min.js +1 -1
  3. package/dist/cjs/adapters/index.js +15 -0
  4. package/dist/cjs/adapters/react.js +192 -0
  5. package/dist/cjs/adapters/vanilla.js +38 -0
  6. package/dist/cjs/adapters/vue.js +187 -0
  7. package/dist/cjs/browser.js +58 -0
  8. package/dist/cjs/client/http.js +159 -0
  9. package/dist/cjs/client/index.js +19 -0
  10. package/dist/cjs/client/logger.js +135 -0
  11. package/dist/cjs/client/phone-auth-client.js +439 -0
  12. package/dist/cjs/client/strategies/polling.js +177 -0
  13. package/dist/cjs/core/errors.js +204 -0
  14. package/dist/cjs/core/index.js +83 -0
  15. package/dist/cjs/core/type-guards.js +196 -0
  16. package/dist/cjs/core/types.js +25 -0
  17. package/dist/{core/phone-auth/validation-utils.js → cjs/core/validators.js} +70 -23
  18. package/dist/cjs/index.js +81 -0
  19. package/dist/cjs/ui/index.js +11 -0
  20. package/dist/{core/phone-auth → cjs}/ui/mobile-debug-console.js +149 -78
  21. package/dist/cjs/ui/modal.js +1122 -0
  22. package/dist/esm/adapters/index.js +11 -0
  23. package/dist/esm/adapters/react.js +182 -0
  24. package/dist/esm/adapters/vanilla.js +29 -0
  25. package/dist/esm/adapters/vue.js +177 -0
  26. package/dist/esm/browser.js +30 -11
  27. package/dist/esm/client/http.js +156 -0
  28. package/dist/esm/client/index.js +11 -0
  29. package/dist/esm/client/logger.js +131 -0
  30. package/dist/esm/client/phone-auth-client.js +435 -0
  31. package/dist/esm/client/strategies/polling.js +174 -0
  32. package/dist/esm/core/errors.js +193 -0
  33. package/dist/esm/core/index.js +60 -0
  34. package/dist/esm/core/type-guards.js +181 -0
  35. package/dist/esm/core/types.js +22 -1
  36. package/dist/esm/core/{phone-auth/validation-utils.js → validators.js} +66 -21
  37. package/dist/esm/index.js +45 -17
  38. package/dist/esm/ui/index.js +5 -0
  39. package/dist/esm/{core/phone-auth/ui → ui}/mobile-debug-console.js +149 -78
  40. package/dist/esm/ui/modal.js +1117 -0
  41. package/dist/types/adapters/index.d.ts +10 -0
  42. package/dist/types/adapters/index.d.ts.map +1 -0
  43. package/dist/types/adapters/react.d.ts +70 -0
  44. package/dist/types/adapters/react.d.ts.map +1 -0
  45. package/dist/types/adapters/vanilla.d.ts +29 -0
  46. package/dist/types/adapters/vanilla.d.ts.map +1 -0
  47. package/dist/types/adapters/vue.d.ts +71 -0
  48. package/dist/types/adapters/vue.d.ts.map +1 -0
  49. package/dist/types/browser.d.ts +27 -0
  50. package/dist/types/browser.d.ts.map +1 -0
  51. package/dist/types/client/http.d.ts +41 -0
  52. package/dist/types/client/http.d.ts.map +1 -0
  53. package/dist/types/client/index.d.ts +10 -0
  54. package/dist/types/client/index.d.ts.map +1 -0
  55. package/dist/types/client/logger.d.ts +36 -0
  56. package/dist/types/client/logger.d.ts.map +1 -0
  57. package/dist/types/client/phone-auth-client.d.ts +91 -0
  58. package/dist/types/client/phone-auth-client.d.ts.map +1 -0
  59. package/dist/types/client/strategies/polling.d.ts +36 -0
  60. package/dist/types/client/strategies/polling.d.ts.map +1 -0
  61. package/dist/types/core/errors.d.ts +71 -0
  62. package/dist/types/core/errors.d.ts.map +1 -0
  63. package/dist/types/core/index.d.ts +38 -0
  64. package/dist/types/core/index.d.ts.map +1 -0
  65. package/dist/types/core/type-guards.d.ts +118 -0
  66. package/dist/types/core/type-guards.d.ts.map +1 -0
  67. package/dist/types/core/types.d.ts +534 -0
  68. package/dist/types/core/types.d.ts.map +1 -0
  69. package/dist/types/core/validators.d.ts +63 -0
  70. package/dist/types/core/validators.d.ts.map +1 -0
  71. package/dist/types/index.d.ts +40 -0
  72. package/dist/types/index.d.ts.map +1 -0
  73. package/dist/types/ui/index.d.ts +6 -0
  74. package/dist/types/ui/index.d.ts.map +1 -0
  75. package/dist/{esm/core/phone-auth → types}/ui/mobile-debug-console.d.ts +1 -0
  76. package/dist/types/ui/mobile-debug-console.d.ts.map +1 -0
  77. package/dist/types/ui/modal.d.ts +87 -0
  78. package/dist/types/ui/modal.d.ts.map +1 -0
  79. package/package.json +48 -34
  80. package/dist/adapters/angular/client.service.d.ts +0 -7
  81. package/dist/adapters/angular/client.service.js +0 -30
  82. package/dist/adapters/angular/index.d.ts +0 -3
  83. package/dist/adapters/angular/index.js +0 -18
  84. package/dist/adapters/angular/phone-auth.service.d.ts +0 -38
  85. package/dist/adapters/angular/phone-auth.service.js +0 -130
  86. package/dist/adapters/react/index.d.ts +0 -9
  87. package/dist/adapters/react/index.js +0 -28
  88. package/dist/adapters/react/useClient.d.ts +0 -26
  89. package/dist/adapters/react/useClient.js +0 -121
  90. package/dist/adapters/react/usePhoneAuth.d.ts +0 -23
  91. package/dist/adapters/react/usePhoneAuth.js +0 -95
  92. package/dist/adapters/vanilla/client.d.ts +0 -8
  93. package/dist/adapters/vanilla/client.js +0 -33
  94. package/dist/adapters/vanilla/index.d.ts +0 -3
  95. package/dist/adapters/vanilla/index.js +0 -18
  96. package/dist/adapters/vanilla/phone-auth.d.ts +0 -46
  97. package/dist/adapters/vanilla/phone-auth.js +0 -138
  98. package/dist/adapters/vue/index.d.ts +0 -10
  99. package/dist/adapters/vue/index.js +0 -36
  100. package/dist/adapters/vue/useClient.d.ts +0 -115
  101. package/dist/adapters/vue/useClient.js +0 -131
  102. package/dist/adapters/vue/usePhoneAuth.d.ts +0 -94
  103. package/dist/adapters/vue/usePhoneAuth.js +0 -103
  104. package/dist/browser.d.ts +0 -7
  105. package/dist/browser.js +0 -31
  106. package/dist/core/client.d.ts +0 -22
  107. package/dist/core/client.js +0 -77
  108. package/dist/core/logger.d.ts +0 -130
  109. package/dist/core/logger.js +0 -370
  110. package/dist/core/phone-auth/api-types.d.ts +0 -593
  111. package/dist/core/phone-auth/api-types.js +0 -215
  112. package/dist/core/phone-auth/client.d.ts +0 -189
  113. package/dist/core/phone-auth/client.js +0 -1441
  114. package/dist/core/phone-auth/error-utils.d.ts +0 -110
  115. package/dist/core/phone-auth/error-utils.js +0 -350
  116. package/dist/core/phone-auth/index.d.ts +0 -7
  117. package/dist/core/phone-auth/index.js +0 -50
  118. package/dist/core/phone-auth/status-types.d.ts +0 -107
  119. package/dist/core/phone-auth/status-types.js +0 -31
  120. package/dist/core/phone-auth/strategies/desktop.d.ts +0 -122
  121. package/dist/core/phone-auth/strategies/desktop.js +0 -596
  122. package/dist/core/phone-auth/strategies/index.d.ts +0 -11
  123. package/dist/core/phone-auth/strategies/index.js +0 -15
  124. package/dist/core/phone-auth/strategies/link.d.ts +0 -89
  125. package/dist/core/phone-auth/strategies/link.js +0 -384
  126. package/dist/core/phone-auth/strategies/ts43.d.ts +0 -32
  127. package/dist/core/phone-auth/strategies/ts43.js +0 -151
  128. package/dist/core/phone-auth/strategies/types.d.ts +0 -18
  129. package/dist/core/phone-auth/strategies/types.js +0 -6
  130. package/dist/core/phone-auth/type-guards.d.ts +0 -143
  131. package/dist/core/phone-auth/type-guards.js +0 -198
  132. package/dist/core/phone-auth/types.d.ts +0 -237
  133. package/dist/core/phone-auth/types.js +0 -93
  134. package/dist/core/phone-auth/ui/mobile-debug-console.d.ts +0 -25
  135. package/dist/core/phone-auth/ui/modal.d.ts +0 -88
  136. package/dist/core/phone-auth/ui/modal.js +0 -598
  137. package/dist/core/phone-auth/validation-utils.d.ts +0 -44
  138. package/dist/core/types.d.ts +0 -62
  139. package/dist/core/types.js +0 -2
  140. package/dist/core/version.d.ts +0 -1
  141. package/dist/core/version.js +0 -5
  142. package/dist/esm/adapters/angular/client.service.d.ts +0 -7
  143. package/dist/esm/adapters/angular/client.service.js +0 -27
  144. package/dist/esm/adapters/angular/index.d.ts +0 -3
  145. package/dist/esm/adapters/angular/index.js +0 -4
  146. package/dist/esm/adapters/angular/phone-auth.service.d.ts +0 -38
  147. package/dist/esm/adapters/angular/phone-auth.service.js +0 -127
  148. package/dist/esm/adapters/react/index.d.ts +0 -9
  149. package/dist/esm/adapters/react/index.js +0 -8
  150. package/dist/esm/adapters/react/useClient.d.ts +0 -26
  151. package/dist/esm/adapters/react/useClient.js +0 -116
  152. package/dist/esm/adapters/react/usePhoneAuth.d.ts +0 -23
  153. package/dist/esm/adapters/react/usePhoneAuth.js +0 -92
  154. package/dist/esm/adapters/vanilla/client.d.ts +0 -8
  155. package/dist/esm/adapters/vanilla/client.js +0 -29
  156. package/dist/esm/adapters/vanilla/index.d.ts +0 -3
  157. package/dist/esm/adapters/vanilla/index.js +0 -4
  158. package/dist/esm/adapters/vanilla/phone-auth.d.ts +0 -46
  159. package/dist/esm/adapters/vanilla/phone-auth.js +0 -134
  160. package/dist/esm/adapters/vue/index.d.ts +0 -10
  161. package/dist/esm/adapters/vue/index.js +0 -11
  162. package/dist/esm/adapters/vue/useClient.d.ts +0 -115
  163. package/dist/esm/adapters/vue/useClient.js +0 -127
  164. package/dist/esm/adapters/vue/usePhoneAuth.d.ts +0 -94
  165. package/dist/esm/adapters/vue/usePhoneAuth.js +0 -100
  166. package/dist/esm/browser.d.ts +0 -7
  167. package/dist/esm/core/client.d.ts +0 -22
  168. package/dist/esm/core/client.js +0 -70
  169. package/dist/esm/core/logger.d.ts +0 -130
  170. package/dist/esm/core/logger.js +0 -359
  171. package/dist/esm/core/phone-auth/api-types.d.ts +0 -593
  172. package/dist/esm/core/phone-auth/api-types.js +0 -203
  173. package/dist/esm/core/phone-auth/client.d.ts +0 -189
  174. package/dist/esm/core/phone-auth/client.js +0 -1404
  175. package/dist/esm/core/phone-auth/error-utils.d.ts +0 -110
  176. package/dist/esm/core/phone-auth/error-utils.js +0 -338
  177. package/dist/esm/core/phone-auth/index.d.ts +0 -7
  178. package/dist/esm/core/phone-auth/index.js +0 -8
  179. package/dist/esm/core/phone-auth/status-types.d.ts +0 -107
  180. package/dist/esm/core/phone-auth/status-types.js +0 -26
  181. package/dist/esm/core/phone-auth/strategies/desktop.d.ts +0 -122
  182. package/dist/esm/core/phone-auth/strategies/desktop.js +0 -590
  183. package/dist/esm/core/phone-auth/strategies/index.d.ts +0 -11
  184. package/dist/esm/core/phone-auth/strategies/index.js +0 -7
  185. package/dist/esm/core/phone-auth/strategies/link.d.ts +0 -89
  186. package/dist/esm/core/phone-auth/strategies/link.js +0 -380
  187. package/dist/esm/core/phone-auth/strategies/ts43.d.ts +0 -32
  188. package/dist/esm/core/phone-auth/strategies/ts43.js +0 -147
  189. package/dist/esm/core/phone-auth/strategies/types.d.ts +0 -18
  190. package/dist/esm/core/phone-auth/strategies/types.js +0 -5
  191. package/dist/esm/core/phone-auth/type-guards.d.ts +0 -143
  192. package/dist/esm/core/phone-auth/type-guards.js +0 -185
  193. package/dist/esm/core/phone-auth/types.d.ts +0 -237
  194. package/dist/esm/core/phone-auth/types.js +0 -76
  195. package/dist/esm/core/phone-auth/ui/modal.d.ts +0 -88
  196. package/dist/esm/core/phone-auth/ui/modal.js +0 -594
  197. package/dist/esm/core/phone-auth/validation-utils.d.ts +0 -44
  198. package/dist/esm/core/types.d.ts +0 -62
  199. package/dist/esm/core/version.d.ts +0 -1
  200. package/dist/esm/core/version.js +0 -2
  201. package/dist/esm/index.d.ts +0 -12
  202. package/dist/index.d.ts +0 -12
  203. package/dist/index.js +0 -55
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GlideWebClientSDK=t():e.GlideWebClientSDK=t()}(this,(()=>(()=>{"use strict";var e={982:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.VanillaClient=void 0;const r=n(499);t.VanillaClient=class{constructor(e){this.client=new r.SDKClient(e)}authenticate(e,t){return o(this,void 0,void 0,(function*(){throw new Error("authenticate method is deprecated. Use client.setToken() directly.")}))}setToken(e){this.client.setToken(e)}get(e,t){return o(this,void 0,void 0,(function*(){return this.client.get(e,t)}))}}},724:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthManager=void 0;const r=n(514);t.PhoneAuthManager=class{constructor(e={}){this.listeners=[],this.client=new r.PhoneAuthClient(e),this.state={isLoading:!1,error:null,result:null,currentStep:"idle",isSupported:this.client.isSupported()}}getState(){return Object.assign({},this.state)}subscribe(e){return this.listeners.push(e),()=>{const t=this.listeners.indexOf(e);-1!==t&&this.listeners.splice(t,1)}}updateState(e){this.state=Object.assign(Object.assign({},this.state),e),this.listeners.forEach((e=>e(this.getState())))}verify(e){return o(this,void 0,void 0,(function*(){this.updateState({isLoading:!0,error:null,result:null,currentStep:"requesting"});try{const t=yield this.client.preparePhoneRequest(e);this.updateState({currentStep:"authenticating"});const n=yield this.client.invokeSecurePrompt(t);this.updateState({currentStep:"processing"});const o=n,r="GetPhoneNumber"===e.use_case?yield this.client.getPhoneNumber(o,t.session):yield this.client.verifyPhoneNumber(o,t.session);return this.updateState({result:r,currentStep:"complete",isLoading:!1}),r}catch(t){const n=t,o=Object.assign(Object.assign({},n),{context:n.context||{useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0}});throw this.updateState({error:o,currentStep:"idle",isLoading:!1}),o}}))}getPhoneNumber(e){return o(this,void 0,void 0,(function*(){return this.verify(Object.assign({use_case:"GetPhoneNumber"},e))}))}verifyPhoneNumber(e,t){return o(this,void 0,void 0,(function*(){return this.verify(Object.assign({use_case:"VerifyPhoneNumber",phone_number:e},t))}))}reset(){this.updateState({isLoading:!1,error:null,result:null,currentStep:"idle"})}isSupported(){return this.state.isSupported}}},499:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SDKClient=void 0;const i=r(n(425)),s=n(514);t.SDKClient=class{constructor(e){this.config=e,this.client=i.default.create({baseURL:e.baseURL||"",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.phoneAuth=new s.PhoneAuthClient({endpoints:e.phoneAuthEndpoints?{prepare:e.phoneAuthEndpoints.prepareRequest,process:e.phoneAuthEndpoints.processResponse}:void 0,debug:e.debug}),this.client.interceptors.request.use((e=>o(this,void 0,void 0,(function*(){return this.token&&(e.headers.Authorization=`Bearer ${this.token}`),e}))))}setToken(e){this.token=e}clearToken(){this.token=void 0}get(e,t){return o(this,void 0,void 0,(function*(){if(!this.config.baseURL)throw new Error("baseURL is required for making API requests. Please provide it in the ClientConfig.");const n=yield this.client.get(e,{headers:null==t?void 0:t.headers,params:null==t?void 0:t.params});return{data:n.data,status:n.status,headers:Object.fromEntries(Object.entries(n.headers).map((([e,t])=>[e,String(t)])))}}))}}},928:function(e,t){var n,o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.LoggerFactory=t.PerformanceTimer=t.RemoteLogger=t.NoopLogger=t.ConsoleLogger=t.LogLevel=void 0,t.parseLogLevel=s,t.getLogLevelFromEnv=a,t.generateRequestId=function(){return`req_${Date.now()}_${Math.random().toString(36).substring(2,9)}`},function(e){e[e.SILENT=0]="SILENT",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG"}(n||(t.LogLevel=n={}));class r{constructor(e=n.SILENT,t="[Glide]",o=!1){this.level=e,this.prefix=t,this.enableGrouping=o}debug(e,t){this.level>=n.DEBUG&&this.log("debug",e,t)}info(e,t){this.level>=n.INFO&&this.log("info",e,t)}warn(e,t){this.level>=n.WARN&&this.log("warn",e,t)}error(e,t){this.level>=n.ERROR&&this.log("error",e,t)}log(e,t,n){const o=(new Date).toISOString(),r=n?this.sanitizeFields(n):{},i=`${this.prefix} ${o} [${e.toUpperCase()}] ${t}`;this.enableGrouping&&Object.keys(r).length>0?(console.groupCollapsed(i),Object.entries(r).forEach((([e,t])=>{console.log(`${e}:`,t)})),console.groupEnd()):Object.keys(r).length>0?console[e](i,r):console[e](i)}sanitizeFields(e){const t={};for(const[n,o]of Object.entries(e))t[n]=this.sanitizeValue(n,o);return t}sanitizeValue(e,t){const n=["apikey","api_key","apiKey","token","accesstoken","access_token","accessToken","password","passwd","pwd","secret","credential","authorization","auth","cookie","session"],o=e.toLowerCase();for(const e of n)if(o.includes(e.toLowerCase()))return"string"==typeof t&&t.length>4?t.substring(0,4)+"****[REDACTED]":"****[REDACTED]";if("string"==typeof t){if(/^\+?[1-9]\d{6,14}$/.test(t))return t.substring(0,6)+"****";if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){const[,e]=t.split("@");return"****@"+e}if(t.includes("://")&&t.includes("@"))return t.replace(/\/\/([^:]+):([^@]+)@/,"//****:****@");if(t.startsWith("eyJ")&&3===t.split(".").length)return t.substring(0,10)+"****[JWT]";if(/\b\d{13,19}\b/.test(t))return t.substring(0,4)+"****"+t.substring(t.length-4)}return t&&"object"==typeof t&&!Array.isArray(t)?this.sanitizeFields(t):Array.isArray(t)?t.map(((t,n)=>this.sanitizeValue(`${e}[${n}]`,t))):t}}t.ConsoleLogger=r,t.NoopLogger=class{debug(e,t){}info(e,t){}warn(e,t){}error(e,t){}};class i{constructor(e,t,o){this.buffer=[],this.flushInterval=5e3,this.maxBufferSize=100,this.endpoint=e,this.apiKey=t,this.localLogger=o||new r(n.ERROR),"undefined"!=typeof window&&(setInterval((()=>this.flush()),this.flushInterval),window.addEventListener("beforeunload",(()=>this.flush())))}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}log(e,t,n){const o={timestamp:(new Date).toISOString(),level:e,message:t,fields:n,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0};this.buffer.push(o),this.localLogger[e](t,n),this.buffer.length>=this.maxBufferSize&&this.flush()}flush(){return o(this,void 0,void 0,(function*(){if(0===this.buffer.length)return;const e=[...this.buffer];this.buffer=[];try{yield fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({logs:e})})}catch(e){this.localLogger.error("Failed to send logs to remote server",{error:e})}}))}}function s(e){switch(e.toLowerCase()){case"debug":return n.DEBUG;case"info":return n.INFO;case"warn":case"warning":return n.WARN;case"error":return n.ERROR;default:return n.SILENT}}function a(){if("undefined"!=typeof localStorage){const e=localStorage.getItem("GLIDE_LOG_LEVEL");if(e)return s(e);const t=localStorage.getItem("GLIDE_DEBUG");if("true"===t||"1"===t)return n.DEBUG}if("undefined"!=typeof window&&window.location){const e=new URLSearchParams(window.location.search),t=e.get("glide_log_level");if(t)return s(t);if(e.has("glide_debug"))return n.DEBUG}return n.SILENT}t.RemoteLogger=i,t.PerformanceTimer=class{constructor(e){this.marks=new Map,this.startTime=performance.now(),this.logger=e}mark(e){this.marks.set(e,performance.now())}logElapsed(e,t){const n=performance.now()-this.startTime;this.logger.debug(e,Object.assign(Object.assign({},t),{elapsedMs:n,elapsed:`${n.toFixed(2)}ms`}))}logMarkDuration(e,t,n,o){const r=this.marks.get(e),i=this.marks.get(t);if(r&&i){const s=i-r;this.logger.debug(n,Object.assign(Object.assign({},o),{durationMs:s,duration:`${s.toFixed(2)}ms`,fromMark:e,toMark:t}))}}};class l{static setDefaultLevel(e){this.defaultLevel=e}static setDefaultLogger(e){this.defaultLogger=e}static create(e){var t,n;if(null==e?void 0:e.custom)return e.custom;if(this.defaultLogger)return this.defaultLogger;const o=null!==(n=null!==(t=null==e?void 0:e.level)&&void 0!==t?t:a())&&void 0!==n?n:this.defaultLevel;if(null==e?void 0:e.remote){const t=new r(o,null==e?void 0:e.prefix);return new i(e.remote.endpoint,e.remote.apiKey,t)}return new r(o,null==e?void 0:e.prefix)}}t.LoggerFactory=l,l.defaultLevel=n.SILENT,l.defaultLogger=null},566:(e,t)=>{function n(e){return t.E164_REGEX.test(e)}function o(e){return!!/^\d{3}$/.test(e.mcc)&&!!/^\d{2,3}$/.test(e.mnc)}function r(e){return!(!e.session_key||e.session_key.length<16)}function i(e){return e===t.USE_CASE.GET_PHONE_NUMBER||e===t.USE_CASE.VERIFY_PHONE_NUMBER}function s(e,n,o){return{code:e,message:t.ERROR_MESSAGES[e],request_id:o,timestamp:(new Date).toISOString(),details:n}}function a(e){return t.ERROR_STATUS_CODES[e]||500}function l(e){return e&&"string"==typeof e.protocol&&e.data&&e.data.dcql_query}function c(e){return e&&e.url&&"string"==typeof e.url}function u(e){return e&&"string"==typeof e.code&&"string"==typeof e.message}Object.defineProperty(t,"__esModule",{value:!0}),t.E164_REGEX=t.ERROR_STATUS_CODES=t.ERROR_MESSAGES=t.ERROR_CODE=t.AUTHENTICATION_STRATEGY=t.USE_CASE=void 0,t.validatePhoneNumber=n,t.validatePLMN=o,t.validateSession=r,t.validateUseCase=i,t.createErrorResponse=s,t.getErrorStatusCode=a,t.isTS43Data=l,t.isLinkData=c,t.isErrorResponse=u,t.USE_CASE={GET_PHONE_NUMBER:"GetPhoneNumber",VERIFY_PHONE_NUMBER:"VerifyPhoneNumber"},t.AUTHENTICATION_STRATEGY={TS43:"ts43",LINK:"link",DESKTOP:"desktop"},t.ERROR_CODE={INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",MISSING_REQUIRED_FIELD:"MISSING_REQUIRED_FIELD",INVALID_USE_CASE:"INVALID_USE_CASE",INVALID_SESSION:"INVALID_SESSION",SESSION_EXPIRED:"SESSION_EXPIRED",CARRIER_NOT_ELIGIBLE:"CARRIER_NOT_ELIGIBLE",UNSUPPORTED_PLATFORM:"UNSUPPORTED_PLATFORM",PHONE_NUMBER_MISMATCH:"PHONE_NUMBER_MISMATCH",INVALID_CREDENTIAL:"INVALID_CREDENTIAL",VERIFICATION_FAILED:"VERIFICATION_FAILED",USE_CASE_MISMATCH:"USE_CASE_MISMATCH",RATE_LIMIT_EXCEEDED:"RATE_LIMIT_EXCEEDED",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE"},t.ERROR_MESSAGES={[t.ERROR_CODE.INVALID_PHONE_NUMBER]:"Phone number must be in E.164 format",[t.ERROR_CODE.MISSING_REQUIRED_FIELD]:"Required field is missing",[t.ERROR_CODE.INVALID_USE_CASE]:"Use case must be 'GetPhoneNumber' or 'VerifyPhoneNumber'",[t.ERROR_CODE.INVALID_SESSION]:"Session not found or expired",[t.ERROR_CODE.SESSION_EXPIRED]:"Session has expired",[t.ERROR_CODE.CARRIER_NOT_ELIGIBLE]:"Your carrier does not support this verification method",[t.ERROR_CODE.UNSUPPORTED_PLATFORM]:"Your platform is not supported",[t.ERROR_CODE.PHONE_NUMBER_MISMATCH]:"Phone number does not match the device",[t.ERROR_CODE.INVALID_CREDENTIAL]:"Invalid or expired credential",[t.ERROR_CODE.VERIFICATION_FAILED]:"Phone number verification failed",[t.ERROR_CODE.USE_CASE_MISMATCH]:"Session was prepared for a different use case",[t.ERROR_CODE.RATE_LIMIT_EXCEEDED]:"Too many requests. Please try again later",[t.ERROR_CODE.INTERNAL_SERVER_ERROR]:"An unexpected error occurred",[t.ERROR_CODE.SERVICE_UNAVAILABLE]:"Service temporarily unavailable"},t.ERROR_STATUS_CODES={[t.ERROR_CODE.INVALID_PHONE_NUMBER]:400,[t.ERROR_CODE.MISSING_REQUIRED_FIELD]:400,[t.ERROR_CODE.INVALID_USE_CASE]:400,[t.ERROR_CODE.INVALID_SESSION]:404,[t.ERROR_CODE.SESSION_EXPIRED]:404,[t.ERROR_CODE.CARRIER_NOT_ELIGIBLE]:422,[t.ERROR_CODE.UNSUPPORTED_PLATFORM]:422,[t.ERROR_CODE.PHONE_NUMBER_MISMATCH]:422,[t.ERROR_CODE.INVALID_CREDENTIAL]:422,[t.ERROR_CODE.VERIFICATION_FAILED]:422,[t.ERROR_CODE.USE_CASE_MISMATCH]:422,[t.ERROR_CODE.RATE_LIMIT_EXCEEDED]:429,[t.ERROR_CODE.INTERNAL_SERVER_ERROR]:500,[t.ERROR_CODE.SERVICE_UNAVAILABLE]:503},t.E164_REGEX=/^\+[1-9]\d{1,14}$/,t.default={USE_CASE:t.USE_CASE,AUTHENTICATION_STRATEGY:t.AUTHENTICATION_STRATEGY,ERROR_CODE:t.ERROR_CODE,ERROR_MESSAGES:t.ERROR_MESSAGES,ERROR_STATUS_CODES:t.ERROR_STATUS_CODES,E164_REGEX:t.E164_REGEX,validatePhoneNumber:n,validatePLMN:o,validateSession:r,validateUseCase:i,isTS43Data:l,isLinkData:c,isErrorResponse:u,createErrorResponse:s,getErrorStatusCode:a}},895:function(e,t,n){var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),s=0;s<n.length;s++)"default"!==n[s]&&r(t,e,n[s]);return i(t,e),t}),a=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthClient=void 0;const l=s(n(566)),c=n(931),u=n(192),d=n(495),h=n(928),p=n(802),E=n(544),g=n(244);t.PhoneAuthClient=class{constructor(e={}){var t,o,r,i;this.crossDeviceActive=!1,this.retryCount=0,this.sessionCache=new Map,this.baseTimeout=e.timeout||3e4,this.config={endpoints:{prepare:(null===(t=e.endpoints)||void 0===t?void 0:t.prepare)||"/api/magic-auth/prepare",process:(null===(o=e.endpoints)||void 0===o?void 0:o.process)||"/api/magic-auth/process",polling:null===(r=e.endpoints)||void 0===r?void 0:r.polling},timeout:e.timeout||3e4,pollingInterval:e.pollingInterval||2e3,maxPollingAttempts:e.maxPollingAttempts||30,debug:e.debug||!1,aggregatorId:e.aggregatorId||"default",devEnv:e.devEnv,devtools:e.devtools},this.debug=this.config.debug,e.devEnv&&console.log(`[PhoneAuth] Initialized with devEnv: ${e.devEnv}`),this.callbacks={onCrossDeviceDetected:e.onCrossDeviceDetected,onRetryAttempt:e.onRetryAttempt},this.logger=h.LoggerFactory.create({level:e.logLevel,prefix:"[PhoneAuth]",remote:e.remoteLogging,custom:e.logger}),(null===(i=e.devtools)||void 0===i?void 0:i.showMobileConsole)&&"undefined"!=typeof window&&Promise.resolve().then((()=>s(n(545)))).then((({MobileDebugConsole:e})=>{e.init(),console.log("[PhoneAuth] Mobile debug console enabled")})).catch((e=>{console.error("[PhoneAuth] Failed to load mobile debug console:",e)})),this.setupCacheCleanup()}getUserFriendlyMessage(e){return"string"==typeof e?(0,u.getUserMessage)({code:e}):(0,u.getUserMessage)(e)}logError(e,t){const n=(0,u.createErrorBreadcrumb)(e),o=(0,u.serializeError)(e);!this.debug&&(0,u.isUserError)(e)||console.error("[PhoneAuth] Error:",Object.assign(Object.assign({},o),{breadcrumb:n,context:t})),e.traceId&&console.debug("[PhoneAuth] Trace Context:",{traceId:e.traceId,spanId:e.spanId,requestId:e.requestId})}isSupported(){return"undefined"!=typeof window&&"DigitalCredential"in window}getBrowserSupportInfo(){if("undefined"==typeof window)return{supported:!1,browser:"unknown",message:"Not running in a browser environment"};const e=navigator.userAgent,t=/Chrome/.test(e)&&/Google Inc/.test(navigator.vendor),n=/Edg\//.test(e);return this.isSupported()?{supported:!0,browser:t?c.BrowserName.CHROME:n?c.BrowserName.EDGE:c.BrowserName.OTHER}:t||n?{supported:!1,browser:t?c.BrowserName.CHROME:c.BrowserName.EDGE,message:"Digital Credentials API is not enabled. Please enable the #web-identity-digital-credentials flag.",helpUrl:t?"chrome://flags/#web-identity-digital-credentials":"edge://flags/#web-identity-digital-credentials"}:{supported:!1,browser:"other",message:"Your browser doesn't support the Digital Credentials API. Please use Chrome or Edge with the #web-identity-digital-credentials flag enabled."}}verify(e){return a(this,void 0,void 0,(function*(){return this.retryCount=0,this.lastRequest=e,this.verifyWithRetry(e,2)}))}verifyWithRetry(e,t){return a(this,void 0,void 0,(function*(){var n,o;try{const t=yield this.preparePhoneRequest(e),n=yield this.invokeSecurePrompt(t);if(n&&"object"==typeof n&&"strategy"in n)throw this.createError(u.PhoneAuthErrorCode.INVALID_RESPONSE,"Headless mode is not supported in authenticatePhoneNumber. Use preparePhoneRequest and invokeSecurePrompt directly for headless mode.");const o=n;if(!e.use_case)throw this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});const r=e.use_case===l.USE_CASE.GET_PHONE_NUMBER?yield this.getPhoneNumber(o,t.session):yield this.verifyPhoneNumber(o,t.session);return this.cacheSession(e,r),r}catch(r){const i=(0,u.isPhoneAuthError)(r)?r:(0,u.parseBackendError)(r);if(this.shouldRetry(i)&&this.retryCount<t){this.retryCount++,null===(o=(n=this.callbacks).onRetryAttempt)||void 0===o||o.call(n,this.retryCount,t),this.debug&&console.log(`[PhoneAuth] Retrying verification (attempt ${this.retryCount+1}/${t+1})`),yield this.delay(Math.min(1e3*Math.pow(2,this.retryCount-1),5e3));const r=this.getCachedSession(e);return r?(this.debug&&console.log("[PhoneAuth] Using cached session result"),r):this.verifyWithRetry(e,t)}if(i.context={step:"complete",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,attemptNumber:this.retryCount+1,maxAttempts:t+1},this.logError(i,{options:e}),(0,u.isPhoneAuthError)(r)){if(r.context)throw r;throw{code:i.code,message:r.message,details:r.details,status:r.status,requestId:r.requestId,timestamp:r.timestamp,retryAfter:r.retryAfter,browserError:r.browserError,context:{useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0,attemptNumber:this.retryCount+1,maxAttempts:t+1}}}throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"Verification failed",r)}}))}getPhoneNumberComplete(e){return a(this,void 0,void 0,(function*(){return this.verify(Object.assign({use_case:l.USE_CASE.GET_PHONE_NUMBER},e))}))}verifyPhoneNumberComplete(e,t){return a(this,void 0,void 0,(function*(){return this.verify(Object.assign({use_case:l.USE_CASE.VERIFY_PHONE_NUMBER,phone_number:e},t))}))}preparePhoneRequest(e){return a(this,void 0,void 0,(function*(){var t,n,o;if(e.phone_number){const t=(0,d.validatePhoneNumber)(e.phone_number);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.INVALID_PHONE_NUMBER,t.error,{field:"phone_number"})}if(e.plmn){const t=(0,d.validatePlmn)(e.plmn);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.BAD_REQUEST,t.error,{field:"plmn"})}if(!e.use_case&&(!(null===(t=e.options)||void 0===t?void 0:t.parent_session_id)||e.phone_number||e.plmn))throw this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});if(!e.phone_number&&!e.plmn&&!(null===(n=e.options)||void 0===n?void 0:n.parent_session_id))throw e.use_case===l.USE_CASE.GET_PHONE_NUMBER?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"PLMN (MCC/MNC) is required for GetPhoneNumber. Please provide carrier network information.",{field:"plmn",useCase:"GetPhoneNumber"}):e.use_case===l.USE_CASE.VERIFY_PHONE_NUMBER?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Phone number is required for VerifyPhoneNumber",{field:"phoneNumber",useCase:"VerifyPhoneNumber"}):this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Either phone number or PLMN (MCC/MNC) must be provided",{field:"phoneNumber,plmn"});!(null===(o=e.options)||void 0===o?void 0:o.parent_session_id)||e.phone_number||e.plmn||this.debug&&console.log("[PhoneAuth] Using parent_session_id: %s, use_case: %s",e.options.parent_session_id,e.use_case||"not provided");const r=`web-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,i={use_case:e.use_case,phone_number:e.phone_number,plmn:e.plmn?{mcc:e.plmn.mcc,mnc:e.plmn.mnc}:void 0,id:r,client_info:{user_agent:navigator.userAgent,platform:navigator.platform},options:e.options};this.log("Preparing phone verification request",i);try{const t=yield this.fetchWithTimeout(this.config.endpoints.prepare,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!t.ok){let n=null;try{n=yield t.json(),n=Object.assign(Object.assign({},n),{status:t.status})}catch(e){n={status:t.status,statusText:t.statusText}}const o=(0,u.parseBackendError)(n);throw o.context={step:"prepare",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},o.details=Object.assign(Object.assign({},o.details),{endpoint:"prepare",status:t.status}),o}const n=yield t.json();if(this.log("Phone verification request prepared",n),!n.authentication_strategy||!n.data||!n.session)throw this.createError(u.PhoneAuthErrorCode.INVALID_RESPONSE,"Invalid response format from backend");return n}catch(t){if(this.isAuthError(t))throw t;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to prepare verification request",{originalError:t,context:{step:"prepare",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0}})}}))}invokeSecurePrompt(e,t){return a(this,void 0,void 0,(function*(){var n,o,r,i,s,d,h,f,m,R,v,_,b,A,y;let S;try{S="undefined"!=typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(t){this.debug&&console.log("[PhoneAuth] structuredClone failed, using JSON fallback:",t),S=JSON.parse(JSON.stringify(e))}console.log("[PhoneAuth] === invokeSecurePrompt called ==="),console.log("[PhoneAuth] Session cache size:",this.sessionCache.size),console.log("[PhoneAuth] Retry count:",this.retryCount),console.log("[PhoneAuth] PrepareResponse received:",JSON.stringify(S,null,2));const O=t,I=(S.authentication_strategy,null!==(n=null==O?void 0:O.preventDefaultUI)&&void 0!==n&&n),C=null!==(o=null==O?void 0:O.executionMode)&&void 0!==o?o:"standard";if(S.authentication_strategy===l.AUTHENTICATION_STRATEGY.TS43){if(!this.isSupported())throw this.createError(u.PhoneAuthErrorCode.BROWSER_NOT_SUPPORTED,"Your browser does not support the Digital Credentials API required for TS43 authentication");const e=S.data,t={digital:{requests:[{protocol:e.protocol,data:e.data}]}};this.log("Invoking TS43 secure authentication prompt",t);const n=()=>a(this,void 0,void 0,(function*(){var e,n;try{const e=t,n=yield navigator.credentials.get(e);if(!n||!("data"in n)||!n.data){const e=this.getBrowserSupportInfo();if(e.browser===c.BrowserName.CHROME||e.browser===c.BrowserName.EDGE)throw new Error(`Digital Credentials API returned no response. This usually means the browser feature flag is not enabled. Please ensure the ${e.helpUrl||"#web-identity-digital-credentials flag"} is set to "Enabled" (not "Default" or "Disabled") and restart your browser.`);throw new Error("Digital Credentials API returned no response. Your browser may not fully support this feature.")}const o=n.data;return this.log("Secure credential response received",o),o.vp_token}catch(t){const o=t,r={name:o.name||"UnknownError",message:o.message||"Unknown error occurred",stack:o.stack,code:o.code},i={step:"prompt",timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href,authentication_strategy:S.authentication_strategy,hasSession:!!S.session};if(o.name===c.BrowserError.NOT_ALLOWED)throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"User denied the credential request or the request timed out",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NETWORK&&o.code===c.BrowserErrorCode.USER_CANCELLED_DC_API)throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled by user",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NETWORK)throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Network error occurred while retrieving credentials",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NOT_SUPPORTED)throw this.createError(u.PhoneAuthErrorCode.BROWSER_NOT_SUPPORTED,"Your browser does not support the Digital Credentials API",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.SECURITY)throw this.createError(u.PhoneAuthErrorCode.FORBIDDEN,"Security error: This feature requires a secure context (HTTPS)",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.ABORT||(null===(e=r.message)||void 0===e?void 0:e.includes("The operation was aborted"))||(null===(n=r.message)||void 0===n?void 0:n.includes("User cancelled")))throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled",{originalError:t,browserError:r,context:i});throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,`Digital Credentials API error: ${o.message||"Unknown error"}`,{originalError:t,browserError:r,context:i})}})),o=()=>a(this,void 0,void 0,(function*(){var e,t;try{const t=yield n();return null===(e=null==O?void 0:O.onTriggerAttempt)||void 0===e||e.call(O,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!0}),t}catch(e){throw null===(t=null==O?void 0:O.onTriggerAttempt)||void 0===t||t.call(O,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!1,error:e}),e}})),r={promise:null};try{const e=yield o();r.promise=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:S.session,authenticated:!0})}catch(e){r.promise=Promise.reject(e)}if("extended"===C){const e={strategy:"ts43",session:S.session,credential:r.promise,trigger:()=>a(this,void 0,void 0,(function*(){const e=yield o();r.promise=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:S.session,authenticated:!0})})),cancel:()=>{r.promise=Promise.reject(this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled"))}};return Object.defineProperty(e,"credential",{get:()=>r.promise,enumerable:!0,configurable:!0}),e}{const e=yield r.promise;return{[S.session.session_key]:e.credential}}}if(S.authentication_strategy!==l.AUTHENTICATION_STRATEGY.DESKTOP){if(S.authentication_strategy===l.AUTHENTICATION_STRATEGY.LINK){const e=S.data,t=new E.LinkHandler,n=()=>{var t,n;try{window.open(e.url,"_blank"),null===(t=null==O?void 0:O.onTriggerAttempt)||void 0===t||t.call(O,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!0})}catch(t){null===(n=null==O?void 0:O.onTriggerAttempt)||void 0===n||n.call(O,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!1,error:t})}};!1!==(null==O?void 0:O.autoTrigger)&&n(),console.log("[PhoneAuth Client] Link polling config:",{fromOptions:null==O?void 0:O.pollingEndpoint,fromClientConfig:null===(b=this.config.endpoints)||void 0===b?void 0:b.polling,finalPollingEndpoint:(null==O?void 0:O.pollingEndpoint)||(null===(A=this.config.endpoints)||void 0===A?void 0:A.polling)});const o={pollingEndpoint:(null==O?void 0:O.pollingEndpoint)||(null===(y=this.config.endpoints)||void 0===y?void 0:y.polling),pollingInterval:(null==O?void 0:O.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==O?void 0:O.maxPollingAttempts)||this.config.maxPollingAttempts||30,devEnv:(null==O?void 0:O.devEnv)||this.config.devEnv,onLinkOpened:void 0,onStatusUpdate:void 0};if(console.log("[PhoneAuth Client] Final Link polling options:",o),"extended"===C){let r=!1,i=null;i=t.invoke(S,o),r=!0;const s=i.then((e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:S.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")})),l=()=>a(this,void 0,void 0,(function*(){if(!r){r=!0,i||(i=t.invoke(S,o));const e=yield i;if(e.authenticated&&e.credential)return{credential:e.credential,session:S.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}const e=yield i;if(e.authenticated&&e.credential)return{credential:e.credential,session:S.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")})),c={strategy:"link",session:S.session,credential:s,data:{app_url:e.url},trigger:n,start_polling:l,stop_polling:()=>t.cleanup(),cancel:()=>{t.cancel(),t.cleanup()},is_polling:!1};return Object.defineProperty(c,"is_polling",{get:()=>t.isPolling(),enumerable:!0,configurable:!0}),c}{const e=t.invoke(S,o).then((e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:S.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")})),n=yield e,r=this.config.aggregatorId||"default";return{[r]:n.credential}}}throw this.createError(u.PhoneAuthErrorCode.UNSUPPORTED_STRATEGY,`Unknown authentication strategy: ${S.authentication_strategy}`)}{const e=S.data,t=new p.DesktopHandler,n={iosQRCode:(null===(r=e.data)||void 0===r?void 0:r.ios_qr_image)||e.ios_qr_image||(null===(i=e.data)||void 0===i?void 0:i.qr_code_image)||e.qr_code_image||e.qr_code||"",androidQRCode:(null===(s=e.data)||void 0===s?void 0:s.android_qr_image)||e.android_qr_image,iosUrl:(null===(d=e.data)||void 0===d?void 0:d.ios_url)||e.ios_url,androidUrl:(null===(h=e.data)||void 0===h?void 0:h.android_url)||e.android_url},o={ios_qr_image:(null===(f=e.data)||void 0===f?void 0:f.ios_qr_image)||e.ios_qr_image,android_qr_image:(null===(m=e.data)||void 0===m?void 0:m.android_qr_image)||e.android_qr_image,qr_code:(null===(R=e.data)||void 0===R?void 0:R.qr_code_image)||e.qr_code_image||e.qr_code,challenge:null===(v=e.data)||void 0===v?void 0:v.challenge},l=(null==O?void 0:O.pollingEndpoint)||(null===(_=this.config.endpoints)||void 0===_?void 0:_.polling),c=Object.assign(Object.assign({},O),{pollingEndpoint:l,pollingInterval:(null==O?void 0:O.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==O?void 0:O.maxPollingAttempts)||this.config.maxPollingAttempts||30,devEnv:(null==O?void 0:O.devEnv)||this.config.devEnv,onQRCodeReady:void 0,onStatusUpdate:void 0}),E=!I;let b,A;console.log("[Desktop] Modal decision:",{preventDefaultUI:I,showModal:E,executionMode:C,hasOptions:!!O}),E?(console.log("[Desktop] Creating modal with QR data:",n),b=new g.AuthModal(null==O?void 0:O.modalOptions,null==O?void 0:O.callbacks),b.setCloseCallback((()=>{this.log("Desktop QR modal closed by user, cancelling polling"),t.cancel()})),c.onQRCodeReady=e=>{console.log("[Desktop] onQRCodeReady callback triggered:",e),b.showQRCode(e,"Scan with your mobile device")},c.onStatusUpdate=e=>{"pending"===e.status?b.updateStatus("Waiting for authentication..."):"authenticated"===e.status?(b.updateStatus("Authentication successful!"),setTimeout((()=>b.close()),1500)):"expired"===e.status?b.updateStatus("QR code expired",!0):"error"===e.status&&b.updateStatus("Authentication failed",!0)},A=b):console.log("[Desktop] Modal not shown - preventDefaultUI is true");const y=()=>t.invoke(S,c).then((e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:S.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Desktop authentication failed")}));if("extended"===C){const e=new Promise(((e,t)=>{y().then(e).catch(t)})),n=()=>a(this,void 0,void 0,(function*(){return e})),r=()=>{t.cleanup(),b&&b.close()},i=()=>{t.cancel(),t.cleanup(),b&&b.close()},s={strategy:"desktop",session:S.session,credential:e,qr_code_data:o,modal_ref:A,start_polling:n,stop_polling:r,cancel:i,is_polling:!1};return Object.defineProperty(s,"is_polling",{get:()=>t.isPolling(),enumerable:!0,configurable:!0}),s}try{const t=yield y();let n="default";return e&&"object"==typeof e&&(e.data&&"object"==typeof e.data&&(n=e.data.session_id||n),n&&"default"!==n||(n=e.session_id||n)),{[n]:t.credential}}finally{t.cleanup(),b&&b.close()}}}))}getPhoneNumber(e,t){return a(this,void 0,void 0,(function*(){const n=this.extractCredentialString(e),o={session:t,credential:n,use_case:l.USE_CASE.GET_PHONE_NUMBER};this.config.debug?this.log("Getting phone number from credential",{session:t,credential:n?n.substring(0,50)+"...":"undefined",endpoint:this.config.endpoints.process||"/api/phone-auth/process"}):this.log("Getting phone number from credential");try{const e=yield this.fetchWithTimeout(this.config.endpoints.process||"/api/phone-auth/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!e.ok){const t=yield this.extractErrorDetails(e),n=(0,u.parseBackendError)(t);throw n.context={step:"process",timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},n}const t=yield e.json();if(this.log("Phone number retrieved",{phone_number:t.phone_number}),!t.phone_number)throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"No phone number returned from server");return t}catch(e){if(this.isAuthError(e))throw e;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to get phone number",{originalError:e,context:{step:"process",timestamp:(new Date).toISOString()}})}}))}verifyPhoneNumber(e,t){return a(this,void 0,void 0,(function*(){const n=this.extractCredentialString(e),o={session:t,credential:n,use_case:l.USE_CASE.VERIFY_PHONE_NUMBER};this.config.debug?this.log("Verifying phone number with credential",{session:t,credential:n?n.substring(0,50)+"...":"undefined",endpoint:this.config.endpoints.process||"/api/phone-auth/process"}):this.log("Verifying phone number");try{const e=yield this.fetchWithTimeout(this.config.endpoints.process||"/api/phone-auth/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!e.ok){const t=yield this.extractErrorDetails(e),n=(0,u.parseBackendError)(t);throw n.context={step:"process",timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},n}const t=yield e.json();if(this.log("Phone number verification result",{phone_number:t.phone_number,verified:t.verified}),!t.phone_number)throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"No phone number returned from server");return t}catch(e){if(this.isAuthError(e))throw e;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to verify phone number",{originalError:e,context:{step:"process",timestamp:(new Date).toISOString()}})}}))}extractCredentialString(e){if("string"==typeof e)return e;let t=e[this.config.aggregatorId||"glide"];if(!t&&e.glide&&(t=e.glide),!t&&e.default&&(t=e.default),!t){const n=Object.keys(e);n.length>0&&(t=e[n[0]])}return Array.isArray(t)?t[0]:t}extractErrorDetails(e){return a(this,void 0,void 0,(function*(){try{const t=yield e.json();return Object.assign(Object.assign({},t),{status:e.status})}catch(t){return{status:e.status,statusText:e.statusText}}}))}fetchWithTimeout(e,t){return a(this,void 0,void 0,(function*(){const n=new AbortController,o=setTimeout((()=>n.abort()),this.config.timeout);try{return yield fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}))}finally{clearTimeout(o)}}))}createError(e,t,n){const o={code:e,message:t,details:(null==n?void 0:n.originalError)?Object.assign(Object.assign({},n),{originalError:void 0}):n};return(null==n?void 0:n.browserError)&&(o.browserError=n.browserError),(null==n?void 0:n.context)&&(o.context=n.context),(null==n?void 0:n.status)&&(o.status=n.status),(null==n?void 0:n.requestId)&&(o.requestId=n.requestId),(null==n?void 0:n.timestamp)&&(o.timestamp=n.timestamp),(null==n?void 0:n.retryAfter)&&(o.retryAfter=n.retryAfter),o}isAuthError(e){return e&&"string"==typeof e.code&&"string"==typeof e.message}log(...e){this.debug&&console.log("[PhoneAuth]",...e)}shouldRetry(e){var t,n,o;if(e.status&&e.status>=400&&e.status<500)return!1;if(["USER_DENIED","BROWSER_NOT_SUPPORTED","INVALID_PHONE_NUMBER","INVALID_PARAMETERS","MISSING_PARAMETERS","UNPROCESSABLE_ENTITY","USE_CASE_MISMATCH","PHONE_NUMBER_MISMATCH","VERIFICATION_FAILED","INVALID_CREDENTIAL","CARRIER_NOT_ELIGIBLE","SESSION_EXPIRED","INVALID_SESSION"].includes(e.code))return!1;const r=(null===(t=e.details)||void 0===t?void 0:t.errorType)&&["CROSS_DEVICE_TIMEOUT","CROSS_DEVICE_CONNECTION_LOST","CROSS_DEVICE_INCOMPLETE"].includes(e.details.errorType);return["NETWORK_ERROR","REQUEST_TIMEOUT","GATEWAY_TIMEOUT","SERVICE_UNAVAILABLE","BAD_GATEWAY","INTERNAL_SERVER_ERROR"].includes(e.code)||r||"NetworkError"===(null===(n=e.browserError)||void 0===n?void 0:n.name)&&19!==(null===(o=e.browserError)||void 0===o?void 0:o.code)}analyzeCrossDeviceError(e,t){var n;const o=e,r="AbortError"===o.name&&this.crossDeviceActive||(null===(n=o.message)||void 0===n?void 0:n.includes("timeout"))&&this.crossDeviceActive,i="NetworkError"===o.name&&19!==o.code&&this.crossDeviceActive;return r?{code:"REQUEST_TIMEOUT",message:"Cross-device authentication timed out. The QR code may have expired or the phone connection was lost.",details:{suggestion:"Try again and complete the phone authentication within 2 minutes",originalError:o.message,crossDevice:!0,errorType:"CROSS_DEVICE_TIMEOUT"},browserError:e.browserError}:i?{code:"NETWORK_ERROR",message:"Connection lost during cross-device authentication. Please ensure both devices have stable internet.",details:{suggestion:"Check your network connection on both devices and try again",originalError:o.message,crossDevice:!0,errorType:"CROSS_DEVICE_CONNECTION_LOST"},browserError:e.browserError}:e}cacheSession(e,t){const n=this.getCacheKey(e);this.sessionCache.set(n,{timestamp:Date.now(),data:t})}getCachedSession(e){const t=this.getCacheKey(e),n=this.sessionCache.get(t);return n?Date.now()-n.timestamp>3e5?(this.sessionCache.delete(t),null):n.data:null}getCacheKey(e){var t,n;return`${e.use_case}-${e.phone_number||"no-phone"}-${(null===(t=e.plmn)||void 0===t?void 0:t.mcc)||""}-${(null===(n=e.plmn)||void 0===n?void 0:n.mnc)||""}`}setupCacheCleanup(){"undefined"!=typeof window&&setInterval((()=>{const e=Date.now();for(const[t,n]of this.sessionCache.entries())e-n.timestamp>3e5&&this.sessionCache.delete(t)}),6e4)}delay(e){return new Promise((t=>setTimeout(t,e)))}}},192:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthErrorCode=void 0,t.isPhoneAuthError=function(e){return e&&"string"==typeof e.code&&"string"==typeof e.message},t.isUserError=s,t.getUserMessage=a,t.isErrorCode=function(e,t){return e.code===t},t.getRetryDelay=function(e){return e.code===t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED&&e.retryAfter?1e3*e.retryAfter:null},t.isRetryableError=function(e){return[t.PhoneAuthErrorCode.NETWORK_ERROR,t.PhoneAuthErrorCode.SERVICE_UNAVAILABLE,t.PhoneAuthErrorCode.DOWNSTREAM_SERVICE_ERROR,t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED].includes(e.code)},t.parseBackendError=function(e){var n,o;if(e&&"object"==typeof e&&(e.code||e.error)){const t=e.code||e.error,o={code:t,message:e.message||a({code:t}),status:e.status,requestId:e.requestId||e.request_id,timestamp:e.timestamp,details:e.details,traceId:e.trace_id||e.traceId,spanId:e.span_id||e.spanId,service:e.service};return(null===(n=e.details)||void 0===n?void 0:n.retryAfter)&&(o.retryAfter=e.details.retryAfter),o}if(e&&e.status){const n=function(e){switch(e){case 400:return t.PhoneAuthErrorCode.BAD_REQUEST;case 401:return t.PhoneAuthErrorCode.UNAUTHORIZED;case 403:return t.PhoneAuthErrorCode.FORBIDDEN;case 404:return t.PhoneAuthErrorCode.NOT_FOUND;case 409:return t.PhoneAuthErrorCode.CONFLICT;case 422:return t.PhoneAuthErrorCode.UNPROCESSABLE_ENTITY;case 429:return t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED;case 500:default:return t.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR;case 502:return t.PhoneAuthErrorCode.BAD_GATEWAY;case 503:return t.PhoneAuthErrorCode.SERVICE_UNAVAILABLE;case 504:return t.PhoneAuthErrorCode.GATEWAY_TIMEOUT}}(e.status);return{code:n,message:e.message||a({code:n}),status:e.status,requestId:null===(o=e.headers)||void 0===o?void 0:o["x-request-id"]}}return{code:t.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,message:"An unexpected error occurred",status:500}},t.serializeError=function(e){return{code:e.code,message:e.message,status:e.status,requestId:e.requestId,timestamp:e.timestamp,traceId:e.traceId,spanId:e.spanId,service:e.service,retryAfter:e.retryAfter,browserError:e.browserError,context:e.context,details:l(e.details),sdkVersion:o.SDK_VERSION,errorCapturedAt:(new Date).toISOString()}},t.createErrorBreadcrumb=function(e){var t,n,o;return{category:"phone-auth",message:`Phone Auth Error: ${e.code}`,level:s(e)?"warning":"error",data:{code:e.code,step:null===(t=e.context)||void 0===t?void 0:t.step,useCase:null===(n=e.context)||void 0===n?void 0:n.useCase,requestId:e.requestId,browserErrorType:null===(o=e.browserError)||void 0===o?void 0:o.name}}};const o=n(50);t.PhoneAuthErrorCode={BAD_REQUEST:"BAD_REQUEST",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_PARAMETERS:"INVALID_PARAMETERS",MISSING_PARAMETERS:"MISSING_PARAMETERS",INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",INVALID_MCC_MNC:"INVALID_MCC_MNC",UNAUTHORIZED:"UNAUTHORIZED",INVALID_CREDENTIALS:"INVALID_CREDENTIALS",EXPIRED_TOKEN:"EXPIRED_TOKEN",TOKEN_ACQUISITION_FAILED:"TOKEN_ACQUISITION_FAILED",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTH_HEADER:"MISSING_AUTH_HEADER",FORBIDDEN:"FORBIDDEN",INSUFFICIENT_PERMISSIONS:"INSUFFICIENT_PERMISSIONS",ACCESS_DENIED:"ACCESS_DENIED",NOT_FOUND:"NOT_FOUND",RESOURCE_NOT_FOUND:"RESOURCE_NOT_FOUND",SESSION_NOT_FOUND:"SESSION_NOT_FOUND",CARRIER_NOT_FOUND:"CARRIER_NOT_FOUND",ENDPOINT_NOT_FOUND:"ENDPOINT_NOT_FOUND",CONFLICT:"CONFLICT",RESOURCE_ALREADY_EXISTS:"RESOURCE_ALREADY_EXISTS",DUPLICATE_SESSION:"DUPLICATE_SESSION",CONCURRENT_MODIFICATION:"CONCURRENT_MODIFICATION",UNPROCESSABLE_ENTITY:"UNPROCESSABLE_ENTITY",UNSUPPORTED_VERIFICATION:"UNSUPPORTED_VERIFICATION",INVALID_VERIFICATION:"INVALID_VERIFICATION",VERIFICATION_FAILED:"VERIFICATION_FAILED",OTP_EXPIRED:"OTP_EXPIRED",OTP_INVALID:"OTP_INVALID",RCS_UNAVAILABLE:"RCS_UNAVAILABLE",CARRIER_IDENTIFICATION_FAILED:"CARRIER_IDENTIFICATION_FAILED",CARRIER_NOT_ELIGIBLE:"CARRIER_NOT_ELIGIBLE",UNSUPPORTED_CARRIER:"UNSUPPORTED_CARRIER",UNSUPPORTED_PLATFORM:"UNSUPPORTED_PLATFORM",UNSUPPORTED_STRATEGY:"UNSUPPORTED_STRATEGY",INVALID_SESSION_STATE:"INVALID_SESSION_STATE",PHONE_NUMBER_MISMATCH:"PHONE_NUMBER_MISMATCH",INVALID_CREDENTIAL_FORMAT:"INVALID_CREDENTIAL_FORMAT",RATE_LIMIT_EXCEEDED:"RATE_LIMIT_EXCEEDED",TOO_MANY_REQUESTS:"TOO_MANY_REQUESTS",QUOTA_EXCEEDED:"QUOTA_EXCEEDED",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",CIRCUIT_BREAKER_CONFIGURATION_ERROR:"CIRCUIT_BREAKER_CONFIGURATION_ERROR",DATABASE_ERROR:"DATABASE_ERROR",CACHE_ERROR:"CACHE_ERROR",SERIALIZATION_ERROR:"SERIALIZATION_ERROR",CRYPTO_ERROR:"CRYPTO_ERROR",BAD_GATEWAY:"BAD_GATEWAY",UPSTREAM_ERROR:"UPSTREAM_ERROR",INVALID_RESPONSE:"INVALID_RESPONSE",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE",DOWNSTREAM_SERVICE_ERROR:"DOWNSTREAM_SERVICE_ERROR",PROVIDER_ERROR:"PROVIDER_ERROR",CIRCUIT_BREAKER_OPEN:"CIRCUIT_BREAKER_OPEN",MAINTENANCE_MODE:"MAINTENANCE_MODE",GATEWAY_TIMEOUT:"GATEWAY_TIMEOUT",REQUEST_TIMEOUT:"REQUEST_TIMEOUT",UPSTREAM_TIMEOUT:"UPSTREAM_TIMEOUT",DEADLINE_EXCEEDED:"DEADLINE_EXCEEDED",BROWSER_NOT_SUPPORTED:"BROWSER_NOT_SUPPORTED",USER_DENIED:"USER_DENIED",NETWORK_ERROR:"NETWORK_ERROR"};const r={CARRIER_NOT_ELIGIBLE:"Your carrier is not eligible for this verification method.",CARRIER_IDENTIFICATION_FAILED:"Unable to identify carrier for the provided phone number.",CARRIER_NOT_FOUND:"Carrier information not available.",UNSUPPORTED_CARRIER:"This carrier is not supported.",RATE_LIMIT_EXCEEDED:"Too many attempts. Please wait a moment and try again.",TOO_MANY_REQUESTS:"Too many requests. Please slow down and try again.",QUOTA_EXCEEDED:"Usage limit reached. Please try again later.",SESSION_NOT_FOUND:"Your session has expired. Please start over.",INVALID_SESSION_STATE:"Invalid session state. Please start over.",DUPLICATE_SESSION:"A session already exists. Please complete or cancel it first.",BROWSER_NOT_SUPPORTED:"Digital Credentials API is not available. Please enable the #web-identity-digital-credentials flag in chrome://flags",UNSUPPORTED_PLATFORM:"This platform is not supported for authentication.",UNSUPPORTED_STRATEGY:"This authentication method is not available.",USER_DENIED:"Authentication was cancelled. Please try again when you're ready.",SERVICE_UNAVAILABLE:"The service is temporarily unavailable. Please try again later.",CIRCUIT_BREAKER_OPEN:"Service is experiencing issues. Please try again later.",MAINTENANCE_MODE:"Service is under maintenance. Please try again later.",DOWNSTREAM_SERVICE_ERROR:"A required service is unavailable. Please try again later.",TOKEN_ACQUISITION_FAILED:"Failed to acquire authentication token. Please try again.",EXPIRED_TOKEN:"Your authentication has expired. Please start over.",INVALID_CREDENTIALS:"Invalid credentials provided.",INVALID_PHONE_NUMBER:"Please enter a valid phone number.",PHONE_NUMBER_MISMATCH:"Phone number mismatch. Please verify your number.",INVALID_PARAMETERS:"Invalid parameters provided.",MISSING_PARAMETERS:"Required information is missing.",VALIDATION_ERROR:"Validation failed. Please check your input.",NETWORK_ERROR:"Network connection failed. Please check your connection and try again.",GATEWAY_TIMEOUT:"Request timed out. Please try again.",REQUEST_TIMEOUT:"Request timed out. Please try again.",DEADLINE_EXCEEDED:"Operation took too long. Please try again.",VERIFICATION_FAILED:"Verification failed. Please try again.",INVALID_VERIFICATION:"Invalid verification response.",INVALID_CREDENTIAL_FORMAT:"Invalid credential format.",BAD_REQUEST:"Invalid request. Please try again.",UNAUTHORIZED:"Authentication required.",FORBIDDEN:"Access denied.",NOT_FOUND:"Resource not found.",INTERNAL_SERVER_ERROR:"An error occurred. Please try again later."},i=new Set(["CARRIER_NOT_ELIGIBLE","CARRIER_IDENTIFICATION_FAILED","CARRIER_NOT_FOUND","UNSUPPORTED_CARRIER","RATE_LIMIT_EXCEEDED","TOO_MANY_REQUESTS","QUOTA_EXCEEDED","BROWSER_NOT_SUPPORTED","UNSUPPORTED_PLATFORM","UNSUPPORTED_STRATEGY","USER_DENIED","SESSION_NOT_FOUND","INVALID_SESSION_STATE","EXPIRED_TOKEN","SERVICE_UNAVAILABLE","CIRCUIT_BREAKER_OPEN","MAINTENANCE_MODE","NETWORK_ERROR","GATEWAY_TIMEOUT","REQUEST_TIMEOUT","INVALID_PHONE_NUMBER","PHONE_NUMBER_MISMATCH","MISSING_PARAMETERS","VALIDATION_ERROR"]);function s(e){return i.has(e.code)}function a(e){return r[e.code]||"An unexpected error occurred. Please try again."}function l(e){if(!e||"object"!=typeof e)return e;const t=JSON.parse(JSON.stringify(e)),n=["carrier","phone_number","mnc","mcc","carrier_name"];for(const e of n)delete t[e];return t}},514:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.requiresUserAction=t.requiresPolling=t.isHeadlessResult=t.hasTrigger=t.hasPollingControls=t.getStrategy=t.isDesktopStrategy=t.isTS43Strategy=t.isLinkStrategy=t.isAuthCredential=t.isCredential=t.isExtendedResponse=t.MobileDebugConsole=t.validateUseCaseRequirements=t.validatePlmn=t.validatePhoneNumber=t.createErrorBreadcrumb=t.serializeError=t.isRetryableError=t.getRetryDelay=t.isErrorCode=t.getUserMessage=t.isUserError=t.isPhoneAuthError=t.PhoneAuthErrorCode=t.PhoneAuthClient=void 0;var i=n(895);Object.defineProperty(t,"PhoneAuthClient",{enumerable:!0,get:function(){return i.PhoneAuthClient}}),r(n(931),t);var s=n(192);Object.defineProperty(t,"PhoneAuthErrorCode",{enumerable:!0,get:function(){return s.PhoneAuthErrorCode}}),Object.defineProperty(t,"isPhoneAuthError",{enumerable:!0,get:function(){return s.isPhoneAuthError}}),Object.defineProperty(t,"isUserError",{enumerable:!0,get:function(){return s.isUserError}}),Object.defineProperty(t,"getUserMessage",{enumerable:!0,get:function(){return s.getUserMessage}}),Object.defineProperty(t,"isErrorCode",{enumerable:!0,get:function(){return s.isErrorCode}}),Object.defineProperty(t,"getRetryDelay",{enumerable:!0,get:function(){return s.getRetryDelay}}),Object.defineProperty(t,"isRetryableError",{enumerable:!0,get:function(){return s.isRetryableError}}),Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return s.serializeError}}),Object.defineProperty(t,"createErrorBreadcrumb",{enumerable:!0,get:function(){return s.createErrorBreadcrumb}});var a=n(495);Object.defineProperty(t,"validatePhoneNumber",{enumerable:!0,get:function(){return a.validatePhoneNumber}}),Object.defineProperty(t,"validatePlmn",{enumerable:!0,get:function(){return a.validatePlmn}}),Object.defineProperty(t,"validateUseCaseRequirements",{enumerable:!0,get:function(){return a.validateUseCaseRequirements}});var l=n(545);Object.defineProperty(t,"MobileDebugConsole",{enumerable:!0,get:function(){return l.MobileDebugConsole}});var c=n(363);Object.defineProperty(t,"isExtendedResponse",{enumerable:!0,get:function(){return c.isExtendedResponse}}),Object.defineProperty(t,"isCredential",{enumerable:!0,get:function(){return c.isCredential}}),Object.defineProperty(t,"isAuthCredential",{enumerable:!0,get:function(){return c.isAuthCredential}}),Object.defineProperty(t,"isLinkStrategy",{enumerable:!0,get:function(){return c.isLinkStrategy}}),Object.defineProperty(t,"isTS43Strategy",{enumerable:!0,get:function(){return c.isTS43Strategy}}),Object.defineProperty(t,"isDesktopStrategy",{enumerable:!0,get:function(){return c.isDesktopStrategy}}),Object.defineProperty(t,"getStrategy",{enumerable:!0,get:function(){return c.getStrategy}}),Object.defineProperty(t,"hasPollingControls",{enumerable:!0,get:function(){return c.hasPollingControls}}),Object.defineProperty(t,"hasTrigger",{enumerable:!0,get:function(){return c.hasTrigger}}),Object.defineProperty(t,"isHeadlessResult",{enumerable:!0,get:function(){return c.isHeadlessResult}}),Object.defineProperty(t,"requiresPolling",{enumerable:!0,get:function(){return c.requiresPolling}}),Object.defineProperty(t,"requiresUserAction",{enumerable:!0,get:function(){return c.requiresUserAction}})},802:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};function o(e,t){const n=(null==t?void 0:t.container)||document.createElement("div");let o;if(n.className="phone-auth-qr-container","string"==typeof e)o=e;else{if(!e||"object"!=typeof e)throw new Error("Invalid qrCodeData: must be string or QRCodeData object");if(e.iosQRCode)o=e.iosQRCode;else{if(!e.androidQRCode)throw new Error("Invalid QRCodeData: missing QR code images");o=e.androidQRCode}}const r=document.createElement("img");if(r.src=o,r.alt="QR Code for authentication",r.style.width=`${(null==t?void 0:t.size)||256}px`,r.style.height=`${(null==t?void 0:t.size)||256}px`,r.style.display="block",r.style.margin="0 auto",null==t?void 0:t.title){const e=document.createElement("h3");e.textContent=t.title,e.style.textAlign="center",e.style.marginBottom="1rem",n.appendChild(e)}if(n.appendChild(r),null==t?void 0:t.description){const e=document.createElement("p");e.textContent=t.description,e.style.textAlign="center",e.style.marginTop="1rem",e.style.color="#666",n.appendChild(e)}return n}Object.defineProperty(t,"__esModule",{value:!0}),t.DesktopHandler=void 0,t.createQRCodeDisplay=o,t.showQRCodeModal=function(e,t){const n=document.createElement("div");n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n ";const r=document.createElement("div");r.style.cssText="\n background: white;\n padding: 2rem;\n border-radius: 8px;\n max-width: 400px;\n position: relative;\n ";const i=document.createElement("button");i.textContent="×",i.style.cssText="\n position: absolute;\n top: 10px;\n right: 10px;\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #999;\n ",i.onclick=()=>{document.body.removeChild(n),(null==t?void 0:t.onClose)&&t.onClose()},r.appendChild(i);const s=o(e,{title:(null==t?void 0:t.title)||"Scan QR Code to Authenticate",description:(null==t?void 0:t.description)||"Use your mobile device to scan this QR code"});r.appendChild(s);const a=document.createElement("div");a.id="desktop-auth-status",a.style.cssText="\n text-align: center;\n margin-top: 1rem;\n color: #666;\n font-size: 14px;\n ",r.appendChild(a),n.appendChild(r),document.body.appendChild(n),n.onclick=e=>{e.target===n&&(document.body.removeChild(n),(null==t?void 0:t.onClose)&&t.onClose())}},t.DesktopHandler=class{constructor(){this.pollingAttempts=0,this.isCancelled=!1,this.isPollingInProgress=!1}mapBackendStatus(e,t){switch(e){case 200:return"completed"===t?"authenticated":"pending";case 410:return"expired";default:return"error"}}invoke(e,t){return n(this,void 0,void 0,(function*(){const n=e.data;let o,r,i,s,a;if(n&&n.data&&"object"==typeof n.data){const e=n.data;o=e.ios_qr_image&&e.android_qr_image?{iosQRCode:e.ios_qr_image,androidQRCode:e.android_qr_image,iosUrl:e.ios_url,androidUrl:e.android_url}:e.ios_qr_image||e.android_qr_image?e.ios_qr_image||e.android_qr_image:e.qr_code_image||e.qr_code,r=e.session_id,i=e.status_url,s=e.polling_interval,a=e.expires_in}if(!o&&n&&(o=n.qr_code_image||n.qr_code,r=r||n.session_id,i=i||n.status_url||n.polling_endpoint,s=s||n.polling_interval,a=a||n.expires_in),!o)throw new Error("Invalid desktop authentication data: missing QR code");if(!r)throw new Error("Invalid desktop authentication data: missing session ID");(null==t?void 0:t.onQRCodeReady)&&t.onQRCodeReady(o),console.log("[Desktop QR] Polling endpoint selection:"),console.log(" - options?.pollingEndpoint:",null==t?void 0:t.pollingEndpoint),console.log(" - backend pollingEndpoint:",i);let l=null==t?void 0:t.pollingEndpoint,c="options";l||(l=i,c="backend"),l||(console.log("[Desktop QR] No polling endpoint provided, will use hardcoded fallback"),c="fallback"),console.log("[Desktop QR] Selected endpoint:",l,"from source:",c);const u=(null==t?void 0:t.pollingInterval)||s||2e3,d=(null==t?void 0:t.maxPollingAttempts)||30;return console.log(`[Desktop QR] Starting polling - endpoint source: ${c}, interval: ${u}ms, max attempts: ${d}`),this.startPolling(l||"",r,u,d,a||300,t,c)}))}startPolling(e,t,o,r,i,s){return n(this,arguments,void 0,(function*(e,t,o,r,i,s,a="unknown"){const l=Date.now()+1e3*i;return new Promise(((i,c)=>{this.pollingReject=c;const u=()=>n(this,void 0,void 0,(function*(){if(!this.isPollingInProgress)try{if(this.isPollingInProgress=!0,this.isCancelled)return this.stopPolling(),(null==s?void 0:s.onCancel)&&s.onCancel(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"cancelled",message:"Authentication cancelled"}),void c({code:"USER_DENIED",message:"Authentication cancelled by user"});if(Date.now()>l)return this.stopPolling(),(null==s?void 0:s.onExpired)&&s.onExpired(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"expired",message:"QR code has expired"}),void i({authenticated:!1,error:"Authentication expired"});if(this.pollingAttempts>=r)return this.stopPolling(),(null==s?void 0:s.onTimeout)&&s.onTimeout(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:"Polling timeout reached"}),void i({authenticated:!1,error:"Polling timeout"});let n;n=e&&(e.startsWith("http://")||e.startsWith("https://"))?e:e&&""!==e?`${e}/${t}`:`/api/phone-auth/status/${t}`,console.log(`[Desktop QR] Polling status (attempt ${this.pollingAttempts}/${r})`),console.log(`[Desktop QR] Using ${a} endpoint: ${n}`);const o={Accept:"application/json"};(null==s?void 0:s.devEnv)&&(o.developer=s.devEnv,console.log(`[Desktop QR] Adding developer header: ${s.devEnv}`));const u=yield fetch(n,{method:"GET",headers:o});if(console.log(`[Desktop QR] Status response: ${u.status} ${u.statusText}`),200===u.status){const e=yield u.json();if("completed"===e.status){this.stopPolling();const n=document.querySelector('[style*="position: fixed"]');n&&n.querySelector("#desktop-auth-status")&&setTimeout((()=>{n.remove()}),500),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"authenticated",message:"Authentication successful",data:e}),this.pollingReject=void 0,i({authenticated:!0,credential:e.credential||e.session_key||t,session:e.session||{session_key:e.session_key||t,status:e.status,protocol:e.protocol,created_at:e.created_at,last_updated:e.last_updated}})}else"pending"===e.status&&(this.pollingAttempts++,(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"pending",message:`Waiting for authentication (attempt ${this.pollingAttempts}/${r})`}))}else if(410===u.status){this.stopPolling();const e=yield u.json().catch((()=>({message:"Session expired"}))),t=document.querySelector('[style*="position: fixed"]');t&&t.querySelector("#desktop-auth-status")&&setTimeout((()=>{t.remove()}),500),(null==s?void 0:s.onExpired)&&s.onExpired(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"expired",message:e.message||"Session has expired"}),i({authenticated:!1,error:e.message||"Session expired"})}else if(422===u.status){this.stopPolling();const e=yield u.json().catch((()=>({message:"Authentication failed"}))),t=document.querySelector('[style*="position: fixed"]');t&&t.querySelector("#desktop-auth-status")&&setTimeout((()=>{t.remove()}),500);const n="USER_CANCELLED"===e.code;(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:e.message||"Authentication failed"}),i({authenticated:!1,error:n?"User cancelled authentication":e.message||"Authentication failed"})}else if(404===u.status)this.stopPolling(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:"Session not found"}),i({authenticated:!1,error:"Session not found"});else if(400===u.status){this.stopPolling();const e=yield u.json().catch((()=>({message:"Invalid session key"})));i({authenticated:!1,error:e.message||"Invalid session key"})}else this.pollingAttempts++}catch(e){this.pollingAttempts++,(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"pending",message:`Network error, retrying... (attempt ${this.pollingAttempts}/${r})`})}finally{this.isPollingInProgress=!1}}));u(),this.pollingIntervalId=setInterval(u,o)}))}))}stopPolling(){this.pollingIntervalId&&(console.log("[Desktop QR] Stopping polling"),clearInterval(this.pollingIntervalId),this.pollingIntervalId=void 0),this.pollingAttempts=0,this.isPollingInProgress=!1}isPolling(){return void 0!==this.pollingIntervalId}formatResponse(e){if(!e.authenticated||!e.credential)throw new Error("Authentication not completed");return{credential:e.credential,session:e.session}}isSupported(){return"undefined"!=typeof window&&"undefined"!=typeof fetch&&"undefined"!=typeof Promise}cleanup(){this.stopPolling(),this.isCancelled=!1,this.onCancel=void 0,this.pollingReject=void 0}cancel(){var e;console.log("[Desktop QR] Cancelling authentication"),this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this),this.pollingReject&&(this.pollingReject({code:"USER_DENIED",message:"Authentication cancelled by user"}),this.pollingReject=void 0)}}},544:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.LinkHandler=void 0,t.LinkHandler=class{constructor(){this.isPollingActive=!1,this.isCancelled=!1,this.isPollingInProgress=!1}invoke(e,t){return n(this,void 0,void 0,(function*(){console.log("[Link Auth] 🔗 invoke() called with data:",JSON.stringify(e,null,2)),console.log("[Link Auth] Options:",t?JSON.stringify({pollingInterval:t.pollingInterval,maxPollingAttempts:t.maxPollingAttempts,pollingEndpoint:t.pollingEndpoint}):"none");const n=e.data;if(!n||!n.url)throw new Error("Invalid link data: missing URL");const o=e.session.session_key;return console.log("[Link Auth] Session key:",o),console.log("[Link Auth] Link URL:",n.url),this.openAuthenticationLink(n.url),(null==t?void 0:t.onLinkOpened)&&t.onLinkOpened(),this.startPolling(o,n,t)}))}openAuthenticationLink(e){window.location.href=e}startPolling(e,t,o){return n(this,void 0,void 0,(function*(){const r=(null==o?void 0:o.pollingInterval)||2e3,i=(null==o?void 0:o.maxPollingAttempts)||30;let s=0;return console.log("[Link Auth] 🚀 Starting polling:",{sessionKey:e,interval:`${r}ms`,maxAttempts:i,linkDataAvailable:!!t}),new Promise(((a,l)=>{this.isPollingActive=!0,this.pollingReject=l;const c=()=>n(this,void 0,void 0,(function*(){if(!this.isPollingActive)return;if(this.isPollingInProgress)return;let n="";try{if(this.isPollingInProgress=!0,s>=i){this.stopPolling(),(null==o?void 0:o.onTimeout)&&o.onTimeout();const e=Math.round(i*r/1e3),t=e>=60?`${Math.floor(e/60)} minute${Math.floor(e/60)>1?"s":""}`:`${e} seconds`;return(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"expired",message:`Authentication timeout after ${t}`}),void l(new Error(`Authentication timeout after ${t}`))}let c=null==o?void 0:o.pollingEndpoint,u="options";if(!c&&t.status_url&&(c=t.status_url,u="backend"),console.log("[Link Auth] Polling endpoint selection:"),console.log(" - options?.pollingEndpoint:",null==o?void 0:o.pollingEndpoint),console.log(" - linkData.status_url:",t.status_url),console.log(" - selected endpoint:",c,"from source:",u),c&&(c.startsWith("http://")||c.startsWith("https://")))n=c;else if(c&&""!==c){const t="undefined"!=typeof window?window.location.origin:"";n=c.includes("{{session_id}}")?t+c.replace("{{session_id}}",e):t+c+"/"+e}else n=`https://api.glideidentity.app/public/status/${e}`,u="fallback";console.log(`[Link Auth] Using ${u} endpoint: ${n}`),console.log(`[Link Auth] Polling status (attempt ${s}/${i}): ${n}`);const d={Accept:"application/json"};(null==o?void 0:o.devEnv)&&(d.developer=o.devEnv,console.log(`[Link Auth] Adding developer header: ${o.devEnv}`));const h=yield fetch(n,{method:"GET",headers:d});if(console.log(`[Link Auth] Poll response - Status: ${h.status}, OK: ${h.ok}`),200===h.status){const t=yield h.json();console.log("[Link Auth] Poll response data:",JSON.stringify(t,null,2)),"completed"===t.status?(console.log("[Link Auth] ✅ Authentication COMPLETED! Session:",e),console.log("[Link Auth] Full completion result:",JSON.stringify(t,null,2)),this.stopPolling(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"authenticated",message:"Authentication successful",data:t}),this.pollingReject=void 0,a({authenticated:!0,credential:t.credential||e,session:t.session||{session_key:e,status:t.status,protocol:t.protocol||"link",created_at:t.created_at,last_updated:t.last_updated}})):"pending"===t.status?(console.log("[Link Auth] Status still pending, continuing to poll..."),s++,(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"pending",message:"Waiting for app authentication..."})):(console.log("[Link Auth] ⚠️ Unexpected status value:",t.status,"Full result:",JSON.stringify(t,null,2)),s++)}else if(410===h.status){console.log("[Link Auth] ❌ Session expired (410)"),this.stopPolling();const e=yield h.json().catch((()=>({message:"Session expired"})));(null==o?void 0:o.onTimeout)&&o.onTimeout(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"expired",message:e.message||"Session expired"}),l(new Error(e.message||"Session expired"))}else if(422===h.status){console.log("[Link Auth] ❌ Authentication failed (422)"),this.stopPolling();const e=yield h.json().catch((()=>({message:"Authentication failed"})));console.log("[Link Auth] Error data:",JSON.stringify(e,null,2));const t="USER_CANCELLED"===e.code?"User cancelled authentication":e.message||"Verification failed";(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"error",message:t}),l(new Error(t))}else if(404===h.status)console.log("[Link Auth] ❌ Session not found (404)"),this.stopPolling(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"error",message:"Session not found"}),l(new Error("Session not found"));else if(400===h.status){console.log("[Link Auth] ❌ Invalid session key (400)"),this.stopPolling();const e=yield h.json().catch((()=>({message:"Invalid session key"})));console.log("[Link Auth] Error data:",JSON.stringify(e,null,2)),l(new Error(e.message||"Invalid session key"))}else{console.log("[Link Auth] ⚠️ Unexpected HTTP status:",h.status,"continuing to poll..."),s++;try{const e=yield h.text();console.log("[Link Auth] Response body:",e)}catch(e){console.log("[Link Auth] Could not read response body")}}}catch(e){console.error("[Link Auth] 🔴 Polling error:",e.message||e),s++,console.error("[Link Auth] Error details:",{name:e.name,message:e.message,stack:e.stack,statusUrl:n,attempt:s,error:e}),e.message&&e.message.toLowerCase().includes("failed")&&(console.error("[Link Auth] ⚠️ Possible CORS issue. Status URL:",n),console.error("[Link Auth] Make sure the API endpoint allows CORS from your ngrok domain")),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"pending",message:`Connection issue, retrying... (${s}/${i})`})}finally{this.isPollingInProgress=!1}}));c(),this.pollingInterval=setInterval(c,r)}))}))}stopPolling(){console.log("[Link Auth] 🏁 Stopping polling"),this.isPollingActive=!1,this.isPollingInProgress=!1,this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=void 0)}formatResponse(e){if(!e.authenticated||!e.credential)throw new Error("Authentication not completed");return{credential:e.credential,session:e.session,type:"link"}}isSupported(){return/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)}cleanup(){this.stopPolling(),this.isCancelled=!1,this.onCancel=void 0,this.pollingReject=void 0}isPolling(){return void 0!==this.pollingInterval}cancel(){var e;console.log("[Link Auth] Cancelling authentication"),this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this),this.pollingReject&&(this.pollingReject({code:"USER_DENIED",message:"Authentication cancelled by user"}),this.pollingReject=void 0)}}},363:(e,t)=>{function n(e){return e&&"object"==typeof e&&"strategy"in e&&"credential"in e&&"cancel"in e&&"function"==typeof e.cancel}function o(e){return!!n(e)&&("link"===e.strategy&&"start_polling"in e||"desktop"===e.strategy&&"start_polling"in e)}Object.defineProperty(t,"__esModule",{value:!0}),t.requiresUserAction=t.requiresPolling=t.isHeadlessResult=void 0,t.isExtendedResponse=n,t.isCredential=function(e){return!!e&&("string"==typeof e||"object"==typeof e&&(!("strategy"in e)&&!("credential"in e)&&!("cancel"in e)))},t.isAuthCredential=function(e){return e&&"object"==typeof e&&"credential"in e&&"authenticated"in e&&"session"in e},t.isLinkStrategy=function(e){return"link"===e.strategy},t.isTS43Strategy=function(e){return"ts43"===e.strategy},t.isDesktopStrategy=function(e){return"desktop"===e.strategy},t.getStrategy=function(e){if(n(e))return e.strategy},t.hasPollingControls=o,t.hasTrigger=function(e){return!!n(e)&&"trigger"in e&&"function"==typeof e.trigger},t.isHeadlessResult=n,t.requiresPolling=o,t.requiresUserAction=e=>!1},931:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthStatus=t.BrowserName=t.BrowserErrorCode=t.BrowserError=void 0,r(n(566),t),t.BrowserError={NOT_ALLOWED:"NotAllowedError",NETWORK:"NetworkError",NOT_SUPPORTED:"NotSupportedError",SECURITY:"SecurityError",ABORT:"AbortError",TIMEOUT:"TimeoutError",INVALID_STATE:"InvalidStateError",DATA_CLONE:"DataCloneError",ENCODING:"EncodingError",NOT_READABLE:"NotReadableError",UNKNOWN:"UnknownError",TYPE:"TypeError",RANGE:"RangeError",SYNTAX:"SyntaxError"},t.BrowserErrorCode={USER_CANCELLED_DC_API:19,PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3,NOT_FOUND:8,ABORT:20,NETWORK:19,SECURITY:18},t.BrowserName={CHROME:"Chrome",EDGE:"Edge",SAFARI:"Safari",FIREFOX:"Firefox",OPERA:"Opera",BRAVE:"Brave",OTHER:"other"},t.AuthStatus={PENDING:"pending",COMPLETED:"completed",CANCELLED:"cancelled",FAILED:"failed",EXPIRED:"expired",NOT_FOUND:"not_found"}},545:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MobileDebugConsole=void 0;class n{constructor(){this.logs=[],this.container=null,this.logsContainer=null,this.floatingToggle=null,this.isAtBottom=!0,this.isVisible=!0,this.originalConsole={log:console.log,error:console.error,warn:console.warn,debug:console.debug,info:console.info},this.interceptConsole(),this.createUI()}static init(){return n.instance||(n.instance=new n),n.instance}static destroy(){n.instance&&(n.instance.cleanup(),n.instance=null)}interceptConsole(){["log","error","warn","debug","info"].forEach((e=>{const t=this.originalConsole[e];console[e]=(...n)=>{t.apply(console,n),this.addLog(e,n)}}))}addLog(e,t){const n=(new Date).toTimeString().split(" ")[0],o=t.map((e=>{if("object"==typeof e)try{return JSON.stringify(e,null,2)}catch(e){return"[Object]"}return String(e)})).join(" "),r={log:"#fff",error:"#ff6b6b",warn:"#ffd93d",info:"#6bcf7f",debug:"#95a5a6"},i=`\n <div style="margin: 4px 0; font-family: monospace; font-size: 11px; color: ${r[e]||"#fff"};">\n <span style="color: #666;">[${n}]</span>\n <span style="color: ${r[e]}; font-weight: bold; text-transform: uppercase; font-size: 9px;">[${e}]</span>\n <span style="white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(o)}</span>\n </div>\n `;this.logs.push(i),this.logs.length>500&&this.logs.shift(),this.updateDisplay()}updateDisplay(){this.logsContainer&&this.isVisible&&(this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50,this.logsContainer.innerHTML=this.logs.join(""),this.isAtBottom&&(this.logsContainer.scrollTop=this.logsContainer.scrollHeight))}createUI(){const e=document.createElement("style");e.textContent="\n #mobile-debug-console {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n height: 45vh;\n background: rgba(0, 0, 0, 0.95);\n z-index: 999999;\n display: flex;\n flex-direction: column;\n font-family: monospace;\n transition: transform 0.3s ease;\n }\n \n #mobile-debug-console.hidden {\n transform: translateY(100%);\n }\n \n #debug-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 10px;\n background: #1a1a1a;\n border-top: 2px solid #333;\n }\n \n #debug-title {\n color: #0f0;\n font-size: 12px;\n font-weight: bold;\n }\n \n #debug-buttons {\n display: flex;\n gap: 10px;\n }\n \n #debug-buttons button {\n padding: 5px 10px;\n background: #333;\n color: #fff;\n border: 1px solid #555;\n border-radius: 3px;\n font-size: 11px;\n cursor: pointer;\n }\n \n #debug-buttons button:active {\n background: #555;\n }\n \n #debug-logs {\n flex: 1;\n overflow-y: auto;\n padding: 10px;\n -webkit-overflow-scrolling: touch;\n }\n \n #debug-floating-toggle {\n position: fixed;\n bottom: 20px;\n right: 20px;\n width: 50px;\n height: 50px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.8);\n border: 2px solid #0f0;\n color: #0f0;\n cursor: pointer;\n z-index: 999998;\n display: none;\n align-items: center;\n justify-content: center;\n font-size: 24px;\n box-shadow: 0 2px 10px rgba(0, 255, 0, 0.3);\n transition: all 0.3s ease;\n }\n \n #debug-floating-toggle:hover {\n background: rgba(0, 0, 0, 0.9);\n transform: scale(1.1);\n box-shadow: 0 4px 15px rgba(0, 255, 0, 0.5);\n }\n \n #debug-floating-toggle.visible {\n display: flex;\n }\n ",document.head.appendChild(e),this.container=document.createElement("div"),this.container.id="mobile-debug-console",this.isVisible||(this.container.className="hidden");const t=document.createElement("div");t.id="debug-header";const n=document.createElement("div");n.id="debug-title",n.textContent="📱 Mobile Debug Console";const o=document.createElement("div");o.id="debug-buttons";const r=document.createElement("button");r.textContent="Clear",r.onclick=()=>this.clear();const i=document.createElement("button");i.textContent="Hide",i.onclick=()=>this.toggle();const s=document.createElement("button");s.textContent="✕",s.style.color="#ff6b6b",s.onclick=()=>this.cleanup(),o.appendChild(r),o.appendChild(i),o.appendChild(s),t.appendChild(n),t.appendChild(o),this.logsContainer=document.createElement("div"),this.logsContainer.id="debug-logs",this.logsContainer.addEventListener("scroll",(()=>{this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50})),this.container.appendChild(t),this.container.appendChild(this.logsContainer),document.body.appendChild(this.container),this.floatingToggle=document.createElement("button"),this.floatingToggle.id="debug-floating-toggle",this.floatingToggle.innerHTML="🖥️",this.floatingToggle.title="Show Debug Console",this.floatingToggle.onclick=()=>this.toggle(),document.body.appendChild(this.floatingToggle),window.__debugToggleBtn=i}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}toggle(){this.isVisible=!this.isVisible,this.container&&this.floatingToggle&&(this.isVisible?(this.container.classList.remove("hidden"),this.floatingToggle.classList.remove("visible"),window.__debugToggleBtn.textContent="Hide",this.updateDisplay()):(this.container.classList.add("hidden"),this.floatingToggle.classList.add("visible"),window.__debugToggleBtn.textContent="Show"))}clear(){this.logs=[],this.logsContainer&&(this.logsContainer.innerHTML="")}cleanup(){Object.keys(this.originalConsole).forEach((e=>{console[e]=this.originalConsole[e]})),this.container&&this.container.remove(),this.floatingToggle&&this.floatingToggle.remove(),delete window.__debugToggleBtn}}t.MobileDebugConsole=n,n.instance=null},244:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthModal=void 0,t.AuthModal=class{constructor(e,t){this.container=null,this.backdrop=null,this.isOpen=!1,this.options=e||{},this.callbacks=t||{},this.handleEscapeKey=this.handleEscapeKey.bind(this)}handleEscapeKey(e){var t,n;"Escape"===e.key&&this.isOpen&&!1!==(null===(t=this.options)||void 0===t?void 0:t.closeOnEscape)&&(null===(n=this.closeCallback)||void 0===n||n.call(this),this.close())}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}showQRCode(e,t="Scan QR code with your phone"){if(console.log("[Modal] showQRCode called with:",e),this.isOpen)console.log("[Modal] Modal already open, skipping recreation");else{if("object"==typeof e&&e.iosQRCode){const n=e.androidQRCode&&e.androidQRCode.length>0&&e.androidQRCode!==e.iosQRCode;if(console.log("[Modal] Has valid Android QR?",n),n)return console.log("[Modal] Using dual-platform modal"),void this.createDualPlatformQRModal(e,t);console.log("[Modal] Android QR missing/empty, using single iOS QR"),this.createModal(`\n <div class="glide-auth-qr-container">\n <img src="${this.escapeHtml(e.iosQRCode)}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">Scan with your iPhone to authenticate</p>\n </div>\n `)}else console.log("[Modal] Using legacy single QR code modal"),this.createModal(`\n <div class="glide-auth-qr-container">\n <img src="${this.escapeHtml(e)}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">${this.escapeHtml(t)}</p>\n </div>\n `);this.show()}}createDualPlatformQRModal(e,t){this.createModal(`\n <div class="glide-auth-qr-container">\n \x3c!-- Platform Switcher --\x3e\n <div class="glide-platform-switcher">\n <button class="glide-platform-btn glide-platform-ios active" data-platform="ios">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"/>\n </svg>\n <span>iOS</span>\n </button>\n <button class="glide-platform-btn glide-platform-android" data-platform="android">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M17.6 9.48l1.84-3.18c.16-.31.04-.69-.26-.85-.29-.15-.65-.06-.83.22l-1.88 3.24c-2.86-1.21-6.08-1.21-8.94 0L5.65 5.67c-.19-.28-.54-.38-.83-.22-.3.16-.42.54-.26.85l1.84 3.18C4.08 11.08 2.4 13.97 2.4 17.2h19.2c0-3.23-1.68-6.12-4.0-7.72zM7.0 14.8c-.66 0-1.2-.54-1.2-1.2s.54-1.2 1.2-1.2 1.2.54 1.2 1.2-.54 1.2-1.2 1.2zm10 0c-.66 0-1.2-.54-1.2-1.2s.54-1.2 1.2-1.2 1.2.54 1.2 1.2-.54 1.2-1.2 1.2z"/>\n </svg>\n <span>Android</span>\n </button>\n </div>\n\n \x3c!-- QR Code Image --\x3e\n <img \n id="glide-qr-code-img" \n src="${this.escapeHtml(e.iosQRCode)}" \n alt="QR Code" \n class="glide-auth-qr-code" \n data-ios="${this.escapeHtml(e.iosQRCode)}"\n data-android="${this.escapeHtml(e.androidQRCode||"")}"\n />\n \n \x3c!-- Status Message --\x3e\n <p class="glide-auth-status" id="glide-platform-message">Scan with your iPhone to authenticate</p>\n </div>\n `),this.show()}setCloseCallback(e){this.closeCallback=e}showLinkButton(e,t){return new Promise((n=>{var o,r,i;const s=t||(null===(o=this.options)||void 0===o?void 0:o.buttonText)||"Open Verification App";this.createModal(`\n <div class="glide-auth-link-container">\n <p class="glide-auth-description">\n ${(null===(r=this.options)||void 0===r?void 0:r.description)||"Click below to verify your phone number"}\n </p>\n <button class="glide-auth-button" id="glide-auth-link-button">\n ${s}\n </button>\n <p class="glide-auth-helper-text">\n You'll be redirected to complete verification\n </p>\n </div>\n `),this.show();const a=null===(i=this.container)||void 0===i?void 0:i.querySelector("#glide-auth-link-button");a?a.addEventListener("click",(t=>{var o,r;null===(r=null===(o=this.callbacks)||void 0===o?void 0:o.onAuthStart)||void 0===r||r.call(o),window.open(e,"_blank"),n()})):console.error("[Modal] Link button not found in modal")}))}showTS43Button(e){return new Promise(((t,o)=>{var r,i,s;const a=(null===(r=this.options)||void 0===r?void 0:r.buttonText)||"Verify with Carrier";this.createModal(`\n <div class="glide-auth-ts43-container">\n <p class="glide-auth-description">\n ${(null===(i=this.options)||void 0===i?void 0:i.description)||"Verify using your carrier credentials"}\n </p>\n <button class="glide-auth-button" id="glide-auth-ts43-button">\n ${a}\n </button>\n <p class="glide-auth-helper-text">\n Secure verification through your mobile carrier\n </p>\n </div>\n `),this.show();const l=null===(s=this.container)||void 0===s?void 0:s.querySelector("#glide-auth-ts43-button");l?l.addEventListener("click",(r=>n(this,void 0,void 0,(function*(){var n,r,i,s,c,u;null===(r=null===(n=this.callbacks)||void 0===n?void 0:n.onAuthStart)||void 0===r||r.call(n),l.setAttribute("disabled","true"),l.textContent="Verifying...";try{const n=yield e();null===(s=null===(i=this.callbacks)||void 0===i?void 0:i.onAuthComplete)||void 0===s||s.call(i,n),t(n),this.close()}catch(e){null===(u=null===(c=this.callbacks)||void 0===c?void 0:c.onError)||void 0===u||u.call(c,e),l.removeAttribute("disabled"),l.textContent=a,o(e)}})))):console.error("[Modal] TS43 button not found in modal")}))}updateStatus(e,t=!1){var n;const o=null===(n=this.container)||void 0===n?void 0:n.querySelector(".glide-auth-status");o&&(o.textContent=e,o.className=t?"glide-auth-status glide-auth-error":"glide-auth-status")}createModal(e){var t,n,o;this.cleanup(),this.backdrop=document.createElement("div"),this.backdrop.className="glide-auth-backdrop",this.backdrop.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n z-index: 9998;\n opacity: 0;\n transition: opacity 0.3s ease;\n ",this.container=document.createElement("div"),this.container.className=`glide-auth-modal ${(null===(t=this.options)||void 0===t?void 0:t.className)||""}`,this.container.style.cssText="\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.9);\n background: white;\n border-radius: 12px;\n padding: 24px;\n max-width: 400px;\n width: 90%;\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);\n z-index: 9999;\n opacity: 0;\n transition: opacity 0.3s ease, transform 0.3s ease;\n ",this.container.innerHTML=`\n <div class="glide-auth-header">\n ${!1!==(null===(n=this.options)||void 0===n?void 0:n.showCloseButton)?'\n <button class="glide-auth-close" aria-label="Close">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n ':""}\n <h2 class="glide-auth-title">${(null===(o=this.options)||void 0===o?void 0:o.title)||"Phone Verification"}</h2>\n </div>\n <div class="glide-auth-content">\n ${e}\n </div>\n `,this.injectStyles();const r=this.container.querySelector(".glide-auth-close");r&&r.addEventListener("click",(()=>{var e;null===(e=this.closeCallback)||void 0===e||e.call(this),this.close()})),this.backdrop.addEventListener("click",(e=>{var t,n;e.target===this.backdrop&&!1!==(null===(t=this.options)||void 0===t?void 0:t.closeOnBackdrop)&&(null===(n=this.closeCallback)||void 0===n||n.call(this),this.close())}))}injectStyles(){if(document.getElementById("glide-auth-styles"))return;const e=document.createElement("style");e.id="glide-auth-styles",e.textContent="\n .glide-auth-backdrop {\n backdrop-filter: blur(4px);\n }\n\n .glide-auth-modal {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;\n }\n\n .glide-auth-header {\n position: relative;\n margin-bottom: 20px;\n }\n\n .glide-auth-close {\n position: absolute;\n top: 0;\n right: 0;\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n color: #666;\n transition: color 0.2s;\n }\n\n .glide-auth-close:hover {\n color: #000;\n }\n\n .glide-auth-title {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #333;\n text-align: center;\n }\n\n .glide-auth-content {\n text-align: center;\n }\n\n .glide-auth-description {\n color: #666;\n margin: 0 0 20px 0;\n font-size: 16px;\n line-height: 1.5;\n }\n\n .glide-auth-button {\n background: #007AFF;\n color: white;\n border: none;\n border-radius: 8px;\n padding: 12px 24px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.2s, transform 0.1s;\n min-width: 200px;\n }\n\n .glide-auth-button:hover:not(:disabled) {\n background: #0051D5;\n transform: translateY(-1px);\n }\n\n .glide-auth-button:active {\n transform: translateY(0);\n }\n\n .glide-auth-button:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n .glide-auth-helper-text {\n color: #999;\n font-size: 14px;\n margin: 16px 0 0 0;\n }\n\n .glide-auth-qr-code {\n max-width: 256px;\n width: 100%;\n height: auto;\n margin: 20px auto;\n display: block;\n }\n\n .glide-auth-status {\n color: #666;\n font-size: 16px;\n margin: 16px 0;\n }\n\n .glide-auth-error {\n color: #FF3B30;\n }\n\n .glide-auth-qr-container,\n .glide-auth-link-container,\n .glide-auth-ts43-container {\n padding: 20px 0;\n }\n\n /* Platform Switcher Styles */\n .glide-platform-switcher {\n display: flex;\n justify-content: center;\n gap: 10px;\n margin-bottom: 20px;\n }\n\n .glide-platform-btn {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 10px 20px;\n border: 2px solid;\n background: transparent;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 600;\n transition: all 0.2s ease;\n }\n\n .glide-platform-btn svg {\n flex-shrink: 0;\n }\n\n .glide-platform-ios {\n border-color: #007AFF;\n color: #007AFF;\n }\n\n .glide-platform-ios.active {\n background: #007AFF;\n color: white;\n }\n\n .glide-platform-ios:hover:not(.active) {\n background: rgba(0, 122, 255, 0.1);\n }\n\n .glide-platform-android {\n border-color: #3DDC84;\n color: #3DDC84;\n }\n\n .glide-platform-android.active {\n background: #3DDC84;\n color: white;\n }\n\n .glide-platform-android:hover:not(.active) {\n background: rgba(61, 220, 132, 0.1);\n }\n ",document.head.appendChild(e)}show(){var e,t;this.container&&this.backdrop&&!this.isOpen&&(document.body.appendChild(this.backdrop),document.body.appendChild(this.container),document.addEventListener("keydown",this.handleEscapeKey),this.setupPlatformToggles(),requestAnimationFrame((()=>{this.backdrop&&this.container&&(this.backdrop.style.opacity="1",this.container.style.opacity="1",this.container.style.transform="translate(-50%, -50%) scale(1)")})),this.isOpen=!0,null===(t=null===(e=this.callbacks)||void 0===e?void 0:e.onOpen)||void 0===t||t.call(e))}setupPlatformToggles(){var e,t,n;const o=null===(e=this.container)||void 0===e?void 0:e.querySelectorAll(".glide-platform-btn"),r=null===(t=this.container)||void 0===t?void 0:t.querySelector("#glide-qr-code-img"),i=null===(n=this.container)||void 0===n?void 0:n.querySelector("#glide-platform-message");o&&r&&o.forEach((e=>{e.addEventListener("click",(e=>{const t=e.currentTarget,n=t.getAttribute("data-platform");o.forEach((e=>e.classList.remove("active"))),t.classList.add("active"),"ios"===n?(r.src=r.getAttribute("data-ios")||"",i&&(i.textContent="Scan with your iPhone to authenticate")):"android"===n&&(r.src=r.getAttribute("data-android")||"",i&&(i.textContent="Scan with your Android device to authenticate"))}))}))}close(){this.container&&this.backdrop&&this.isOpen&&(document.removeEventListener("keydown",this.handleEscapeKey),this.backdrop.style.opacity="0",this.container.style.opacity="0",this.container.style.transform="translate(-50%, -50%) scale(0.9)",this.closeCallback=void 0,setTimeout((()=>{var e,t;this.cleanup(),this.isOpen=!1,null===(t=null===(e=this.callbacks)||void 0===e?void 0:e.onClose)||void 0===t||t.call(e)}),300))}cleanup(){var e,t;null===(e=this.container)||void 0===e||e.remove(),null===(t=this.backdrop)||void 0===t||t.remove(),this.container=null,this.backdrop=null}isModalOpen(){return this.isOpen}}},495:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validatePhoneNumber=function(e){return e?e.startsWith("+")?e.length<8?{valid:!1,error:"Phone number too short for E.164 format (minimum 8 characters including +)"}:e.length>16?{valid:!1,error:"Phone number too long for E.164 format (maximum 15 digits after +)"}:/^\+\d+$/.test(e)?/^\+[1-9]\d{1,14}$/.test(e)?{valid:!0}:{valid:!1,error:"Invalid E.164 phone number format"}:{valid:!1,error:"Phone number contains invalid characters. E.164 format only allows + followed by digits"}:{valid:!1,error:"Phone number must be in E.164 format (start with +)"}:{valid:!0}},t.validatePlmn=function(e){if(!e)return{valid:!0};const{mcc:t,mnc:n}=e;return t&&/^\d{3}$/.test(t)?n&&/^\d{2,3}$/.test(n)?{valid:!0}:{valid:!1,error:"MNC must be 2 or 3 digits"}:{valid:!1,error:"MCC must be exactly 3 digits"}},t.validateUseCaseRequirements=function(e,t,n){return e!==o.USE_CASE.VERIFY_PHONE_NUMBER||t||n?{valid:!0}:{valid:!1,error:"Phone number is required for VerifyPhoneNumber use case"}},t.createValidationError=function(e,t,n){const o=new Error(t);return o.code=e,n&&(o.field=n),o};const o=n(566)},50:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SDK_VERSION=void 0,t.SDK_VERSION="5.1.2"},425:(e,t,n)=>{function o(e,t){return function(){return e.apply(t,arguments)}}const{toString:r}=Object.prototype,{getPrototypeOf:i}=Object,s=(a=Object.create(null),e=>{const t=r.call(e);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())});var a;const l=e=>(e=e.toLowerCase(),t=>s(t)===e),c=e=>t=>typeof t===e,{isArray:u}=Array,d=c("undefined"),h=l("ArrayBuffer"),p=c("string"),E=c("function"),g=c("number"),f=e=>null!==e&&"object"==typeof e,m=e=>{if("object"!==s(e))return!1;const t=i(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},R=l("Date"),v=l("File"),_=l("Blob"),b=l("FileList"),A=l("URLSearchParams"),[y,S,O,I]=["ReadableStream","Request","Response","Headers"].map(l);function C(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let o,r;if("object"!=typeof e&&(e=[e]),u(e))for(o=0,r=e.length;o<r;o++)t.call(null,e[o],o,e);else{const r=n?Object.getOwnPropertyNames(e):Object.keys(e),i=r.length;let s;for(o=0;o<i;o++)s=r[o],t.call(null,e[s],s,e)}}function T(e,t){t=t.toLowerCase();const n=Object.keys(e);let o,r=n.length;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const N="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,P=e=>!d(e)&&e!==N,w=(D="undefined"!=typeof Uint8Array&&i(Uint8Array),e=>D&&e instanceof D);var D;const U=l("HTMLFormElement"),L=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),x=l("RegExp"),k=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),o={};C(n,((n,r)=>{let i;!1!==(i=t(n,r,e))&&(o[r]=i||n)})),Object.defineProperties(e,o)},M="abcdefghijklmnopqrstuvwxyz",j="0123456789",B={DIGIT:j,ALPHA:M,ALPHA_DIGIT:M+M.toUpperCase()+j},F=l("AsyncFunction"),V=(q="function"==typeof setImmediate,H=E(N.postMessage),q?setImmediate:H?(G=`axios@${Math.random()}`,$=[],N.addEventListener("message",(({source:e,data:t})=>{e===N&&t===G&&$.length&&$.shift()()}),!1),e=>{$.push(e),N.postMessage(G,"*")}):e=>setTimeout(e));var q,H,G,$;const Q="undefined"!=typeof queueMicrotask?queueMicrotask.bind(N):"undefined"!=typeof process&&process.nextTick||V;var W={isArray:u,isArrayBuffer:h,isBuffer:function(e){return null!==e&&!d(e)&&null!==e.constructor&&!d(e.constructor)&&E(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||E(e.append)&&("formdata"===(t=s(e))||"object"===t&&E(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer),t},isString:p,isNumber:g,isBoolean:e=>!0===e||!1===e,isObject:f,isPlainObject:m,isReadableStream:y,isRequest:S,isResponse:O,isHeaders:I,isUndefined:d,isDate:R,isFile:v,isBlob:_,isRegExp:x,isFunction:E,isStream:e=>f(e)&&E(e.pipe),isURLSearchParams:A,isTypedArray:w,isFileList:b,forEach:C,merge:function e(){const{caseless:t}=P(this)&&this||{},n={},o=(o,r)=>{const i=t&&T(n,r)||r;m(n[i])&&m(o)?n[i]=e(n[i],o):m(o)?n[i]=e({},o):u(o)?n[i]=o.slice():n[i]=o};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&C(arguments[e],o);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(C(t,((t,r)=>{n&&E(t)?e[r]=o(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,o)=>{e.prototype=Object.create(t.prototype,o),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,o)=>{let r,s,a;const l={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),s=r.length;s-- >0;)a=r[s],o&&!o(a,e,t)||l[a]||(t[a]=e[a],l[a]=!0);e=!1!==n&&i(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:s,kindOfTest:l,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const o=e.indexOf(t,n);return-1!==o&&o===n},toArray:e=>{if(!e)return null;if(u(e))return e;let t=e.length;if(!g(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let o;for(;(o=n.next())&&!o.done;){const n=o.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const o=[];for(;null!==(n=e.exec(t));)o.push(n);return o},isHTMLForm:U,hasOwnProperty:L,hasOwnProp:L,reduceDescriptors:k,freezeMethods:e=>{k(e,((t,n)=>{if(E(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const o=e[n];E(o)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},o=e=>{e.forEach((e=>{n[e]=!0}))};return u(e)?o(e):o(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:T,global:N,isContextDefined:P,ALPHABET:B,generateString:(e=16,t=B.ALPHA_DIGIT)=>{let n="";const{length:o}=t;for(;e--;)n+=t[Math.random()*o|0];return n},isSpecCompliantForm:function(e){return!!(e&&E(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,o)=>{if(f(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[o]=e;const r=u(e)?[]:{};return C(e,((e,t)=>{const i=n(e,o+1);!d(i)&&(r[t]=i)})),t[o]=void 0,r}}return e};return n(e,0)},isAsyncFn:F,isThenable:e=>e&&(f(e)||E(e))&&E(e.then)&&E(e.catch),setImmediate:V,asap:Q};function z(e,t,n,o,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),o&&(this.request=o),r&&(this.response=r,this.status=r.status?r.status:null)}W.inherits(z,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:W.toJSONObject(this.config),code:this.code,status:this.status}}});const K=z.prototype,Y={};function X(e){return W.isPlainObject(e)||W.isArray(e)}function J(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,n){return e?e.concat(t).map((function(e,t){return e=J(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Y[e]={value:e}})),Object.defineProperties(z,Y),Object.defineProperty(K,"isAxiosError",{value:!0}),z.from=(e,t,n,o,r,i)=>{const s=Object.create(K);return W.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),z.call(s,e.message,t,n,o,r),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};const ee=W.toFlatObject(W,{},null,(function(e){return/^is[A-Z]/.test(e)}));function te(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const o=(n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!W.isUndefined(t[e])}))).metaTokens,r=n.visitor||c,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(r))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(W.isDate(e))return e.toISOString();if(!a&&W.isBlob(e))throw new z("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(e)||W.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,r){let a=e;if(e&&!r&&"object"==typeof e)if(W.endsWith(n,"{}"))n=o?n:n.slice(0,-2),e=JSON.stringify(e);else if(W.isArray(e)&&function(e){return W.isArray(e)&&!e.some(X)}(e)||(W.isFileList(e)||W.endsWith(n,"[]"))&&(a=W.toArray(e)))return n=J(n),a.forEach((function(e,o){!W.isUndefined(e)&&null!==e&&t.append(!0===s?Z([n],o,i):null===s?n:n+"[]",l(e))})),!1;return!!X(e)||(t.append(Z(r,n,i),l(e)),!1)}const u=[],d=Object.assign(ee,{defaultVisitor:c,convertValue:l,isVisitable:X});if(!W.isObject(e))throw new TypeError("data must be an object");return function e(n,o){if(!W.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+o.join("."));u.push(n),W.forEach(n,(function(n,i){!0===(!(W.isUndefined(n)||null===n)&&r.call(t,n,W.isString(i)?i.trim():i,o,d))&&e(n,o?o.concat(i):[i])})),u.pop()}}(e),t}function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function oe(e,t){this._pairs=[],e&&te(e,this,t)}const re=oe.prototype;function ie(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function se(e,t,n){if(!t)return e;const o=n&&n.encode||ie;W.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let i;if(i=r?r(t,n):W.isURLSearchParams(t)?t.toString():new oe(t,n).toString(o),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}re.append=function(e,t){this._pairs.push([e,t])},re.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ae=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){W.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},le={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ce={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:oe,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ue="undefined"!=typeof window&&"undefined"!=typeof document,de="object"==typeof navigator&&navigator||void 0,he=ue&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),pe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Ee=ue&&window.location.href||"http://localhost";var ge={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:pe,hasStandardBrowserEnv:he,navigator:de,origin:Ee}),...ce};function fe(e){function t(e,n,o,r){let i=e[r++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=r>=e.length;return i=!i&&W.isArray(o)?o.length:i,a?(W.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!s):(o[i]&&W.isObject(o[i])||(o[i]=[]),t(e,n,o[i],r)&&W.isArray(o[i])&&(o[i]=function(e){const t={},n=Object.keys(e);let o;const r=n.length;let i;for(o=0;o<r;o++)i=n[o],t[i]=e[i];return t}(o[i])),!s)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,((e,o)=>{t(function(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),o,n,0)})),n}return null}const me={transitional:le,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",o=n.indexOf("application/json")>-1,r=W.isObject(e);if(r&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return o?JSON.stringify(fe(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(r){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new ge.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,o){return ge.isNode&&W.isBuffer(e)?(this.append(t,e.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||o?(t.setContentType("application/json",!1),function(e){if(W.isString(e))try{return(0,JSON.parse)(e),W.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||me.transitional,n=t&&t.forcedJSONParsing,o="json"===this.responseType;if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||o)){const n=!(t&&t.silentJSONParsing)&&o;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw z.from(e,z.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ge.classes.FormData,Blob:ge.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],(e=>{me.headers[e]={}}));var Re=me;const ve=W.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_e=Symbol("internals");function be(e){return e&&String(e).trim().toLowerCase()}function Ae(e){return!1===e||null==e?e:W.isArray(e)?e.map(Ae):String(e)}function ye(e,t,n,o,r){return W.isFunction(o)?o.call(this,t,n):(r&&(t=n),W.isString(t)?W.isString(o)?-1!==t.indexOf(o):W.isRegExp(o)?o.test(t):void 0:void 0)}class Se{constructor(e){e&&this.set(e)}set(e,t,n){const o=this;function r(e,t,n){const r=be(t);if(!r)throw new Error("header name must be a non-empty string");const i=W.findKey(o,r);(!i||void 0===o[i]||!0===n||void 0===n&&!1!==o[i])&&(o[i||t]=Ae(e))}const i=(e,t)=>W.forEach(e,((e,n)=>r(e,n,t)));if(W.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(W.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,o,r;return e&&e.split("\n").forEach((function(e){r=e.indexOf(":"),n=e.substring(0,r).trim().toLowerCase(),o=e.substring(r+1).trim(),!n||t[n]&&ve[n]||("set-cookie"===n?t[n]?t[n].push(o):t[n]=[o]:t[n]=t[n]?t[n]+", "+o:o)})),t})(e),t);else if(W.isHeaders(e))for(const[t,o]of e.entries())r(o,t,n);else null!=e&&r(t,e,n);return this}get(e,t){if(e=be(e)){const n=W.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=n.exec(e);)t[o[1]]=o[2];return t}(e);if(W.isFunction(t))return t.call(this,e,n);if(W.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=be(e)){const n=W.findKey(this,e);return!(!n||void 0===this[n]||t&&!ye(0,this[n],n,t))}return!1}delete(e,t){const n=this;let o=!1;function r(e){if(e=be(e)){const r=W.findKey(n,e);!r||t&&!ye(0,n[r],r,t)||(delete n[r],o=!0)}}return W.isArray(e)?e.forEach(r):r(e),o}clear(e){const t=Object.keys(this);let n=t.length,o=!1;for(;n--;){const r=t[n];e&&!ye(0,this[r],r,e,!0)||(delete this[r],o=!0)}return o}normalize(e){const t=this,n={};return W.forEach(this,((o,r)=>{const i=W.findKey(n,r);if(i)return t[i]=Ae(o),void delete t[r];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(r):String(r).trim();s!==r&&delete t[r],t[s]=Ae(o),n[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,((n,o)=>{null!=n&&!1!==n&&(t[o]=e&&W.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[_e]=this[_e]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=be(e);t[o]||(function(e,t){const n=W.toCamelCase(" "+t);["get","set","has"].forEach((o=>{Object.defineProperty(e,o+n,{value:function(e,n,r){return this[o].call(this,t,e,n,r)},configurable:!0})}))}(n,e),t[o]=!0)}return W.isArray(e)?e.forEach(o):o(e),this}}Se.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Se.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),W.freezeMethods(Se);var Oe=Se;function Ie(e,t){const n=this||Re,o=t||n,r=Oe.from(o.headers);let i=o.data;return W.forEach(e,(function(e){i=e.call(n,i,r.normalize(),t?t.status:void 0)})),r.normalize(),i}function Ce(e){return!(!e||!e.__CANCEL__)}function Te(e,t,n){z.call(this,null==e?"canceled":e,z.ERR_CANCELED,t,n),this.name="CanceledError"}function Ne(e,t,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new z("Request failed with status code "+n.status,[z.ERR_BAD_REQUEST,z.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}W.inherits(Te,z,{__CANCEL__:!0});const Pe=(e,t,n=3)=>{let o=0;const r=function(e,t){e=e||10;const n=new Array(e),o=new Array(e);let r,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=o[s];r||(r=l),n[i]=a,o[i]=l;let u=s,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),l-r<t)return;const h=c&&l-c;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(e,t){let n,o,r=0,i=1e3/t;const s=(t,i=Date.now())=>{r=i,n=null,o&&(clearTimeout(o),o=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-r;a>=i?s(e,t):(n=e,o||(o=setTimeout((()=>{o=null,s(n)}),i-a)))},()=>n&&s(n)]}((n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-o,l=r(a);o=i,e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&i<=s?(s-i)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})}),n)},we=(e,t)=>{const n=null!=e;return[o=>t[0]({lengthComputable:n,total:e,loaded:o}),t[1]]},De=e=>(...t)=>W.asap((()=>e(...t)));var Ue=ge.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ge.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ge.origin),ge.navigator&&/(msie|trident)/i.test(ge.navigator.userAgent)):()=>!0,Le=ge.hasStandardBrowserEnv?{write(e,t,n,o,r,i){const s=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),W.isString(o)&&s.push("path="+o),W.isString(r)&&s.push("domain="+r),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function xe(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ke=e=>e instanceof Oe?{...e}:e;function Me(e,t){t=t||{};const n={};function o(e,t,n,o){return W.isPlainObject(e)&&W.isPlainObject(t)?W.merge.call({caseless:o},e,t):W.isPlainObject(t)?W.merge({},t):W.isArray(t)?t.slice():t}function r(e,t,n,r){return W.isUndefined(t)?W.isUndefined(e)?void 0:o(void 0,e,0,r):o(e,t,0,r)}function i(e,t){if(!W.isUndefined(t))return o(void 0,t)}function s(e,t){return W.isUndefined(t)?W.isUndefined(e)?void 0:o(void 0,e):o(void 0,t)}function a(n,r,i){return i in t?o(n,r):i in e?o(void 0,n):void 0}const l={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>r(ke(e),ke(t),0,!0)};return W.forEach(Object.keys(Object.assign({},e,t)),(function(o){const i=l[o]||r,s=i(e[o],t[o],o);W.isUndefined(s)&&i!==a||(n[o]=s)})),n}var je=e=>{const t=Me({},e);let n,{data:o,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:s,headers:a,auth:l}=t;if(t.headers=a=Oe.from(a),t.url=se(xe(t.baseURL,t.url),e.params,e.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),W.isFormData(o))if(ge.hasStandardBrowserEnv||ge.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(n=a.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(ge.hasStandardBrowserEnv&&(r&&W.isFunction(r)&&(r=r(t)),r||!1!==r&&Ue(t.url))){const e=i&&s&&Le.read(s);e&&a.set(i,e)}return t},Be="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const o=je(e);let r=o.data;const i=Oe.from(o.headers).normalize();let s,a,l,c,u,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=o;function E(){c&&c(),u&&u(),o.cancelToken&&o.cancelToken.unsubscribe(s),o.signal&&o.signal.removeEventListener("abort",s)}let g=new XMLHttpRequest;function f(){if(!g)return;const o=Oe.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());Ne((function(e){t(e),E()}),(function(e){n(e),E()}),{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:o,config:e,request:g}),g=null}g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout,"onloadend"in g?g.onloadend=f:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(f)},g.onabort=function(){g&&(n(new z("Request aborted",z.ECONNABORTED,e,g)),g=null)},g.onerror=function(){n(new z("Network Error",z.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){let t=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const r=o.transitional||le;o.timeoutErrorMessage&&(t=o.timeoutErrorMessage),n(new z(t,r.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,e,g)),g=null},void 0===r&&i.setContentType(null),"setRequestHeader"in g&&W.forEach(i.toJSON(),(function(e,t){g.setRequestHeader(t,e)})),W.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),d&&"json"!==d&&(g.responseType=o.responseType),p&&([l,u]=Pe(p,!0),g.addEventListener("progress",l)),h&&g.upload&&([a,c]=Pe(h),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",c)),(o.cancelToken||o.signal)&&(s=t=>{g&&(n(!t||t.type?new Te(null,e,g):t),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(s),o.signal&&(o.signal.aborted?s():o.signal.addEventListener("abort",s)));const m=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(o.url);m&&-1===ge.protocols.indexOf(m)?n(new z("Unsupported protocol "+m+":",z.ERR_BAD_REQUEST,e)):g.send(r||null)}))},Fe=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,o=new AbortController;const r=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;o.abort(t instanceof z?t:new Te(t instanceof Error?t.message:t))}};let i=t&&setTimeout((()=>{i=null,r(new z(`timeout ${t} of ms exceeded`,z.ETIMEDOUT))}),t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)})),e=null)};e.forEach((e=>e.addEventListener("abort",r)));const{signal:a}=o;return a.unsubscribe=()=>W.asap(s),a}};const Ve=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let o,r=0;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},qe=(e,t,n,o)=>{const r=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Ve(n,t)}(e,t);let i,s=0,a=e=>{i||(i=!0,o&&o(e))};return new ReadableStream({async pull(e){try{const{done:t,value:o}=await r.next();if(t)return a(),void e.close();let i=o.byteLength;if(n){let e=s+=i;n(e)}e.enqueue(new Uint8Array(o))}catch(e){throw a(e),e}},cancel:e=>(a(e),r.return())},{highWaterMark:2})},He="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Ge=He&&"function"==typeof ReadableStream,$e=He&&("function"==typeof TextEncoder?(Qe=new TextEncoder,e=>Qe.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Qe;const We=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},ze=Ge&&We((()=>{let e=!1;const t=new Request(ge.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Ke=Ge&&We((()=>W.isReadableStream(new Response("").body))),Ye={stream:Ke&&(e=>e.body)};var Xe;He&&(Xe=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Ye[e]&&(Ye[e]=W.isFunction(Xe[e])?t=>t[e]():(t,n)=>{throw new z(`Response type '${e}' is not supported`,z.ERR_NOT_SUPPORT,n)})})));const Je={http:null,xhr:Be,fetch:He&&(async e=>{let{url:t,method:n,data:o,signal:r,cancelToken:i,timeout:s,onDownloadProgress:a,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:h}=je(e);c=c?(c+"").toLowerCase():"text";let p,E=Fe([r,i&&i.toAbortSignal()],s);const g=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let f;try{if(l&&ze&&"get"!==n&&"head"!==n&&0!==(f=await(async(e,t)=>{const n=W.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(W.isBlob(e))return e.size;if(W.isSpecCompliantForm(e)){const t=new Request(ge.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return W.isArrayBufferView(e)||W.isArrayBuffer(e)?e.byteLength:(W.isURLSearchParams(e)&&(e+=""),W.isString(e)?(await $e(e)).byteLength:void 0)})(t):n})(u,o))){let e,n=new Request(t,{method:"POST",body:o,duplex:"half"});if(W.isFormData(o)&&(e=n.headers.get("content-type"))&&u.setContentType(e),n.body){const[e,t]=we(f,Pe(De(l)));o=qe(n.body,65536,e,t)}}W.isString(d)||(d=d?"include":"omit");const r="credentials"in Request.prototype;p=new Request(t,{...h,signal:E,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:r?d:void 0});let i=await fetch(p);const s=Ke&&("stream"===c||"response"===c);if(Ke&&(a||s&&g)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=i[t]}));const t=W.toFiniteNumber(i.headers.get("content-length")),[n,o]=a&&we(t,Pe(De(a),!0))||[];i=new Response(qe(i.body,65536,n,(()=>{o&&o(),g&&g()})),e)}c=c||"text";let m=await Ye[W.findKey(Ye,c)||"text"](i,e);return!s&&g&&g(),await new Promise(((t,n)=>{Ne(t,n,{data:m,headers:Oe.from(i.headers),status:i.status,statusText:i.statusText,config:e,request:p})}))}catch(t){if(g&&g(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new z("Network Error",z.ERR_NETWORK,e,p),{cause:t.cause||t});throw z.from(t,t&&t.code,e,p)}})};W.forEach(Je,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Ze=e=>`- ${e}`,et=e=>W.isFunction(e)||null===e||!1===e;var tt=e=>{e=W.isArray(e)?e:[e];const{length:t}=e;let n,o;const r={};for(let i=0;i<t;i++){let t;if(n=e[i],o=n,!et(n)&&(o=Je[(t=String(n)).toLowerCase()],void 0===o))throw new z(`Unknown adapter '${t}'`);if(o)break;r[t||"#"+i]=o}if(!o){const e=Object.entries(r).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new z("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ze).join("\n"):" "+Ze(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o};function nt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Te(null,e)}function ot(e){return nt(e),e.headers=Oe.from(e.headers),e.data=Ie.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),tt(e.adapter||Re.adapter)(e).then((function(t){return nt(e),t.data=Ie.call(e,e.transformResponse,t),t.headers=Oe.from(t.headers),t}),(function(t){return Ce(t)||(nt(e),t&&t.response&&(t.response.data=Ie.call(e,e.transformResponse,t.response),t.response.headers=Oe.from(t.response.headers))),Promise.reject(t)}))}const rt={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{rt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const it={};rt.transitional=function(e,t,n){function o(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,r,i)=>{if(!1===e)throw new z(o(r," has been removed"+(t?" in "+t:"")),z.ERR_DEPRECATED);return t&&!it[r]&&(it[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,i)}},rt.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var st={assertOptions:function(e,t,n){if("object"!=typeof e)throw new z("options must be an object",z.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let r=o.length;for(;r-- >0;){const i=o[r],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new z("option "+i+" must be "+n,z.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new z("Unknown option "+i,z.ERR_BAD_OPTION)}},validators:rt};const at=st.validators;class lt{constructor(e){this.defaults=e,this.interceptors={request:new ae,response:new ae}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Me(this.defaults,t);const{transitional:n,paramsSerializer:o,headers:r}=t;void 0!==n&&st.assertOptions(n,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=o&&(W.isFunction(o)?t.paramsSerializer={serialize:o}:st.assertOptions(o,{encode:at.function,serialize:at.function},!0)),st.assertOptions(t,{baseUrl:at.spelling("baseURL"),withXsrfToken:at.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=r&&W.merge(r.common,r[t.method]);r&&W.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete r[e]})),t.headers=Oe.concat(i,r);const s=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const l=[];let c;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let u,d=0;if(!a){const e=[ot.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=s.length;let h=t;for(d=0;d<u;){const e=s[d++],t=s[d++];try{h=e(h)}catch(e){t.call(this,e);break}}try{c=ot.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return se(xe((e=Me(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}W.forEach(["delete","get","head","options"],(function(e){lt.prototype[e]=function(t,n){return this.request(Me(n||{},{method:e,url:t,data:(n||{}).data}))}})),W.forEach(["post","put","patch"],(function(e){function t(t){return function(n,o,r){return this.request(Me(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}lt.prototype[e]=t(),lt.prototype[e+"Form"]=t(!0)}));var ct=lt;class ut{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const o=new Promise((e=>{n.subscribe(e),t=e})).then(e);return o.cancel=function(){n.unsubscribe(t)},o},e((function(e,o,r){n.reason||(n.reason=new Te(e,o,r),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ut((function(t){e=t})),cancel:e}}}var dt=ut;const ht={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ht).forEach((([e,t])=>{ht[t]=e}));var pt=ht;const Et=function e(t){const n=new ct(t),r=o(ct.prototype.request,n);return W.extend(r,ct.prototype,n,{allOwnKeys:!0}),W.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Me(t,n))},r}(Re);Et.Axios=ct,Et.CanceledError=Te,Et.CancelToken=dt,Et.isCancel=Ce,Et.VERSION="1.7.9",Et.toFormData=te,Et.AxiosError=z,Et.Cancel=Et.CanceledError,Et.all=function(e){return Promise.all(e)},Et.spread=function(e){return function(t){return e.apply(null,t)}},Et.isAxiosError=function(e){return W.isObject(e)&&!0===e.isAxiosError},Et.mergeConfig=Me,Et.AxiosHeaders=Oe,Et.formToJSON=e=>fe(W.isHTMLForm(e)?new FormData(e):e),Et.getAdapter=tt,Et.HttpStatusCode=pt,Et.default=Et,e.exports=Et}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var o={};return(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.PhoneAuthManager=e.ClientManager=e.BrowserName=e.BrowserErrorCode=e.BrowserError=e.AuthenticationStrategy=e.UseCase=e.createErrorBreadcrumb=e.serializeError=e.isRetryableError=e.getRetryDelay=e.isErrorCode=e.getUserMessage=e.isUserError=e.isPhoneAuthError=e.PhoneAuthErrorCode=e.PhoneAuthClient=void 0;var t=n(514);Object.defineProperty(e,"PhoneAuthClient",{enumerable:!0,get:function(){return t.PhoneAuthClient}});var r=n(514);Object.defineProperty(e,"PhoneAuthErrorCode",{enumerable:!0,get:function(){return r.PhoneAuthErrorCode}}),Object.defineProperty(e,"isPhoneAuthError",{enumerable:!0,get:function(){return r.isPhoneAuthError}}),Object.defineProperty(e,"isUserError",{enumerable:!0,get:function(){return r.isUserError}}),Object.defineProperty(e,"getUserMessage",{enumerable:!0,get:function(){return r.getUserMessage}}),Object.defineProperty(e,"isErrorCode",{enumerable:!0,get:function(){return r.isErrorCode}}),Object.defineProperty(e,"getRetryDelay",{enumerable:!0,get:function(){return r.getRetryDelay}}),Object.defineProperty(e,"isRetryableError",{enumerable:!0,get:function(){return r.isRetryableError}}),Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(e,"createErrorBreadcrumb",{enumerable:!0,get:function(){return r.createErrorBreadcrumb}});var i=n(931);Object.defineProperty(e,"UseCase",{enumerable:!0,get:function(){return i.USE_CASE}}),Object.defineProperty(e,"AuthenticationStrategy",{enumerable:!0,get:function(){return i.AUTHENTICATION_STRATEGY}}),Object.defineProperty(e,"BrowserError",{enumerable:!0,get:function(){return i.BrowserError}}),Object.defineProperty(e,"BrowserErrorCode",{enumerable:!0,get:function(){return i.BrowserErrorCode}}),Object.defineProperty(e,"BrowserName",{enumerable:!0,get:function(){return i.BrowserName}});var s=n(982);Object.defineProperty(e,"ClientManager",{enumerable:!0,get:function(){return s.VanillaClient}});var a=n(724);Object.defineProperty(e,"PhoneAuthManager",{enumerable:!0,get:function(){return a.PhoneAuthManager}})})(),o})()));
1
+ !function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.GlideWebClientSDK=e():n.GlideWebClientSDK=e()}(this,()=>(()=>{"use strict";var n={d:(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},e={};n.r(e),n.d(e,{AUTHENTICATION_STRATEGY:()=>i,AuthModal:()=>x,ERROR_CODES:()=>s,PhoneAuthClient:()=>E,USE_CASE:()=>t,createAuthError:()=>h,createQRCodeDataFromDesktop:()=>w,getUserMessage:()=>p,isAuthCredential:()=>S,isAuthError:()=>d,isCancellable:()=>_,isClientError:()=>c,isDesktopData:()=>T,isDesktopStrategy:()=>I,isErrorResponse:()=>D,isGetPhoneNumberResponse:()=>P,isInvokeResult:()=>C,isLinkData:()=>O,isLinkStrategy:()=>R,isRetryableError:()=>g,isTS43Data:()=>N,isTS43Strategy:()=>A,isVerifyPhoneNumberResponse:()=>L,validatePhoneNumber:()=>r,validatePlmn:()=>a});const t={GET_PHONE_NUMBER:"GetPhoneNumber",VERIFY_PHONE_NUMBER:"VerifyPhoneNumber"},i={TS43:"ts43",LINK:"link",DESKTOP:"desktop"},o=/^\+[1-9]\d{1,14}$/;function r(n){return n?n.startsWith("+")?n.length<8?{valid:!1,error:"Phone number too short for E.164 format (minimum 8 characters including +)"}:n.length>16?{valid:!1,error:"Phone number too long for E.164 format (maximum 15 digits after +)"}:/^\+\d+$/.test(n)?o.test(n)?{valid:!0}:{valid:!1,error:"Invalid E.164 phone number format"}:{valid:!1,error:"Phone number contains invalid characters. E.164 format only allows + followed by digits"}:{valid:!1,error:"Phone number must be in E.164 format (start with +)"}:{valid:!0}}function a(n){if(!n)return{valid:!0};const{mcc:e,mnc:t}=n;return e&&/^\d{3}$/.test(e)?t&&/^\d{2,3}$/.test(t)?{valid:!0}:{valid:!1,error:"MNC must be 2 or 3 digits"}:{valid:!1,error:"MCC must be exactly 3 digits"}}const s={INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",INVALID_PLMN:"INVALID_PLMN",MISSING_PARAMETERS:"MISSING_PARAMETERS",BROWSER_NOT_SUPPORTED:"BROWSER_NOT_SUPPORTED",UNSUPPORTED_STRATEGY:"UNSUPPORTED_STRATEGY",USER_CANCELLED:"USER_CANCELLED",CANCELLED:"CANCELLED",VERIFICATION_FAILED:"VERIFICATION_FAILED",NETWORK_ERROR:"NETWORK_ERROR",TIMEOUT:"TIMEOUT",INVALID_RESPONSE:"INVALID_RESPONSE"},l={[s.INVALID_PHONE_NUMBER]:"Please enter a valid phone number in E.164 format (e.g., +14155551234).",[s.INVALID_PLMN]:"Invalid carrier information provided.",[s.MISSING_PARAMETERS]:"Required information is missing.",[s.BROWSER_NOT_SUPPORTED]:"Your browser does not support this authentication method. Please use Chrome or Edge with the Digital Credentials flag enabled.",[s.UNSUPPORTED_STRATEGY]:"This authentication strategy is not supported.",[s.USER_CANCELLED]:"Authentication was cancelled.",[s.CANCELLED]:"Authentication was cancelled.",[s.VERIFICATION_FAILED]:"Verification failed. Please try again.",[s.NETWORK_ERROR]:"Network connection failed. Please check your connection and try again.",[s.TIMEOUT]:"Request timed out. Please try again.",[s.INVALID_RESPONSE]:"Invalid response received."};function d(n){return null!==n&&"object"==typeof n&&"code"in n&&"message"in n&&"string"==typeof n.code&&"string"==typeof n.message}function c(n){return Object.values(s).includes(n.code)}function g(n){return n.code===s.NETWORK_ERROR||n.code===s.TIMEOUT}function p(n){return c(n)&&l[n.code]||n.message}function h(n,e,t){const i=new Error(e||l[n]||n);return i.code=n,i.details=t,i.timestamp=(new Date).toISOString(),i}const u=/(\+?[1-9]\d{6,14})/g,b=/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/g,m=/(eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*)/g,f=/session[_-]?key["']?\s*[:=]\s*["']?([a-zA-Z0-9_-]{20,})["']?/gi;function y(n){if(null==n)return n;if("string"==typeof n){let e=n;return e=e.replace(u,n=>n.length<8?n:n.slice(0,2)+"***"+n.slice(-4)),e=e.replace(b,n=>{const[e,t]=n.split("@");return e.slice(0,1)+"***@"+t}),e=e.replace(m,"[JWT]"),e=e.replace(f,(n,e)=>n.replace(e,e.slice(0,4)+"***"+e.slice(-4))),e}if(Array.isArray(n))return n.map(y);if("object"==typeof n){const e={};for(const[t,i]of Object.entries(n))["phone_number","phoneNumber","credential","token","password","secret"].some(n=>t.toLowerCase().includes(n.toLowerCase()))?e[t]="string"==typeof i?"[REDACTED]":i:e[t]=y(i);return e}return n}function v(n){const{sessionKey:e,interval:t=2e3,maxAttempts:i=30,pollingEndpoint:o,statusUrl:r,logger:a}=n;let l,d,c=0,g=!1,p=!1;function u(){p=!1,l&&(clearInterval(l),l=void 0)}return{start:function(){return new Promise((n,s)=>{d=s,p=!0,c=0;const h=async()=>{if(p&&!g){if(c>=i)return u(),a?.warn("Polling timeout reached",{attempts:c,maxAttempts:i}),void n({status:"expired",message:"Authentication timeout"});try{const t=o?(a?.debug("Using developer config endpoint for polling",{pollingEndpoint:o}),`${o}/${e}`):r?(a?.debug("Using backend status_url for polling",{statusUrl:r}),r):(a?.debug("Using prod fallback for status polling"),`https://api.glideidentity.app/public/status/${e}`);a?.debug("Polling status",{url:t,attempt:c+1,maxAttempts:i});const s=await fetch(t,{method:"GET",headers:{Accept:"application/json"}});if(200===s.status){const t=await s.json();if("completed"===t.status)return u(),a?.info("Authentication completed"),void n({status:"completed",credential:t.credential||e,session:t.session||{session_key:e}});c++}else if(410===s.status){u();const e=await s.json().catch(()=>({}));n({status:"expired",message:e.message||"Session expired"})}else if(422===s.status){u();const e=await s.json().catch(()=>({}));n({status:"error",message:e.message||"Authentication failed"})}else 404===s.status?(u(),n({status:"error",message:"Session not found"})):c++}catch(n){a?.debug("Polling error, retrying",{error:n,attempt:c+1}),c++}}};h(),l=setInterval(h,t)})},stop:u,cancel:function(){a?.debug("Polling cancelled"),g=!0,u(),d&&(d(h(s.CANCELLED,"Authentication cancelled")),d=void 0)},isPolling:function(){return void 0!==l},cleanup:function(){u(),g=!1,d=void 0}}}class x{constructor(n){this.container=null,this.backdrop=null,this.isOpen=!1,this.currentStep="os-choice",this.qrCodeData=null,this.statusMessage="",this.originalBodyOverflow="",this.isClosing=!1,this.iconApple='<svg class="glide-icon glide-icon-os" viewBox="0 0 384 512" fill="currentColor"><path d="M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 52.3-11.4 69.5-34.3z"/></svg>',this.iconAndroid='<svg class="glide-icon glide-icon-os" viewBox="0 0 576 512" fill="currentColor"><path d="M420.55,301.93a24,24,0,1,1,24-24,24,24,0,0,1-24,24m-265.1,0a24,24,0,1,1,24-24,24,24,0,0,1-24,24m273.7-144.48,47.94-83a10,10,0,1,0-17.27-10h0l-48.54,84.07a301.25,301.25,0,0,0-246.56,0L116.18,64.45a10,10,0,1,0-17.27,10h0l47.94,83C64.53,202.22,8.24,285.55,0,384H576c-8.24-98.45-64.54-181.78-146.85-226.55"/></svg>',this.iconBack='<svg class="glide-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',this.options=n||{},this.theme=this.options.theme||"auto",this.handleEscapeKey=this.handleEscapeKey.bind(this)}shouldUseDarkMode(){return"dark"===this.theme||"light"!==this.theme&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}handleEscapeKey(n){"Escape"===n.key&&this.isOpen&&!1!==this.options?.closeOnEscape&&(this.closeCallback?.(),this.close())}escapeHtml(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}showQRCode(n,e="Scan with your phone camera"){this.qrCodeData=n,this.statusMessage=e;const t=this.options.viewMode||"toggle";if("string"==typeof n)this.renderToggleMode(n,e);else switch(t){case"dual":this.renderDualMode(n,e);break;case"pre-step":this.renderPreStepMode(n,e);break;default:this.renderToggleMode(n,e)}this.show()}updateStatus(n,e=!1){if(this.statusMessage=n,this.container){const t=this.container.querySelector("#glide-status");t&&(t.textContent=n,t.style.color=e?"#ff3b30":"")}}setCloseCallback(n){this.closeCallback=n}renderToggleMode(n,e){let t="",i="";"string"==typeof n?(t=n,i=n):(t=n.iosQRCode,i=n.androidQRCode||n.iosQRCode);const o=`\n <div class="glide-content">\n <div class="glide-toggle" id="glide-toggle" data-active="ios">\n <div class="glide-toggle-slider"></div>\n <button class="glide-btn glide-toggle-btn active" data-platform="ios">${this.iconApple}<span>iOS</span></button>\n <button class="glide-btn glide-toggle-btn" data-platform="android">${this.iconAndroid}<span>Android</span></button>\n </div>\n\n <div class="glide-qr-area">\n <img \n class="glide-qr-img"\n id="glide-qr-img" \n src="${this.escapeHtml(t)}" \n alt="QR Code" \n class="glide-qr-img" \n data-ios="${this.escapeHtml(t)}"\n data-android="${this.escapeHtml(i)}"\n />\n \n \x3c!-- Animation Overlay (Inside QR Area for centering) --\x3e\n <div id="glide-phone-overlay" class="glide-phone-animation-overlay">\n <div class="glide-outlined-phone">\n <div class="glide-scan-line"></div>\n </div>\n </div>\n </div>\n </div>\n `;this.createModal(o,"",!0),this.setupPlatformToggles(),this.setupHelpInteraction()}renderDualMode(n,e){const t='\n <div class="glide-phone-animation-overlay">\n <div class="glide-outlined-phone">\n <div class="glide-scan-line"></div>\n </div>\n </div>\n ';this.createModal(`\n <div class="glide-content glide-dual-mode">\n <div class="glide-dual-container">\n <div class="glide-dual-item">\n <div class="glide-os-logo">\n ${this.iconApple}\n <span>iOS</span>\n </div>\n <div class="glide-qr-area">\n <img src="${this.escapeHtml(n.iosQRCode)}" alt="iOS QR" class="glide-qr-img" />\n ${t}\n </div>\n </div>\n <div class="glide-dual-separator">\n <div class="glide-separator-line"></div>\n <span class="glide-separator-text">or</span>\n <div class="glide-separator-line"></div>\n </div>\n <div class="glide-dual-item">\n <div class="glide-os-logo">\n ${this.iconAndroid}\n <span>Android</span>\n </div>\n <div class="glide-qr-area">\n <img src="${this.escapeHtml(n.androidQRCode||n.iosQRCode)}" alt="Android QR" class="glide-qr-img" />\n ${t}\n </div>\n </div>\n </div>\n </div>\n `,"glide-modal-wide",!0),this.setupHelpInteraction()}renderPreStepMode(n,e){this.currentStep="os-choice";const t=`\n <div class="glide-pre-step-container">\n <button class="glide-os-choice-btn" id="glide-btn-ios">\n ${this.iconApple}\n <span>iOS</span>\n </button>\n <button class="glide-os-choice-btn" id="glide-btn-android">\n ${this.iconAndroid}\n <span>Android</span>\n </button>\n </div>\n `;this.createModal(t,"",!1),this.setupPreStepListeners(),this.show()}setupPreStepListeners(){this.container&&(this.container.querySelector("#glide-btn-ios")?.addEventListener("click",()=>{this.currentStep="ios-qr",this.updatePreStepUI()}),this.container.querySelector("#glide-btn-android")?.addEventListener("click",()=>{this.currentStep="android-qr",this.updatePreStepUI()}))}updatePreStepUI(){if(!this.container)return;let n="";if("os-choice"===this.currentStep)n=`\n <div class="glide-pre-step-container">\n <button class="glide-os-choice-btn" id="glide-btn-ios">\n ${this.iconApple}\n <span>iOS</span>\n </button>\n <button class="glide-os-choice-btn" id="glide-btn-android">\n ${this.iconAndroid}\n <span>Android</span>\n </button>\n </div>\n `,this.createModal(n,"",!1),this.setupPreStepListeners();else if("ios-qr"===this.currentStep){const e="object"==typeof this.qrCodeData&&this.qrCodeData?.iosQRCode?this.qrCodeData.iosQRCode:this.qrCodeData;n=`\n <div class="glide-content">\n <div class="glide-qr-area">\n <img src="${this.escapeHtml(e)}" alt="QR Code" class="glide-qr-img" />\n \n \x3c!-- Animation Overlay --\x3e\n <div id="glide-phone-overlay" class="glide-phone-animation-overlay">\n <div class="glide-outlined-phone">\n <div class="glide-scan-line"></div>\n </div>\n </div>\n </div>\n </div>\n `,this.createModal(n,"",!0,!0),this.setupBackButton(),this.setupHelpInteraction()}else if("android-qr"===this.currentStep){const e="object"==typeof this.qrCodeData&&this.qrCodeData?.androidQRCode?this.qrCodeData.androidQRCode:"object"==typeof this.qrCodeData&&this.qrCodeData?.iosQRCode?this.qrCodeData.iosQRCode:this.qrCodeData;n=`\n <div class="glide-content">\n <div class="glide-qr-area">\n <img src="${this.escapeHtml(e)}" alt="QR Code" class="glide-qr-img" />\n \n \x3c!-- Animation Overlay --\x3e\n <div id="glide-phone-overlay" class="glide-phone-animation-overlay">\n <div class="glide-outlined-phone">\n <div class="glide-scan-line"></div>\n </div>\n </div>\n </div>\n </div>\n `,this.createModal(n,"",!0,!0),this.setupBackButton(),this.setupHelpInteraction()}}setupBackButton(){this.container&&this.container.querySelector("#glide-back-btn")?.addEventListener("click",()=>{this.currentStep="os-choice",this.updatePreStepUI()})}createModal(n,e="",t=!1,i=!1){this.isClosing&&(this.isClosing=!1,this.cleanup()),this.container?(this.container.className=`glide-modal ${e}`,this.shouldUseDarkMode()&&this.container.classList.add("dark")):(this.backdrop=document.createElement("div"),this.backdrop.className="glide-backdrop",this.backdrop.id="glide-backdrop",this.container=document.createElement("div"),this.container.className=`glide-modal ${e}`,this.container.id="glide-modal",this.shouldUseDarkMode()&&this.container.classList.add("dark"),this.isOpen&&(document.body.appendChild(this.backdrop),document.body.appendChild(this.container))),this.container.innerHTML=`\n ${i?`\n <button class="glide-btn glide-btn-back" id="glide-back-btn" aria-label="Back">\n ${this.iconBack}\n </button>\n `:""}\n ${!1!==this.options?.showCloseButton?'\n <button class="glide-btn glide-btn-close" id="glide-close-btn" aria-label="Close">\n <svg class="glide-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n ':""}\n <h2 class="glide-title">${this.options?.title||"Scan to Verify"}</h2>\n <div id="glide-modal-content">${n}</div>\n <p class="glide-status" id="glide-status">${this.options?.description||""}</p>\n ${t?'\n <button class="glide-btn glide-btn-help" id="glide-help-btn">?</button>\n ':""}\n `,this.injectStyles();const o=this.container.querySelector("#glide-close-btn");o&&o.addEventListener("click",()=>{this.closeCallback?.(),this.close()}),this.backdrop&&(this.backdrop.onclick=n=>{n.target===this.backdrop&&!1!==this.options?.closeOnBackdropClick&&(this.closeCallback?.(),this.close())})}setupHelpInteraction(){const n=this.container?.querySelector("#glide-help-btn");n&&n.addEventListener("click",()=>{const n=this.container?.querySelectorAll(".glide-phone-animation-overlay");n&&n.forEach(n=>{n.classList.remove("playing"),n.offsetWidth,n.classList.add("playing"),setTimeout(()=>{n.classList.remove("playing")},3e3)})})}injectStyles(){if(document.getElementById("glide-modal-styles"))return;const n=document.createElement("style");n.id="glide-modal-styles",n.textContent='\n :root {\n --glide-primary: #007AFF;\n --glide-text: #1d1d1f;\n --glide-bg-light: rgba(255, 255, 255, 0.6);\n --glide-bg-dark: rgba(30, 30, 30, 0.6);\n --glide-phone-border: #000000; /* High Contrast Black */\n \n /* Button sizes */\n --glide-btn-size: 28px;\n --glide-help-btn-size: 24px;\n --glide-toggle-icon-size: 14px;\n --glide-dual-icon-size: 18px;\n }\n\n #glide-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.2);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n z-index: 9998;\n opacity: 0;\n transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);\n }\n\n #glide-modal {\n position: fixed;\n top: 20px;\n left: 50%;\n transform: translateX(-50%) scale(0.94);\n background: var(--glide-bg-light);\n backdrop-filter: blur(24px) saturate(180%);\n -webkit-backdrop-filter: blur(24px) saturate(180%);\n border-radius: 24px;\n padding: 32px;\n width: 360px;\n max-width: 90%;\n box-shadow: \n 0 20px 40px rgba(0,0,0,0.2),\n 0 0 0 1px rgba(255,255,255,0.6) inset,\n 0 0 0 1px rgba(0,0,0,0.05);\n z-index: 9999;\n opacity: 0;\n transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n text-align: center;\n color: var(--glide-text);\n }\n \n #glide-modal.glide-modal-wide {\n width: 600px;\n max-width: 95vw;\n }\n\n #glide-modal.dark {\n background: var(--glide-bg-dark);\n color: white;\n box-shadow: \n 0 20px 40px rgba(0,0,0,0.4),\n 0 0 0 1px rgba(255,255,255,0.15) inset,\n 0 0 0 1px rgba(0,0,0,0.5);\n --glide-phone-border: #ffffff; /* High Contrast White */\n }\n\n #glide-modal .glide-btn-close {\n position: absolute;\n top: 16px;\n right: 16px;\n width: var(--glide-btn-size);\n height: var(--glide-btn-size);\n min-width: var(--glide-btn-size);\n min-height: var(--glide-btn-size);\n max-width: var(--glide-btn-size);\n max-height: var(--glide-btn-size);\n background: rgba(118, 118, 128, 0.12);\n border: none;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n color: rgba(0,0,0,0.5);\n transition: background 0.2s;\n padding: 0;\n z-index: 20;\n box-sizing: border-box;\n flex-shrink: 0;\n }\n\n #glide-modal.dark .glide-btn-close {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255,255,255,0.5);\n }\n\n #glide-modal .glide-btn-close:hover {\n background: rgba(118, 118, 128, 0.2);\n }\n \n #glide-modal.dark .glide-btn-close:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n\n .glide-title {\n margin: 0 0 8px 0;\n font-size: 22px;\n font-weight: 600;\n letter-spacing: -0.01em;\n }\n \n .glide-status {\n margin: 12px 0 0 0;\n font-size: 13px;\n color: rgba(0,0,0,0.5);\n text-align: center;\n min-height: 18px;\n }\n \n .glide-status:empty {\n display: none;\n }\n \n #glide-modal.dark .glide-status {\n color: rgba(255,255,255,0.5);\n }\n \n .glide-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n position: relative;\n }\n \n /* --- Sliding Toggle Switch --- */\n #glide-toggle {\n background: rgba(118, 118, 128, 0.12);\n padding: 2px;\n border-radius: 8px;\n display: inline-flex;\n margin-bottom: 24px;\n margin-top: 16px;\n position: relative;\n height: 32px;\n width: 200px;\n box-sizing: border-box;\n }\n\n #glide-modal.dark #glide-toggle {\n background: rgba(118, 118, 128, 0.24);\n }\n \n /* The sliding background */\n .glide-toggle-slider {\n position: absolute;\n top: 2px;\n left: 2px;\n width: calc(50% - 2px);\n height: calc(100% - 4px);\n background: white;\n border-radius: 6px;\n box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 3px 1px rgba(0,0,0,0.04);\n transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);\n z-index: 0;\n }\n \n #glide-modal.dark .glide-toggle-slider {\n background: #636366;\n }\n \n /* Move slider for Android */\n #glide-toggle[data-active="android"] .glide-toggle-slider {\n transform: translateX(100%);\n }\n\n .glide-toggle-btn {\n flex: 1;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n font-size: 13px;\n font-weight: 500;\n color: inherit;\n cursor: pointer;\n position: relative;\n z-index: 1;\n transition: color 0.2s;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n min-height: auto;\n height: auto;\n min-width: auto;\n border-radius: 0;\n }\n \n #glide-modal .glide-toggle-btn .glide-icon-os,\n #glide-modal .glide-toggle-btn svg {\n width: var(--glide-toggle-icon-size);\n height: var(--glide-toggle-icon-size);\n flex-shrink: 0;\n margin: 0;\n padding: 0;\n }\n \n .glide-toggle-btn span {\n margin: 0;\n padding: 0;\n line-height: 1;\n }\n \n #glide-modal.dark .glide-toggle-btn {\n color: rgba(255,255,255,0.6);\n }\n \n #glide-toggle[data-active="ios"] .glide-toggle-btn[data-platform="ios"],\n #glide-toggle[data-active="android"] .glide-toggle-btn[data-platform="android"] {\n color: #1d1d1f;\n }\n \n #glide-modal.dark #glide-toggle[data-active="ios"] .glide-toggle-btn[data-platform="ios"],\n #glide-modal.dark #glide-toggle[data-active="android"] .glide-toggle-btn[data-platform="android"] {\n color: white;\n }\n\n /* QR Area */\n .glide-qr-area {\n position: relative;\n margin: 0 auto;\n }\n\n .glide-qr-img {\n width: 200px;\n height: 200px;\n object-fit: contain;\n display: block;\n border-radius: 16px;\n }\n \n /* Dual Mode QR Area - no extra padding, same as single mode */\n .glide-dual-mode .glide-qr-area {\n background: transparent;\n padding: 0;\n }\n \n .glide-dual-mode .glide-qr-img {\n width: 180px;\n height: 180px;\n border-radius: 16px;\n }\n \n /* --- Help Icon & Interaction --- */\n .glide-btn-help {\n position: absolute;\n bottom: 20px;\n right: 20px;\n width: var(--glide-help-btn-size);\n height: var(--glide-help-btn-size);\n min-width: var(--glide-help-btn-size);\n min-height: var(--glide-help-btn-size);\n max-width: var(--glide-help-btn-size);\n max-height: var(--glide-help-btn-size);\n border-radius: 50%;\n border: 1.5px solid rgba(0,0,0,0.2);\n color: rgba(0,0,0,0.4);\n display: flex;\n align-items: center;\n justify-content: center;\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n font-size: 14px;\n font-weight: 600;\n line-height: 1;\n cursor: pointer;\n transition: all 0.2s;\n background: transparent;\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n z-index: 10;\n }\n \n #glide-modal.dark .glide-btn-help {\n border-color: rgba(255,255,255,0.3);\n color: rgba(255,255,255,0.5);\n }\n\n .glide-btn-help:hover {\n border-color: var(--glide-primary);\n color: var(--glide-primary);\n background: rgba(0, 122, 255, 0.1);\n }\n \n /* Tooltip */\n .glide-btn-help::after {\n content: "Need help?";\n position: absolute;\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%) translateY(-8px);\n background: rgba(0,0,0,0.8);\n color: white;\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 11px;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s;\n }\n \n .glide-btn-help:hover::after {\n opacity: 1;\n }\n\n /* --- Outlined Phone Animation --- */\n .glide-phone-animation-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.3s;\n border-radius: 16px;\n background: rgba(255,255,255,0.8);\n }\n \n #glide-modal.dark .glide-phone-animation-overlay {\n background: rgba(0,0,0,0.6);\n }\n \n .glide-phone-animation-overlay.playing {\n opacity: 1;\n }\n\n .glide-outlined-phone {\n width: 100px;\n height: 180px;\n border: 4px solid var(--glide-phone-border);\n border-radius: 16px;\n position: relative;\n background: transparent;\n box-shadow: 0 10px 30px rgba(0,0,0,0.2);\n transform: translateY(20px);\n }\n \n /* Notch */\n .glide-outlined-phone::before {\n content: \'\';\n position: absolute;\n top: -1px;\n left: 50%;\n transform: translateX(-50%);\n width: 40%;\n height: 12px;\n background: var(--glide-phone-border);\n border-bottom-left-radius: 8px;\n border-bottom-right-radius: 8px;\n }\n \n /* Scanning Line */\n .glide-scan-line {\n position: absolute;\n top: 10%;\n left: 5%;\n width: 90%;\n height: 2px;\n background: var(--glide-primary);\n box-shadow: 0 0 8px var(--glide-primary);\n opacity: 0;\n }\n \n /* Animation Keyframes */\n @keyframes glide-scan-motion {\n 0% { top: 10%; opacity: 0; }\n 10% { opacity: 1; }\n 90% { opacity: 1; }\n 100% { top: 90%; opacity: 0; }\n }\n \n .glide-phone-animation-overlay.playing .glide-outlined-phone {\n animation: glide-phone-appear 3s ease-in-out forwards;\n }\n \n .glide-phone-animation-overlay.playing .glide-scan-line {\n animation: glide-scan-motion 2s ease-in-out 0.5s infinite;\n }\n \n @keyframes glide-phone-appear {\n 0% { transform: translateY(20px); opacity: 0; }\n 10% { transform: translateY(0); opacity: 1; }\n 90% { transform: translateY(0); opacity: 1; }\n 100% { transform: translateY(20px); opacity: 0; }\n }\n \n /* Dual Mode */\n .glide-dual-container {\n display: flex;\n justify-content: center;\n align-items: stretch;\n gap: 32px;\n margin-top: 20px;\n }\n \n .glide-dual-item {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n \n .glide-os-logo {\n display: flex;\n align-items: center;\n gap: 8px;\n font-weight: 600;\n margin-bottom: 12px;\n font-size: 15px;\n color: inherit;\n }\n \n /* Dual mode OS logo - aligned icons with text, spacing to QR */\n .glide-dual-mode .glide-os-logo {\n margin-bottom: 12px; /* Space between label and QR code */\n }\n \n #glide-modal .glide-dual-mode .glide-os-logo .glide-icon-os,\n #glide-modal .glide-dual-mode .glide-os-logo svg {\n width: var(--glide-dual-icon-size);\n height: var(--glide-dual-icon-size);\n margin: 0;\n padding: 0;\n flex-shrink: 0;\n }\n \n .glide-dual-mode .glide-os-logo span {\n margin: 0;\n padding: 0;\n line-height: 1;\n }\n \n .glide-os-logo svg {\n width: 20px;\n height: 20px;\n opacity: 0.8;\n }\n \n /* Dual Mode Separator - aligned to QR codes only */\n .glide-dual-separator {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n align-self: stretch;\n /* Offset for OS label (18px icon + 12px margin = ~30px) */\n margin-top: 30px;\n padding: 20px 0;\n }\n \n .glide-separator-line {\n width: 1px;\n flex: 1;\n background: linear-gradient(to bottom, transparent, rgba(128,128,128,0.3), transparent);\n }\n \n .glide-separator-text {\n padding: 8px 0;\n font-size: 11px;\n font-weight: 500;\n color: rgba(128,128,128,0.5);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n }\n \n #glide-modal.dark .glide-separator-line {\n background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.2), transparent);\n }\n \n #glide-modal.dark .glide-separator-text {\n color: rgba(255,255,255,0.4);\n }\n \n /* Pre-Step */\n .glide-pre-step-container {\n display: flex;\n gap: 20px;\n justify-content: center;\n margin: 24px 0;\n }\n \n .glide-os-choice-btn {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 140px;\n height: 140px;\n border: 1px solid rgba(0,0,0,0.08);\n border-radius: 20px;\n background: rgba(255,255,255,0.4);\n cursor: pointer;\n transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);\n position: relative;\n overflow: hidden;\n font-size: 14px;\n color: inherit;\n }\n \n #glide-modal.dark .glide-os-choice-btn {\n background: rgba(255,255,255,0.05);\n border-color: rgba(255,255,255,0.1);\n color: white;\n }\n \n .glide-os-choice-btn:hover {\n background: rgba(255,255,255,0.9);\n transform: translateY(-4px);\n box-shadow: 0 12px 24px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.04);\n border-color: var(--glide-primary);\n }\n \n #glide-modal.dark .glide-os-choice-btn:hover {\n background: rgba(255,255,255,0.15);\n box-shadow: 0 12px 24px rgba(0,0,0,0.3);\n border-color: var(--glide-primary);\n }\n \n .glide-icon-os {\n width: 40px;\n height: 40px;\n margin-bottom: 12px;\n transition: transform 0.3s;\n fill: currentColor;\n }\n \n .glide-os-choice-btn:hover .glide-icon-os {\n transform: scale(1.1);\n }\n \n #glide-modal .glide-btn-back {\n position: absolute;\n top: 16px;\n left: 16px;\n width: var(--glide-btn-size);\n height: var(--glide-btn-size);\n min-width: var(--glide-btn-size);\n min-height: var(--glide-btn-size);\n max-width: var(--glide-btn-size);\n max-height: var(--glide-btn-size);\n background: rgba(118, 118, 128, 0.12);\n border: none;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n color: rgba(0,0,0,0.5);\n transition: background 0.2s;\n z-index: 20;\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n flex-shrink: 0;\n }\n \n #glide-modal.dark .glide-btn-back {\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255,255,255,0.5);\n }\n\n .glide-btn-back:hover {\n background: rgba(118, 118, 128, 0.2);\n }\n \n #glide-modal.dark .glide-btn-back:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n \n .glide-spinner {\n width: 40px;\n height: 40px;\n border: 3px solid rgba(0,0,0,0.1);\n border-top-color: var(--glide-primary);\n border-radius: 50%;\n animation: glide-spin 1s linear infinite;\n margin: 40px auto;\n }\n \n #glide-modal.dark .glide-spinner {\n border-color: rgba(255,255,255,0.1);\n border-top-color: var(--glide-primary);\n }\n \n @keyframes glide-spin {\n to { transform: rotate(360deg); }\n }\n ',document.head.appendChild(n)}show(){this.container&&this.backdrop&&!this.isOpen?(document.body.appendChild(this.backdrop),document.body.appendChild(this.container),this.lockBodyScroll(),document.addEventListener("keydown",this.handleEscapeKey),requestAnimationFrame(()=>{this.backdrop&&this.container&&(this.backdrop.style.opacity="1",this.container.style.opacity="1",this.container.style.transform="translateX(-50%) scale(1)")}),this.isOpen=!0):this.isOpen&&this.container&&this.backdrop&&(document.removeEventListener("keydown",this.handleEscapeKey),document.addEventListener("keydown",this.handleEscapeKey))}setupPlatformToggles(){const n=this.container?.querySelector("#glide-toggle"),e=this.container?.querySelectorAll(".glide-toggle-btn"),t=this.container?.querySelector("#glide-qr-img"),i=this.container?.querySelector("#glide-platform-message");e&&t&&e.forEach(o=>{o.addEventListener("click",o=>{const r=o.currentTarget,a=r.getAttribute("data-platform");n&&a&&n.setAttribute("data-active",a),e.forEach(n=>n.classList.remove("active")),r.classList.add("active"),"ios"===a?(t.src=t.getAttribute("data-ios")||"",i&&(i.textContent="Scan with your iPhone camera")):"android"===a&&(t.src=t.getAttribute("data-android")||"",i&&(i.textContent="Scan with your Android camera"))})})}lockBodyScroll(){this.originalBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden"}unlockBodyScroll(){document.body.style.overflow=this.originalBodyOverflow}close(){this.container&&this.backdrop&&this.isOpen&&(this.isClosing=!0,document.removeEventListener("keydown",this.handleEscapeKey),this.backdrop.style.opacity="0",this.container.style.opacity="0",this.container.style.transform="translateX(-50%) scale(0.94)",this.closeCallback=void 0,setTimeout(()=>{this.isClosing&&(this.cleanup(),this.isOpen=!1,this.isClosing=!1)},400))}cleanup(){this.container?.remove(),this.backdrop?.remove(),this.container=null,this.backdrop=null,this.unlockBodyScroll()}isModalOpen(){return this.isOpen}}function w(n){const{data:e}=n;if(e.ios_qr_image)return{iosQRCode:e.ios_qr_image,androidQRCode:e.android_qr_image||e.ios_qr_image};if(e.qr_code_image)return e.qr_code_image;throw new Error("No QR code data available")}class k{constructor(){this.logs=[],this.container=null,this.logsContainer=null,this.floatingToggle=null,this.isAtBottom=!0,this.isVisible=!0,this.originalConsole={log:console.log,error:console.error,warn:console.warn,debug:console.debug,info:console.info},this.interceptConsole(),this.createUI()}static init(){return k.instance||(k.instance=new k),k.instance}static destroy(){k.instance&&(k.instance.cleanup(),k.instance=null)}interceptConsole(){["log","error","warn","debug","info"].forEach(n=>{const e=this.originalConsole[n];console[n]=(...t)=>{e.apply(console,t),this.addLog(n,t)}})}addLog(n,e){const t=(new Date).toTimeString().split(" ")[0],i=e.map(n=>{if("object"==typeof n)try{return JSON.stringify(n,null,2)}catch{return"[Object]"}return String(n)}).join(" "),o={log:"#abb2bf",error:"#e06c75",warn:"#e5c07b",info:"#61afef",debug:"#5c6370"},r=`\n <div style="margin: 3px 0; font-family: 'SF Mono', Menlo, Monaco, monospace; font-size: 11px; color: ${o[n]||"#abb2bf"}; line-height: 1.5;">\n <span style="color: #5c6370; font-size: 10px;">${t}</span>\n <span style="background: ${{log:"#3c3c3c",error:"rgba(224, 108, 117, 0.2)",warn:"rgba(229, 192, 123, 0.2)",info:"rgba(97, 175, 239, 0.2)",debug:"#2d2d2d"}[n]}; color: ${o[n]}; padding: 1px 5px; border-radius: 3px; font-size: 9px; font-weight: 500; text-transform: uppercase; margin: 0 6px;">${n}</span>\n <span style="white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(i)}</span>\n </div>\n `;this.logs.push(r),this.logs.length>500&&this.logs.shift(),this.updateDisplay()}updateDisplay(){this.logsContainer&&this.isVisible&&(this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50,this.logsContainer.innerHTML=this.logs.join(""),this.isAtBottom&&(this.logsContainer.scrollTop=this.logsContainer.scrollHeight))}createUI(){const n=document.createElement("style");n.textContent="\n #mobile-debug-console {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n height: 45vh;\n background: #1e1e1e;\n z-index: 999999;\n display: flex;\n flex-direction: column;\n font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;\n transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n border-top: 1px solid #3c3c3c;\n box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);\n }\n \n #mobile-debug-console.hidden {\n transform: translateY(100%);\n }\n \n #debug-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 12px;\n background: #2d2d2d;\n border-bottom: 1px solid #3c3c3c;\n min-height: 36px;\n }\n \n #debug-title {\n display: flex;\n align-items: center;\n gap: 8px;\n color: #9da5b4;\n font-size: 12px;\n font-weight: 500;\n letter-spacing: 0.3px;\n }\n \n #debug-title svg {\n width: 14px;\n height: 14px;\n opacity: 0.8;\n }\n \n /* Traffic light buttons - using ID for specificity */\n #mobile-debug-console .debug-traffic-lights {\n display: flex;\n gap: 8px;\n align-items: center;\n }\n \n #mobile-debug-console button.debug-traffic-btn {\n width: 16px;\n height: 16px;\n min-width: 16px;\n min-height: 16px;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n font-size: 0;\n line-height: 1;\n }\n \n #mobile-debug-console .debug-traffic-btn svg {\n width: 8px;\n height: 8px;\n }\n \n #mobile-debug-console .debug-traffic-btn.close {\n background: #ff5f57;\n }\n \n #mobile-debug-console .debug-traffic-btn.close svg {\n stroke: #820005;\n stroke-width: 2;\n }\n \n #mobile-debug-console .debug-traffic-btn.clear {\n background: #febc2e;\n }\n \n #mobile-debug-console .debug-traffic-btn.minimize {\n background: #28c840;\n }\n \n #mobile-debug-console .debug-traffic-btn.minimize svg {\n stroke: #006500;\n stroke-width: 2;\n }\n \n #mobile-debug-console .debug-traffic-btn:active {\n filter: brightness(0.85);\n }\n \n #debug-logs {\n flex: 1;\n overflow-y: auto;\n padding: 12px;\n background: #1e1e1e;\n -webkit-overflow-scrolling: touch;\n }\n \n button#debug-floating-toggle {\n position: fixed !important;\n bottom: 20px !important;\n right: 20px !important;\n width: 42px !important;\n height: 42px !important;\n min-width: 42px !important;\n min-height: 42px !important;\n border-radius: 8px !important;\n background: #2d2d2d !important;\n border: 1px solid #3c3c3c !important;\n color: #9da5b4 !important;\n cursor: pointer !important;\n z-index: 999998 !important;\n display: none;\n align-items: center !important;\n justify-content: center !important;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;\n transition: all 0.2s ease !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n \n button#debug-floating-toggle:hover {\n background: #3c3c3c !important;\n color: #fff !important;\n transform: translateY(-2px) !important;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;\n }\n \n button#debug-floating-toggle:active {\n transform: translateY(0) !important;\n }\n \n button#debug-floating-toggle.visible {\n display: flex !important;\n }\n \n button#debug-floating-toggle svg {\n width: 20px !important;\n height: 20px !important;\n }\n ",document.head.appendChild(n);const e='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>';this.container=document.createElement("div"),this.container.id="mobile-debug-console",this.isVisible||(this.container.className="hidden");const t=document.createElement("div");t.id="debug-header";const i=document.createElement("div");i.id="debug-title",i.innerHTML=`${e}<span>Mobile Console</span>`;const o=document.createElement("div");o.className="debug-traffic-lights";const r=document.createElement("button");r.className="debug-traffic-btn close",r.title="Close",r.innerHTML='<svg viewBox="0 0 10 10" fill="none"><line x1="2.5" y1="2.5" x2="7.5" y2="7.5" stroke="currentColor"/><line x1="7.5" y1="2.5" x2="2.5" y2="7.5" stroke="currentColor"/></svg>',r.onclick=()=>this.cleanup();const a=document.createElement("button");a.className="debug-traffic-btn clear",a.title="Clear",a.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/><path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/></svg>',a.onclick=()=>this.clear();const s=document.createElement("button");s.className="debug-traffic-btn minimize",s.title="Minimize",s.innerHTML='<svg viewBox="0 0 10 10" fill="none"><path d="M2 3L5 6L8 3" stroke="currentColor" fill="none"/></svg>',s.onclick=()=>this.toggle(),o.appendChild(r),o.appendChild(a),o.appendChild(s),t.appendChild(o),t.appendChild(i),this.logsContainer=document.createElement("div"),this.logsContainer.id="debug-logs",this.logsContainer.addEventListener("scroll",()=>{this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50}),this.container.appendChild(t),this.container.appendChild(this.logsContainer),document.body.appendChild(this.container),this.floatingToggle=document.createElement("button"),this.floatingToggle.id="debug-floating-toggle",this.floatingToggle.innerHTML=e,this.floatingToggle.title="Show Console",this.floatingToggle.onclick=()=>this.toggle(),document.body.appendChild(this.floatingToggle)}escapeHtml(n){const e=document.createElement("div");return e.textContent=n,e.innerHTML}toggle(){this.isVisible=!this.isVisible,this.container&&this.floatingToggle&&(this.isVisible?(this.container.classList.remove("hidden"),this.floatingToggle.classList.remove("visible"),this.updateDisplay()):(this.container.classList.add("hidden"),this.floatingToggle.classList.add("visible")))}clear(){this.logs=[],this.logsContainer&&(this.logsContainer.innerHTML="")}cleanup(){Object.keys(this.originalConsole).forEach(n=>{console[n]=this.originalConsole[n]}),this.container&&this.container.remove(),this.floatingToggle&&this.floatingToggle.remove()}}k.instance=null;class E{constructor(n={}){this.config={...n,endpoints:{prepare:n.endpoints?.prepare||"/api/magic-auth/prepare",process:n.endpoints?.process||"/api/magic-auth/process",polling:n.endpoints?.polling},timeout:n.timeout||3e4,pollingInterval:n.pollingInterval||2e3,maxPollingAttempts:n.maxPollingAttempts||30,debug:n.debug||!1},this.http=n.httpClient||function(n={}){const{timeout:e=3e4,headers:t={},dynamicHeaders:i}=n;async function o(n,e){const o={"Content-Type":"application/json"};t.common&&Object.assign(o,t.common);const r=t[n.endpoint];if(r&&"object"==typeof r&&Object.assign(o,r),i){const e=await i(n);Object.assign(o,e)}return e&&Object.assign(o,e),o}async function r(n,e,t,i){const o=new AbortController,r=setTimeout(()=>o.abort(),t),a=i?()=>o.abort():null;i&&a&&i.addEventListener("abort",a);try{return await fetch(n,{...e,signal:o.signal})}catch(n){if(n instanceof Error&&"AbortError"===n.name){if(i?.aborted)throw h(s.CANCELLED,"Request was cancelled");throw h(s.TIMEOUT,"Request timed out")}throw h(s.NETWORK_ERROR,n instanceof Error?n.message:"Network request failed")}finally{clearTimeout(r),i&&a&&i.removeEventListener("abort",a)}}async function a(n){let e;try{e=await n.json()}catch{if(!n.ok)throw h(s.INVALID_RESPONSE,`Request failed with status ${n.status}`);throw h(s.INVALID_RESPONSE,"Failed to parse response")}if(!n.ok)throw function(n){if(n&&("code"in n||"error"in n)){const e=n,t=e.code||e.error,i=e.message,o=new Error(i||"An error occurred");return o.code=t,o.status=e.status,o.requestId=e.requestId||e.request_id,o.timestamp=e.timestamp,o.details=e.details,o.traceId=e.trace_id||e.traceId,o.spanId=e.span_id||e.spanId,o.service=e.service,e.details&&"object"==typeof e.details&&"retryAfter"in e.details&&(o.retryAfter=e.details.retryAfter),o}if(n&&"status"in n){const e=n,t=e.status,i=new Error(e.message||`Request failed with status ${t}`);return i.code=`HTTP_${t}`,i.status=t,i}const e=new Error("An unexpected error occurred");return e.code="UNKNOWN_ERROR",e}({...e,status:n.status});return e}function l(n){return n.includes("/prepare")?"prepare":n.includes("/process")||n.includes("/get-phone")||n.includes("/verify-phone")?"process":n.includes("/status")?"polling":"prepare"}return{async post(n,t,i){const s=l(n),d=await o({endpoint:s,method:"POST"},i?.headers);return a(await r(n,{method:"POST",headers:d,body:JSON.stringify(t)},i?.timeout||e,i?.signal))},async get(n,t){const i=l(n),s=await o({endpoint:i,method:"GET"},t?.headers);return delete s["Content-Type"],a(await r(n,{method:"GET",headers:s},t?.timeout||e,t?.signal))}}}({timeout:this.config.timeout,headers:n.headers,dynamicHeaders:n.dynamicHeaders}),this.logger=n.logger||(this.config.debug?function(n={}){const{debug:e=!1,prefix:t="[PhoneAuth]"}=n;function i(n,e){const i=`${t} ${n}`;return void 0!==e?[i,y(e)]:[i]}return{debug(n,t){if(e){const e=i(n,t);console.debug(...e)}},info(n,e){const t=i(n,e);console.info(...t)},warn(n,e){const t=i(n,e);console.warn(...t)},error(n,e){const t=i(n,e);console.error(...t)}}}({debug:!0}):{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}}),this.logger.debug("PhoneAuthClient initialized",{endpoints:this.config.endpoints,timeout:this.config.timeout}),n.devtools?.showMobileConsole&&"undefined"!=typeof window&&(k.init(),this.logger.info("Mobile debug console enabled"))}async authenticate(n,e){const i=await this.prepare(n),o=await this.invokeSecurePrompt(i,e),r=await o.credential,a=i.session.use_case||i.session.metadata?.use_case||n.use_case;if(!a)throw h(s.INVALID_RESPONSE,"Could not determine use_case from session or request");return a===t.VERIFY_PHONE_NUMBER?this.verifyPhoneNumber(r,i.session):this.getPhoneNumber(r,i.session)}async prepare(n){if(this.logger.debug("Preparing authentication",{use_case:n.use_case}),n.phone_number){const e=r(n.phone_number);if(!e.valid)throw h(s.INVALID_PHONE_NUMBER,e.error)}if(n.plmn){const e=a(n.plmn);if(!e.valid)throw h(s.INVALID_PLMN,e.error)}if(!n.use_case&&!n.options?.parent_session_id)throw h(s.MISSING_PARAMETERS,"use_case is required");const e={...n,id:n.id||this.generateRequestId(),client_info:n.client_info||{user_agent:navigator.userAgent,platform:navigator.platform}};try{const n=await this.http.post(this.config.endpoints.prepare,e);return this.logger.debug("Prepare successful",{strategy:n.authentication_strategy,sessionKey:n.session.session_key}),n}catch(n){throw this.logger.error("Prepare failed",n),n}}async invokeSecurePrompt(n,e){const{authentication_strategy:t,session:o,data:r}=n;switch(this.logger.debug("Invoking secure prompt",{strategy:t}),t){case i.TS43:return this.handleTS43(r,o);case i.LINK:return this.handleLink(r,o,e);case i.DESKTOP:return this.handleDesktop(r,o,e);default:throw h(s.UNSUPPORTED_STRATEGY,`Unknown strategy: ${t}`)}}async getPhoneNumber(n,e){this.logger.debug("Getting phone number");const i={session:e,credential:n.credential,use_case:t.GET_PHONE_NUMBER};try{const n=await this.http.post(this.config.endpoints.process,i);return this.logger.info("Phone number retrieved"),n}catch(n){throw this.logger.error("Get phone number failed",n),n}}async verifyPhoneNumber(n,e){this.logger.debug("Verifying phone number");const i={session:e,credential:n.credential,use_case:t.VERIFY_PHONE_NUMBER};try{const n=await this.http.post(this.config.endpoints.process,i);return this.logger.info("Phone number verified",{verified:n.verified}),n}catch(n){throw this.logger.error("Verify phone number failed",n),n}}isSupported(){return"undefined"!=typeof window&&"DigitalCredential"in window}getBrowserSupportInfo(){if("undefined"==typeof window)return{supported:!1,browser:"unknown",message:"Not in browser"};const n=navigator.userAgent,e=/Chrome/.test(n)&&/Google Inc/.test(navigator.vendor),t=/Edg\//.test(n);return this.isSupported()?{supported:!0,browser:e?"Chrome":t?"Edge":"Other"}:{supported:!1,browser:e?"Chrome":t?"Edge":"Other",message:"Enable chrome://flags/#web-identity-digital-credentials"}}async handleTS43(n,e){if(!this.isSupported())throw h(s.BROWSER_NOT_SUPPORTED,"Digital Credentials API not available");const t={digital:{requests:[{protocol:n.protocol,data:n.data}]}};return this.logger.debug("Invoking Digital Credentials API"),{credential:(async()=>{try{const n=await navigator.credentials.get(t);if(!n?.data?.vp_token)throw h(s.INVALID_RESPONSE,"No credential returned from Digital Credentials API");const i=n.data.vp_token,o="string"==typeof i?i:Object.values(i)[0],r=Array.isArray(o)?o[0]:o;if(!r||"string"==typeof r&&""===r.trim())throw h(s.INVALID_RESPONSE,"Empty credential returned from Digital Credentials API");return{credential:r,session:e,authenticated:!0}}catch(n){if(d(n))throw n;const e=n;if("NotAllowedError"===e.name||"NetworkError"===e.name&&19===e.code)throw h(s.USER_CANCELLED,"User cancelled authentication");if("NotSupportedError"===e.name)throw h(s.BROWSER_NOT_SUPPORTED,"Browser not supported");throw h(s.NETWORK_ERROR,e.message||"Credential request failed")}})(),cancel:void 0,strategy:i.TS43,session:e}}handleLink(n,e,t){if(!n.url)throw h(s.INVALID_RESPONSE,"Missing link URL");this.logger.debug("Opening App Clip",{url:n.url}),window.location.href=n.url;const o=v({sessionKey:e.session_key,interval:t?.pollingInterval||this.config.pollingInterval,maxAttempts:t?.maxPollingAttempts||this.config.maxPollingAttempts,pollingEndpoint:t?.pollingEndpoint||this.config.endpoints.polling,statusUrl:n.status_url,logger:this.logger});return{credential:o.start().then(n=>{if("completed"===n.status&&n.credential)return{credential:n.credential,session:n.session||e,authenticated:!0};throw h(s.VERIFICATION_FAILED,n.message||"Link authentication failed")}),cancel:()=>o.cancel(),strategy:i.LINK,session:e}}handleDesktop(n,e,t){const o=n.data?.session_id||e.session_key;this.logger.debug("Starting desktop authentication",{sessionId:o});const r=v({sessionKey:o,interval:t?.pollingInterval||this.config.pollingInterval,maxAttempts:t?.maxPollingAttempts||this.config.maxPollingAttempts,pollingEndpoint:t?.pollingEndpoint||this.config.endpoints.polling,statusUrl:n.data?.status_url,logger:this.logger});let a=null;if(!t?.preventDefaultUI)try{const e=w(n);a=new x(t?.modalOptions),a.showQRCode(e,t?.modalOptions?.description||"Scan with your phone camera"),a.setCloseCallback(()=>{this.logger.debug("Modal closed by user, cancelling authentication"),r.cancel()}),this.logger.debug("Desktop modal displayed")}catch(n){this.logger.warn("Failed to show modal, continuing with polling only",n)}return{credential:r.start().then(n=>{if(a&&a.close(),"completed"===n.status&&n.credential)return{credential:n.credential,session:n.session||e,authenticated:!0};throw h(s.VERIFICATION_FAILED,n.message||"Desktop authentication failed")}).catch(n=>{throw a&&a.close(),n}),cancel:()=>{r.cancel(),a&&a.close()},strategy:i.DESKTOP,session:e}}generateRequestId(){return`web-${Date.now()}-${Math.random().toString(36).substring(2,11)}`}}function C(n){return null!==n&&"object"==typeof n&&"credential"in n&&"strategy"in n&&"session"in n}function S(n){return null!==n&&"object"==typeof n&&"credential"in n&&"authenticated"in n&&"session"in n}function A(n){return n.strategy===i.TS43}function R(n){return n.strategy===i.LINK}function I(n){return n.strategy===i.DESKTOP}function _(n){return void 0!==n.cancel}function N(n){return null!==n&&"object"==typeof n&&"protocol"in n&&"data"in n&&"object"==typeof n.data&&"dcql_query"in n.data}function O(n){return null!==n&&"object"==typeof n&&"url"in n&&"string"==typeof n.url}function T(n){return null!==n&&"object"==typeof n&&"data"in n&&"object"==typeof n.data}function P(n){return!("verified"in n)}function L(n){return"verified"in n}function D(n){return null!==n&&"object"==typeof n&&"code"in n&&"message"in n}return e})());
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * Framework adapters for Phone Authentication SDK.
4
+ *
5
+ * Import from specific adapter paths for proper tree-shaking:
6
+ * - @glideidentity/web-client-sdk/react
7
+ * - @glideidentity/web-client-sdk/vue
8
+ * - @glideidentity/web-client-sdk/vanilla
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.PhoneAuthClient = void 0;
12
+ // Note: Don't import React/Vue here to avoid bundling framework deps
13
+ // Each adapter should be imported directly from its path
14
+ var phone_auth_client_1 = require("../client/phone-auth-client");
15
+ Object.defineProperty(exports, "PhoneAuthClient", { enumerable: true, get: function () { return phone_auth_client_1.PhoneAuthClient; } });