@grabjs/superapp-sdk 2.0.0-beta.48 → 2.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-reference/api.json +5138 -4446
- package/dist/index.d.ts +54 -10
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/skills/SKILL.md +30 -20
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare const AuthorizeRequestSchema: v.ObjectSchema<{
|
|
|
51
51
|
*
|
|
52
52
|
* @remarks
|
|
53
53
|
* This response can have the following status codes:
|
|
54
|
-
* - `200`: Authorization completed successfully (native in_place flow). The `result` contains the authorization code and
|
|
54
|
+
* - `200`: Authorization completed successfully (native in_place flow). The `result` contains the authorization code, state, and PKCE artifacts (`codeVerifier`, `nonce`, `redirectUri`).
|
|
55
55
|
* - `204`: No content - user cancelled or flow completed without result data.
|
|
56
56
|
* - `302`: Redirect in progress (web redirect flow). The page will navigate away.
|
|
57
57
|
* - `400`: Bad request - missing required OAuth parameters or invalid configuration.
|
|
@@ -73,6 +73,9 @@ export declare const AuthorizeResponseSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
|
73
73
|
readonly result: v.ObjectSchema<{
|
|
74
74
|
readonly code: v.StringSchema<undefined>;
|
|
75
75
|
readonly state: v.StringSchema<undefined>;
|
|
76
|
+
readonly codeVerifier: v.StringSchema<undefined>;
|
|
77
|
+
readonly nonce: v.StringSchema<undefined>;
|
|
78
|
+
readonly redirectUri: v.StringSchema<undefined>;
|
|
76
79
|
}, undefined>;
|
|
77
80
|
}, undefined>, v.ObjectSchema<{
|
|
78
81
|
readonly status_code: v.LiteralSchema<204, undefined>;
|
|
@@ -94,13 +97,16 @@ export declare const AuthorizeResponseSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
|
94
97
|
|
|
95
98
|
/**
|
|
96
99
|
* Result object for the authorization flow.
|
|
97
|
-
* Contains the authorization code and
|
|
100
|
+
* Contains the authorization code, state, and PKCE artifacts when native in_place flow completes successfully.
|
|
98
101
|
*
|
|
99
102
|
* @example
|
|
100
103
|
* ```typescript
|
|
101
104
|
* {
|
|
102
105
|
* code: 'auth-code-abc123',
|
|
103
|
-
* state: 'csrf-state-xyz789'
|
|
106
|
+
* state: 'csrf-state-xyz789',
|
|
107
|
+
* codeVerifier: 'code-verifier-123',
|
|
108
|
+
* nonce: 'nonce-abc',
|
|
109
|
+
* redirectUri: 'https://your-app.com/current-page'
|
|
104
110
|
* }
|
|
105
111
|
* ```
|
|
106
112
|
*
|
|
@@ -116,6 +122,9 @@ export declare type AuthorizeResult = InferOutput<typeof AuthorizeResultSchema>;
|
|
|
116
122
|
export declare const AuthorizeResultSchema: v.ObjectSchema<{
|
|
117
123
|
readonly code: v.StringSchema<undefined>;
|
|
118
124
|
readonly state: v.StringSchema<undefined>;
|
|
125
|
+
readonly codeVerifier: v.StringSchema<undefined>;
|
|
126
|
+
readonly nonce: v.StringSchema<undefined>;
|
|
127
|
+
readonly redirectUri: v.StringSchema<undefined>;
|
|
119
128
|
}, undefined>;
|
|
120
129
|
|
|
121
130
|
/**
|
|
@@ -1130,10 +1139,15 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1130
1139
|
* @noInheritDoc
|
|
1131
1140
|
*/
|
|
1132
1141
|
export declare class DeviceModule extends BaseModule {
|
|
1142
|
+
static readonly MINIMUM_VERSION: Version;
|
|
1133
1143
|
constructor();
|
|
1134
1144
|
/**
|
|
1135
1145
|
* Checks whether the current device supports eSIM.
|
|
1136
1146
|
*
|
|
1147
|
+
* @minimumGrabAppVersion Android: 5.402.0, iOS: 5.402.0
|
|
1148
|
+
*
|
|
1149
|
+
* @requiredOAuthScope mobile.device
|
|
1150
|
+
*
|
|
1137
1151
|
* @returns Whether eSIM is supported on the current device. See {@link IsEsimSupportedResponse}.
|
|
1138
1152
|
*
|
|
1139
1153
|
* @example
|
|
@@ -1151,7 +1165,18 @@ export declare class DeviceModule extends BaseModule {
|
|
|
1151
1165
|
* if (isSuccess(response)) {
|
|
1152
1166
|
* console.log('eSIM supported:', response.result);
|
|
1153
1167
|
* } else if (isError(response)) {
|
|
1154
|
-
*
|
|
1168
|
+
* switch (response.status_code) {
|
|
1169
|
+
* case 403:
|
|
1170
|
+
* console.log('No permission to query eSIM support');
|
|
1171
|
+
* // Trigger IdentityModule.authorize() for scope 'mobile.device', then reload via ScopeModule.reloadScopes() and try again
|
|
1172
|
+
* break;
|
|
1173
|
+
* case 426:
|
|
1174
|
+
* console.log('User needs to upgrade the app');
|
|
1175
|
+
* // Advise user to upgrade app
|
|
1176
|
+
* break;
|
|
1177
|
+
* default:
|
|
1178
|
+
* console.error(`Error ${response.status_code}: ${response.error}`);
|
|
1179
|
+
* }
|
|
1155
1180
|
* } else {
|
|
1156
1181
|
* console.error('Unhandled response');
|
|
1157
1182
|
* }
|
|
@@ -2660,9 +2685,11 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2660
2685
|
* Uses your provided `redirectUri`
|
|
2661
2686
|
* - `responseMode: 'redirect'`: Always uses your provided `redirectUri`
|
|
2662
2687
|
*
|
|
2663
|
-
*
|
|
2664
|
-
*
|
|
2665
|
-
*
|
|
2688
|
+
* On a `200` response (native `in_place` success), the actual `redirectUri` and PKCE values
|
|
2689
|
+
* (`codeVerifier`, `nonce`) are returned in `response.result` alongside `code` and `state`,
|
|
2690
|
+
* so you do not need to call `getAuthorizationArtifacts()`.
|
|
2691
|
+
* For the web redirect flow (`302`), retrieve artifacts from `getAuthorizationArtifacts()` after
|
|
2692
|
+
* the redirect round-trip completes.
|
|
2666
2693
|
*
|
|
2667
2694
|
* **Consent Selection Rules (Native vs Web):**
|
|
2668
2695
|
*
|
|
@@ -2692,10 +2719,15 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2692
2719
|
* // Handle the response
|
|
2693
2720
|
* if (isSuccess(response)) {
|
|
2694
2721
|
* switch (response.status_code) {
|
|
2695
|
-
* case 200:
|
|
2696
|
-
*
|
|
2697
|
-
* console.log('
|
|
2722
|
+
* case 200: {
|
|
2723
|
+
* const { code, state, codeVerifier, nonce, redirectUri } = response.result;
|
|
2724
|
+
* console.log('Auth Code:', code);
|
|
2725
|
+
* console.log('State:', state);
|
|
2726
|
+
* console.log('Code Verifier:', codeVerifier);
|
|
2727
|
+
* console.log('Nonce:', nonce);
|
|
2728
|
+
* console.log('Redirect URI:', redirectUri);
|
|
2698
2729
|
* break;
|
|
2730
|
+
* }
|
|
2699
2731
|
* case 204:
|
|
2700
2732
|
* console.log('Authorization cancelled');
|
|
2701
2733
|
* break;
|
|
@@ -2837,6 +2869,9 @@ export declare function isError<T extends BridgeResponse>(response: T): response
|
|
|
2837
2869
|
* @remarks
|
|
2838
2870
|
* This response can have the following status codes:
|
|
2839
2871
|
* - `200`: eSIM capability was checked successfully. The `result` contains `true` or `false`.
|
|
2872
|
+
* - `403`: Forbidden - client not authorized to query eSIM capability.
|
|
2873
|
+
* - `424`: Failed Dependency - underlying telephony/eSIM service unavailable.
|
|
2874
|
+
* - `426`: Upgrade Required - feature requires Grab app version 5.402 or above.
|
|
2840
2875
|
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2841
2876
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2842
2877
|
*
|
|
@@ -2852,6 +2887,15 @@ export declare type IsEsimSupportedResponse = InferOutput<typeof IsEsimSupported
|
|
|
2852
2887
|
export declare const IsEsimSupportedResponseSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
2853
2888
|
readonly status_code: v.LiteralSchema<200, undefined>;
|
|
2854
2889
|
readonly result: v.BooleanSchema<undefined>;
|
|
2890
|
+
}, undefined>, v.ObjectSchema<{
|
|
2891
|
+
readonly status_code: v.LiteralSchema<403, undefined>;
|
|
2892
|
+
readonly error: v.StringSchema<undefined>;
|
|
2893
|
+
}, undefined>, v.ObjectSchema<{
|
|
2894
|
+
readonly status_code: v.LiteralSchema<424, undefined>;
|
|
2895
|
+
readonly error: v.StringSchema<undefined>;
|
|
2896
|
+
}, undefined>, v.ObjectSchema<{
|
|
2897
|
+
readonly status_code: v.LiteralSchema<426, undefined>;
|
|
2898
|
+
readonly error: v.StringSchema<undefined>;
|
|
2855
2899
|
}, undefined>, v.ObjectSchema<{
|
|
2856
2900
|
readonly status_code: v.LiteralSchema<500, undefined>;
|
|
2857
2901
|
readonly error: v.StringSchema<undefined>;
|
package/dist/index.esm.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
5
5
|
* directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
var e,t={exports:{}},n=(e||(e=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function n(e){return{subscribe:e,then:function(t,n){return new Promise(function(s,r){try{var o=null,a=!1;o=e({next:function(e){s(null==t?void 0:t(e)),o&&o.unsubscribe(),a=!0}}),a&&o&&o.unsubscribe()}catch(e){null==n?r(e):s(n(e))}})}}}function s(s,r){return r.funcNameToWrap,function(s,r){var o=r.callbackNameFunc,a=r.funcToWrap;return n(function(n){var r,i=o();return s[i]=function(t){if(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)return!1;var s=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=s.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&r.unsubscribe();else{var s=t.result,o=t.error,a=t.status_code;n&&n.next&&n.next({result:null===s?void 0:s,error:null===o?void 0:o,status_code:null===a?void 0:a})}},a(i),r=t(function(){s[i]=void 0,n&&n.complete&&n.complete()})})}(s,function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&(n[s[r]]=e[s[r]])}return n}(r,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=n,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var n;e[(n=t,"Wrapped"+n)]=function(e,t,n){return{invoke:function(r,o){return s(e,{funcNameToWrap:r,callbackNameFunc:function(){return function(e,t){var n=t.moduleName,s=t.funcName,r=0;return function(){for(var t,o,a="";(a=(t={moduleName:n,funcName:s,requestID:r}).moduleName+"_"+t.funcName+"Callback"+(null!==(o=t.requestID)?"_"+o:""))in e;)r+=1;return r+=1,a}()}(e,{moduleName:t,funcName:r})},funcToWrap:function(e){return n({callback:e,method:r,module:t,parameters:null!=o?o:{}})}})}}}(e,t,function(n){if(e[t]&&e[t][n.method]instanceof Function)e[t][n.method](JSON.stringify(n));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+n.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(n)}})},Object.defineProperty(e,"__esModule",{value:!0})}(t.exports)),t.exports);function s(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function r(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function o(e,t,n,s,o){const a=o&&"input"in o?o.input:n.value,i=o?.expected??e.expects??null,c=o?.received??r(a),u={kind:e.kind,type:e.type,input:a,expected:i,received:c,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:o?.path,issues:o?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},d="schema"===e.kind,l=o?.message??e.message??(e.reference,void u.lang)??(d?void u.lang:null)??s.message??void u.lang;void 0!==l&&(u.message="function"==typeof l?l(u):l),d&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function a(e){return{version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},s())}}function i(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function c(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}function u(e,t){return{kind:"validation",type:"min_length",reference:u,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&o(this,"length",e,t,{received:`${e.value.length}`}),e}}}function d(e){return{kind:"validation",type:"url",reference:d,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&o(this,"URL",e,t),e}}}function l(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function h(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function p(e){return{kind:"schema",type:"boolean",reference:p,expects:"boolean",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"boolean"==typeof e.value?e.typed=!0:o(this,"type",e,t),e}}}function g(e,t){return{kind:"schema",type:"literal",reference:g,expects:r(e),async:!1,literal:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:o(this,"type",e,t),e}}}function m(e,t){return{kind:"schema",type:"nullish",reference:m,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return null!==e.value&&void 0!==e.value||(void 0!==this.default&&(e.value=h(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped["~run"](e,t):(e.typed=!0,e)}}}function f(e){return{kind:"schema",type:"number",reference:f,expects:"number",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?o(this,"type",e,t):e.typed=!0,e}}}function v(e,t){return{kind:"schema",type:"object",reference:v,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in this.entries){const r=this.entries[s];if(s in n||("exact_optional"===r.type||"optional"===r.type||"nullish"===r.type)&&void 0!==r.default){const o=s in n?n[s]:h(r),a=r["~run"]({value:o},t);if(a.issues){const r={type:"object",origin:"value",input:n,key:s,value:o};for(const t of a.issues)t.path?t.path.unshift(r):t.path=[r],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[s]=a.value}else if(void 0!==r.fallback)e.value[s]=l(r);else if("exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type&&(o(this,"key",e,t,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:n,key:s,value:n[s]}]}),t.abortEarly))break}}else o(this,"type",e,t);return e}}}function y(e,t){return{kind:"schema",type:"optional",reference:y,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=h(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function w(e,t){return{kind:"schema",type:"picklist",reference:w,expects:c(e.map(r),"|"),async:!1,options:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:o(this,"type",e,t),e}}}function k(e,t,n){return{kind:"schema",type:"record",reference:k,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in n)if(i(n,s)){const r=n[s],o=this.key["~run"]({value:s},t);if(o.issues){const a={type:"object",origin:"key",input:n,key:s,value:r};for(const t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const a=this.value["~run"]({value:r},t);if(a.issues){const o={type:"object",origin:"value",input:n,key:s,value:r};for(const t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}o.typed&&a.typed||(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else o(this,"type",e,t);return e}}}function b(e){return{kind:"schema",type:"string",reference:b,expects:"string",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"string"==typeof e.value?e.typed=!0:o(this,"type",e,t),e}}}function _(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function x(e,t){return{kind:"schema",type:"union",reference:x,expects:c(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){let n,s,r;for(const o of this.options){const a=o["~run"]({value:e.value},t);if(a.typed){if(!a.issues){n=a;break}s?s.push(a):s=[a]}else r?r.push(a):r=[a]}if(n)return n;if(s){if(1===s.length)return s[0];o(this,"type",e,t,{issues:_(s)}),e.typed=!0}else{if(1===r?.length)return r[0];o(this,"type",e,t,{issues:_(r)})}return e}}}function U(){return{kind:"schema",type:"unknown",reference:U,expects:"unknown",async:!1,get"~standard"(){return a(this)},"~run":e=>(e.typed=!0,e)}}function $(...e){return{...e[0],pipe:e,get"~standard"(){return a(this)},"~run"(t,n){for(const s of e)if("metadata"!==s.kind){if(t.issues&&("schema"===s.kind||"transformation"===s.kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=s["~run"](t,n))}return t}}}function S(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class E{constructor(e){this.moduleName=e}formatPrefix(e){return`[SuperAppSDK][${this.moduleName}.${e}]`}warn(e,t){console.warn(`${this.formatPrefix(e)} ${t}`)}error(e,t){console.error(`${this.formatPrefix(e)} ${t}`)}}function C(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class A{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new E(e),!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${S(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},s(void 0));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}(e,t);return n.success?null:n.issues.map(e=>{const t=e.path?.map(e=>String(e.key)).join(".");return t?`${t}: ${e.message}`:e.message}).join(", ")}checkSupport(e){const t=C();return t?e(t)?null:{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"}:{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}async invoke(e){const{method:t,params:n}=e;try{return C()?await this.wrappedModule.invoke(t,n):{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}catch(e){return{status_code:500,error:`Failed to invoke method: ${S(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:n}=e;try{return C()?this.wrappedModule.invoke(t,n):this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"})}catch(e){return this.createErrorStream({status_code:500,error:`Failed to invoke method: ${S(e)?e.message:"Unknown error"}`})}}}function I(e){return e.status_code>=200&&e.status_code<300}function M(e){return 200===e.status_code}function T(e){return 204===e.status_code}function O(e){return 302===e.status_code}function N(e){return 302===e.status_code}function P(e){return e.status_code>=400&&e.status_code<500}function R(e){return e.status_code>=500&&e.status_code<600}function B(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0}function L(e){return"result"in e&&null!==e.result&&void 0!==e.result}const j=e=>v({status_code:g(e),error:b()}),D=e=>v({status_code:g(200),result:e}),z=v({status_code:g(204)}),K=v({status_code:g(302)}),G=v({title:y(b())}),W=v({qrCode:b()}),F=x([D(W),z,j(400),j(403),j(500),j(501)]);class q extends A{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(G,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),s=this.validate(F,n);return s&&this.logger.warn("scanQRCode",`Unexpected response shape: ${s}`),n}}const H=k(b(),U()),V=function e(t,n,s){return{kind:"schema",type:"variant",reference:e,expects:"Object",async:!1,key:t,options:n,message:s,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){let s,r=0,a=this.key,i=[];const u=(e,o)=>{for(const c of e.options){if("variant"===c.type)u(c,new Set(o).add(c.key));else{let e=!0,u=0;for(const t of o){const s=c.entries[t];if(t in n?s["~run"]({typed:!1,value:n[t]},{abortEarly:!0}).issues:"exact_optional"!==s.type&&"optional"!==s.type&&"nullish"!==s.type){e=!1,a!==t&&(r<u||r===u&&t in n&&!(a in n))&&(r=u,a=t,i=[]),a===t&&i.push(c.entries[t].expects);break}u++}if(e){const e=c["~run"]({value:n},t);(!s||!s.typed&&e.typed)&&(s=e)}}if(s&&!s.issues)break}};if(u(this,new Set([this.key])),s)return s;o(this,"type",e,t,{input:n[a],expected:c(i,"|"),path:[{type:"object",origin:"value",input:n,key:a,value:n[a]}]})}else o(this,"type",e,t);return e}}}("status",[v({status:g("success"),transactionID:b()}),v({status:g("failure"),transactionID:b(),errorMessage:b(),errorCode:b()}),v({status:g("pending"),transactionID:b()}),v({status:g("userInitiatedCancel")})]),Y=x([D(V),j(400),j(500),j(501)]);class J extends A{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(H,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"triggerCheckout",params:e}),s=this.validate(Y,n);return s&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${s}`),n}}const Q={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},X={DEFAULT:"DEFAULT"},Z={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},ee=x([D(p()),z,j(400),j(500),j(501)]),te=x([z,j(400),j(500),j(501)]),ne=x([D(p()),z,j(400),j(500),j(501)]),se=x([z,j(400),j(500),j(501)]),re=x([D(p()),z,j(500),j(501)]),oe=x([z,j(500),j(501)]),ae=x([D(p()),z,j(500),j(501)]),ie=x([z,j(500),j(501)]),ce=x([D(p()),z,j(500),j(501)]),ue=x([z,j(500),j(501)]),de=x([D(p()),z,j(500),j(501)]),le=x([z,j(500),j(501)]),he=x([D(p()),z,j(500),j(501)]),pe=x([z,j(500),j(501)]),ge=x([D(p()),z,j(500),j(501)]),me=x([D(p()),z,j(500),j(501)]),fe=x([z,j(500),j(501)]),ve=x([D(p()),z,j(500),j(501)]),ye=x([z,j(500),j(501)]),we=x([D(p()),z,j(400),j(500),j(501)]),ke=x([z,j(400),j(500),j(501)]),be=x([D(p()),j(500),j(501)]),_e=v({state:$(b(),u(1)),name:$(b(),u(1)),data:y(k(b(),U()))}),xe=x([D(p()),z,j(400),j(500),j(501)]),Ue=x([z,j(400),j(500),j(501)]),$e=v({connected:p()}),Se=x([D($e),j(404)]),Ee=b(),Ce=x([D(Ee),z,j(500),j(501)]);class Ae extends A{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(ee,t);let s;n&&this.logger.warn("setBackgroundColor",`Unexpected raw response shape: ${n}`),s=M(t)?{status_code:204}:t;const r=this.validate(te,s);return r&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${r}`),s}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(ne,t);let s;n&&this.logger.warn("setTitle",`Unexpected raw response shape: ${n}`),s=M(t)?{status_code:204}:t;const r=this.validate(se,s);return r&&this.logger.warn("setTitle",`Unexpected response shape: ${r}`),s}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(re,e);let n;t&&this.logger.warn("hideBackButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(oe,n);return s&&this.logger.warn("hideBackButton",`Unexpected response shape: ${s}`),n}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(ae,e);let n;t&&this.logger.warn("showBackButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(ie,n);return s&&this.logger.warn("showBackButton",`Unexpected response shape: ${s}`),n}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(ce,e);let n;t&&this.logger.warn("hideRefreshButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(ue,n);return s&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${s}`),n}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(de,e);let n;t&&this.logger.warn("showRefreshButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(le,n);return s&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${s}`),n}async close(){const e=await this.invoke({method:"close"}),t=this.validate(he,e);let n;t&&this.logger.warn("close",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(pe,n);return s&&this.logger.warn("close",`Unexpected response shape: ${s}`),n}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(ge,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(me,e);let n;t&&this.logger.warn("showLoader",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(fe,n);return s&&this.logger.warn("showLoader",`Unexpected response shape: ${s}`),n}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ve,e);let n;t&&this.logger.warn("hideLoader",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(ye,n);return s&&this.logger.warn("hideLoader",`Unexpected response shape: ${s}`),n}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(we,t);let s;n&&this.logger.warn("openExternalLink",`Unexpected raw response shape: ${n}`),s=M(t)?{status_code:204}:t;const r=this.validate(ke,s);return r&&this.logger.warn("openExternalLink",`Unexpected response shape: ${r}`),s}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(be,t);return n&&this.logger.warn("onCtaTap",`Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(_e,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}}),s=this.validate(xe,n);let r;s&&this.logger.warn("sendAnalyticsEvent",`Unexpected raw response shape: ${s}`),r=M(n)?{status_code:204}:n;const o=this.validate(Ue,r);return o&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${o}`),r}async isConnected(){return null!==C()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(Ce,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}}const Ie=p(),Me=x([D(Ie),j(500),j(501)]);class Te extends A{constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(Me,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}}const Oe=v({fileUrl:$(b(),d()),fileName:$(b(),u(1))}),Ne=x([z,j(400),j(500),j(501)]);class Pe extends A{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(Oe,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),s=this.validate(Ne,n);return s&&this.logger.warn("downloadFile",`Unexpected response shape: ${s}`),n}}function Re(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let s=0;s<e;s+=1)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[s]%62);return n}async function Be(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let n="";for(let e=0;e<t.byteLength;e+=1)n+=String.fromCharCode(t[e]);return btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}function Le(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const je="grabid",De={staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"};class ze extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Ke=v({clientId:$(b(),u(1)),redirectUri:$(b(),d()),scope:$(b(),u(1)),environment:w(["staging","production"]),responseMode:y(w(["redirect","in_place"]))}),Ge=v({code:b(),state:b()}),We=x([D(Ge),z,K,j(400),j(403),j(500),j(501)]),Fe=v({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),qe=x([D(Fe),z,j(400)]),He=x([z]);class Ve extends A{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=De[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new ze("Failed to fetch authorization configuration");const n=await e.json();if(!n.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new ze("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof ze)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=Re(16),t=Re(32),n=(s=Re(64),btoa(s).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var s;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await Be(n),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),n=this.getStorageItem("nonce"),s=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===n&&null===s?{status_code:204}:null!==e&&null!==t&&null!==n&&null!==s?{status_code:200,result:{state:e,codeVerifier:t,nonce:n,redirectUri:s}}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${je}:nonce`),window.localStorage.removeItem(`${je}:state`),window.localStorage.removeItem(`${je}:code_verifier`),window.localStorage.removeItem(`${je}:redirect_uri`),window.localStorage.removeItem(`${je}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${je}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${je}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=C();return!t||"staging"!==e.environment&&!Le(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:S(e)?e.message:"Could not fetch authorization endpoint"}}const n={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},s=Ve.buildAuthorizeUrl(t,n);return window.location.assign(s),{status_code:302}}async performNativeAuthorization(e){const t=await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}}),n=this.validate(We,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(Ke,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),s=e.responseMode||"redirect",r="in_place"===s?Ve.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...n,redirectUri:r});const o={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod};if(Ve.shouldUseWebConsent(e))return this.performWebAuthorization({...o,environment:e.environment});try{const t=await this.performNativeAuthorization({...o,actualRedirectUri:r,responseMode:s});return 400===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...o,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...o,environment:e.environment})}}}const Ye=b(),Je=x([D(Ye),z,j(400),j(500),j(501)]);class Qe extends A{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Je,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}}const Xe=v({latitude:f(),longitude:f()}),Ze=x([D(Xe),j(403),j(424),j(500),j(501)]),et=b(),tt=x([D(et),z,j(403),j(424),j(500),j(501)]);class nt extends A{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(Ze,e);return t&&this.logger.warn("getCoordinate",`Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(tt,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}}const st=v({type:w(["START_PLAYBACK","PROGRESS_PLAYBACK","START_SEEK","STOP_SEEK","STOP_PLAYBACK","CLOSE_PLAYBACK","PAUSE_PLAYBACK","RESUME_PLAYBACK","FAST_FORWARD_PLAYBACK","REWIND_PLAYBACK","ERROR_PLAYBACK","CHANGE_VOLUME"]),titleId:b(),position:f(),length:f()}),rt=x([D(st),z,j(400),j(424),j(500),j(501)]),ot=x([D(st),j(500),j(501)]);class at extends A{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(rt,t);return n&&this.logger.warn("playDRMContent",`Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}}const it=v({endpoint:b(),method:w(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:y(k(b(),b())),query:y(k(b(),b())),body:y(U()),timeout:y(f())}),ct=k(b(),U()),ut=x([D(ct),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]),dt=x([b(),ct]),lt=x([D(dt),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]);class ht extends A{constructor(){super("NetworkModule")}async send(e){const t=this.validate(it,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e}),s=this.validate(lt,n);if(s&&this.logger.warn("send",`Unexpected raw response shape: ${s}`),I(n)&&L(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result),t={...n,result:e},s=this.validate(ut,t);return s&&this.logger.warn("send",`Unexpected response shape after parsing: ${s}`),t}catch{return{status_code:500,error:"Failed to parse response result as JSON"}}const r=n,o=this.validate(ut,r);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),r}}const pt=x([z,j(500),j(501)]);class gt extends A{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(pt,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}}const mt=v({email:b()}),ft=x([D(mt),z,j(400),j(403),j(426),j(500),j(501)]),vt=v({email:y($(b(),u(1))),skipUserInput:y(p())}),yt=v({email:b()}),wt=x([D(yt),z,j(400),j(403),j(426),j(500),j(501)]);class kt extends A{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>Le(e.version,kt.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(ft,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>Le(e.version,kt.MINIMUM_VERSION));if(t)return t;const n=this.validate(vt,e??{});if(n)return{status_code:400,error:n};const s=await this.invoke({method:"verifyEmail",params:e}),r=this.validate(wt,s);return r&&this.logger.warn("verifyEmail",`Unexpected response shape: ${r}`),s}}kt.MINIMUM_VERSION={major:5,minor:399,patch:0};const bt=v({module:$(b(),u(1)),method:$(b(),u(1))}),_t=p(),xt=x([D(_t),j(400),j(424),j(500),j(501)]),Ut=x([z,j(424),j(500),j(501)]);class $t extends A{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},s=this.validate(bt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(xt,r);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),r}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(Ut,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}}const St=x([z,j(400),j(403),j(500),j(501)]);class Et extends A{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(St,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}}const Ct=$(b(),u(1)),At=v({key:Ct}),It=v({key:Ct,value:p()}),Mt=x([z,j(400),j(424),j(500),j(501)]),Tt=At,Ot=p(),Nt=x([v({status_code:g(200),result:m(p())}),z,j(400),j(424)]),Pt=x([D(Ot),z,j(400),j(424),j(500),j(501)]),Rt=v({key:Ct,value:f()}),Bt=x([z,j(400),j(424),j(500),j(501)]),Lt=At,jt=f(),Dt=x([v({status_code:g(200),result:m(f())}),z,j(400),j(424)]),zt=x([D(jt),z,j(400),j(424),j(500),j(501)]),Kt=v({key:Ct,value:b()}),Gt=x([z,j(400),j(424),j(500),j(501)]),Wt=At,Ft=b(),qt=x([v({status_code:g(200),result:m(b())}),z,j(400),j(424)]),Ht=x([D(Ft),z,j(400),j(424),j(500),j(501)]),Vt=v({key:Ct,value:f()}),Yt=x([z,j(400),j(424),j(500),j(501)]),Jt=At,Qt=f(),Xt=x([v({status_code:g(200),result:m(f())}),z,j(400),j(424)]),Zt=x([D(Qt),z,j(400),j(424),j(500),j(501)]),en=At,tn=x([z,j(400),j(424),j(500),j(501)]),nn=x([z,j(424),j(500),j(501)]);class sn extends A{constructor(){super("StorageModule")}async setBoolean(e,t){const n={key:e,value:t},s=this.validate(It,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setBoolean",params:n}),o=this.validate(Mt,r);return o&&this.logger.warn("setBoolean",`Unexpected response shape: ${o}`),r}async getBoolean(e){const t={key:e},n=this.validate(Tt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getBoolean",params:t}),r=this.validate(Nt,s);let o;if(r&&this.logger.warn("getBoolean",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(Pt,o);return a&&this.logger.warn("getBoolean",`Unexpected response shape: ${a}`),o}async setInt(e,t){const n={key:e,value:t},s=this.validate(Rt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setInt",params:n}),o=this.validate(Bt,r);return o&&this.logger.warn("setInt",`Unexpected response shape: ${o}`),r}async getInt(e){const t={key:e},n=this.validate(Lt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getInt",params:t}),r=this.validate(Dt,s);let o;if(r&&this.logger.warn("getInt",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(zt,o);return a&&this.logger.warn("getInt",`Unexpected response shape: ${a}`),o}async setString(e,t){const n={key:e,value:t},s=this.validate(Kt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setString",params:n}),o=this.validate(Gt,r);return o&&this.logger.warn("setString",`Unexpected response shape: ${o}`),r}async getString(e){const t={key:e},n=this.validate(Wt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getString",params:t}),r=this.validate(qt,s);let o;if(r&&this.logger.warn("getString",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(Ht,o);return a&&this.logger.warn("getString",`Unexpected response shape: ${a}`),o}async setDouble(e,t){const n={key:e,value:t},s=this.validate(Vt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setDouble",params:n}),o=this.validate(Yt,r);return o&&this.logger.warn("setDouble",`Unexpected response shape: ${o}`),r}async getDouble(e){const t={key:e},n=this.validate(Jt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getDouble",params:t}),r=this.validate(Xt,s);let o;if(r&&this.logger.warn("getDouble",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(Zt,o);return a&&this.logger.warn("getDouble",`Unexpected response shape: ${a}`),o}async remove(e){const t={key:e},n=this.validate(en,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"remove",params:t}),r=this.validate(tn,s);return r&&this.logger.warn("remove",`Unexpected response shape: ${r}`),s}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(nn,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}}const rn=v({url:$(b(),d())}),on=x([D(b()),j(400),j(424),j(500),j(501)]);class an extends A{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(rn,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),s=this.validate(on,n);return s&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${s}`),n}}const cn=b(),un=x([D(cn),z,j(500),j(501)]);class dn extends A{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(un,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}}export{Ke as AuthorizeRequestSchema,We as AuthorizeResponseSchema,Ge as AuthorizeResultSchema,pt as BackResponseSchema,A as BaseModule,q as CameraModule,J as CheckoutModule,He as ClearAuthorizationArtifactsResponseSchema,pe as CloseResponseSchema,Z as ContainerAnalyticsEventData,X as ContainerAnalyticsEventName,Q as ContainerAnalyticsEventState,Ae as ContainerModule,st as DRMPlaybackEventSchema,Te as DeviceModule,St as DismissSplashScreenResponseSchema,Oe as DownloadFileRequestSchema,Ne as DownloadFileResponseSchema,ft as FetchEmailResponseSchema,mt as FetchEmailResultSchema,Pe as FileModule,qe as GetAuthorizationArtifactsResponseSchema,Fe as GetAuthorizationArtifactsResultSchema,Tt as GetBooleanRequestSchema,Pt as GetBooleanResponseSchema,Ot as GetBooleanResultSchema,Ze as GetCoordinateResponseSchema,Xe as GetCoordinateResultSchema,tt as GetCountryCodeResponseSchema,et as GetCountryCodeResultSchema,Jt as GetDoubleRequestSchema,Zt as GetDoubleResponseSchema,Qt as GetDoubleResultSchema,Lt as GetIntRequestSchema,zt as GetIntResponseSchema,jt as GetIntResultSchema,Je as GetLanguageLocaleIdentifierResponseSchema,Ye as GetLanguageLocaleIdentifierResultSchema,un as GetSelectedTravelDestinationResponseSchema,cn as GetSelectedTravelDestinationResultSchema,Ce as GetSessionParamsResponseSchema,Ee as GetSessionParamsResultSchema,Wt as GetStringRequestSchema,Ht as GetStringResponseSchema,Ft as GetStringResultSchema,bt as HasAccessToRequestSchema,xt as HasAccessToResponseSchema,_t as HasAccessToResultSchema,oe as HideBackButtonResponseSchema,ye as HideLoaderResponseSchema,ue as HideRefreshButtonResponseSchema,Ve as IdentityModule,Se as IsConnectedResponseSchema,$e as IsConnectedResultSchema,Me as IsEsimSupportedResponseSchema,Ie as IsEsimSupportedResultSchema,Qe as LocaleModule,nt as LocationModule,E as Logger,at as MediaModule,ht as NetworkModule,ot as ObserveDRMPlaybackResponseSchema,ge as OnContentLoadedResponseSchema,be as OnCtaTapResponseSchema,ke as OpenExternalLinkResponseSchema,gt as PlatformModule,rt as PlayDRMContentResponseSchema,kt as ProfileModule,rn as RedirectToSystemWebViewRequestSchema,on as RedirectToSystemWebViewResponseSchema,Ut as ReloadScopesResponseSchema,nn as RemoveAllResponseSchema,tn as RemoveResponseSchema,G as ScanQRCodeRequestSchema,F as ScanQRCodeResponseSchema,W as ScanQRCodeResultSchema,$t as ScopeModule,_e as SendAnalyticsEventRequestSchema,Ue as SendAnalyticsEventResponseSchema,it as SendRequestSchema,ut as SendResponseSchema,ct as SendResultSchema,te as SetBackgroundColorResponseSchema,It as SetBooleanRequestSchema,Mt as SetBooleanResponseSchema,Vt as SetDoubleRequestSchema,Yt as SetDoubleResponseSchema,Rt as SetIntRequestSchema,Bt as SetIntResponseSchema,Kt as SetStringRequestSchema,Gt as SetStringResponseSchema,se as SetTitleResponseSchema,ie as ShowBackButtonResponseSchema,fe as ShowLoaderResponseSchema,le as ShowRefreshButtonResponseSchema,Et as SplashScreenModule,sn as StorageModule,an as SystemWebViewKitModule,H as TriggerCheckoutRequestSchema,Y as TriggerCheckoutResponseSchema,V as TriggerCheckoutResultSchema,dn as UserAttributesModule,vt as VerifyEmailRequestSchema,wt as VerifyEmailResponseSchema,yt as VerifyEmailResultSchema,L as hasResult,P as isClientError,B as isError,N as isFound,T as isNoContent,M as isOk,O as isRedirection,R as isServerError,I as isSuccess};
|
|
7
|
+
var e,t={exports:{}},n=(e||(e=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function n(e){return{subscribe:e,then:function(t,n){return new Promise(function(s,r){try{var o=null,a=!1;o=e({next:function(e){s(null==t?void 0:t(e)),o&&o.unsubscribe(),a=!0}}),a&&o&&o.unsubscribe()}catch(e){null==n?r(e):s(n(e))}})}}}function s(s,r){return r.funcNameToWrap,function(s,r){var o=r.callbackNameFunc,a=r.funcToWrap;return n(function(n){var r,i=o();return s[i]=function(t){if(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)return!1;var s=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=s.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&r.unsubscribe();else{var s=t.result,o=t.error,a=t.status_code;n&&n.next&&n.next({result:null===s?void 0:s,error:null===o?void 0:o,status_code:null===a?void 0:a})}},a(i),r=t(function(){s[i]=void 0,n&&n.complete&&n.complete()})})}(s,function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&(n[s[r]]=e[s[r]])}return n}(r,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=n,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var n;e[(n=t,"Wrapped"+n)]=function(e,t,n){return{invoke:function(r,o){return s(e,{funcNameToWrap:r,callbackNameFunc:function(){return function(e,t){var n=t.moduleName,s=t.funcName,r=0;return function(){for(var t,o,a="";(a=(t={moduleName:n,funcName:s,requestID:r}).moduleName+"_"+t.funcName+"Callback"+(null!==(o=t.requestID)?"_"+o:""))in e;)r+=1;return r+=1,a}()}(e,{moduleName:t,funcName:r})},funcToWrap:function(e){return n({callback:e,method:r,module:t,parameters:null!=o?o:{}})}})}}}(e,t,function(n){if(e[t]&&e[t][n.method]instanceof Function)e[t][n.method](JSON.stringify(n));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+n.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(n)}})},Object.defineProperty(e,"__esModule",{value:!0})}(t.exports)),t.exports);function s(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function r(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function o(e,t,n,s,o){const a=o&&"input"in o?o.input:n.value,i=o?.expected??e.expects??null,c=o?.received??r(a),u={kind:e.kind,type:e.type,input:a,expected:i,received:c,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:o?.path,issues:o?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},d="schema"===e.kind,l=o?.message??e.message??(e.reference,void u.lang)??(d?void u.lang:null)??s.message??void u.lang;void 0!==l&&(u.message="function"==typeof l?l(u):l),d&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function a(e){return{version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},s())}}function i(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function c(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}function u(e,t){return{kind:"validation",type:"min_length",reference:u,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&o(this,"length",e,t,{received:`${e.value.length}`}),e}}}function d(e){return{kind:"validation",type:"url",reference:d,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&o(this,"URL",e,t),e}}}function l(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function h(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function p(e){return{kind:"schema",type:"boolean",reference:p,expects:"boolean",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"boolean"==typeof e.value?e.typed=!0:o(this,"type",e,t),e}}}function g(e,t){return{kind:"schema",type:"literal",reference:g,expects:r(e),async:!1,literal:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:o(this,"type",e,t),e}}}function m(e,t){return{kind:"schema",type:"nullish",reference:m,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return null!==e.value&&void 0!==e.value||(void 0!==this.default&&(e.value=h(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped["~run"](e,t):(e.typed=!0,e)}}}function f(e){return{kind:"schema",type:"number",reference:f,expects:"number",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?o(this,"type",e,t):e.typed=!0,e}}}function v(e,t){return{kind:"schema",type:"object",reference:v,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in this.entries){const r=this.entries[s];if(s in n||("exact_optional"===r.type||"optional"===r.type||"nullish"===r.type)&&void 0!==r.default){const o=s in n?n[s]:h(r),a=r["~run"]({value:o},t);if(a.issues){const r={type:"object",origin:"value",input:n,key:s,value:o};for(const t of a.issues)t.path?t.path.unshift(r):t.path=[r],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[s]=a.value}else if(void 0!==r.fallback)e.value[s]=l(r);else if("exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type&&(o(this,"key",e,t,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:n,key:s,value:n[s]}]}),t.abortEarly))break}}else o(this,"type",e,t);return e}}}function y(e,t){return{kind:"schema",type:"optional",reference:y,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=h(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function w(e,t){return{kind:"schema",type:"picklist",reference:w,expects:c(e.map(r),"|"),async:!1,options:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:o(this,"type",e,t),e}}}function k(e,t,n){return{kind:"schema",type:"record",reference:k,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in n)if(i(n,s)){const r=n[s],o=this.key["~run"]({value:s},t);if(o.issues){const a={type:"object",origin:"key",input:n,key:s,value:r};for(const t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const a=this.value["~run"]({value:r},t);if(a.issues){const o={type:"object",origin:"value",input:n,key:s,value:r};for(const t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}o.typed&&a.typed||(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else o(this,"type",e,t);return e}}}function b(e){return{kind:"schema",type:"string",reference:b,expects:"string",async:!1,message:e,get"~standard"(){return a(this)},"~run"(e,t){return"string"==typeof e.value?e.typed=!0:o(this,"type",e,t),e}}}function _(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function x(e,t){return{kind:"schema",type:"union",reference:x,expects:c(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return a(this)},"~run"(e,t){let n,s,r;for(const o of this.options){const a=o["~run"]({value:e.value},t);if(a.typed){if(!a.issues){n=a;break}s?s.push(a):s=[a]}else r?r.push(a):r=[a]}if(n)return n;if(s){if(1===s.length)return s[0];o(this,"type",e,t,{issues:_(s)}),e.typed=!0}else{if(1===r?.length)return r[0];o(this,"type",e,t,{issues:_(r)})}return e}}}function U(){return{kind:"schema",type:"unknown",reference:U,expects:"unknown",async:!1,get"~standard"(){return a(this)},"~run":e=>(e.typed=!0,e)}}function $(...e){return{...e[0],pipe:e,get"~standard"(){return a(this)},"~run"(t,n){for(const s of e)if("metadata"!==s.kind){if(t.issues&&("schema"===s.kind||"transformation"===s.kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=s["~run"](t,n))}return t}}}function S(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class E{constructor(e){this.moduleName=e}formatPrefix(e){return`[SuperAppSDK][${this.moduleName}.${e}]`}warn(e,t){console.warn(`${this.formatPrefix(e)} ${t}`)}error(e,t){console.error(`${this.formatPrefix(e)} ${t}`)}}function C(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class A{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new E(e),!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${S(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},s(void 0));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}(e,t);return n.success?null:n.issues.map(e=>{const t=e.path?.map(e=>String(e.key)).join(".");return t?`${t}: ${e.message}`:e.message}).join(", ")}checkSupport(e){const t=C();return t?e(t)?null:{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"}:{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}async invoke(e){const{method:t,params:n}=e;try{return C()?await this.wrappedModule.invoke(t,n):{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}catch(e){return{status_code:500,error:`Failed to invoke method: ${S(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:n}=e;try{return C()?this.wrappedModule.invoke(t,n):this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"})}catch(e){return this.createErrorStream({status_code:500,error:`Failed to invoke method: ${S(e)?e.message:"Unknown error"}`})}}}function I(e){return e.status_code>=200&&e.status_code<300}function M(e){return 200===e.status_code}function T(e){return 204===e.status_code}function N(e){return 302===e.status_code}function O(e){return 302===e.status_code}function P(e){return e.status_code>=400&&e.status_code<500}function R(e){return e.status_code>=500&&e.status_code<600}function B(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0}function L(e){return"result"in e&&null!==e.result&&void 0!==e.result}const j=e=>v({status_code:g(e),error:b()}),D=e=>v({status_code:g(200),result:e}),z=v({status_code:g(204)}),K=v({status_code:g(302)}),G=v({title:y(b())}),W=v({qrCode:b()}),V=x([D(W),z,j(400),j(403),j(500),j(501)]);class F extends A{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(G,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),s=this.validate(V,n);return s&&this.logger.warn("scanQRCode",`Unexpected response shape: ${s}`),n}}const q=k(b(),U()),H=function e(t,n,s){return{kind:"schema",type:"variant",reference:e,expects:"Object",async:!1,key:t,options:n,message:s,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){let s,r=0,a=this.key,i=[];const u=(e,o)=>{for(const c of e.options){if("variant"===c.type)u(c,new Set(o).add(c.key));else{let e=!0,u=0;for(const t of o){const s=c.entries[t];if(t in n?s["~run"]({typed:!1,value:n[t]},{abortEarly:!0}).issues:"exact_optional"!==s.type&&"optional"!==s.type&&"nullish"!==s.type){e=!1,a!==t&&(r<u||r===u&&t in n&&!(a in n))&&(r=u,a=t,i=[]),a===t&&i.push(c.entries[t].expects);break}u++}if(e){const e=c["~run"]({value:n},t);(!s||!s.typed&&e.typed)&&(s=e)}}if(s&&!s.issues)break}};if(u(this,new Set([this.key])),s)return s;o(this,"type",e,t,{input:n[a],expected:c(i,"|"),path:[{type:"object",origin:"value",input:n,key:a,value:n[a]}]})}else o(this,"type",e,t);return e}}}("status",[v({status:g("success"),transactionID:b()}),v({status:g("failure"),transactionID:b(),errorMessage:b(),errorCode:b()}),v({status:g("pending"),transactionID:b()}),v({status:g("userInitiatedCancel")})]),Y=x([D(H),j(400),j(500),j(501)]);class J extends A{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(q,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"triggerCheckout",params:e}),s=this.validate(Y,n);return s&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${s}`),n}}const Q={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},X={DEFAULT:"DEFAULT"},Z={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},ee=x([D(p()),z,j(400),j(500),j(501)]),te=x([z,j(400),j(500),j(501)]),ne=x([D(p()),z,j(400),j(500),j(501)]),se=x([z,j(400),j(500),j(501)]),re=x([D(p()),z,j(500),j(501)]),oe=x([z,j(500),j(501)]),ae=x([D(p()),z,j(500),j(501)]),ie=x([z,j(500),j(501)]),ce=x([D(p()),z,j(500),j(501)]),ue=x([z,j(500),j(501)]),de=x([D(p()),z,j(500),j(501)]),le=x([z,j(500),j(501)]),he=x([D(p()),z,j(500),j(501)]),pe=x([z,j(500),j(501)]),ge=x([D(p()),z,j(500),j(501)]),me=x([D(p()),z,j(500),j(501)]),fe=x([z,j(500),j(501)]),ve=x([D(p()),z,j(500),j(501)]),ye=x([z,j(500),j(501)]),we=x([D(p()),z,j(400),j(500),j(501)]),ke=x([z,j(400),j(500),j(501)]),be=x([D(p()),j(500),j(501)]),_e=v({state:$(b(),u(1)),name:$(b(),u(1)),data:y(k(b(),U()))}),xe=x([D(p()),z,j(400),j(500),j(501)]),Ue=x([z,j(400),j(500),j(501)]),$e=v({connected:p()}),Se=x([D($e),j(404)]),Ee=b(),Ce=x([D(Ee),z,j(500),j(501)]);class Ae extends A{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(ee,t);let s;n&&this.logger.warn("setBackgroundColor",`Unexpected raw response shape: ${n}`),s=M(t)?{status_code:204}:t;const r=this.validate(te,s);return r&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${r}`),s}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(ne,t);let s;n&&this.logger.warn("setTitle",`Unexpected raw response shape: ${n}`),s=M(t)?{status_code:204}:t;const r=this.validate(se,s);return r&&this.logger.warn("setTitle",`Unexpected response shape: ${r}`),s}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(re,e);let n;t&&this.logger.warn("hideBackButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(oe,n);return s&&this.logger.warn("hideBackButton",`Unexpected response shape: ${s}`),n}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(ae,e);let n;t&&this.logger.warn("showBackButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(ie,n);return s&&this.logger.warn("showBackButton",`Unexpected response shape: ${s}`),n}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(ce,e);let n;t&&this.logger.warn("hideRefreshButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(ue,n);return s&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${s}`),n}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(de,e);let n;t&&this.logger.warn("showRefreshButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(le,n);return s&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${s}`),n}async close(){const e=await this.invoke({method:"close"}),t=this.validate(he,e);let n;t&&this.logger.warn("close",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(pe,n);return s&&this.logger.warn("close",`Unexpected response shape: ${s}`),n}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(ge,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(me,e);let n;t&&this.logger.warn("showLoader",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(fe,n);return s&&this.logger.warn("showLoader",`Unexpected response shape: ${s}`),n}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ve,e);let n;t&&this.logger.warn("hideLoader",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const s=this.validate(ye,n);return s&&this.logger.warn("hideLoader",`Unexpected response shape: ${s}`),n}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(we,t);let s;n&&this.logger.warn("openExternalLink",`Unexpected raw response shape: ${n}`),s=M(t)?{status_code:204}:t;const r=this.validate(ke,s);return r&&this.logger.warn("openExternalLink",`Unexpected response shape: ${r}`),s}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(be,t);return n&&this.logger.warn("onCtaTap",`Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(_e,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}}),s=this.validate(xe,n);let r;s&&this.logger.warn("sendAnalyticsEvent",`Unexpected raw response shape: ${s}`),r=M(n)?{status_code:204}:n;const o=this.validate(Ue,r);return o&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${o}`),r}async isConnected(){return null!==C()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(Ce,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}}function Ie(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const Me=p(),Te=x([D(Me),j(403),j(424),j(426),j(500),j(501)]);class Ne extends A{constructor(){super("DeviceModule")}async isEsimSupported(){const e=this.checkSupport(e=>Ie(e.version,Ne.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"isEsimSupported"}),n=this.validate(Te,t);return n&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${n}`),t}}Ne.MINIMUM_VERSION={major:5,minor:402,patch:0};const Oe=v({fileUrl:$(b(),d()),fileName:$(b(),u(1))}),Pe=x([z,j(400),j(500),j(501)]);class Re extends A{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(Oe,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),s=this.validate(Pe,n);return s&&this.logger.warn("downloadFile",`Unexpected response shape: ${s}`),n}}function Be(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let s=0;s<e;s+=1)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[s]%62);return n}async function Le(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let n="";for(let e=0;e<t.byteLength;e+=1)n+=String.fromCharCode(t[e]);return btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}const je="grabid",De={staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"};class ze extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Ke=v({clientId:$(b(),u(1)),redirectUri:$(b(),d()),scope:$(b(),u(1)),environment:w(["staging","production"]),responseMode:y(w(["redirect","in_place"]))}),Ge=x([D(v({code:b(),state:b()})),z,K,j(400),j(403),j(500),j(501)]),We=v({code:b(),state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Ve=x([D(We),z,K,j(400),j(403),j(500),j(501)]),Fe=v({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),qe=x([D(Fe),z,j(400)]),He=x([z]);class Ye extends A{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=De[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new ze("Failed to fetch authorization configuration");const n=await e.json();if(!n.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new ze("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof ze)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=Be(16),t=Be(32),n=(s=Be(64),btoa(s).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var s;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await Le(n),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),n=this.getStorageItem("nonce"),s=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===n&&null===s?{status_code:204}:null!==e&&null!==t&&null!==n&&null!==s?{status_code:200,result:{state:e,codeVerifier:t,nonce:n,redirectUri:s}}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${je}:nonce`),window.localStorage.removeItem(`${je}:state`),window.localStorage.removeItem(`${je}:code_verifier`),window.localStorage.removeItem(`${je}:redirect_uri`),window.localStorage.removeItem(`${je}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${je}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${je}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=C();return!t||"staging"!==e.environment&&!Ie(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:S(e)?e.message:"Could not fetch authorization endpoint"}}const n={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},s=Ye.buildAuthorizeUrl(t,n);return window.location.assign(s),{status_code:302}}async performNativeAuthorization(e){const t=await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}}),n=this.validate(Ge,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(Ke,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),s=e.responseMode||"redirect",r="in_place"===s?Ye.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...n,redirectUri:r});const o={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod};if(Ye.shouldUseWebConsent(e))return this.performWebAuthorization({...o,environment:e.environment});try{const t=await this.performNativeAuthorization({...o,actualRedirectUri:r,responseMode:s});return 200===t.status_code?{status_code:200,result:{code:t.result.code,state:t.result.state,codeVerifier:n.codeVerifier,nonce:n.nonce,redirectUri:r}}:400===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...o,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...o,environment:e.environment})}}}const Je=b(),Qe=x([D(Je),z,j(400),j(500),j(501)]);class Xe extends A{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Qe,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}}const Ze=v({latitude:f(),longitude:f()}),et=x([D(Ze),j(403),j(424),j(500),j(501)]),tt=b(),nt=x([D(tt),z,j(403),j(424),j(500),j(501)]);class st extends A{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(et,e);return t&&this.logger.warn("getCoordinate",`Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(nt,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}}const rt=v({type:w(["START_PLAYBACK","PROGRESS_PLAYBACK","START_SEEK","STOP_SEEK","STOP_PLAYBACK","CLOSE_PLAYBACK","PAUSE_PLAYBACK","RESUME_PLAYBACK","FAST_FORWARD_PLAYBACK","REWIND_PLAYBACK","ERROR_PLAYBACK","CHANGE_VOLUME"]),titleId:b(),position:f(),length:f()}),ot=x([D(rt),z,j(400),j(424),j(500),j(501)]),at=x([D(rt),j(500),j(501)]);class it extends A{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(ot,t);return n&&this.logger.warn("playDRMContent",`Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}}const ct=v({endpoint:b(),method:w(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:y(k(b(),b())),query:y(k(b(),b())),body:y(U()),timeout:y(f())}),ut=k(b(),U()),dt=x([D(ut),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]),lt=x([b(),ut]),ht=x([D(lt),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]);class pt extends A{constructor(){super("NetworkModule")}async send(e){const t=this.validate(ct,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e}),s=this.validate(ht,n);if(s&&this.logger.warn("send",`Unexpected raw response shape: ${s}`),I(n)&&L(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result),t={...n,result:e},s=this.validate(dt,t);return s&&this.logger.warn("send",`Unexpected response shape after parsing: ${s}`),t}catch{return{status_code:500,error:"Failed to parse response result as JSON"}}const r=n,o=this.validate(dt,r);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),r}}const gt=x([z,j(500),j(501)]);class mt extends A{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(gt,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}}const ft=v({email:b()}),vt=x([D(ft),z,j(400),j(403),j(426),j(500),j(501)]),yt=v({email:y($(b(),u(1))),skipUserInput:y(p())}),wt=v({email:b()}),kt=x([D(wt),z,j(400),j(403),j(426),j(500),j(501)]);class bt extends A{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>Ie(e.version,bt.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(vt,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>Ie(e.version,bt.MINIMUM_VERSION));if(t)return t;const n=this.validate(yt,e??{});if(n)return{status_code:400,error:n};const s=await this.invoke({method:"verifyEmail",params:e}),r=this.validate(kt,s);return r&&this.logger.warn("verifyEmail",`Unexpected response shape: ${r}`),s}}bt.MINIMUM_VERSION={major:5,minor:399,patch:0};const _t=v({module:$(b(),u(1)),method:$(b(),u(1))}),xt=p(),Ut=x([D(xt),j(400),j(424),j(500),j(501)]),$t=x([z,j(424),j(500),j(501)]);class St extends A{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},s=this.validate(_t,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(Ut,r);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),r}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate($t,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}}const Et=x([z,j(400),j(403),j(500),j(501)]);class Ct extends A{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(Et,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}}const At=$(b(),u(1)),It=v({key:At}),Mt=v({key:At,value:p()}),Tt=x([z,j(400),j(424),j(500),j(501)]),Nt=It,Ot=p(),Pt=x([v({status_code:g(200),result:m(p())}),z,j(400),j(424)]),Rt=x([D(Ot),z,j(400),j(424),j(500),j(501)]),Bt=v({key:At,value:f()}),Lt=x([z,j(400),j(424),j(500),j(501)]),jt=It,Dt=f(),zt=x([v({status_code:g(200),result:m(f())}),z,j(400),j(424)]),Kt=x([D(Dt),z,j(400),j(424),j(500),j(501)]),Gt=v({key:At,value:b()}),Wt=x([z,j(400),j(424),j(500),j(501)]),Vt=It,Ft=b(),qt=x([v({status_code:g(200),result:m(b())}),z,j(400),j(424)]),Ht=x([D(Ft),z,j(400),j(424),j(500),j(501)]),Yt=v({key:At,value:f()}),Jt=x([z,j(400),j(424),j(500),j(501)]),Qt=It,Xt=f(),Zt=x([v({status_code:g(200),result:m(f())}),z,j(400),j(424)]),en=x([D(Xt),z,j(400),j(424),j(500),j(501)]),tn=It,nn=x([z,j(400),j(424),j(500),j(501)]),sn=x([z,j(424),j(500),j(501)]);class rn extends A{constructor(){super("StorageModule")}async setBoolean(e,t){const n={key:e,value:t},s=this.validate(Mt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setBoolean",params:n}),o=this.validate(Tt,r);return o&&this.logger.warn("setBoolean",`Unexpected response shape: ${o}`),r}async getBoolean(e){const t={key:e},n=this.validate(Nt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getBoolean",params:t}),r=this.validate(Pt,s);let o;if(r&&this.logger.warn("getBoolean",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(Rt,o);return a&&this.logger.warn("getBoolean",`Unexpected response shape: ${a}`),o}async setInt(e,t){const n={key:e,value:t},s=this.validate(Bt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setInt",params:n}),o=this.validate(Lt,r);return o&&this.logger.warn("setInt",`Unexpected response shape: ${o}`),r}async getInt(e){const t={key:e},n=this.validate(jt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getInt",params:t}),r=this.validate(zt,s);let o;if(r&&this.logger.warn("getInt",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(Kt,o);return a&&this.logger.warn("getInt",`Unexpected response shape: ${a}`),o}async setString(e,t){const n={key:e,value:t},s=this.validate(Gt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setString",params:n}),o=this.validate(Wt,r);return o&&this.logger.warn("setString",`Unexpected response shape: ${o}`),r}async getString(e){const t={key:e},n=this.validate(Vt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getString",params:t}),r=this.validate(qt,s);let o;if(r&&this.logger.warn("getString",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(Ht,o);return a&&this.logger.warn("getString",`Unexpected response shape: ${a}`),o}async setDouble(e,t){const n={key:e,value:t},s=this.validate(Yt,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"setDouble",params:n}),o=this.validate(Jt,r);return o&&this.logger.warn("setDouble",`Unexpected response shape: ${o}`),r}async getDouble(e){const t={key:e},n=this.validate(Qt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getDouble",params:t}),r=this.validate(Zt,s);let o;if(r&&this.logger.warn("getDouble",`Unexpected raw response shape: ${r}`),200===s.status_code){const e=s.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=s;const a=this.validate(en,o);return a&&this.logger.warn("getDouble",`Unexpected response shape: ${a}`),o}async remove(e){const t={key:e},n=this.validate(tn,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"remove",params:t}),r=this.validate(nn,s);return r&&this.logger.warn("remove",`Unexpected response shape: ${r}`),s}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(sn,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}}const on=v({url:$(b(),d())}),an=x([D(b()),j(400),j(424),j(500),j(501)]);class cn extends A{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(on,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),s=this.validate(an,n);return s&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${s}`),n}}const un=b(),dn=x([D(un),z,j(500),j(501)]);class ln extends A{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(dn,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}}export{Ke as AuthorizeRequestSchema,Ve as AuthorizeResponseSchema,We as AuthorizeResultSchema,gt as BackResponseSchema,A as BaseModule,F as CameraModule,J as CheckoutModule,He as ClearAuthorizationArtifactsResponseSchema,pe as CloseResponseSchema,Z as ContainerAnalyticsEventData,X as ContainerAnalyticsEventName,Q as ContainerAnalyticsEventState,Ae as ContainerModule,rt as DRMPlaybackEventSchema,Ne as DeviceModule,Et as DismissSplashScreenResponseSchema,Oe as DownloadFileRequestSchema,Pe as DownloadFileResponseSchema,vt as FetchEmailResponseSchema,ft as FetchEmailResultSchema,Re as FileModule,qe as GetAuthorizationArtifactsResponseSchema,Fe as GetAuthorizationArtifactsResultSchema,Nt as GetBooleanRequestSchema,Rt as GetBooleanResponseSchema,Ot as GetBooleanResultSchema,et as GetCoordinateResponseSchema,Ze as GetCoordinateResultSchema,nt as GetCountryCodeResponseSchema,tt as GetCountryCodeResultSchema,Qt as GetDoubleRequestSchema,en as GetDoubleResponseSchema,Xt as GetDoubleResultSchema,jt as GetIntRequestSchema,Kt as GetIntResponseSchema,Dt as GetIntResultSchema,Qe as GetLanguageLocaleIdentifierResponseSchema,Je as GetLanguageLocaleIdentifierResultSchema,dn as GetSelectedTravelDestinationResponseSchema,un as GetSelectedTravelDestinationResultSchema,Ce as GetSessionParamsResponseSchema,Ee as GetSessionParamsResultSchema,Vt as GetStringRequestSchema,Ht as GetStringResponseSchema,Ft as GetStringResultSchema,_t as HasAccessToRequestSchema,Ut as HasAccessToResponseSchema,xt as HasAccessToResultSchema,oe as HideBackButtonResponseSchema,ye as HideLoaderResponseSchema,ue as HideRefreshButtonResponseSchema,Ye as IdentityModule,Se as IsConnectedResponseSchema,$e as IsConnectedResultSchema,Te as IsEsimSupportedResponseSchema,Me as IsEsimSupportedResultSchema,Xe as LocaleModule,st as LocationModule,E as Logger,it as MediaModule,pt as NetworkModule,at as ObserveDRMPlaybackResponseSchema,ge as OnContentLoadedResponseSchema,be as OnCtaTapResponseSchema,ke as OpenExternalLinkResponseSchema,mt as PlatformModule,ot as PlayDRMContentResponseSchema,bt as ProfileModule,on as RedirectToSystemWebViewRequestSchema,an as RedirectToSystemWebViewResponseSchema,$t as ReloadScopesResponseSchema,sn as RemoveAllResponseSchema,nn as RemoveResponseSchema,G as ScanQRCodeRequestSchema,V as ScanQRCodeResponseSchema,W as ScanQRCodeResultSchema,St as ScopeModule,_e as SendAnalyticsEventRequestSchema,Ue as SendAnalyticsEventResponseSchema,ct as SendRequestSchema,dt as SendResponseSchema,ut as SendResultSchema,te as SetBackgroundColorResponseSchema,Mt as SetBooleanRequestSchema,Tt as SetBooleanResponseSchema,Yt as SetDoubleRequestSchema,Jt as SetDoubleResponseSchema,Bt as SetIntRequestSchema,Lt as SetIntResponseSchema,Gt as SetStringRequestSchema,Wt as SetStringResponseSchema,se as SetTitleResponseSchema,ie as ShowBackButtonResponseSchema,fe as ShowLoaderResponseSchema,le as ShowRefreshButtonResponseSchema,Ct as SplashScreenModule,rn as StorageModule,cn as SystemWebViewKitModule,q as TriggerCheckoutRequestSchema,Y as TriggerCheckoutResponseSchema,H as TriggerCheckoutResultSchema,ln as UserAttributesModule,yt as VerifyEmailRequestSchema,kt as VerifyEmailResponseSchema,wt as VerifyEmailResultSchema,L as hasResult,P as isClientError,B as isError,O as isFound,T as isNoContent,M as isOk,N as isRedirection,R as isServerError,I as isSuccess};
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
5
5
|
* directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SuperAppSDK={})}(this,function(e){"use strict";var t,s={exports:{}},n=(t||(t=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function s(e){return{subscribe:e,then:function(t,s){return new Promise(function(n,r){try{var o=null,a=!1;o=e({next:function(e){n(null==t?void 0:t(e)),o&&o.unsubscribe(),a=!0}}),a&&o&&o.unsubscribe()}catch(e){null==s?r(e):n(s(e))}})}}}function n(n,r){return r.funcNameToWrap,function(n,r){var o=r.callbackNameFunc,a=r.funcToWrap;return s(function(s){var r,i=o();return n[i]=function(t){if(function(e){for(var t=[],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(!e)return!1;var n=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=n.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&r.unsubscribe();else{var n=t.result,o=t.error,a=t.status_code;s&&s.next&&s.next({result:null===n?void 0:n,error:null===o?void 0:o,status_code:null===a?void 0:a})}},a(i),r=t(function(){n[i]=void 0,s&&s.complete&&s.complete()})})}(n,function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&(s[n[r]]=e[n[r]])}return s}(r,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=s,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var s;e[(s=t,"Wrapped"+s)]=function(e,t,s){return{invoke:function(r,o){return n(e,{funcNameToWrap:r,callbackNameFunc:function(){return function(e,t){var s=t.moduleName,n=t.funcName,r=0;return function(){for(var t,o,a="";(a=(t={moduleName:s,funcName:n,requestID:r}).moduleName+"_"+t.funcName+"Callback"+(null!==(o=t.requestID)?"_"+o:""))in e;)r+=1;return r+=1,a}()}(e,{moduleName:t,funcName:r})},funcToWrap:function(e){return s({callback:e,method:r,module:t,parameters:null!=o?o:{}})}})}}}(e,t,function(s){if(e[t]&&e[t][s.method]instanceof Function)e[t][s.method](JSON.stringify(s));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+s.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(s)}})},Object.defineProperty(e,"__esModule",{value:!0})}(s.exports)),s.exports);function r(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function o(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function a(e,t,s,n,r){const a=r&&"input"in r?r.input:s.value,i=r?.expected??e.expects??null,c=r?.received??o(a),u={kind:e.kind,type:e.type,input:a,expected:i,received:c,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},l="schema"===e.kind,d=r?.message??e.message??(e.reference,void u.lang)??(l?void u.lang:null)??n.message??void u.lang;void 0!==d&&(u.message="function"==typeof d?d(u):d),l&&(s.typed=!1),s.issues?s.issues.push(u):s.issues=[u]}function i(e){return{version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},r())}}function c(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function u(e,t){const s=[...new Set(e)];return s.length>1?`(${s.join(` ${t} `)})`:s[0]??"never"}function l(e,t){return{kind:"validation",type:"min_length",reference:l,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&a(this,"length",e,t,{received:`${e.value.length}`}),e}}}function d(e){return{kind:"validation",type:"url",reference:d,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&a(this,"URL",e,t),e}}}function h(e,t,s){return"function"==typeof e.fallback?e.fallback(t,s):e.fallback}function p(e,t,s){return"function"==typeof e.default?e.default(t,s):e.default}function m(e){return{kind:"schema",type:"boolean",reference:m,expects:"boolean",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"boolean"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}}}function g(e,t){return{kind:"schema",type:"literal",reference:g,expects:o(e),async:!1,literal:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:a(this,"type",e,t),e}}}function f(e,t){return{kind:"schema",type:"nullish",reference:f,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return null!==e.value&&void 0!==e.value||(void 0!==this.default&&(e.value=p(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped["~run"](e,t):(e.typed=!0,e)}}}function v(e){return{kind:"schema",type:"number",reference:v,expects:"number",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?a(this,"type",e,t):e.typed=!0,e}}}function y(e,t){return{kind:"schema",type:"object",reference:y,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){const s=e.value;if(s&&"object"==typeof s){e.typed=!0,e.value={};for(const n in this.entries){const r=this.entries[n];if(n in s||("exact_optional"===r.type||"optional"===r.type||"nullish"===r.type)&&void 0!==r.default){const o=n in s?s[n]:p(r),a=r["~run"]({value:o},t);if(a.issues){const r={type:"object",origin:"value",input:s,key:n,value:o};for(const t of a.issues)t.path?t.path.unshift(r):t.path=[r],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[n]=a.value}else if(void 0!==r.fallback)e.value[n]=h(r);else if("exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type&&(a(this,"key",e,t,{input:void 0,expected:`"${n}"`,path:[{type:"object",origin:"key",input:s,key:n,value:s[n]}]}),t.abortEarly))break}}else a(this,"type",e,t);return e}}}function w(e,t){return{kind:"schema",type:"optional",reference:w,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function S(e,t){return{kind:"schema",type:"picklist",reference:S,expects:u(e.map(o),"|"),async:!1,options:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:a(this,"type",e,t),e}}}function k(e,t,s){return{kind:"schema",type:"record",reference:k,expects:"Object",async:!1,key:e,value:t,message:s,get"~standard"(){return i(this)},"~run"(e,t){const s=e.value;if(s&&"object"==typeof s){e.typed=!0,e.value={};for(const n in s)if(c(s,n)){const r=s[n],o=this.key["~run"]({value:n},t);if(o.issues){const a={type:"object",origin:"key",input:s,key:n,value:r};for(const t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const a=this.value["~run"]({value:r},t);if(a.issues){const o={type:"object",origin:"value",input:s,key:n,value:r};for(const t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}o.typed&&a.typed||(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else a(this,"type",e,t);return e}}}function b(e){return{kind:"schema",type:"string",reference:b,expects:"string",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"string"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}}}function R(e){let t;if(e)for(const s of e)t?t.push(...s.issues):t=s.issues;return t}function _(e,t){return{kind:"schema",type:"union",reference:_,expects:u(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){let s,n,r;for(const o of this.options){const a=o["~run"]({value:e.value},t);if(a.typed){if(!a.issues){s=a;break}n?n.push(a):n=[a]}else r?r.push(a):r=[a]}if(s)return s;if(n){if(1===n.length)return n[0];a(this,"type",e,t,{issues:R(n)}),e.typed=!0}else{if(1===r?.length)return r[0];a(this,"type",e,t,{issues:R(r)})}return e}}}function x(){return{kind:"schema",type:"unknown",reference:x,expects:"unknown",async:!1,get"~standard"(){return i(this)},"~run":e=>(e.typed=!0,e)}}function C(...e){return{...e[0],pipe:e,get"~standard"(){return i(this)},"~run"(t,s){for(const n of e)if("metadata"!==n.kind){if(t.issues&&("schema"===n.kind||"transformation"===n.kind)){t.typed=!1;break}t.issues&&(s.abortEarly||s.abortPipeEarly)||(t=n["~run"](t,s))}return t}}}function E(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class U{constructor(e){this.moduleName=e}formatPrefix(e){return`[SuperAppSDK][${this.moduleName}.${e}]`}warn(e,t){console.warn(`${this.formatPrefix(e)} ${t}`)}error(e,t){console.error(`${this.formatPrefix(e)} ${t}`)}}function $(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class A{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new U(e),!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${E(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const s=function(e,t){const s=e["~run"]({value:t},r(void 0));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}(e,t);return s.success?null:s.issues.map(e=>{const t=e.path?.map(e=>String(e.key)).join(".");return t?`${t}: ${e.message}`:e.message}).join(", ")}checkSupport(e){const t=$();return t?e(t)?null:{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"}:{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}async invoke(e){const{method:t,params:s}=e;try{return $()?await this.wrappedModule.invoke(t,s):{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}catch(e){return{status_code:500,error:`Failed to invoke method: ${E(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:s}=e;try{return $()?this.wrappedModule.invoke(t,s):this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"})}catch(e){return this.createErrorStream({status_code:500,error:`Failed to invoke method: ${E(e)?e.message:"Unknown error"}`})}}}function M(e){return e.status_code>=200&&e.status_code<300}function I(e){return 200===e.status_code}function T(e){return"result"in e&&null!==e.result&&void 0!==e.result}const O=e=>y({status_code:g(e),error:b()}),B=e=>y({status_code:g(200),result:e}),N=y({status_code:g(204)}),P=y({status_code:g(302)}),L=y({title:w(b())}),D=y({qrCode:b()}),G=_([B(D),N,O(400),O(403),O(500),O(501)]),j=k(b(),x()),z=function e(t,s,n){return{kind:"schema",type:"variant",reference:e,expects:"Object",async:!1,key:t,options:s,message:n,get"~standard"(){return i(this)},"~run"(e,t){const s=e.value;if(s&&"object"==typeof s){let n,r=0,o=this.key,i=[];const c=(e,a)=>{for(const u of e.options){if("variant"===u.type)c(u,new Set(a).add(u.key));else{let e=!0,c=0;for(const t of a){const n=u.entries[t];if(t in s?n["~run"]({typed:!1,value:s[t]},{abortEarly:!0}).issues:"exact_optional"!==n.type&&"optional"!==n.type&&"nullish"!==n.type){e=!1,o!==t&&(r<c||r===c&&t in s&&!(o in s))&&(r=c,o=t,i=[]),o===t&&i.push(u.entries[t].expects);break}c++}if(e){const e=u["~run"]({value:s},t);(!n||!n.typed&&e.typed)&&(n=e)}}if(n&&!n.issues)break}};if(c(this,new Set([this.key])),n)return n;a(this,"type",e,t,{input:s[o],expected:u(i,"|"),path:[{type:"object",origin:"value",input:s,key:o,value:s[o]}]})}else a(this,"type",e,t);return e}}}("status",[y({status:g("success"),transactionID:b()}),y({status:g("failure"),transactionID:b(),errorMessage:b(),errorCode:b()}),y({status:g("pending"),transactionID:b()}),y({status:g("userInitiatedCancel")})]),q=_([B(z),O(400),O(500),O(501)]),F=_([B(m()),N,O(400),O(500),O(501)]),K=_([N,O(400),O(500),O(501)]),W=_([B(m()),N,O(400),O(500),O(501)]),H=_([N,O(400),O(500),O(501)]),V=_([B(m()),N,O(500),O(501)]),Y=_([N,O(500),O(501)]),Q=_([B(m()),N,O(500),O(501)]),J=_([N,O(500),O(501)]),X=_([B(m()),N,O(500),O(501)]),Z=_([N,O(500),O(501)]),ee=_([B(m()),N,O(500),O(501)]),te=_([N,O(500),O(501)]),se=_([B(m()),N,O(500),O(501)]),ne=_([N,O(500),O(501)]),re=_([B(m()),N,O(500),O(501)]),oe=_([B(m()),N,O(500),O(501)]),ae=_([N,O(500),O(501)]),ie=_([B(m()),N,O(500),O(501)]),ce=_([N,O(500),O(501)]),ue=_([B(m()),N,O(400),O(500),O(501)]),le=_([N,O(400),O(500),O(501)]),de=_([B(m()),O(500),O(501)]),he=y({state:C(b(),l(1)),name:C(b(),l(1)),data:w(k(b(),x()))}),pe=_([B(m()),N,O(400),O(500),O(501)]),me=_([N,O(400),O(500),O(501)]),ge=y({connected:m()}),fe=_([B(ge),O(404)]),ve=b(),ye=_([B(ve),N,O(500),O(501)]),we=m(),Se=_([B(we),O(500),O(501)]),ke=y({fileUrl:C(b(),d()),fileName:C(b(),l(1))}),be=_([N,O(400),O(500),O(501)]);function Re(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let s="";for(let n=0;n<e;n+=1)s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[n]%62);return s}async function _e(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let s="";for(let e=0;e<t.byteLength;e+=1)s+=String.fromCharCode(t[e]);return btoa(s).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}function xe(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const Ce="grabid",Ee={staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"};class Ue extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const $e=y({clientId:C(b(),l(1)),redirectUri:C(b(),d()),scope:C(b(),l(1)),environment:S(["staging","production"]),responseMode:w(S(["redirect","in_place"]))}),Ae=y({code:b(),state:b()}),Me=_([B(Ae),N,P,O(400),O(403),O(500),O(501)]),Ie=y({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Te=_([B(Ie),N,O(400)]),Oe=_([N]);class Be extends A{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=Ee[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new Ue("Failed to fetch authorization configuration");const s=await e.json();if(!s.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new Ue("Invalid authorization configuration");return s.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof Ue)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=Re(16),t=Re(32),s=(n=Re(64),btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var n;return{nonce:e,state:t,codeVerifier:s,codeChallenge:await _e(s),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),s=this.getStorageItem("nonce"),n=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===s&&null===n?{status_code:204}:null!==e&&null!==t&&null!==s&&null!==n?{status_code:200,result:{state:e,codeVerifier:t,nonce:s,redirectUri:n}}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${Ce}:nonce`),window.localStorage.removeItem(`${Ce}:state`),window.localStorage.removeItem(`${Ce}:code_verifier`),window.localStorage.removeItem(`${Ce}:redirect_uri`),window.localStorage.removeItem(`${Ce}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${Ce}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${Ce}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=$();return!t||"staging"!==e.environment&&!xe(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:E(e)?e.message:"Could not fetch authorization endpoint"}}const s={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},n=Be.buildAuthorizeUrl(t,s);return window.location.assign(n),{status_code:302}}async performNativeAuthorization(e){const t=await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}}),s=this.validate(Me,t);return s&&this.logger.warn("authorize",`Unexpected response shape: ${s}`),t}async authorize(e){const t=this.validate($e,e);if(t)return{status_code:400,error:t};const s=await this.generatePKCEArtifacts(),n=e.responseMode||"redirect",r="in_place"===n?Be.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...s,redirectUri:r});const o={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:s.nonce,state:s.state,codeChallenge:s.codeChallenge,codeChallengeMethod:s.codeChallengeMethod};if(Be.shouldUseWebConsent(e))return this.performWebAuthorization({...o,environment:e.environment});try{const t=await this.performNativeAuthorization({...o,actualRedirectUri:r,responseMode:n});return 400===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...o,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...o,environment:e.environment})}}}const Ne=b(),Pe=_([B(Ne),N,O(400),O(500),O(501)]),Le=y({latitude:v(),longitude:v()}),De=_([B(Le),O(403),O(424),O(500),O(501)]),Ge=b(),je=_([B(Ge),N,O(403),O(424),O(500),O(501)]),ze=y({type:S(["START_PLAYBACK","PROGRESS_PLAYBACK","START_SEEK","STOP_SEEK","STOP_PLAYBACK","CLOSE_PLAYBACK","PAUSE_PLAYBACK","RESUME_PLAYBACK","FAST_FORWARD_PLAYBACK","REWIND_PLAYBACK","ERROR_PLAYBACK","CHANGE_VOLUME"]),titleId:b(),position:v(),length:v()}),qe=_([B(ze),N,O(400),O(424),O(500),O(501)]),Fe=_([B(ze),O(500),O(501)]),Ke=y({endpoint:b(),method:S(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:w(k(b(),b())),query:w(k(b(),b())),body:w(x()),timeout:w(v())}),We=k(b(),x()),He=_([B(We),N,O(400),O(401),O(403),O(404),O(424),O(426),O(500),O(501)]),Ve=_([b(),We]),Ye=_([B(Ve),N,O(400),O(401),O(403),O(404),O(424),O(426),O(500),O(501)]),Qe=_([N,O(500),O(501)]),Je=y({email:b()}),Xe=_([B(Je),N,O(400),O(403),O(426),O(500),O(501)]),Ze=y({email:w(C(b(),l(1))),skipUserInput:w(m())}),et=y({email:b()}),tt=_([B(et),N,O(400),O(403),O(426),O(500),O(501)]);class st extends A{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>xe(e.version,st.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),s=this.validate(Xe,t);return s&&this.logger.warn("fetchEmail",`Unexpected response shape: ${s}`),t}async verifyEmail(e){const t=this.checkSupport(e=>xe(e.version,st.MINIMUM_VERSION));if(t)return t;const s=this.validate(Ze,e??{});if(s)return{status_code:400,error:s};const n=await this.invoke({method:"verifyEmail",params:e}),r=this.validate(tt,n);return r&&this.logger.warn("verifyEmail",`Unexpected response shape: ${r}`),n}}st.MINIMUM_VERSION={major:5,minor:399,patch:0};const nt=y({module:C(b(),l(1)),method:C(b(),l(1))}),rt=m(),ot=_([B(rt),O(400),O(424),O(500),O(501)]),at=_([N,O(424),O(500),O(501)]),it=_([N,O(400),O(403),O(500),O(501)]),ct=C(b(),l(1)),ut=y({key:ct}),lt=y({key:ct,value:m()}),dt=_([N,O(400),O(424),O(500),O(501)]),ht=ut,pt=m(),mt=_([y({status_code:g(200),result:f(m())}),N,O(400),O(424)]),gt=_([B(pt),N,O(400),O(424),O(500),O(501)]),ft=y({key:ct,value:v()}),vt=_([N,O(400),O(424),O(500),O(501)]),yt=ut,wt=v(),St=_([y({status_code:g(200),result:f(v())}),N,O(400),O(424)]),kt=_([B(wt),N,O(400),O(424),O(500),O(501)]),bt=y({key:ct,value:b()}),Rt=_([N,O(400),O(424),O(500),O(501)]),_t=ut,xt=b(),Ct=_([y({status_code:g(200),result:f(b())}),N,O(400),O(424)]),Et=_([B(xt),N,O(400),O(424),O(500),O(501)]),Ut=y({key:ct,value:v()}),$t=_([N,O(400),O(424),O(500),O(501)]),At=ut,Mt=v(),It=_([y({status_code:g(200),result:f(v())}),N,O(400),O(424)]),Tt=_([B(Mt),N,O(400),O(424),O(500),O(501)]),Ot=ut,Bt=_([N,O(400),O(424),O(500),O(501)]),Nt=_([N,O(424),O(500),O(501)]),Pt=y({url:C(b(),d())}),Lt=_([B(b()),O(400),O(424),O(500),O(501)]),Dt=b(),Gt=_([B(Dt),N,O(500),O(501)]);e.AuthorizeRequestSchema=$e,e.AuthorizeResponseSchema=Me,e.AuthorizeResultSchema=Ae,e.BackResponseSchema=Qe,e.BaseModule=A,e.CameraModule=class extends A{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(L,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"scanQRCode",params:e}),n=this.validate(G,s);return n&&this.logger.warn("scanQRCode",`Unexpected response shape: ${n}`),s}},e.CheckoutModule=class extends A{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(j,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"triggerCheckout",params:e}),n=this.validate(q,s);return n&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${n}`),s}},e.ClearAuthorizationArtifactsResponseSchema=Oe,e.CloseResponseSchema=ne,e.ContainerAnalyticsEventData={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},e.ContainerAnalyticsEventName={DEFAULT:"DEFAULT"},e.ContainerAnalyticsEventState={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},e.ContainerModule=class extends A{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),s=this.validate(F,t);let n;s&&this.logger.warn("setBackgroundColor",`Unexpected raw response shape: ${s}`),n=I(t)?{status_code:204}:t;const r=this.validate(K,n);return r&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${r}`),n}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),s=this.validate(W,t);let n;s&&this.logger.warn("setTitle",`Unexpected raw response shape: ${s}`),n=I(t)?{status_code:204}:t;const r=this.validate(H,n);return r&&this.logger.warn("setTitle",`Unexpected response shape: ${r}`),n}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(V,e);let s;t&&this.logger.warn("hideBackButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(Y,s);return n&&this.logger.warn("hideBackButton",`Unexpected response shape: ${n}`),s}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(Q,e);let s;t&&this.logger.warn("showBackButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(J,s);return n&&this.logger.warn("showBackButton",`Unexpected response shape: ${n}`),s}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(X,e);let s;t&&this.logger.warn("hideRefreshButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(Z,s);return n&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${n}`),s}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(ee,e);let s;t&&this.logger.warn("showRefreshButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(te,s);return n&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${n}`),s}async close(){const e=await this.invoke({method:"close"}),t=this.validate(se,e);let s;t&&this.logger.warn("close",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(ne,s);return n&&this.logger.warn("close",`Unexpected response shape: ${n}`),s}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(re,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(oe,e);let s;t&&this.logger.warn("showLoader",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(ae,s);return n&&this.logger.warn("showLoader",`Unexpected response shape: ${n}`),s}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ie,e);let s;t&&this.logger.warn("hideLoader",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(ce,s);return n&&this.logger.warn("hideLoader",`Unexpected response shape: ${n}`),s}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),s=this.validate(ue,t);let n;s&&this.logger.warn("openExternalLink",`Unexpected raw response shape: ${s}`),n=I(t)?{status_code:204}:t;const r=this.validate(le,n);return r&&this.logger.warn("openExternalLink",`Unexpected response shape: ${r}`),n}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),s=this.validate(de,t);return s&&this.logger.warn("onCtaTap",`Unexpected response shape: ${s}`),t}async sendAnalyticsEvent(e){const t=this.validate(he,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}}),n=this.validate(pe,s);let r;n&&this.logger.warn("sendAnalyticsEvent",`Unexpected raw response shape: ${n}`),r=I(s)?{status_code:204}:s;const o=this.validate(me,r);return o&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${o}`),r}async isConnected(){return null!==$()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(ye,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}},e.DRMPlaybackEventSchema=ze,e.DeviceModule=class extends A{constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(Se,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}},e.DismissSplashScreenResponseSchema=it,e.DownloadFileRequestSchema=ke,e.DownloadFileResponseSchema=be,e.FetchEmailResponseSchema=Xe,e.FetchEmailResultSchema=Je,e.FileModule=class extends A{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(ke,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"downloadFile",params:e}),n=this.validate(be,s);return n&&this.logger.warn("downloadFile",`Unexpected response shape: ${n}`),s}},e.GetAuthorizationArtifactsResponseSchema=Te,e.GetAuthorizationArtifactsResultSchema=Ie,e.GetBooleanRequestSchema=ht,e.GetBooleanResponseSchema=gt,e.GetBooleanResultSchema=pt,e.GetCoordinateResponseSchema=De,e.GetCoordinateResultSchema=Le,e.GetCountryCodeResponseSchema=je,e.GetCountryCodeResultSchema=Ge,e.GetDoubleRequestSchema=At,e.GetDoubleResponseSchema=Tt,e.GetDoubleResultSchema=Mt,e.GetIntRequestSchema=yt,e.GetIntResponseSchema=kt,e.GetIntResultSchema=wt,e.GetLanguageLocaleIdentifierResponseSchema=Pe,e.GetLanguageLocaleIdentifierResultSchema=Ne,e.GetSelectedTravelDestinationResponseSchema=Gt,e.GetSelectedTravelDestinationResultSchema=Dt,e.GetSessionParamsResponseSchema=ye,e.GetSessionParamsResultSchema=ve,e.GetStringRequestSchema=_t,e.GetStringResponseSchema=Et,e.GetStringResultSchema=xt,e.HasAccessToRequestSchema=nt,e.HasAccessToResponseSchema=ot,e.HasAccessToResultSchema=rt,e.HideBackButtonResponseSchema=Y,e.HideLoaderResponseSchema=ce,e.HideRefreshButtonResponseSchema=Z,e.IdentityModule=Be,e.IsConnectedResponseSchema=fe,e.IsConnectedResultSchema=ge,e.IsEsimSupportedResponseSchema=Se,e.IsEsimSupportedResultSchema=we,e.LocaleModule=class extends A{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Pe,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}},e.LocationModule=class extends A{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(De,e);return t&&this.logger.warn("getCoordinate",`Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(je,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}},e.Logger=U,e.MediaModule=class extends A{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),s=this.validate(qe,t);return s&&this.logger.warn("playDRMContent",`Unexpected response shape: ${s}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}},e.NetworkModule=class extends A{constructor(){super("NetworkModule")}async send(e){const t=this.validate(Ke,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"send",params:e}),n=this.validate(Ye,s);if(n&&this.logger.warn("send",`Unexpected raw response shape: ${n}`),M(s)&&T(s)&&"string"==typeof s.result)try{const e=JSON.parse(s.result),t={...s,result:e},n=this.validate(He,t);return n&&this.logger.warn("send",`Unexpected response shape after parsing: ${n}`),t}catch{return{status_code:500,error:"Failed to parse response result as JSON"}}const r=s,o=this.validate(He,r);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),r}},e.ObserveDRMPlaybackResponseSchema=Fe,e.OnContentLoadedResponseSchema=re,e.OnCtaTapResponseSchema=de,e.OpenExternalLinkResponseSchema=le,e.PlatformModule=class extends A{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(Qe,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}},e.PlayDRMContentResponseSchema=qe,e.ProfileModule=st,e.RedirectToSystemWebViewRequestSchema=Pt,e.RedirectToSystemWebViewResponseSchema=Lt,e.ReloadScopesResponseSchema=at,e.RemoveAllResponseSchema=Nt,e.RemoveResponseSchema=Bt,e.ScanQRCodeRequestSchema=L,e.ScanQRCodeResponseSchema=G,e.ScanQRCodeResultSchema=D,e.ScopeModule=class extends A{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const s={module:e,method:t},n=this.validate(nt,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"hasAccessTo",params:s}),o=this.validate(ot,r);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),r}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(at,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}},e.SendAnalyticsEventRequestSchema=he,e.SendAnalyticsEventResponseSchema=me,e.SendRequestSchema=Ke,e.SendResponseSchema=He,e.SendResultSchema=We,e.SetBackgroundColorResponseSchema=K,e.SetBooleanRequestSchema=lt,e.SetBooleanResponseSchema=dt,e.SetDoubleRequestSchema=Ut,e.SetDoubleResponseSchema=$t,e.SetIntRequestSchema=ft,e.SetIntResponseSchema=vt,e.SetStringRequestSchema=bt,e.SetStringResponseSchema=Rt,e.SetTitleResponseSchema=H,e.ShowBackButtonResponseSchema=J,e.ShowLoaderResponseSchema=ae,e.ShowRefreshButtonResponseSchema=te,e.SplashScreenModule=class extends A{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(it,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}},e.StorageModule=class extends A{constructor(){super("StorageModule")}async setBoolean(e,t){const s={key:e,value:t},n=this.validate(lt,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setBoolean",params:s}),o=this.validate(dt,r);return o&&this.logger.warn("setBoolean",`Unexpected response shape: ${o}`),r}async getBoolean(e){const t={key:e},s=this.validate(ht,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getBoolean",params:t}),r=this.validate(mt,n);let o;if(r&&this.logger.warn("getBoolean",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate(gt,o);return a&&this.logger.warn("getBoolean",`Unexpected response shape: ${a}`),o}async setInt(e,t){const s={key:e,value:t},n=this.validate(ft,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setInt",params:s}),o=this.validate(vt,r);return o&&this.logger.warn("setInt",`Unexpected response shape: ${o}`),r}async getInt(e){const t={key:e},s=this.validate(yt,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getInt",params:t}),r=this.validate(St,n);let o;if(r&&this.logger.warn("getInt",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate(kt,o);return a&&this.logger.warn("getInt",`Unexpected response shape: ${a}`),o}async setString(e,t){const s={key:e,value:t},n=this.validate(bt,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setString",params:s}),o=this.validate(Rt,r);return o&&this.logger.warn("setString",`Unexpected response shape: ${o}`),r}async getString(e){const t={key:e},s=this.validate(_t,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getString",params:t}),r=this.validate(Ct,n);let o;if(r&&this.logger.warn("getString",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate(Et,o);return a&&this.logger.warn("getString",`Unexpected response shape: ${a}`),o}async setDouble(e,t){const s={key:e,value:t},n=this.validate(Ut,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setDouble",params:s}),o=this.validate($t,r);return o&&this.logger.warn("setDouble",`Unexpected response shape: ${o}`),r}async getDouble(e){const t={key:e},s=this.validate(At,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getDouble",params:t}),r=this.validate(It,n);let o;if(r&&this.logger.warn("getDouble",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate(Tt,o);return a&&this.logger.warn("getDouble",`Unexpected response shape: ${a}`),o}async remove(e){const t={key:e},s=this.validate(Ot,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"remove",params:t}),r=this.validate(Bt,n);return r&&this.logger.warn("remove",`Unexpected response shape: ${r}`),n}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(Nt,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}},e.SystemWebViewKitModule=class extends A{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(Pt,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"redirectToSystemWebView",params:e}),n=this.validate(Lt,s);return n&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${n}`),s}},e.TriggerCheckoutRequestSchema=j,e.TriggerCheckoutResponseSchema=q,e.TriggerCheckoutResultSchema=z,e.UserAttributesModule=class extends A{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(Gt,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}},e.VerifyEmailRequestSchema=Ze,e.VerifyEmailResponseSchema=tt,e.VerifyEmailResultSchema=et,e.hasResult=T,e.isClientError=function(e){return e.status_code>=400&&e.status_code<500},e.isError=function(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0},e.isFound=function(e){return 302===e.status_code},e.isNoContent=function(e){return 204===e.status_code},e.isOk=I,e.isRedirection=function(e){return 302===e.status_code},e.isServerError=function(e){return e.status_code>=500&&e.status_code<600},e.isSuccess=M});
|
|
7
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SuperAppSDK={})}(this,function(e){"use strict";var t,s={exports:{}},n=(t||(t=1,function(e){function t(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(e(),t=!0)}}}function s(e){return{subscribe:e,then:function(t,s){return new Promise(function(n,r){try{var o=null,a=!1;o=e({next:function(e){n(null==t?void 0:t(e)),o&&o.unsubscribe(),a=!0}}),a&&o&&o.unsubscribe()}catch(e){null==s?r(e):n(s(e))}})}}}function n(n,r){return r.funcNameToWrap,function(n,r){var o=r.callbackNameFunc,a=r.funcToWrap;return s(function(s){var r,i=o();return n[i]=function(t){if(function(e){for(var t=[],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(!e)return!1;var n=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=n.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&r.unsubscribe();else{var n=t.result,o=t.error,a=t.status_code;s&&s.next&&s.next({result:null===n?void 0:n,error:null===o?void 0:o,status_code:null===a?void 0:a})}},a(i),r=t(function(){n[i]=void 0,s&&s.complete&&s.complete()})})}(n,function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&(s[n[r]]=e[n[r]])}return s}(r,["funcNameToWrap"]))}(e.StreamEvent||(e.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",e.createDataStream=s,e.createSubscription=t,e.getModuleEnvironment=function(e,t){return e[t]?"android":e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]?"ios":void 0},e.wrapModule=function(e,t){var s;e[(s=t,"Wrapped"+s)]=function(e,t,s){return{invoke:function(r,o){return n(e,{funcNameToWrap:r,callbackNameFunc:function(){return function(e,t){var s=t.moduleName,n=t.funcName,r=0;return function(){for(var t,o,a="";(a=(t={moduleName:s,funcName:n,requestID:r}).moduleName+"_"+t.funcName+"Callback"+(null!==(o=t.requestID)?"_"+o:""))in e;)r+=1;return r+=1,a}()}(e,{moduleName:t,funcName:r})},funcToWrap:function(e){return s({callback:e,method:r,module:t,parameters:null!=o?o:{}})}})}}}(e,t,function(s){if(e[t]&&e[t][s.method]instanceof Function)e[t][s.method](JSON.stringify(s));else{if(!(e.webkit&&e.webkit.messageHandlers&&e.webkit.messageHandlers[t]))throw new Error("Unexpected method '"+s.method+"' for module '"+t+"'");e.webkit.messageHandlers[t].postMessage(s)}})},Object.defineProperty(e,"__esModule",{value:!0})}(s.exports)),s.exports);function r(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function o(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function a(e,t,s,n,r){const a=r&&"input"in r?r.input:s.value,i=r?.expected??e.expects??null,c=r?.received??o(a),u={kind:e.kind,type:e.type,input:a,expected:i,received:c,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},l="schema"===e.kind,d=r?.message??e.message??(e.reference,void u.lang)??(l?void u.lang:null)??n.message??void u.lang;void 0!==d&&(u.message="function"==typeof d?d(u):d),l&&(s.typed=!1),s.issues?s.issues.push(u):s.issues=[u]}function i(e){return{version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},r())}}function c(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function u(e,t){const s=[...new Set(e)];return s.length>1?`(${s.join(` ${t} `)})`:s[0]??"never"}function l(e,t){return{kind:"validation",type:"min_length",reference:l,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&a(this,"length",e,t,{received:`${e.value.length}`}),e}}}function d(e){return{kind:"validation",type:"url",reference:d,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&a(this,"URL",e,t),e}}}function h(e,t,s){return"function"==typeof e.fallback?e.fallback(t,s):e.fallback}function p(e,t,s){return"function"==typeof e.default?e.default(t,s):e.default}function m(e){return{kind:"schema",type:"boolean",reference:m,expects:"boolean",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"boolean"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}}}function g(e,t){return{kind:"schema",type:"literal",reference:g,expects:o(e),async:!1,literal:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:a(this,"type",e,t),e}}}function f(e,t){return{kind:"schema",type:"nullish",reference:f,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return null!==e.value&&void 0!==e.value||(void 0!==this.default&&(e.value=p(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped["~run"](e,t):(e.typed=!0,e)}}}function v(e){return{kind:"schema",type:"number",reference:v,expects:"number",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?a(this,"type",e,t):e.typed=!0,e}}}function y(e,t){return{kind:"schema",type:"object",reference:y,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){const s=e.value;if(s&&"object"==typeof s){e.typed=!0,e.value={};for(const n in this.entries){const r=this.entries[n];if(n in s||("exact_optional"===r.type||"optional"===r.type||"nullish"===r.type)&&void 0!==r.default){const o=n in s?s[n]:p(r),a=r["~run"]({value:o},t);if(a.issues){const r={type:"object",origin:"value",input:s,key:n,value:o};for(const t of a.issues)t.path?t.path.unshift(r):t.path=[r],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[n]=a.value}else if(void 0!==r.fallback)e.value[n]=h(r);else if("exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type&&(a(this,"key",e,t,{input:void 0,expected:`"${n}"`,path:[{type:"object",origin:"key",input:s,key:n,value:s[n]}]}),t.abortEarly))break}}else a(this,"type",e,t);return e}}}function w(e,t){return{kind:"schema",type:"optional",reference:w,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function S(e,t){return{kind:"schema",type:"picklist",reference:S,expects:u(e.map(o),"|"),async:!1,options:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:a(this,"type",e,t),e}}}function k(e,t,s){return{kind:"schema",type:"record",reference:k,expects:"Object",async:!1,key:e,value:t,message:s,get"~standard"(){return i(this)},"~run"(e,t){const s=e.value;if(s&&"object"==typeof s){e.typed=!0,e.value={};for(const n in s)if(c(s,n)){const r=s[n],o=this.key["~run"]({value:n},t);if(o.issues){const a={type:"object",origin:"key",input:s,key:n,value:r};for(const t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const a=this.value["~run"]({value:r},t);if(a.issues){const o={type:"object",origin:"value",input:s,key:n,value:r};for(const t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}o.typed&&a.typed||(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else a(this,"type",e,t);return e}}}function b(e){return{kind:"schema",type:"string",reference:b,expects:"string",async:!1,message:e,get"~standard"(){return i(this)},"~run"(e,t){return"string"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}}}function R(e){let t;if(e)for(const s of e)t?t.push(...s.issues):t=s.issues;return t}function _(e,t){return{kind:"schema",type:"union",reference:_,expects:u(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){let s,n,r;for(const o of this.options){const a=o["~run"]({value:e.value},t);if(a.typed){if(!a.issues){s=a;break}n?n.push(a):n=[a]}else r?r.push(a):r=[a]}if(s)return s;if(n){if(1===n.length)return n[0];a(this,"type",e,t,{issues:R(n)}),e.typed=!0}else{if(1===r?.length)return r[0];a(this,"type",e,t,{issues:R(r)})}return e}}}function x(){return{kind:"schema",type:"unknown",reference:x,expects:"unknown",async:!1,get"~standard"(){return i(this)},"~run":e=>(e.typed=!0,e)}}function E(...e){return{...e[0],pipe:e,get"~standard"(){return i(this)},"~run"(t,s){for(const n of e)if("metadata"!==n.kind){if(t.issues&&("schema"===n.kind||"transformation"===n.kind)){t.typed=!1;break}t.issues&&(s.abortEarly||s.abortPipeEarly)||(t=n["~run"](t,s))}return t}}}function C(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class U{constructor(e){this.moduleName=e}formatPrefix(e){return`[SuperAppSDK][${this.moduleName}.${e}]`}warn(e,t){console.warn(`${this.formatPrefix(e)} ${t}`)}error(e,t){console.error(`${this.formatPrefix(e)} ${t}`)}}function $(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class A{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new U(e),!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${C(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const s=function(e,t){const s=e["~run"]({value:t},r(void 0));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}(e,t);return s.success?null:s.issues.map(e=>{const t=e.path?.map(e=>String(e.key)).join(".");return t?`${t}: ${e.message}`:e.message}).join(", ")}checkSupport(e){const t=$();return t?e(t)?null:{status_code:426,error:"Upgrade Required: This method requires a newer version of the Grab app"}:{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}async invoke(e){const{method:t,params:s}=e;try{return $()?await this.wrappedModule.invoke(t,s):{status_code:501,error:"Not implemented: This method requires the Grab app environment"}}catch(e){return{status_code:500,error:`Failed to invoke method: ${C(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:s}=e;try{return $()?this.wrappedModule.invoke(t,s):this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"})}catch(e){return this.createErrorStream({status_code:500,error:`Failed to invoke method: ${C(e)?e.message:"Unknown error"}`})}}}function M(e){return e.status_code>=200&&e.status_code<300}function I(e){return 200===e.status_code}function T(e){return"result"in e&&null!==e.result&&void 0!==e.result}const O=e=>y({status_code:g(e),error:b()}),N=e=>y({status_code:g(200),result:e}),B=y({status_code:g(204)}),P=y({status_code:g(302)}),L=y({title:w(b())}),D=y({qrCode:b()}),G=_([N(D),B,O(400),O(403),O(500),O(501)]),j=k(b(),x()),z=function e(t,s,n){return{kind:"schema",type:"variant",reference:e,expects:"Object",async:!1,key:t,options:s,message:n,get"~standard"(){return i(this)},"~run"(e,t){const s=e.value;if(s&&"object"==typeof s){let n,r=0,o=this.key,i=[];const c=(e,a)=>{for(const u of e.options){if("variant"===u.type)c(u,new Set(a).add(u.key));else{let e=!0,c=0;for(const t of a){const n=u.entries[t];if(t in s?n["~run"]({typed:!1,value:s[t]},{abortEarly:!0}).issues:"exact_optional"!==n.type&&"optional"!==n.type&&"nullish"!==n.type){e=!1,o!==t&&(r<c||r===c&&t in s&&!(o in s))&&(r=c,o=t,i=[]),o===t&&i.push(u.entries[t].expects);break}c++}if(e){const e=u["~run"]({value:s},t);(!n||!n.typed&&e.typed)&&(n=e)}}if(n&&!n.issues)break}};if(c(this,new Set([this.key])),n)return n;a(this,"type",e,t,{input:s[o],expected:u(i,"|"),path:[{type:"object",origin:"value",input:s,key:o,value:s[o]}]})}else a(this,"type",e,t);return e}}}("status",[y({status:g("success"),transactionID:b()}),y({status:g("failure"),transactionID:b(),errorMessage:b(),errorCode:b()}),y({status:g("pending"),transactionID:b()}),y({status:g("userInitiatedCancel")})]),q=_([N(z),O(400),O(500),O(501)]),V=_([N(m()),B,O(400),O(500),O(501)]),F=_([B,O(400),O(500),O(501)]),K=_([N(m()),B,O(400),O(500),O(501)]),W=_([B,O(400),O(500),O(501)]),H=_([N(m()),B,O(500),O(501)]),Y=_([B,O(500),O(501)]),Q=_([N(m()),B,O(500),O(501)]),J=_([B,O(500),O(501)]),X=_([N(m()),B,O(500),O(501)]),Z=_([B,O(500),O(501)]),ee=_([N(m()),B,O(500),O(501)]),te=_([B,O(500),O(501)]),se=_([N(m()),B,O(500),O(501)]),ne=_([B,O(500),O(501)]),re=_([N(m()),B,O(500),O(501)]),oe=_([N(m()),B,O(500),O(501)]),ae=_([B,O(500),O(501)]),ie=_([N(m()),B,O(500),O(501)]),ce=_([B,O(500),O(501)]),ue=_([N(m()),B,O(400),O(500),O(501)]),le=_([B,O(400),O(500),O(501)]),de=_([N(m()),O(500),O(501)]),he=y({state:E(b(),l(1)),name:E(b(),l(1)),data:w(k(b(),x()))}),pe=_([N(m()),B,O(400),O(500),O(501)]),me=_([B,O(400),O(500),O(501)]),ge=y({connected:m()}),fe=_([N(ge),O(404)]),ve=b(),ye=_([N(ve),B,O(500),O(501)]);function we(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const Se=m(),ke=_([N(Se),O(403),O(424),O(426),O(500),O(501)]);class be extends A{constructor(){super("DeviceModule")}async isEsimSupported(){const e=this.checkSupport(e=>we(e.version,be.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"isEsimSupported"}),s=this.validate(ke,t);return s&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${s}`),t}}be.MINIMUM_VERSION={major:5,minor:402,patch:0};const Re=y({fileUrl:E(b(),d()),fileName:E(b(),l(1))}),_e=_([B,O(400),O(500),O(501)]);function xe(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let s="";for(let n=0;n<e;n+=1)s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[n]%62);return s}async function Ee(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let s="";for(let e=0;e<t.byteLength;e+=1)s+=String.fromCharCode(t[e]);return btoa(s).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}const Ce="grabid",Ue={staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"};class $e extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Ae=y({clientId:E(b(),l(1)),redirectUri:E(b(),d()),scope:E(b(),l(1)),environment:S(["staging","production"]),responseMode:w(S(["redirect","in_place"]))}),Me=_([N(y({code:b(),state:b()})),B,P,O(400),O(403),O(500),O(501)]),Ie=y({code:b(),state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Te=_([N(Ie),B,P,O(400),O(403),O(500),O(501)]),Oe=y({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Ne=_([N(Oe),B,O(400)]),Be=_([B]);class Pe extends A{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=Ue[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new $e("Failed to fetch authorization configuration");const s=await e.json();if(!s.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new $e("Invalid authorization configuration");return s.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof $e)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=xe(16),t=xe(32),s=(n=xe(64),btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var n;return{nonce:e,state:t,codeVerifier:s,codeChallenge:await Ee(s),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),s=this.getStorageItem("nonce"),n=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===s&&null===n?{status_code:204}:null!==e&&null!==t&&null!==s&&null!==n?{status_code:200,result:{state:e,codeVerifier:t,nonce:s,redirectUri:n}}:{status_code:400,error:"Inconsistent authorization artifacts in storage"}}async clearAuthorizationArtifacts(){return window.localStorage.removeItem(`${Ce}:nonce`),window.localStorage.removeItem(`${Ce}:state`),window.localStorage.removeItem(`${Ce}:code_verifier`),window.localStorage.removeItem(`${Ce}:redirect_uri`),window.localStorage.removeItem(`${Ce}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${Ce}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${Ce}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=$();return!t||"staging"!==e.environment&&!we(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:C(e)?e.message:"Could not fetch authorization endpoint"}}const s={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},n=Pe.buildAuthorizeUrl(t,s);return window.location.assign(n),{status_code:302}}async performNativeAuthorization(e){const t=await this.invoke({method:"authorize",params:{clientId:e.clientId,redirectUri:e.actualRedirectUri,scope:e.scope,nonce:e.nonce,state:e.state,codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod,responseMode:e.responseMode}}),s=this.validate(Me,t);return s&&this.logger.warn("authorize",`Unexpected response shape: ${s}`),t}async authorize(e){const t=this.validate(Ae,e);if(t)return{status_code:400,error:t};const s=await this.generatePKCEArtifacts(),n=e.responseMode||"redirect",r="in_place"===n?Pe.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...s,redirectUri:r});const o={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:s.nonce,state:s.state,codeChallenge:s.codeChallenge,codeChallengeMethod:s.codeChallengeMethod};if(Pe.shouldUseWebConsent(e))return this.performWebAuthorization({...o,environment:e.environment});try{const t=await this.performNativeAuthorization({...o,actualRedirectUri:r,responseMode:n});return 200===t.status_code?{status_code:200,result:{code:t.result.code,state:t.result.state,codeVerifier:s.codeVerifier,nonce:s.nonce,redirectUri:r}}:400===t.status_code||403===t.status_code||500===t.status_code||501===t.status_code?(console.error(`Native authorization returned ${t.status_code}, falling back to web flow:`,t.error),this.performWebAuthorization({...o,environment:e.environment})):t}catch(t){return console.error("Native authorization failed, falling back to web flow:",t),this.performWebAuthorization({...o,environment:e.environment})}}}const Le=b(),De=_([N(Le),B,O(400),O(500),O(501)]),Ge=y({latitude:v(),longitude:v()}),je=_([N(Ge),O(403),O(424),O(500),O(501)]),ze=b(),qe=_([N(ze),B,O(403),O(424),O(500),O(501)]),Ve=y({type:S(["START_PLAYBACK","PROGRESS_PLAYBACK","START_SEEK","STOP_SEEK","STOP_PLAYBACK","CLOSE_PLAYBACK","PAUSE_PLAYBACK","RESUME_PLAYBACK","FAST_FORWARD_PLAYBACK","REWIND_PLAYBACK","ERROR_PLAYBACK","CHANGE_VOLUME"]),titleId:b(),position:v(),length:v()}),Fe=_([N(Ve),B,O(400),O(424),O(500),O(501)]),Ke=_([N(Ve),O(500),O(501)]),We=y({endpoint:b(),method:S(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:w(k(b(),b())),query:w(k(b(),b())),body:w(x()),timeout:w(v())}),He=k(b(),x()),Ye=_([N(He),B,O(400),O(401),O(403),O(404),O(424),O(426),O(500),O(501)]),Qe=_([b(),He]),Je=_([N(Qe),B,O(400),O(401),O(403),O(404),O(424),O(426),O(500),O(501)]),Xe=_([B,O(500),O(501)]),Ze=y({email:b()}),et=_([N(Ze),B,O(400),O(403),O(426),O(500),O(501)]),tt=y({email:w(E(b(),l(1))),skipUserInput:w(m())}),st=y({email:b()}),nt=_([N(st),B,O(400),O(403),O(426),O(500),O(501)]);class rt extends A{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>we(e.version,rt.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),s=this.validate(et,t);return s&&this.logger.warn("fetchEmail",`Unexpected response shape: ${s}`),t}async verifyEmail(e){const t=this.checkSupport(e=>we(e.version,rt.MINIMUM_VERSION));if(t)return t;const s=this.validate(tt,e??{});if(s)return{status_code:400,error:s};const n=await this.invoke({method:"verifyEmail",params:e}),r=this.validate(nt,n);return r&&this.logger.warn("verifyEmail",`Unexpected response shape: ${r}`),n}}rt.MINIMUM_VERSION={major:5,minor:399,patch:0};const ot=y({module:E(b(),l(1)),method:E(b(),l(1))}),at=m(),it=_([N(at),O(400),O(424),O(500),O(501)]),ct=_([B,O(424),O(500),O(501)]),ut=_([B,O(400),O(403),O(500),O(501)]),lt=E(b(),l(1)),dt=y({key:lt}),ht=y({key:lt,value:m()}),pt=_([B,O(400),O(424),O(500),O(501)]),mt=dt,gt=m(),ft=_([y({status_code:g(200),result:f(m())}),B,O(400),O(424)]),vt=_([N(gt),B,O(400),O(424),O(500),O(501)]),yt=y({key:lt,value:v()}),wt=_([B,O(400),O(424),O(500),O(501)]),St=dt,kt=v(),bt=_([y({status_code:g(200),result:f(v())}),B,O(400),O(424)]),Rt=_([N(kt),B,O(400),O(424),O(500),O(501)]),_t=y({key:lt,value:b()}),xt=_([B,O(400),O(424),O(500),O(501)]),Et=dt,Ct=b(),Ut=_([y({status_code:g(200),result:f(b())}),B,O(400),O(424)]),$t=_([N(Ct),B,O(400),O(424),O(500),O(501)]),At=y({key:lt,value:v()}),Mt=_([B,O(400),O(424),O(500),O(501)]),It=dt,Tt=v(),Ot=_([y({status_code:g(200),result:f(v())}),B,O(400),O(424)]),Nt=_([N(Tt),B,O(400),O(424),O(500),O(501)]),Bt=dt,Pt=_([B,O(400),O(424),O(500),O(501)]),Lt=_([B,O(424),O(500),O(501)]),Dt=y({url:E(b(),d())}),Gt=_([N(b()),O(400),O(424),O(500),O(501)]),jt=b(),zt=_([N(jt),B,O(500),O(501)]);e.AuthorizeRequestSchema=Ae,e.AuthorizeResponseSchema=Te,e.AuthorizeResultSchema=Ie,e.BackResponseSchema=Xe,e.BaseModule=A,e.CameraModule=class extends A{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(L,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"scanQRCode",params:e}),n=this.validate(G,s);return n&&this.logger.warn("scanQRCode",`Unexpected response shape: ${n}`),s}},e.CheckoutModule=class extends A{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(j,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"triggerCheckout",params:e}),n=this.validate(q,s);return n&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${n}`),s}},e.ClearAuthorizationArtifactsResponseSchema=Be,e.CloseResponseSchema=ne,e.ContainerAnalyticsEventData={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},e.ContainerAnalyticsEventName={DEFAULT:"DEFAULT"},e.ContainerAnalyticsEventState={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},e.ContainerModule=class extends A{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),s=this.validate(V,t);let n;s&&this.logger.warn("setBackgroundColor",`Unexpected raw response shape: ${s}`),n=I(t)?{status_code:204}:t;const r=this.validate(F,n);return r&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${r}`),n}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),s=this.validate(K,t);let n;s&&this.logger.warn("setTitle",`Unexpected raw response shape: ${s}`),n=I(t)?{status_code:204}:t;const r=this.validate(W,n);return r&&this.logger.warn("setTitle",`Unexpected response shape: ${r}`),n}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(H,e);let s;t&&this.logger.warn("hideBackButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(Y,s);return n&&this.logger.warn("hideBackButton",`Unexpected response shape: ${n}`),s}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(Q,e);let s;t&&this.logger.warn("showBackButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(J,s);return n&&this.logger.warn("showBackButton",`Unexpected response shape: ${n}`),s}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(X,e);let s;t&&this.logger.warn("hideRefreshButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(Z,s);return n&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${n}`),s}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(ee,e);let s;t&&this.logger.warn("showRefreshButton",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(te,s);return n&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${n}`),s}async close(){const e=await this.invoke({method:"close"}),t=this.validate(se,e);let s;t&&this.logger.warn("close",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(ne,s);return n&&this.logger.warn("close",`Unexpected response shape: ${n}`),s}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(re,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(oe,e);let s;t&&this.logger.warn("showLoader",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(ae,s);return n&&this.logger.warn("showLoader",`Unexpected response shape: ${n}`),s}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ie,e);let s;t&&this.logger.warn("hideLoader",`Unexpected raw response shape: ${t}`),s=I(e)?{status_code:204}:e;const n=this.validate(ce,s);return n&&this.logger.warn("hideLoader",`Unexpected response shape: ${n}`),s}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),s=this.validate(ue,t);let n;s&&this.logger.warn("openExternalLink",`Unexpected raw response shape: ${s}`),n=I(t)?{status_code:204}:t;const r=this.validate(le,n);return r&&this.logger.warn("openExternalLink",`Unexpected response shape: ${r}`),n}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),s=this.validate(de,t);return s&&this.logger.warn("onCtaTap",`Unexpected response shape: ${s}`),t}async sendAnalyticsEvent(e){const t=this.validate(he,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}}),n=this.validate(pe,s);let r;n&&this.logger.warn("sendAnalyticsEvent",`Unexpected raw response shape: ${n}`),r=I(s)?{status_code:204}:s;const o=this.validate(me,r);return o&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${o}`),r}async isConnected(){return null!==$()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(ye,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}},e.DRMPlaybackEventSchema=Ve,e.DeviceModule=be,e.DismissSplashScreenResponseSchema=ut,e.DownloadFileRequestSchema=Re,e.DownloadFileResponseSchema=_e,e.FetchEmailResponseSchema=et,e.FetchEmailResultSchema=Ze,e.FileModule=class extends A{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(Re,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"downloadFile",params:e}),n=this.validate(_e,s);return n&&this.logger.warn("downloadFile",`Unexpected response shape: ${n}`),s}},e.GetAuthorizationArtifactsResponseSchema=Ne,e.GetAuthorizationArtifactsResultSchema=Oe,e.GetBooleanRequestSchema=mt,e.GetBooleanResponseSchema=vt,e.GetBooleanResultSchema=gt,e.GetCoordinateResponseSchema=je,e.GetCoordinateResultSchema=Ge,e.GetCountryCodeResponseSchema=qe,e.GetCountryCodeResultSchema=ze,e.GetDoubleRequestSchema=It,e.GetDoubleResponseSchema=Nt,e.GetDoubleResultSchema=Tt,e.GetIntRequestSchema=St,e.GetIntResponseSchema=Rt,e.GetIntResultSchema=kt,e.GetLanguageLocaleIdentifierResponseSchema=De,e.GetLanguageLocaleIdentifierResultSchema=Le,e.GetSelectedTravelDestinationResponseSchema=zt,e.GetSelectedTravelDestinationResultSchema=jt,e.GetSessionParamsResponseSchema=ye,e.GetSessionParamsResultSchema=ve,e.GetStringRequestSchema=Et,e.GetStringResponseSchema=$t,e.GetStringResultSchema=Ct,e.HasAccessToRequestSchema=ot,e.HasAccessToResponseSchema=it,e.HasAccessToResultSchema=at,e.HideBackButtonResponseSchema=Y,e.HideLoaderResponseSchema=ce,e.HideRefreshButtonResponseSchema=Z,e.IdentityModule=Pe,e.IsConnectedResponseSchema=fe,e.IsConnectedResultSchema=ge,e.IsEsimSupportedResponseSchema=ke,e.IsEsimSupportedResultSchema=Se,e.LocaleModule=class extends A{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(De,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}},e.LocationModule=class extends A{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(je,e);return t&&this.logger.warn("getCoordinate",`Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(qe,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}},e.Logger=U,e.MediaModule=class extends A{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),s=this.validate(Fe,t);return s&&this.logger.warn("playDRMContent",`Unexpected response shape: ${s}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}},e.NetworkModule=class extends A{constructor(){super("NetworkModule")}async send(e){const t=this.validate(We,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"send",params:e}),n=this.validate(Je,s);if(n&&this.logger.warn("send",`Unexpected raw response shape: ${n}`),M(s)&&T(s)&&"string"==typeof s.result)try{const e=JSON.parse(s.result),t={...s,result:e},n=this.validate(Ye,t);return n&&this.logger.warn("send",`Unexpected response shape after parsing: ${n}`),t}catch{return{status_code:500,error:"Failed to parse response result as JSON"}}const r=s,o=this.validate(Ye,r);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),r}},e.ObserveDRMPlaybackResponseSchema=Ke,e.OnContentLoadedResponseSchema=re,e.OnCtaTapResponseSchema=de,e.OpenExternalLinkResponseSchema=le,e.PlatformModule=class extends A{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(Xe,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}},e.PlayDRMContentResponseSchema=Fe,e.ProfileModule=rt,e.RedirectToSystemWebViewRequestSchema=Dt,e.RedirectToSystemWebViewResponseSchema=Gt,e.ReloadScopesResponseSchema=ct,e.RemoveAllResponseSchema=Lt,e.RemoveResponseSchema=Pt,e.ScanQRCodeRequestSchema=L,e.ScanQRCodeResponseSchema=G,e.ScanQRCodeResultSchema=D,e.ScopeModule=class extends A{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const s={module:e,method:t},n=this.validate(ot,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"hasAccessTo",params:s}),o=this.validate(it,r);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),r}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(ct,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}},e.SendAnalyticsEventRequestSchema=he,e.SendAnalyticsEventResponseSchema=me,e.SendRequestSchema=We,e.SendResponseSchema=Ye,e.SendResultSchema=He,e.SetBackgroundColorResponseSchema=F,e.SetBooleanRequestSchema=ht,e.SetBooleanResponseSchema=pt,e.SetDoubleRequestSchema=At,e.SetDoubleResponseSchema=Mt,e.SetIntRequestSchema=yt,e.SetIntResponseSchema=wt,e.SetStringRequestSchema=_t,e.SetStringResponseSchema=xt,e.SetTitleResponseSchema=W,e.ShowBackButtonResponseSchema=J,e.ShowLoaderResponseSchema=ae,e.ShowRefreshButtonResponseSchema=te,e.SplashScreenModule=class extends A{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(ut,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}},e.StorageModule=class extends A{constructor(){super("StorageModule")}async setBoolean(e,t){const s={key:e,value:t},n=this.validate(ht,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setBoolean",params:s}),o=this.validate(pt,r);return o&&this.logger.warn("setBoolean",`Unexpected response shape: ${o}`),r}async getBoolean(e){const t={key:e},s=this.validate(mt,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getBoolean",params:t}),r=this.validate(ft,n);let o;if(r&&this.logger.warn("getBoolean",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate(vt,o);return a&&this.logger.warn("getBoolean",`Unexpected response shape: ${a}`),o}async setInt(e,t){const s={key:e,value:t},n=this.validate(yt,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setInt",params:s}),o=this.validate(wt,r);return o&&this.logger.warn("setInt",`Unexpected response shape: ${o}`),r}async getInt(e){const t={key:e},s=this.validate(St,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getInt",params:t}),r=this.validate(bt,n);let o;if(r&&this.logger.warn("getInt",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate(Rt,o);return a&&this.logger.warn("getInt",`Unexpected response shape: ${a}`),o}async setString(e,t){const s={key:e,value:t},n=this.validate(_t,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setString",params:s}),o=this.validate(xt,r);return o&&this.logger.warn("setString",`Unexpected response shape: ${o}`),r}async getString(e){const t={key:e},s=this.validate(Et,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getString",params:t}),r=this.validate(Ut,n);let o;if(r&&this.logger.warn("getString",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate($t,o);return a&&this.logger.warn("getString",`Unexpected response shape: ${a}`),o}async setDouble(e,t){const s={key:e,value:t},n=this.validate(At,s);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"setDouble",params:s}),o=this.validate(Mt,r);return o&&this.logger.warn("setDouble",`Unexpected response shape: ${o}`),r}async getDouble(e){const t={key:e},s=this.validate(It,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"getDouble",params:t}),r=this.validate(Ot,n);let o;if(r&&this.logger.warn("getDouble",`Unexpected raw response shape: ${r}`),200===n.status_code){const e=n.result;o=null==e?{status_code:204}:{status_code:200,result:e}}else o=n;const a=this.validate(Nt,o);return a&&this.logger.warn("getDouble",`Unexpected response shape: ${a}`),o}async remove(e){const t={key:e},s=this.validate(Bt,t);if(s)return{status_code:400,error:s};const n=await this.invoke({method:"remove",params:t}),r=this.validate(Pt,n);return r&&this.logger.warn("remove",`Unexpected response shape: ${r}`),n}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(Lt,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}},e.SystemWebViewKitModule=class extends A{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(Dt,e);if(t)return{status_code:400,error:t};const s=await this.invoke({method:"redirectToSystemWebView",params:e}),n=this.validate(Gt,s);return n&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${n}`),s}},e.TriggerCheckoutRequestSchema=j,e.TriggerCheckoutResponseSchema=q,e.TriggerCheckoutResultSchema=z,e.UserAttributesModule=class extends A{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(zt,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}},e.VerifyEmailRequestSchema=tt,e.VerifyEmailResponseSchema=nt,e.VerifyEmailResultSchema=st,e.hasResult=T,e.isClientError=function(e){return e.status_code>=400&&e.status_code<500},e.isError=function(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0},e.isFound=function(e){return 302===e.status_code},e.isNoContent=function(e){return 204===e.status_code},e.isOk=I,e.isRedirection=function(e){return 302===e.status_code},e.isServerError=function(e){return e.status_code>=500&&e.status_code<600},e.isSuccess=M});
|