@yodlpay/react-native 0.11.0 → 0.12.0

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
@@ -474,7 +474,7 @@ Renders the hosted signup flow. Use this as a full-screen component inside `<Yod
474
474
  | `onStatusChange` | `(status: 'checking' \| 'signed_out' \| 'signing_up' \| 'signed_up') => void` | No | Called when the hosted flow reports signup status |
475
475
  | `onSignedUp` | `() => void` | No | Called when signup completes |
476
476
  | `onDismiss` | `() => void` | No | Called when the hosted success screen is dismissed |
477
- | `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, or RPC errors |
477
+ | `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, RPC, or WebView errors. See [errors](#errors) |
478
478
 
479
479
  ### `<YodlPayment />`
480
480
 
@@ -486,9 +486,9 @@ Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is e
486
486
  | `navigateOnSubmit` | `'always' \| 'never'` | No | Whether the hosted UI moves to its own status screen once the transaction is submitted. Defaults to `'always'` |
487
487
  | `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
488
488
  | `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
489
- | `onError` | `(error: Error) => void` | No | Called on RPC / payment errors |
489
+ | `onError` | `(error: Error) => void` | No | Called on RPC, payment, or WebView errors. See [errors](#errors) |
490
490
 
491
- `navigateOnSubmit="never"` parks the hosted UI on a terminal "sent" frame so your app owns the transition after signing — drive it from `onTransactionSent` or `onPaymentDetails`. Note the moment: the hosted UI moves when the transaction is **submitted**, not when it settles. It keeps polling behind that frame, so `onPaymentDetails` still reports `'processing'` and then `'success'` or `'failure'` — you get a `'submitted'` message first, then the same stream `'always'` produces. A host that ignores both callbacks leaves the user on that frame, which is why the default is `'always'`: omit the prop and the URL, and therefore the behavior, is unchanged. The prop feeds the WebView's URL and the WebView is keyed by it, so changing it on a mounted component reloads the hosted UI — pass a constant.
491
+ `navigateOnSubmit="never"` keeps the hosted UI on the payment screen exactly as it was at the hold: the control stays busy, nothing else is drawn, its URL does not change, and your app owns the transition after signing — drive it from `onTransactionSent` or `onPaymentDetails`. Note the moment: under `'always'` the hosted UI moves when the transaction is **submitted**, not when it settles. Under `'never'` it keeps polling from that screen, so `onPaymentDetails` still reports `'processing'` and then `'success'` or `'failure'` — you get a `'submitted'` message first, then the same stream `'always'` produces. A host that ignores both callbacks leaves the user on a busy screen, which is why the default is `'always'`: omit the prop and the URL, and therefore the behavior, is unchanged. The prop feeds the WebView's URL and the WebView is keyed by it, so changing it on a mounted component reloads the hosted UI — pass a constant. The hosted UI reads the parameter once, on its first load, and removes it from the URL.
492
492
 
493
493
  ### `<YodlDashboard />`
494
494
 
@@ -498,7 +498,7 @@ Renders the full Yodl account dashboard. Also accepts all [shared visual props](
498
498
  | ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
499
499
  | `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
