@yodlpay/react-native 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,6 +38,7 @@ const sdk = createSdk({
38
38
  - [Platform Notes](#platform-notes)
39
39
  - [Usage](#usage)
40
40
  - [Signup flow](#signup-flow)
41
+ - [Hosted UI theming](#hosted-ui-theming)
41
42
  - [Full example](#full-example)
42
43
  - [Optional EIP-7702 fallback](#optional-eip-7702-fallback)
43
44
  - [API Reference](#api-reference)
@@ -176,6 +177,82 @@ export function SignupScreen() {
176
177
 
177
178
  `<YodlSignup />` shows the Yodl signup flow and calls `onSignedUp` when the user is finished. The SDK does not expose account details from the hosted flow. If you need to remember that the user signed up, save completion in your own app state, storage, or backend.
178
179
 
180
+ ### Hosted UI theming
181
+
182
+ Theming is **opt-in**. Set `theme`, `themeMode`, or both on `<YodlProvider>` (or on any hosted component) to style the Yodl UI. Omit them and the hosted UI keeps its own appearance. Every field is optional.
183
+
184
+ ```tsx
185
+ import type { YodlTheme } from '@yodlpay/react-native';
186
+ import { YodlPayment, YodlProvider } from '@yodlpay/react-native';
187
+
188
+ // A small, representative subset of tokens — see "Tokens" for the full list.
189
+ const brandTheme: YodlTheme = {
190
+ name: 'acme',
191
+ light: { bg: '#ffffff', surface: '#f4f4f5', text: '#18181b', accent: '#6d4fc0' },
192
+ dark: { bg: '#18181b', surface: '#27272a', text: '#fafafa', accent: '#9662ff' },
193
+ images: {
194
+ light: { loading: 'https://cdn.example.com/yodl-loading-light.mp4' },
195
+ dark: { loading: 'https://cdn.example.com/yodl-loading-dark.mp4' },
196
+ },
197
+ };
198
+
199
+ <YodlProvider
200
+ sdk={sdk}
201
+ provider={provider}
202
+ address={address}
203
+ chainId={chainId}
204
+ theme={brandTheme}
205
+ themeMode="system"
206
+ >
207
+ <YodlPayment qrData={qrData} />
208
+ </YodlProvider>;
209
+ ```
210
+
211
+ #### Modes
212
+
213
+ `themeMode` is `'system'` (follow the device), `'light'`, or `'dark'`. The two props combine as:
214
+
215
+ | `theme` | `themeMode` | Result |
216
+ | --- | --- | --- |
217
+ | Omitted | Omitted | Hosted UI keeps its own appearance |
218
+ | Set | Omitted | Your palette, following the device |
219
+ | Omitted | Set | Stock Yodl palette, pinned to that mode |
220
+ | Set | Set | Your palette, pinned to that mode |
221
+
222
+ #### Defaults and overrides
223
+
224
+ - `theme` / `themeMode` on `<YodlProvider>` are defaults for every hosted component under it.
225
+ - The same props on `<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` override the provider **per prop** — set one and the other still inherits.
226
+ - Remove `theme` and `themeMode` from both the component and its provider to hand appearance control back to the hosted UI.
227
+
228
+ ```tsx
229
+ // Provider follows the device; this one screen pins dark but keeps the palette.
230
+ <YodlProvider sdk={sdk} provider={provider} address={address} chainId={chainId} theme={brandTheme}>
231
+ <YodlPayment qrData={qrData} themeMode="dark" />
232
+ </YodlProvider>;
233
+ ```
234
+
235
+ #### Tokens
236
+
237
+ `name` is an optional label (≤64 chars). Set colors per mode under `light` and `dark`; omitted tokens keep their stock value. The 21 keys:
238
+
239
+ - **Core:** `bg` `surface` `surfaceSecondary` `text` `textSecondary` `textMuted` `border` `success` `error` `warning` `accent`
240
+ - **Fine-tune** (derived from core when omitted): `bgDeep` `surfaceHover` `skeleton` `accentStrong` `accentDeep`
241
+ - **Brand:** `brandSurface` `brandSheet` `brandText` `brandButton` `brandButtonText`
242
+
243
+ #### Validation
244
+
245
+ - Colors must be `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb(…)`, or `rgba(…)`.
246
+ - Images go under `images.light` / `images.dark`, each with `payBackground`, `loading`, and `processing` slots (`processing` is only used when `loading` is unset). A `.mp4` URL plays as a looping muted video; anything else is an image.
247
+ - Image URLs must be `https://`, at most 2048 characters, with no whitespace, quotes, or backslashes.
248
+ - An invalid `theme` or `themeMode` never crashes — it falls back to stock Yodl and logs the error in `__DEV__`.
249
+
250
+ #### Live updates
251
+
252
+ Changing `theme` / `themeMode` on a mounted component applies over the bridge **without reloading** — the active flow keeps its state.
253
+
254
+ > **Compatibility.** `yodlUiBaseUrl` must point at a current hosted UI that supports correlated readiness. Against an older build the WebView never reveals and the loading spinner stays up. See [Troubleshooting](#troubleshooting).
255
+
179
256
  ### Full example
180
257
 
181
258
  **`sdk.ts`** — create the instance once, app-wide:
@@ -331,12 +408,27 @@ Supplies the SDK instance and wallet state to the components. Render it once, hi
331
408
  | `provider` | `EIP1193Provider` | Yes | EIP-1193 provider from any wallet SDK. Prefer the wallet's native EIP-5792 support; only if it lacks it, wrap with `withYodl7702(...)` for the [EIP-7702 fallback](#optional-eip-7702-fallback) |
332
409
  | `address` | `string` | Yes | Connected wallet address |
333
410
  | `chainId` | `number` | Yes | Chain ID the wallet is currently on |
411
+ | `theme` | `YodlTheme` | No | Default custom hosted-UI palette; all fields are optional |
412
+ | `themeMode` | `'system' \| 'light' \| 'dark'` | No | Default host-controlled mode |
334
413
 
335
414
  `address` and `chainId` are the wallet's **live** account and chain — pass them straight from your wallet SDK's hooks (e.g. `useWallets()`, `useAccount()`), not as fixed values. They tell the embedded Yodl UI who is connected and on which chain, and the SDK pushes `accountsChanged` / `chainChanged` into the UI whenever they change — so keep them updated when the user switches account or network. (The `provider` is used only as the RPC/signing transport.)
336
415
 
416
+ `theme` and `themeMode` are also available on `<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` as per-component overrides — along with `backgroundColor` and `style`. See [Shared visual props](#shared-visual-props) and [Hosted UI theming](#hosted-ui-theming).
417
+
418
+ ### Shared visual props
419
+
420
+ `<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` all accept the same visual props. They are listed here once rather than repeated in each component's table below.
421
+
422
+ | Prop | Type | Required | Description |
423
+ | ----------------- | ------------------------------- | -------- | --------------------------------------------------------------------------------- |
424
+ | `theme` | `YodlTheme` | No | Palette override; inherits the provider `theme` when omitted |
425
+ | `themeMode` | `'system' \| 'light' \| 'dark'` | No | Mode override; inherits the provider `themeMode` when omitted |
426
+ | `backgroundColor` | `string` | No | Color behind the WebView before first paint; overrides the theme background |
427
+ | `style` | `ViewStyle` | No | Container style |
428
+
337
429
  ### `<YodlSignup />`
338
430
 
339
- Renders the hosted signup flow. Use this as a full-screen component inside `<YodlProvider>`.
431
+ Renders the hosted signup flow. Use this as a full-screen component inside `<YodlProvider>`. Also accepts all [shared visual props](#shared-visual-props).
340
432
 
341
433
  | Prop | Type | Required | Description |
342
434
  | ---------------- | ---------------------------------------------------------------------------- | -------- | ----------------------------------------------------- |
@@ -344,11 +436,10 @@ Renders the hosted signup flow. Use this as a full-screen component inside `<Yod
344
436
  | `onSignedUp` | `() => void` | No | Called when signup completes |
345
437
  | `onDismiss` | `() => void` | No | Called when the hosted success screen is dismissed |
346
438
  | `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, or RPC errors |
347
- | `style` | `ViewStyle` | No | Container style |
348
439
 
349
440
  ### `<YodlPayment />`
350
441
 
351
- Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is empty or unsupported.
442
+ Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is empty or unsupported. Also accepts all [shared visual props](#shared-visual-props).
352
443
 
353
444
  | Prop | Type | Required | Description |
354
445
  | ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
@@ -356,18 +447,16 @@ Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is e
356
447
  | `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
357
448
  | `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
358
449
  | `onError` | `(error: Error) => void` | No | Called on RPC / payment errors |
359
- | `style` | `ViewStyle` | No | Container style |
360
450
 
361
451
  ### `<YodlDashboard />`
362
452
 
363
- Renders the full Yodl account dashboard.
453
+ Renders the full Yodl account dashboard. Also accepts all [shared visual props](#shared-visual-props).
364
454
 
365
455
  | Prop | Type | Required | Description |
366
456
  | ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
367
457
  | `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
368
458
  | `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
369
459
  | `onError` | `(error: Error) => void` | No | Called on RPC errors |
370
- | `style` | `ViewStyle` | No | Container style |
371
460
 
372
461
  ### Payment details events
373
462
 
@@ -390,6 +479,7 @@ The bridge forwards EIP-5792 (`wallet_sendCalls`, `wallet_getCallsStatus`, `wall
390
479
  | `Yodl components must be rendered inside <YodlProvider>` | A component is mounted outside the provider. Wrap it in `<YodlProvider>`. |
391
480
  | Payment screen renders blank | `qrData` isn't a Yodl payment QR. Guard with `isPaymentQr(qrData)` before rendering `<YodlPayment>`. |
392
481
  | `webview-action providers are not supported yet` | The scanned QR maps to a provider whose hosted webview flow isn't supported yet. Catch it (e.g. via `onError` or an error boundary) and prompt a retry. |
482
+ | Loading overlay never lifts (spinner stays forever) | The hosted UI at `yodlUiBaseUrl` doesn't support correlated readiness. Point it at a current hosted build. See [Hosted UI theming](#hosted-ui-theming). |
393
483
 
394
484
  ## License
395
485
 
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime"),n=require("react-native"),r=require("react-native-webview");const i=(0,e.createContext)(null);function a({sdk:n,provider:r,address:a,chainId:o,children:s}){let c=(0,e.useMemo)(()=>({sdk:n,provider:r,address:a,chainId:o,supportedChainIds:n.config.supportedChainIds}),[n,r,a,o]);return(0,t.jsx)(i.Provider,{value:c,children:s})}function o(){let t=(0,e.useContext)(i);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function s(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function c(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function l(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function u(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function d(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function f(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function p(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const m=/^0x[a-fA-F0-9]{40}$/;function h(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!m.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function g(e){return{"X-Yodl-Integration-Id":h(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.4.0`}}function _(e,t){let n=e.yodlUiBaseUrl?f(e.yodlUiBaseUrl):null;if(!(!n||!p(t,n)))return g(e)}function v(e){return`0x${e.toString(16)}`}function y(e,t=`unsupported`){let n={};for(let r of e)n[v(r)]={atomic:{status:t}};return n}const b=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function x(e){return b.some(t=>t===e)}function S(e,t,n){if(!x(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=u((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=v(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function C(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>u(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function w(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function T(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!w(t))return;let n=t.receipts;if(n?.length&&!n.some(T))return n[n.length-1]?.transactionHash}function D(e){let t=v(e.chainId);return`(function() {
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react-native"),n=require("react/jsx-runtime"),r=require("react-native-webview");const i=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*[\d.%\s,/]+\s*\))$/i,a=/^https:\/\/[^\s"\\]+$/,o=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],s=[`payBackground`,`processing`,`loading`];function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e,t){if(!c(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of o){let a=e[r];if(a!==void 0){if(typeof a!=`string`||!i.test(a))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=a}}return{success:!0,data:n}}function u(e,t){if(!c(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of s){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!a.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function d(e){if(!c(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=u(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function f(e){if(!c(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=l(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=d(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function p(e){return!c(e)||Object.keys(e).length!==3?!1:e.type===`yodl_ready`&&e.version===1&&typeof e.sessionId==`string`&&e.sessionId.length>=1&&e.sessionId.length<=128}const m={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function h(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function g(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:f(e),i=t===void 0||t===`system`||t===`light`||t===`dark`,a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:h(a,n)},error:o.length>0?o.join(`; `):null}}function _(e,t){let n=m[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function v(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function y(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function b(e,t){return JSON.stringify(y(e,t))}function x(e,t,n,r){let{envelope:i,error:a}=g(e,t,n);return a&&r?.(a),i}function S(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=g(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function C(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const w=(0,e.createContext)(null);function T({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>x(s,c,u,C),[s,c,u]),f=(0,e.useMemo)(()=>({sdk:r,provider:i,address:a,chainId:o,supportedChainIds:r.config.supportedChainIds,hostTheme:d,systemScheme:u}),[r,i,a,o,d,u]);return(0,n.jsx)(w.Provider,{value:f,children:l})}function E(){let t=(0,e.useContext)(w);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function D(t,n){let r=E(),i=(0,e.useMemo)(()=>S(r.hostTheme,t,n,r.systemScheme,C),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function O(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function k(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function A(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function j(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function M(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function ee(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function te(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const ne=/^0x[a-fA-F0-9]{40}$/;function N(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!ne.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function P(e){return{"X-Yodl-Integration-Id":N(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.5.1`}}function re(e,t){let n=e.yodlUiBaseUrl?ee(e.yodlUiBaseUrl):null;if(!(!n||!te(t,n)))return P(e)}let F=0;function ie(){return F+=1,`yodl-${Date.now().toString(36)}-${F.toString(36)}`}function ae(e,t=ie){return{sessionId:t(),initialHostTheme:e}}function I(e){return`0x${e.toString(16)}`}function oe(e,t=`unsupported`){let n={};for(let r of e)n[I(r)]={atomic:{status:t}};return n}const se=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function ce(e){return se.some(t=>t===e)}function le(e,t,n){if(!ce(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=j((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=I(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function ue(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>j(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function de(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function fe(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!de(t))return;let n=t.receipts;if(n?.length&&!n.some(fe))return n[n.length-1]?.transactionHash}function me(e){let t=I(e.chainId);return`(function() {
2
2
  if (window.ethereum) return;
3
3
 
4
4
  var _address = ${JSON.stringify(e.address.toLowerCase())};
@@ -225,4 +225,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
225
225
  announceProvider();
226
226
  window.addEventListener("eip6963:requestProvider", announceProvider);
227
227
  })();
228
- true;`}function O(e){return e.toLowerCase()}function k(e,t){let n=O(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:v(t.chainId)}}:{}}}function A(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function j(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function M(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:u,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g}=t,_=(0,e.useRef)(null),b=(0,e.useRef)(O(r)),w=(0,e.useRef)(i),T=(0,e.useRef)(i),M=(0,e.useRef)(new Set),N=(0,e.useCallback)(e=>{M.current.has(e)||(M.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=k({address:b.current,propChainId:w.current,activeChainId:T.current},{address:r,chainId:i});e&&(b.current=e.nextAddress,w.current=e.nextPropChainId,T.current=e.nextActiveChainId,e.accountsChanged&&j(_,`accountsChanged`,e.accountsChanged),e.chainChanged&&j(_,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]);let P=(0,e.useMemo)(()=>D({address:r,chainId:i}),[r,i]),F=(0,e.useCallback)(async(e,t,r)=>{try{let i=S(t,r,a);if(`error`in i){A(_,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),A(_,e,null),i.switchesActiveChain&&(T.current=i.requestedChainId,j(_,`chainChanged`,i.chainIdHex))}catch(t){let n=c(t,`Chain request failed`);A(_,e,void 0,l(n)),h?.(n)}},[n,a,h]),I=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>v(e))];A(_,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=c(n,`Capabilities unavailable`);if(!d(r)){A(_,e,void 0,l(r));return}A(_,e,y(C(t,a),`unsupported`))}},[n,r,a]),L=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=E(r);i&&N(i),A(_,e,r)}catch(t){A(_,e,void 0,l(c(t,`Failed to get call status`)))}},[n,N]),R=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&N(i),A(_,e,i)}catch(t){let n=c(t,`Request failed`),r=s(n);A(_,e,void 0,r?{code:4001,message:n.message}:l(n)),r||h?.(n)}},[n,N,h]);return{uiRef:_,injectedJavaScript:P,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_ready`){g?.();return}if(t.type===`yodl_payment_details`){u?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_status`){f?.(t.status);return}if(t.type===`yodl_signup_complete`){p?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_dismissed`){m?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;x(r)?F(n,r,i):r===`wallet_getCapabilities`?I(n,i):r===`wallet_getCallsStatus`?L(n,i):R(n,r,i)},[F,I,L,R,u,f,p,m,h,g])}}function N({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:m,onSignedUp:h,onSignupDismissed:g,onError:v,style:y,backgroundColor:b=`#18181b`,sharedCookiesEnabled:x=!0,thirdPartyCookiesEnabled:S=!0,...C}){let[w,T]=(0,e.useState)(!1),E=(0,e.useCallback)(()=>T(!0),[]),{uiRef:D,injectedJavaScript:O,onMessage:k}=M({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:E,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...m!==void 0&&{onSignupStatusChange:m},...h!==void 0&&{onSignedUp:h},...g!==void 0&&{onSignupDismissed:g},...v!==void 0&&{onError:v}});(0,e.useEffect)(()=>{if(w)return;let e=setTimeout(E,8e3);return()=>clearTimeout(e)},[w,E]);let A=(0,e.useMemo)(()=>f(i),[i]),j=(0,e.useMemo)(()=>{let e=_(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),N=(0,e.useMemo)(()=>e=>A?p(e.url,A)||e.url.startsWith(`about:`):!1,[A]);return(0,t.jsxs)(n.View,{style:[P.container,{backgroundColor:b},y],children:[(0,t.jsx)(r.WebView,{ref:D,source:j,originWhitelist:A?[A]:[],onShouldStartLoadWithRequest:N,javaScriptEnabled:!0,sharedCookiesEnabled:x,thirdPartyCookiesEnabled:S,injectedJavaScriptBeforeContentLoaded:O,onMessage:k,onLoadEnd:E,style:[P.ui,{backgroundColor:b}],...C}),w?null:(0,t.jsx)(n.View,{style:[P.overlay,{backgroundColor:b}],children:(0,t.jsx)(n.ActivityIndicator,{color:`#a1a1aa`})})]})}const P=n.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{...n.StyleSheet.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function F({onTransactionSent:n,onPaymentDetails:r,onError:i,style:a,backgroundColor:s}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=o();return(0,t.jsx)(N,{uri:(0,e.useMemo)(()=>f.config.yodlUiBaseUrl.replace(/\/$/,``),[f.config.yodlUiBaseUrl]),sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{style:a},...s!==void 0&&{backgroundColor:s}})}function I(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function L(e){if(Array.isArray(e))return e}function R(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ee(e,t,n){return t&&z(e.prototype,t),n&&z(e,n),e}function te(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ne(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function re(e,t){return L(e)||te(e,t)||ae(e,t)||ne()}function ie(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ae(e,t){if(e){if(typeof e==`string`)return I(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return I(e,t)}}var B=Object.defineProperty,oe=function(e,t,n){return t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},V=function(e,t){for(var n in t)B(e,n,{get:t[n],enumerable:!0})},H=function(e,t,n){return oe(e,(t===void 0?`undefined`:ie(t))===`symbol`?t:t+``,n)},se=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function ce(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=se[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function U(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function W(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=W(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function G(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=ce(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function K(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=G(e,n),e}function le(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function q(e,t){return{id:e,length:t.length,value:t}}function J(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[q(`00`,`A000000677010112`),q(`01`,t),q(`02`,r)];i&&o.push(q(`03`,i));var s=[q(`00`,`01`),q(`01`,n?`12`:`11`),q(`30`,W(o)),q(`53`,`764`),q(`58`,`TH`)];return n&&s.push(q(`54`,Number(n).toFixed(2))),a&&s.push(q(`62`,W([q(`07`,a)]))),K(W(s),`63`)}var ue=function(){"use strict";function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;R(this,e),H(this,`billerId`),H(this,`ref1`),H(this,`ref2`),H(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ee(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return J({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=re(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Y=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Y||{});function de(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=W([q(`00`,`A000000677010111`),q(Y[t],n)]),a=[q(`00`,`01`),q(`01`,r?`12`:`11`),q(`29`,i),q(`53`,`764`),q(`58`,`TH`)];return r&&a.push(q(`54`,Number(r).toFixed(2))),K(W(a),`63`)}V({},{ProxyType:function(){return Y},anyId:function(){return de},billPayment:function(){return J},botBarcode:function(){return fe},slipVerify:function(){return pe},trueMoney:function(){return he},trueMoneySlipVerify:function(){return ge}});function fe(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ue(t,n,r,i).toString()}function pe(e){var t=e.sendingBank,n=e.transRef;return K(W([q(`00`,W([q(`00`,`000001`),q(`01`,t),q(`02`,n)])),q(`51`,`TH`)]),`91`)}function me(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function he(e){var t=e.mobileNo,n=e.amount,r=e.message,i=W([q(`00`,`A000000677010111`),q(`03`,`14000${t}`)]),a=[q(`00`,`01`),q(`01`,n?`12`:`11`),q(`29`,i),q(`53`,`764`),q(`58`,`TH`)];return n&&a.push(q(`54`,Number(n).toFixed(2))),r&&a.push(q(`81`,me(r))),K(W(a),`63`)}function ge(e){var t=e.eventType,n=e.transactionId,r=e.date;return K(W([q(`00`,W([q(`00`,`01`),q(`01`,`01`),q(`02`,t),q(`03`,n),q(`04`,r)]))]),`91`,!1)}function X(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _e(e){if(Array.isArray(e))return e}function ve(e){if(Array.isArray(e))return X(e)}function ye(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function be(e,t,n){return t&&Z(e.prototype,t),n&&Z(e,n),e}function xe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Se(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Ce(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function we(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Te(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ee(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){xe(e,t,n[t])})}return e}function De(e,t){return _e(e)||Ce(e,t)||ke(e,t)||we()}function Oe(e){return ve(e)||Se(e)||ke(e)||Te()}function ke(e,t){if(e){if(typeof e==`string`)return X(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return X(e,t)}}V({},{anyId:function(){return Me},bcelOneProof:function(){return je},billPayment:function(){return Ne},slipVerify:function(){return Pe},trueMoneySlipVerify:function(){return Fe}});var Ae=function(){"use strict";function e(t,n){ye(this,e),H(this,`payload`),H(this,`tags`),this.payload=t,this.tags=n}return be(e,[{key:`getTag`,value:function(e,t){return le(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=K(W(Oe(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function Q(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=G(e.slice(0,-4)))return null;var r=U(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=U(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Ae(e,r)}function je(e){var t=Q(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Me(e){var t=Q(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Y).find(function(e){var n=De(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=De(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Ee({type:o,target:c},u!==void 0&&{amount:u})}function Ne(e){var t=Q(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Ee({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Pe(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=Q(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Fe(e){var t=Q(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Ie={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Le(e){return e?e.getTagValue(`58`)??null:null}function Re(e){let t=[];for(let[n,r]of Object.entries(Ie))r.includes(e)&&t.push(n);return t}function ze(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Le(Q(r));if(e){let n=Re(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Be(e,t){return!e||typeof e!=`string`||e.trim().length===0||!ze(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Ve({qrData:n,onTransactionSent:r,onPaymentDetails:i,onError:a,style:s,backgroundColor:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p}=o(),m=(0,e.useMemo)(()=>Be(n,p.config.yodlUiBaseUrl),[n,p.config.yodlUiBaseUrl]);return m?(0,t.jsx)(N,{uri:m,sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,...r!==void 0&&{onTransactionSent:r},...i!==void 0&&{onPaymentDetails:i},...a!==void 0&&{onError:a},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}}):null}function He(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Ue({onStatusChange:n,onSignedUp:r,onError:i,onDismiss:a,style:s,backgroundColor:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p}=o();return(0,t.jsx)(N,{uri:(0,e.useMemo)(()=>He(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]),sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,...n!==void 0&&{onSignupStatusChange:n},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function We(e){return(Array.isArray(e)?e:[e]).some(e=>ze(e).some(e=>e.action===`resolve`))}var $=class{config;constructor(e){let t=h(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function Ge(e){return new $(e)}exports.Yodl=$,exports.YodlDashboard=F,exports.YodlPayment=Ve,exports.YodlProvider=a,exports.YodlSignup=Ue,exports.createSdk=Ge,exports.isPaymentQr=We;
228
+ true;`}function he(e){return JSON.stringify(e)}function L(e){return{state:e,message:null,readyAccepted:!1}}function ge(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:b(e.sessionId,e.currentTheme),readyAccepted:t}}function _e(e,t){let n=he(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function ve(e,t){let n=he(t);if(n===e.currentFingerprint)return L(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?ge(r,!1):L(r)}function ye(e,t){return!p(t)||t.sessionId!==e.sessionId?L(e):ge({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function be(e){return e.toLowerCase()}function xe(e,t){let n=be(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:I(t.chainId)}}:{}}}function R(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function z(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Se(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:u,onError:d,onReady:f,sessionId:p,hostTheme:m=null,initialHostTheme:h=null}=t,g=(0,e.useRef)(null),_=(0,e.useRef)(be(r)),v=(0,e.useRef)(i),y=(0,e.useRef)(i),b=(0,e.useRef)(new Set),x=(0,e.useRef)(m),S=(0,e.useRef)(p?_e(p,h):null);(0,e.useLayoutEffect)(()=>{x.current=m},[m]),(0,e.useLayoutEffect)(()=>{S.current=p?_e(p,h):null},[h,p]);let C=(0,e.useCallback)(e=>{b.current.has(e)||(b.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=xe({address:_.current,propChainId:v.current,activeChainId:y.current},{address:r,chainId:i});e&&(_.current=e.nextAddress,v.current=e.nextPropChainId,y.current=e.nextActiveChainId,e.accountsChanged&&z(g,`accountsChanged`,e.accountsChanged),e.chainChanged&&z(g,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!S.current)return;let e=ve(S.current,m);S.current=e.state,e.message&&g.current?.postMessage(e.message)},[m]);let w=(0,e.useMemo)(()=>me({address:r,chainId:i}),[r,i]),T=(0,e.useCallback)(async(e,t,r)=>{try{let i=le(t,r,a);if(`error`in i){R(g,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),R(g,e,null),i.switchesActiveChain&&(y.current=i.requestedChainId,z(g,`chainChanged`,i.chainIdHex))}catch(t){let n=k(t,`Chain request failed`);R(g,e,void 0,A(n)),d?.(n)}},[n,a,d]),E=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>I(e))];R(g,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=k(n,`Capabilities unavailable`);if(!M(r)){R(g,e,void 0,A(r));return}R(g,e,oe(ue(t,a),`unsupported`))}},[n,r,a]),D=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=pe(r);i&&C(i),R(g,e,r)}catch(t){R(g,e,void 0,A(k(t,`Failed to get call status`)))}},[n,C]),j=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&C(i),R(g,e,i)}catch(t){let n=k(t,`Request failed`),r=O(n);R(g,e,void 0,r?{code:4001,message:n.message}:A(n)),r||d?.(n)}},[n,C,d]);return{uiRef:g,injectedJavaScript:w,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(!t||typeof t!=`object`||!(`type`in t))return;if(t.type===`yodl_ready`){if(!S.current){f?.();return}let e=ve(S.current,x.current);S.current=e.state,e.message&&g.current?.postMessage(e.message);let n=ye(S.current,t);if(S.current=n.state,!n.readyAccepted)return;n.message&&g.current?.postMessage(n.message),f?.();return}if(t.type===`yodl_payment_details`){s?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),d?.(n);return}if(t.type===`yodl_signup_status`){c?.(t.status);return}if(t.type===`yodl_signup_complete`){l?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),d?.(n);return}if(t.type===`yodl_signup_dismissed`){u?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;ce(r)?T(n,r,i):r===`wallet_getCapabilities`?E(n,i):r===`wallet_getCallsStatus`?D(n,i):j(n,r,i)},[T,E,D,j,s,c,l,u,d,f])}}function B(e){return(0,n.jsx)(Ce,{...e},e.uri)}function Ce({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,style:g,backgroundColor:y,hostTheme:b=null,sharedCookiesEnabled:x=!0,thirdPartyCookiesEnabled:S=!0,onLoadStart:C,...w}){let[T]=(0,e.useState)(()=>ae(b)),E=_(b,y),D=E.background,[O,k]=(0,e.useState)(null),A=O===T.sessionId,{uiRef:j,injectedJavaScript:M,onMessage:ne}=Se({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:(0,e.useCallback)(()=>{k(T.sessionId)},[T.sessionId]),sessionId:T.sessionId,hostTheme:b,initialHostTheme:T.initialHostTheme,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...f!==void 0&&{onSignupStatusChange:f},...p!==void 0&&{onSignedUp:p},...m!==void 0&&{onSignupDismissed:m},...h!==void 0&&{onError:h}}),N=(0,e.useMemo)(()=>ee(i),[i]),P=(0,e.useMemo)(()=>{let e=re(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),F=(0,e.useMemo)(()=>e=>!N||!e?.url?!1:te(e.url,N)||e.url.startsWith(`about:`),[N]);return(0,n.jsxs)(t.View,{style:[V.container,{backgroundColor:D},g],children:[(0,n.jsx)(r.WebView,{ref:j,source:P,originWhitelist:N?[N]:[],onShouldStartLoadWithRequest:F,javaScriptEnabled:!0,sharedCookiesEnabled:x,thirdPartyCookiesEnabled:S,injectedJavaScriptBeforeContentLoaded:M,injectedJavaScriptObject:v(T.sessionId,T.initialHostTheme,a.integrationAddress),onMessage:ne,...C!==void 0&&{onLoadStart:C},style:[V.ui,{backgroundColor:D}],...w}),A?null:(0,n.jsx)(t.View,{style:[V.overlay,{backgroundColor:D}],children:(0,n.jsx)(t.ActivityIndicator,{color:E.spinner})})]})}const V=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{...t.StyleSheet.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function we({onTransactionSent:t,onPaymentDetails:r,onError:i,style:a,backgroundColor:o,theme:s,themeMode:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p,hostTheme:m}=D(s,c);return(0,n.jsx)(B,{uri:(0,e.useMemo)(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]),sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,hostTheme:m,...t!==void 0&&{onTransactionSent:t},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}})}function H(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Te(e){if(Array.isArray(e))return e}function Ee(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function U(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function De(e,t,n){return t&&U(e.prototype,t),n&&U(e,n),e}function Oe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ke(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ae(e,t){return Te(e)||Oe(e,t)||Me(e,t)||ke()}function je(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function Me(e,t){if(e){if(typeof e==`string`)return H(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return H(e,t)}}var W=Object.defineProperty,Ne=function(e,t,n){return t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},G=function(e,t){for(var n in t)W(e,n,{get:t[n],enumerable:!0})},K=function(e,t,n){return Ne(e,(t===void 0?`undefined`:je(t))===`symbol`?t:t+``,n)},Pe=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function Fe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=Pe[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function Ie(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function q(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=q(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function Le(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Fe(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function J(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Le(e,n),e}function Re(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function Y(e,t){return{id:e,length:t.length,value:t}}function ze(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Y(`00`,`A000000677010112`),Y(`01`,t),Y(`02`,r)];i&&o.push(Y(`03`,i));var s=[Y(`00`,`01`),Y(`01`,n?`12`:`11`),Y(`30`,q(o)),Y(`53`,`764`),Y(`58`,`TH`)];return n&&s.push(Y(`54`,Number(n).toFixed(2))),a&&s.push(Y(`62`,q([Y(`07`,a)]))),J(q(s),`63`)}var Be=function(){"use strict";function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;Ee(this,e),K(this,`billerId`),K(this,`ref1`),K(this,`ref2`),K(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return De(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return ze({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=Ae(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),X=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(X||{});function Ve(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=q([Y(`00`,`A000000677010111`),Y(X[t],n)]),a=[Y(`00`,`01`),Y(`01`,r?`12`:`11`),Y(`29`,i),Y(`53`,`764`),Y(`58`,`TH`)];return r&&a.push(Y(`54`,Number(r).toFixed(2))),J(q(a),`63`)}G({},{ProxyType:function(){return X},anyId:function(){return Ve},billPayment:function(){return ze},botBarcode:function(){return He},slipVerify:function(){return Ue},trueMoney:function(){return Ge},trueMoneySlipVerify:function(){return Ke}});function He(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Be(t,n,r,i).toString()}function Ue(e){var t=e.sendingBank,n=e.transRef;return J(q([Y(`00`,q([Y(`00`,`000001`),Y(`01`,t),Y(`02`,n)])),Y(`51`,`TH`)]),`91`)}function We(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Ge(e){var t=e.mobileNo,n=e.amount,r=e.message,i=q([Y(`00`,`A000000677010111`),Y(`03`,`14000${t}`)]),a=[Y(`00`,`01`),Y(`01`,n?`12`:`11`),Y(`29`,i),Y(`53`,`764`),Y(`58`,`TH`)];return n&&a.push(Y(`54`,Number(n).toFixed(2))),r&&a.push(Y(`81`,We(r))),J(q(a),`63`)}function Ke(e){var t=e.eventType,n=e.transactionId,r=e.date;return J(q([Y(`00`,q([Y(`00`,`01`),Y(`01`,`01`),Y(`02`,t),Y(`03`,n),Y(`04`,r)]))]),`91`,!1)}function Z(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function qe(e){if(Array.isArray(e))return e}function Je(e){if(Array.isArray(e))return Z(e)}function Ye(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Q(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Xe(e,t,n){return t&&Q(e.prototype,t),n&&Q(e,n),e}function Ze(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function $e(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function et(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Ze(e,t,n[t])})}return e}function rt(e,t){return qe(e)||$e(e,t)||at(e,t)||et()}function it(e){return Je(e)||Qe(e)||at(e)||tt()}function at(e,t){if(e){if(typeof e==`string`)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}G({},{anyId:function(){return ct},bcelOneProof:function(){return st},billPayment:function(){return lt},slipVerify:function(){return ut},trueMoneySlipVerify:function(){return dt}});var ot=function(){"use strict";function e(t,n){Ye(this,e),K(this,`payload`),K(this,`tags`),this.payload=t,this.tags=n}return Xe(e,[{key:`getTag`,value:function(e,t){return Re(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=J(q(it(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Le(e.slice(0,-4)))return null;var r=Ie(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=Ie(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new ot(e,r)}function st(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function ct(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(X).find(function(e){var n=rt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=rt(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return nt({type:o,target:c},u!==void 0&&{amount:u})}function lt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return nt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function ut(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function dt(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const ft={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function pt(e){return e?e.getTagValue(`58`)??null:null}function mt(e){let t=[];for(let[n,r]of Object.entries(ft))r.includes(e)&&t.push(n);return t}function ht(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=pt($(r));if(e){let n=mt(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function gt(e,t){return!e||typeof e!=`string`||e.trim().length===0||!ht(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function _t({qrData:t,onTransactionSent:r,onPaymentDetails:i,onError:a,style:o,backgroundColor:s,theme:c,themeMode:l}){let{provider:u,address:d,chainId:f,supportedChainIds:p,sdk:m,hostTheme:h}=D(c,l),g=(0,e.useMemo)(()=>gt(t,m.config.yodlUiBaseUrl),[t,m.config.yodlUiBaseUrl]);return g?(0,n.jsx)(B,{uri:g,sdkConfig:m.config,provider:u,address:d,chainId:f,supportedChainIds:p,hostTheme:h,...r!==void 0&&{onTransactionSent:r},...i!==void 0&&{onPaymentDetails:i},...a!==void 0&&{onError:a},...o!==void 0&&{style:o},...s!==void 0&&{backgroundColor:s}}):null}function vt(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function yt({onStatusChange:t,onSignedUp:r,onError:i,onDismiss:a,style:o,backgroundColor:s,theme:c,themeMode:l}){let{provider:u,address:d,chainId:f,supportedChainIds:p,sdk:m,hostTheme:h}=D(c,l);return(0,n.jsx)(B,{uri:(0,e.useMemo)(()=>vt(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]),sdkConfig:m.config,provider:u,address:d,chainId:f,supportedChainIds:p,hostTheme:h,...t!==void 0&&{onSignupStatusChange:t},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...o!==void 0&&{style:o},...s!==void 0&&{backgroundColor:s}})}function bt(e){return(Array.isArray(e)?e:[e]).some(e=>ht(e).some(e=>e.action===`resolve`))}var xt=class{config;constructor(e){let t=N(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function St(e){return new xt(e)}exports.Yodl=xt,exports.YodlDashboard=we,exports.YodlPayment=_t,exports.YodlProvider=T,exports.YodlSignup=yt,exports.createSdk=St,exports.isPaymentQr=bt;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,89 @@
1
+ import { output, z } from "zod";
1
2
  import { ViewStyle } from "react-native";
2
3
  import { ReactNode } from "react";
3
4
 
5
+ //#region ../sdk-core/dist/validate-CNVgf-WX.d.mts
6
+ //#region src/theme/schemas.d.ts
7
+ /** What a host may ask for: an explicit mode, or "follow the host appearance". */
8
+ declare const yodlThemeModeSchema: z.ZodEnum<{
9
+ system: "system";
10
+ light: "light";
11
+ dark: "dark";
12
+ }>;
13
+ /** What `system` resolves to once the host appearance is known. */
14
+ /** One customizable Yodl theme: a light/dark palette pair plus optional media. */
15
+ declare const yodlThemeSchema: z.ZodObject<{
16
+ name: z.ZodOptional<z.ZodString>;
17
+ light: z.ZodOptional<z.ZodObject<{
18
+ bg: z.ZodOptional<z.ZodString>;
19
+ surface: z.ZodOptional<z.ZodString>;
20
+ surfaceSecondary: z.ZodOptional<z.ZodString>;
21
+ text: z.ZodOptional<z.ZodString>;
22
+ textSecondary: z.ZodOptional<z.ZodString>;
23
+ textMuted: z.ZodOptional<z.ZodString>;
24
+ border: z.ZodOptional<z.ZodString>;
25
+ success: z.ZodOptional<z.ZodString>;
26
+ error: z.ZodOptional<z.ZodString>;
27
+ warning: z.ZodOptional<z.ZodString>;
28
+ accent: z.ZodOptional<z.ZodString>;
29
+ bgDeep: z.ZodOptional<z.ZodString>;
30
+ surfaceHover: z.ZodOptional<z.ZodString>;
31
+ skeleton: z.ZodOptional<z.ZodString>;
32
+ accentStrong: z.ZodOptional<z.ZodString>;
33
+ accentDeep: z.ZodOptional<z.ZodString>;
34
+ brandSurface: z.ZodOptional<z.ZodString>;
35
+ brandSheet: z.ZodOptional<z.ZodString>;
36
+ brandText: z.ZodOptional<z.ZodString>;
37
+ brandButton: z.ZodOptional<z.ZodString>;
38
+ brandButtonText: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>>;
40
+ dark: z.ZodOptional<z.ZodObject<{
41
+ bg: z.ZodOptional<z.ZodString>;
42
+ surface: z.ZodOptional<z.ZodString>;
43
+ surfaceSecondary: z.ZodOptional<z.ZodString>;
44
+ text: z.ZodOptional<z.ZodString>;
45
+ textSecondary: z.ZodOptional<z.ZodString>;
46
+ textMuted: z.ZodOptional<z.ZodString>;
47
+ border: z.ZodOptional<z.ZodString>;
48
+ success: z.ZodOptional<z.ZodString>;
49
+ error: z.ZodOptional<z.ZodString>;
50
+ warning: z.ZodOptional<z.ZodString>;
51
+ accent: z.ZodOptional<z.ZodString>;
52
+ bgDeep: z.ZodOptional<z.ZodString>;
53
+ surfaceHover: z.ZodOptional<z.ZodString>;
54
+ skeleton: z.ZodOptional<z.ZodString>;
55
+ accentStrong: z.ZodOptional<z.ZodString>;
56
+ accentDeep: z.ZodOptional<z.ZodString>;
57
+ brandSurface: z.ZodOptional<z.ZodString>;
58
+ brandSheet: z.ZodOptional<z.ZodString>;
59
+ brandText: z.ZodOptional<z.ZodString>;
60
+ brandButton: z.ZodOptional<z.ZodString>;
61
+ brandButtonText: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$strip>>;
63
+ images: z.ZodOptional<z.ZodObject<{
64
+ light: z.ZodOptional<z.ZodObject<{
65
+ payBackground: z.ZodOptional<z.ZodString>;
66
+ processing: z.ZodOptional<z.ZodString>;
67
+ loading: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strip>>;
69
+ dark: z.ZodOptional<z.ZodObject<{
70
+ payBackground: z.ZodOptional<z.ZodString>;
71
+ processing: z.ZodOptional<z.ZodString>;
72
+ loading: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>>;
74
+ }, z.core.$strict>>;
75
+ }, z.core.$strip>;
76
+ /**
77
+ * The complete host-controlled theme state for one hosted session. `theme: null` means
78
+ * host-controlled stock Yodl, which is distinct from "no host authority at all" — the
79
+ * latter is expressed by not sending an envelope. Versioned so the protocol can change
80
+ * without silently misinterpreting older payloads.
81
+ */
82
+ //#endregion
83
+ //#region src/theme/contract.d.ts
84
+ type YodlThemeMode = output<typeof yodlThemeModeSchema>;
85
+ type YodlTheme = output<typeof yodlThemeSchema>;
86
+ //#endregion
4
87
  //#region src/types.d.ts
5
88
  /** Any JSON-RPC payload value — used wherever provider params/results cross the wire. */
6
89
  type JsonValue = string | number | boolean | null | JsonValue[] | {
@@ -73,6 +156,24 @@ interface YodlWallet {
73
156
  /** Chain IDs the wallet can switch to. */
74
157
  supportedChainIds: SupportedChainIds;
75
158
  }
159
+ /**
160
+ * Optional host-owned theming for the hosted Yodl UI. Both props are optional and
161
+ * independent: supplying either one puts the host in charge of the hosted theme;
162
+ * omitting both leaves the Yodl UI's own theme behavior untouched.
163
+ */
164
+ interface YodlHostThemeProps {
165
+ /**
166
+ * A light/dark palette pair (plus optional media) applied to the hosted Yodl UI.
167
+ * Without `themeMode` it follows the device appearance. Keep the object stable
168
+ * across renders (module constant or memo) to avoid redundant theme updates.
169
+ */
170
+ theme?: YodlTheme;
171
+ /**
172
+ * Which mode the hosted UI paints: `'system'` follows the device appearance,
173
+ * `'light'`/`'dark'` pin it. Supplied without `theme`, it controls stock Yodl.
174
+ */
175
+ themeMode?: YodlThemeMode;
176
+ }
76
177
  /** Event callbacks shared by the Yodl UI components and the underlying hook. */
77
178
  interface YodlEventHandlers {
78
179
  /** Called after a transaction is sent. */
@@ -83,7 +184,7 @@ interface YodlEventHandlers {
83
184
  onError?: (error: Error) => void;
84
185
  }
85
186
  /** Visual props shared by all Yodl UI components. */
86
- interface YodlVisualProps {
187
+ interface YodlVisualProps extends YodlHostThemeProps {
87
188
  style?: ViewStyle;
88
189
  /**
89
190
  * Color painted behind the WebView and in the loading overlay while the Yodl
@@ -107,7 +208,9 @@ declare function YodlDashboard({
107
208
  onPaymentDetails,
108
209
  onError,
109
210
  style,
110
- backgroundColor
211
+ backgroundColor,
212
+ theme,
213
+ themeMode
111
214
  }: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
112
215
  //#endregion
113
216
  //#region src/components/YodlPayment.d.ts
@@ -127,7 +230,9 @@ declare function YodlPayment({
127
230
  onPaymentDetails,
128
231
  onError,
129
232
  style,
130
- backgroundColor
233
+ backgroundColor,
234
+ theme,
235
+ themeMode
131
236
  }: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
132
237
  //#endregion
133
238
  //#region src/components/YodlSignup.d.ts
@@ -152,7 +257,9 @@ declare function YodlSignup({
152
257
  onError,
153
258
  onDismiss,
154
259
  style,
155
- backgroundColor
260
+ backgroundColor,
261
+ theme,
262
+ themeMode
156
263
  }: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
157
264
  //#endregion
158
265
  //#region src/sdk/yodl.d.ts
@@ -192,7 +299,7 @@ declare class Yodl {
192
299
  declare function createSdk(config: YodlConfig): Yodl;
193
300
  //#endregion
194
301
  //#region src/provider/context.d.ts
195
- interface YodlProviderProps {
302
+ interface YodlProviderProps extends YodlHostThemeProps {
196
303
  /** The SDK instance created via createSdk(). */
197
304
  sdk: Yodl;
198
305
  /** EIP-1193 provider from the host wallet SDK. */
@@ -204,14 +311,16 @@ interface YodlProviderProps {
204
311
  children: ReactNode;
205
312
  }
206
313
  /**
207
- * Supplies the SDK instance and runtime wallet state (provider/address/chainId)
208
- * to the Yodl components via React context.
314
+ * Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
315
+ * the optional host theme state to the Yodl components via React context.
209
316
  */
210
317
  declare function YodlProvider({
211
318
  sdk,
212
319
  provider,
213
320
  address,
214
321
  chainId,
322
+ theme,
323
+ themeMode,
215
324
  children
216
325
  }: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
217
326
  //#endregion
@@ -227,4 +336,4 @@ declare function YodlProvider({
227
336
  */
228
337
  declare function isPaymentQr(qrData: string | string[]): boolean;
229
338
  //#endregion
230
- export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, createSdk, isPaymentQr };
339
+ export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,89 @@
1
1
  import { ReactNode } from "react";
2
2
  import { ViewStyle } from "react-native";
3
+ import { output, z } from "zod";
3
4
 
5
+ //#region ../sdk-core/dist/validate-CNVgf-WX.d.mts
6
+ //#region src/theme/schemas.d.ts
7
+ /** What a host may ask for: an explicit mode, or "follow the host appearance". */
8
+ declare const yodlThemeModeSchema: z.ZodEnum<{
9
+ system: "system";
10
+ light: "light";
11
+ dark: "dark";
12
+ }>;
13
+ /** What `system` resolves to once the host appearance is known. */
14
+ /** One customizable Yodl theme: a light/dark palette pair plus optional media. */
15
+ declare const yodlThemeSchema: z.ZodObject<{
16
+ name: z.ZodOptional<z.ZodString>;
17
+ light: z.ZodOptional<z.ZodObject<{
18
+ bg: z.ZodOptional<z.ZodString>;
19
+ surface: z.ZodOptional<z.ZodString>;
20
+ surfaceSecondary: z.ZodOptional<z.ZodString>;
21
+ text: z.ZodOptional<z.ZodString>;
22
+ textSecondary: z.ZodOptional<z.ZodString>;
23
+ textMuted: z.ZodOptional<z.ZodString>;
24
+ border: z.ZodOptional<z.ZodString>;
25
+ success: z.ZodOptional<z.ZodString>;
26
+ error: z.ZodOptional<z.ZodString>;
27
+ warning: z.ZodOptional<z.ZodString>;
28
+ accent: z.ZodOptional<z.ZodString>;
29
+ bgDeep: z.ZodOptional<z.ZodString>;
30
+ surfaceHover: z.ZodOptional<z.ZodString>;
31
+ skeleton: z.ZodOptional<z.ZodString>;
32
+ accentStrong: z.ZodOptional<z.ZodString>;
33
+ accentDeep: z.ZodOptional<z.ZodString>;
34
+ brandSurface: z.ZodOptional<z.ZodString>;
35
+ brandSheet: z.ZodOptional<z.ZodString>;
36
+ brandText: z.ZodOptional<z.ZodString>;
37
+ brandButton: z.ZodOptional<z.ZodString>;
38
+ brandButtonText: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>>;
40
+ dark: z.ZodOptional<z.ZodObject<{
41
+ bg: z.ZodOptional<z.ZodString>;
42
+ surface: z.ZodOptional<z.ZodString>;
43
+ surfaceSecondary: z.ZodOptional<z.ZodString>;
44
+ text: z.ZodOptional<z.ZodString>;
45
+ textSecondary: z.ZodOptional<z.ZodString>;
46
+ textMuted: z.ZodOptional<z.ZodString>;
47
+ border: z.ZodOptional<z.ZodString>;
48
+ success: z.ZodOptional<z.ZodString>;
49
+ error: z.ZodOptional<z.ZodString>;
50
+ warning: z.ZodOptional<z.ZodString>;
51
+ accent: z.ZodOptional<z.ZodString>;
52
+ bgDeep: z.ZodOptional<z.ZodString>;
53
+ surfaceHover: z.ZodOptional<z.ZodString>;
54
+ skeleton: z.ZodOptional<z.ZodString>;
55
+ accentStrong: z.ZodOptional<z.ZodString>;
56
+ accentDeep: z.ZodOptional<z.ZodString>;
57
+ brandSurface: z.ZodOptional<z.ZodString>;
58
+ brandSheet: z.ZodOptional<z.ZodString>;
59
+ brandText: z.ZodOptional<z.ZodString>;
60
+ brandButton: z.ZodOptional<z.ZodString>;
61
+ brandButtonText: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$strip>>;
63
+ images: z.ZodOptional<z.ZodObject<{
64
+ light: z.ZodOptional<z.ZodObject<{
65
+ payBackground: z.ZodOptional<z.ZodString>;
66
+ processing: z.ZodOptional<z.ZodString>;
67
+ loading: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strip>>;
69
+ dark: z.ZodOptional<z.ZodObject<{
70
+ payBackground: z.ZodOptional<z.ZodString>;
71
+ processing: z.ZodOptional<z.ZodString>;
72
+ loading: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>>;
74
+ }, z.core.$strict>>;
75
+ }, z.core.$strip>;
76
+ /**
77
+ * The complete host-controlled theme state for one hosted session. `theme: null` means
78
+ * host-controlled stock Yodl, which is distinct from "no host authority at all" — the
79
+ * latter is expressed by not sending an envelope. Versioned so the protocol can change
80
+ * without silently misinterpreting older payloads.
81
+ */
82
+ //#endregion
83
+ //#region src/theme/contract.d.ts
84
+ type YodlThemeMode = output<typeof yodlThemeModeSchema>;
85
+ type YodlTheme = output<typeof yodlThemeSchema>;
86
+ //#endregion
4
87
  //#region src/types.d.ts
5
88
  /** Any JSON-RPC payload value — used wherever provider params/results cross the wire. */
6
89
  type JsonValue = string | number | boolean | null | JsonValue[] | {
@@ -73,6 +156,24 @@ interface YodlWallet {
73
156
  /** Chain IDs the wallet can switch to. */
74
157
  supportedChainIds: SupportedChainIds;
75
158
  }
159
+ /**
160
+ * Optional host-owned theming for the hosted Yodl UI. Both props are optional and
161
+ * independent: supplying either one puts the host in charge of the hosted theme;
162
+ * omitting both leaves the Yodl UI's own theme behavior untouched.
163
+ */
164
+ interface YodlHostThemeProps {
165
+ /**
166
+ * A light/dark palette pair (plus optional media) applied to the hosted Yodl UI.
167
+ * Without `themeMode` it follows the device appearance. Keep the object stable
168
+ * across renders (module constant or memo) to avoid redundant theme updates.
169
+ */
170
+ theme?: YodlTheme;
171
+ /**
172
+ * Which mode the hosted UI paints: `'system'` follows the device appearance,
173
+ * `'light'`/`'dark'` pin it. Supplied without `theme`, it controls stock Yodl.
174
+ */
175
+ themeMode?: YodlThemeMode;
176
+ }
76
177
  /** Event callbacks shared by the Yodl UI components and the underlying hook. */
77
178
  interface YodlEventHandlers {
78
179
  /** Called after a transaction is sent. */
@@ -83,7 +184,7 @@ interface YodlEventHandlers {
83
184
  onError?: (error: Error) => void;
84
185
  }
85
186
  /** Visual props shared by all Yodl UI components. */
86
- interface YodlVisualProps {
187
+ interface YodlVisualProps extends YodlHostThemeProps {
87
188
  style?: ViewStyle;
88
189
  /**
89
190
  * Color painted behind the WebView and in the loading overlay while the Yodl
@@ -107,7 +208,9 @@ declare function YodlDashboard({
107
208
  onPaymentDetails,
108
209
  onError,
109
210
  style,
110
- backgroundColor
211
+ backgroundColor,
212
+ theme,
213
+ themeMode
111
214
  }: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
112
215
  //#endregion
113
216
  //#region src/components/YodlPayment.d.ts
@@ -127,7 +230,9 @@ declare function YodlPayment({
127
230
  onPaymentDetails,
128
231
  onError,
129
232
  style,
130
- backgroundColor
233
+ backgroundColor,
234
+ theme,
235
+ themeMode
131
236
  }: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
132
237
  //#endregion
133
238
  //#region src/components/YodlSignup.d.ts
@@ -152,7 +257,9 @@ declare function YodlSignup({
152
257
  onError,
153
258
  onDismiss,
154
259
  style,
155
- backgroundColor
260
+ backgroundColor,
261
+ theme,
262
+ themeMode
156
263
  }: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
157
264
  //#endregion
158
265
  //#region src/sdk/yodl.d.ts
@@ -192,7 +299,7 @@ declare class Yodl {
192
299
  declare function createSdk(config: YodlConfig): Yodl;
193
300
  //#endregion
194
301
  //#region src/provider/context.d.ts
195
- interface YodlProviderProps {
302
+ interface YodlProviderProps extends YodlHostThemeProps {
196
303
  /** The SDK instance created via createSdk(). */
197
304
  sdk: Yodl;
198
305
  /** EIP-1193 provider from the host wallet SDK. */
@@ -204,14 +311,16 @@ interface YodlProviderProps {
204
311
  children: ReactNode;
205
312
  }
206
313
  /**
207
- * Supplies the SDK instance and runtime wallet state (provider/address/chainId)
208
- * to the Yodl components via React context.
314
+ * Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
315
+ * the optional host theme state to the Yodl components via React context.
209
316
  */
210
317
  declare function YodlProvider({
211
318
  sdk,
212
319
  provider,
213
320
  address,
214
321
  chainId,
322
+ theme,
323
+ themeMode,
215
324
  children
216
325
  }: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
217
326
  //#endregion
@@ -227,4 +336,4 @@ declare function YodlProvider({
227
336
  */
228
337
  declare function isPaymentQr(qrData: string | string[]): boolean;
229
338
  //#endregion
230
- export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, createSdk, isPaymentQr };
339
+ export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{createContext as e,useCallback as t,useContext as n,useEffect as r,useMemo as i,useRef as a,useState as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{ActivityIndicator as l,StyleSheet as u,View as d}from"react-native";import{WebView as f}from"react-native-webview";const p=e(null);function m({sdk:e,provider:t,address:n,chainId:r,children:a}){let o=i(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds}),[e,t,n,r]);return s(p.Provider,{value:o,children:a})}function h(){let e=n(p);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function g(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function _(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function v(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function y(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function b(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function x(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function S(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const C=/^0x[a-fA-F0-9]{40}$/;function w(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!C.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function T(e){return{"X-Yodl-Integration-Id":w(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.4.0`}}function E(e,t){let n=e.yodlUiBaseUrl?x(e.yodlUiBaseUrl):null;if(!(!n||!S(t,n)))return T(e)}function D(e){return`0x${e.toString(16)}`}function O(e,t=`unsupported`){let n={};for(let r of e)n[D(r)]={atomic:{status:t}};return n}const k=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function A(e){return k.some(t=>t===e)}function j(e,t,n){if(!A(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=y((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=D(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function ee(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>y(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function M(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function N(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function P(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!M(t))return;let n=t.receipts;if(n?.length&&!n.some(N))return n[n.length-1]?.transactionHash}function F(e){let t=D(e.chainId);return`(function() {
1
+ import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{WebView as m}from"react-native-webview";const h=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*[\d.%\s,/]+\s*\))$/i,g=/^https:\/\/[^\s"\\]+$/,_=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],v=[`payBackground`,`processing`,`loading`];function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b(e,t){if(!y(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of _){let i=e[r];if(i!==void 0){if(typeof i!=`string`||!h.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function x(e,t){if(!y(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of v){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!g.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function S(e){if(!y(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=x(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function C(e){if(!y(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=b(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=S(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function w(e){return!y(e)||Object.keys(e).length!==3?!1:e.type===`yodl_ready`&&e.version===1&&typeof e.sessionId==`string`&&e.sessionId.length>=1&&e.sessionId.length<=128}const T={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function E(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function D(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:C(e),i=t===void 0||t===`system`||t===`light`||t===`dark`,a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:E(a,n)},error:o.length>0?o.join(`; `):null}}function ee(e,t){let n=T[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function O(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function k(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function A(e,t){return JSON.stringify(k(e,t))}function j(e,t,n,r){let{envelope:i,error:a}=D(e,t,n);return a&&r?.(a),i}function te(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=D(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function M(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const N=e(null);function ne({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>j(i,o,c,M),[i,o,c]),u=a(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds,hostTheme:l,systemScheme:c}),[e,t,n,r,l,c]);return f(N.Provider,{value:u,children:s})}function re(){let e=n(N);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function P(e,t){let n=re(),r=a(()=>te(n.hostTheme,e,t,n.systemScheme,M),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function ie(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function F(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function I(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function ae(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function oe(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function se(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function ce(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const le=/^0x[a-fA-F0-9]{40}$/;function L(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!le.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function ue(e){return{"X-Yodl-Integration-Id":L(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.5.1`}}function de(e,t){let n=e.yodlUiBaseUrl?se(e.yodlUiBaseUrl):null;if(!(!n||!ce(t,n)))return ue(e)}let fe=0;function pe(){return fe+=1,`yodl-${Date.now().toString(36)}-${fe.toString(36)}`}function me(e,t=pe){return{sessionId:t(),initialHostTheme:e}}function R(e){return`0x${e.toString(16)}`}function he(e,t=`unsupported`){let n={};for(let r of e)n[R(r)]={atomic:{status:t}};return n}const ge=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function _e(e){return ge.some(t=>t===e)}function ve(e,t,n){if(!_e(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=ae((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=R(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function ye(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>ae(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function be(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function xe(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!be(t))return;let n=t.receipts;if(n?.length&&!n.some(xe))return n[n.length-1]?.transactionHash}function Ce(e){let t=R(e.chainId);return`(function() {
2
2
  if (window.ethereum) return;
3
3
 
4
4
  var _address = ${JSON.stringify(e.address.toLowerCase())};
@@ -225,4 +225,4 @@ import{createContext as e,useCallback as t,useContext as n,useEffect as r,useMem
225
225
  announceProvider();
226
226
  window.addEventListener("eip6963:requestProvider", announceProvider);
227
227
  })();
228
- true;`}function I(e){return e.toLowerCase()}function te(e,t){let n=I(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:D(t.chainId)}}:{}}}function L(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function R(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function z(e){let{provider:n,address:o,chainId:s,supportedChainIds:c,onTransactionSent:l,onPaymentDetails:u,onSignupStatusChange:d,onSignedUp:f,onSignupDismissed:p,onError:m,onReady:h}=e,y=a(null),x=a(I(o)),S=a(s),C=a(s),w=a(new Set),T=t(e=>{w.current.has(e)||(w.current.add(e),l?.(e))},[l]);r(()=>{let e=te({address:x.current,propChainId:S.current,activeChainId:C.current},{address:o,chainId:s});e&&(x.current=e.nextAddress,S.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&R(y,`accountsChanged`,e.accountsChanged),e.chainChanged&&R(y,`chainChanged`,e.chainChanged.chainIdHex))},[o,s]);let E=i(()=>F({address:o,chainId:s}),[o,s]),k=t(async(e,t,r)=>{try{let i=j(t,r,c);if(`error`in i){L(y,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),L(y,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,R(y,`chainChanged`,i.chainIdHex))}catch(t){let n=_(t,`Chain request failed`);L(y,e,void 0,v(n)),m?.(n)}},[n,c,m]),M=t(async(e,t)=>{try{let r=t.length>0?t:[o,c.map(e=>D(e))];L(y,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=_(n,`Capabilities unavailable`);if(!b(r)){L(y,e,void 0,v(r));return}L(y,e,O(ee(t,c),`unsupported`))}},[n,o,c]),N=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=P(r);i&&T(i),L(y,e,r)}catch(t){L(y,e,void 0,v(_(t,`Failed to get call status`)))}},[n,T]),z=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&T(i),L(y,e,i)}catch(t){let n=_(t,`Request failed`),r=g(n);L(y,e,void 0,r?{code:4001,message:n.message}:v(n)),r||m?.(n)}},[n,T,m]);return{uiRef:y,injectedJavaScript:E,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_ready`){h?.();return}if(t.type===`yodl_payment_details`){u?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),m?.(n);return}if(t.type===`yodl_signup_status`){d?.(t.status);return}if(t.type===`yodl_signup_complete`){f?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),m?.(n);return}if(t.type===`yodl_signup_dismissed`){p?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;A(r)?k(n,r,i):r===`wallet_getCapabilities`?M(n,i):r===`wallet_getCallsStatus`?N(n,i):z(n,r,i)},[k,M,N,z,u,d,f,p,m,h])}}function B({uri:e,sdkConfig:n,provider:a,address:u,chainId:p,supportedChainIds:m,onTransactionSent:h,onPaymentDetails:g,onSignupStatusChange:_,onSignedUp:v,onSignupDismissed:y,onError:b,style:C,backgroundColor:w=`#18181b`,sharedCookiesEnabled:T=!0,thirdPartyCookiesEnabled:D=!0,...O}){let[k,A]=o(!1),j=t(()=>A(!0),[]),{uiRef:ee,injectedJavaScript:M,onMessage:N}=z({provider:a,address:u,chainId:p,supportedChainIds:m,onReady:j,...h!==void 0&&{onTransactionSent:h},...g!==void 0&&{onPaymentDetails:g},..._!==void 0&&{onSignupStatusChange:_},...v!==void 0&&{onSignedUp:v},...y!==void 0&&{onSignupDismissed:y},...b!==void 0&&{onError:b}});r(()=>{if(k)return;let e=setTimeout(j,8e3);return()=>clearTimeout(e)},[k,j]);let P=i(()=>x(e),[e]),F=i(()=>{let t=E(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),I=i(()=>e=>P?S(e.url,P)||e.url.startsWith(`about:`):!1,[P]);return c(d,{style:[V.container,{backgroundColor:w},C],children:[s(f,{ref:ee,source:F,originWhitelist:P?[P]:[],onShouldStartLoadWithRequest:I,javaScriptEnabled:!0,sharedCookiesEnabled:T,thirdPartyCookiesEnabled:D,injectedJavaScriptBeforeContentLoaded:M,onMessage:N,onLoadEnd:j,style:[V.ui,{backgroundColor:w}],...O}),k?null:s(d,{style:[V.overlay,{backgroundColor:w}],children:s(l,{color:`#a1a1aa`})})]})}const V=u.create({container:{flex:1},ui:{flex:1},overlay:{...u.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function ne({onTransactionSent:e,onPaymentDetails:t,onError:n,style:r,backgroundColor:a}){let{provider:o,address:c,chainId:l,supportedChainIds:u,sdk:d}=h();return s(B,{uri:i(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]),sdkConfig:d.config,provider:o,address:c,chainId:l,supportedChainIds:u,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{style:r},...a!==void 0&&{backgroundColor:a}})}function H(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function re(e){if(Array.isArray(e))return e}function ie(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ae(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t,n){return t&&ae(e.prototype,t),n&&ae(e,n),e}function se(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ce(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function le(e,t){return re(e)||se(e,t)||de(e,t)||ce()}function ue(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function de(e,t){if(e){if(typeof e==`string`)return H(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return H(e,t)}}var fe=Object.defineProperty,pe=function(e,t,n){return t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},me=function(e,t){for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},U=function(e,t,n){return pe(e,(t===void 0?`undefined`:ue(t))===`symbol`?t:t+``,n)},he=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function ge(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=he[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function W(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function G(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=G(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function K(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=ge(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function q(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=K(e,n),e}function _e(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function J(e,t){return{id:e,length:t.length,value:t}}function Y(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[J(`00`,`A000000677010112`),J(`01`,t),J(`02`,r)];i&&o.push(J(`03`,i));var s=[J(`00`,`01`),J(`01`,n?`12`:`11`),J(`30`,G(o)),J(`53`,`764`),J(`58`,`TH`)];return n&&s.push(J(`54`,Number(n).toFixed(2))),a&&s.push(J(`62`,G([J(`07`,a)]))),q(G(s),`63`)}var ve=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;ie(this,e),U(this,`billerId`),U(this,`ref1`),U(this,`ref2`),U(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return oe(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return Y({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=le(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),X=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(X||{});function ye(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=G([J(`00`,`A000000677010111`),J(X[t],n)]),a=[J(`00`,`01`),J(`01`,r?`12`:`11`),J(`29`,i),J(`53`,`764`),J(`58`,`TH`)];return r&&a.push(J(`54`,Number(r).toFixed(2))),q(G(a),`63`)}me({},{ProxyType:function(){return X},anyId:function(){return ye},billPayment:function(){return Y},botBarcode:function(){return be},slipVerify:function(){return xe},trueMoney:function(){return Ce},trueMoneySlipVerify:function(){return we}});function be(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ve(t,n,r,i).toString()}function xe(e){var t=e.sendingBank,n=e.transRef;return q(G([J(`00`,G([J(`00`,`000001`),J(`01`,t),J(`02`,n)])),J(`51`,`TH`)]),`91`)}function Se(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Ce(e){var t=e.mobileNo,n=e.amount,r=e.message,i=G([J(`00`,`A000000677010111`),J(`03`,`14000${t}`)]),a=[J(`00`,`01`),J(`01`,n?`12`:`11`),J(`29`,i),J(`53`,`764`),J(`58`,`TH`)];return n&&a.push(J(`54`,Number(n).toFixed(2))),r&&a.push(J(`81`,Se(r))),q(G(a),`63`)}function we(e){var t=e.eventType,n=e.transactionId,r=e.date;return q(G([J(`00`,G([J(`00`,`01`),J(`01`,`01`),J(`02`,t),J(`03`,n),J(`04`,r)]))]),`91`,!1)}function Z(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Te(e){if(Array.isArray(e))return e}function Ee(e){if(Array.isArray(e))return Z(e)}function De(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Oe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ke(e,t,n){return t&&Oe(e.prototype,t),n&&Oe(e,n),e}function Ae(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function je(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Me(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Ne(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pe(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Ae(e,t,n[t])})}return e}function Q(e,t){return Te(e)||Me(e,t)||Le(e,t)||Ne()}function Ie(e){return Ee(e)||je(e)||Le(e)||Pe()}function Le(e,t){if(e){if(typeof e==`string`)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}me({},{anyId:function(){return Be},bcelOneProof:function(){return ze},billPayment:function(){return Ve},slipVerify:function(){return He},trueMoneySlipVerify:function(){return Ue}});var Re=function(){function e(t,n){De(this,e),U(this,`payload`),U(this,`tags`),this.payload=t,this.tags=n}return ke(e,[{key:`getTag`,value:function(e,t){return _e(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=q(G(Ie(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=K(e.slice(0,-4)))return null;var r=W(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=W(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Re(e,r)}function ze(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Be(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(X).find(function(e){var n=Q(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Q(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Fe({type:o,target:c},u!==void 0&&{amount:u})}function Ve(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Fe({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function He(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Ue(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const We={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Ge(e){return e?e.getTagValue(`58`)??null:null}function Ke(e){let t=[];for(let[n,r]of Object.entries(We))r.includes(e)&&t.push(n);return t}function qe(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Ge($(r));if(e){let n=Ke(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Je(e,t){return!e||typeof e!=`string`||e.trim().length===0||!qe(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Ye({qrData:e,onTransactionSent:t,onPaymentDetails:n,onError:r,style:a,backgroundColor:o}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=h(),p=i(()=>Je(e,f.config.yodlUiBaseUrl),[e,f.config.yodlUiBaseUrl]);return p?s(B,{uri:p,sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...r!==void 0&&{onError:r},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}}):null}function Xe(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Ze({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,style:a,backgroundColor:o}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=h();return s(B,{uri:i(()=>Xe(f.config.yodlUiBaseUrl),[f.config.yodlUiBaseUrl]),sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}})}function Qe(e){return(Array.isArray(e)?e:[e]).some(e=>qe(e).some(e=>e.action===`resolve`))}var $e=class{config;constructor(e){let t=w(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function et(e){return new $e(e)}export{$e as Yodl,ne as YodlDashboard,Ye as YodlPayment,m as YodlProvider,Ze as YodlSignup,et as createSdk,Qe as isPaymentQr};
228
+ true;`}function we(e){return JSON.stringify(e)}function z(e){return{state:e,message:null,readyAccepted:!1}}function Te(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:A(e.sessionId,e.currentTheme),readyAccepted:t}}function Ee(e,t){let n=we(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function B(e,t){let n=we(t);if(n===e.currentFingerprint)return z(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Te(r,!1):z(r)}function De(e,t){return!w(t)||t.sessionId!==e.sessionId?z(e):Te({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function V(e){return e.toLowerCase()}function Oe(e,t){let n=V(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:R(t.chainId)}}:{}}}function H(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function U(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function ke(e){let{provider:n,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g,sessionId:_,hostTheme:v=null,initialHostTheme:y=null}=e,b=o(null),x=o(V(s)),S=o(c),C=o(c),w=o(new Set),T=o(v),E=o(_?Ee(_,y):null);i(()=>{T.current=v},[v]),i(()=>{E.current=_?Ee(_,y):null},[y,_]);let D=t(e=>{w.current.has(e)||(w.current.add(e),u?.(e))},[u]);r(()=>{let e=Oe({address:x.current,propChainId:S.current,activeChainId:C.current},{address:s,chainId:c});e&&(x.current=e.nextAddress,S.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&U(b,`accountsChanged`,e.accountsChanged),e.chainChanged&&U(b,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!E.current)return;let e=B(E.current,v);E.current=e.state,e.message&&b.current?.postMessage(e.message)},[v]);let ee=a(()=>Ce({address:s,chainId:c}),[s,c]),O=t(async(e,t,r)=>{try{let i=ve(t,r,l);if(`error`in i){H(b,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),H(b,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,U(b,`chainChanged`,i.chainIdHex))}catch(t){let n=F(t,`Chain request failed`);H(b,e,void 0,I(n)),h?.(n)}},[n,l,h]),k=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>R(e))];H(b,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=F(n,`Capabilities unavailable`);if(!oe(r)){H(b,e,void 0,I(r));return}H(b,e,he(ye(t,l),`unsupported`))}},[n,s,l]),A=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Se(r);i&&D(i),H(b,e,r)}catch(t){H(b,e,void 0,I(F(t,`Failed to get call status`)))}},[n,D]),j=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&D(i),H(b,e,i)}catch(t){let n=F(t,`Request failed`),r=ie(n);H(b,e,void 0,r?{code:4001,message:n.message}:I(n)),r||h?.(n)}},[n,D,h]);return{uiRef:b,injectedJavaScript:ee,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(!t||typeof t!=`object`||!(`type`in t))return;if(t.type===`yodl_ready`){if(!E.current){g?.();return}let e=B(E.current,T.current);E.current=e.state,e.message&&b.current?.postMessage(e.message);let n=De(E.current,t);if(E.current=n.state,!n.readyAccepted)return;n.message&&b.current?.postMessage(n.message),g?.();return}if(t.type===`yodl_payment_details`){d?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_status`){f?.(t.status);return}if(t.type===`yodl_signup_complete`){p?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_dismissed`){m?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;_e(r)?O(n,r,i):r===`wallet_getCapabilities`?k(n,i):r===`wallet_getCallsStatus`?A(n,i):j(n,r,i)},[O,k,A,j,d,f,p,m,h,g])}}function W(e){return f(Ae,{...e},e.uri)}function Ae({uri:e,sdkConfig:n,provider:r,address:i,chainId:o,supportedChainIds:l,onTransactionSent:d,onPaymentDetails:h,onSignupStatusChange:g,onSignedUp:_,onSignupDismissed:v,onError:y,style:b,backgroundColor:x,hostTheme:S=null,sharedCookiesEnabled:C=!0,thirdPartyCookiesEnabled:w=!0,onLoadStart:T,...E}){let[D]=s(()=>me(S)),k=ee(S,x),A=k.background,[j,te]=s(null),M=j===D.sessionId,{uiRef:N,injectedJavaScript:ne,onMessage:re}=ke({provider:r,address:i,chainId:o,supportedChainIds:l,onReady:t(()=>{te(D.sessionId)},[D.sessionId]),sessionId:D.sessionId,hostTheme:S,initialHostTheme:D.initialHostTheme,...d!==void 0&&{onTransactionSent:d},...h!==void 0&&{onPaymentDetails:h},...g!==void 0&&{onSignupStatusChange:g},..._!==void 0&&{onSignedUp:_},...v!==void 0&&{onSignupDismissed:v},...y!==void 0&&{onError:y}}),P=a(()=>se(e),[e]),ie=a(()=>{let t=de(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),F=a(()=>e=>!P||!e?.url?!1:ce(e.url,P)||e.url.startsWith(`about:`),[P]);return p(u,{style:[G.container,{backgroundColor:A},b],children:[f(m,{ref:N,source:ie,originWhitelist:P?[P]:[],onShouldStartLoadWithRequest:F,javaScriptEnabled:!0,sharedCookiesEnabled:C,thirdPartyCookiesEnabled:w,injectedJavaScriptBeforeContentLoaded:ne,injectedJavaScriptObject:O(D.sessionId,D.initialHostTheme,n.integrationAddress),onMessage:re,...T!==void 0&&{onLoadStart:T},style:[G.ui,{backgroundColor:A}],...E}),M?null:f(u,{style:[G.overlay,{backgroundColor:A}],children:f(c,{color:k.spinner})})]})}const G=l.create({container:{flex:1},ui:{flex:1},overlay:{...l.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function je({onTransactionSent:e,onPaymentDetails:t,onError:n,style:r,backgroundColor:i,theme:o,themeMode:s}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:p,hostTheme:m}=P(o,s);return f(W,{uri:a(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]),sdkConfig:p.config,provider:c,address:l,chainId:u,supportedChainIds:d,hostTheme:m,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{style:r},...i!==void 0&&{backgroundColor:i}})}function Me(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ne(e){if(Array.isArray(e))return e}function Pe(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function K(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Fe(e,t,n){return t&&K(e.prototype,t),n&&K(e,n),e}function Ie(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Le(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Re(e,t){return Ne(e)||Ie(e,t)||Be(e,t)||Le()}function ze(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function Be(e,t){if(e){if(typeof e==`string`)return Me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Me(e,t)}}var Ve=Object.defineProperty,He=function(e,t,n){return t in e?Ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},Ue=function(e,t){for(var n in t)Ve(e,n,{get:t[n],enumerable:!0})},q=function(e,t,n){return He(e,(t===void 0?`undefined`:ze(t))===`symbol`?t:t+``,n)},We=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function Ge(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=We[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function Ke(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function J(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=J(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function qe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Ge(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Y(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=qe(e,n),e}function Je(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function X(e,t){return{id:e,length:t.length,value:t}}function Ye(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[X(`00`,`A000000677010112`),X(`01`,t),X(`02`,r)];i&&o.push(X(`03`,i));var s=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`30`,J(o)),X(`53`,`764`),X(`58`,`TH`)];return n&&s.push(X(`54`,Number(n).toFixed(2))),a&&s.push(X(`62`,J([X(`07`,a)]))),Y(J(s),`63`)}var Xe=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;Pe(this,e),q(this,`billerId`),q(this,`ref1`),q(this,`ref2`),q(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return Fe(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return Ye({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=Re(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Z=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Z||{});function Ze(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=J([X(`00`,`A000000677010111`),X(Z[t],n)]),a=[X(`00`,`01`),X(`01`,r?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return r&&a.push(X(`54`,Number(r).toFixed(2))),Y(J(a),`63`)}Ue({},{ProxyType:function(){return Z},anyId:function(){return Ze},billPayment:function(){return Ye},botBarcode:function(){return Qe},slipVerify:function(){return $e},trueMoney:function(){return tt},trueMoneySlipVerify:function(){return nt}});function Qe(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Xe(t,n,r,i).toString()}function $e(e){var t=e.sendingBank,n=e.transRef;return Y(J([X(`00`,J([X(`00`,`000001`),X(`01`,t),X(`02`,n)])),X(`51`,`TH`)]),`91`)}function et(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function tt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=J([X(`00`,`A000000677010111`),X(`03`,`14000${t}`)]),a=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return n&&a.push(X(`54`,Number(n).toFixed(2))),r&&a.push(X(`81`,et(r))),Y(J(a),`63`)}function nt(e){var t=e.eventType,n=e.transactionId,r=e.date;return Y(J([X(`00`,J([X(`00`,`01`),X(`01`,`01`),X(`02`,t),X(`03`,n),X(`04`,r)]))]),`91`,!1)}function Q(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function rt(e){if(Array.isArray(e))return e}function it(e){if(Array.isArray(e))return Q(e)}function at(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ot(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function st(e,t,n){return t&&ot(e.prototype,t),n&&ot(e,n),e}function ct(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function ut(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function dt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ft(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ct(e,t,n[t])})}return e}function mt(e,t){return rt(e)||ut(e,t)||gt(e,t)||dt()}function ht(e){return it(e)||lt(e)||gt(e)||ft()}function gt(e,t){if(e){if(typeof e==`string`)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}}Ue({},{anyId:function(){return yt},bcelOneProof:function(){return vt},billPayment:function(){return bt},slipVerify:function(){return xt},trueMoneySlipVerify:function(){return St}});var _t=function(){function e(t,n){at(this,e),q(this,`payload`),q(this,`tags`),this.payload=t,this.tags=n}return st(e,[{key:`getTag`,value:function(e,t){return Je(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=Y(J(ht(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=qe(e.slice(0,-4)))return null;var r=Ke(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=Ke(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new _t(e,r)}function vt(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function yt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Z).find(function(e){var n=mt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=mt(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return pt({type:o,target:c},u!==void 0&&{amount:u})}function bt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return pt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function xt(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function St(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Ct={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function wt(e){return e?e.getTagValue(`58`)??null:null}function Tt(e){let t=[];for(let[n,r]of Object.entries(Ct))r.includes(e)&&t.push(n);return t}function Et(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=wt($(r));if(e){let n=Tt(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Dt(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Et(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Ot({qrData:e,onTransactionSent:t,onPaymentDetails:n,onError:r,style:i,backgroundColor:o,theme:s,themeMode:c}){let{provider:l,address:u,chainId:d,supportedChainIds:p,sdk:m,hostTheme:h}=P(s,c),g=a(()=>Dt(e,m.config.yodlUiBaseUrl),[e,m.config.yodlUiBaseUrl]);return g?f(W,{uri:g,sdkConfig:m.config,provider:l,address:u,chainId:d,supportedChainIds:p,hostTheme:h,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...r!==void 0&&{onError:r},...i!==void 0&&{style:i},...o!==void 0&&{backgroundColor:o}}):null}function kt(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function At({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,style:i,backgroundColor:o,theme:s,themeMode:c}){let{provider:l,address:u,chainId:d,supportedChainIds:p,sdk:m,hostTheme:h}=P(s,c);return f(W,{uri:a(()=>kt(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]),sdkConfig:m.config,provider:l,address:u,chainId:d,supportedChainIds:p,hostTheme:h,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...i!==void 0&&{style:i},...o!==void 0&&{backgroundColor:o}})}function jt(e){return(Array.isArray(e)?e:[e]).some(e=>Et(e).some(e=>e.action===`resolve`))}var Mt=class{config;constructor(e){let t=L(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function Nt(e){return new Mt(e)}export{Mt as Yodl,je as YodlDashboard,Ot as YodlPayment,ne as YodlProvider,At as YodlSignup,Nt as createSdk,jt as isPaymentQr};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yodlpay/react-native",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
6
6
  "keywords": [
@@ -75,7 +75,10 @@
75
75
  "tsdown": "^0.22.0",
76
76
  "typescript": "^5.7.2",
77
77
  "vitest": "^4.1.7",
78
- "@yodlpay/sdk-core": "0.4.0"
78
+ "@yodlpay/sdk-core": "0.5.0"
79
+ },
80
+ "dependencies": {
81
+ "zod": "^4.4.3"
79
82
  },
80
83
  "scripts": {
81
84
  "build": "tsdown",