@grabjs/superapp-sdk 2.0.0-beta.36 → 2.0.0-beta.38
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 +6715 -5605
- package/dist/index.d.ts +55 -50
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/skills/SKILL.md +8 -2
package/dist/index.d.ts
CHANGED
|
@@ -2335,6 +2335,27 @@ export declare type HasAccessToResult = InferOutput<typeof HasAccessToResultSche
|
|
|
2335
2335
|
*/
|
|
2336
2336
|
export declare const HasAccessToResultSchema: v.BooleanSchema<undefined>;
|
|
2337
2337
|
|
|
2338
|
+
/**
|
|
2339
|
+
* Type guard to check if a JSBridge response has a defined result (not null or undefined).
|
|
2340
|
+
*
|
|
2341
|
+
* @param response - The JSBridge response to check
|
|
2342
|
+
* @returns True if the response has a result that is neither null nor undefined, false otherwise
|
|
2343
|
+
*
|
|
2344
|
+
* @example
|
|
2345
|
+
* ```typescript
|
|
2346
|
+
* const response = await someBridgeMethod();
|
|
2347
|
+
* if (isSuccess(response) && hasResult(response)) {
|
|
2348
|
+
* // response.result is guaranteed to be defined
|
|
2349
|
+
* console.log('Result:', response.result);
|
|
2350
|
+
* }
|
|
2351
|
+
* ```
|
|
2352
|
+
*
|
|
2353
|
+
* @public
|
|
2354
|
+
*/
|
|
2355
|
+
export declare function hasResult<T extends BridgeResponse>(response: T): response is Extract<T, {
|
|
2356
|
+
result: NonNullable<unknown>;
|
|
2357
|
+
}>;
|
|
2358
|
+
|
|
2338
2359
|
/**
|
|
2339
2360
|
* Response when hiding the back button.
|
|
2340
2361
|
*
|
|
@@ -3344,6 +3365,8 @@ export declare class MediaModule extends BaseModule {
|
|
|
3344
3365
|
*
|
|
3345
3366
|
* @remarks
|
|
3346
3367
|
* Provides access to native network functionality for making HTTP requests.
|
|
3368
|
+
* This module is **only** for MiniApps hosted on the Grab domain to call authenticated Grab API endpoints.
|
|
3369
|
+
* It should **not** be used by external MiniApps (not on Grab domain) or for non-authenticated Grab APIs.
|
|
3347
3370
|
* This code must run on the Grab SuperApp's WebView to function correctly.
|
|
3348
3371
|
*
|
|
3349
3372
|
* @example
|
|
@@ -3375,36 +3398,14 @@ export declare class NetworkModule extends BaseModule {
|
|
|
3375
3398
|
* @returns The network response containing the result data or error information. See {@link SendResponse}.
|
|
3376
3399
|
*
|
|
3377
3400
|
* @example
|
|
3378
|
-
* **Simple
|
|
3401
|
+
* **Simple usage**
|
|
3379
3402
|
* ```typescript
|
|
3380
3403
|
* import { NetworkModule, isSuccess, isError, hasResult } from '@grabjs/superapp-sdk';
|
|
3381
3404
|
*
|
|
3382
3405
|
* // Initialize the network module
|
|
3383
3406
|
* const network = new NetworkModule();
|
|
3384
3407
|
*
|
|
3385
|
-
* // Send a
|
|
3386
|
-
* const response = await network.send({
|
|
3387
|
-
* endpoint: 'https://api.example.com/users',
|
|
3388
|
-
* method: 'GET'
|
|
3389
|
-
* });
|
|
3390
|
-
*
|
|
3391
|
-
* // Handle the response
|
|
3392
|
-
* if (isSuccess(response) && hasResult(response)) {
|
|
3393
|
-
* console.log('Response data:', response.result);
|
|
3394
|
-
* } else if (isError(response)) {
|
|
3395
|
-
* console.error(`Error ${response.status_code}: ${response.error}`);
|
|
3396
|
-
* } else {
|
|
3397
|
-
* console.error('Unhandled response');
|
|
3398
|
-
* }
|
|
3399
|
-
* ```
|
|
3400
|
-
*
|
|
3401
|
-
* @example
|
|
3402
|
-
* **POST request with body and headers**
|
|
3403
|
-
* ```typescript
|
|
3404
|
-
* import { NetworkModule, isSuccess, isError, hasResult } from '@grabjs/superapp-sdk';
|
|
3405
|
-
*
|
|
3406
|
-
* const network = new NetworkModule();
|
|
3407
|
-
*
|
|
3408
|
+
* // Send a POST request with headers and body
|
|
3408
3409
|
* const response = await network.send({
|
|
3409
3410
|
* endpoint: 'https://api.example.com/users',
|
|
3410
3411
|
* method: 'POST',
|
|
@@ -3413,32 +3414,13 @@ export declare class NetworkModule extends BaseModule {
|
|
|
3413
3414
|
* timeout: 30
|
|
3414
3415
|
* });
|
|
3415
3416
|
*
|
|
3417
|
+
* // Handle the response
|
|
3416
3418
|
* if (isSuccess(response) && hasResult(response)) {
|
|
3417
|
-
* console.log('
|
|
3419
|
+
* console.log('Success:', response.result);
|
|
3418
3420
|
* } else if (isError(response)) {
|
|
3419
3421
|
* console.error(`Error ${response.status_code}: ${response.error}`);
|
|
3420
|
-
* }
|
|
3421
|
-
*
|
|
3422
|
-
*
|
|
3423
|
-
* @example
|
|
3424
|
-
* **Handling specific status codes**
|
|
3425
|
-
* ```typescript
|
|
3426
|
-
* import { NetworkModule, isClientError, isServerError, isSuccess, hasResult } from '@grabjs/superapp-sdk';
|
|
3427
|
-
*
|
|
3428
|
-
* const network = new NetworkModule();
|
|
3429
|
-
* const response = await network.send({
|
|
3430
|
-
* endpoint: 'https://api.example.com/users/123',
|
|
3431
|
-
* method: 'GET'
|
|
3432
|
-
* });
|
|
3433
|
-
*
|
|
3434
|
-
* if (isSuccess(response) && hasResult(response)) {
|
|
3435
|
-
* console.log('Success:', response.result);
|
|
3436
|
-
* } else if (isClientError(response)) {
|
|
3437
|
-
* // Handle 4xx errors (bad request, unauthorized, not found, etc.)
|
|
3438
|
-
* console.error(`Client error ${response.status_code}: ${response.error}`);
|
|
3439
|
-
* } else if (isServerError(response)) {
|
|
3440
|
-
* // Handle 5xx errors (internal server error, service unavailable, etc.)
|
|
3441
|
-
* console.error(`Server error ${response.status_code}: ${response.error}`);
|
|
3422
|
+
* } else {
|
|
3423
|
+
* console.error('Unhandled response');
|
|
3442
3424
|
* }
|
|
3443
3425
|
* ```
|
|
3444
3426
|
*
|
|
@@ -4431,7 +4413,7 @@ export declare const SendRequestSchema: v.ObjectSchema<{
|
|
|
4431
4413
|
*
|
|
4432
4414
|
* @remarks
|
|
4433
4415
|
* This response can have any HTTP status code returned by the external API:
|
|
4434
|
-
* - Success codes (2xx): Contains the `result` with response data.
|
|
4416
|
+
* - Success codes (2xx): Contains the `result` with response data, except 204 which has no body.
|
|
4435
4417
|
* - Client error codes (4xx): Contains an `error` message from the API.
|
|
4436
4418
|
* - Server error codes (5xx): Contains an `error` message from the API.
|
|
4437
4419
|
* - SDK error codes (400, 500, 501): Invalid request, internal SDK error, or not implemented.
|
|
@@ -4446,10 +4428,33 @@ export declare type SendResponse = InferOutput<typeof SendResponseSchema>;
|
|
|
4446
4428
|
* @public
|
|
4447
4429
|
*/
|
|
4448
4430
|
export declare const SendResponseSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
4449
|
-
readonly status_code: v.
|
|
4431
|
+
readonly status_code: v.LiteralSchema<200, undefined>;
|
|
4450
4432
|
readonly result: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
|
|
4451
4433
|
}, undefined>, v.ObjectSchema<{
|
|
4452
|
-
readonly status_code: v.
|
|
4434
|
+
readonly status_code: v.LiteralSchema<204, undefined>;
|
|
4435
|
+
}, undefined>, v.ObjectSchema<{
|
|
4436
|
+
readonly status_code: v.LiteralSchema<400, undefined>;
|
|
4437
|
+
readonly error: v.StringSchema<undefined>;
|
|
4438
|
+
}, undefined>, v.ObjectSchema<{
|
|
4439
|
+
readonly status_code: v.LiteralSchema<401, undefined>;
|
|
4440
|
+
readonly error: v.StringSchema<undefined>;
|
|
4441
|
+
}, undefined>, v.ObjectSchema<{
|
|
4442
|
+
readonly status_code: v.LiteralSchema<403, undefined>;
|
|
4443
|
+
readonly error: v.StringSchema<undefined>;
|
|
4444
|
+
}, undefined>, v.ObjectSchema<{
|
|
4445
|
+
readonly status_code: v.LiteralSchema<404, undefined>;
|
|
4446
|
+
readonly error: v.StringSchema<undefined>;
|
|
4447
|
+
}, undefined>, v.ObjectSchema<{
|
|
4448
|
+
readonly status_code: v.LiteralSchema<424, undefined>;
|
|
4449
|
+
readonly error: v.StringSchema<undefined>;
|
|
4450
|
+
}, undefined>, v.ObjectSchema<{
|
|
4451
|
+
readonly status_code: v.LiteralSchema<426, undefined>;
|
|
4452
|
+
readonly error: v.StringSchema<undefined>;
|
|
4453
|
+
}, undefined>, v.ObjectSchema<{
|
|
4454
|
+
readonly status_code: v.LiteralSchema<500, undefined>;
|
|
4455
|
+
readonly error: v.StringSchema<undefined>;
|
|
4456
|
+
}, undefined>, v.ObjectSchema<{
|
|
4457
|
+
readonly status_code: v.LiteralSchema<501, undefined>;
|
|
4453
4458
|
readonly error: v.StringSchema<undefined>;
|
|
4454
4459
|
}, undefined>], undefined>;
|
|
4455
4460
|
|
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(r,s){try{var o=null,a=!1;o=e({next:function(e){r(null==t?void 0:t(e)),o&&o.unsubscribe(),a=!0}}),a&&o&&o.unsubscribe()}catch(e){null==n?s(e):r(n(e))}})}}}function r(r,s){return s.funcNameToWrap,function(r,s){var o=s.callbackNameFunc,a=s.funcToWrap;return n(function(n){var s,i=o();return r[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 r=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=r.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&s.unsubscribe();else{var r=t.result,o=t.error,a=t.status_code;n&&n.next&&n.next({result:null===r?void 0:r,error:null===o?void 0:o,status_code:null===a?void 0:a})}},a(i),s=t(function(){r[i]=void 0,n&&n.complete&&n.complete()})})}(r,function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&(n[r[s]]=e[r[s]])}return n}(s,["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(s,o){return r(e,{funcNameToWrap:s,callbackNameFunc:function(){return function(e,t){var n=t.moduleName,r=t.funcName,s=0;return function(){for(var t,o,a="";(a=(t={moduleName:n,funcName:r,requestID:s}).moduleName+"_"+t.funcName+"Callback"+(null!==(o=t.requestID)?"_"+o:""))in e;)s+=1;return s+=1,a}()}(e,{moduleName:t,funcName:s})},funcToWrap:function(e){return n({callback:e,method:s,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 r(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function s(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,r,o){const a=o&&"input"in o?o.input:n.value,i=o?.expected??e.expects??null,c=o?.received??s(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:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},d="schema"===e.kind,l=o?.message??e.message??(e.reference,void u.lang)??(d?void u.lang:null)??r.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},r())}}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 m(e,t){return{kind:"schema",type:"literal",reference:m,expects:s(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 g(e,t){return{kind:"schema",type:"nullable",reference:g,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return null===e.value&&(void 0!==this.default&&(e.value=h(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}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 r in this.entries){const s=this.entries[r];if(r in n||("exact_optional"===s.type||"optional"===s.type||"nullish"===s.type)&&void 0!==s.default){const o=r in n?n[r]:h(s),a=s["~run"]({value:o},t);if(a.issues){const s={type:"object",origin:"value",input:n,key:r,value:o};for(const t of a.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[r]=a.value}else if(void 0!==s.fallback)e.value[r]=l(s);else if("exact_optional"!==s.type&&"optional"!==s.type&&"nullish"!==s.type&&(o(this,"key",e,t,{input:void 0,expected:`"${r}"`,path:[{type:"object",origin:"key",input:n,key:r,value:n[r]}]}),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(s),"|"),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 r in n)if(i(n,r)){const s=n[r],o=this.key["~run"]({value:r},t);if(o.issues){const a={type:"object",origin:"key",input:n,key:r,value:s};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:s},t);if(a.issues){const o={type:"object",origin:"value",input:n,key:r,value:s};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,r,s;for(const o of this.options){const a=o["~run"]({value:e.value},t);if(a.typed){if(!a.issues){n=a;break}r?r.push(a):r=[a]}else s?s.push(a):s=[a]}if(n)return n;if(r){if(1===r.length)return r[0];o(this,"type",e,t,{issues:_(r)}),e.typed=!0}else{if(1===s?.length)return s[0];o(this,"type",e,t,{issues:_(s)})}return e}}}function S(){return{kind:"schema",type:"unknown",reference:S,expects:"unknown",async:!1,get"~standard"(){return a(this)},"~run":e=>(e.typed=!0,e)}}function E(...e){return{...e[0],pipe:e,get"~standard"(){return a(this)},"~run"(t,n){for(const r of e)if("metadata"!==r.kind){if(t.issues&&("schema"===r.kind||"transformation"===r.kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=r["~run"](t,n))}return t}}}function U(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class C{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 C(e),!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${U(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},r(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=$();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 $()?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: ${U(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 $()?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: ${U(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 L(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0}const B=e=>v({status_code:m(e),error:b()}),j=e=>v({status_code:m(200),result:e}),D=v({status_code:m(204)}),z=v({status_code:m(302)}),K=v({title:y(b())}),G=v({qrCode:b()}),W=x([j(G),D,B(400),B(403),B(500),B(501)]);class F extends A{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(K,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),r=this.validate(W,n);return r&&this.logger.warn("scanQRCode",`Unexpected response shape: ${r}`),n}}const q=k(b(),S()),H=function e(t,n,r){return{kind:"schema",type:"variant",reference:e,expects:"Object",async:!1,key:t,options:n,message:r,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){let r,s=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 r=c.entries[t];if(t in n?r["~run"]({typed:!1,value:n[t]},{abortEarly:!0}).issues:"exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type){e=!1,a!==t&&(s<u||s===u&&t in n&&!(a in n))&&(s=u,a=t,i=[]),a===t&&i.push(c.entries[t].expects);break}u++}if(e){const e=c["~run"]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(u(this,new Set([this.key])),r)return r;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:m("success"),transactionID:b()}),v({status:m("failure"),transactionID:b(),errorMessage:b(),errorCode:b()}),v({status:m("pending"),transactionID:b()}),v({status:m("userInitiatedCancel")})]),V=x([j(H),B(400),B(500),B(501)]);class Y 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}),r=this.validate(V,n);return r&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${r}`),n}}const J={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},Q={DEFAULT:"DEFAULT"},X={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},Z=x([j(p()),D,B(400),B(500),B(501)]),ee=x([j(p()),D,B(400),B(500),B(501)]),te=x([j(p()),D,B(500),B(501)]),ne=x([j(p()),D,B(500),B(501)]),re=x([j(p()),D,B(500),B(501)]),se=x([j(p()),D,B(500),B(501)]),oe=x([j(p()),D,B(500),B(501)]),ae=x([j(p()),D,B(500),B(501)]),ie=x([j(p()),D,B(500),B(501)]),ce=x([j(p()),D,B(500),B(501)]),ue=x([j(p()),D,B(400),B(500),B(501)]),de=x([j(p()),B(500),B(501)]),le=v({state:E(b(),u(1)),name:E(b(),u(1)),data:y(k(b(),S()))}),he=x([j(p()),D,B(400),B(500),B(501)]),pe=v({connected:p()}),me=x([j(pe),B(404)]),ge=b(),fe=x([j(ge),D,B(500),B(501)]);class ve extends A{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(Z,t);return n&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${n}`),t}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(ee,t);return n&&this.logger.warn("setTitle",`Unexpected response shape: ${n}`),t}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(te,e);return t&&this.logger.warn("hideBackButton",`Unexpected response shape: ${t}`),e}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(ne,e);return t&&this.logger.warn("showBackButton",`Unexpected response shape: ${t}`),e}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(re,e);return t&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${t}`),e}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(se,e);return t&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${t}`),e}async close(){const e=await this.invoke({method:"close"}),t=this.validate(oe,e);return t&&this.logger.warn("close",`Unexpected response shape: ${t}`),e}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(ae,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(ie,e);return t&&this.logger.warn("showLoader",`Unexpected response shape: ${t}`),e}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ce,e);return t&&this.logger.warn("hideLoader",`Unexpected response shape: ${t}`),e}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(ue,t);return n&&this.logger.warn("openExternalLink",`Unexpected response shape: ${n}`),t}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(de,t);return n&&this.logger.warn("onCtaTap",`Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(le,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}}),r=this.validate(he,n);return r&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${r}`),n}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(fe,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}}const ye=p(),we=x([j(ye),B(500),B(501)]);class ke extends A{constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(we,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}}const be=v({fileUrl:E(b(),d()),fileName:E(b(),u(1))}),_e=x([D,B(400),B(500),B(501)]);class xe extends A{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(be,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),r=this.validate(_e,n);return r&&this.logger.warn("downloadFile",`Unexpected response shape: ${r}`),n}}function Se(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let r=0;r<e;r+=1)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[r]%62);return n}async function Ee(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 Ue(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",$e={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 Ae extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Ie=v({clientId:E(b(),u(1)),redirectUri:E(b(),d()),scope:E(b(),u(1)),environment:w(["staging","production"]),responseMode:y(w(["redirect","in_place"]))}),Me=v({code:b(),state:b()}),Te=x([j(Me),D,z,B(400),B(403),B(500),B(501)]),Oe=v({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Ne=x([j(Oe),D,B(400)]),Pe=x([D]);class Re extends A{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=$e[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 Ae("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 Ae("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof Ae)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=Se(16),t=Se(32),n=(r=Se(64),btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var r;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await Ee(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"),r=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===n&&null===r?{status_code:204}:null!==e&&null!==t&&null!==n&&null!==r?{status_code:200,result:{state:e,codeVerifier:t,nonce:n,redirectUri:r}}:{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&&!Ue(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:U(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},r=Re.buildAuthorizeUrl(t,n);return window.location.assign(r),{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(Te,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(Ie,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),r=e.responseMode||"redirect",s="in_place"===r?Re.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...n,redirectUri:s});const o={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod};if(Re.shouldUseWebConsent(e))return this.performWebAuthorization({...o,environment:e.environment});try{const t=await this.performNativeAuthorization({...o,actualRedirectUri:s,responseMode:r});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 Le=b(),Be=x([j(Le),D,B(400),B(500),B(501)]);class je extends A{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Be,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}}const De=v({latitude:f(),longitude:f()}),ze=x([j(De),B(403),B(424),B(500),B(501)]),Ke=b(),Ge=x([j(Ke),D,B(403),B(424),B(500),B(501)]);class We 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(Ge,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}}const Fe=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()}),qe=x([j(Fe),D,B(400),B(424),B(500),B(501)]),He=x([j(Fe),B(500),B(501)]);class Ve extends A{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(qe,t);return n&&this.logger.warn("playDRMContent",`Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}}const Ye=v({endpoint:b(),method:w(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:y(k(b(),b())),query:y(k(b(),b())),body:y(S()),timeout:y(f())}),Je=k(b(),S()),Qe=x([(Xe=Je,v({status_code:f(),result:Xe})),v({status_code:f(),error:b()})]);var Xe;class Ze extends A{constructor(){super("NetworkModule")}async send(e){const t=this.validate(Ye,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e});if(function(e){return"result"in e&&null!==e.result&&void 0!==e.result}(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result);return{...n,result:e}}catch{return{status_code:500,error:"Failed to parse response result as JSON"}}const r=this.validate(Qe,n);return r&&this.logger.warn("send",`Unexpected response shape: ${r}`),n}}const et=x([D,B(500),B(501)]);class tt extends A{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(et,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}}const nt=v({email:b()}),rt=x([j(nt),D,B(400),B(403),B(426),B(500),B(501)]),st=v({email:y(E(b(),u(1))),skipUserInput:y(p())}),ot=v({email:b()}),at=x([j(ot),D,B(400),B(403),B(426),B(500),B(501)]);class it extends A{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>Ue(e.version,it.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(rt,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>Ue(e.version,it.MINIMUM_VERSION));if(t)return t;const n=this.validate(st,e??{});if(n)return{status_code:400,error:n};const r=await this.invoke({method:"verifyEmail",params:e}),s=this.validate(at,r);return s&&this.logger.warn("verifyEmail",`Unexpected response shape: ${s}`),r}}it.MINIMUM_VERSION={major:5,minor:399,patch:0};const ct=v({module:E(b(),u(1)),method:E(b(),u(1))}),ut=p(),dt=x([j(ut),B(400),B(424),B(500),B(501)]),lt=x([D,B(424),B(500),B(501)]);class ht extends A{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},r=this.validate(ct,n);if(r)return{status_code:400,error:r};const s=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(dt,s);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),s}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(lt,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}}const pt=x([D,B(400),B(403),B(500),B(501)]);class mt extends A{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(pt,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}}const gt=v({key:E(b(),u(1))}),ft=x([D,B(400),B(424),B(500),B(501)]),vt=gt,yt=v({value:g(p())}),wt=x([j(yt),B(400),B(424),B(500),B(501)]),kt=x([D,B(400),B(424),B(500),B(501)]),bt=gt,_t=v({value:g(f())}),xt=x([j(_t),B(400),B(424),B(500),B(501)]),St=x([D,B(400),B(424),B(500),B(501)]),Et=gt,Ut=v({value:g(b())}),Ct=x([j(Ut),B(400),B(424),B(500),B(501)]),$t=x([D,B(400),B(424),B(500),B(501)]),At=gt,It=v({value:g(f())}),Mt=x([j(It),B(400),B(424),B(500),B(501)]),Tt=gt,Ot=x([D,B(400),B(424),B(500),B(501)]),Nt=x([D,B(424),B(500),B(501)]);class Pt extends A{constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),r=this.validate(ft,n);return r&&this.logger.warn("setBoolean",`Unexpected response shape: ${r}`),n}async getBoolean(e){const t={key:e},n=this.validate(vt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getBoolean",params:t}),s=this.validate(wt,r);return s&&this.logger.warn("getBoolean",`Unexpected response shape: ${s}`),r}async setInt(e,t){const n=await this.invoke({method:"setInt",params:{key:e,value:t}}),r=this.validate(kt,n);return r&&this.logger.warn("setInt",`Unexpected response shape: ${r}`),n}async getInt(e){const t={key:e},n=this.validate(bt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getInt",params:t}),s=this.validate(xt,r);return s&&this.logger.warn("getInt",`Unexpected response shape: ${s}`),r}async setString(e,t){const n=await this.invoke({method:"setString",params:{key:e,value:t}}),r=this.validate(St,n);return r&&this.logger.warn("setString",`Unexpected response shape: ${r}`),n}async getString(e){const t={key:e},n=this.validate(Et,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getString",params:t}),s=this.validate(Ct,r);return s&&this.logger.warn("getString",`Unexpected response shape: ${s}`),r}async setDouble(e,t){const n=await this.invoke({method:"setDouble",params:{key:e,value:t}}),r=this.validate($t,n);return r&&this.logger.warn("setDouble",`Unexpected response shape: ${r}`),n}async getDouble(e){const t={key:e},n=this.validate(At,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getDouble",params:t}),s=this.validate(Mt,r);return s&&this.logger.warn("getDouble",`Unexpected response shape: ${s}`),r}async remove(e){const t={key:e},n=this.validate(Tt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"remove",params:t}),s=this.validate(Ot,r);return s&&this.logger.warn("remove",`Unexpected response shape: ${s}`),r}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}}const Rt=v({url:E(b(),d())}),Lt=x([j(b()),B(400),B(424),B(500),B(501)]);class Bt extends A{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(Rt,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),r=this.validate(Lt,n);return r&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${r}`),n}}const jt=b(),Dt=x([j(jt),D,B(500),B(501)]);class zt extends A{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(Dt,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}}export{Ie as AuthorizeRequestSchema,Te as AuthorizeResponseSchema,Me as AuthorizeResultSchema,et as BackResponseSchema,A as BaseModule,F as CameraModule,Y as CheckoutModule,Pe as ClearAuthorizationArtifactsResponseSchema,oe as CloseResponseSchema,X as ContainerAnalyticsEventData,Q as ContainerAnalyticsEventName,J as ContainerAnalyticsEventState,ve as ContainerModule,Fe as DRMPlaybackEventSchema,ke as DeviceModule,pt as DismissSplashScreenResponseSchema,be as DownloadFileRequestSchema,_e as DownloadFileResponseSchema,rt as FetchEmailResponseSchema,nt as FetchEmailResultSchema,xe as FileModule,Ne as GetAuthorizationArtifactsResponseSchema,Oe as GetAuthorizationArtifactsResultSchema,vt as GetBooleanRequestSchema,wt as GetBooleanResponseSchema,yt as GetBooleanResultSchema,ze as GetCoordinateResponseSchema,De as GetCoordinateResultSchema,Ge as GetCountryCodeResponseSchema,Ke as GetCountryCodeResultSchema,At as GetDoubleRequestSchema,Mt as GetDoubleResponseSchema,It as GetDoubleResultSchema,bt as GetIntRequestSchema,xt as GetIntResponseSchema,_t as GetIntResultSchema,Be as GetLanguageLocaleIdentifierResponseSchema,Le as GetLanguageLocaleIdentifierResultSchema,Dt as GetSelectedTravelDestinationResponseSchema,jt as GetSelectedTravelDestinationResultSchema,fe as GetSessionParamsResponseSchema,ge as GetSessionParamsResultSchema,Et as GetStringRequestSchema,Ct as GetStringResponseSchema,Ut as GetStringResultSchema,ct as HasAccessToRequestSchema,dt as HasAccessToResponseSchema,ut as HasAccessToResultSchema,te as HideBackButtonResponseSchema,ce as HideLoaderResponseSchema,re as HideRefreshButtonResponseSchema,Re as IdentityModule,me as IsConnectedResponseSchema,pe as IsConnectedResultSchema,we as IsEsimSupportedResponseSchema,ye as IsEsimSupportedResultSchema,je as LocaleModule,We as LocationModule,C as Logger,Ve as MediaModule,Ze as NetworkModule,He as ObserveDRMPlaybackResponseSchema,ae as OnContentLoadedResponseSchema,de as OnCtaTapResponseSchema,ue as OpenExternalLinkResponseSchema,tt as PlatformModule,qe as PlayDRMContentResponseSchema,it as ProfileModule,Rt as RedirectToSystemWebViewRequestSchema,Lt as RedirectToSystemWebViewResponseSchema,lt as ReloadScopesResponseSchema,Nt as RemoveAllResponseSchema,Ot as RemoveResponseSchema,K as ScanQRCodeRequestSchema,W as ScanQRCodeResponseSchema,G as ScanQRCodeResultSchema,ht as ScopeModule,le as SendAnalyticsEventRequestSchema,he as SendAnalyticsEventResponseSchema,Ye as SendRequestSchema,Qe as SendResponseSchema,Je as SendResultSchema,Z as SetBackgroundColorResponseSchema,ft as SetBooleanResponseSchema,$t as SetDoubleResponseSchema,kt as SetIntResponseSchema,St as SetStringResponseSchema,ee as SetTitleResponseSchema,ne as ShowBackButtonResponseSchema,ie as ShowLoaderResponseSchema,se as ShowRefreshButtonResponseSchema,mt as SplashScreenModule,Pt as StorageModule,Bt as SystemWebViewKitModule,q as TriggerCheckoutRequestSchema,V as TriggerCheckoutResponseSchema,H as TriggerCheckoutResultSchema,zt as UserAttributesModule,st as VerifyEmailRequestSchema,at as VerifyEmailResponseSchema,ot as VerifyEmailResultSchema,P as isClientError,L 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(r,s){try{var o=null,a=!1;o=e({next:function(e){r(null==t?void 0:t(e)),o&&o.unsubscribe(),a=!0}}),a&&o&&o.unsubscribe()}catch(e){null==n?s(e):r(n(e))}})}}}function r(r,s){return s.funcNameToWrap,function(r,s){var o=s.callbackNameFunc,a=s.funcToWrap;return n(function(n){var s,i=o();return r[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 r=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=r.indexOf(e)})}(t.result,"event"))t.result.event===e.StreamEvent.STREAM_TERMINATED&&s.unsubscribe();else{var r=t.result,o=t.error,a=t.status_code;n&&n.next&&n.next({result:null===r?void 0:r,error:null===o?void 0:o,status_code:null===a?void 0:a})}},a(i),s=t(function(){r[i]=void 0,n&&n.complete&&n.complete()})})}(r,function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&(n[r[s]]=e[r[s]])}return n}(s,["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(s,o){return r(e,{funcNameToWrap:s,callbackNameFunc:function(){return function(e,t){var n=t.moduleName,r=t.funcName,s=0;return function(){for(var t,o,a="";(a=(t={moduleName:n,funcName:r,requestID:s}).moduleName+"_"+t.funcName+"Callback"+(null!==(o=t.requestID)?"_"+o:""))in e;)s+=1;return s+=1,a}()}(e,{moduleName:t,funcName:s})},funcToWrap:function(e){return n({callback:e,method:s,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 r(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function s(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,r,o){const a=o&&"input"in o?o.input:n.value,i=o?.expected??e.expects??null,c=o?.received??s(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:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},d="schema"===e.kind,l=o?.message??e.message??(e.reference,void u.lang)??(d?void u.lang:null)??r.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},r())}}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:s(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:"nullable",reference:m,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return a(this)},"~run"(e,t){return null===e.value&&(void 0!==this.default&&(e.value=h(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}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 r in this.entries){const s=this.entries[r];if(r in n||("exact_optional"===s.type||"optional"===s.type||"nullish"===s.type)&&void 0!==s.default){const o=r in n?n[r]:h(s),a=s["~run"]({value:o},t);if(a.issues){const s={type:"object",origin:"value",input:n,key:r,value:o};for(const t of a.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value[r]=a.value}else if(void 0!==s.fallback)e.value[r]=l(s);else if("exact_optional"!==s.type&&"optional"!==s.type&&"nullish"!==s.type&&(o(this,"key",e,t,{input:void 0,expected:`"${r}"`,path:[{type:"object",origin:"key",input:n,key:r,value:n[r]}]}),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(s),"|"),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 r in n)if(i(n,r)){const s=n[r],o=this.key["~run"]({value:r},t);if(o.issues){const a={type:"object",origin:"key",input:n,key:r,value:s};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:s},t);if(a.issues){const o={type:"object",origin:"value",input:n,key:r,value:s};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,r,s;for(const o of this.options){const a=o["~run"]({value:e.value},t);if(a.typed){if(!a.issues){n=a;break}r?r.push(a):r=[a]}else s?s.push(a):s=[a]}if(n)return n;if(r){if(1===r.length)return r[0];o(this,"type",e,t,{issues:_(r)}),e.typed=!0}else{if(1===s?.length)return s[0];o(this,"type",e,t,{issues:_(s)})}return e}}}function S(){return{kind:"schema",type:"unknown",reference:S,expects:"unknown",async:!1,get"~standard"(){return a(this)},"~run":e=>(e.typed=!0,e)}}function E(...e){return{...e[0],pipe:e,get"~standard"(){return a(this)},"~run"(t,n){for(const r of e)if("metadata"!==r.kind){if(t.issues&&("schema"===r.kind||"transformation"===r.kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=r["~run"](t,n))}return t}}}function U(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class ${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),!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${U(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},r(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: ${U(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: ${U(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 L(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0}function B(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}),r=this.validate(F,n);return r&&this.logger.warn("scanQRCode",`Unexpected response shape: ${r}`),n}}const H=k(b(),S()),V=function e(t,n,r){return{kind:"schema",type:"variant",reference:e,expects:"Object",async:!1,key:t,options:n,message:r,get"~standard"(){return a(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){let r,s=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 r=c.entries[t];if(t in n?r["~run"]({typed:!1,value:n[t]},{abortEarly:!0}).issues:"exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type){e=!1,a!==t&&(s<u||s===u&&t in n&&!(a in n))&&(s=u,a=t,i=[]),a===t&&i.push(c.entries[t].expects);break}u++}if(e){const e=c["~run"]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(u(this,new Set([this.key])),r)return r;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}),r=this.validate(Y,n);return r&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${r}`),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([D(p()),z,j(400),j(500),j(501)]),ne=x([D(p()),z,j(500),j(501)]),re=x([D(p()),z,j(500),j(501)]),se=x([D(p()),z,j(500),j(501)]),oe=x([D(p()),z,j(500),j(501)]),ae=x([D(p()),z,j(500),j(501)]),ie=x([D(p()),z,j(500),j(501)]),ce=x([D(p()),z,j(500),j(501)]),ue=x([D(p()),z,j(500),j(501)]),de=x([D(p()),z,j(400),j(500),j(501)]),le=x([D(p()),j(500),j(501)]),he=v({state:E(b(),u(1)),name:E(b(),u(1)),data:y(k(b(),S()))}),pe=x([D(p()),z,j(400),j(500),j(501)]),ge=v({connected:p()}),me=x([D(ge),j(404)]),fe=b(),ve=x([D(fe),z,j(500),j(501)]);class ye extends A{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(ee,t);return n&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${n}`),t}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(te,t);return n&&this.logger.warn("setTitle",`Unexpected response shape: ${n}`),t}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(ne,e);return t&&this.logger.warn("hideBackButton",`Unexpected response shape: ${t}`),e}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(re,e);return t&&this.logger.warn("showBackButton",`Unexpected response shape: ${t}`),e}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(se,e);return t&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${t}`),e}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(oe,e);return t&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${t}`),e}async close(){const e=await this.invoke({method:"close"}),t=this.validate(ae,e);return t&&this.logger.warn("close",`Unexpected response shape: ${t}`),e}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(ie,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(ce,e);return t&&this.logger.warn("showLoader",`Unexpected response shape: ${t}`),e}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ue,e);return t&&this.logger.warn("hideLoader",`Unexpected response shape: ${t}`),e}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(de,t);return n&&this.logger.warn("openExternalLink",`Unexpected response shape: ${n}`),t}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(le,t);return n&&this.logger.warn("onCtaTap",`Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(he,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}}),r=this.validate(pe,n);return r&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${r}`),n}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(ve,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}}const we=p(),ke=x([D(we),j(500),j(501)]);class be extends A{constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(ke,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}}const _e=v({fileUrl:E(b(),d()),fileName:E(b(),u(1))}),xe=x([z,j(400),j(500),j(501)]);class Se extends A{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(_e,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),r=this.validate(xe,n);return r&&this.logger.warn("downloadFile",`Unexpected response shape: ${r}`),n}}function Ee(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let r=0;r<e;r+=1)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[r]%62);return n}async function Ue(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 $e(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",Ae={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 Ie extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Me=v({clientId:E(b(),u(1)),redirectUri:E(b(),d()),scope:E(b(),u(1)),environment:w(["staging","production"]),responseMode:y(w(["redirect","in_place"]))}),Te=v({code:b(),state:b()}),Oe=x([D(Te),z,K,j(400),j(403),j(500),j(501)]),Ne=v({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Pe=x([D(Ne),z,j(400)]),Re=x([z]);class Le extends A{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=Ae[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 Ie("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 Ie("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof Ie)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=Ee(16),t=Ee(32),n=(r=Ee(64),btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var r;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await Ue(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"),r=this.getStorageItem("redirect_uri");return null===e&&null===t&&null===n&&null===r?{status_code:204}:null!==e&&null!==t&&null!==n&&null!==r?{status_code:200,result:{state:e,codeVerifier:t,nonce:n,redirectUri:r}}:{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=C();return!t||"staging"!==e.environment&&!$e(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:U(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},r=Le.buildAuthorizeUrl(t,n);return window.location.assign(r),{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(Oe,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(Me,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),r=e.responseMode||"redirect",s="in_place"===r?Le.normalizeUrl(window.location.href):e.redirectUri;this.storePKCEArtifacts({...n,redirectUri:s});const o={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope,nonce:n.nonce,state:n.state,codeChallenge:n.codeChallenge,codeChallengeMethod:n.codeChallengeMethod};if(Le.shouldUseWebConsent(e))return this.performWebAuthorization({...o,environment:e.environment});try{const t=await this.performNativeAuthorization({...o,actualRedirectUri:s,responseMode:r});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 Be=b(),je=x([D(Be),z,j(400),j(500),j(501)]);class De 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 ze=v({latitude:f(),longitude:f()}),Ke=x([D(ze),j(403),j(424),j(500),j(501)]),Ge=b(),We=x([D(Ge),z,j(403),j(424),j(500),j(501)]);class Fe extends A{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(Ke,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(We,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}}const qe=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()}),He=x([D(qe),z,j(400),j(424),j(500),j(501)]),Ve=x([D(qe),j(500),j(501)]);class Ye extends A{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(He,t);return n&&this.logger.warn("playDRMContent",`Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}}const Je=v({endpoint:b(),method:w(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:y(k(b(),b())),query:y(k(b(),b())),body:y(S()),timeout:y(f())}),Qe=k(b(),S()),Xe=x([D(Qe),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]),Ze=x([b(),Qe]),et=x([D(Ze),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]);class tt extends A{constructor(){super("NetworkModule")}async send(e){const t=this.validate(Je,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e}),r=this.validate(et,n);if(r&&this.logger.warn("send",`Unexpected raw response shape: ${r}`),I(n)&&B(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result),t={...n,result:e},r=this.validate(Xe,t);return r&&this.logger.warn("send",`Unexpected response shape after parsing: ${r}`),t}catch{return{status_code:500,error:"Failed to parse response result as JSON"}}const s=n,o=this.validate(Xe,s);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),s}}const nt=x([z,j(500),j(501)]);class rt extends A{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(nt,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}}const st=v({email:b()}),ot=x([D(st),z,j(400),j(403),j(426),j(500),j(501)]),at=v({email:y(E(b(),u(1))),skipUserInput:y(p())}),it=v({email:b()}),ct=x([D(it),z,j(400),j(403),j(426),j(500),j(501)]);class ut extends A{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>$e(e.version,ut.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(ot,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>$e(e.version,ut.MINIMUM_VERSION));if(t)return t;const n=this.validate(at,e??{});if(n)return{status_code:400,error:n};const r=await this.invoke({method:"verifyEmail",params:e}),s=this.validate(ct,r);return s&&this.logger.warn("verifyEmail",`Unexpected response shape: ${s}`),r}}ut.MINIMUM_VERSION={major:5,minor:399,patch:0};const dt=v({module:E(b(),u(1)),method:E(b(),u(1))}),lt=p(),ht=x([D(lt),j(400),j(424),j(500),j(501)]),pt=x([z,j(424),j(500),j(501)]);class gt extends A{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},r=this.validate(dt,n);if(r)return{status_code:400,error:r};const s=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(ht,s);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),s}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(pt,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}}const mt=x([z,j(400),j(403),j(500),j(501)]);class ft extends A{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(mt,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}}const vt=v({key:E(b(),u(1))}),yt=x([z,j(400),j(424),j(500),j(501)]),wt=vt,kt=v({value:m(p())}),bt=x([D(kt),j(400),j(424),j(500),j(501)]),_t=x([z,j(400),j(424),j(500),j(501)]),xt=vt,St=v({value:m(f())}),Et=x([D(St),j(400),j(424),j(500),j(501)]),Ut=x([z,j(400),j(424),j(500),j(501)]),$t=vt,Ct=v({value:m(b())}),At=x([D(Ct),j(400),j(424),j(500),j(501)]),It=x([z,j(400),j(424),j(500),j(501)]),Mt=vt,Tt=v({value:m(f())}),Ot=x([D(Tt),j(400),j(424),j(500),j(501)]),Nt=vt,Pt=x([z,j(400),j(424),j(500),j(501)]),Rt=x([z,j(424),j(500),j(501)]);class Lt extends A{constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),r=this.validate(yt,n);return r&&this.logger.warn("setBoolean",`Unexpected response shape: ${r}`),n}async getBoolean(e){const t={key:e},n=this.validate(wt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getBoolean",params:t}),s=this.validate(bt,r);return s&&this.logger.warn("getBoolean",`Unexpected response shape: ${s}`),r}async setInt(e,t){const n=await this.invoke({method:"setInt",params:{key:e,value:t}}),r=this.validate(_t,n);return r&&this.logger.warn("setInt",`Unexpected response shape: ${r}`),n}async getInt(e){const t={key:e},n=this.validate(xt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getInt",params:t}),s=this.validate(Et,r);return s&&this.logger.warn("getInt",`Unexpected response shape: ${s}`),r}async setString(e,t){const n=await this.invoke({method:"setString",params:{key:e,value:t}}),r=this.validate(Ut,n);return r&&this.logger.warn("setString",`Unexpected response shape: ${r}`),n}async getString(e){const t={key:e},n=this.validate($t,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getString",params:t}),s=this.validate(At,r);return s&&this.logger.warn("getString",`Unexpected response shape: ${s}`),r}async setDouble(e,t){const n=await this.invoke({method:"setDouble",params:{key:e,value:t}}),r=this.validate(It,n);return r&&this.logger.warn("setDouble",`Unexpected response shape: ${r}`),n}async getDouble(e){const t={key:e},n=this.validate(Mt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getDouble",params:t}),s=this.validate(Ot,r);return s&&this.logger.warn("getDouble",`Unexpected response shape: ${s}`),r}async remove(e){const t={key:e},n=this.validate(Nt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"remove",params:t}),s=this.validate(Pt,r);return s&&this.logger.warn("remove",`Unexpected response shape: ${s}`),r}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(Rt,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}}const Bt=v({url:E(b(),d())}),jt=x([D(b()),j(400),j(424),j(500),j(501)]);class Dt extends A{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(Bt,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),r=this.validate(jt,n);return r&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${r}`),n}}const zt=b(),Kt=x([D(zt),z,j(500),j(501)]);class Gt extends A{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(Kt,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}}export{Me as AuthorizeRequestSchema,Oe as AuthorizeResponseSchema,Te as AuthorizeResultSchema,nt as BackResponseSchema,A as BaseModule,q as CameraModule,J as CheckoutModule,Re as ClearAuthorizationArtifactsResponseSchema,ae as CloseResponseSchema,Z as ContainerAnalyticsEventData,X as ContainerAnalyticsEventName,Q as ContainerAnalyticsEventState,ye as ContainerModule,qe as DRMPlaybackEventSchema,be as DeviceModule,mt as DismissSplashScreenResponseSchema,_e as DownloadFileRequestSchema,xe as DownloadFileResponseSchema,ot as FetchEmailResponseSchema,st as FetchEmailResultSchema,Se as FileModule,Pe as GetAuthorizationArtifactsResponseSchema,Ne as GetAuthorizationArtifactsResultSchema,wt as GetBooleanRequestSchema,bt as GetBooleanResponseSchema,kt as GetBooleanResultSchema,Ke as GetCoordinateResponseSchema,ze as GetCoordinateResultSchema,We as GetCountryCodeResponseSchema,Ge as GetCountryCodeResultSchema,Mt as GetDoubleRequestSchema,Ot as GetDoubleResponseSchema,Tt as GetDoubleResultSchema,xt as GetIntRequestSchema,Et as GetIntResponseSchema,St as GetIntResultSchema,je as GetLanguageLocaleIdentifierResponseSchema,Be as GetLanguageLocaleIdentifierResultSchema,Kt as GetSelectedTravelDestinationResponseSchema,zt as GetSelectedTravelDestinationResultSchema,ve as GetSessionParamsResponseSchema,fe as GetSessionParamsResultSchema,$t as GetStringRequestSchema,At as GetStringResponseSchema,Ct as GetStringResultSchema,dt as HasAccessToRequestSchema,ht as HasAccessToResponseSchema,lt as HasAccessToResultSchema,ne as HideBackButtonResponseSchema,ue as HideLoaderResponseSchema,se as HideRefreshButtonResponseSchema,Le as IdentityModule,me as IsConnectedResponseSchema,ge as IsConnectedResultSchema,ke as IsEsimSupportedResponseSchema,we as IsEsimSupportedResultSchema,De as LocaleModule,Fe as LocationModule,$ as Logger,Ye as MediaModule,tt as NetworkModule,Ve as ObserveDRMPlaybackResponseSchema,ie as OnContentLoadedResponseSchema,le as OnCtaTapResponseSchema,de as OpenExternalLinkResponseSchema,rt as PlatformModule,He as PlayDRMContentResponseSchema,ut as ProfileModule,Bt as RedirectToSystemWebViewRequestSchema,jt as RedirectToSystemWebViewResponseSchema,pt as ReloadScopesResponseSchema,Rt as RemoveAllResponseSchema,Pt as RemoveResponseSchema,G as ScanQRCodeRequestSchema,F as ScanQRCodeResponseSchema,W as ScanQRCodeResultSchema,gt as ScopeModule,he as SendAnalyticsEventRequestSchema,pe as SendAnalyticsEventResponseSchema,Je as SendRequestSchema,Xe as SendResponseSchema,Qe as SendResultSchema,ee as SetBackgroundColorResponseSchema,yt as SetBooleanResponseSchema,It as SetDoubleResponseSchema,_t as SetIntResponseSchema,Ut as SetStringResponseSchema,te as SetTitleResponseSchema,re as ShowBackButtonResponseSchema,ce as ShowLoaderResponseSchema,oe as ShowRefreshButtonResponseSchema,ft as SplashScreenModule,Lt as StorageModule,Dt as SystemWebViewKitModule,H as TriggerCheckoutRequestSchema,Y as TriggerCheckoutResponseSchema,V as TriggerCheckoutResultSchema,Gt as UserAttributesModule,at as VerifyEmailRequestSchema,ct as VerifyEmailResponseSchema,it as VerifyEmailResultSchema,B as hasResult,P as isClientError,L as isError,N as isFound,T as isNoContent,M as isOk,O 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,n={exports:{}},s=(t||(t=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})}(n.exports)),n.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,n,s,r){const a=r&&"input"in r?r.input:n.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:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},l="schema"===e.kind,d=r?.message??e.message??(e.reference,void u.lang)??(l?void u.lang:null)??s.message??void u.lang;void 0!==d&&(u.message="function"==typeof d?d(u):d),l&&(n.typed=!1),n.issues?n.issues.push(u):n.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 n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[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,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function p(e,t,n){return"function"==typeof e.default?e.default(t,n):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:"nullable",reference:f,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return null===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}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 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]:p(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]=h(r);else if("exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type&&(a(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 a(this,"type",e,t);return e}}}function S(e,t){return{kind:"schema",type:"optional",reference:S,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 w(e,t){return{kind:"schema",type:"picklist",reference:w,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,n){return{kind:"schema",type:"record",reference:k,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return i(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in n)if(c(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 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 n of e)t?t.push(...n.issues):t=n.issues;return t}function C(e,t){return{kind:"schema",type:"union",reference:C,expects:u(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return i(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];a(this,"type",e,t,{issues:R(s)}),e.typed=!0}else{if(1===r?.length)return r[0];a(this,"type",e,t,{issues:R(r)})}return e}}}function _(){return{kind:"schema",type:"unknown",reference:_,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,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 x(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class A{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 U(){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 M{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new A(e),!this.wrappedModule)try{s.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${x(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},r(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=U();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 U()?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: ${x(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 U()?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: ${x(e)?e.message:"Unknown error"}`})}}}const $=e=>y({status_code:g(e),error:b()}),I=e=>y({status_code:g(200),result:e}),T=y({status_code:g(204)}),O=y({status_code:g(302)}),N=y({title:S(b())}),P=y({qrCode:b()}),B=C([I(P),T,$(400),$(403),$(500),$(501)]),L=k(b(),_()),D=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 i(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){let s,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 s=u.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,o!==t&&(r<c||r===c&&t in n&&!(o in n))&&(r=c,o=t,i=[]),o===t&&i.push(u.entries[t].expects);break}c++}if(e){const e=u["~run"]({value:n},t);(!s||!s.typed&&e.typed)&&(s=e)}}if(s&&!s.issues)break}};if(c(this,new Set([this.key])),s)return s;a(this,"type",e,t,{input:n[o],expected:u(i,"|"),path:[{type:"object",origin:"value",input:n,key:o,value:n[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")})]),G=C([I(D),$(400),$(500),$(501)]),j=C([I(m()),T,$(400),$(500),$(501)]),z=C([I(m()),T,$(400),$(500),$(501)]),q=C([I(m()),T,$(500),$(501)]),F=C([I(m()),T,$(500),$(501)]),K=C([I(m()),T,$(500),$(501)]),W=C([I(m()),T,$(500),$(501)]),H=C([I(m()),T,$(500),$(501)]),V=C([I(m()),T,$(500),$(501)]),Y=C([I(m()),T,$(500),$(501)]),Q=C([I(m()),T,$(500),$(501)]),J=C([I(m()),T,$(400),$(500),$(501)]),X=C([I(m()),$(500),$(501)]),Z=y({state:E(b(),l(1)),name:E(b(),l(1)),data:S(k(b(),_()))}),ee=C([I(m()),T,$(400),$(500),$(501)]),te=y({connected:m()}),ne=C([I(te),$(404)]),se=b(),re=C([I(se),T,$(500),$(501)]),oe=m(),ae=C([I(oe),$(500),$(501)]),ie=y({fileUrl:E(b(),d()),fileName:E(b(),l(1))}),ce=C([T,$(400),$(500),$(501)]);function ue(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))}function de(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const he="grabid",pe={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 me extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const ge=y({clientId:E(b(),l(1)),redirectUri:E(b(),d()),scope:E(b(),l(1)),environment:w(["staging","production"]),responseMode:S(w(["redirect","in_place"]))}),fe=y({code:b(),state:b()}),ve=C([I(fe),T,O,$(400),$(403),$(500),$(501)]),ye=y({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Se=C([I(ye),T,$(400)]),we=C([T]);class ke extends M{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=pe[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 me("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 me("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof me)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=ue(16),t=ue(32),n=(s=ue(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(`${he}:nonce`),window.localStorage.removeItem(`${he}:state`),window.localStorage.removeItem(`${he}:code_verifier`),window.localStorage.removeItem(`${he}:redirect_uri`),window.localStorage.removeItem(`${he}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${he}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${he}:${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=U();return!t||"staging"!==e.environment&&!de(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:x(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=ke.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(ve,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(ge,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),s=e.responseMode||"redirect",r="in_place"===s?ke.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(ke.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 be=b(),Re=C([I(be),T,$(400),$(500),$(501)]),Ce=y({latitude:v(),longitude:v()}),_e=C([I(Ce),$(403),$(424),$(500),$(501)]),Ee=b(),xe=C([I(Ee),T,$(403),$(424),$(500),$(501)]),Ae=y({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:v(),length:v()}),Ue=C([I(Ae),T,$(400),$(424),$(500),$(501)]),Me=C([I(Ae),$(500),$(501)]),$e=y({endpoint:b(),method:w(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:S(k(b(),b())),query:S(k(b(),b())),body:S(_()),timeout:S(v())}),Ie=k(b(),_()),Te=C([(Oe=Ie,y({status_code:v(),result:Oe})),y({status_code:v(),error:b()})]);var Oe;const Ne=C([T,$(500),$(501)]),Pe=y({email:b()}),Be=C([I(Pe),T,$(400),$(403),$(426),$(500),$(501)]),Le=y({email:S(E(b(),l(1))),skipUserInput:S(m())}),De=y({email:b()}),Ge=C([I(De),T,$(400),$(403),$(426),$(500),$(501)]);class je extends M{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>de(e.version,je.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(Be,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>de(e.version,je.MINIMUM_VERSION));if(t)return t;const n=this.validate(Le,e??{});if(n)return{status_code:400,error:n};const s=await this.invoke({method:"verifyEmail",params:e}),r=this.validate(Ge,s);return r&&this.logger.warn("verifyEmail",`Unexpected response shape: ${r}`),s}}je.MINIMUM_VERSION={major:5,minor:399,patch:0};const ze=y({module:E(b(),l(1)),method:E(b(),l(1))}),qe=m(),Fe=C([I(qe),$(400),$(424),$(500),$(501)]),Ke=C([T,$(424),$(500),$(501)]),We=C([T,$(400),$(403),$(500),$(501)]),He=y({key:E(b(),l(1))}),Ve=C([T,$(400),$(424),$(500),$(501)]),Ye=He,Qe=y({value:f(m())}),Je=C([I(Qe),$(400),$(424),$(500),$(501)]),Xe=C([T,$(400),$(424),$(500),$(501)]),Ze=He,et=y({value:f(v())}),tt=C([I(et),$(400),$(424),$(500),$(501)]),nt=C([T,$(400),$(424),$(500),$(501)]),st=He,rt=y({value:f(b())}),ot=C([I(rt),$(400),$(424),$(500),$(501)]),at=C([T,$(400),$(424),$(500),$(501)]),it=He,ct=y({value:f(v())}),ut=C([I(ct),$(400),$(424),$(500),$(501)]),lt=He,dt=C([T,$(400),$(424),$(500),$(501)]),ht=C([T,$(424),$(500),$(501)]),pt=y({url:E(b(),d())}),mt=C([I(b()),$(400),$(424),$(500),$(501)]),gt=b(),ft=C([I(gt),T,$(500),$(501)]);e.AuthorizeRequestSchema=ge,e.AuthorizeResponseSchema=ve,e.AuthorizeResultSchema=fe,e.BackResponseSchema=Ne,e.BaseModule=M,e.CameraModule=class extends M{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(N,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),s=this.validate(B,n);return s&&this.logger.warn("scanQRCode",`Unexpected response shape: ${s}`),n}},e.CheckoutModule=class extends M{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(L,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"triggerCheckout",params:e}),s=this.validate(G,n);return s&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${s}`),n}},e.ClearAuthorizationArtifactsResponseSchema=we,e.CloseResponseSchema=H,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 M{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(j,t);return n&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${n}`),t}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(z,t);return n&&this.logger.warn("setTitle",`Unexpected response shape: ${n}`),t}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(q,e);return t&&this.logger.warn("hideBackButton",`Unexpected response shape: ${t}`),e}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(F,e);return t&&this.logger.warn("showBackButton",`Unexpected response shape: ${t}`),e}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(K,e);return t&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${t}`),e}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(W,e);return t&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${t}`),e}async close(){const e=await this.invoke({method:"close"}),t=this.validate(H,e);return t&&this.logger.warn("close",`Unexpected response shape: ${t}`),e}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(V,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(Y,e);return t&&this.logger.warn("showLoader",`Unexpected response shape: ${t}`),e}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(Q,e);return t&&this.logger.warn("hideLoader",`Unexpected response shape: ${t}`),e}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(J,t);return n&&this.logger.warn("openExternalLink",`Unexpected response shape: ${n}`),t}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(X,t);return n&&this.logger.warn("onCtaTap",`Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(Z,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(ee,n);return s&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${s}`),n}async isConnected(){return null!==U()?{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(re,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}},e.DRMPlaybackEventSchema=Ae,e.DeviceModule=class extends M{constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(ae,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}},e.DismissSplashScreenResponseSchema=We,e.DownloadFileRequestSchema=ie,e.DownloadFileResponseSchema=ce,e.FetchEmailResponseSchema=Be,e.FetchEmailResultSchema=Pe,e.FileModule=class extends M{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(ie,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),s=this.validate(ce,n);return s&&this.logger.warn("downloadFile",`Unexpected response shape: ${s}`),n}},e.GetAuthorizationArtifactsResponseSchema=Se,e.GetAuthorizationArtifactsResultSchema=ye,e.GetBooleanRequestSchema=Ye,e.GetBooleanResponseSchema=Je,e.GetBooleanResultSchema=Qe,e.GetCoordinateResponseSchema=_e,e.GetCoordinateResultSchema=Ce,e.GetCountryCodeResponseSchema=xe,e.GetCountryCodeResultSchema=Ee,e.GetDoubleRequestSchema=it,e.GetDoubleResponseSchema=ut,e.GetDoubleResultSchema=ct,e.GetIntRequestSchema=Ze,e.GetIntResponseSchema=tt,e.GetIntResultSchema=et,e.GetLanguageLocaleIdentifierResponseSchema=Re,e.GetLanguageLocaleIdentifierResultSchema=be,e.GetSelectedTravelDestinationResponseSchema=ft,e.GetSelectedTravelDestinationResultSchema=gt,e.GetSessionParamsResponseSchema=re,e.GetSessionParamsResultSchema=se,e.GetStringRequestSchema=st,e.GetStringResponseSchema=ot,e.GetStringResultSchema=rt,e.HasAccessToRequestSchema=ze,e.HasAccessToResponseSchema=Fe,e.HasAccessToResultSchema=qe,e.HideBackButtonResponseSchema=q,e.HideLoaderResponseSchema=Q,e.HideRefreshButtonResponseSchema=K,e.IdentityModule=ke,e.IsConnectedResponseSchema=ne,e.IsConnectedResultSchema=te,e.IsEsimSupportedResponseSchema=ae,e.IsEsimSupportedResultSchema=oe,e.LocaleModule=class extends M{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Re,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}},e.LocationModule=class extends M{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(_e,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(xe,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}},e.Logger=A,e.MediaModule=class extends M{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(Ue,t);return n&&this.logger.warn("playDRMContent",`Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}},e.NetworkModule=class extends M{constructor(){super("NetworkModule")}async send(e){const t=this.validate($e,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e});if(function(e){return"result"in e&&null!==e.result&&void 0!==e.result}(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result);return{...n,result:e}}catch{return{status_code:500,error:"Failed to parse response result as JSON"}}const s=this.validate(Te,n);return s&&this.logger.warn("send",`Unexpected response shape: ${s}`),n}},e.ObserveDRMPlaybackResponseSchema=Me,e.OnContentLoadedResponseSchema=V,e.OnCtaTapResponseSchema=X,e.OpenExternalLinkResponseSchema=J,e.PlatformModule=class extends M{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(Ne,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}},e.PlayDRMContentResponseSchema=Ue,e.ProfileModule=je,e.RedirectToSystemWebViewRequestSchema=pt,e.RedirectToSystemWebViewResponseSchema=mt,e.ReloadScopesResponseSchema=Ke,e.RemoveAllResponseSchema=ht,e.RemoveResponseSchema=dt,e.ScanQRCodeRequestSchema=N,e.ScanQRCodeResponseSchema=B,e.ScanQRCodeResultSchema=P,e.ScopeModule=class extends M{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},s=this.validate(ze,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(Fe,r);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),r}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(Ke,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}},e.SendAnalyticsEventRequestSchema=Z,e.SendAnalyticsEventResponseSchema=ee,e.SendRequestSchema=$e,e.SendResponseSchema=Te,e.SendResultSchema=Ie,e.SetBackgroundColorResponseSchema=j,e.SetBooleanResponseSchema=Ve,e.SetDoubleResponseSchema=at,e.SetIntResponseSchema=Xe,e.SetStringResponseSchema=nt,e.SetTitleResponseSchema=z,e.ShowBackButtonResponseSchema=F,e.ShowLoaderResponseSchema=Y,e.ShowRefreshButtonResponseSchema=W,e.SplashScreenModule=class extends M{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(We,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}},e.StorageModule=class extends M{constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),s=this.validate(Ve,n);return s&&this.logger.warn("setBoolean",`Unexpected response shape: ${s}`),n}async getBoolean(e){const t={key:e},n=this.validate(Ye,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getBoolean",params:t}),r=this.validate(Je,s);return r&&this.logger.warn("getBoolean",`Unexpected response shape: ${r}`),s}async setInt(e,t){const n=await this.invoke({method:"setInt",params:{key:e,value:t}}),s=this.validate(Xe,n);return s&&this.logger.warn("setInt",`Unexpected response shape: ${s}`),n}async getInt(e){const t={key:e},n=this.validate(Ze,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getInt",params:t}),r=this.validate(tt,s);return r&&this.logger.warn("getInt",`Unexpected response shape: ${r}`),s}async setString(e,t){const n=await this.invoke({method:"setString",params:{key:e,value:t}}),s=this.validate(nt,n);return s&&this.logger.warn("setString",`Unexpected response shape: ${s}`),n}async getString(e){const t={key:e},n=this.validate(st,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getString",params:t}),r=this.validate(ot,s);return r&&this.logger.warn("getString",`Unexpected response shape: ${r}`),s}async setDouble(e,t){const n=await this.invoke({method:"setDouble",params:{key:e,value:t}}),s=this.validate(at,n);return s&&this.logger.warn("setDouble",`Unexpected response shape: ${s}`),n}async getDouble(e){const t={key:e},n=this.validate(it,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getDouble",params:t}),r=this.validate(ut,s);return r&&this.logger.warn("getDouble",`Unexpected response shape: ${r}`),s}async remove(e){const t={key:e},n=this.validate(lt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"remove",params:t}),r=this.validate(dt,s);return r&&this.logger.warn("remove",`Unexpected response shape: ${r}`),s}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(ht,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}},e.SystemWebViewKitModule=class extends M{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(pt,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),s=this.validate(mt,n);return s&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${s}`),n}},e.TriggerCheckoutRequestSchema=L,e.TriggerCheckoutResponseSchema=G,e.TriggerCheckoutResultSchema=D,e.UserAttributesModule=class extends M{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(ft,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}},e.VerifyEmailRequestSchema=Le,e.VerifyEmailResponseSchema=Ge,e.VerifyEmailResultSchema=De,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=function(e){return 200===e.status_code},e.isRedirection=function(e){return 302===e.status_code},e.isServerError=function(e){return e.status_code>=500&&e.status_code<600},e.isSuccess=function(e){return e.status_code>=200&&e.status_code<300}});
|
|
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,n={exports:{}},s=(t||(t=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})}(n.exports)),n.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,n,s,r){const a=r&&"input"in r?r.input:n.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:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},l="schema"===e.kind,d=r?.message??e.message??(e.reference,void u.lang)??(l?void u.lang:null)??s.message??void u.lang;void 0!==d&&(u.message="function"==typeof d?d(u):d),l&&(n.typed=!1),n.issues?n.issues.push(u):n.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 n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[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,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function p(e,t,n){return"function"==typeof e.default?e.default(t,n):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:"nullable",reference:f,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return null===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}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 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]:p(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]=h(r);else if("exact_optional"!==r.type&&"optional"!==r.type&&"nullish"!==r.type&&(a(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 a(this,"type",e,t);return e}}}function S(e,t){return{kind:"schema",type:"optional",reference:S,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 w(e,t){return{kind:"schema",type:"picklist",reference:w,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,n){return{kind:"schema",type:"record",reference:k,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return i(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const s in n)if(c(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 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 n of e)t?t.push(...n.issues):t=n.issues;return t}function C(e,t){return{kind:"schema",type:"union",reference:C,expects:u(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return i(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];a(this,"type",e,t,{issues:R(s)}),e.typed=!0}else{if(1===r?.length)return r[0];a(this,"type",e,t,{issues:R(r)})}return e}}}function E(){return{kind:"schema",type:"unknown",reference:E,expects:"unknown",async:!1,get"~standard"(){return i(this)},"~run":e=>(e.typed=!0,e)}}function _(...e){return{...e[0],pipe:e,get"~standard"(){return i(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 x(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class A{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 U(){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 M{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new A(e),!this.wrappedModule)try{s.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${x(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},r(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=U();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 U()?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: ${x(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 U()?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: ${x(e)?e.message:"Unknown error"}`})}}}function $(e){return e.status_code>=200&&e.status_code<300}function I(e){return"result"in e&&null!==e.result&&void 0!==e.result}const T=e=>y({status_code:g(e),error:b()}),O=e=>y({status_code:g(200),result:e}),N=y({status_code:g(204)}),P=y({status_code:g(302)}),B=y({title:S(b())}),L=y({qrCode:b()}),D=C([O(L),N,T(400),T(403),T(500),T(501)]),G=k(b(),E()),j=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 i(this)},"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){let s,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 s=u.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,o!==t&&(r<c||r===c&&t in n&&!(o in n))&&(r=c,o=t,i=[]),o===t&&i.push(u.entries[t].expects);break}c++}if(e){const e=u["~run"]({value:n},t);(!s||!s.typed&&e.typed)&&(s=e)}}if(s&&!s.issues)break}};if(c(this,new Set([this.key])),s)return s;a(this,"type",e,t,{input:n[o],expected:u(i,"|"),path:[{type:"object",origin:"value",input:n,key:o,value:n[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")})]),z=C([O(j),T(400),T(500),T(501)]),q=C([O(m()),N,T(400),T(500),T(501)]),F=C([O(m()),N,T(400),T(500),T(501)]),K=C([O(m()),N,T(500),T(501)]),W=C([O(m()),N,T(500),T(501)]),H=C([O(m()),N,T(500),T(501)]),V=C([O(m()),N,T(500),T(501)]),Y=C([O(m()),N,T(500),T(501)]),Q=C([O(m()),N,T(500),T(501)]),J=C([O(m()),N,T(500),T(501)]),X=C([O(m()),N,T(500),T(501)]),Z=C([O(m()),N,T(400),T(500),T(501)]),ee=C([O(m()),T(500),T(501)]),te=y({state:_(b(),l(1)),name:_(b(),l(1)),data:S(k(b(),E()))}),ne=C([O(m()),N,T(400),T(500),T(501)]),se=y({connected:m()}),re=C([O(se),T(404)]),oe=b(),ae=C([O(oe),N,T(500),T(501)]),ie=m(),ce=C([O(ie),T(500),T(501)]),ue=y({fileUrl:_(b(),d()),fileName:_(b(),l(1))}),le=C([N,T(400),T(500),T(501)]);function de(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 he(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 pe(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="grabid",ge={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 fe extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const ve=y({clientId:_(b(),l(1)),redirectUri:_(b(),d()),scope:_(b(),l(1)),environment:w(["staging","production"]),responseMode:S(w(["redirect","in_place"]))}),ye=y({code:b(),state:b()}),Se=C([O(ye),N,P,T(400),T(403),T(500),T(501)]),we=y({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),ke=C([O(we),N,T(400)]),be=C([N]);class Re extends M{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=ge[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 fe("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 fe("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof fe)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=de(16),t=de(32),n=(s=de(64),btoa(s).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var s;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await he(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(`${me}:nonce`),window.localStorage.removeItem(`${me}:state`),window.localStorage.removeItem(`${me}:code_verifier`),window.localStorage.removeItem(`${me}:redirect_uri`),window.localStorage.removeItem(`${me}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${me}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${me}:${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=U();return!t||"staging"!==e.environment&&!pe(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:x(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=Re.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(Se,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(ve,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),s=e.responseMode||"redirect",r="in_place"===s?Re.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(Re.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 Ce=b(),Ee=C([O(Ce),N,T(400),T(500),T(501)]),_e=y({latitude:v(),longitude:v()}),xe=C([O(_e),T(403),T(424),T(500),T(501)]),Ae=b(),Ue=C([O(Ae),N,T(403),T(424),T(500),T(501)]),Me=y({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:v(),length:v()}),$e=C([O(Me),N,T(400),T(424),T(500),T(501)]),Ie=C([O(Me),T(500),T(501)]),Te=y({endpoint:b(),method:w(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:S(k(b(),b())),query:S(k(b(),b())),body:S(E()),timeout:S(v())}),Oe=k(b(),E()),Ne=C([O(Oe),N,T(400),T(401),T(403),T(404),T(424),T(426),T(500),T(501)]),Pe=C([b(),Oe]),Be=C([O(Pe),N,T(400),T(401),T(403),T(404),T(424),T(426),T(500),T(501)]),Le=C([N,T(500),T(501)]),De=y({email:b()}),Ge=C([O(De),N,T(400),T(403),T(426),T(500),T(501)]),je=y({email:S(_(b(),l(1))),skipUserInput:S(m())}),ze=y({email:b()}),qe=C([O(ze),N,T(400),T(403),T(426),T(500),T(501)]);class Fe extends M{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>pe(e.version,Fe.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(Ge,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>pe(e.version,Fe.MINIMUM_VERSION));if(t)return t;const n=this.validate(je,e??{});if(n)return{status_code:400,error:n};const s=await this.invoke({method:"verifyEmail",params:e}),r=this.validate(qe,s);return r&&this.logger.warn("verifyEmail",`Unexpected response shape: ${r}`),s}}Fe.MINIMUM_VERSION={major:5,minor:399,patch:0};const Ke=y({module:_(b(),l(1)),method:_(b(),l(1))}),We=m(),He=C([O(We),T(400),T(424),T(500),T(501)]),Ve=C([N,T(424),T(500),T(501)]),Ye=C([N,T(400),T(403),T(500),T(501)]),Qe=y({key:_(b(),l(1))}),Je=C([N,T(400),T(424),T(500),T(501)]),Xe=Qe,Ze=y({value:f(m())}),et=C([O(Ze),T(400),T(424),T(500),T(501)]),tt=C([N,T(400),T(424),T(500),T(501)]),nt=Qe,st=y({value:f(v())}),rt=C([O(st),T(400),T(424),T(500),T(501)]),ot=C([N,T(400),T(424),T(500),T(501)]),at=Qe,it=y({value:f(b())}),ct=C([O(it),T(400),T(424),T(500),T(501)]),ut=C([N,T(400),T(424),T(500),T(501)]),lt=Qe,dt=y({value:f(v())}),ht=C([O(dt),T(400),T(424),T(500),T(501)]),pt=Qe,mt=C([N,T(400),T(424),T(500),T(501)]),gt=C([N,T(424),T(500),T(501)]),ft=y({url:_(b(),d())}),vt=C([O(b()),T(400),T(424),T(500),T(501)]),yt=b(),St=C([O(yt),N,T(500),T(501)]);e.AuthorizeRequestSchema=ve,e.AuthorizeResponseSchema=Se,e.AuthorizeResultSchema=ye,e.BackResponseSchema=Le,e.BaseModule=M,e.CameraModule=class extends M{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(B,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),s=this.validate(D,n);return s&&this.logger.warn("scanQRCode",`Unexpected response shape: ${s}`),n}},e.CheckoutModule=class extends M{constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(G,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"triggerCheckout",params:e}),s=this.validate(z,n);return s&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${s}`),n}},e.ClearAuthorizationArtifactsResponseSchema=be,e.CloseResponseSchema=Y,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 M{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(q,t);return n&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${n}`),t}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(F,t);return n&&this.logger.warn("setTitle",`Unexpected response shape: ${n}`),t}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(K,e);return t&&this.logger.warn("hideBackButton",`Unexpected response shape: ${t}`),e}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(W,e);return t&&this.logger.warn("showBackButton",`Unexpected response shape: ${t}`),e}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(H,e);return t&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${t}`),e}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(V,e);return t&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${t}`),e}async close(){const e=await this.invoke({method:"close"}),t=this.validate(Y,e);return t&&this.logger.warn("close",`Unexpected response shape: ${t}`),e}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(Q,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(J,e);return t&&this.logger.warn("showLoader",`Unexpected response shape: ${t}`),e}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(X,e);return t&&this.logger.warn("hideLoader",`Unexpected response shape: ${t}`),e}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(Z,t);return n&&this.logger.warn("openExternalLink",`Unexpected response shape: ${n}`),t}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(ee,t);return n&&this.logger.warn("onCtaTap",`Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(te,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(ne,n);return s&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${s}`),n}async isConnected(){return null!==U()?{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(ae,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}},e.DRMPlaybackEventSchema=Me,e.DeviceModule=class extends M{constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(ce,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}},e.DismissSplashScreenResponseSchema=Ye,e.DownloadFileRequestSchema=ue,e.DownloadFileResponseSchema=le,e.FetchEmailResponseSchema=Ge,e.FetchEmailResultSchema=De,e.FileModule=class extends M{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(ue,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),s=this.validate(le,n);return s&&this.logger.warn("downloadFile",`Unexpected response shape: ${s}`),n}},e.GetAuthorizationArtifactsResponseSchema=ke,e.GetAuthorizationArtifactsResultSchema=we,e.GetBooleanRequestSchema=Xe,e.GetBooleanResponseSchema=et,e.GetBooleanResultSchema=Ze,e.GetCoordinateResponseSchema=xe,e.GetCoordinateResultSchema=_e,e.GetCountryCodeResponseSchema=Ue,e.GetCountryCodeResultSchema=Ae,e.GetDoubleRequestSchema=lt,e.GetDoubleResponseSchema=ht,e.GetDoubleResultSchema=dt,e.GetIntRequestSchema=nt,e.GetIntResponseSchema=rt,e.GetIntResultSchema=st,e.GetLanguageLocaleIdentifierResponseSchema=Ee,e.GetLanguageLocaleIdentifierResultSchema=Ce,e.GetSelectedTravelDestinationResponseSchema=St,e.GetSelectedTravelDestinationResultSchema=yt,e.GetSessionParamsResponseSchema=ae,e.GetSessionParamsResultSchema=oe,e.GetStringRequestSchema=at,e.GetStringResponseSchema=ct,e.GetStringResultSchema=it,e.HasAccessToRequestSchema=Ke,e.HasAccessToResponseSchema=He,e.HasAccessToResultSchema=We,e.HideBackButtonResponseSchema=K,e.HideLoaderResponseSchema=X,e.HideRefreshButtonResponseSchema=H,e.IdentityModule=Re,e.IsConnectedResponseSchema=re,e.IsConnectedResultSchema=se,e.IsEsimSupportedResponseSchema=ce,e.IsEsimSupportedResultSchema=ie,e.LocaleModule=class extends M{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Ee,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}},e.LocationModule=class extends M{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(xe,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(Ue,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}},e.Logger=A,e.MediaModule=class extends M{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate($e,t);return n&&this.logger.warn("playDRMContent",`Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}},e.NetworkModule=class extends M{constructor(){super("NetworkModule")}async send(e){const t=this.validate(Te,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e}),s=this.validate(Be,n);if(s&&this.logger.warn("send",`Unexpected raw response shape: ${s}`),$(n)&&I(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result),t={...n,result:e},s=this.validate(Ne,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(Ne,r);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),r}},e.ObserveDRMPlaybackResponseSchema=Ie,e.OnContentLoadedResponseSchema=Q,e.OnCtaTapResponseSchema=ee,e.OpenExternalLinkResponseSchema=Z,e.PlatformModule=class extends M{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(Le,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}},e.PlayDRMContentResponseSchema=$e,e.ProfileModule=Fe,e.RedirectToSystemWebViewRequestSchema=ft,e.RedirectToSystemWebViewResponseSchema=vt,e.ReloadScopesResponseSchema=Ve,e.RemoveAllResponseSchema=gt,e.RemoveResponseSchema=mt,e.ScanQRCodeRequestSchema=B,e.ScanQRCodeResponseSchema=D,e.ScanQRCodeResultSchema=L,e.ScopeModule=class extends M{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},s=this.validate(Ke,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(He,r);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),r}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(Ve,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}},e.SendAnalyticsEventRequestSchema=te,e.SendAnalyticsEventResponseSchema=ne,e.SendRequestSchema=Te,e.SendResponseSchema=Ne,e.SendResultSchema=Oe,e.SetBackgroundColorResponseSchema=q,e.SetBooleanResponseSchema=Je,e.SetDoubleResponseSchema=ut,e.SetIntResponseSchema=tt,e.SetStringResponseSchema=ot,e.SetTitleResponseSchema=F,e.ShowBackButtonResponseSchema=W,e.ShowLoaderResponseSchema=J,e.ShowRefreshButtonResponseSchema=V,e.SplashScreenModule=class extends M{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(Ye,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}},e.StorageModule=class extends M{constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),s=this.validate(Je,n);return s&&this.logger.warn("setBoolean",`Unexpected response shape: ${s}`),n}async getBoolean(e){const t={key:e},n=this.validate(Xe,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getBoolean",params:t}),r=this.validate(et,s);return r&&this.logger.warn("getBoolean",`Unexpected response shape: ${r}`),s}async setInt(e,t){const n=await this.invoke({method:"setInt",params:{key:e,value:t}}),s=this.validate(tt,n);return s&&this.logger.warn("setInt",`Unexpected response shape: ${s}`),n}async getInt(e){const t={key:e},n=this.validate(nt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getInt",params:t}),r=this.validate(rt,s);return r&&this.logger.warn("getInt",`Unexpected response shape: ${r}`),s}async setString(e,t){const n=await this.invoke({method:"setString",params:{key:e,value:t}}),s=this.validate(ot,n);return s&&this.logger.warn("setString",`Unexpected response shape: ${s}`),n}async getString(e){const t={key:e},n=this.validate(at,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getString",params:t}),r=this.validate(ct,s);return r&&this.logger.warn("getString",`Unexpected response shape: ${r}`),s}async setDouble(e,t){const n=await this.invoke({method:"setDouble",params:{key:e,value:t}}),s=this.validate(ut,n);return s&&this.logger.warn("setDouble",`Unexpected response shape: ${s}`),n}async getDouble(e){const t={key:e},n=this.validate(lt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getDouble",params:t}),r=this.validate(ht,s);return r&&this.logger.warn("getDouble",`Unexpected response shape: ${r}`),s}async remove(e){const t={key:e},n=this.validate(pt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"remove",params:t}),r=this.validate(mt,s);return r&&this.logger.warn("remove",`Unexpected response shape: ${r}`),s}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(gt,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}},e.SystemWebViewKitModule=class extends M{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(ft,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),s=this.validate(vt,n);return s&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${s}`),n}},e.TriggerCheckoutRequestSchema=G,e.TriggerCheckoutResponseSchema=z,e.TriggerCheckoutResultSchema=j,e.UserAttributesModule=class extends M{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(St,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}},e.VerifyEmailRequestSchema=je,e.VerifyEmailResponseSchema=qe,e.VerifyEmailResultSchema=ze,e.hasResult=I,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=function(e){return 200===e.status_code},e.isRedirection=function(e){return 302===e.status_code},e.isServerError=function(e){return e.status_code>=500&&e.status_code<600},e.isSuccess=$});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grabjs/superapp-sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.38",
|
|
4
4
|
"description": "SDK for Grab SuperApp WebView.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": "
|
|
21
|
+
"node": ">=18"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "npm run clean && npm run build:dist && npm run build:docs && npm run build:skills",
|
package/skills/SKILL.md
CHANGED
|
@@ -318,7 +318,7 @@ JSBridge module for playing DRM-protected media content.
|
|
|
318
318
|
|
|
319
319
|
#### `NetworkModule`
|
|
320
320
|
JSBridge module for making network requests via the native bridge.
|
|
321
|
-
- `send(request: { body?: unknown; endpoint: string; headers?: Record<string, string>; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS"; query?: Record<string, string>; timeout?: number }): Promise<{ result: Record<string, unknown>; status_code:
|
|
321
|
+
- `send(request: { body?: unknown; endpoint: string; headers?: Record<string, string>; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS"; query?: Record<string, string>; timeout?: number }): Promise<{ status_code: 204 } | { error: string; status_code: 400 } | { error: string; status_code: 403 } | { error: string; status_code: 500 } | { error: string; status_code: 501 } | { error: string; status_code: 404 } | { error: string; status_code: 424 } | { result: Record<string, unknown>; status_code: 200 } | { error: string; status_code: 401 } | { error: string; status_code: 426 }>` — Sends a network request via the native bridge.
|
|
322
322
|
|
|
323
323
|
#### `PlatformModule`
|
|
324
324
|
JSBridge module for controlling platform navigation.
|
|
@@ -327,7 +327,7 @@ This navigates back in the native navigation stack.
|
|
|
327
327
|
|
|
328
328
|
#### `ProfileModule`
|
|
329
329
|
JSBridge module for accessing user profile information.
|
|
330
|
-
- `fetchEmail(): Promise<{ status_code: 204 } | { error: string; status_code: 400 } | { error: string; status_code: 403 } | { error: string; status_code: 500 } | { error: string; status_code: 501 } | {
|
|
330
|
+
- `fetchEmail(): Promise<{ status_code: 204 } | { error: string; status_code: 400 } | { error: string; status_code: 403 } | { error: string; status_code: 500 } | { error: string; status_code: 501 } | { error: string; status_code: 426 } | { result: { email: string }; status_code: 200 }>` — Fetches the user's email address from their Grab profile.
|
|
331
331
|
- `verifyEmail(request?: { email?: string; skipUserInput?: boolean }): Promise<{ status_code: 204 } | { error: string; status_code: 400 } | { error: string; status_code: 403 } | { error: string; status_code: 500 } | { error: string; status_code: 501 } | { error: string; status_code: 426 } | { result: { email: string }; status_code: 200 }>` — Verifies the user's email address by triggering email capture bottom sheet and OTP verification.
|
|
332
332
|
|
|
333
333
|
#### `ScopeModule`
|
|
@@ -363,6 +363,12 @@ JSBridge module for reading user-related attributes from native code.
|
|
|
363
363
|
|
|
364
364
|
### Functions
|
|
365
365
|
|
|
366
|
+
#### `hasResult`
|
|
367
|
+
Type guard to check if a JSBridge response has a defined result (not null or undefined).
|
|
368
|
+
```ts
|
|
369
|
+
hasResult<T>(response: T): response is Extract<T, { result: {} }>
|
|
370
|
+
```
|
|
371
|
+
|
|
366
372
|
#### `isClientError`
|
|
367
373
|
Type guard to check if a JSBridge response is a client error (4xx status codes).
|
|
368
374
|
```ts
|