500
500
  | `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
501
- | `onError` | `(error: Error) => void` | No | Called on RPC errors |
501
+ | `onError` | `(error: Error) => void` | No | Called on RPC or WebView errors. See [errors](#errors) |
502
502
 
503
503
  ### Loading and readiness
504
504
 
@@ -536,7 +536,17 @@ Until the hosted UI reports it has painted, the SDK covers the WebView with an o
536
536
 
537
537
  `onReady` fires **once per mount**, the first time the UI is revealed. It does not fire again. The hosted document re-posts readiness when it reloads, but the overlay has already lifted and does not come back, so there is nothing to re-announce — it lifts once and stays lifted.
538
538
 
539
- **The reveal has a ceiling.** If nothing is heard from the hosted UI within 8 seconds, the SDK reveals anyway and fires `onReady`. It is a last resort for a page that is genuinely dead, not a routine path: a reveal on that timer arrives without the readiness handshake, so the hosted UI has not received your theme or the SDK's capability announcement. A current hosted build runs its own, shorter ceiling and always reports readiness first, so in practice you only reach 8 seconds when the UI never loaded at all. The ceiling reveals — it does not report an error. Use `onError` and your own network handling for that.
539
+ **The reveal has a ceiling.** If nothing is heard from the hosted UI within 8 seconds, the SDK reveals anyway and fires `onReady`. It is a last resort for a page that is genuinely dead, not a routine path: a reveal on that timer arrives without the readiness handshake, so the hosted UI has not received your theme or the SDK's capability announcement. A current hosted build runs its own, shorter ceiling and always reports readiness first, so in practice you only reach 8 seconds when the UI never loaded at all. The ceiling reveals — it does not report an error. A page that failed to load reaches `onError` as a `YodlWebViewError` (see [errors](#errors)); pair it with your own network handling.
540
+
541
+ ### Errors
542
+
543
+ `onError` receives one of three kinds of error:
544
+
545
+ - A `YodlUIError` when the hosted UI reported a failure. `code` is the hosted UI's own code, when it sent one.
546
+ - A `YodlWebViewError` when the WebView under the hosted UI failed, so the page could not report anything itself. `code` is `'load_failed'` (no network, DNS, TLS), `'http_error'` (`status` has the HTTP status), or `'process_terminated'` (the OS ended the web process; remount the component to load the page again). `url` is the page's URL without its query, which carries the scanned QR.
547
+ - Your wallet's own error when a request to your EIP-1193 provider failed. A user rejection is not reported.
548
+
549
+ Both classes are exported from `@yodlpay/react-native`, and an error tracker titles them by name rather than as a plain `Error`.
540
550
 
541
551
  ### Payment details events
542
552
 
@@ -544,6 +554,8 @@ Until the hosted UI reports it has painted, the SDK covers the WebView with an o
544
554
 
545
555
  The Yodl UI emits generalized payment lifecycle details once it has payment status. The SDK forwards them to `onPaymentDetails`. Normalized fields cover transaction hash, chain, lifecycle status, recipient, invoice, token amounts, refund state, and rewards when available; the original payload may be included under `raw`. The SDK does not fetch transaction details itself — it only bridges UI messages.
546
556
 
557
+ `onError` during this sequence means the hosted UI has given up on the receipt: an expired session or a backend failure it cannot poll through. The 404 the backend answers while it is still indexing a fresh hash is not one of these. The poll expects it and keeps asking, and the details stream is unaffected. An older hosted build forwarded that 404 as `Payment not found for txHash=…` between `'submitted'` and `'processing'`; a host that still sees it can ignore it, since the terminal status arrives regardless.
558
+
547
559
  ## Security
548
560
 
549
561
  `<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` inject an EIP-1193 provider bound to the user's wallet, so the underlying Yodl UI is **locked to the configured Yodl origin** and off-origin navigation is blocked (`onShouldStartLoadWithRequest`). This prevents origin spoofing and mid-request navigation that could intercept signed responses. The injected provider also enforces a 30 s pending-request timeout.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
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");function i(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const a=/^0x[a-fA-F0-9]{40}$/;function o(e){return typeof e==`string`&&a.test(e)}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const c=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function l(e){if(e===void 0)return!0;if(!s(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function u(e){if(!s(e))return!1;switch(e.type){case`yodl_payment_details`:return s(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return l(e.error);case`yodl_signup_status`:return d(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return f(e);default:return!1}}function d(e){return typeof e==`string`&&c.has(e)}function f(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const p=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,m=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,h=/^https:\/\/[^\s"\\]+$/,g=[`system`,`inter`,`geist`,`mono`],_=[`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,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function ee(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function b(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const x=new Set([`system`,`light`,`dark`]);function S(e){return typeof e==`string`&&x.has(e)}const C=new Set(g);function w(e,t){if(!s(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`||i.length>64||!p.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function T(e,t){if(!s(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||!h.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function E(e){if(!s(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=T(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function D(e){if(!s(e))return{success:!1,error:`(root): expected an object`};let t=O(e);if(!t.success)return t;let n=te(e);if(!n.success)return n;let r=k(e);if(!r.success)return r;let i=A(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=E(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function O(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function te(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!C.has(e.font)?{success:!1,error:`font: must be one of ${[...C].join(`, `)}`}:{success:!0,data:{font:e.font}}}function k(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!m.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function A(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=w(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function j(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function M(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function N(e){if(!s(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!j(r,128))}const P=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function F(e){if(!s(e)||!M(e,P))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!j(r,128)||!j(i,64)||!o(a))}const I={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function L(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function R(e){let t=D(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function z(e){return e===void 0?{preference:`system`,error:null}:S(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function B(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:R(e),i=z(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:L(i.preference,n)},error:a.length>0?a.join(`; `):null}}function ne(e,t){let n=I[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function re(e,t,n,r){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{}}}}function ie(e,t){return JSON.stringify(y(e,t))}function ae(e,t,n,r){let{envelope:i,error:a}=B(e,t,n);return a&&r?.(a),i}function oe(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=B(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function se(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ce=(0,e.createContext)(null);function le({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>ae(s,c,u,se),[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)(ce.Provider,{value:f,children:l})}function ue(){let t=(0,e.useContext)(ce);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function de(t,n){let r=ue(),i=(0,e.useMemo)(()=>oe(r.hostTheme,t,n,r.systemScheme,se),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function V(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=de(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}function fe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!o(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function pe(e,t){return{"X-Yodl-Integration-Id":fe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function H(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 me(e){return e.code===4001||/rejected|denied/i.test(e.message)}const he=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],ge=[...he,`not supported`,`not available`];function _e(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ve(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||_e(e,he):_e(e,ge)}function ye(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function be(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const xe={name:`@yodlpay/react-native`,version:`0.11.0`};function Se(e){return pe(e,xe)}function Ce(e,t){let n=e.yodlUiBaseUrl?ye(e.yodlUiBaseUrl):null;if(!(!n||!be(t,n)))return Se(e)}let we=0;function Te(){return we+=1,`yodl-${Date.now().toString(36)}-${we.toString(36)}`}function Ee(e,t=Te){return{sessionId:t(),initialHostTheme:e}}function U(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function De(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,t){let n=e[1];return Array.isArray(n)?n.map(e=>De(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function ke(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Ae(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!ke(t))return;let n=t.receipts;if(n?.length&&!n.some(Ae))return n[n.length-1]?.transactionHash}function W(e){return`0x${e.toString(16)}`}function Me(e,t=`unsupported`){let n={};for(let r of e)n[W(r)]={atomic:{status:t}};return n}function G(e){return e.toLowerCase()}function Ne(e,t){let n=G(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:W(t.chainId)}}:{}}}function Pe(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Fe(e){return{state:e,decision:{kind:`ignore`}}}function K(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ie(e,t,n){return!F(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Fe(e):n.supported?G(t.address)===G(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?K(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:K(e,t.requestId,`address_mismatch`):K(e,t.requestId,`not_supported`)}function Le(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Re=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function ze(e){return Re.some(t=>t===e)}function Be(e,t,n){if(!ze(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=De((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=W(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function Ve(e){let t=W(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");function i(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const a=/^0x[a-fA-F0-9]{40}$/;function o(e){return typeof e==`string`&&a.test(e)}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const c=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function l(e){if(e===void 0)return!0;if(!s(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function u(e){if(!s(e))return!1;switch(e.type){case`yodl_payment_details`:return s(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return l(e.error);case`yodl_signup_status`:return d(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return f(e);default:return!1}}function d(e){return typeof e==`string`&&c.has(e)}function f(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const p=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,m=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,h=/^https:\/\/[^\s"\\]+$/,g=[`system`,`inter`,`geist`,`mono`],_=[`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,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function b(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function ee(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const x=new Set([`system`,`light`,`dark`]);function S(e){return typeof e==`string`&&x.has(e)}const C=new Set(g);function w(e,t){if(!s(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`||i.length>64||!p.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function T(e,t){if(!s(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||!h.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function E(e){if(!s(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=T(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function D(e){if(!s(e))return{success:!1,error:`(root): expected an object`};let t=O(e);if(!t.success)return t;let n=te(e);if(!n.success)return n;let r=k(e);if(!r.success)return r;let i=A(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=E(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function O(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function te(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!C.has(e.font)?{success:!1,error:`font: must be one of ${[...C].join(`, `)}`}:{success:!0,data:{font:e.font}}}function k(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!m.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function A(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=w(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function j(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function M(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function N(e){if(!s(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!j(r,128))}const P=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function F(e){if(!s(e)||!M(e,P))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!j(r,128)||!j(i,64)||!o(a))}const I={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function L(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function R(e){let t=D(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function z(e){return e===void 0?{preference:`system`,error:null}:S(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function B(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:R(e),i=z(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:L(i.preference,n)},error:a.length>0?a.join(`; `):null}}function ne(e,t){let n=I[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function re(e,t,n,r){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{}}}}function V(e,t){return JSON.stringify(y(e,t))}function ie(e,t,n,r){let{envelope:i,error:a}=B(e,t,n);return a&&r?.(a),i}function ae(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=B(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function oe(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const se=(0,e.createContext)(null);function ce({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>ie(s,c,u,oe),[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)(se.Provider,{value:f,children:l})}function le(){let t=(0,e.useContext)(se);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function ue(t,n){let r=le(),i=(0,e.useMemo)(()=>ae(r.hostTheme,t,n,r.systemScheme,oe),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function de(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=ue(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}function fe(e){let[t=``]=e.split(/[?#]/,1);return t.replace(/^([a-z][a-z\d+.-]*:\/\/)[^/]*@/i,`$1`)}function pe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!o(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function me(e,t){return{"X-Yodl-Integration-Id":pe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function H(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 he(e){return e.code===4001||/rejected|denied/i.test(e.message)}const ge=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],_e=[...ge,`not supported`,`not available`];function ve(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ye(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||ve(e,ge):ve(e,_e)}function be(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function xe(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const Se={name:`@yodlpay/react-native`,version:`0.12.0`};function Ce(e){return me(e,Se)}function we(e,t){let n=e.yodlUiBaseUrl?be(e.yodlUiBaseUrl):null;if(!(!n||!xe(t,n)))return Ce(e)}var Te=class extends Error{code;constructor(e,t){super(e?.message??t),this.name=`YodlUIError`,this.code=e?.code,Object.setPrototypeOf(this,new.target.prototype)}},U=class extends Error{code;url;status;constructor(e,t,n,r){super(t),this.name=`YodlWebViewError`,this.code=e,this.url=n===void 0?void 0:fe(n),this.status=r,Object.setPrototypeOf(this,new.target.prototype)}};let Ee=0;function De(){return Ee+=1,`yodl-${Date.now().toString(36)}-${Ee.toString(36)}`}function Oe(e,t=De){return{sessionId:t(),initialHostTheme:e}}function W(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function ke(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 Ae(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>ke(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function je(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Me(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Ne(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!je(t))return;let n=t.receipts;if(n?.length&&!n.some(Me))return n[n.length-1]?.transactionHash}function G(e){return`0x${e.toString(16)}`}function Pe(e,t=`unsupported`){let n={};for(let r of e)n[G(r)]={atomic:{status:t}};return n}function K(e){return e.toLowerCase()}function Fe(e,t){let n=K(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:G(t.chainId)}}:{}}}function Ie(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Le(e){return{state:e,decision:{kind:`ignore`}}}function Re(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function ze(e,t,n){return!F(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Le(e):n.supported?K(t.address)===K(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Re(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:Re(e,t.requestId,`address_mismatch`):Re(e,t.requestId,`not_supported`)}function Be(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Ve=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function He(e){return Ve.some(t=>t===e)}function Ue(e,t,n){if(!He(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=ke((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=G(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function We(e){let t=G(e.chainId);return`(function() {
2
2
  if (window.ethereum) return;
3
3
 
4
4
  var _address = ${JSON.stringify(e.address.toLowerCase())};
@@ -225,4 +225,7 @@ 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 He(e){return JSON.stringify(e)}function Ue(e){return{state:e,message:null,readyAccepted:!1}}function We(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:ie(e.sessionId,e.currentTheme),readyAccepted:t}}function Ge(e,t){let n=He(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Ke(e,t){let n=He(t);if(n===e.currentFingerprint)return Ue(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?We(r,!1):Ue(r)}function qe(e,t){return!N(t)||t.sessionId!==e.sessionId?Ue(e):We({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function q(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 Je(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Ye(e){return s(e)&&`type`in e}function Xe(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function Ze(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:d,onError:f,onReady:p,sessionId:m,hostTheme:h=null,initialHostTheme:g=null,fetchEmailAttestation:_}=t,v=(0,e.useRef)(null),y=(0,e.useRef)(G(r)),x=(0,e.useRef)(i),S=(0,e.useRef)(i),C=(0,e.useRef)(new Set),w=(0,e.useRef)(h),T=(0,e.useRef)(m?Ge(m,g):null),E=(0,e.useRef)(m?Pe(m):null),D=(0,e.useRef)(_);(0,e.useLayoutEffect)(()=>{w.current=h},[h]),(0,e.useLayoutEffect)(()=>{D.current=_},[_]),(0,e.useLayoutEffect)(()=>{T.current=m?Ge(m,g):null},[g,m]),(0,e.useLayoutEffect)(()=>{E.current=m?Pe(m):null},[m]);let O=(0,e.useCallback)(e=>{C.current.has(e)||(C.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=Ne({address:y.current,propChainId:x.current,activeChainId:S.current},{address:r,chainId:i});e&&(y.current=e.nextAddress,x.current=e.nextPropChainId,S.current=e.nextActiveChainId,e.accountsChanged&&Je(v,`accountsChanged`,e.accountsChanged),e.chainChanged&&Je(v,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!T.current)return;let e=Ke(T.current,h);T.current=e.state,e.message&&v.current?.postMessage(e.message)},[h]);let te=(0,e.useMemo)(()=>Ve({address:r,chainId:i}),[r,i]),k=(0,e.useCallback)(async(e,t,r)=>{try{let i=Be(t,r,a);if(`error`in i){q(v,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(v,e,null),i.switchesActiveChain&&(S.current=i.requestedChainId,Je(v,`chainChanged`,i.chainIdHex))}catch(t){let n=H(t,`Chain request failed`);q(v,e,void 0,U(n)),f?.(n)}},[n,a,f]),A=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>W(e))],o=await n.request({method:`wallet_getCapabilities`,params:i});q(v,e,o)}catch(n){let r=H(n,`Capabilities unavailable`);if(!ve(r)){q(v,e,void 0,U(r));return}q(v,e,Me(Oe(t,a),`unsupported`))}},[n,r,a]),j=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=je(r);i&&O(i),q(v,e,r)}catch(t){let n=H(t,`Failed to get call status`);q(v,e,void 0,U(n))}},[n,O]),M=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&O(i),q(v,e,i)}catch(t){let n=H(t,`Request failed`),r=me(n);q(v,e,void 0,r?{code:4001,message:n.message}:U(n)),r||f?.(n)}},[n,O,f]),N=(0,e.useCallback)((e,t)=>{let n=E.current;n&&(E.current=Le(n,e),v.current?.postMessage(JSON.stringify(b(n.sessionId,e,t))))},[]),P=(0,e.useCallback)(async(e,t)=>{let n=D.current;if(!n){N(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}E.current?.sessionId===e&&N(t.requestId,a)},[N]),F=(0,e.useCallback)(e=>{let t=E.current;if(!t)return;let n=Ie(t,e,{walletAddress:y.current,supported:!!D.current});if(E.current=n.state,n.decision.kind===`reject`){N(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&P(t.sessionId,n.decision.request)},[P,N]),I=(0,e.useCallback)((e,t,n)=>{ze(t)?k(e,t,n):t===`wallet_getCapabilities`?A(e,n):t===`wallet_getCallsStatus`?j(e,n):M(e,t,n)},[k,A,j,M]),L=(0,e.useCallback)(e=>{switch(e.type){case`yodl_signup_status`:c?.(e.status);return;case`yodl_signup_complete`:l?.();return;case`yodl_signup_error`:f?.(Xe(e.error,`Signup error`));return;case`yodl_signup_dismissed`:d?.();return}},[c,l,d,f]),R=(0,e.useCallback)(e=>{switch(e.type){case`yodl_payment_details`:s?.(e.details);return;case`yodl_payment_error`:f?.(Xe(e.error,`Payment details error`));return;case`ethereum_rpc_request`:I(e.id,e.method,e.params);return;default:L(e)}},[I,L,s,f]),z=(0,e.useCallback)(()=>{let e=E.current;e&&v.current?.postMessage(JSON.stringify(ee(e.sessionId,!!D.current)))},[]),B=(0,e.useCallback)(e=>{if(!T.current){p?.();return}let t=Ke(T.current,w.current);T.current=t.state,t.message&&v.current?.postMessage(t.message);let n=qe(T.current,e);T.current=n.state,n.readyAccepted&&(n.message&&v.current?.postMessage(n.message),z(),p?.())},[z,p]);return{uiRef:v,injectedJavaScript:te,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(Ye(t)){if(t.type===`yodl_ready`){B(t);return}if(t.type===`yodl_email_attestation_request`){F(t);return}u(t)&&R(t)}},[R,F,B])}}function Qe(e){return(0,n.jsx)($e,{...e},e.uri)}function $e({uri:a,sdkConfig:o,provider:s,address:c,chainId:l,supportedChainIds:u,onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,style:_,backgroundColor:v,hostTheme:y=null,fetchEmailAttestation:ee,renderLoading:b,onReady:x,sharedCookiesEnabled:S=!0,thirdPartyCookiesEnabled:C=!0,onLoadStart:w,...T}){let[E]=(0,e.useState)(()=>Ee(y)),D=ne(y,v),O=D.background,[te,k]=(0,e.useState)(null),A=te===E.sessionId,j=(0,e.useRef)(x);(0,e.useLayoutEffect)(()=>{j.current=x},[x]);let M=(0,e.useRef)(!1),N=(0,e.useCallback)(()=>{k(E.sessionId),!M.current&&(M.current=!0,j.current?.())},[E.sessionId]);(0,e.useEffect)(()=>{if(A)return;let e=setTimeout(N,8e3);return()=>clearTimeout(e)},[N,A]);let{uiRef:P,injectedJavaScript:F,onMessage:I}=Ze({provider:s,address:c,chainId:l,supportedChainIds:u,onReady:N,sessionId:E.sessionId,hostTheme:y,initialHostTheme:E.initialHostTheme,...i({onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,fetchEmailAttestation:ee})}),L=(0,e.useMemo)(()=>ye(a),[a]),R=(0,e.useMemo)(()=>{let e=Ce(o,a);return e?{uri:a,headers:e}:{uri:a}},[o,a]),z=(0,e.useMemo)(()=>e=>!L||!e?.url?!1:be(e.url,L)||e.url.startsWith(`about:`),[L]),B=A?null:b?b():(0,n.jsx)(t.ActivityIndicator,{color:D.spinner});return(0,n.jsxs)(t.View,{style:[et.container,{backgroundColor:O},_],children:[(0,n.jsx)(r.WebView,{ref:P,source:R,originWhitelist:L?[L]:[],onShouldStartLoadWithRequest:z,javaScriptEnabled:!0,sharedCookiesEnabled:S,thirdPartyCookiesEnabled:C,injectedJavaScriptBeforeContentLoaded:F,injectedJavaScriptObject:re(E.sessionId,E.initialHostTheme,o.integrationAddress,ee?{emailAttestation:!0}:void 0),onMessage:I,...w!==void 0&&{onLoadStart:w},style:[et.ui,{backgroundColor:O}],...T}),B&&(0,n.jsx)(t.View,{style:[et.overlay,{backgroundColor:O}],children:B})]})}const et=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function tt({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:f}){let{sdk:p,hostProps:m}=V(d,f),h=(0,e.useMemo)(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]);return(0,n.jsx)(Qe,{uri:h,...m,...i({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})})}function nt(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,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function at(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 ot(e,t,n){return t&&at(e.prototype,t),n&&at(e,n),e}function st(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 ct(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lt(e,t){return rt(e)||st(e,t)||dt(e,t)||ct()}function ut(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function dt(e,t){if(e){if(typeof e==`string`)return nt(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 nt(e,t)}}var ft=Object.defineProperty,pt=function(e,t,n){return t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},mt=function(e,t){for(var n in t)ft(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return pt(e,(t===void 0?`undefined`:ut(t))===`symbol`?t:t+``,n)},ht=[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 gt(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=ht[(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 _t(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 Y(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+=Y(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 vt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=gt(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function X(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=vt(e,n),e}function yt(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 Z(e,t){return{id:e,length:t.length,value:t}}function bt(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Z(`00`,`A000000677010112`),Z(`01`,t),Z(`02`,r)];i&&o.push(Z(`03`,i));var s=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`30`,Y(o)),Z(`53`,`764`),Z(`58`,`TH`)];return n&&s.push(Z(`54`,Number(n).toFixed(2))),a&&s.push(Z(`62`,Y([Z(`07`,a)]))),X(Y(s),`63`)}var xt=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;it(this,e),J(this,`billerId`),J(this,`ref1`),J(this,`ref2`),J(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ot(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 bt({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=lt(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}(),Q=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Q||{});function St(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=Y([Z(`00`,`A000000677010111`),Z(Q[t],n)]),a=[Z(`00`,`01`),Z(`01`,r?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return r&&a.push(Z(`54`,Number(r).toFixed(2))),X(Y(a),`63`)}mt({},{ProxyType:function(){return Q},anyId:function(){return St},billPayment:function(){return bt},botBarcode:function(){return Ct},slipVerify:function(){return wt},trueMoney:function(){return Et},trueMoneySlipVerify:function(){return Dt}});function Ct(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new xt(t,n,r,i).toString()}function wt(e){var t=e.sendingBank,n=e.transRef;return X(Y([Z(`00`,Y([Z(`00`,`000001`),Z(`01`,t),Z(`02`,n)])),Z(`51`,`TH`)]),`91`)}function Tt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Et(e){var t=e.mobileNo,n=e.amount,r=e.message,i=Y([Z(`00`,`A000000677010111`),Z(`03`,`14000${t}`)]),a=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return n&&a.push(Z(`54`,Number(n).toFixed(2))),r&&a.push(Z(`81`,Tt(r))),X(Y(a),`63`)}function Dt(e){var t=e.eventType,n=e.transactionId,r=e.date;return X(Y([Z(`00`,Y([Z(`00`,`01`),Z(`01`,`01`),Z(`02`,t),Z(`03`,n),Z(`04`,r)]))]),`91`,!1)}function Ot(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 kt(e){if(Array.isArray(e))return e}function At(e){if(Array.isArray(e))return Ot(e)}function jt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Mt(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 Nt(e,t,n){return t&&Mt(e.prototype,t),n&&Mt(e,n),e}function Pt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ft(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function It(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 Lt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zt(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){Pt(e,t,n[t])})}return e}function Bt(e,t){return kt(e)||It(e,t)||Ht(e,t)||Lt()}function Vt(e){return At(e)||Ft(e)||Ht(e)||Rt()}function Ht(e,t){if(e){if(typeof e==`string`)return Ot(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 Ot(e,t)}}mt({},{anyId:function(){return Gt},bcelOneProof:function(){return Wt},billPayment:function(){return Kt},slipVerify:function(){return qt},trueMoneySlipVerify:function(){return Jt}});var Ut=function(){"use strict";function e(t,n){jt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Nt(e,[{key:`getTag`,value:function(e,t){return yt(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=X(Y(Vt(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],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=vt(e.slice(0,-4)))return null;var r=_t(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=_t(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 Ut(e,r)}function Wt(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 Gt(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(Q).find(function(e){var n=Bt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Bt(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 zt({type:o,target:c},u!==void 0&&{amount:u})}function Kt(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 zt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function qt(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 Jt(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 Yt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function Xt(e){return e?e.getTagValue(`58`)??null:null}function Zt(e){let t=[];for(let[n,r]of Object.entries(Yt))r.includes(e)&&t.push(n);return t}function Qt(e){return e.toLowerCase().startsWith(`upi://`)&&e.length>6}function $t(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function en(e,t){return!t||t.includes(e)}function tn(e,t){let n=[];try{let r=Xt($(e));if(!r)return n;for(let e of Zt(r))en(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function nn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if($t(n))return en(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=tn(n,t);return r.length>0?r:Qt(n)&&en(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]:r}function rn(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function an(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function on(e){return an(e,`/sdk/signup`)}const sn=`always`;function cn(e,t,n=sn){return!e||typeof e!=`string`||e.trim().length===0||rn(nn(e)).length===0?null:an(t,`/resolve`,{data:e,navigateOnSubmit:n===sn?void 0:n})}function ln({qrData:t,navigateOnSubmit:r,onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f,theme:p,themeMode:m}){let{sdk:h,hostProps:g}=V(p,m),_=(0,e.useMemo)(()=>cn(t,h.config.yodlUiBaseUrl,r),[t,h.config.yodlUiBaseUrl,r]);return _?(0,n.jsx)(Qe,{uri:_,...g,...i({onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f})}):null}function un({onStatusChange:t,onSignedUp:r,onError:a,onDismiss:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d,theme:f,themeMode:p}){let{sdk:m,hostProps:h}=V(f,p),g=(0,e.useMemo)(()=>on(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]);return(0,n.jsx)(Qe,{uri:g,...h,...i({onSignupStatusChange:t,onSignedUp:r,onError:a,onSignupDismissed:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d})})}function dn(e){return(Array.isArray(e)?e:[e]).some(e=>rn(nn(e)).length>0)}var fn=class{config;constructor(e){let t=fe(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 pn(e){return new fn(e)}exports.YodlDashboard=tt,exports.YodlPayment=ln,exports.YodlProvider=le,exports.YodlSdk=fn,exports.YodlSignup=un,exports.createYodlSdk=pn,exports.isPaymentQr=dn;
228
+ true;`}function Ge(e){return JSON.stringify(e)}function Ke(e){return{state:e,message:null,readyAccepted:!1}}function qe(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:V(e.sessionId,e.currentTheme),readyAccepted:t}}function Je(e,t){let n=Ge(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Ye(e,t){let n=Ge(t);if(n===e.currentFingerprint)return Ke(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?qe(r,!1):Ke(r)}function Xe(e,t){return!N(t)||t.sessionId!==e.sessionId?Ke(e):qe({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function q(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 Ze(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Qe(e){return s(e)&&`type`in e}function $e(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:d,onError:f,onReady:p,sessionId:m,hostTheme:h=null,initialHostTheme:g=null,fetchEmailAttestation:_}=t,v=(0,e.useRef)(null),y=(0,e.useRef)(K(r)),x=(0,e.useRef)(i),S=(0,e.useRef)(i),C=(0,e.useRef)(new Set),w=(0,e.useRef)(h),T=(0,e.useRef)(m?Je(m,g):null),E=(0,e.useRef)(m?Ie(m):null),D=(0,e.useRef)(_);(0,e.useLayoutEffect)(()=>{w.current=h},[h]),(0,e.useLayoutEffect)(()=>{D.current=_},[_]),(0,e.useLayoutEffect)(()=>{T.current=m?Je(m,g):null},[g,m]),(0,e.useLayoutEffect)(()=>{E.current=m?Ie(m):null},[m]);let O=(0,e.useCallback)(e=>{C.current.has(e)||(C.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=Fe({address:y.current,propChainId:x.current,activeChainId:S.current},{address:r,chainId:i});e&&(y.current=e.nextAddress,x.current=e.nextPropChainId,S.current=e.nextActiveChainId,e.accountsChanged&&Ze(v,`accountsChanged`,e.accountsChanged),e.chainChanged&&Ze(v,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!T.current)return;let e=Ye(T.current,h);T.current=e.state,e.message&&v.current?.postMessage(e.message)},[h]);let te=(0,e.useMemo)(()=>We({address:r,chainId:i}),[r,i]),k=(0,e.useCallback)(async(e,t,r)=>{try{let i=Ue(t,r,a);if(`error`in i){q(v,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(v,e,null),i.switchesActiveChain&&(S.current=i.requestedChainId,Ze(v,`chainChanged`,i.chainIdHex))}catch(t){let n=H(t,`Chain request failed`);q(v,e,void 0,W(n)),f?.(n)}},[n,a,f]),A=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>G(e))],o=await n.request({method:`wallet_getCapabilities`,params:i});q(v,e,o)}catch(n){let r=H(n,`Capabilities unavailable`);if(!ye(r)){q(v,e,void 0,W(r));return}q(v,e,Pe(Ae(t,a),`unsupported`))}},[n,r,a]),j=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Ne(r);i&&O(i),q(v,e,r)}catch(t){let n=H(t,`Failed to get call status`);q(v,e,void 0,W(n))}},[n,O]),M=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&O(i),q(v,e,i)}catch(t){let n=H(t,`Request failed`),r=he(n);q(v,e,void 0,r?{code:4001,message:n.message}:W(n)),r||f?.(n)}},[n,O,f]),N=(0,e.useCallback)((e,t)=>{let n=E.current;n&&(E.current=Be(n,e),v.current?.postMessage(JSON.stringify(ee(n.sessionId,e,t))))},[]),P=(0,e.useCallback)(async(e,t)=>{let n=D.current;if(!n){N(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}E.current?.sessionId===e&&N(t.requestId,a)},[N]),F=(0,e.useCallback)(e=>{let t=E.current;if(!t)return;let n=ze(t,e,{walletAddress:y.current,supported:!!D.current});if(E.current=n.state,n.decision.kind===`reject`){N(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&P(t.sessionId,n.decision.request)},[P,N]),I=(0,e.useCallback)((e,t,n)=>{He(t)?k(e,t,n):t===`wallet_getCapabilities`?A(e,n):t===`wallet_getCallsStatus`?j(e,n):M(e,t,n)},[k,A,j,M]),L=(0,e.useCallback)(e=>{switch(e.type){case`yodl_signup_status`:c?.(e.status);return;case`yodl_signup_complete`:l?.();return;case`yodl_signup_error`:f?.(new Te(e.error,`Signup error`));return;case`yodl_signup_dismissed`:d?.();return}},[c,l,d,f]),R=(0,e.useCallback)(e=>{switch(e.type){case`yodl_payment_details`:s?.(e.details);return;case`yodl_payment_error`:f?.(new Te(e.error,`Payment details error`));return;case`ethereum_rpc_request`:I(e.id,e.method,e.params);return;default:L(e)}},[I,L,s,f]),z=(0,e.useCallback)(()=>{let e=E.current;e&&v.current?.postMessage(JSON.stringify(b(e.sessionId,!!D.current)))},[]),B=(0,e.useCallback)(e=>{if(!T.current){p?.();return}let t=Ye(T.current,w.current);T.current=t.state,t.message&&v.current?.postMessage(t.message);let n=Xe(T.current,e);T.current=n.state,n.readyAccepted&&(n.message&&v.current?.postMessage(n.message),z(),p?.())},[z,p]);return{uiRef:v,injectedJavaScript:te,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(Qe(t)){if(t.type===`yodl_ready`){B(t);return}if(t.type===`yodl_email_attestation_request`){F(t);return}u(t)&&R(t)}},[R,F,B])}}function et(e){return(0,n.jsx)(tt,{...e},e.uri)}function tt({uri:a,sdkConfig:o,provider:s,address:c,chainId:l,supportedChainIds:u,onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,style:_,backgroundColor:v,hostTheme:y=null,fetchEmailAttestation:b,renderLoading:ee,onReady:x,sharedCookiesEnabled:S=!0,thirdPartyCookiesEnabled:C=!0,onLoadStart:w,...T}){let[E]=(0,e.useState)(()=>Oe(y)),D=ne(y,v),O=D.background,[te,k]=(0,e.useState)(null),A=te===E.sessionId,j=(0,e.useRef)(x);(0,e.useLayoutEffect)(()=>{j.current=x},[x]);let M=(0,e.useRef)(!1),N=(0,e.useCallback)(()=>{k(E.sessionId),!M.current&&(M.current=!0,j.current?.())},[E.sessionId]);(0,e.useEffect)(()=>{if(A)return;let e=setTimeout(N,8e3);return()=>clearTimeout(e)},[N,A]);let{uiRef:P,injectedJavaScript:F,onMessage:I}=$e({provider:s,address:c,chainId:l,supportedChainIds:u,onReady:N,sessionId:E.sessionId,hostTheme:y,initialHostTheme:E.initialHostTheme,...i({onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,fetchEmailAttestation:b})}),L=(0,e.useMemo)(()=>be(a),[a]),R=(0,e.useMemo)(()=>{let e=we(o,a);return e?{uri:a,headers:e}:{uri:a}},[o,a]),z=(0,e.useMemo)(()=>e=>!L||!e?.url?!1:xe(e.url,L)||e.url.startsWith(`about:`),[L]),B=(0,e.useMemo)(()=>{if(!g)return{};let e=e=>g(new U(`process_terminated`,`The Yodl UI web process was terminated`,e));return{onError:({nativeEvent:e})=>g(new U(`load_failed`,`The Yodl UI failed to load: ${e.description}`,e.url)),onHttpError:({nativeEvent:e})=>g(new U(`http_error`,`The Yodl UI answered HTTP ${e.statusCode}`,e.url,e.statusCode)),onRenderProcessGone:()=>e(a),onContentProcessDidTerminate:({nativeEvent:t})=>e(t.url)}},[g,a]),V=A?null:ee?ee():(0,n.jsx)(t.ActivityIndicator,{color:D.spinner});return(0,n.jsxs)(t.View,{style:[nt.container,{backgroundColor:O},_],children:[(0,n.jsx)(r.WebView,{ref:P,source:R,originWhitelist:L?[L]:[],onShouldStartLoadWithRequest:z,javaScriptEnabled:!0,sharedCookiesEnabled:S,thirdPartyCookiesEnabled:C,injectedJavaScriptBeforeContentLoaded:F,injectedJavaScriptObject:re(E.sessionId,E.initialHostTheme,o.integrationAddress,b?{emailAttestation:!0}:void 0),onMessage:I,...B,...w!==void 0&&{onLoadStart:w},style:[nt.ui,{backgroundColor:O}],...T}),V&&(0,n.jsx)(t.View,{style:[nt.overlay,{backgroundColor:O}],children:V})]})}const nt=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function rt({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:f}){let{sdk:p,hostProps:m}=de(d,f),h=(0,e.useMemo)(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]);return(0,n.jsx)(et,{uri:h,...m,...i({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})})}function it(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function at(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 ot(e){if(Array.isArray(e))return e}function st(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ct(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 lt(e,t,n){return t&&ct(e.prototype,t),n&&ct(e,n),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.
229
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ft(e,t){return ot(e)||ut(e,t)||mt(e,t)||dt()}function pt(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function mt(e,t){if(e){if(typeof e==`string`)return at(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 at(e,t)}}var ht=Object.defineProperty,gt=function(e,t,n){return t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},_t=function(e,t){for(var n in t)ht(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return gt(e,(t===void 0?`undefined`:pt(t))===`symbol`?t:t+``,n)},vt=[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 yt(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=65536+(r-55296<<10)+(i-56320),n++)}r>=55296&&r<=57343&&(r=65533),r<128?t.push(r):r<2048?t.push(192|r>>6,128|r&63):r<65536?t.push(224|r>>12,128|r>>6&63,128|r&63):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}return t}function bt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=typeof e==`string`?yt(e):e,r=!0,i=!1,a=void 0;try{for(var o=n[Symbol.iterator](),s;!(r=(s=o.next()).done);r=!0)t=vt[(s.value^t>>8)&255]^t<<8}catch(e){i=!0,a=e}finally{try{!r&&o.return!=null&&o.return()}finally{if(i)throw a}}return(t^0)&65535}function xt(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 Y(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+=Y(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 St(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=bt(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function X(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=St(e,n),e}function Ct(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 Z(e,t){return{id:e,length:t.length,value:t}}function wt(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Z(`00`,`A000000677010112`),Z(`01`,t),Z(`02`,r)];i&&o.push(Z(`03`,i));var s=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`30`,Y(o)),Z(`53`,`764`),Z(`58`,`TH`)];return n&&s.push(Z(`54`,Number(n).toFixed(2))),a&&s.push(Z(`62`,Y([Z(`07`,a)]))),X(Y(s),`63`)}var Tt=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;st(this,e),J(this,`billerId`),J(this,`ref1`),J(this,`ref2`),J(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return lt(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 wt({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=ft(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}(),Q=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Q||{});function Et(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=Y([Z(`00`,`A000000677010111`),Z(Q[t],n)]),a=[Z(`00`,`01`),Z(`01`,r?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return r&&a.push(Z(`54`,Number(r).toFixed(2))),X(Y(a),`63`)}_t({},{ProxyType:function(){return Q},anyId:function(){return Et},billPayment:function(){return wt},botBarcode:function(){return Dt},slipVerify:function(){return Ot},trueMoney:function(){return At},trueMoneySlipVerify:function(){return jt}});function Dt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Tt(t,n,r,i).toString()}function Ot(e){var t=e.sendingBank,n=e.transRef;return X(Y([Z(`00`,Y([Z(`00`,`000001`),Z(`01`,t),Z(`02`,n)])),Z(`51`,`TH`)]),`91`)}function kt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function At(e){var t=e.mobileNo,n=e.amount,r=e.message,i=Y([Z(`00`,`A000000677010111`),Z(`03`,`14000${t}`)]),a=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return n&&a.push(Z(`54`,Number(n).toFixed(2))),r&&a.push(Z(`81`,kt(r))),X(Y(a),`63`)}function jt(e){var t=e.eventType,n=e.transactionId,r=e.date;return X(Y([Z(`00`,Y([Z(`00`,`01`),Z(`01`,`01`),Z(`02`,t),Z(`03`,n),Z(`04`,r)]))]),`91`,!1)}function Mt(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 Nt(e){if(Array.isArray(e))return e}function Pt(e){if(Array.isArray(e))return Mt(e)}function Ft(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function It(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 Lt(e,t,n){return t&&It(e.prototype,t),n&&It(e,n),e}function Rt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Bt(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 Vt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
230
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ht(){throw TypeError(`Invalid attempt to spread non-iterable instance.
231
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ut(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){Rt(e,t,n[t])})}return e}function Wt(e,t){return Nt(e)||Bt(e,t)||Kt(e,t)||Vt()}function Gt(e){return Pt(e)||zt(e)||Kt(e)||Ht()}function Kt(e,t){if(e){if(typeof e==`string`)return Mt(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 Mt(e,t)}}_t({},{anyId:function(){return Yt},bcelOneProof:function(){return Jt},billPayment:function(){return Xt},slipVerify:function(){return Zt},trueMoneySlipVerify:function(){return Qt}});var qt=function(){"use strict";function e(t,n){Ft(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Lt(e,[{key:`getTag`,value:function(e,t){return Ct(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=X(Y(Gt(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],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=St(e.slice(0,-4)))return null;var r=xt(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=xt(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 qt(e,r)}function Jt(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(Q).find(function(e){var n=Wt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Wt(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 Ut({type:o,target:c},u!==void 0&&{amount:u})}function Xt(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 Ut({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Zt(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 Qt(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 $t={aeon:[`PH`,`VN`,`BR`,`AR`,`CO`,`PE`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function en(e){return e?e.getTagValue(`58`)??null:null}function tn(e){let t=[];for(let[n,r]of Object.entries($t))r.includes(e)&&t.push(n);return t}const nn=/^[a-z0-9+/]{64,}={0,2}\|[0-9a-f]{16,64}$/i;function rn(e){return nn.test(e)}function an(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function on(e,t){return!t||t.includes(e)}function sn(e,t){let n=[];try{let r=en($(e));if(!r)return n;for(let e of tn(r))on(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function cn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(an(n))return on(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=sn(n,t);return r.length>0?r:rn(n)&&on(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]:r}function ln(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function un(e){return ln(e,`/sdk/signup`)}const dn=`always`;function fn(e,t,n=dn){return!e||typeof e!=`string`||e.trim().length===0||it(cn(e)).length===0?null:ln(t,`/resolve`,{data:e,navigateOnSubmit:n===dn?void 0:n})}function pn({qrData:t,navigateOnSubmit:r,onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f,theme:p,themeMode:m}){let{sdk:h,hostProps:g}=de(p,m),_=(0,e.useMemo)(()=>fn(t,h.config.yodlUiBaseUrl,r),[t,h.config.yodlUiBaseUrl,r]);return _?(0,n.jsx)(et,{uri:_,...g,...i({onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f})}):null}function mn({onStatusChange:t,onSignedUp:r,onError:a,onDismiss:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d,theme:f,themeMode:p}){let{sdk:m,hostProps:h}=de(f,p),g=(0,e.useMemo)(()=>un(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]);return(0,n.jsx)(et,{uri:g,...h,...i({onSignupStatusChange:t,onSignedUp:r,onError:a,onSignupDismissed:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d})})}function hn(e){return(Array.isArray(e)?e:[e]).some(e=>it(cn(e)).length>0)}var gn=class{config;constructor(e){let t=pe(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 _n(e){return new gn(e)}exports.YodlDashboard=rt,exports.YodlPayment=pn,exports.YodlProvider=ce,exports.YodlSdk=gn,exports.YodlSignup=mn,exports.YodlUIError=Te,exports.YodlWebViewError=U,exports.createYodlSdk=_n,exports.isPaymentQr=hn;
package/dist/index.d.cts CHANGED
@@ -64,8 +64,13 @@ interface YodlPaymentDetails {
64
64
  };
65
65
  raw?: unknown;
66
66
  }
67
+ /** What a failure message carries; both fields are optional on the wire. */
68
+ interface YodlBridgeError {
69
+ message?: string;
70
+ code?: string | number;
71
+ }
67
72
  //#endregion
68
- //#region ../sdk-core/dist/index-DO0fv_gp.d.mts
73
+ //#region ../sdk-core/dist/index-D5Dst92E.d.mts
69
74
  //#endregion
70
75
  //#region src/evm/wallet-provider.d.ts
71
76
  /**
@@ -369,4 +374,32 @@ declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMod
369
374
  */
370
375
  declare function isPaymentQr(qrData: string | string[]): boolean;
371
376
  //#endregion
372
- export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createYodlSdk, isPaymentQr };
377
+ //#region src/yodl-ui/errors.d.ts
378
+ /**
379
+ * A failure the Yodl UI reported over the bridge (`yodl_payment_error`,
380
+ * `yodl_signup_error`). `code` is the page's own, as it sent it; the class is
381
+ * what tells a host — and an error tracker, which titles an error by its name —
382
+ * that the Yodl UI raised it rather than the wallet.
383
+ */
384
+ declare class YodlUIError extends Error {
385
+ readonly code?: string | number | undefined;
386
+ constructor(error: YodlBridgeError | undefined, fallbackMessage: string);
387
+ }
388
+ /** Why the WebView under the Yodl UI failed. */
389
+ type YodlWebViewErrorCode = 'load_failed' | 'http_error' | 'process_terminated';
390
+ /**
391
+ * The WebView under the Yodl UI failed, leaving the page in no state to report
392
+ * anything itself: it did not load (`load_failed`), its document answered an
393
+ * HTTP error (`http_error`), or the OS ended its web process
394
+ * (`process_terminated`).
395
+ */
396
+ declare class YodlWebViewError extends Error {
397
+ readonly code: YodlWebViewErrorCode;
398
+ /** The page's URL without its query, which carries the scanned QR payload. */
399
+ readonly url?: string | undefined;
400
+ /** The HTTP status, for `http_error`. */
401
+ readonly status?: number | undefined;
402
+ constructor(code: YodlWebViewErrorCode, message: string, url?: string, status?: number);
403
+ }
404
+ //#endregion
405
+ export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, YodlUIError, YodlWebViewError, type YodlWebViewErrorCode, createYodlSdk, isPaymentQr };
package/dist/index.d.mts CHANGED
@@ -64,8 +64,13 @@ interface YodlPaymentDetails {
64
64
  };
65
65
  raw?: unknown;
66
66
  }
67
+ /** What a failure message carries; both fields are optional on the wire. */
68
+ interface YodlBridgeError {
69
+ message?: string;
70
+ code?: string | number;
71
+ }
67
72
  //#endregion
68
- //#region ../sdk-core/dist/index-DO0fv_gp.d.mts
73
+ //#region ../sdk-core/dist/index-D5Dst92E.d.mts
69
74
  //#endregion
70
75
  //#region src/evm/wallet-provider.d.ts
71
76
  /**
@@ -369,4 +374,32 @@ declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMod
369
374
  */
370
375
  declare function isPaymentQr(qrData: string | string[]): boolean;
371
376
  //#endregion
372
- export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createYodlSdk, isPaymentQr };
377
+ //#region src/yodl-ui/errors.d.ts
378
+ /**
379
+ * A failure the Yodl UI reported over the bridge (`yodl_payment_error`,
380
+ * `yodl_signup_error`). `code` is the page's own, as it sent it; the class is
381
+ * what tells a host — and an error tracker, which titles an error by its name —
382
+ * that the Yodl UI raised it rather than the wallet.
383
+ */
384
+ declare class YodlUIError extends Error {
385
+ readonly code?: string | number | undefined;
386
+ constructor(error: YodlBridgeError | undefined, fallbackMessage: string);
387
+ }
388
+ /** Why the WebView under the Yodl UI failed. */
389
+ type YodlWebViewErrorCode = 'load_failed' | 'http_error' | 'process_terminated';
390
+ /**
391
+ * The WebView under the Yodl UI failed, leaving the page in no state to report
392
+ * anything itself: it did not load (`load_failed`), its document answered an
393
+ * HTTP error (`http_error`), or the OS ended its web process
394
+ * (`process_terminated`).
395
+ */
396
+ declare class YodlWebViewError extends Error {
397
+ readonly code: YodlWebViewErrorCode;
398
+ /** The page's URL without its query, which carries the scanned QR payload. */
399
+ readonly url?: string | undefined;
400
+ /** The HTTP status, for `http_error`. */
401
+ readonly status?: number | undefined;
402
+ constructor(code: YodlWebViewErrorCode, message: string, url?: string, status?: number);
403
+ }
404
+ //#endregion
405
+ export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, YodlUIError, YodlWebViewError, type YodlWebViewErrorCode, createYodlSdk, isPaymentQr };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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";function h(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const g=/^0x[a-fA-F0-9]{40}$/;function _(e){return typeof e==`string`&&g.test(e)}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const y=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function b(e){if(e===void 0)return!0;if(!v(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function ee(e){if(!v(e))return!1;switch(e.type){case`yodl_payment_details`:return v(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return b(e.error);case`yodl_signup_status`:return x(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return S(e);default:return!1}}function x(e){return typeof e==`string`&&y.has(e)}function S(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const C=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,w=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,T=/^https:\/\/[^\s"\\]+$/,E=[`system`,`inter`,`geist`,`mono`],D=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],O=[`payBackground`,`processing`,`loading`];function k(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function te(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function ne(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const A=new Set([`system`,`light`,`dark`]);function j(e){return typeof e==`string`&&A.has(e)}const M=new Set(E);function N(e,t){if(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of D){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!C.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function P(e,t){if(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of O){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!T.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function F(e){if(!v(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=P(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function I(e){if(!v(e))return{success:!1,error:`(root): expected an object`};let t=L(e);if(!t.success)return t;let n=R(e);if(!n.success)return n;let r=z(e);if(!r.success)return r;let i=B(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=F(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function L(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function R(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!M.has(e.font)?{success:!1,error:`font: must be one of ${[...M].join(`, `)}`}:{success:!0,data:{font:e.font}}}function z(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!w.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function B(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=N(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function V(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function H(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function U(e){if(!v(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!V(r,128))}const re=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function ie(e){if(!v(e)||!H(e,re))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!V(r,128)||!V(i,64)||!_(a))}const ae={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function oe(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function se(e){let t=I(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function ce(e){return e===void 0?{preference:`system`,error:null}:j(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function le(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:se(e),i=ce(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:oe(i.preference,n)},error:a.length>0?a.join(`; `):null}}function ue(e,t){let n=ae[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function de(e,t,n,r){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{}}}}function fe(e,t){return JSON.stringify(k(e,t))}function pe(e,t,n,r){let{envelope:i,error:a}=le(e,t,n);return a&&r?.(a),i}function me(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=le(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function he(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ge=e(null);function _e({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>pe(i,o,c,he),[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(ge.Provider,{value:u,children:s})}function ve(){let e=n(ge);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function ye(e,t){let n=ve(),r=a(()=>me(n.hostTheme,e,t,n.systemScheme,he),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function be(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=ye(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}function xe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!_(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function Se(e,t){return{"X-Yodl-Integration-Id":xe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function W(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 Ce(e){return e.code===4001||/rejected|denied/i.test(e.message)}const we=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],Te=[...we,`not supported`,`not available`];function Ee(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function De(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||Ee(e,we):Ee(e,Te)}function Oe(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function ke(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const Ae={name:`@yodlpay/react-native`,version:`0.11.0`};function je(e){return Se(e,Ae)}function Me(e,t){let n=e.yodlUiBaseUrl?Oe(e.yodlUiBaseUrl):null;if(!(!n||!ke(t,n)))return je(e)}let Ne=0;function Pe(){return Ne+=1,`yodl-${Date.now().toString(36)}-${Ne.toString(36)}`}function Fe(e,t=Pe){return{sessionId:t(),initialHostTheme:e}}function G(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function Ie(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 Le(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>Ie(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function Re(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function ze(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Be(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!Re(t))return;let n=t.receipts;if(n?.length&&!n.some(ze))return n[n.length-1]?.transactionHash}function K(e){return`0x${e.toString(16)}`}function Ve(e,t=`unsupported`){let n={};for(let r of e)n[K(r)]={atomic:{status:t}};return n}function q(e){return e.toLowerCase()}function He(e,t){let n=q(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:K(t.chainId)}}:{}}}function Ue(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function We(e){return{state:e,decision:{kind:`ignore`}}}function Ge(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ke(e,t,n){return!ie(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?We(e):n.supported?q(t.address)===q(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Ge(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:Ge(e,t.requestId,`address_mismatch`):Ge(e,t.requestId,`not_supported`)}function qe(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Je=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Ye(e){return Je.some(t=>t===e)}function Xe(e,t,n){if(!Ye(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=Ie((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=K(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function Ze(e){let t=K(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";function h(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const g=/^0x[a-fA-F0-9]{40}$/;function _(e){return typeof e==`string`&&g.test(e)}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const y=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function b(e){if(e===void 0)return!0;if(!v(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function ee(e){if(!v(e))return!1;switch(e.type){case`yodl_payment_details`:return v(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return b(e.error);case`yodl_signup_status`:return x(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return S(e);default:return!1}}function x(e){return typeof e==`string`&&y.has(e)}function S(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const C=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,w=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,T=/^https:\/\/[^\s"\\]+$/,E=[`system`,`inter`,`geist`,`mono`],D=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],O=[`payBackground`,`processing`,`loading`];function k(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function te(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function ne(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const A=new Set([`system`,`light`,`dark`]);function j(e){return typeof e==`string`&&A.has(e)}const M=new Set(E);function N(e,t){if(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of D){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!C.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function P(e,t){if(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of O){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!T.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function F(e){if(!v(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=P(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function I(e){if(!v(e))return{success:!1,error:`(root): expected an object`};let t=L(e);if(!t.success)return t;let n=R(e);if(!n.success)return n;let r=z(e);if(!r.success)return r;let i=re(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=F(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function L(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function R(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!M.has(e.font)?{success:!1,error:`font: must be one of ${[...M].join(`, `)}`}:{success:!0,data:{font:e.font}}}function z(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!w.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function re(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=N(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function B(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function V(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function H(e){if(!v(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!B(r,128))}const ie=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function ae(e){if(!v(e)||!V(e,ie))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!B(r,128)||!B(i,64)||!_(a))}const oe={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function se(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function ce(e){let t=I(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function le(e){return e===void 0?{preference:`system`,error:null}:j(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function ue(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:ce(e),i=le(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:se(i.preference,n)},error:a.length>0?a.join(`; `):null}}function de(e,t){let n=oe[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function fe(e,t,n,r){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{}}}}function pe(e,t){return JSON.stringify(k(e,t))}function me(e,t,n,r){let{envelope:i,error:a}=ue(e,t,n);return a&&r?.(a),i}function he(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=ue(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function ge(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const _e=e(null);function ve({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>me(i,o,c,ge),[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(_e.Provider,{value:u,children:s})}function ye(){let e=n(_e);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function be(e,t){let n=ye(),r=a(()=>he(n.hostTheme,e,t,n.systemScheme,ge),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function xe(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=be(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}function Se(e){let[t=``]=e.split(/[?#]/,1);return t.replace(/^([a-z][a-z\d+.-]*:\/\/)[^/]*@/i,`$1`)}function Ce(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!_(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function we(e,t){return{"X-Yodl-Integration-Id":Ce(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function U(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 Te(e){return e.code===4001||/rejected|denied/i.test(e.message)}const Ee=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],De=[...Ee,`not supported`,`not available`];function Oe(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ke(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||Oe(e,Ee):Oe(e,De)}function Ae(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function je(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const Me={name:`@yodlpay/react-native`,version:`0.12.0`};function Ne(e){return we(e,Me)}function Pe(e,t){let n=e.yodlUiBaseUrl?Ae(e.yodlUiBaseUrl):null;if(!(!n||!je(t,n)))return Ne(e)}var Fe=class extends Error{code;constructor(e,t){super(e?.message??t),this.name=`YodlUIError`,this.code=e?.code,Object.setPrototypeOf(this,new.target.prototype)}},W=class extends Error{code;url;status;constructor(e,t,n,r){super(t),this.name=`YodlWebViewError`,this.code=e,this.url=n===void 0?void 0:Se(n),this.status=r,Object.setPrototypeOf(this,new.target.prototype)}};let Ie=0;function Le(){return Ie+=1,`yodl-${Date.now().toString(36)}-${Ie.toString(36)}`}function Re(e,t=Le){return{sessionId:t(),initialHostTheme:e}}function G(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function ze(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 Be(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>ze(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function Ve(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function He(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Ue(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!Ve(t))return;let n=t.receipts;if(n?.length&&!n.some(He))return n[n.length-1]?.transactionHash}function K(e){return`0x${e.toString(16)}`}function We(e,t=`unsupported`){let n={};for(let r of e)n[K(r)]={atomic:{status:t}};return n}function q(e){return e.toLowerCase()}function Ge(e,t){let n=q(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:K(t.chainId)}}:{}}}function Ke(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function qe(e){return{state:e,decision:{kind:`ignore`}}}function Je(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ye(e,t,n){return!ae(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?qe(e):n.supported?q(t.address)===q(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Je(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:Je(e,t.requestId,`address_mismatch`):Je(e,t.requestId,`not_supported`)}function Xe(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Ze=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Qe(e){return Ze.some(t=>t===e)}function $e(e,t,n){if(!Qe(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=ze((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=K(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function et(e){let t=K(e.chainId);return`(function() {
2
2
  if (window.ethereum) return;
3
3
 
4
4
  var _address = ${JSON.stringify(e.address.toLowerCase())};
@@ -225,4 +225,7 @@ import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLay
225
225
  announceProvider();
226
226
  window.addEventListener("eip6963:requestProvider", announceProvider);
227
227
  })();
228
- true;`}function Qe(e){return JSON.stringify(e)}function $e(e){return{state:e,message:null,readyAccepted:!1}}function et(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:fe(e.sessionId,e.currentTheme),readyAccepted:t}}function tt(e,t){let n=Qe(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function nt(e,t){let n=Qe(t);if(n===e.currentFingerprint)return $e(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?et(r,!1):$e(r)}function rt(e,t){return!U(t)||t.sessionId!==e.sessionId?$e(e):et({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function J(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 it(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function at(e){return v(e)&&`type`in e}function ot(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function st(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,fetchEmailAttestation:b}=e,x=o(null),S=o(q(s)),C=o(c),w=o(c),T=o(new Set),E=o(v),D=o(_?tt(_,y):null),O=o(_?Ue(_):null),k=o(b);i(()=>{E.current=v},[v]),i(()=>{k.current=b},[b]),i(()=>{D.current=_?tt(_,y):null},[y,_]),i(()=>{O.current=_?Ue(_):null},[_]);let A=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=He({address:S.current,propChainId:C.current,activeChainId:w.current},{address:s,chainId:c});e&&(S.current=e.nextAddress,C.current=e.nextPropChainId,w.current=e.nextActiveChainId,e.accountsChanged&&it(x,`accountsChanged`,e.accountsChanged),e.chainChanged&&it(x,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!D.current)return;let e=nt(D.current,v);D.current=e.state,e.message&&x.current?.postMessage(e.message)},[v]);let j=a(()=>Ze({address:s,chainId:c}),[s,c]),M=t(async(e,t,r)=>{try{let i=Xe(t,r,l);if(`error`in i){J(x,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),J(x,e,null),i.switchesActiveChain&&(w.current=i.requestedChainId,it(x,`chainChanged`,i.chainIdHex))}catch(t){let n=W(t,`Chain request failed`);J(x,e,void 0,G(n)),h?.(n)}},[n,l,h]),N=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>K(e))],i=await n.request({method:`wallet_getCapabilities`,params:r});J(x,e,i)}catch(n){let r=W(n,`Capabilities unavailable`);if(!De(r)){J(x,e,void 0,G(r));return}J(x,e,Ve(Le(t,l),`unsupported`))}},[n,s,l]),P=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Be(r);i&&A(i),J(x,e,r)}catch(t){let n=W(t,`Failed to get call status`);J(x,e,void 0,G(n))}},[n,A]),F=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&A(i),J(x,e,i)}catch(t){let n=W(t,`Request failed`),r=Ce(n);J(x,e,void 0,r?{code:4001,message:n.message}:G(n)),r||h?.(n)}},[n,A,h]),I=t((e,t)=>{let n=O.current;n&&(O.current=qe(n,e),x.current?.postMessage(JSON.stringify(ne(n.sessionId,e,t))))},[]),L=t(async(e,t)=>{let n=k.current;if(!n){I(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}O.current?.sessionId===e&&I(t.requestId,a)},[I]),R=t(e=>{let t=O.current;if(!t)return;let n=Ke(t,e,{walletAddress:S.current,supported:!!k.current});if(O.current=n.state,n.decision.kind===`reject`){I(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&L(t.sessionId,n.decision.request)},[L,I]),z=t((e,t,n)=>{Ye(t)?M(e,t,n):t===`wallet_getCapabilities`?N(e,n):t===`wallet_getCallsStatus`?P(e,n):F(e,t,n)},[M,N,P,F]),B=t(e=>{switch(e.type){case`yodl_signup_status`:f?.(e.status);return;case`yodl_signup_complete`:p?.();return;case`yodl_signup_error`:h?.(ot(e.error,`Signup error`));return;case`yodl_signup_dismissed`:m?.();return}},[f,p,m,h]),V=t(e=>{switch(e.type){case`yodl_payment_details`:d?.(e.details);return;case`yodl_payment_error`:h?.(ot(e.error,`Payment details error`));return;case`ethereum_rpc_request`:z(e.id,e.method,e.params);return;default:B(e)}},[z,B,d,h]),H=t(()=>{let e=O.current;e&&x.current?.postMessage(JSON.stringify(te(e.sessionId,!!k.current)))},[]),U=t(e=>{if(!D.current){g?.();return}let t=nt(D.current,E.current);D.current=t.state,t.message&&x.current?.postMessage(t.message);let n=rt(D.current,e);D.current=n.state,n.readyAccepted&&(n.message&&x.current?.postMessage(n.message),H(),g?.())},[H,g]);return{uiRef:x,injectedJavaScript:j,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(at(t)){if(t.type===`yodl_ready`){U(t);return}if(t.type===`yodl_email_attestation_request`){R(t);return}ee(t)&&V(t)}},[V,R,U])}}function ct(e){return f(lt,{...e},e.uri)}function lt({uri:e,sdkConfig:n,provider:l,address:d,chainId:g,supportedChainIds:_,onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,style:C,backgroundColor:w,hostTheme:T=null,fetchEmailAttestation:E,renderLoading:D,onReady:O,sharedCookiesEnabled:k=!0,thirdPartyCookiesEnabled:te=!0,onLoadStart:ne,...A}){let[j]=s(()=>Fe(T)),M=ue(T,w),N=M.background,[P,F]=s(null),I=P===j.sessionId,L=o(O);i(()=>{L.current=O},[O]);let R=o(!1),z=t(()=>{F(j.sessionId),!R.current&&(R.current=!0,L.current?.())},[j.sessionId]);r(()=>{if(I)return;let e=setTimeout(z,8e3);return()=>clearTimeout(e)},[z,I]);let{uiRef:B,injectedJavaScript:V,onMessage:H}=st({provider:l,address:d,chainId:g,supportedChainIds:_,onReady:z,sessionId:j.sessionId,hostTheme:T,initialHostTheme:j.initialHostTheme,...h({onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,fetchEmailAttestation:E})}),U=a(()=>Oe(e),[e]),re=a(()=>{let t=Me(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),ie=a(()=>e=>!U||!e?.url?!1:ke(e.url,U)||e.url.startsWith(`about:`),[U]),ae=I?null:D?D():f(c,{color:M.spinner});return p(u,{style:[ut.container,{backgroundColor:N},C],children:[f(m,{ref:B,source:re,originWhitelist:U?[U]:[],onShouldStartLoadWithRequest:ie,javaScriptEnabled:!0,sharedCookiesEnabled:k,thirdPartyCookiesEnabled:te,injectedJavaScriptBeforeContentLoaded:V,injectedJavaScriptObject:de(j.sessionId,j.initialHostTheme,n.integrationAddress,E?{emailAttestation:!0}:void 0),onMessage:H,...ne!==void 0&&{onLoadStart:ne},style:[ut.ui,{backgroundColor:N}],...A}),ae&&f(u,{style:[ut.overlay,{backgroundColor:N}],children:ae})]})}const ut=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function dt({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{sdk:d,hostProps:p}=be(l,u),m=a(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]);return f(ct,{uri:m,...p,...h({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c})})}function ft(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 pt(e){if(Array.isArray(e))return e}function mt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ht(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 gt(e,t,n){return t&&ht(e.prototype,t),n&&ht(e,n),e}function _t(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 vt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yt(e,t){return pt(e)||_t(e,t)||xt(e,t)||vt()}function bt(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function xt(e,t){if(e){if(typeof e==`string`)return ft(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 ft(e,t)}}var St=Object.defineProperty,Ct=function(e,t,n){return t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},wt=function(e,t){for(var n in t)St(e,n,{get:t[n],enumerable:!0})},Y=function(e,t,n){return Ct(e,(t===void 0?`undefined`:bt(t))===`symbol`?t:t+``,n)},Tt=[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 Et(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=Tt[(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 Dt(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 X(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+=X(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 Ot(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Et(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Z(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Ot(e,n),e}function kt(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 At(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`,X(o)),Q(`53`,`764`),Q(`58`,`TH`)];return n&&s.push(Q(`54`,Number(n).toFixed(2))),a&&s.push(Q(`62`,X([Q(`07`,a)]))),Z(X(s),`63`)}var jt=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;mt(this,e),Y(this,`billerId`),Y(this,`ref1`),Y(this,`ref2`),Y(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return gt(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 At({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=yt(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}(),Mt=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Mt||{});function Nt(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=X([Q(`00`,`A000000677010111`),Q(Mt[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))),Z(X(a),`63`)}wt({},{ProxyType:function(){return Mt},anyId:function(){return Nt},billPayment:function(){return At},botBarcode:function(){return Pt},slipVerify:function(){return Ft},trueMoney:function(){return Lt},trueMoneySlipVerify:function(){return Rt}});function Pt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new jt(t,n,r,i).toString()}function Ft(e){var t=e.sendingBank,n=e.transRef;return Z(X([Q(`00`,X([Q(`00`,`000001`),Q(`01`,t),Q(`02`,n)])),Q(`51`,`TH`)]),`91`)}function It(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Lt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=X([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`,It(r))),Z(X(a),`63`)}function Rt(e){var t=e.eventType,n=e.transactionId,r=e.date;return Z(X([Q(`00`,X([Q(`00`,`01`),Q(`01`,`01`),Q(`02`,t),Q(`03`,n),Q(`04`,r)]))]),`91`,!1)}function zt(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 Bt(e){if(Array.isArray(e))return e}function Vt(e){if(Array.isArray(e))return zt(e)}function Ht(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ut(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 Wt(e,t,n){return t&&Ut(e.prototype,t),n&&Ut(e,n),e}function Gt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function qt(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 Jt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xt(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){Gt(e,t,n[t])})}return e}function Zt(e,t){return Bt(e)||qt(e,t)||$t(e,t)||Jt()}function Qt(e){return Vt(e)||Kt(e)||$t(e)||Yt()}function $t(e,t){if(e){if(typeof e==`string`)return zt(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 zt(e,t)}}wt({},{anyId:function(){return nn},bcelOneProof:function(){return tn},billPayment:function(){return rn},slipVerify:function(){return an},trueMoneySlipVerify:function(){return on}});var en=function(){function e(t,n){Ht(this,e),Y(this,`payload`),Y(this,`tags`),this.payload=t,this.tags=n}return Wt(e,[{key:`getTag`,value:function(e,t){return kt(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=Z(X(Qt(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],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Ot(e.slice(0,-4)))return null;var r=Dt(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=Dt(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 en(e,r)}function tn(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 nn(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(Mt).find(function(e){var n=Zt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Zt(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 Xt({type:o,target:c},u!==void 0&&{amount:u})}function rn(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 Xt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function an(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 on(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 sn={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function cn(e){return e?e.getTagValue(`58`)??null:null}function ln(e){let t=[];for(let[n,r]of Object.entries(sn))r.includes(e)&&t.push(n);return t}function un(e){return e.toLowerCase().startsWith(`upi://`)&&e.length>6}function dn(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function fn(e,t){return!t||t.includes(e)}function pn(e,t){let n=[];try{let r=cn($(e));if(!r)return n;for(let e of ln(r))fn(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function mn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(dn(n))return fn(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=pn(n,t);return r.length>0?r:un(n)&&fn(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]:r}function hn(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function gn(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function _n(e){return gn(e,`/sdk/signup`)}const vn=`always`;function yn(e,t,n=vn){return!e||typeof e!=`string`||e.trim().length===0||hn(mn(e)).length===0?null:gn(t,`/resolve`,{data:e,navigateOnSubmit:n===vn?void 0:n})}function bn({qrData:e,navigateOnSubmit:t,onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:p}){let{sdk:m,hostProps:g}=be(d,p),_=a(()=>yn(e,m.config.yodlUiBaseUrl,t),[e,m.config.yodlUiBaseUrl,t]);return _?f(ct,{uri:_,...g,...h({onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})}):null}function xn({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{sdk:p,hostProps:m}=be(u,d),g=a(()=>_n(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]);return f(ct,{uri:g,...m,...h({onSignupStatusChange:e,onSignedUp:t,onError:n,onSignupDismissed:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l})})}function Sn(e){return(Array.isArray(e)?e:[e]).some(e=>hn(mn(e)).length>0)}var Cn=class{config;constructor(e){let t=xe(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 wn(e){return new Cn(e)}export{dt as YodlDashboard,bn as YodlPayment,_e as YodlProvider,Cn as YodlSdk,xn as YodlSignup,wn as createYodlSdk,Sn as isPaymentQr};
228
+ true;`}function tt(e){return JSON.stringify(e)}function nt(e){return{state:e,message:null,readyAccepted:!1}}function rt(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:pe(e.sessionId,e.currentTheme),readyAccepted:t}}function it(e,t){let n=tt(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function at(e,t){let n=tt(t);if(n===e.currentFingerprint)return nt(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?rt(r,!1):nt(r)}function ot(e,t){return!H(t)||t.sessionId!==e.sessionId?nt(e):rt({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function J(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 st(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function ct(e){return v(e)&&`type`in e}function lt(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,fetchEmailAttestation:b}=e,x=o(null),S=o(q(s)),C=o(c),w=o(c),T=o(new Set),E=o(v),D=o(_?it(_,y):null),O=o(_?Ke(_):null),k=o(b);i(()=>{E.current=v},[v]),i(()=>{k.current=b},[b]),i(()=>{D.current=_?it(_,y):null},[y,_]),i(()=>{O.current=_?Ke(_):null},[_]);let A=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=Ge({address:S.current,propChainId:C.current,activeChainId:w.current},{address:s,chainId:c});e&&(S.current=e.nextAddress,C.current=e.nextPropChainId,w.current=e.nextActiveChainId,e.accountsChanged&&st(x,`accountsChanged`,e.accountsChanged),e.chainChanged&&st(x,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!D.current)return;let e=at(D.current,v);D.current=e.state,e.message&&x.current?.postMessage(e.message)},[v]);let j=a(()=>et({address:s,chainId:c}),[s,c]),M=t(async(e,t,r)=>{try{let i=$e(t,r,l);if(`error`in i){J(x,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),J(x,e,null),i.switchesActiveChain&&(w.current=i.requestedChainId,st(x,`chainChanged`,i.chainIdHex))}catch(t){let n=U(t,`Chain request failed`);J(x,e,void 0,G(n)),h?.(n)}},[n,l,h]),N=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>K(e))],i=await n.request({method:`wallet_getCapabilities`,params:r});J(x,e,i)}catch(n){let r=U(n,`Capabilities unavailable`);if(!ke(r)){J(x,e,void 0,G(r));return}J(x,e,We(Be(t,l),`unsupported`))}},[n,s,l]),P=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Ue(r);i&&A(i),J(x,e,r)}catch(t){let n=U(t,`Failed to get call status`);J(x,e,void 0,G(n))}},[n,A]),F=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&A(i),J(x,e,i)}catch(t){let n=U(t,`Request failed`),r=Te(n);J(x,e,void 0,r?{code:4001,message:n.message}:G(n)),r||h?.(n)}},[n,A,h]),I=t((e,t)=>{let n=O.current;n&&(O.current=Xe(n,e),x.current?.postMessage(JSON.stringify(ne(n.sessionId,e,t))))},[]),L=t(async(e,t)=>{let n=k.current;if(!n){I(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}O.current?.sessionId===e&&I(t.requestId,a)},[I]),R=t(e=>{let t=O.current;if(!t)return;let n=Ye(t,e,{walletAddress:S.current,supported:!!k.current});if(O.current=n.state,n.decision.kind===`reject`){I(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&L(t.sessionId,n.decision.request)},[L,I]),z=t((e,t,n)=>{Qe(t)?M(e,t,n):t===`wallet_getCapabilities`?N(e,n):t===`wallet_getCallsStatus`?P(e,n):F(e,t,n)},[M,N,P,F]),re=t(e=>{switch(e.type){case`yodl_signup_status`:f?.(e.status);return;case`yodl_signup_complete`:p?.();return;case`yodl_signup_error`:h?.(new Fe(e.error,`Signup error`));return;case`yodl_signup_dismissed`:m?.();return}},[f,p,m,h]),B=t(e=>{switch(e.type){case`yodl_payment_details`:d?.(e.details);return;case`yodl_payment_error`:h?.(new Fe(e.error,`Payment details error`));return;case`ethereum_rpc_request`:z(e.id,e.method,e.params);return;default:re(e)}},[z,re,d,h]),V=t(()=>{let e=O.current;e&&x.current?.postMessage(JSON.stringify(te(e.sessionId,!!k.current)))},[]),H=t(e=>{if(!D.current){g?.();return}let t=at(D.current,E.current);D.current=t.state,t.message&&x.current?.postMessage(t.message);let n=ot(D.current,e);D.current=n.state,n.readyAccepted&&(n.message&&x.current?.postMessage(n.message),V(),g?.())},[V,g]);return{uiRef:x,injectedJavaScript:j,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(ct(t)){if(t.type===`yodl_ready`){H(t);return}if(t.type===`yodl_email_attestation_request`){R(t);return}ee(t)&&B(t)}},[B,R,H])}}function ut(e){return f(dt,{...e},e.uri)}function dt({uri:e,sdkConfig:n,provider:l,address:d,chainId:g,supportedChainIds:_,onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,style:C,backgroundColor:w,hostTheme:T=null,fetchEmailAttestation:E,renderLoading:D,onReady:O,sharedCookiesEnabled:k=!0,thirdPartyCookiesEnabled:te=!0,onLoadStart:ne,...A}){let[j]=s(()=>Re(T)),M=de(T,w),N=M.background,[P,F]=s(null),I=P===j.sessionId,L=o(O);i(()=>{L.current=O},[O]);let R=o(!1),z=t(()=>{F(j.sessionId),!R.current&&(R.current=!0,L.current?.())},[j.sessionId]);r(()=>{if(I)return;let e=setTimeout(z,8e3);return()=>clearTimeout(e)},[z,I]);let{uiRef:re,injectedJavaScript:B,onMessage:V}=lt({provider:l,address:d,chainId:g,supportedChainIds:_,onReady:z,sessionId:j.sessionId,hostTheme:T,initialHostTheme:j.initialHostTheme,...h({onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,fetchEmailAttestation:E})}),H=a(()=>Ae(e),[e]),ie=a(()=>{let t=Pe(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),ae=a(()=>e=>!H||!e?.url?!1:je(e.url,H)||e.url.startsWith(`about:`),[H]),oe=a(()=>{if(!S)return{};let t=e=>S(new W(`process_terminated`,`The Yodl UI web process was terminated`,e));return{onError:({nativeEvent:e})=>S(new W(`load_failed`,`The Yodl UI failed to load: ${e.description}`,e.url)),onHttpError:({nativeEvent:e})=>S(new W(`http_error`,`The Yodl UI answered HTTP ${e.statusCode}`,e.url,e.statusCode)),onRenderProcessGone:()=>t(e),onContentProcessDidTerminate:({nativeEvent:e})=>t(e.url)}},[S,e]),se=I?null:D?D():f(c,{color:M.spinner});return p(u,{style:[ft.container,{backgroundColor:N},C],children:[f(m,{ref:re,source:ie,originWhitelist:H?[H]:[],onShouldStartLoadWithRequest:ae,javaScriptEnabled:!0,sharedCookiesEnabled:k,thirdPartyCookiesEnabled:te,injectedJavaScriptBeforeContentLoaded:B,injectedJavaScriptObject:fe(j.sessionId,j.initialHostTheme,n.integrationAddress,E?{emailAttestation:!0}:void 0),onMessage:V,...oe,...ne!==void 0&&{onLoadStart:ne},style:[ft.ui,{backgroundColor:N}],...A}),se&&f(u,{style:[ft.overlay,{backgroundColor:N}],children:se})]})}const ft=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function pt({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{sdk:d,hostProps:p}=xe(l,u),m=a(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]);return f(ut,{uri:m,...p,...h({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c})})}function mt(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function ht(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 gt(e){if(Array.isArray(e))return e}function _t(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function vt(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 yt(e,t,n){return t&&vt(e.prototype,t),n&&vt(e,n),e}function bt(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 xt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
229
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function St(e,t){return gt(e)||bt(e,t)||wt(e,t)||xt()}function Ct(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function wt(e,t){if(e){if(typeof e==`string`)return ht(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 ht(e,t)}}var Tt=Object.defineProperty,Et=function(e,t,n){return t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},Dt=function(e,t){for(var n in t)Tt(e,n,{get:t[n],enumerable:!0})},Y=function(e,t,n){return Et(e,(t===void 0?`undefined`:Ct(t))===`symbol`?t:t+``,n)},Ot=[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 kt(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=65536+(r-55296<<10)+(i-56320),n++)}r>=55296&&r<=57343&&(r=65533),r<128?t.push(r):r<2048?t.push(192|r>>6,128|r&63):r<65536?t.push(224|r>>12,128|r>>6&63,128|r&63):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}return t}function At(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=typeof e==`string`?kt(e):e,r=!0,i=!1,a=void 0;try{for(var o=n[Symbol.iterator](),s;!(r=(s=o.next()).done);r=!0)t=Ot[(s.value^t>>8)&255]^t<<8}catch(e){i=!0,a=e}finally{try{!r&&o.return!=null&&o.return()}finally{if(i)throw a}}return(t^0)&65535}function jt(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 X(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+=X(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 Mt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=At(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Z(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Mt(e,n),e}function Nt(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 Pt(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`,X(o)),Q(`53`,`764`),Q(`58`,`TH`)];return n&&s.push(Q(`54`,Number(n).toFixed(2))),a&&s.push(Q(`62`,X([Q(`07`,a)]))),Z(X(s),`63`)}var Ft=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;_t(this,e),Y(this,`billerId`),Y(this,`ref1`),Y(this,`ref2`),Y(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return yt(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 Pt({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=St(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}(),It=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(It||{});function Lt(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=X([Q(`00`,`A000000677010111`),Q(It[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))),Z(X(a),`63`)}Dt({},{ProxyType:function(){return It},anyId:function(){return Lt},billPayment:function(){return Pt},botBarcode:function(){return Rt},slipVerify:function(){return zt},trueMoney:function(){return Vt},trueMoneySlipVerify:function(){return Ht}});function Rt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Ft(t,n,r,i).toString()}function zt(e){var t=e.sendingBank,n=e.transRef;return Z(X([Q(`00`,X([Q(`00`,`000001`),Q(`01`,t),Q(`02`,n)])),Q(`51`,`TH`)]),`91`)}function Bt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Vt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=X([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`,Bt(r))),Z(X(a),`63`)}function Ht(e){var t=e.eventType,n=e.transactionId,r=e.date;return Z(X([Q(`00`,X([Q(`00`,`01`),Q(`01`,`01`),Q(`02`,t),Q(`03`,n),Q(`04`,r)]))]),`91`,!1)}function Ut(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 Wt(e){if(Array.isArray(e))return e}function Gt(e){if(Array.isArray(e))return Ut(e)}function Kt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function qt(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 Jt(e,t,n){return t&&qt(e.prototype,t),n&&qt(e,n),e}function Yt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Zt(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 Qt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
230
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $t(){throw TypeError(`Invalid attempt to spread non-iterable instance.
231
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function en(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){Yt(e,t,n[t])})}return e}function tn(e,t){return Wt(e)||Zt(e,t)||rn(e,t)||Qt()}function nn(e){return Gt(e)||Xt(e)||rn(e)||$t()}function rn(e,t){if(e){if(typeof e==`string`)return Ut(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 Ut(e,t)}}Dt({},{anyId:function(){return sn},bcelOneProof:function(){return on},billPayment:function(){return cn},slipVerify:function(){return ln},trueMoneySlipVerify:function(){return un}});var an=function(){function e(t,n){Kt(this,e),Y(this,`payload`),Y(this,`tags`),this.payload=t,this.tags=n}return Jt(e,[{key:`getTag`,value:function(e,t){return Nt(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=Z(X(nn(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],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Mt(e.slice(0,-4)))return null;var r=jt(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=jt(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 an(e,r)}function on(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 sn(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(It).find(function(e){var n=tn(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=tn(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 en({type:o,target:c},u!==void 0&&{amount:u})}function cn(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 en({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function ln(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 un(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 dn={aeon:[`PH`,`VN`,`BR`,`AR`,`CO`,`PE`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function fn(e){return e?e.getTagValue(`58`)??null:null}function pn(e){let t=[];for(let[n,r]of Object.entries(dn))r.includes(e)&&t.push(n);return t}const mn=/^[a-z0-9+/]{64,}={0,2}\|[0-9a-f]{16,64}$/i;function hn(e){return mn.test(e)}function gn(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function _n(e,t){return!t||t.includes(e)}function vn(e,t){let n=[];try{let r=fn($(e));if(!r)return n;for(let e of pn(r))_n(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function yn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(gn(n))return _n(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=vn(n,t);return r.length>0?r:hn(n)&&_n(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]:r}function bn(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function xn(e){return bn(e,`/sdk/signup`)}const Sn=`always`;function Cn(e,t,n=Sn){return!e||typeof e!=`string`||e.trim().length===0||mt(yn(e)).length===0?null:bn(t,`/resolve`,{data:e,navigateOnSubmit:n===Sn?void 0:n})}function wn({qrData:e,navigateOnSubmit:t,onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:p}){let{sdk:m,hostProps:g}=xe(d,p),_=a(()=>Cn(e,m.config.yodlUiBaseUrl,t),[e,m.config.yodlUiBaseUrl,t]);return _?f(ut,{uri:_,...g,...h({onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})}):null}function Tn({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{sdk:p,hostProps:m}=xe(u,d),g=a(()=>xn(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]);return f(ut,{uri:g,...m,...h({onSignupStatusChange:e,onSignedUp:t,onError:n,onSignupDismissed:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l})})}function En(e){return(Array.isArray(e)?e:[e]).some(e=>mt(yn(e)).length>0)}var Dn=class{config;constructor(e){let t=Ce(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 On(e){return new Dn(e)}export{pt as YodlDashboard,wn as YodlPayment,ve as YodlProvider,Dn as YodlSdk,Tn as YodlSignup,Fe as YodlUIError,W as YodlWebViewError,On as createYodlSdk,En as isPaymentQr};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yodlpay/react-native",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
6
6
  "keywords": [
@@ -77,7 +77,7 @@
77
77
  "tsdown": "^0.22.14",
78
78
  "typescript": "^5.9.0",
79
79
  "vitest": "^4.1.11",
80
- "@yodlpay/sdk-core": "0.23.0"
80
+ "@yodlpay/sdk-core": "0.27.0"
81
81
  },
82
82
  "scripts": {
83
83
  "build": "tsdown",