@imtbl/sdk 1.15.6 → 1.15.7
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/dist/blockchain_data.js +2 -2
- package/dist/browser/checkout/BridgeWidget-2efbd9ad.js +1 -0
- package/dist/browser/checkout/{OnRampWidget-8e8b8819.js → OnRampWidget-a66e7fa3.js} +1 -1
- package/dist/browser/checkout/SaleWidget-3c62a591.js +2 -0
- package/dist/browser/checkout/{SpendingCapHero-800633cb.js → SpendingCapHero-f79df11e.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-4214431b.js → SwapWidget-c978d4a4.js} +1 -1
- package/dist/browser/checkout/{TopUpView-c90cfc04.js → TopUpView-16db081a.js} +1 -1
- package/dist/browser/checkout/{WalletWidget-c00d8723.js → WalletWidget-a5c469ba.js} +1 -1
- package/dist/browser/checkout/{auto-track-6525038f.js → auto-track-639217b4.js} +1 -1
- package/dist/browser/checkout/balance-123191fd.js +1 -0
- package/dist/browser/checkout/index-0246bdc8.js +1 -0
- package/dist/browser/checkout/{index-41e34266.js → index-0e73c11a.js} +1 -1
- package/dist/browser/checkout/{index-32df522a.js → index-2141407f.js} +1 -1
- package/dist/browser/checkout/{index-89152f0a.js → index-4b1d2f64.js} +12 -12
- package/dist/browser/checkout/{index-6817e91e.js → index-4c08daa5.js} +17 -17
- package/dist/browser/checkout/{index-b0776e1e.js → index-7c3b9755.js} +1 -1
- package/dist/browser/checkout/{index-ac189cb1.js → index-92d189dd.js} +1 -1
- package/dist/browser/checkout/{index-3e347faa.js → index-9c24e104.js} +1 -1
- package/dist/browser/checkout/{index.umd-fc914ede.js → index.umd-ccd06a86.js} +1 -1
- package/dist/browser/checkout/{retry-06ea349a.js → retry-428bd9ee.js} +1 -1
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/{useTransakEvents-2b588362.js → useTransakEvents-c01d9b36.js} +1 -1
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +61 -61
- package/dist/checkout.d.ts +2 -0
- package/dist/checkout.js +18 -11
- package/dist/config.js +1 -1
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +22 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -14
- package/dist/orderbook.js +1 -1
- package/dist/passport.js +5 -4
- package/dist/x.js +3 -3
- package/package.json +1 -1
- package/dist/browser/checkout/BridgeWidget-6e7e7a05.js +0 -1
- package/dist/browser/checkout/SaleWidget-7d3e4b1b.js +0 -2
- package/dist/browser/checkout/balance-c7e1bedb.js +0 -1
- package/dist/browser/checkout/index-e0bf7c42.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -181,7 +181,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
181
181
|
};
|
|
182
182
|
|
|
183
183
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
184
|
-
const SDK_VERSION$1 = '1.15.
|
|
184
|
+
const SDK_VERSION$1 = '1.15.7';
|
|
185
185
|
const getReferrer$1 = () => {
|
|
186
186
|
if (isNode$1()) {
|
|
187
187
|
return '';
|
|
@@ -13557,7 +13557,7 @@ class MultiRollupApiClients {
|
|
|
13557
13557
|
}
|
|
13558
13558
|
|
|
13559
13559
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13560
|
-
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.15.
|
|
13560
|
+
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.15.7' };
|
|
13561
13561
|
const createConfig$1 = ({ basePath, headers, }) => {
|
|
13562
13562
|
if (!basePath.trim()) {
|
|
13563
13563
|
throw Error('basePath can not be empty');
|
|
@@ -13629,7 +13629,7 @@ class APIError extends Error {
|
|
|
13629
13629
|
|
|
13630
13630
|
/* eslint-disable implicit-arrow-linebreak */
|
|
13631
13631
|
const defaultHeaders$1 = {
|
|
13632
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.15.
|
|
13632
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.15.7',
|
|
13633
13633
|
};
|
|
13634
13634
|
/**
|
|
13635
13635
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -14106,7 +14106,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
|
|
|
14106
14106
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
14107
14107
|
class ApiConfiguration extends index$2.Configuration {
|
|
14108
14108
|
}
|
|
14109
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.
|
|
14109
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.7' };
|
|
14110
14110
|
/**
|
|
14111
14111
|
* @dev use createImmutableXConfiguration instead
|
|
14112
14112
|
*/
|
|
@@ -14145,7 +14145,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
14145
14145
|
chainID,
|
|
14146
14146
|
coreContractAddress,
|
|
14147
14147
|
registrationContractAddress,
|
|
14148
|
-
sdkVersion: 'ts-immutable-sdk-1.15.
|
|
14148
|
+
sdkVersion: 'ts-immutable-sdk-1.15.7',
|
|
14149
14149
|
baseConfig,
|
|
14150
14150
|
});
|
|
14151
14151
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
|
@@ -24317,6 +24317,7 @@ const getAuthConfiguration = (config) => {
|
|
|
24317
24317
|
end_session_endpoint: endSessionEndpoint,
|
|
24318
24318
|
},
|
|
24319
24319
|
mergeClaims: true,
|
|
24320
|
+
automaticSilentRenew: false,
|
|
24320
24321
|
scope: oidcConfiguration.scope,
|
|
24321
24322
|
userStore,
|
|
24322
24323
|
};
|
|
@@ -45439,7 +45440,7 @@ const flattenProperties = (properties) => {
|
|
|
45439
45440
|
};
|
|
45440
45441
|
|
|
45441
45442
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
45442
|
-
const SDK_VERSION = '1.15.
|
|
45443
|
+
const SDK_VERSION = '1.15.7';
|
|
45443
45444
|
const getReferrer = () => {
|
|
45444
45445
|
if (isNode()) {
|
|
45445
45446
|
return '';
|
|
@@ -50619,7 +50620,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
50619
50620
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
50620
50621
|
};
|
|
50621
50622
|
|
|
50622
|
-
const SDK_VERSION_MARKER = '1.15.
|
|
50623
|
+
const SDK_VERSION_MARKER = '1.15.7';
|
|
50623
50624
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
50624
50625
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
50625
50626
|
|
|
@@ -54041,13 +54042,20 @@ const sell = async (config, provider, orders) => {
|
|
|
54041
54042
|
const itemRequirements = [
|
|
54042
54043
|
getERC721Requirement(sellToken.id, sellToken.collectionAddress, spenderAddress),
|
|
54043
54044
|
];
|
|
54044
|
-
|
|
54045
|
-
|
|
54046
|
-
|
|
54047
|
-
|
|
54048
|
-
|
|
54049
|
-
|
|
54050
|
-
|
|
54045
|
+
let smartCheckoutResult;
|
|
54046
|
+
const isPassport = provider.provider?.isPassport;
|
|
54047
|
+
if (!isPassport) {
|
|
54048
|
+
smartCheckoutResult = await measureAsyncExecution(config, 'Total time running smart checkout', smartCheckout(config, provider, itemRequirements, {
|
|
54049
|
+
type: TransactionOrGasType.GAS,
|
|
54050
|
+
gasToken: {
|
|
54051
|
+
type: GasTokenType.NATIVE,
|
|
54052
|
+
limit: ethers.BigNumber.from(constants.estimatedFulfillmentGasGwei),
|
|
54053
|
+
},
|
|
54054
|
+
}));
|
|
54055
|
+
}
|
|
54056
|
+
else {
|
|
54057
|
+
smartCheckoutResult = { sufficient: true, transactionRequirements: [] };
|
|
54058
|
+
}
|
|
54051
54059
|
if (smartCheckoutResult.sufficient) {
|
|
54052
54060
|
const unsignedTransactions = await getUnsignedERC721Transactions(listing.actions);
|
|
54053
54061
|
const approvalResult = await signApprovalTransactions(provider, unsignedTransactions.approvalTransactions);
|
package/dist/index.d.ts
CHANGED
|
@@ -27986,6 +27986,8 @@ declare enum ConnectTargetLayer {
|
|
|
27986
27986
|
type ConnectWidgetParams = {
|
|
27987
27987
|
/** The language to use for the connect widget */
|
|
27988
27988
|
language?: WidgetLanguage;
|
|
27989
|
+
/** The target chain to connect to as part of the connection process (defaults to Immutable zkEVM / Immutable zkEVM Testnet) */
|
|
27990
|
+
targetChainId?: ChainId;
|
|
27989
27991
|
};
|
|
27990
27992
|
|
|
27991
27993
|
/**
|
package/dist/index.js
CHANGED
|
@@ -159,7 +159,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
162
|
-
const SDK_VERSION$1 = '1.15.
|
|
162
|
+
const SDK_VERSION$1 = '1.15.7';
|
|
163
163
|
const getReferrer$1 = () => {
|
|
164
164
|
if (isNode$1()) {
|
|
165
165
|
return '';
|
|
@@ -13535,7 +13535,7 @@ class MultiRollupApiClients {
|
|
|
13535
13535
|
}
|
|
13536
13536
|
|
|
13537
13537
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13538
|
-
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.15.
|
|
13538
|
+
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.15.7' };
|
|
13539
13539
|
const createConfig$1 = ({ basePath, headers, }) => {
|
|
13540
13540
|
if (!basePath.trim()) {
|
|
13541
13541
|
throw Error('basePath can not be empty');
|
|
@@ -13607,7 +13607,7 @@ class APIError extends Error {
|
|
|
13607
13607
|
|
|
13608
13608
|
/* eslint-disable implicit-arrow-linebreak */
|
|
13609
13609
|
const defaultHeaders$1 = {
|
|
13610
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.15.
|
|
13610
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.15.7',
|
|
13611
13611
|
};
|
|
13612
13612
|
/**
|
|
13613
13613
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -14084,7 +14084,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
|
|
|
14084
14084
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
14085
14085
|
class ApiConfiguration extends index$2.Configuration {
|
|
14086
14086
|
}
|
|
14087
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.
|
|
14087
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.7' };
|
|
14088
14088
|
/**
|
|
14089
14089
|
* @dev use createImmutableXConfiguration instead
|
|
14090
14090
|
*/
|
|
@@ -14123,7 +14123,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
14123
14123
|
chainID,
|
|
14124
14124
|
coreContractAddress,
|
|
14125
14125
|
registrationContractAddress,
|
|
14126
|
-
sdkVersion: 'ts-immutable-sdk-1.15.
|
|
14126
|
+
sdkVersion: 'ts-immutable-sdk-1.15.7',
|
|
14127
14127
|
baseConfig,
|
|
14128
14128
|
});
|
|
14129
14129
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
|
@@ -24295,6 +24295,7 @@ const getAuthConfiguration = (config) => {
|
|
|
24295
24295
|
end_session_endpoint: endSessionEndpoint,
|
|
24296
24296
|
},
|
|
24297
24297
|
mergeClaims: true,
|
|
24298
|
+
automaticSilentRenew: false,
|
|
24298
24299
|
scope: oidcConfiguration.scope,
|
|
24299
24300
|
userStore,
|
|
24300
24301
|
};
|
|
@@ -45417,7 +45418,7 @@ const flattenProperties = (properties) => {
|
|
|
45417
45418
|
};
|
|
45418
45419
|
|
|
45419
45420
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
45420
|
-
const SDK_VERSION = '1.15.
|
|
45421
|
+
const SDK_VERSION = '1.15.7';
|
|
45421
45422
|
const getReferrer = () => {
|
|
45422
45423
|
if (isNode()) {
|
|
45423
45424
|
return '';
|
|
@@ -50597,7 +50598,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
50597
50598
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
50598
50599
|
};
|
|
50599
50600
|
|
|
50600
|
-
const SDK_VERSION_MARKER = '1.15.
|
|
50601
|
+
const SDK_VERSION_MARKER = '1.15.7';
|
|
50601
50602
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
50602
50603
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
50603
50604
|
|
|
@@ -54019,13 +54020,20 @@ const sell = async (config, provider, orders) => {
|
|
|
54019
54020
|
const itemRequirements = [
|
|
54020
54021
|
getERC721Requirement(sellToken.id, sellToken.collectionAddress, spenderAddress),
|
|
54021
54022
|
];
|
|
54022
|
-
|
|
54023
|
-
|
|
54024
|
-
|
|
54025
|
-
|
|
54026
|
-
|
|
54027
|
-
|
|
54028
|
-
|
|
54023
|
+
let smartCheckoutResult;
|
|
54024
|
+
const isPassport = provider.provider?.isPassport;
|
|
54025
|
+
if (!isPassport) {
|
|
54026
|
+
smartCheckoutResult = await measureAsyncExecution(config, 'Total time running smart checkout', smartCheckout(config, provider, itemRequirements, {
|
|
54027
|
+
type: TransactionOrGasType.GAS,
|
|
54028
|
+
gasToken: {
|
|
54029
|
+
type: GasTokenType.NATIVE,
|
|
54030
|
+
limit: BigNumber$1.from(constants.estimatedFulfillmentGasGwei),
|
|
54031
|
+
},
|
|
54032
|
+
}));
|
|
54033
|
+
}
|
|
54034
|
+
else {
|
|
54035
|
+
smartCheckoutResult = { sufficient: true, transactionRequirements: [] };
|
|
54036
|
+
}
|
|
54029
54037
|
if (smartCheckoutResult.sufficient) {
|
|
54030
54038
|
const unsignedTransactions = await getUnsignedERC721Transactions(listing.actions);
|
|
54031
54039
|
const approvalResult = await signApprovalTransactions(provider, unsignedTransactions.approvalTransactions);
|
package/dist/orderbook.js
CHANGED
|
@@ -131,7 +131,7 @@ const flattenProperties = (properties) => {
|
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
134
|
-
const SDK_VERSION = '1.15.
|
|
134
|
+
const SDK_VERSION = '1.15.7';
|
|
135
135
|
const getReferrer = () => {
|
|
136
136
|
if (isNode()) {
|
|
137
137
|
return '';
|
package/dist/passport.js
CHANGED
|
@@ -11350,7 +11350,7 @@ class MultiRollupApiClients {
|
|
|
11350
11350
|
}
|
|
11351
11351
|
|
|
11352
11352
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11353
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.15.
|
|
11353
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.15.7' };
|
|
11354
11354
|
const createConfig$1 = ({ basePath, headers, }) => {
|
|
11355
11355
|
if (!basePath.trim()) {
|
|
11356
11356
|
throw Error('basePath can not be empty');
|
|
@@ -11529,7 +11529,7 @@ const flattenProperties = (properties) => {
|
|
|
11529
11529
|
};
|
|
11530
11530
|
|
|
11531
11531
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
11532
|
-
const SDK_VERSION = '1.15.
|
|
11532
|
+
const SDK_VERSION = '1.15.7';
|
|
11533
11533
|
const getReferrer = () => {
|
|
11534
11534
|
if (isNode()) {
|
|
11535
11535
|
return '';
|
|
@@ -11779,7 +11779,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
11779
11779
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
11780
11780
|
class ApiConfiguration extends index$2.Configuration {
|
|
11781
11781
|
}
|
|
11782
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.
|
|
11782
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.7' };
|
|
11783
11783
|
/**
|
|
11784
11784
|
* @dev use createImmutableXConfiguration instead
|
|
11785
11785
|
*/
|
|
@@ -11818,7 +11818,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11818
11818
|
chainID,
|
|
11819
11819
|
coreContractAddress,
|
|
11820
11820
|
registrationContractAddress,
|
|
11821
|
-
sdkVersion: 'ts-immutable-sdk-1.15.
|
|
11821
|
+
sdkVersion: 'ts-immutable-sdk-1.15.7',
|
|
11822
11822
|
baseConfig,
|
|
11823
11823
|
});
|
|
11824
11824
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
|
@@ -19273,6 +19273,7 @@ const getAuthConfiguration = (config) => {
|
|
|
19273
19273
|
end_session_endpoint: endSessionEndpoint,
|
|
19274
19274
|
},
|
|
19275
19275
|
mergeClaims: true,
|
|
19276
|
+
automaticSilentRenew: false,
|
|
19276
19277
|
scope: oidcConfiguration.scope,
|
|
19277
19278
|
userStore,
|
|
19278
19279
|
};
|
package/dist/x.js
CHANGED
|
@@ -8954,7 +8954,7 @@ const flattenProperties = (properties) => {
|
|
|
8954
8954
|
};
|
|
8955
8955
|
|
|
8956
8956
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
8957
|
-
const SDK_VERSION = '1.15.
|
|
8957
|
+
const SDK_VERSION = '1.15.7';
|
|
8958
8958
|
const getReferrer = () => {
|
|
8959
8959
|
if (isNode()) {
|
|
8960
8960
|
return '';
|
|
@@ -9197,7 +9197,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
9197
9197
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
9198
9198
|
class ApiConfiguration extends index$2.Configuration {
|
|
9199
9199
|
}
|
|
9200
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.
|
|
9200
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.15.7' };
|
|
9201
9201
|
/**
|
|
9202
9202
|
* @dev use createImmutableXConfiguration instead
|
|
9203
9203
|
*/
|
|
@@ -9236,7 +9236,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
9236
9236
|
chainID,
|
|
9237
9237
|
coreContractAddress,
|
|
9238
9238
|
registrationContractAddress,
|
|
9239
|
-
sdkVersion: 'ts-immutable-sdk-1.15.
|
|
9239
|
+
sdkVersion: 'ts-immutable-sdk-1.15.7',
|
|
9240
9240
|
baseConfig,
|
|
9241
9241
|
});
|
|
9242
9242
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b7 as e,b8 as t,r as s,b9 as a,u as n,j as o,M as r,au as i,ba as l,I as c,aq as d,bb as u,bc as x,B as p,l as g,O as w,bd as h,a6 as b,aO as m,P as f,Q as E,be as T,bf as v,a as y,bg as I,U as A,bh as S,V as k,d as C,a0 as R,bi as _,a2 as j,bj as N,aN as D,bk as W,z as L,X as P,af as O,Y as B,E as M,o as G,q as F,T as z,p as U,bl as $,bm as V,c as H,H as K,F as J,bn as q,bo as Q,L as Y,at as X,w as Z,bp as ee,m as te,_ as se,bq as ae,aL as ne,br as oe,aM as re,x as ie,n as le,N as ce,aR as de,aX as ue,S as xe,ae as pe,aS as ge,aK as we,bs as he,aP as be,bt as me,bu as fe,aV as Ee,bv as Te,bw as ve,a3 as ye,a4 as Ie,bx as Ae,e as Se,D as ke,aY as Ce,by as Re,t as _e,v as je,i as Ne,bz as De,a_ as We,bA as Le,f as Pe,h as Oe,a8 as Be,bB as Me,bC as Ge,bD as Fe}from"./index-6817e91e.js";import{B as ze,C as Ue,a as $e,b as Ve,T as He}from"./TopUpView-c90cfc04.js";import{r as Ke,u as Je}from"./retry-06ea349a.js";import{c as qe,d as Qe,e as Ye,f as Xe,g as Ze,S as et,T as tt,a as st,b as at,F as nt,N as ot,W as rt}from"./balance-c7e1bedb.js";const{Axios:it,AxiosError:lt,CanceledError:ct,isCancel:dt,CancelToken:ut,VERSION:xt,all:pt,Cancel:gt,isAxiosError:wt,spread:ht,toFormData:bt,AxiosHeaders:mt,HttpStatusCode:ft,formToJSON:Et,getAdapter:Tt,mergeConfig:vt}=e;class yt{url;ttl;env;cacheMap;setCache(e,t){this.cacheMap[e]={data:t,ttl:(new Date).getTime()+1e3*this.ttl}}getCache(e){const t=this.cacheMap[e];return!t||t.ttl<=(new Date).getTime()?null:t.data}constructor(e){this.env=e.env,this.url=`${t[this.env]}/checkout`,this.cacheMap={},this.ttl=void 0!==e.ttl?e.ttl:60}static isHttpError=e=>"code"in e;async getTransactions(t){const{txType:s,fromAddress:a}=t;try{const t=`${this.url}/v1/transactions?from_address=${a}&tx_type=${s}`,n=this.getCache(t);if(n)return Promise.resolve(n);const o=await e.get(t);if(o.status>=400)return Promise.reject({code:o.status,message:o.statusText});const{data:r}=o;return this.setCache(t,r),Promise.resolve(r)}catch(t){let s=ft.InternalServerError,a="InternalServerError";return e.isAxiosError(t)&&(s=t.response?.status||s,a=t.message),Promise.reject({code:s,message:a})}}}var It;!function(e){e.BRIDGE="bridge"}(It||(It={}));const At={IN_PROGRESS:"in_progress",WITHDRAWAL_PENDING:"withdrawal_pending"},St={web3Provider:null,walletProviderName:null,from:null,to:null,tokenBridge:null,tokenBalances:[],allowedTokens:[],token:null,amount:"0"};var kt;!function(e){e.SET_WALLETS_AND_NETWORKS="SET_WALLETS_AND_NETWORKS",e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_PROVIDER="SET_PROVIDER",e.SET_TOKEN_BRIDGE="SET_TOKEN_BRIDGE",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_ALLOWED_TOKENS="SET_ALLOWED_TOKENS",e.SET_TOKEN_AND_AMOUNT="SET_TOKEN_AND_AMOUNT"}(kt||(kt={}));const Ct=s.createContext({bridgeState:{...St,checkout:{}},bridgeDispatch:()=>{}});Ct.displayName="BridgeContext";const Rt=(e,t)=>{switch(t.payload.type){case kt.SET_WALLETS_AND_NETWORKS:return{...e,from:t.payload.from,to:t.payload.to};case kt.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case kt.SET_PROVIDER:return{...e,web3Provider:t.payload.web3Provider};case kt.SET_TOKEN_BRIDGE:return{...e,tokenBridge:t.payload.tokenBridge};case kt.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case kt.SET_ALLOWED_TOKENS:return{...e,allowedTokens:t.payload.allowedTokens};case kt.SET_TOKEN_AND_AMOUNT:return{...e,token:t.payload.token,amount:t.payload.amount};default:return e}};function _t(e){switch(e){case a.METAMASK:return"MetaMaskSymbol";case a.PASSPORT:return"PassportSymbolOutlined";case"walletconnect":return"WalletConnectSymbol";default:return"MetaMaskSymbol"}}function jt({testId:e,walletProviderName:t,onWalletClick:a,loading:i}){const{t:l}=n(),[c,d]=s.useState(!1);return o.jsxs(r,{testId:`${e}-wallet-list-${t}`,size:"medium",emphasized:!0,onClick:async()=>{if(!i){d(!0);try{await a(t)}finally{d(!1)}}},children:[o.jsx(r.FramedLogo,{logo:_t(t),sx:{backgroundColor:"base.color.translucent.standard.200"}}),o.jsx(r.Label,{size:"medium",children:l(`wallets.${t}.heading`)}),c&&o.jsx(r.StatefulButtCon,{state:"loading",icon:"Loading"})]})}const Nt={display:"flex",flexDirection:"column",gap:"base.spacing.x1",paddingX:"base.spacing.x4"};function Dt({testId:e,drawerText:t,walletOptions:a,showWalletSelectorTarget:n,showDrawer:r,setShowDrawer:c,onWalletItemClick:d}){const[u,x]=s.useState(!1),{heading:p,defaultText:g}=t,w=async e=>{x(!0);try{await d(e)}catch(e){console.error(e)}finally{x(!1)}};return o.jsxs(i,{headerBarTitle:p,size:"full",onCloseDrawer:()=>{u||c(!1)},visible:r,children:[n&&o.jsx(i.Target,{children:o.jsx(qe,{testId:`${e}-wallet-form-control`,textAlign:"left",children:o.jsx(l,{testId:`${e}-wallet-select`,defaultLabel:g??"",size:"large",targetClickOveride:()=>c(!0)})})}),o.jsx(i.Content,{sx:Nt,children:a.map((t=>o.jsx(jt,{testId:e,loading:u,walletProviderName:t,onWalletClick:w},t)))})]})}const Wt=(e,t)=>{const s=new CustomEvent(c.IMTBL_BRIDGE_WIDGET_EVENT,{detail:{type:d.TRANSACTION_SENT,data:{transactionHash:t}}});console.log("bridge success ",e,s),void 0!==e&&e.dispatchEvent(s)};function Lt(e){const t=new CustomEvent(c.IMTBL_BRIDGE_WIDGET_EVENT,{detail:{type:d.CLOSE_WIDGET,data:{}}});console.log("bridge close ",e,t),void 0!==e&&e.dispatchEvent(t)}function Pt(){return o.jsxs(u,{sx:{gap:"base.spacing.x2"},children:[o.jsx(x,{sx:{h:"base.spacing.x4",w:"base.spacing.x32",mt:"base.spacing.x2"}}),o.jsx(r,{shimmer:!0,emphasized:!0,size:"small"}),o.jsx(r,{shimmer:!0,emphasized:!0,size:"small"}),o.jsx(r,{shimmer:!0,emphasized:!0,size:"small"})]})}const Ot={px:"base.spacing.x4",display:"flex",flexDirection:"column",height:"100%"},Bt={flexGrow:"1",flexShrink:"0",flexBasis:"0"},Mt={flexGrow:"0",flexShrink:"1",mt:"base.spacing.x2"},Gt={bg:"base.color.translucent.emphasis.100",borderRadius:"base.borderRadius.x4",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",height:"100%",px:"base.spacing.x5"};function Ft({openWalletDrawer:e}){const{t:t}=n();return o.jsxs(p,{sx:Gt,children:[o.jsx(g,{sx:{mb:"base.spacing.x8"},children:t("views.TRANSACTIONS.status.emptyState.notConnected.body")}),o.jsx(w,{variant:"secondary",size:"medium",testId:"transactions-connect-wallet-button",onClick:e,children:t("views.TRANSACTIONS.status.emptyState.notConnected.buttonText")})]})}const zt={backgroundColor:"base.color.neutral.800",px:"base.spacing.x4",p:"base.spacing.x5",borderRadius:"base.borderRadius.x6"},Ut={color:"base.color.text.body.secondary"};function $t({checkout:e,isPassport:t}){const{t:a}=n(),[r,i]=s.useState("");return s.useEffect((()=>{e&&i(h[e.config.environment])}),[e]),o.jsx(p,{sx:zt,children:o.jsxs(p,{sx:{display:"flex",flexDirection:"column"},children:[o.jsxs(p,{children:[o.jsx(g,{size:"small",children:a("views.TRANSACTIONS.support.body1")}),o.jsxs(g,{size:"small",sx:Ut,children:[a("views.TRANSACTIONS.support.body2"),o.jsx(b,{size:"small",rc:o.jsx("a",{target:"_blank",href:a("views.TRANSACTIONS.support.supportLink"),rel:"noreferrer"}),children:a("views.TRANSACTIONS.support.body3")})]})]}),t&&o.jsxs(g,{size:"small",sx:Ut,children:[a("views.TRANSACTIONS.support.passport.body1")," ",o.jsx(b,{size:"small",rc:o.jsx("a",{target:"_blank",href:r,rel:"noreferrer"}),children:a("views.TRANSACTIONS.support.passport.body2")})]})]})})}const Vt={display:"flex",flexDirection:"column",borderRadius:"base.borderRadius.x4",bg:"base.color.translucent.emphasis.100"},Ht={p:"base.spacing.x3",d:"flex",justifyContent:"space-between",position:"relative"},Kt={display:"flex",flexGrow:"1",alignItems:"center",gap:"base.spacing.x2"};function Jt({transaction:e}){const t=Qe(e.details.from_chain),s=Qe(e.details.to_chain);return o.jsxs(p,{sx:{display:"flex",px:"base.spacing.x4",gap:"base.spacing.x2"},children:[o.jsx(m,{icon:f[t],sx:{w:"base.icon.size.250",fill:E[t]},variant:"bold"}),o.jsxs(p,{sx:{display:"flex",flexDirection:"column",flexGrow:"1"},children:[o.jsx(g,{size:"xxSmall",sx:{color:"base.color.translucent.standard.900"},children:T[t]}),o.jsx(v,{size:"xxSmall",sx:{color:"base.color.translucent.standard.600"},text:e.details.from_address})]}),o.jsx(p,{sx:{flexGrow:"1"}}),o.jsx(m,{icon:"ArrowForward",sx:{w:"base.icon.size.250",fill:"base.color.brand.4"}}),o.jsx(p,{sx:{flexGrow:"1"}}),o.jsx(m,{icon:f[s],sx:{w:"base.icon.size.250",fill:E[s]},variant:"bold"}),o.jsxs(p,{sx:{display:"flex",flexDirection:"column",flexGrow:"1"},children:[o.jsx(g,{size:"xxSmall",sx:{color:"base.color.translucent.standard.900"},children:T[s]}),o.jsx(v,{size:"xxSmall",sx:{color:"base.color.translucent.standard.600"},text:e.details.to_address})]})]})}function qt({label:e,details:t,transaction:a,fiatAmount:n,amount:i,icon:l,defaultTokenImage:c}){const{track:d}=y(),u=s.useMemo((()=>`${t.link}${t.hash}`),[t]);return o.jsx(p,{testId:`transaction-item-${a.blockchain_metadata.transaction_hash}`,sx:Vt,children:o.jsxs(I,{chevronSide:"right",sx:{button:{p:"base.spacing.x1"},article:{pr:"base.spacing.x10"}},onExpandChange:e=>e&&d({userJourney:A.BRIDGE,screen:"TransactionItem",control:"Accordion",controlType:"Button"}),children:[o.jsx(I.TargetLeftSlot,{sx:{pr:"base.spacing.x2"},children:o.jsxs(r,{size:"xSmall",children:[o.jsx(r.FramedImage,{imageUrl:l,circularFrame:!0,defaultImageUrl:c}),o.jsx(r.Label,{children:e}),o.jsx(r.Caption,{children:o.jsx(b,{size:"xSmall",rc:o.jsx("a",{target:"_blank",href:u,rel:"noreferrer",onClick:e=>{return s=t,e.stopPropagation(),void d({userJourney:A.BRIDGE,screen:"TransactionItem",control:"Details",controlType:"Link",extras:{linkDetail:s}});var s}}),children:t.text})}),o.jsx(r.PriceDisplay,{fiatAmount:n,price:i})]})}),o.jsxs(I.ExpandedContent,{sx:{pr:"0",pl:"0",mb:"base.spacing.x3",gap:"0"},children:[o.jsx(S,{size:"xSmall",sx:{px:"base.spacing.x2"}}),o.jsx(Jt,{transaction:a})]})]})})}const Qt=e=>{let t=440;return e&&(t-=20),{backgroundColor:"base.color.neutral.800",px:"base.spacing.x4",pt:"base.spacing.x5",pb:"base.spacing.x4",borderRadius:"base.borderRadius.x6",h:`${t}px`,w:"100%",overflowY:"scroll"}},Yt={borderRadius:"base.borderRadius.x4",display:"flex",flexDirection:"column",gap:"base.spacing.x5"};function Xt({label:e,transaction:t,fiatAmount:a,amount:i,icon:l,defaultTokenImage:c}){const{viewDispatch:d}=s.useContext(k),{track:u}=y(),x=n(),h=s.useMemo((()=>(new Date).getTime()),[]),b=s.useMemo((()=>t.details.current_status.withdrawal_ready_at?new Date(t.details.current_status.withdrawal_ready_at):void 0),[t]),f=t.details.current_status.status===At.WITHDRAWAL_PENDING,E=new Intl.RelativeTimeFormat(x[1].language||"en",{numeric:"auto"}),T=s.useMemo((()=>{if(!f||void 0===b)return"";const e=(b.getTime()-h)/6e4;if(e<=1)return"in 1 minute";if(e<60)return E.format(Math.ceil(e),"minute");const t=e/60;if(e<1440)return E.format(Math.ceil(t),"hour");const s=t/24;return E.format(Math.ceil(s),"day")}),[h,x[1].language]),v=!!b&&b.getTime()<h,R=s.useMemo((()=>!0===v?x.t("views.TRANSACTIONS.status.withdrawalPending.withdrawalReadyText"):`${x.t("views.TRANSACTIONS.status.withdrawalPending.withdrawalDelayText")} ${T}`),[T,x[1].language]);return o.jsxs(p,{testId:`transaction-item-${t.blockchain_metadata.transaction_hash}`,sx:Vt,children:[f&&o.jsxs(o.Fragment,{children:[o.jsxs(p,{sx:Ht,children:[o.jsxs(p,{sx:Kt,children:[o.jsx(m,{icon:"Alert",variant:"bold",sx:{fill:v?"base.color.status.fatal.bright":"base.color.status.attention.bright",w:"base.icon.size.200"}}),o.jsx(g,{testId:`transaction-item-${t.blockchain_metadata.transaction_hash}-action-message`,size:"xSmall",sx:{color:"base.color.text.body.secondary"},children:R})]}),f&&v&&o.jsx(w,{testId:`transaction-item-${t.blockchain_metadata.transaction_hash}-action-button`,variant:"primary",size:"small",onClick:()=>{d({payload:{type:C.UPDATE_VIEW,view:{type:ze.CLAIM_WITHDRAWAL,transaction:t}}})},children:x.t("views.TRANSACTIONS.status.withdrawalPending.actionButtonText")})]}),o.jsx(S,{size:"small",sx:{color:"base.color.translucent.emphasis.300",opacity:.1}})]}),o.jsxs(I,{chevronSide:"right",sx:{button:{p:"base.spacing.x1"},article:{pr:"base.spacing.x10"},borderTopRightRadius:"0",borderTopLeftRadius:"0"},onExpandChange:e=>e&&u({userJourney:A.BRIDGE,screen:"TransactionItem",control:"Accordion",controlType:"Button"}),children:[o.jsx(I.TargetLeftSlot,{sx:{pr:"base.spacing.x2"},children:o.jsxs(r,{size:"xSmall",children:[o.jsx(r.FramedImage,{imageUrl:l,circularFrame:!0,defaultImageUrl:c}),o.jsx(r.Label,{children:e}),o.jsx(r.Caption,{children:x.t("views.TRANSACTIONS.status.withdrawalPending.caption")}),o.jsx(r.PriceDisplay,{fiatAmount:a,price:i})]})}),o.jsxs(I.ExpandedContent,{sx:{pr:"0",pl:"0",mb:"base.spacing.x3",gap:"0"},children:[o.jsx(S,{size:"xSmall",sx:{px:"base.spacing.x2"}}),o.jsx(Jt,{transaction:t})]})]})]})}const Zt={display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",p:"base.spacing.x2",pb:"base.spacing.x4"},es={position:"relative",pr:"base.spacing.x2"},ts={width:"base.icon.size.400"},ss={position:"absolute",top:"-6px",left:"18px",width:"20px",padding:"2px",backgroundColor:"base.color.translucent.inverse.900",borderRadius:"base.borderRadius.x2"};function as({onChangeWalletClick:e}){const{t:t}=n(),{bridgeState:{checkout:a,from:r}}=s.useContext(Ct),[i,l]=s.useState(void 0),[c,d]=s.useState(!1),{isWalletConnectEnabled:u,getWalletLogoUrl:x}=R({checkout:a}),{track:g}=y(),h=r?.walletAddress||"",b=_t(_(r?.web3Provider));return s.useEffect((()=>{u&&(d(j(r?.web3Provider)),(async()=>{l(await x())})())}),[u,r]),o.jsxs(p,{sx:Zt,children:[o.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:"base.spacing.x1"},children:[c&&i?o.jsxs(p,{sx:es,children:[o.jsx(N,{imageUrl:i,alt:"walletconnect",sx:ts}),o.jsx(D,{logo:"WalletConnectSymbol",sx:ss})]}):o.jsx(D,{logo:b,sx:{width:"base.icon.size.400",pr:"base.spacing.x1"}}),o.jsx(v,{leftSideLength:6,rightSideLength:4,text:h})]}),o.jsx(w,{size:"small",variant:"tertiary",onClick:()=>{g({userJourney:A.BRIDGE,screen:ze.TRANSACTIONS,controlType:"Button",control:"Pressed"}),e()},children:t("views.TRANSACTIONS.changeWallet.buttonText")})]})}function ns({checkout:e,transactions:t,knownTokenMap:a,isPassport:r,defaultTokenImage:i,changeWallet:l}){const{cryptoFiatState:c}=s.useContext(Ue),{t:d}=n(),[u,x]=s.useState("");s.useEffect((()=>{e&&x(W[e.config.environment])}),[e]);const g=s.useCallback(((e,t)=>e.details.current_status.status===At.WITHDRAWAL_PENDING&&t.details.current_status.status!==At.WITHDRAWAL_PENDING?-1:e.details.current_status.status===t.details.current_status.status?0:1),[]),w=s.useCallback((t=>L(t.details.from_token_address)?P(e.config.environment,Ye(t.details.from_chain)):P(e.config.environment,t.details.from_token_address)),[e]);return o.jsxs(p,{sx:Qt(r),children:[o.jsx(as,{onChangeWalletClick:l}),o.jsx(p,{testId:"move-transaction-list",sx:Yt,children:t.sort(g).map((e=>{const t=e.blockchain_metadata.transaction_hash,s=a[e.details.from_chain][e.details.from_token_address.toLowerCase()],n=O.formatUnits(e.details.amount,s.decimals),r=B(n,s.symbol,c.conversions);return e.details.current_status.status===At.WITHDRAWAL_PENDING?o.jsx(Xt,{label:s.name,transaction:e,fiatAmount:`${d("views.TRANSACTIONS.fiatPricePrefix")}${r}`,amount:n,icon:w(e),defaultTokenImage:i},t):o.jsx(qt,{label:s.name,details:{text:d("views.TRANSACTIONS.status.inProgress.stepInfo"),link:u,hash:t},transaction:e,fiatAmount:`${d("views.TRANSACTIONS.fiatPricePrefix")}${r}`,amount:n,icon:w(e),defaultTokenImage:i},t)}))})]})}const os={backgroundColor:"base.color.neutral.800",px:"base.spacing.x4",pt:"base.spacing.x5",pb:"base.spacing.x4",borderRadius:"base.borderRadius.x6",h:"100%",w:"100%",display:"flex",flexDirection:"column"},rs={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",padding:"base.spacing.x5",flex:1},is={mb:"base.spacing.x8",color:"base.color.text.body.secondary"},ls={color:"base.color.text.body.secondary"};function cs({checkout:e,isPassport:t,changeWallet:a}){const{page:r}=y(),{t:i}=n(),[l,c]=s.useState("");return s.useEffect((()=>{e&&c(h[e.config.environment])}),[e]),s.useEffect((()=>{r({userJourney:A.BRIDGE,screen:"NoTransactions"})}),[]),o.jsxs(p,{sx:os,children:[o.jsx(as,{onChangeWalletClick:a}),o.jsxs(p,{sx:rs,children:[o.jsx(g,{size:"small",sx:is,children:i("views.TRANSACTIONS.status.noTransactions.body")}),t&&o.jsxs(g,{size:"small",sx:ls,children:[i("views.TRANSACTIONS.status.noTransactions.passport.body")," ",o.jsx(b,{size:"small",rc:o.jsx("a",{target:"_blank",href:l,rel:"noreferrer"}),children:i("views.TRANSACTIONS.status.noTransactions.passport.link")})]})]})]})}function ds({defaultTokenImage:e,onBackButtonClick:t}){const{eventTargetState:{eventTarget:r}}=s.useContext(M),{cryptoFiatDispatch:i}=s.useContext(Ue),{bridgeDispatch:l,bridgeState:{checkout:c,from:d}}=s.useContext(Ct),{page:u}=y(),{t:x}=n(),{track:g}=y(),[w,h]=s.useState(!0),[b,m]=s.useState(void 0),[f,E]=s.useState([]),[T,v]=s.useState(!1),I=G(d?.web3Provider),{isWalletConnectEnabled:S,openWalletConnectModal:k}=R({checkout:c}),C=s.useCallback((async()=>{if(!c)return{};const e=F(c.config);try{return((await c.getTokenAllowList({type:z.BRIDGE,chainId:e})).tokens??[]).reduce(((e,t)=>(e[t.address.toLowerCase()]=t,e)),{})}catch(e){return console.error(e),[]}}),[c]),_=s.useCallback((async()=>{if(!d?.web3Provider)return{};if(!d?.walletAddress)return{};const e=U(c.config);try{return(await c.getAllBalances({provider:d?.web3Provider,walletAddress:d?.walletAddress,chainId:e})).balances.reduce(((e,t)=>(e[t.token.address.toLowerCase()]=t.token,e)),{})}catch(e){return console.error(e),[]}}),[c,d]),j=e=>{e.getNetwork().then((t=>{e?.getSigner().getAddress().then((s=>{E([]),l({payload:{type:kt.SET_WALLETS_AND_NETWORKS,from:{web3Provider:e,walletAddress:s.toLowerCase(),network:t.chainId},to:null}})}))}))},N=s.useCallback((async e=>{g({userJourney:A.BRIDGE,screen:"EmptyStateNotConnected",control:"WalletProvider",controlType:"Select",extras:{walletProviderName:e}});try{let t;"walletconnect"===e?await k({connectCallback:e=>{j(new $(e))},restoreSession:!0}):(t=await V(c,e,!0),j(t))}catch(e){console.error(e)}finally{v(!1)}}),[c,d,k]),D=async e=>{const t=Xe(F(c.config)),s=Xe(U(c.config)),[a,n]=await Promise.all([C(),_()]),o={};Object.entries(e).forEach((([r,i])=>{(e[r]===t&&!a[r]||e[r]===s&&!n[r])&&(o[r]=i)}));const r=new q(c.config.networkMap.get(F(c.config))?.rpcUrls[0]),l=new q(c.config.networkMap.get(U(c.config))?.rpcUrls[0]),d=[],u=[];Object.entries(o).forEach((([e,s])=>{s===t?d.push(c.getTokenInfo({provider:r,tokenAddress:e})):u.push(c.getTokenInfo({provider:l,tokenAddress:e}))}));const x=await Promise.allSettled(d),p=await Promise.allSettled(u);x.filter((e=>"fulfilled"===e.status)).forEach((e=>{const t=e;a[t.value.address.toLowerCase()]=t.value})),p.filter((e=>"fulfilled"===e.status)).forEach((e=>{const t=e;n[t.value.address.toLowerCase()]=t.value}));const g=[];return Object.values(a).forEach((e=>g.push(e.symbol.toLowerCase()))),Object.values(n).forEach((e=>g.push(e.symbol.toLowerCase()))),i({payload:{type:$e.SET_TOKEN_SYMBOLS,tokenSymbols:g}}),{[t]:a,[s]:n}},W=s.useCallback((async(e,t)=>new yt({env:e}).getTransactions({txType:It.BRIDGE,fromAddress:t})),[]),L=s.useCallback((async()=>{if(!d?.walletAddress)return;const e=await W(c.config.environment,d?.walletAddress),t={};return e.result.forEach((e=>{t[e.details.from_token_address]=e.details.from_chain})),{tokens:await D(t),transactions:e.result}}),[d,W]),P=s.useMemo((()=>{const e=[a.METAMASK];return c.passport&&e.push(a.PASSPORT),S&&e.push("walletconnect"),e}),[c,S]);return s.useEffect((()=>{(async()=>{h(!0);const e=await Ke(L,Q);if(!e)return void h(!1);const t=e.transactions.filter((t=>{const s=e.tokens[t.details.from_chain];if(!s)return!1;return!!s[t.details.from_token_address.toLowerCase()]}));m(e.tokens),E(t),h(!1)})()}),[d,c]),s.useEffect((()=>{u({userJourney:A.BRIDGE,screen:"Transactions"})}),[]),o.jsx(H,{testId:"bridge-view",header:o.jsx(K,{showBack:!0,onBackButtonClick:()=>{d&&(l({payload:{type:kt.SET_WALLETS_AND_NETWORKS,from:{web3Provider:d?.web3Provider,walletAddress:d?.walletAddress,network:d?.network},to:null}}),l({payload:{type:kt.SET_TOKEN_AND_AMOUNT,token:null,amount:""}})),t()},title:x("views.TRANSACTIONS.layoutHeading"),onCloseButtonClick:()=>Lt(r)}),footer:o.jsx(J,{}),children:o.jsxs(p,{sx:Ot,children:[o.jsxs(p,{sx:Bt,children:[!d?.web3Provider&&o.jsx(Ft,{openWalletDrawer:()=>v(!0)}),d?.web3Provider&&w&&o.jsx(Pt,{}),d?.web3Provider&&!w&&f.length>0&&b&&o.jsx(ns,{checkout:c,transactions:f,knownTokenMap:b,isPassport:I,defaultTokenImage:e,changeWallet:()=>v(!0)}),d?.web3Provider&&!w&&0===f.length&&o.jsx(cs,{checkout:c,isPassport:I,changeWallet:()=>v(!0)})]}),d?.web3Provider&&f.length>0&&o.jsx(p,{sx:Mt,children:o.jsx($t,{checkout:c,isPassport:I})}),o.jsx(Dt,{testId:"select-wallet-drawer",drawerText:{heading:x("views.TRANSACTIONS.walletSelection.heading")},showWalletSelectorTarget:!1,walletOptions:P,showDrawer:T,setShowDrawer:e=>{v(e)},onWalletItemClick:N})]})})}function us({transactionResponse:e}){const{t:t}=n(),{viewDispatch:a}=s.useContext(k),{page:r}=y();return s.useEffect((()=>{r({userJourney:A.BRIDGE,screen:"ClaimWithdrawalInProgress"})}),[]),s.useEffect((()=>{e&&(async()=>{try{const t=await e.wait();if(1===t.status)return void a({payload:{type:C.UPDATE_VIEW,view:{type:ze.CLAIM_WITHDRAWAL_SUCCESS,transactionHash:t.transactionHash}}});a({payload:{type:C.UPDATE_VIEW,view:{type:ze.CLAIM_WITHDRAWAL_FAILURE,transactionHash:t.transactionHash,reason:"Transaction failed"}}})}catch(e){console.error(e),a({payload:{type:C.UPDATE_VIEW,view:{type:ze.CLAIM_WITHDRAWAL_FAILURE,transactionHash:"",reason:"Transaction failed"}}})}})()}),[e]),o.jsx(Y,{loadingText:t("views.CLAIM_WITHDRAWAL.IN_PROGRESS.loading.text"),showFooterLogo:!0})}function xs(e){return e?e.substring(0,6).concat("...").concat(e.substring(e.length-4)):""}const ps={height:"100%",display:"flex",flexDirection:"column",paddingX:"base.spacing.x4"},gs={paddingTop:"base.spacing.x10",paddingBottom:"base.spacing.x4"},ws={display:"flex",flexDirection:"column",paddingY:"base.spacing.x6"},hs={[X.IMTBL_ZKEVM_DEVNET]:"base.color.text.link.primary",[X.IMTBL_ZKEVM_TESTNET]:"base.color.text.link.primary",[X.IMTBL_ZKEVM_MAINNET]:"base.color.text.link.primary",[X.ETHEREUM]:"base.color.accent.5",[X.SEPOLIA]:"base.color.accent.5"},bs=e=>({backgroundColor:hs[e],"& svg":{fill:"base.color.brand.2"}});function ms({testId:e,chainId:t,chainName:s,onNetworkClick:a}){return o.jsxs(r,{testId:`${e}-network-list-${t}`,size:"medium",emphasized:!0,onClick:async()=>{await a(t)},sx:{marginBottom:"base.spacing.x1"},children:[o.jsx(r.FramedIcon,{icon:f[t],circularFrame:!0,sx:bs(t)}),o.jsx(r.Label,{size:"medium",children:s})]})}const fs={[X.IMTBL_ZKEVM_DEVNET]:"base.color.text.link.primary",[X.IMTBL_ZKEVM_TESTNET]:"base.color.text.link.primary",[X.IMTBL_ZKEVM_MAINNET]:"base.color.text.link.primary",[X.ETHEREUM]:"base.color.accent.5",[X.SEPOLIA]:"base.color.accent.5"},Es={position:"relative",width:"100%",backgroundColor:"base.color.translucent.emphasis.100",borderRadius:"base.borderRadius.x4",paddingX:"base.spacing.x3",paddingY:"base.spacing.x5",display:"flex",flexDirection:"row",gap:"base.spacing.x4",alignItems:"center","&:hover":{cursor:"pointer",backgroundColor:"base.color.translucent.emphasis.200"}},Ts={width:"base.icon.size.500",backgroundColor:"base.color.translucent.standard.200",borderRadius:"base.borderRadius.x2"},vs={position:"absolute",top:"14px",left:"38px",width:"28px",padding:"base.spacing.x1",backgroundColor:"base.color.translucent.inverse.900",borderRadius:"base.borderRadius.x2"},ys=e=>({width:"base.icon.size.500",padding:(a.PASSPORT,"base.spacing.x1"),backgroundColor:"base.color.translucent.standard.200",borderRadius:"base.borderRadius.x2"}),Is={color:"base.color.text.body.secondary"},As={paddingY:"base.spacing.x6",borderRadius:"base.borderRadius.x18"},Ss=e=>({fill:"base.color.brand.2",width:"base.icon.size.300",backgroundColor:fs[e],borderRadius:"100%",padding:"base.spacing.x1"});function ks({testId:e,walletProvider:t,walletName:n,walletAddress:r,chainId:i,disableNetworkButton:l=!1,onWalletClick:c,onNetworkClick:d}){const u=Ze(i),x=function(e){switch(e){case a.METAMASK:return"MetaMask";case a.PASSPORT:return"Passport";case"WalletConnect":return"WalletConnect";default:return"Other"}}(n),h=_t(n),[b,m]=s.useState(void 0),[E,T]=s.useState(!1),{bridgeState:{checkout:v}}=s.useContext(Ct),{isWalletConnectEnabled:y,getWalletLogoUrl:I}=R({checkout:v});return s.useEffect((()=>{y&&(T(j(t)),(async()=>{m(await I())})())}),[y,t]),o.jsxs(p,{testId:`${e}-${n}-${i}-button-wrapper`,sx:Es,onClick:c,children:[E&&b?o.jsxs(o.Fragment,{children:[o.jsx(N,{imageUrl:b,alt:"walletconnect",sx:Ts}),o.jsx(D,{logo:"WalletConnectSymbol",sx:vs})]}):o.jsx(D,{logo:h,sx:ys(n)}),o.jsxs(p,{sx:{display:"flex",flexDirection:"column",flex:1},children:[o.jsx(Z,{size:"xSmall",children:x}),o.jsx(g,{size:"xSmall",sx:Is,children:r})]}),o.jsxs(w,{testId:`${e}-network-${i}-button`,size:"small",disabled:l,onClick:e=>{e.stopPropagation(),d(e)},variant:"tertiary",sx:As,children:[o.jsx(w.Icon,{icon:f[i],sx:Ss(i)}),u]})]})}const Cs="wallet-network-selector";function Rs(){const{t:e}=n(),{bridgeState:{checkout:t,from:r,to:l},bridgeDispatch:c}=s.useContext(Ct),{viewDispatch:d}=s.useContext(k),{track:u}=y(),x=F(t.config),g=Ze(x),h=U(t.config),b=Ze(h),m=s.useRef(),{isWalletConnectEnabled:f,openWalletConnectModal:E}=R({checkout:t}),[T,v]=s.useState(!1),[I,S]=s.useState(!1),[j,N]=s.useState(),[D,W]=s.useState(),[L,P]=s.useState(""),[O,B]=s.useState(!1),[M,z]=s.useState(),[H,K]=s.useState(),[J,q]=s.useState(""),Q=j&&D,Y=M&&H,X=s.useMemo((()=>j?_(j):null),[j]),te=s.useMemo((()=>M?_(M):null),[M]),se=s.useMemo((()=>{const e=[a.METAMASK.toString()];return t.passport&&e.push(a.PASSPORT.toString()),f&&e.push("walletconnect"),e}),[t,f]),ae=s.useMemo((()=>{const e=[a.METAMASK.toString()];return t.passport&&D===x&&e.push(a.PASSPORT.toString()),f&&e.push("walletconnect"),e}),[t,D,X,f]);s.useEffect((()=>{r&&l&&(L!==r?.walletAddress&&u({userJourney:A.BRIDGE,screen:"WalletAndNetwork",control:"FromWallet",controlType:"Select",extras:{walletAddress:r?.walletAddress}}),D!==r?.network&&u({userJourney:A.BRIDGE,screen:"WalletAndNetwork",control:"FromNetwork",controlType:"Select",extras:{chainId:r?.network}}),J!==l?.walletAddress&&u({userJourney:A.BRIDGE,screen:"WalletAndNetwork",control:"ToWallet",controlType:"Select",extras:{walletAddress:l?.walletAddress}}),H!==l?.network&&u({userJourney:A.BRIDGE,screen:"WalletAndNetwork",control:"ToNetwork",controlType:"Select",extras:{chainId:l?.network}}),N(r.web3Provider),P(r.walletAddress.toLowerCase()),W(r.network),z(l.web3Provider),q(l.walletAddress.toLowerCase()),K(l.network),c({payload:{type:kt.SET_WALLETS_AND_NETWORKS,from:null,to:null}}))}),[r,l]);const ne=s.useCallback((async e=>{let s;try{return s=await V(t,e),e===a.PASSPORT.toString()&&(m.current=s),s}catch(e){throw console.error(e),e}}),[t]);function oe(){z(null),K(null)}const re=async e=>{N(e);const t=await e.getSigner().getAddress();if(P(t.toLowerCase()),G(e))return W(h),void v(!1);W(null),v(!1),setTimeout((()=>S(!0)),500)},ie=s.useCallback((async e=>{let t;if(oe(),e===a.PASSPORT.toString()&&m.current)return t=m.current,void await re(t);if(!t)try{"walletconnect"===e?await E({connectCallback:e=>{re(new $(e))},restoreSession:!0}):(t=await ne(e),await re(t))}catch(e){console.error(e)}}),[X,m.current,E]),le=s.useCallback((async e=>{j&&(oe(),S(!1),W(e))}),[t,j]),ce=s.useCallback((()=>{K(D===x?h:x),B(!1)}),[D]),de=s.useCallback((e=>{z(e),e.getSigner().getAddress().then((e=>{q(e.toLowerCase()),ce()}))}),[ce]),ue=s.useCallback((async e=>{if(X===e){z(j);const e=await j.getSigner().getAddress();return q(e.toLowerCase()),void ce()}let t;try{if("walletconnect"===e)await E({connectCallback:e=>{const t=new $(e);de(t),ce()}});else{t=e===a.PASSPORT.toString()&&m.current?m.current:await ne(e),z(t);const s=await t.getSigner().getAddress();q(s.toLowerCase()),ce()}}catch(e){console.error(e)}}),[X,j,m.current,ce,de]),xe=s.useCallback((()=>{j&&D&&M&&H&&(c({payload:{type:kt.SET_TOKEN_BALANCES,tokenBalances:[]}}),c({payload:{type:kt.SET_ALLOWED_TOKENS,allowedTokens:[]}}),c({payload:{type:kt.SET_WALLETS_AND_NETWORKS,from:{web3Provider:j,walletAddress:L.toLowerCase(),network:D},to:{web3Provider:M,walletAddress:J.toLowerCase(),network:H}}}),u({userJourney:A.BRIDGE,screen:"WalletAndNetwork",control:"Next",controlType:"Button",extras:{fromWalletAddress:L,fromNetwork:D,fromWallet:{address:L,isPassportWallet:G(j),isMetaMask:ee(j)},toWalletAddress:J,toNetwork:H,toWallet:{address:J,isPassportWallet:G(M),isMetaMask:ee(M)}}}),d({payload:{type:C.UPDATE_VIEW,view:{type:ze.BRIDGE_FORM}}}))}),[j,D,L,M,H,J]);return o.jsxs(p,{testId:Cs,sx:ps,children:[o.jsx(Z,{testId:`${Cs}-heading`,size:"small",weight:"regular",sx:gs,children:e("views.WALLET_NETWORK_SELECTION.heading")}),o.jsx(Z,{size:"xSmall",sx:{paddingBottom:"base.spacing.x2"},children:e("views.WALLET_NETWORK_SELECTION.fromFormInput.heading")}),o.jsx(Dt,{testId:`${Cs}-from`,drawerText:{heading:e("views.WALLET_NETWORK_SELECTION.fromFormInput.walletSelectorHeading"),defaultText:e("views.WALLET_NETWORK_SELECTION.fromFormInput.selectDefaultText")},showWalletSelectorTarget:!Q,walletOptions:se,showDrawer:T,setShowDrawer:v,onWalletItemClick:ie}),Q&&X&&o.jsxs(p,{sx:{display:"flex",flexDirection:"column",gap:"base.spacing.x10"},children:[o.jsx(ks,{testId:Cs,walletProvider:j,walletName:X,walletAddress:xs(L),chainId:D,onWalletClick:()=>{v(!0)},onNetworkClick:()=>S(!0)}),o.jsxs(p,{children:[o.jsx(Z,{size:"xSmall",sx:{paddingBottom:"base.spacing.x2"},children:e("views.WALLET_NETWORK_SELECTION.toFormInput.heading")}),o.jsx(Dt,{testId:`${Cs}-to`,drawerText:{heading:e("views.WALLET_NETWORK_SELECTION.toFormInput.walletSelectorHeading"),defaultText:e("views.WALLET_NETWORK_SELECTION.toFormInput.selectDefaultText")},showWalletSelectorTarget:!Y,walletOptions:ae,showDrawer:O,setShowDrawer:B,onWalletItemClick:ue})]})]}),o.jsx(i,{headerBarTitle:e("views.WALLET_NETWORK_SELECTION.fromFormInput.networkSelectorHeading"),size:"full",onCloseDrawer:()=>{S(!1)},visible:I,children:o.jsxs(i.Content,{sx:{paddingX:"base.spacing.x4"},children:[o.jsx(ms,{testId:Cs,chainName:b,onNetworkClick:le,chainId:h},b),(X===a.METAMASK.toString()||"walletconnect"===X)&&o.jsx(ms,{testId:Cs,chainName:g,onNetworkClick:le,chainId:x},g)]})}),Y&&te&&o.jsxs(p,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[o.jsx(ks,{testId:Cs,walletProvider:M,walletName:te,walletAddress:xs(J),chainId:H,disableNetworkButton:!0,onWalletClick:()=>{B(!0)},onNetworkClick:()=>{}}),o.jsx(p,{sx:ws,children:o.jsx(w,{testId:`${Cs}-submit-button`,size:"large",onClick:xe,children:e("views.WALLET_NETWORK_SELECTION.submitButton.text")})})]})]})}function _s(){const{t:e}=n(),{viewDispatch:t}=s.useContext(k),{eventTargetState:{eventTarget:a}}=s.useContext(M),{page:r}=y();return s.useEffect((()=>{r({userJourney:A.BRIDGE,screen:"WalletNetworkSelection"})}),[]),o.jsx(H,{testId:"bridge-view",header:o.jsx(K,{title:e("views.WALLET_NETWORK_SELECTION.layoutHeading"),onCloseButtonClick:()=>Lt(a),rightActions:o.jsx(te,{icon:"Minting",sx:se(),onClick:()=>{t({payload:{type:C.UPDATE_VIEW,view:{type:ze.TRANSACTIONS}}})},testId:"move-transactions-button"})}),footer:o.jsx(J,{}),children:o.jsx(Rs,{})})}function js(e,t){return e&&0!==parseFloat(e)?t&&Number(e)>Number(t)?"views.BRIDGE_FORM.validation.insufficientBalance":"":"views.BRIDGE_FORM.validation.noAmountInputted"}const Ns={height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",paddingTop:"base.spacing.x10"},Ds={paddingTop:"base.spacing.x4",display:"flex",gap:"base.spacing.x1"},Ws={display:"flex",flexDirection:"column",paddingY:"base.spacing.x6",paddingX:"base.spacing.x4"},Ls={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x1",height:"100%"},Ps={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"15px"},Os={display:"flex",flexDirection:"column",justifyContent:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Bs={width:"100%",height:"base.spacing.x16"},Ms={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"};function Gs({environment:e,onCloseDrawer:t,visible:a,showHeaderBar:r,walletAddress:l,showAdjustAmount:c,tokenSymbol:d,onAddCoinsClick:u}){const{t:x}=n(),[h,b]=s.useState(!1),m=ae(e),f=ne(e),E=d===oe?`${x("drawers.notEnoughGas.content.eth.heading")}`:`${x("drawers.notEnoughGas.content.imx.heading")}`,T=d===oe?`${x("drawers.notEnoughGas.content.eth.body")}`:`${x("drawers.notEnoughGas.content.imx.body")}`,v=s.useCallback((()=>{l&&""!==l&&navigator.clipboard.writeText(l),b(!0),setTimeout((()=>{b(!1)}),3e3)}),[l]);return o.jsx(i,{headerBarTitle:void 0,size:"full",onCloseDrawer:t,visible:a,showHeaderBar:r,children:o.jsx(i.Content,{children:o.jsxs(p,{testId:"not-enough-gas-bottom-sheet",sx:Ls,children:[o.jsx(re,{imageUrl:d===oe?m:f,sx:{w:"base.icon.size.600",h:"base.icon.size.600"}}),o.jsx(Z,{size:"small",sx:Ps,testId:"not-enough-gas-heading",children:E}),o.jsx(g,{sx:Ps,children:T}),o.jsxs(p,{sx:Os,children:[c&&o.jsx(w,{testId:"not-enough-gas-adjust-amount-button",sx:Bs,variant:"tertiary",onClick:t,children:x("drawers.notEnoughGas.buttons.adjustAmount")}),d===oe?o.jsxs(w,{testId:"not-enough-gas-copy-address-button",sx:Bs,variant:"tertiary",onClick:v,children:[x("drawers.notEnoughGas.buttons.copyAddress"),o.jsx(w.Icon,{icon:h?"Tick":"CopyText"})]}):o.jsx(w,{testId:"not-enough-gas-add-imx-button",sx:Bs,variant:"tertiary",onClick:u,children:x("drawers.notEnoughGas.buttons.addMoreImx")}),o.jsx(w,{sx:Bs,variant:"tertiary",onClick:t,testId:"not-enough-gas-cancel-button",children:x("drawers.notEnoughGas.buttons.cancel")})]}),o.jsx(p,{sx:Ms,children:o.jsx(D,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}function Fs({sx:e}){return o.jsxs(p,{sx:{...e,paddingTop:"0",marginTop:"base.spacing.x4"},rc:o.jsx("div",{}),children:[o.jsx(p,{sx:{display:"flex",backgroundColor:"#F3F3F30A",borderRadius:"8px"},children:o.jsx(p,{sx:{minw:"170px",height:"64px",WebkitMaskPosition:"left center",WebkitMaskRepeat:"no-repeat",WebkitMaskSize:"contain",WebkitMaskImage:'url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none"><path d="M154.75 39q1.65 0 2.85-1.15 1.15-1.15 1.15-2.85v-4q0-1.65-1.15-2.8-1.2-1.2-2.85-1.2h-93.6q-2.3 0-3.85 1.2-1.55 1.15-1.55 2.8v4q0 1.7 1.55 2.85Q58.85 39 61.15 39h93.6m-111.7-3.35q.2-1.3.2-2.65 0-1.35-.2-2.65-.75-4.9-4.5-8.65-4.7-4.7-11.3-4.7-6.65 0-11.3 4.7-4.7 4.7-4.7 11.3 0 6.65 4.7 11.3Q20.6 49 27.25 49q6.6 0 11.3-4.7 3.75-3.7 4.5-8.65Z" id="a"/></svg>\')'},rc:o.jsx("span",{}),children:o.jsx(x,{rc:o.jsx("span",{})})})}),o.jsx(p,{sx:{display:"flex",width:"100%",backgroundColor:"#F3F3F30A",borderRadius:"8px"},children:o.jsx(p,{sx:{width:"100%",height:"64px",WebkitMaskPosition:"right center",WebkitMaskRepeat:"no-repeat",WebkitMaskSize:"contain",WebkitMaskImage:'url(\'data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="196" height="96"><path d="M182.85 55.2Q181.65 54 180 54h-56q-1.7 0-2.85 1.2Q120 56.35 120 58v4q0 1.7 1.15 2.85Q122.3 66 124 66h56q1.65 0 2.85-1.15Q184 63.7 184 62v-4q0-1.65-1.15-2.8m0-22Q181.65 32 180 32H68q-1.7 0-2.85 1.2Q64 34.35 64 36v8q0 1.7 1.15 2.85Q66.3 48 68 48h112q1.65 0 2.85-1.15Q184 45.7 184 44v-8q0-1.65-1.15-2.8Z" id="a"/></svg>\')'},rc:o.jsx("span",{}),children:o.jsx(x,{rc:o.jsx("span",{})})})})]})}function zs(e){const{t:t}=n(),{bridgeDispatch:a,bridgeState:{tokenBalances:r,allowedTokens:i,checkout:l,from:c,to:d,amount:u,token:x}}=s.useContext(Ct),{cryptoFiatState:g,cryptoFiatDispatch:h}=s.useContext(Ue),{viewDispatch:b}=s.useContext(k),{testId:m,defaultAmount:f,defaultTokenAddress:E,isTokenBalancesLoading:T,defaultTokenImage:v}=e,{track:I}=y(),[S,R]=s.useState(f||""),[_,j]=s.useState(""),[N,D]=s.useState(),[W,P]=s.useState(""),[O,M]=s.useState(""),[G,z]=s.useState(!1),U=s.useRef(!1),$=N?`${t("views.BRIDGE_FORM.content.availableBalancePrefix")} ${ie(N?.formattedBalance)}`:"",[V,H]=s.useState([]),[K,J]=s.useState(!1),[q,Q]=s.useState(""),[Y,X]=s.useState(!1),ee=s.useCallback(((e,t)=>t?`${e.toLowerCase()}-${t.toLowerCase()}`:e.toLowerCase()),[]);s.useEffect((()=>{if(0===r.length)return;const e=r.filter((e=>e.balance.gt(0))).map((e=>({id:ee(e.token.symbol,e.token.address),name:e.token.name,symbol:e.token.symbol,icon:e.token.icon,balance:{formattedFiatAmount:0===g.conversions.size?le(""):B(e.formattedBalance,e.token.symbol,g.conversions),formattedAmount:ie(e.formattedBalance)}})));H(e),U.current||(U.current=!0,E&&D(r.find((e=>L(e.token.address)&&E?.toLocaleUpperCase()===ce||e.token.address?.toLowerCase()===E?.toLowerCase()))))}),[r,g.conversions,E,U.current,ee,le]),s.useEffect((()=>{if(u&&x){R(u);for(let e=0;e<r.length;e++){const t=r[e];if(t.token.address===x.address){D(t);break}}a({payload:{type:kt.SET_TOKEN_AND_AMOUNT,token:null,amount:""}})}}),[u,x,r]);const te=s.useMemo((()=>N&&N.token?ee(N.token.symbol,N.token.address):void 0),[N,r,g.conversions,ee]),se=s.useMemo((()=>!r.find((e=>L(e.token.address)))),[r,N,S]),ae=e=>{let t=e;if("."===t&&(t="0."),R(t),_){const e=js(t,N?.formattedBalance);j(e)}var s;N&&(M(B(t,N.token.symbol,g.conversions)),s=!0,Number.isNaN(parseFloat(S))||parseFloat(S)<=0||!N||!c||!c.walletAddress||!d||!d.walletAddress||s&&G||!l||z(!0))};s.useEffect((()=>{h({payload:{type:$e.SET_TOKEN_SYMBOLS,tokenSymbols:i.map((e=>e.symbol))}})}),[h,i]),s.useEffect((()=>{S&&N&&M(B(S,N.token.symbol,g.conversions))}),[S,N]),s.useEffect((()=>{(async()=>{if(!c?.web3Provider)return;const e=await c.web3Provider.getSigner().getAddress();Q((t=>(""!==t&&t!==e&&D(void 0),e)))})()}),[c?.web3Provider,r]);const ne=s.useCallback((()=>{const e=N?"":"views.BRIDGE_FORM.validation.noTokenSelected";const t=js(S,N?.formattedBalance);return e&&P(e),t&&j(t),!e&&!t}),[N,S,P,j]),re=s.useCallback((async()=>{ne()&&l&&c?.web3Provider&&N&&(se?J(!0):(I({userJourney:A.BRIDGE,screen:"TokenAmount",control:"Review",controlType:"Button",extras:{tokenAddress:N.token.address,amount:S}}),a({payload:{type:kt.SET_TOKEN_AND_AMOUNT,token:N.token,amount:S}}),b({payload:{type:C.UPDATE_VIEW,view:{type:ze.BRIDGE_REVIEW}}})))}),[l,c?.web3Provider,ne,se,N]);return o.jsxs(p,{testId:m,sx:Ns,children:[o.jsxs(p,{sx:{paddingX:"base.spacing.x4"},children:[o.jsx(Z,{testId:`${m}-content-heading`,size:"small",weight:"regular",sx:{paddingBottom:"base.spacing.x4"},children:t("views.BRIDGE_FORM.content.title")}),(!E||!T)&&o.jsxs(p,{sx:Ds,children:[o.jsx(et,{testId:"bridge-token",options:V,optionsLoading:T,coinSelectorHeading:t("views.BRIDGE_FORM.bridgeForm.from.selectorTitle"),selectedOption:te,subtext:$,textAlign:"left",errorMessage:t(W),onSelectChange:e=>(e=>{const t=r.find((t=>e===ee(t.token.symbol,t.token.address)));t&&(D(t),P(""))})(e),defaultTokenImage:v}),o.jsx(tt,{testId:"bridge-amount",type:"number",value:S,placeholder:t("views.BRIDGE_FORM.bridgeForm.from.inputPlaceholder"),subtext:`${t("views.BRIDGE_FORM.content.fiatPricePrefix")} $${le(O,!0)}`,validator:de,onTextInputChange:e=>ae(e),onTextInputEnter:re,textAlign:"right",errorMessage:t(_)})]}),E&&T&&o.jsx(Fs,{sx:Ds})]}),o.jsxs(p,{sx:Ws,children:[o.jsx(w,{testId:`${m}-button`,variant:"primary",onClick:re,size:"large",children:t("views.BRIDGE_FORM.bridgeForm.buttonText")}),o.jsx(st,{visible:Y,showHeaderBar:!1,onCloseDrawer:()=>X(!1),onRetry:async()=>{X(!1),await re()}}),o.jsx(Gs,{environment:l.config.environment,visible:K,showHeaderBar:!1,onCloseDrawer:()=>J(!1),walletAddress:q,showAdjustAmount:L(N?.token.address),tokenSymbol:c?.network===F(l?.config)?oe:ue,onAddCoinsClick:()=>{b({payload:{type:C.UPDATE_VIEW,view:{type:xe.TOP_UP_VIEW}}})}})]})]})}const Us=1e4;function $s({amount:e,tokenAddress:t,defaultTokenImage:a}){const{t:r}=n(),{bridgeState:i,bridgeDispatch:l}=s.useContext(Ct),{checkout:c,from:d}=i,{eventTargetState:{eventTarget:u}}=s.useContext(M),[x,p]=s.useState(!1),{page:g}=y();s.useEffect((()=>{(e||t)&&g({userJourney:A.BRIDGE,screen:"TokenAmount",extras:{amount:e,tokenAddress:t}})}),[]);const w=s.useCallback((async()=>{if(c&&d?.web3Provider)try{const e=await at({checkout:c,provider:d.web3Provider,chainId:d?.network,allowTokenListType:z.BRIDGE,retryPolicy:{retryIntervalMs:0,retries:0}});if(void 0===e)return;l({payload:{type:kt.SET_TOKEN_BALANCES,tokenBalances:e.allowedBalances}}),l({payload:{type:kt.SET_ALLOWED_TOKENS,allowedTokens:e.allowList.tokens}})}catch(e){console.debug(e)}}),[c,d?.web3Provider,d?.network]);return Je(w,Us),s.useEffect((()=>{c&&d?.web3Provider&&(p(!0),w().finally((()=>p(!1))))}),[c,d?.web3Provider]),o.jsx(H,{testId:"bridge-view",header:o.jsx(K,{showBack:!0,title:r("views.BRIDGE_FORM.header.title"),onCloseButtonClick:()=>Lt(u)}),footer:o.jsx(J,{}),children:o.jsx(zs,{testId:"bridge-form",defaultAmount:e,defaultTokenAddress:t,isTokenBalancesLoading:x,defaultTokenImage:a})})}const Vs={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px",marginBottom:"2px",position:"relative"},Hs={borderTopLeftRadius:"0px",borderTopRightRadius:"0px",backgroundColor:"base.color.translucent.emphasis.100",position:"relative"},Ks={width:"base.icon.size.400"},Js={position:"absolute",top:"2px",left:"26px",width:"20px",padding:"2px",backgroundColor:"base.color.translucent.inverse.900",borderRadius:"base.borderRadius.x2"},qs={height:"100%",display:"flex",flexDirection:"column",paddingX:"base.spacing.x4"},Qs={paddingTop:"base.spacing.x10",paddingBottom:"base.spacing.x4"},Ys={display:"flex",flexDirection:"column",alignItems:"center",paddingY:"base.spacing.x1"},Xs={width:"base.icon.size.300",transform:"rotate(270deg)"},Zs={width:"base.icon.size.400"},ea=(e,t,s)=>{const a=[];if(!e?.fees||!e.token)return a;let n=pe.from(0);if(e.fees.bridgeFee&&(n=n.add(e.fees.bridgeFee)),e.fees.imtblFee&&(n=n.add(e.fees.imtblFee)),n.gt(0)&&a.push({label:s("drawers.feesBreakdown.fees.serviceFee.label"),fiatAmount:`~ ${s("drawers.feesBreakdown.fees.fiatPricePrefix")}${B(ge(n,e.token.decimals),e.token.symbol,t.conversions)}`,amount:ie(ge(n,e.token.decimals))}),e.fees.sourceChainGas?.gt(0)){const n=ge(e.fees.sourceChainGas,e.token.decimals);a.push({label:s("drawers.feesBreakdown.fees.gasFeeMove.label"),fiatAmount:`~ ${s("drawers.feesBreakdown.fees.fiatPricePrefix")}${B(n,e.token.symbol,t.conversions)}`,amount:`${ie(n)}`,prefix:"~ "})}if(e.fees.approvalFee?.gt(0)){const n=ge(e.fees.approvalFee,e.token.decimals);a.push({label:s("drawers.feesBreakdown.fees.gasFeeApproval.label"),fiatAmount:`~ ${s("drawers.feesBreakdown.fees.fiatPricePrefix")}${B(n,e.token.symbol,t.conversions)}`,amount:`${ie(n)}`,prefix:"~ "})}return a},ta="bridge-review-summary";function sa(){const{t:e}=n(),{viewDispatch:t}=s.useContext(k),{bridgeState:{checkout:a,tokenBridge:i,from:l,to:c,token:d,amount:u},bridgeDispatch:x}=s.useContext(Ct),{track:h}=y(),{cryptoFiatState:b}=s.useContext(Ue),[E,T]=s.useState(!1),[v,I]=s.useState(void 0),[S,N]=s.useState(""),[W,L]=s.useState(""),[P,O]=s.useState(void 0),[M,F]=s.useState(void 0),[z,U]=s.useState(!1),[V,H]=s.useState(void 0),[K,J]=s.useState(void 0),[q,Q]=s.useState(!1),[Y,X]=s.useState(!1),{isWalletConnectEnabled:te,getWalletLogoUrl:se}=R({checkout:a}),ae=s.useMemo((()=>d?.symbol?`${d?.symbol} ${u}`:`${u}`),[d,u]),ne=s.useMemo((()=>u&&d?B(u,d.symbol,b.conversions):""),[d,u]),oe=s.useMemo((()=>l?l.walletAddress:"-"),[l]),re=s.useMemo((()=>_(l?.web3Provider)),[l]),ie=s.useMemo((()=>l&&l.network),[l]),le=_t(re),de=s.useMemo((()=>c?c.walletAddress:"-"),[c]),ue=s.useMemo((()=>_(c?.web3Provider)),[c]),xe=s.useMemo((()=>c?.network),[c]),Te=_t(ue),ve=s.useCallback((async()=>{if(!(i&&u&&l&&c&&d))return;const[e,t]=await Promise.all([i.getUnsignedApproveBridgeTx({senderAddress:oe,token:d.address??ce.toUpperCase(),amount:we(u,d.decimals),sourceChainId:l?.network.toString(),destinationChainId:c?.network.toString()}),i.getUnsignedBridgeTx({senderAddress:oe,recipientAddress:de,token:d.address??ce.toUpperCase(),amount:we(u,d.decimals),sourceChainId:l?.network.toString(),destinationChainId:c?.network.toString(),gasMultiplier:1.1})]);O(e),F(t);const s=t.feeData,{totalFees:n,approvalFee:o}=s;let r=n;e.unsignedTx||(r=n.sub(o),s.approvalFee=pe.from(0));const x={gasEstimateType:he.BRIDGE_TO_L2,fees:{...s,totalFees:r},token:a.config.networkMap.get(l.network)?.nativeCurrency};I(x);const p=ge(x?.fees.totalFees||0,Ee);N(p),L(B(p,x?.token?.symbol||"",b.conversions))}),[a,i]);Je((()=>ve()),be);const ye=s.useCallback((()=>ea(v,b,e)),[v]);s.useEffect((()=>{(async()=>{T(!0),await ve(),T(!1)})()}),[]);const Ie=s.useCallback((e=>{x({payload:{type:kt.SET_WALLETS_AND_NETWORKS,from:{web3Provider:e,walletAddress:l?.walletAddress,network:l?.network},to:{web3Provider:c?.web3Provider,walletAddress:c?.walletAddress,network:c?.network}}})}),[l?.web3Provider,l?.network,c?.web3Provider,c?.network]);s.useEffect((()=>{if(!l?.web3Provider)return;const e=()=>{const e=new $(l?.web3Provider.provider);Ie(e),U(!1)};return me(l?.web3Provider,e),()=>{fe(l?.web3Provider,e)}}),[l?.web3Provider]),s.useEffect((()=>{te&&(Q(j(l?.web3Provider)),X(j(c?.web3Provider)),(async()=>{H(await se()),J(await se())})())}),[te,l,c]);const Ae=s.useCallback((async()=>{if(P&&M){try{const e=await(l?.web3Provider.provider).request({method:"eth_chainId",params:[]});if(parseInt(e.toString())!==l?.network)return void U(!0)}catch(e){console.error("Current network check failed",e)}h({userJourney:A.BRIDGE,screen:"Summary",control:"Submit",controlType:"Button",extras:{fromWalletAddress:oe,fromNetwork:ie,fromWallet:{address:oe,isPassportWallet:G(l?.web3Provider),isMetaMask:ee(l?.web3Provider)},toWalletAddress:de,toNetwork:xe,toWallet:{address:de,isPassportWallet:G(c?.web3Provider),isMetaMask:ee(c?.web3Provider)},amount:u,fiatAmount:ne,tokenAddress:d?.address}}),t({payload:{type:C.UPDATE_VIEW,view:{type:ze.APPROVE_TRANSACTION,approveTransaction:P,transaction:M}}})}}),[t,P,M,l?.web3Provider,l?.network]);return o.jsxs(p,{testId:ta,sx:qs,children:[o.jsx(Z,{testId:`${ta}-heading`,size:"small",weight:"regular",sx:Qs,children:e("views.BRIDGE_REVIEW.heading")}),o.jsxs(r,{testId:`${ta}-from-amount`,size:"small",emphasized:!0,sx:Vs,children:[o.jsx(r.Label,{size:"small",sx:{marginBottom:"base.spacing.x4",fontWeight:"bold"},children:e("views.BRIDGE_REVIEW.fromLabel.amountHeading")}),o.jsx(r.Caption,{}),o.jsx(r.PriceDisplay,{use:o.jsx(Z,{size:"xSmall",weight:"light"}),price:ae??"-",fiatAmount:`${e("views.BRIDGE_REVIEW.fiatPricePrefix")}${ne}`})]}),o.jsxs(r,{testId:`${ta}-from-address`,size:"xSmall",emphasized:!0,sx:Hs,children:[q&&V&&o.jsxs(o.Fragment,{children:[o.jsx(r.FramedImage,{imageUrl:V,alt:"walletconnect",sx:Ks}),o.jsx(D,{logo:"WalletConnectSymbol",sx:Js})]}),re&&!q&&o.jsx(r.FramedLogo,{logo:le,sx:{backgroundColor:"base.color.translucent.standard.200"}}),o.jsxs(r.Label,{children:[o.jsx("strong",{children:e("views.BRIDGE_REVIEW.fromLabel.heading")})," ",o.jsx(g,{size:"small",sx:{color:"base.color.text.body.secondary"},children:xs(oe??"")})]}),ie&&o.jsx(r.IntentIcon,{icon:f[ie],sx:Ss(ie)})]}),o.jsx(p,{sx:Ys,children:o.jsx(m,{icon:"ArrowBackward",sx:Xs})}),o.jsxs(r,{testId:`${ta}-to-address`,size:"xSmall",emphasized:!0,sx:Vs,children:[ue&&Y&&K&&o.jsxs(o.Fragment,{children:[o.jsx(r.FramedImage,{imageUrl:K,alt:"walletconnect",sx:Ks}),o.jsx(D,{logo:"WalletConnectSymbol",sx:Js})]}),ue&&!Y&&o.jsx(r.FramedLogo,{logo:Te,sx:{backgroundColor:"base.color.translucent.standard.200"}}),o.jsxs(r.Label,{children:[o.jsx("strong",{children:e("views.BRIDGE_REVIEW.toLabel.heading")})," ",o.jsx(g,{size:"small",sx:{color:"base.color.text.body.secondary"},children:xs(de??"")})]}),xe&&o.jsx(r.IntentIcon,{icon:f[xe],sx:Ss(xe)})]}),o.jsx(nt,{gasFeeValue:S,gasFeeFiatValue:W,gasFeeToken:v?.token,fees:ye(),onFeesClick:()=>{h({userJourney:A.BRIDGE,screen:"MoveCoins",control:"ViewFees",controlType:"Button"})},sx:{borderTopRightRadius:"0",borderTopLeftRadius:"0"},loading:E}),o.jsx(p,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"flex-end",paddingY:"base.spacing.x6",width:"100%"},children:o.jsx(w,{size:"large",sx:{width:"100%"},onClick:Ae,disabled:E,testId:`${ta}__submit-button`,children:E?o.jsx(w.Icon,{icon:"Loading",sx:Zs}):e("views.BRIDGE_REVIEW.submitButton.buttonText")})}),o.jsx(ot,{visible:z,targetChainId:l?.network,provider:l?.web3Provider,checkout:a,onCloseDrawer:()=>U(!1),onNetworkSwitch:Ie})]})}function aa(){const{t:e}=n(),{eventTargetState:{eventTarget:t}}=s.useContext(M),{page:a}=y();return s.useEffect((()=>{a({userJourney:A.BRIDGE,screen:"Review"})}),[]),o.jsx(H,{testId:"bridge-review",header:o.jsx(K,{showBack:!0,title:e("views.BRIDGE_REVIEW.layoutHeading"),onCloseButtonClick:()=>Lt(t)}),footer:o.jsx(J,{}),children:o.jsx(sa,{})})}function na({environment:e}){const{RiveComponent:t}=Te.useRive({src:`${ve[e]}/v1/blob/img/rocket.riv`,autoplay:!0,layout:new Te.Layout({fit:Te.Fit.Cover}),stateMachines:"State Machine 1"});return o.jsx(p,{sx:{...ye,background:"base.color.translucent.emphasis.100"},children:o.jsx(p,{sx:Ie,rc:o.jsx(t,{})})})}function oa({transactionHash:e}){const{t:t}=n(),{eventTargetState:{eventTarget:a}}=s.useContext(M),{page:r}=y(),{cryptoFiatState:i}=s.useContext(Ue),{viewDispatch:l}=s.useContext(k),{bridgeState:{checkout:c,from:d,to:u,token:x,amount:p}}=s.useContext(Ct);return s.useEffect((()=>{Wt(a,e);const t=B(p,x?.symbol??"",i.conversions);r({userJourney:A.BRIDGE,screen:"InProgress",extras:{fromWalletAddress:d?.walletAddress,toWalletAddress:u?.walletAddress,amount:p,fiatAmount:t,tokenAddress:x?.address}})}),[]),o.jsx(H,{testId:"move-in-progress-view",header:o.jsx(K,{transparent:!0,onCloseButtonClick:()=>Lt(a),rightActions:o.jsxs(o.Fragment,{children:[o.jsx(te,{icon:"Minting",sx:se(),onClick:()=>{l({payload:{type:C.UPDATE_VIEW,view:{type:ze.TRANSACTIONS}}})},testId:"settings-button"}),o.jsx(Ae,{isAnimated:!0,variant:"guidance",sx:{position:"absolute",right:"base.spacing.x14",top:"base.spacing.x1"}})]})}),footer:o.jsx(J,{}),heroContent:o.jsx(na,{environment:c.config.environment}),floatHeader:!0,children:o.jsxs(Se,{heading:t("views.IN_PROGRESS.heading"),children:[t("views.IN_PROGRESS.body1"),o.jsx("br",{}),o.jsx("br",{}),t("views.IN_PROGRESS.body2")]})})}function ra({approveTransaction:e,transaction:t}){const{t:a}=n(),{bridgeState:r}=s.useContext(Ct),{checkout:i,from:l}=r,{viewDispatch:c}=s.useContext(k),{eventTargetState:{eventTarget:d}}=s.useContext(M),{page:u}=y();s.useEffect((()=>{u({userJourney:A.BRIDGE,screen:"ApproveTransaction"})}),[]);const[x,g]=s.useState(!1),[w,h]=s.useState(!1),[b,m]=s.useState(!1),[f,E]=s.useState(!1),T=s.useCallback((()=>{c({payload:{type:C.UPDATE_VIEW,view:{type:xe.ERROR_VIEW,error:new Error("No checkout object or no provider object found")}}})}),[c]),v=s.useCallback((()=>{c({payload:{type:C.GO_BACK}})}),[c]),I=e=>{if(e.type!==ke.UNPREDICTABLE_GAS_LIMIT){if(e.type===ke.TRANSACTION_FAILED||e.type===ke.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status){let t="Transaction failed";return e.type===ke.INSUFFICIENT_FUNDS&&(t="Insufficient funds"),e.receipt&&0===e.receipt.status&&(t="Transaction failed to settle on chain"),void c({payload:{type:C.UPDATE_VIEW,view:{type:ze.BRIDGE_FAILURE,reason:t}}})}c({payload:{type:C.UPDATE_VIEW,view:{type:xe.ERROR_VIEW,error:e}}})}else c({payload:{type:C.UPDATE_VIEW,view:{type:ze.BRIDGE_FAILURE,reason:"Unpredictable gas limit"}}})},S=s.useCallback((async()=>{let s=!1;if(i&&l?.web3Provider&&t){if(!x){if(g(!0),e.unsignedTx)try{h(!0);const t=await i.sendTransaction({provider:l.web3Provider,transaction:e.unsignedTx});if(1!==(await t.transactionResponse.wait()).status)return void c({payload:{type:C.UPDATE_VIEW,view:{type:ze.BRIDGE_FAILURE,reason:"Transaction failed to settle on chain"}}})}catch(e){h(!1),e.type===ke.USER_REJECTED_REQUEST_ERROR?(E(!0),s=!0):I(e)}finally{g(!1)}try{if(s)return;h(!0);const e=await i.sendTransaction({provider:l.web3Provider,transaction:t.unsignedTx});m(!0);const a=await e.transactionResponse.wait();if(0===a.status)return void c({payload:{type:C.UPDATE_VIEW,view:{type:ze.BRIDGE_FAILURE,reason:"Approval transaction failed to settle on chain"}}});c({payload:{type:C.UPDATE_VIEW,view:{type:ze.IN_PROGRESS,transactionHash:a.transactionHash}}})}catch(e){e.type===ke.USER_REJECTED_REQUEST_ERROR?E(!0):I(e)}finally{m(!1),h(!1),g(!1)}}}else T()}),[i,l,T,c,t,e,x]);return o.jsxs(o.Fragment,{children:[b&&o.jsx(Y,{loadingText:a("views.APPROVE_TRANSACTION.loadingView.text"),showFooterLogo:!0}),!b&&o.jsx(H,{header:o.jsx(K,{transparent:!0,showBack:!0,onCloseButtonClick:()=>Lt(d),onBackButtonClick:v}),floatHeader:!0,heroContent:o.jsx(rt,{}),footer:o.jsxs(p,{sx:{width:"100%",flexDirection:"column"},children:[o.jsx(Ce,{loading:w,actionText:a("views.APPROVE_TRANSACTION."+(f?"footer.retryText":"footer.buttonText")),onActionClick:S}),o.jsx(J,{})]}),children:o.jsx(Se,{heading:a("views.APPROVE_TRANSACTION.content.heading"),children:o.jsx(p,{children:a("views.APPROVE_TRANSACTION.content.body")})})})]})}const ia={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x1",height:"100%"},la={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"15px"},ca={display:"flex",flexDirection:"column",justifyContent:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},da={width:"100%",height:"base.spacing.x16"};function ua({visible:e,onClose:t,onChangeAccount:a}){const{t:r}=n(),{bridgeState:{checkout:l}}=s.useContext(Ct),c=ae(l.config.environment);return o.jsx(i,{headerBarTitle:void 0,size:"full",onCloseDrawer:t,visible:e,showHeaderBar:!1,children:o.jsx(i.Content,{children:o.jsxs(p,{testId:"not-enough-eth-drawer",sx:ia,children:[o.jsx(re,{imageUrl:c,sx:{w:"base.icon.size.600",h:"base.icon.size.600"}}),o.jsx(Z,{size:"small",sx:la,testId:"not-enough-gas-heading",children:`${r("drawers.notEnoughEthWithdrawal.content.heading1")} ${oe} ${r("drawers.notEnoughEthWithdrawal.content.heading2")}`}),o.jsx(g,{sx:la,children:`${r("drawers.notEnoughEthWithdrawal.content.body1")} ${oe} ${r("drawers.notEnoughEthWithdrawal.content.body2")}`}),o.jsxs(p,{sx:ca,children:[o.jsx(w,{testId:"not-enough-eth-drawer-retry-button",sx:da,variant:"tertiary",onClick:a,children:r("drawers.notEnoughEthWithdrawal.buttons.retry")}),o.jsx(w,{sx:da,variant:"tertiary",onClick:t,testId:"not-enough-eth-drawer-dismiss-button",children:r("drawers.notEnoughEthWithdrawal.buttons.dismiss")})]})]})})})}function xa({transaction:e}){const{t:t}=n(),{bridgeState:{checkout:r,tokenBridge:i,from:l}}=s.useContext(Ct),{viewDispatch:c}=s.useContext(k),{eventTargetState:{eventTarget:d}}=s.useContext(M),{page:u}=y();s.useEffect((()=>{u({userJourney:A.BRIDGE,screen:"ClaimWithdrawal"})}),[]);const[x,g]=s.useState(!1),[h,b]=s.useState(!1),[m,f]=s.useState(!1),[E,T]=s.useState(),[I,S]=s.useState(!1),R=s.useCallback((()=>{c({payload:{type:C.GO_BACK}})}),[c]);s.useEffect((()=>{(async()=>{if(i&&e&&void 0!==e.details.current_status?.index){b(!0);try{const t=await(i?.getFlowRateWithdrawTx({recipient:e.details.to_address,index:e.details.current_status.index}));T(t)}catch(e){console.log(e)}finally{b(!1)}}})()}),[i,e]);const _=s.useCallback((async({forceChangeAccount:e})=>{if(!(r&&i&&l?.web3Provider&&E))return;if(!E.pendingWithdrawal.canWithdraw||!E.unsignedTx)return void console.log(`Unable to process withdrawal transaction as it is not ready yet. Delay timeout at ${E.pendingWithdrawal.timeoutEnd} `);let t=l?.web3Provider;const s=F(r.config);if(g(!0),G(l?.web3Provider)||e)try{const e=await r.createProvider({walletProviderName:a.METAMASK});t=(await r.connect({provider:e.provider,requestWalletPermissions:!0})).provider,S(!1)}catch(e){return console.log(e),f(!0),void g(!1)}let n,o=null;try{try{n=await t.estimateGas(E.unsignedTx)}catch(e){n=pe.from(Re)}let e=null;try{e=await t.getFeeData()}catch(e){console.log(e)}let s=null;e&&e.lastBaseFeePerGas&&e.maxPriorityFeePerGas?s=e.lastBaseFeePerGas.add(e.maxPriorityFeePerGas):e&&e.gasPrice&&(s=e.gasPrice),s&&(o=n.mul(s))}catch(e){console.log(e)}try{const e=(await r.getAllBalances({provider:t,chainId:s})).balances.find((e=>L(e.token.address)));if(!e||e.balance.lt(o))return S(!0),void g(!1)}catch(e){console.log(e)}if((await t.getNetwork()).chainId!==s)try{t=(await r.switchNetwork({provider:t,chainId:s})).provider}catch(e){return f(!0),b(!1),void console.log(e)}try{const e=await r.sendTransaction({provider:t,transaction:E.unsignedTx});c({payload:{type:C.UPDATE_VIEW,view:{type:ze.CLAIM_WITHDRAWAL_IN_PROGRESS,transactionResponse:e.transactionResponse}}})}catch(e){console.log(e),f(!0),g(!1)}finally{g(!1)}}),[i,l,E]);return o.jsxs(H,{testId:"claim-withdrawal",header:o.jsx(K,{transparent:!0,showBack:!0,onCloseButtonClick:()=>Lt(d),onBackButtonClick:R}),floatHeader:!0,heroContent:o.jsx(rt,{}),footer:o.jsxs(p,{sx:{width:"100%",display:"flex",flexDirection:"column"},children:[o.jsx(p,{sx:{pb:"base.spacing.x5",px:"base.spacing.x6",width:"100%",display:"flex",flexDirection:"column"},children:o.jsx(w,{testId:"claim-withdrawal-continue-button",size:"large",variant:"primary",disabled:h,onClick:()=>x||h?void 0:_({forceChangeAccount:!0}),children:h||x?o.jsx(w.Icon,{icon:"Loading",sx:{width:"base.icon.size.400"}}):t("views.CLAIM_WITHDRAWAL."+(m?"footer.retryText":"footer.buttonText"))})}),o.jsx(J,{})]}),children:[o.jsxs(Se,{heading:`${t("views.CLAIM_WITHDRAWAL.content.heading")} ${Ze(F(r.config))}`,children:[o.jsx(p,{sx:{display:"flex",flexWrap:"wrap",pb:"base.spacing.x1"},children:t("views.CLAIM_WITHDRAWAL.content.body")}),o.jsxs(p,{children:[t("views.CLAIM_WITHDRAWAL.content.body2"),o.jsx(v,{text:e.details.to_address.toLowerCase()??""})]})]}),o.jsx(ua,{visible:I,onClose:()=>S(!1),onChangeAccount:()=>_({forceChangeAccount:!0})})]})}function pa({checkout:e,web3Provider:t,config:a,amount:r,tokenAddress:i}){const{t:l}=n(),{environment:u,isOnRampEnabled:x,isSwapEnabled:p,isBridgeEnabled:g,theme:w}=a,h=_e(e.config.environment,w),{eventTargetState:{eventTarget:b}}=s.useContext(M),{page:m}=y(),[f,E]=s.useReducer(je,{...Ne,view:{type:ze.WALLET_NETWORK_SELECTION},history:[{type:ze.WALLET_NETWORK_SELECTION}]}),[T,v]=s.useReducer(Rt,{...St,checkout:e,web3Provider:t??null,tokenBridge:(()=>{let t=Me;e.config.isDevelopment&&(t=Ge),e.config.isProduction&&(t=Fe);const s=new q(e.config.networkMap.get(F(e.config))?.rpcUrls[0]),a=new q(e.config.networkMap.get(U(e.config))?.rpcUrls[0]),n=new De({baseConfig:new We({environment:e.config.environment}),bridgeInstance:t,rootProvider:s,childProvider:a});return new Le(n)})()}),I=s.useMemo((()=>({viewState:f,viewDispatch:E})),[f,E]),S=s.useMemo((()=>({bridgeState:T,bridgeDispatch:v})),[T,v]),R=s.useCallback((()=>{v({payload:{type:kt.SET_WALLETS_AND_NETWORKS,from:null,to:null}}),v({payload:{type:kt.SET_TOKEN_AND_AMOUNT,amount:"",token:null}}),E({payload:{type:C.GO_BACK_TO,view:{type:ze.WALLET_NETWORK_SELECTION}}})}),[E]),_=s.useCallback((()=>{E({payload:{type:C.GO_BACK_TO,view:{type:ze.WALLET_NETWORK_SELECTION}}})}),[E]),j=s.useCallback((()=>{E({payload:{type:C.UPDATE_VIEW,view:{type:ze.TRANSACTIONS}}})}),[E]),N=s.useCallback((()=>{E({payload:{type:C.GO_BACK_TO,view:{type:ze.BRIDGE_REVIEW}}})}),[E]);return s.useEffect((()=>{(async()=>{v({payload:{type:kt.SET_PROVIDER,web3Provider:t??null}})})()}),[t]),o.jsx(k.Provider,{value:I,children:o.jsx(Ct.Provider,{value:S,children:o.jsxs(Ve,{environment:u,children:[f.view.type===ze.WALLET_NETWORK_SELECTION&&o.jsx(_s,{}),f.view.type===ze.BRIDGE_FORM&&o.jsx($s,{amount:r,tokenAddress:i,defaultTokenImage:h}),f.view.type===ze.BRIDGE_REVIEW&&o.jsx(aa,{}),f.view.type===ze.IN_PROGRESS&&o.jsx(oa,{transactionHash:f.view.transactionHash}),f.view.type===ze.BRIDGE_FAILURE&&o.jsx(Pe,{testId:"bridge-fail",statusText:l("views.BRIDGE_FAILURE.bridgeFailureText.statusText"),actionText:l("views.BRIDGE_FAILURE.bridgeFailureText.actionText"),onActionClick:N,statusType:Oe.FAILURE,onRenderEvent:()=>{let e="";f.view.type===ze.BRIDGE_FAILURE&&(e=f.view.reason),m({userJourney:A.BRIDGE,screen:"Failed",extras:{reason:e}}),((e,t)=>{const s=new CustomEvent(c.IMTBL_BRIDGE_WIDGET_EVENT,{detail:{type:d.FAILURE,data:{reason:t,timestamp:(new Date).getTime()}}});console.log("bridge failed ",e,s),void 0!==e&&e.dispatchEvent(s)})(b,e)}}),f.view.type===ze.APPROVE_TRANSACTION&&o.jsx(ra,{approveTransaction:f.view.approveTransaction,transaction:f.view.transaction}),f.view.type===ze.TRANSACTIONS&&o.jsx(ds,{onBackButtonClick:_,defaultTokenImage:h}),f.view.type===ze.CLAIM_WITHDRAWAL&&o.jsx(xa,{transaction:f.view.transaction}),f.view.type===xe.ERROR_VIEW&&o.jsx(Be,{actionText:l("views.ERROR_VIEW.actionText"),onActionClick:R,onCloseClick:()=>Lt(b),errorEventAction:()=>{m({userJourney:A.BRIDGE,screen:"Error"})}}),f.view.type===xe.TOP_UP_VIEW&&o.jsx(He,{analytics:{userJourney:A.BRIDGE},widgetEvent:c.IMTBL_BRIDGE_WIDGET_EVENT,checkout:e,provider:t,showOnrampOption:x,showSwapOption:p,showBridgeOption:g,onCloseButtonClick:()=>Lt(b)}),f.view.type===ze.CLAIM_WITHDRAWAL_IN_PROGRESS&&o.jsx(us,{transactionResponse:f.view.transactionResponse}),f.view.type===ze.CLAIM_WITHDRAWAL_SUCCESS&&o.jsx(Pe,{statusText:l("views.CLAIM_WITHDRAWAL.IN_PROGRESS.success.text"),actionText:l("views.CLAIM_WITHDRAWAL.IN_PROGRESS.success.actionText"),onRenderEvent:()=>{m({userJourney:A.BRIDGE,screen:"ClaimWithdrawalSuccess"}),((e,t)=>{const s=new CustomEvent(c.IMTBL_BRIDGE_WIDGET_EVENT,{detail:{type:d.CLAIM_WITHDRAWAL_SUCCESS,data:{transactionHash:t}}});console.log("bridge claim withdrawal success event:",e,s),void 0!==e&&e.dispatchEvent(s)})(b,f.view.transactionHash)},onActionClick:j,statusType:Oe.SUCCESS,testId:"claim-withdrawal-success-view"}),f.view.type===ze.CLAIM_WITHDRAWAL_FAILURE&&o.jsx(Pe,{statusText:l("views.CLAIM_WITHDRAWAL.IN_PROGRESS.failure.text"),actionText:l("views.CLAIM_WITHDRAWAL.IN_PROGRESS.failure.actionText"),onRenderEvent:()=>{let e="";f.view.type===ze.CLAIM_WITHDRAWAL_FAILURE&&(e=f.view.reason),m({userJourney:A.BRIDGE,screen:"ClaimWithdrawalFailure",extras:{reason:e}}),((e,t,s)=>{const a=new CustomEvent(c.IMTBL_BRIDGE_WIDGET_EVENT,{detail:{type:d.CLAIM_WITHDRAWAL_FAILURE,data:{transactionHash:t,reason:s,timestamp:(new Date).getTime()}}});console.log("bridge claim withdrawal failed event:",e,a),void 0!==e&&e.dispatchEvent(a)})(b,f.view.transactionHash,"Transaction failed")},onActionClick:j,statusType:Oe.FAILURE,onCloseClick:()=>Lt(b),testId:"claim-withdrawal-fail-view"})]})})})}export{pa as default};
|