@grabjs/superapp-sdk 2.0.0-beta.38 → 2.0.0-beta.47
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 +5649 -6906
- package/dist/index.d.ts +65 -73
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -1
- package/skills/SKILL.md +336 -76
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 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};
|
|
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 U(){return{kind:"schema",type:"unknown",reference:U,expects:"unknown",async:!1,get"~standard"(){return a(this)},"~run":e=>(e.typed=!0,e)}}function $(...e){return{...e[0],pipe:e,get"~standard"(){return a(this)},"~run"(t,n){for(const 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 S(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class E{constructor(e){this.moduleName=e}formatPrefix(e){return`[SuperAppSDK][${this.moduleName}.${e}]`}warn(e,t){console.warn(`${this.formatPrefix(e)} ${t}`)}error(e,t){console.error(`${this.formatPrefix(e)} ${t}`)}}function C(){if("undefined"==typeof window||!window.navigator)return null;const e=window.navigator.userAgent;return e?function(e){if(!e||"string"!=typeof e)return null;const t=e.match(/(Grab|GrabBeta|GrabBetaDebug|GrabTaxi|GrabEarlyAccess)\/v?([0-9]+)\.([0-9]+)\.([0-9]+) \(.*(Android|iOS).*\)/i);return t?{appName:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])},platform:t[5]}:null}(e):null}class A{get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new E(e),!this.wrappedModule)try{n.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${S(e)?`: ${e.message}`:""}`,{cause:e})}}validate(e,t){const n=function(e,t){const n=e["~run"]({value:t},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: ${S(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:n}=e;try{return C()?this.wrappedModule.invoke(t,n):this.createErrorStream({status_code:501,error:"Not implemented: This method requires the Grab app environment"})}catch(e){return this.createErrorStream({status_code:500,error:`Failed to invoke method: ${S(e)?e.message:"Unknown error"}`})}}}function I(e){return e.status_code>=200&&e.status_code<300}function M(e){return 200===e.status_code}function T(e){return 204===e.status_code}function O(e){return 302===e.status_code}function N(e){return 302===e.status_code}function P(e){return e.status_code>=400&&e.status_code<500}function R(e){return e.status_code>=500&&e.status_code<600}function B(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0}function L(e){return"result"in e&&null!==e.result&&void 0!==e.result}const j=e=>v({status_code:g(e),error:b()}),D=e=>v({status_code:g(200),result:e}),z=v({status_code:g(204)}),K=v({status_code:g(302)}),G=v({title:y(b())}),W=v({qrCode:b()}),F=x([D(W),z,j(400),j(403),j(500),j(501)]);class q extends A{constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(G,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),r=this.validate(F,n);return r&&this.logger.warn("scanQRCode",`Unexpected response shape: ${r}`),n}}const H=k(b(),U()),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([z,j(400),j(500),j(501)]),ne=x([D(p()),z,j(400),j(500),j(501)]),re=x([z,j(400),j(500),j(501)]),se=x([D(p()),z,j(500),j(501)]),oe=x([z,j(500),j(501)]),ae=x([D(p()),z,j(500),j(501)]),ie=x([z,j(500),j(501)]),ce=x([D(p()),z,j(500),j(501)]),ue=x([z,j(500),j(501)]),de=x([D(p()),z,j(500),j(501)]),le=x([z,j(500),j(501)]),he=x([D(p()),z,j(500),j(501)]),pe=x([z,j(500),j(501)]),ge=x([D(p()),z,j(500),j(501)]),me=x([D(p()),z,j(500),j(501)]),fe=x([z,j(500),j(501)]),ve=x([D(p()),z,j(500),j(501)]),ye=x([z,j(500),j(501)]),we=x([D(p()),z,j(400),j(500),j(501)]),ke=x([z,j(400),j(500),j(501)]),be=x([D(p()),j(500),j(501)]),_e=v({state:$(b(),u(1)),name:$(b(),u(1)),data:y(k(b(),U()))}),xe=x([D(p()),z,j(400),j(500),j(501)]),Ue=x([z,j(400),j(500),j(501)]),$e=v({connected:p()}),Se=x([D($e),j(404)]),Ee=b(),Ce=x([D(Ee),z,j(500),j(501)]);class Ae extends A{constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(ee,t);let r;n&&this.logger.warn("setBackgroundColor",`Unexpected raw response shape: ${n}`),r=M(t)?{status_code:204}:t;const s=this.validate(te,r);return s&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${s}`),r}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(ne,t);let r;n&&this.logger.warn("setTitle",`Unexpected raw response shape: ${n}`),r=M(t)?{status_code:204}:t;const s=this.validate(re,r);return s&&this.logger.warn("setTitle",`Unexpected response shape: ${s}`),r}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(se,e);let n;t&&this.logger.warn("hideBackButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const r=this.validate(oe,n);return r&&this.logger.warn("hideBackButton",`Unexpected response shape: ${r}`),n}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(ae,e);let n;t&&this.logger.warn("showBackButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const r=this.validate(ie,n);return r&&this.logger.warn("showBackButton",`Unexpected response shape: ${r}`),n}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(ce,e);let n;t&&this.logger.warn("hideRefreshButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const r=this.validate(ue,n);return r&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${r}`),n}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(de,e);let n;t&&this.logger.warn("showRefreshButton",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const r=this.validate(le,n);return r&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${r}`),n}async close(){const e=await this.invoke({method:"close"}),t=this.validate(he,e);let n;t&&this.logger.warn("close",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const r=this.validate(pe,n);return r&&this.logger.warn("close",`Unexpected response shape: ${r}`),n}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(ge,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(me,e);let n;t&&this.logger.warn("showLoader",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const r=this.validate(fe,n);return r&&this.logger.warn("showLoader",`Unexpected response shape: ${r}`),n}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ve,e);let n;t&&this.logger.warn("hideLoader",`Unexpected raw response shape: ${t}`),n=M(e)?{status_code:204}:e;const r=this.validate(ye,n);return r&&this.logger.warn("hideLoader",`Unexpected response shape: ${r}`),n}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(we,t);let r;n&&this.logger.warn("openExternalLink",`Unexpected raw response shape: ${n}`),r=M(t)?{status_code:204}:t;const s=this.validate(ke,r);return s&&this.logger.warn("openExternalLink",`Unexpected response shape: ${s}`),r}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(be,t);return n&&this.logger.warn("onCtaTap",`Unexpected response shape: ${n}`),t}async sendAnalyticsEvent(e){const t=this.validate(_e,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"sendAnalyticsEvent",params:{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null}}),r=this.validate(xe,n);let s;r&&this.logger.warn("sendAnalyticsEvent",`Unexpected raw response shape: ${r}`),s=M(n)?{status_code:204}:n;const o=this.validate(Ue,s);return o&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${o}`),s}async isConnected(){return null!==C()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(Ce,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}}const Ie=p(),Me=x([D(Ie),j(500),j(501)]);class Te extends A{constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(Me,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}}const Oe=v({fileUrl:$(b(),d()),fileName:$(b(),u(1))}),Ne=x([z,j(400),j(500),j(501)]);class Pe extends A{constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(Oe,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),r=this.validate(Ne,n);return r&&this.logger.warn("downloadFile",`Unexpected response shape: ${r}`),n}}function Re(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 Be(e){const t=(new TextEncoder).encode(e);return function(e){const t=new Uint8Array(e);let n="";for(let e=0;e<t.byteLength;e+=1)n+=String.fromCharCode(t[e]);return btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(await crypto.subtle.digest("SHA-256",t))}function Le(e,t){return e.major!==t.major?e.major>t.major:e.minor!==t.minor?e.minor>t.minor:e.patch>=t.patch}const je="grabid",De={staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"};class ze extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Ke=v({clientId:$(b(),u(1)),redirectUri:$(b(),d()),scope:$(b(),u(1)),environment:w(["staging","production"]),responseMode:y(w(["redirect","in_place"]))}),Ge=v({code:b(),state:b()}),We=x([D(Ge),z,K,j(400),j(403),j(500),j(501)]),Fe=v({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),qe=x([D(Fe),z,j(400)]),He=x([z]);class Ve extends A{constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=De[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new ze("Failed to fetch authorization configuration");const n=await e.json();if(!n.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new ze("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof ze)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=Re(16),t=Re(32),n=(r=Re(64),btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var r;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await Be(n),codeChallengeMethod:"S256"}}storePKCEArtifacts(e){this.setStorageItem("nonce",e.nonce),this.setStorageItem("state",e.state),this.setStorageItem("code_verifier",e.codeVerifier),this.setStorageItem("redirect_uri",e.redirectUri)}async getAuthorizationArtifacts(){const e=this.getStorageItem("state"),t=this.getStorageItem("code_verifier"),n=this.getStorageItem("nonce"),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(`${je}:nonce`),window.localStorage.removeItem(`${je}:state`),window.localStorage.removeItem(`${je}:code_verifier`),window.localStorage.removeItem(`${je}:redirect_uri`),window.localStorage.removeItem(`${je}:login_return_uri`),{status_code:204}}setStorageItem(e,t){window.localStorage.setItem(`${je}:${e}`,t)}getStorageItem(e){return window.localStorage.getItem(`${je}:${e}`)}static normalizeUrl(e){const t=new URL(e);return`${t.origin}${t.pathname}`}static buildAuthorizeUrl(e,t){return`${e}?${Object.entries(t).filter(e=>void 0!==e[1]&&null!==e[1]).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}`}static shouldUseWebConsent(e){const t=C();return!t||"staging"!==e.environment&&!Le(t.version,{major:5,minor:396,patch:0})}async performWebAuthorization(e){let t;this.setStorageItem("login_return_uri",window.location.href),this.setStorageItem("redirect_uri",e.redirectUri);try{t=await this.fetchAuthorizationEndpoint(e.environment)}catch(e){return{status_code:400,error:S(e)?e.message:"Could not fetch authorization endpoint"}}const n={client_id:e.clientId,scope:e.scope,response_type:"code",redirect_uri:e.redirectUri,nonce:e.nonce,state:e.state,code_challenge_method:e.codeChallengeMethod,code_challenge:e.codeChallenge},r=Ve.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(We,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(Ke,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),r=e.responseMode||"redirect",s="in_place"===r?Ve.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(Ve.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 Ye=b(),Je=x([D(Ye),z,j(400),j(500),j(501)]);class Qe extends A{constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Je,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}}const Xe=v({latitude:f(),longitude:f()}),Ze=x([D(Xe),j(403),j(424),j(500),j(501)]),et=b(),tt=x([D(et),z,j(403),j(424),j(500),j(501)]);class nt extends A{constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(Ze,e);return t&&this.logger.warn("getCoordinate",`Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(tt,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}}const rt=v({type:w(["START_PLAYBACK","PROGRESS_PLAYBACK","START_SEEK","STOP_SEEK","STOP_PLAYBACK","CLOSE_PLAYBACK","PAUSE_PLAYBACK","RESUME_PLAYBACK","FAST_FORWARD_PLAYBACK","REWIND_PLAYBACK","ERROR_PLAYBACK","CHANGE_VOLUME"]),titleId:b(),position:f(),length:f()}),st=x([D(rt),z,j(400),j(424),j(500),j(501)]),ot=x([D(rt),j(500),j(501)]);class at extends A{constructor(){super("MediaModule")}async playDRMContent(e){const t=await this.invoke({method:"playDRMContent",params:{data:e}}),n=this.validate(st,t);return n&&this.logger.warn("playDRMContent",`Unexpected response shape: ${n}`),t}observePlayDRMContent(e){return this.invokeStream({method:"observePlayDRMContent",params:{data:e}})}}const it=v({endpoint:b(),method:w(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:y(k(b(),b())),query:y(k(b(),b())),body:y(U()),timeout:y(f())}),ct=k(b(),U()),ut=x([D(ct),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]),dt=x([b(),ct]),lt=x([D(dt),z,j(400),j(401),j(403),j(404),j(424),j(426),j(500),j(501)]);class ht extends A{constructor(){super("NetworkModule")}async send(e){const t=this.validate(it,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e}),r=this.validate(lt,n);if(r&&this.logger.warn("send",`Unexpected raw response shape: ${r}`),I(n)&&L(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result),t={...n,result:e},r=this.validate(ut,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(ut,s);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),s}}const pt=x([z,j(500),j(501)]);class gt extends A{constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(pt,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}}const mt=v({email:b()}),ft=x([D(mt),z,j(400),j(403),j(426),j(500),j(501)]),vt=v({email:y($(b(),u(1))),skipUserInput:y(p())}),yt=v({email:b()}),wt=x([D(yt),z,j(400),j(403),j(426),j(500),j(501)]);class kt extends A{constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>Le(e.version,kt.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(ft,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>Le(e.version,kt.MINIMUM_VERSION));if(t)return t;const n=this.validate(vt,e??{});if(n)return{status_code:400,error:n};const r=await this.invoke({method:"verifyEmail",params:e}),s=this.validate(wt,r);return s&&this.logger.warn("verifyEmail",`Unexpected response shape: ${s}`),r}}kt.MINIMUM_VERSION={major:5,minor:399,patch:0};const bt=v({module:$(b(),u(1)),method:$(b(),u(1))}),_t=p(),xt=x([D(_t),j(400),j(424),j(500),j(501)]),Ut=x([z,j(424),j(500),j(501)]);class $t extends A{constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},r=this.validate(bt,n);if(r)return{status_code:400,error:r};const s=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(xt,s);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),s}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(Ut,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}}const St=x([z,j(400),j(403),j(500),j(501)]);class Et extends A{constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(St,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}}const Ct=v({key:$(b(),u(1))}),At=x([z,j(400),j(424),j(500),j(501)]),It=Ct,Mt=v({value:m(p())}),Tt=x([D(Mt),j(400),j(424),j(500),j(501)]),Ot=x([z,j(400),j(424),j(500),j(501)]),Nt=Ct,Pt=v({value:m(f())}),Rt=x([D(Pt),j(400),j(424),j(500),j(501)]),Bt=x([z,j(400),j(424),j(500),j(501)]),Lt=Ct,jt=v({value:m(b())}),Dt=x([D(jt),j(400),j(424),j(500),j(501)]),zt=x([z,j(400),j(424),j(500),j(501)]),Kt=Ct,Gt=v({value:m(f())}),Wt=x([D(Gt),j(400),j(424),j(500),j(501)]),Ft=Ct,qt=x([z,j(400),j(424),j(500),j(501)]),Ht=x([z,j(424),j(500),j(501)]);class Vt extends A{constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),r=this.validate(At,n);return r&&this.logger.warn("setBoolean",`Unexpected response shape: ${r}`),n}async getBoolean(e){const t={key:e},n=this.validate(It,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getBoolean",params:t}),s=this.validate(Tt,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(Ot,n);return r&&this.logger.warn("setInt",`Unexpected response shape: ${r}`),n}async getInt(e){const t={key:e},n=this.validate(Nt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getInt",params:t}),s=this.validate(Rt,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(Bt,n);return r&&this.logger.warn("setString",`Unexpected response shape: ${r}`),n}async getString(e){const t={key:e},n=this.validate(Lt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getString",params:t}),s=this.validate(Dt,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(zt,n);return r&&this.logger.warn("setDouble",`Unexpected response shape: ${r}`),n}async getDouble(e){const t={key:e},n=this.validate(Kt,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"getDouble",params:t}),s=this.validate(Wt,r);return s&&this.logger.warn("getDouble",`Unexpected response shape: ${s}`),r}async remove(e){const t={key:e},n=this.validate(Ft,t);if(n)return{status_code:400,error:n};const r=await this.invoke({method:"remove",params:t}),s=this.validate(qt,r);return s&&this.logger.warn("remove",`Unexpected response shape: ${s}`),r}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}}const Yt=v({url:$(b(),d())}),Jt=x([D(b()),j(400),j(424),j(500),j(501)]);class Qt extends A{constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(Yt,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 Xt=b(),Zt=x([D(Xt),z,j(500),j(501)]);class en extends A{constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(Zt,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}}export{Ke as AuthorizeRequestSchema,We as AuthorizeResponseSchema,Ge as AuthorizeResultSchema,pt as BackResponseSchema,A as BaseModule,q as CameraModule,J as CheckoutModule,He as ClearAuthorizationArtifactsResponseSchema,pe as CloseResponseSchema,Z as ContainerAnalyticsEventData,X as ContainerAnalyticsEventName,Q as ContainerAnalyticsEventState,Ae as ContainerModule,rt as DRMPlaybackEventSchema,Te as DeviceModule,St as DismissSplashScreenResponseSchema,Oe as DownloadFileRequestSchema,Ne as DownloadFileResponseSchema,ft as FetchEmailResponseSchema,mt as FetchEmailResultSchema,Pe as FileModule,qe as GetAuthorizationArtifactsResponseSchema,Fe as GetAuthorizationArtifactsResultSchema,It as GetBooleanRequestSchema,Tt as GetBooleanResponseSchema,Mt as GetBooleanResultSchema,Ze as GetCoordinateResponseSchema,Xe as GetCoordinateResultSchema,tt as GetCountryCodeResponseSchema,et as GetCountryCodeResultSchema,Kt as GetDoubleRequestSchema,Wt as GetDoubleResponseSchema,Gt as GetDoubleResultSchema,Nt as GetIntRequestSchema,Rt as GetIntResponseSchema,Pt as GetIntResultSchema,Je as GetLanguageLocaleIdentifierResponseSchema,Ye as GetLanguageLocaleIdentifierResultSchema,Zt as GetSelectedTravelDestinationResponseSchema,Xt as GetSelectedTravelDestinationResultSchema,Ce as GetSessionParamsResponseSchema,Ee as GetSessionParamsResultSchema,Lt as GetStringRequestSchema,Dt as GetStringResponseSchema,jt as GetStringResultSchema,bt as HasAccessToRequestSchema,xt as HasAccessToResponseSchema,_t as HasAccessToResultSchema,oe as HideBackButtonResponseSchema,ye as HideLoaderResponseSchema,ue as HideRefreshButtonResponseSchema,Ve as IdentityModule,Se as IsConnectedResponseSchema,$e as IsConnectedResultSchema,Me as IsEsimSupportedResponseSchema,Ie as IsEsimSupportedResultSchema,Qe as LocaleModule,nt as LocationModule,E as Logger,at as MediaModule,ht as NetworkModule,ot as ObserveDRMPlaybackResponseSchema,ge as OnContentLoadedResponseSchema,be as OnCtaTapResponseSchema,ke as OpenExternalLinkResponseSchema,gt as PlatformModule,st as PlayDRMContentResponseSchema,kt as ProfileModule,Yt as RedirectToSystemWebViewRequestSchema,Jt as RedirectToSystemWebViewResponseSchema,Ut as ReloadScopesResponseSchema,Ht as RemoveAllResponseSchema,qt as RemoveResponseSchema,G as ScanQRCodeRequestSchema,F as ScanQRCodeResponseSchema,W as ScanQRCodeResultSchema,$t as ScopeModule,_e as SendAnalyticsEventRequestSchema,Ue as SendAnalyticsEventResponseSchema,it as SendRequestSchema,ut as SendResponseSchema,ct as SendResultSchema,te as SetBackgroundColorResponseSchema,At as SetBooleanResponseSchema,zt as SetDoubleResponseSchema,Ot as SetIntResponseSchema,Bt as SetStringResponseSchema,re as SetTitleResponseSchema,ie as ShowBackButtonResponseSchema,fe as ShowLoaderResponseSchema,le as ShowRefreshButtonResponseSchema,Et as SplashScreenModule,Vt as StorageModule,Qt as SystemWebViewKitModule,H as TriggerCheckoutRequestSchema,Y as TriggerCheckoutResponseSchema,V as TriggerCheckoutResultSchema,en as UserAttributesModule,vt as VerifyEmailRequestSchema,wt as VerifyEmailResponseSchema,yt as VerifyEmailResultSchema,L as hasResult,P as isClientError,B as isError,N as isFound,T as isNoContent,M as isOk,O as isRedirection,R as isServerError,I as isSuccess};
|
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 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=$});
|
|
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 w(e,t){return{kind:"schema",type:"optional",reference:w,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return i(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=p(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function S(e,t){return{kind:"schema",type:"picklist",reference:S,expects:u(e.map(o),"|"),async:!1,options:e,message:t,get"~standard"(){return i(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:a(this,"type",e,t),e}}}function k(e,t,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 x(e,t){return{kind:"schema",type:"union",reference:x,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 C(...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 E(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}class U{constructor(e){this.moduleName=e}formatPrefix(e){return`[SuperAppSDK][${this.moduleName}.${e}]`}warn(e,t){console.warn(`${this.formatPrefix(e)} ${t}`)}error(e,t){console.error(`${this.formatPrefix(e)} ${t}`)}}function A(){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 ${get wrappedModule(){return window[`Wrapped${this.name}`]}constructor(e){if(this.name=e,this.logger=new U(e),!this.wrappedModule)try{s.wrapModule(window,this.name)}catch(e){throw new Error(`Failed to initialize ${this.name}${E(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=A();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 A()?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: ${E(e)?e.message:"Unknown error"}`}}}createErrorStream(e){return{subscribe:t=>(t?.next?.(e),t?.complete?.(),{isUnsubscribed:()=>!0,unsubscribe:()=>{}}),then:t=>Promise.resolve(e).then(t)}}invokeStream(e){const{method:t,params:n}=e;try{return A()?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: ${E(e)?e.message:"Unknown error"}`})}}}function M(e){return e.status_code>=200&&e.status_code<300}function I(e){return 200===e.status_code}function T(e){return"result"in e&&null!==e.result&&void 0!==e.result}const O=e=>y({status_code:g(e),error:b()}),N=e=>y({status_code:g(200),result:e}),B=y({status_code:g(204)}),P=y({status_code:g(302)}),L=y({title:w(b())}),D=y({qrCode:b()}),G=x([N(D),B,O(400),O(403),O(500),O(501)]),j=k(b(),_()),z=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")})]),q=x([N(z),O(400),O(500),O(501)]),F=x([N(m()),B,O(400),O(500),O(501)]),K=x([B,O(400),O(500),O(501)]),W=x([N(m()),B,O(400),O(500),O(501)]),H=x([B,O(400),O(500),O(501)]),V=x([N(m()),B,O(500),O(501)]),Y=x([B,O(500),O(501)]),Q=x([N(m()),B,O(500),O(501)]),J=x([B,O(500),O(501)]),X=x([N(m()),B,O(500),O(501)]),Z=x([B,O(500),O(501)]),ee=x([N(m()),B,O(500),O(501)]),te=x([B,O(500),O(501)]),ne=x([N(m()),B,O(500),O(501)]),se=x([B,O(500),O(501)]),re=x([N(m()),B,O(500),O(501)]),oe=x([N(m()),B,O(500),O(501)]),ae=x([B,O(500),O(501)]),ie=x([N(m()),B,O(500),O(501)]),ce=x([B,O(500),O(501)]),ue=x([N(m()),B,O(400),O(500),O(501)]),le=x([B,O(400),O(500),O(501)]),de=x([N(m()),O(500),O(501)]),he=y({state:C(b(),l(1)),name:C(b(),l(1)),data:w(k(b(),_()))}),pe=x([N(m()),B,O(400),O(500),O(501)]),me=x([B,O(400),O(500),O(501)]),ge=y({connected:m()}),fe=x([N(ge),O(404)]),ve=b(),ye=x([N(ve),B,O(500),O(501)]),we=m(),Se=x([N(we),O(500),O(501)]),ke=y({fileUrl:C(b(),d()),fileName:C(b(),l(1))}),be=x([B,O(400),O(500),O(501)]);function Re(e){const t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let s=0;s<e;s+=1)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(t[s]%62);return n}async function xe(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",Ee={staging:"https://partner-api.stg-myteksi.com/grabid/v1/oauth2/.well-known/openid-configuration",production:"https://partner-api.grab.com/grabid/v1/oauth2/.well-known/openid-configuration"};class Ue extends Error{constructor(e,t){super(e),this.cause=t,this.name="AuthorizationConfigurationError"}}const Ae=y({clientId:C(b(),l(1)),redirectUri:C(b(),d()),scope:C(b(),l(1)),environment:S(["staging","production"]),responseMode:w(S(["redirect","in_place"]))}),$e=y({code:b(),state:b()}),Me=x([N($e),B,P,O(400),O(403),O(500),O(501)]),Ie=y({state:b(),codeVerifier:b(),nonce:b(),redirectUri:b()}),Te=x([N(Ie),B,O(400)]),Oe=x([B]);class Ne extends ${constructor(){super("IdentityModule")}async fetchAuthorizationEndpoint(e){const t=Ee[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be 'staging' or 'production'`);try{const e=await fetch(t);if(!e.ok)throw console.error(`Failed to fetch OpenID configuration from ${t}: ${e.status} ${e.statusText}`),new Ue("Failed to fetch authorization configuration");const n=await e.json();if(!n.authorization_endpoint)throw console.error("authorization_endpoint not found in OpenID configuration response"),new Ue("Invalid authorization configuration");return n.authorization_endpoint}catch(e){if(console.error("Error fetching authorization endpoint:",e),e instanceof Ue)throw e;throw new Error("Something wrong happened when fetching authorization configuration",{cause:e})}}async generatePKCEArtifacts(){const e=Re(16),t=Re(32),n=(s=Re(64),btoa(s).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"));var s;return{nonce:e,state:t,codeVerifier:n,codeChallenge:await xe(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(`${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=A();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:E(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=Ne.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(Me,t);return n&&this.logger.warn("authorize",`Unexpected response shape: ${n}`),t}async authorize(e){const t=this.validate(Ae,e);if(t)return{status_code:400,error:t};const n=await this.generatePKCEArtifacts(),s=e.responseMode||"redirect",r="in_place"===s?Ne.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(Ne.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(),Pe=x([N(Be),B,O(400),O(500),O(501)]),Le=y({latitude:v(),longitude:v()}),De=x([N(Le),O(403),O(424),O(500),O(501)]),Ge=b(),je=x([N(Ge),B,O(403),O(424),O(500),O(501)]),ze=y({type:S(["START_PLAYBACK","PROGRESS_PLAYBACK","START_SEEK","STOP_SEEK","STOP_PLAYBACK","CLOSE_PLAYBACK","PAUSE_PLAYBACK","RESUME_PLAYBACK","FAST_FORWARD_PLAYBACK","REWIND_PLAYBACK","ERROR_PLAYBACK","CHANGE_VOLUME"]),titleId:b(),position:v(),length:v()}),qe=x([N(ze),B,O(400),O(424),O(500),O(501)]),Fe=x([N(ze),O(500),O(501)]),Ke=y({endpoint:b(),method:S(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]),headers:w(k(b(),b())),query:w(k(b(),b())),body:w(_()),timeout:w(v())}),We=k(b(),_()),He=x([N(We),B,O(400),O(401),O(403),O(404),O(424),O(426),O(500),O(501)]),Ve=x([b(),We]),Ye=x([N(Ve),B,O(400),O(401),O(403),O(404),O(424),O(426),O(500),O(501)]),Qe=x([B,O(500),O(501)]),Je=y({email:b()}),Xe=x([N(Je),B,O(400),O(403),O(426),O(500),O(501)]),Ze=y({email:w(C(b(),l(1))),skipUserInput:w(m())}),et=y({email:b()}),tt=x([N(et),B,O(400),O(403),O(426),O(500),O(501)]);class nt extends ${constructor(){super("ProfileModule")}async fetchEmail(){const e=this.checkSupport(e=>_e(e.version,nt.MINIMUM_VERSION));if(e)return e;const t=await this.invoke({method:"fetchEmail"}),n=this.validate(Xe,t);return n&&this.logger.warn("fetchEmail",`Unexpected response shape: ${n}`),t}async verifyEmail(e){const t=this.checkSupport(e=>_e(e.version,nt.MINIMUM_VERSION));if(t)return t;const n=this.validate(Ze,e??{});if(n)return{status_code:400,error:n};const s=await this.invoke({method:"verifyEmail",params:e}),r=this.validate(tt,s);return r&&this.logger.warn("verifyEmail",`Unexpected response shape: ${r}`),s}}nt.MINIMUM_VERSION={major:5,minor:399,patch:0};const st=y({module:C(b(),l(1)),method:C(b(),l(1))}),rt=m(),ot=x([N(rt),O(400),O(424),O(500),O(501)]),at=x([B,O(424),O(500),O(501)]),it=x([B,O(400),O(403),O(500),O(501)]),ct=y({key:C(b(),l(1))}),ut=x([B,O(400),O(424),O(500),O(501)]),lt=ct,dt=y({value:f(m())}),ht=x([N(dt),O(400),O(424),O(500),O(501)]),pt=x([B,O(400),O(424),O(500),O(501)]),mt=ct,gt=y({value:f(v())}),ft=x([N(gt),O(400),O(424),O(500),O(501)]),vt=x([B,O(400),O(424),O(500),O(501)]),yt=ct,wt=y({value:f(b())}),St=x([N(wt),O(400),O(424),O(500),O(501)]),kt=x([B,O(400),O(424),O(500),O(501)]),bt=ct,Rt=y({value:f(v())}),xt=x([N(Rt),O(400),O(424),O(500),O(501)]),_t=ct,Ct=x([B,O(400),O(424),O(500),O(501)]),Et=x([B,O(424),O(500),O(501)]),Ut=y({url:C(b(),d())}),At=x([N(b()),O(400),O(424),O(500),O(501)]),$t=b(),Mt=x([N($t),B,O(500),O(501)]);e.AuthorizeRequestSchema=Ae,e.AuthorizeResponseSchema=Me,e.AuthorizeResultSchema=$e,e.BackResponseSchema=Qe,e.BaseModule=$,e.CameraModule=class extends ${constructor(){super("CameraModule")}async scanQRCode(e={}){const t=this.validate(L,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"scanQRCode",params:e}),s=this.validate(G,n);return s&&this.logger.warn("scanQRCode",`Unexpected response shape: ${s}`),n}},e.CheckoutModule=class extends ${constructor(){super("CheckoutModule")}async triggerCheckout(e){const t=this.validate(j,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"triggerCheckout",params:e}),s=this.validate(q,n);return s&&this.logger.warn("triggerCheckout",`Unexpected response shape: ${s}`),n}},e.ClearAuthorizationArtifactsResponseSchema=Oe,e.CloseResponseSchema=se,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 ${constructor(){super("ContainerModule")}async setBackgroundColor(e){const t=await this.invoke({method:"setBackgroundColor",params:{backgroundColor:e}}),n=this.validate(F,t);let s;n&&this.logger.warn("setBackgroundColor",`Unexpected raw response shape: ${n}`),s=I(t)?{status_code:204}:t;const r=this.validate(K,s);return r&&this.logger.warn("setBackgroundColor",`Unexpected response shape: ${r}`),s}async setTitle(e){const t=await this.invoke({method:"setTitle",params:{title:e}}),n=this.validate(W,t);let s;n&&this.logger.warn("setTitle",`Unexpected raw response shape: ${n}`),s=I(t)?{status_code:204}:t;const r=this.validate(H,s);return r&&this.logger.warn("setTitle",`Unexpected response shape: ${r}`),s}async hideBackButton(){const e=await this.invoke({method:"hideBackButton"}),t=this.validate(V,e);let n;t&&this.logger.warn("hideBackButton",`Unexpected raw response shape: ${t}`),n=I(e)?{status_code:204}:e;const s=this.validate(Y,n);return s&&this.logger.warn("hideBackButton",`Unexpected response shape: ${s}`),n}async showBackButton(){const e=await this.invoke({method:"showBackButton"}),t=this.validate(Q,e);let n;t&&this.logger.warn("showBackButton",`Unexpected raw response shape: ${t}`),n=I(e)?{status_code:204}:e;const s=this.validate(J,n);return s&&this.logger.warn("showBackButton",`Unexpected response shape: ${s}`),n}async hideRefreshButton(){const e=await this.invoke({method:"hideRefreshButton"}),t=this.validate(X,e);let n;t&&this.logger.warn("hideRefreshButton",`Unexpected raw response shape: ${t}`),n=I(e)?{status_code:204}:e;const s=this.validate(Z,n);return s&&this.logger.warn("hideRefreshButton",`Unexpected response shape: ${s}`),n}async showRefreshButton(){const e=await this.invoke({method:"showRefreshButton"}),t=this.validate(ee,e);let n;t&&this.logger.warn("showRefreshButton",`Unexpected raw response shape: ${t}`),n=I(e)?{status_code:204}:e;const s=this.validate(te,n);return s&&this.logger.warn("showRefreshButton",`Unexpected response shape: ${s}`),n}async close(){const e=await this.invoke({method:"close"}),t=this.validate(ne,e);let n;t&&this.logger.warn("close",`Unexpected raw response shape: ${t}`),n=I(e)?{status_code:204}:e;const s=this.validate(se,n);return s&&this.logger.warn("close",`Unexpected response shape: ${s}`),n}async onContentLoaded(){const e=await this.invoke({method:"onContentLoaded"}),t=this.validate(re,e);return t&&this.logger.warn("onContentLoaded",`Unexpected response shape: ${t}`),e}async showLoader(){const e=await this.invoke({method:"showLoader"}),t=this.validate(oe,e);let n;t&&this.logger.warn("showLoader",`Unexpected raw response shape: ${t}`),n=I(e)?{status_code:204}:e;const s=this.validate(ae,n);return s&&this.logger.warn("showLoader",`Unexpected response shape: ${s}`),n}async hideLoader(){const e=await this.invoke({method:"hideLoader"}),t=this.validate(ie,e);let n;t&&this.logger.warn("hideLoader",`Unexpected raw response shape: ${t}`),n=I(e)?{status_code:204}:e;const s=this.validate(ce,n);return s&&this.logger.warn("hideLoader",`Unexpected response shape: ${s}`),n}async openExternalLink(e){const t=await this.invoke({method:"openExternalLink",params:{url:e}}),n=this.validate(ue,t);let s;n&&this.logger.warn("openExternalLink",`Unexpected raw response shape: ${n}`),s=I(t)?{status_code:204}:t;const r=this.validate(le,s);return r&&this.logger.warn("openExternalLink",`Unexpected response shape: ${r}`),s}async onCtaTap(e){const t=await this.invoke({method:"onCtaTap",params:{action:e}}),n=this.validate(de,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}}),s=this.validate(pe,n);let r;s&&this.logger.warn("sendAnalyticsEvent",`Unexpected raw response shape: ${s}`),r=I(n)?{status_code:204}:n;const o=this.validate(me,r);return o&&this.logger.warn("sendAnalyticsEvent",`Unexpected response shape: ${o}`),r}async isConnected(){return null!==A()?{status_code:200,result:{connected:!0}}:{status_code:404,error:"Not connected to Grab app"}}async getSessionParams(){const e=await this.invoke({method:"getSessionParams"}),t=this.validate(ye,e);return t&&this.logger.warn("getSessionParams",`Unexpected response shape: ${t}`),e}},e.DRMPlaybackEventSchema=ze,e.DeviceModule=class extends ${constructor(){super("DeviceModule")}async isEsimSupported(){const e=await this.invoke({method:"isEsimSupported"}),t=this.validate(Se,e);return t&&this.logger.warn("isEsimSupported",`Unexpected response shape: ${t}`),e}},e.DismissSplashScreenResponseSchema=it,e.DownloadFileRequestSchema=ke,e.DownloadFileResponseSchema=be,e.FetchEmailResponseSchema=Xe,e.FetchEmailResultSchema=Je,e.FileModule=class extends ${constructor(){super("FileModule")}async downloadFile(e){const t=this.validate(ke,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"downloadFile",params:e}),s=this.validate(be,n);return s&&this.logger.warn("downloadFile",`Unexpected response shape: ${s}`),n}},e.GetAuthorizationArtifactsResponseSchema=Te,e.GetAuthorizationArtifactsResultSchema=Ie,e.GetBooleanRequestSchema=lt,e.GetBooleanResponseSchema=ht,e.GetBooleanResultSchema=dt,e.GetCoordinateResponseSchema=De,e.GetCoordinateResultSchema=Le,e.GetCountryCodeResponseSchema=je,e.GetCountryCodeResultSchema=Ge,e.GetDoubleRequestSchema=bt,e.GetDoubleResponseSchema=xt,e.GetDoubleResultSchema=Rt,e.GetIntRequestSchema=mt,e.GetIntResponseSchema=ft,e.GetIntResultSchema=gt,e.GetLanguageLocaleIdentifierResponseSchema=Pe,e.GetLanguageLocaleIdentifierResultSchema=Be,e.GetSelectedTravelDestinationResponseSchema=Mt,e.GetSelectedTravelDestinationResultSchema=$t,e.GetSessionParamsResponseSchema=ye,e.GetSessionParamsResultSchema=ve,e.GetStringRequestSchema=yt,e.GetStringResponseSchema=St,e.GetStringResultSchema=wt,e.HasAccessToRequestSchema=st,e.HasAccessToResponseSchema=ot,e.HasAccessToResultSchema=rt,e.HideBackButtonResponseSchema=Y,e.HideLoaderResponseSchema=ce,e.HideRefreshButtonResponseSchema=Z,e.IdentityModule=Ne,e.IsConnectedResponseSchema=fe,e.IsConnectedResultSchema=ge,e.IsEsimSupportedResponseSchema=Se,e.IsEsimSupportedResultSchema=we,e.LocaleModule=class extends ${constructor(){super("LocaleModule")}async getLanguageLocaleIdentifier(){const e=await this.invoke({method:"getLanguageLocaleIdentifier"}),t=this.validate(Pe,e);return t&&this.logger.warn("getLanguageLocaleIdentifier",`Unexpected response shape: ${t}`),e}},e.LocationModule=class extends ${constructor(){super("LocationModule")}async getCoordinate(){const e=await this.invoke({method:"getCoordinate"}),t=this.validate(De,e);return t&&this.logger.warn("getCoordinate",`Unexpected response shape: ${t}`),e}observeLocationChange(){return this.invokeStream({method:"observeLocationChange"})}async getCountryCode(){const e=await this.invoke({method:"getCountryCode"}),t=this.validate(je,e);return t&&this.logger.warn("getCountryCode",`Unexpected response shape: ${t}`),e}},e.Logger=U,e.MediaModule=class extends ${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}})}},e.NetworkModule=class extends ${constructor(){super("NetworkModule")}async send(e){const t=this.validate(Ke,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"send",params:e}),s=this.validate(Ye,n);if(s&&this.logger.warn("send",`Unexpected raw response shape: ${s}`),M(n)&&T(n)&&"string"==typeof n.result)try{const e=JSON.parse(n.result),t={...n,result:e},s=this.validate(He,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(He,r);return o&&this.logger.warn("send",`Unexpected response shape: ${o}`),r}},e.ObserveDRMPlaybackResponseSchema=Fe,e.OnContentLoadedResponseSchema=re,e.OnCtaTapResponseSchema=de,e.OpenExternalLinkResponseSchema=le,e.PlatformModule=class extends ${constructor(){super("PlatformModule")}async back(){const e=await this.invoke({method:"back"}),t=this.validate(Qe,e);return t&&this.logger.warn("back",`Unexpected response shape: ${t}`),e}},e.PlayDRMContentResponseSchema=qe,e.ProfileModule=nt,e.RedirectToSystemWebViewRequestSchema=Ut,e.RedirectToSystemWebViewResponseSchema=At,e.ReloadScopesResponseSchema=at,e.RemoveAllResponseSchema=Et,e.RemoveResponseSchema=Ct,e.ScanQRCodeRequestSchema=L,e.ScanQRCodeResponseSchema=G,e.ScanQRCodeResultSchema=D,e.ScopeModule=class extends ${constructor(){super("ScopeModule")}async hasAccessTo(e,t){const n={module:e,method:t},s=this.validate(st,n);if(s)return{status_code:400,error:s};const r=await this.invoke({method:"hasAccessTo",params:n}),o=this.validate(ot,r);return o&&this.logger.warn("hasAccessTo",`Unexpected response shape: ${o}`),r}async reloadScopes(){const e=await this.invoke({method:"reloadScopes"}),t=this.validate(at,e);return t&&this.logger.warn("reloadScopes",`Unexpected response shape: ${t}`),e}},e.SendAnalyticsEventRequestSchema=he,e.SendAnalyticsEventResponseSchema=me,e.SendRequestSchema=Ke,e.SendResponseSchema=He,e.SendResultSchema=We,e.SetBackgroundColorResponseSchema=K,e.SetBooleanResponseSchema=ut,e.SetDoubleResponseSchema=kt,e.SetIntResponseSchema=pt,e.SetStringResponseSchema=vt,e.SetTitleResponseSchema=H,e.ShowBackButtonResponseSchema=J,e.ShowLoaderResponseSchema=ae,e.ShowRefreshButtonResponseSchema=te,e.SplashScreenModule=class extends ${constructor(){super("SplashScreenModule")}async dismiss(){const e=await this.invoke({method:"dismiss"}),t=this.validate(it,e);return t&&this.logger.warn("dismiss",`Unexpected response shape: ${t}`),e}},e.StorageModule=class extends ${constructor(){super("StorageModule")}async setBoolean(e,t){const n=await this.invoke({method:"setBoolean",params:{key:e,value:t}}),s=this.validate(ut,n);return s&&this.logger.warn("setBoolean",`Unexpected response shape: ${s}`),n}async getBoolean(e){const t={key:e},n=this.validate(lt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getBoolean",params:t}),r=this.validate(ht,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(pt,n);return s&&this.logger.warn("setInt",`Unexpected response shape: ${s}`),n}async getInt(e){const t={key:e},n=this.validate(mt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getInt",params:t}),r=this.validate(ft,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(vt,n);return s&&this.logger.warn("setString",`Unexpected response shape: ${s}`),n}async getString(e){const t={key:e},n=this.validate(yt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getString",params:t}),r=this.validate(St,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(kt,n);return s&&this.logger.warn("setDouble",`Unexpected response shape: ${s}`),n}async getDouble(e){const t={key:e},n=this.validate(bt,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"getDouble",params:t}),r=this.validate(xt,s);return r&&this.logger.warn("getDouble",`Unexpected response shape: ${r}`),s}async remove(e){const t={key:e},n=this.validate(_t,t);if(n)return{status_code:400,error:n};const s=await this.invoke({method:"remove",params:t}),r=this.validate(Ct,s);return r&&this.logger.warn("remove",`Unexpected response shape: ${r}`),s}async removeAll(){const e=await this.invoke({method:"removeAll"}),t=this.validate(Et,e);return t&&this.logger.warn("removeAll",`Unexpected response shape: ${t}`),e}},e.SystemWebViewKitModule=class extends ${constructor(){super("SystemWebViewKitModule")}async redirectToSystemWebView(e){const t=this.validate(Ut,e);if(t)return{status_code:400,error:t};const n=await this.invoke({method:"redirectToSystemWebView",params:e}),s=this.validate(At,n);return s&&this.logger.warn("redirectToSystemWebView",`Unexpected response shape: ${s}`),n}},e.TriggerCheckoutRequestSchema=j,e.TriggerCheckoutResponseSchema=q,e.TriggerCheckoutResultSchema=z,e.UserAttributesModule=class extends ${constructor(){super("UserAttributesModule")}async getSelectedTravelDestination(){const e=await this.invoke({method:"getSelectedTravelDestination"}),t=this.validate(Mt,e);return t&&this.logger.warn("getSelectedTravelDestination",`Unexpected response shape: ${t}`),e}},e.VerifyEmailRequestSchema=Ze,e.VerifyEmailResponseSchema=tt,e.VerifyEmailResultSchema=et,e.hasResult=T,e.isClientError=function(e){return e.status_code>=400&&e.status_code<500},e.isError=function(e){return e.status_code>=400&&e.status_code<600||"string"==typeof e.error&&e.error.length>0},e.isFound=function(e){return 302===e.status_code},e.isNoContent=function(e){return 204===e.status_code},e.isOk=I,e.isRedirection=function(e){return 302===e.status_code},e.isServerError=function(e){return e.status_code>=500&&e.status_code<600},e.isSuccess=M});
|
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.47",
|
|
4
4
|
"description": "SDK for Grab SuperApp WebView.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"fix": "npm run fix:format && npm run fix:lint",
|
|
37
37
|
"fix:format": "prettier --write .",
|
|
38
38
|
"fix:lint": "eslint . --fix",
|
|
39
|
+
"notify": "node scripts/notify-slack.mjs",
|
|
39
40
|
"prepare": "husky",
|
|
40
41
|
"prepublishOnly": "npm run build",
|
|
41
42
|
"test": "vitest run",
|